New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@benev/slate

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@benev/slate - npm Package Compare versions

Comparing version 0.0.0-dev.20 to 0.0.0-dev.21

s/shiny/parts/use/parts/helpers.ts

2

package.json
{
"name": "@benev/slate",
"version": "0.0.0-dev.20",
"version": "0.0.0-dev.21",
"description": "frontend web stuff",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -39,5 +39,5 @@

```ts
import {prepare_frontend, Context} from "@benev/slate"
import {setup, Context} from "@benev/slate"
export const slate = prepare_frontend(
export const slate = setup(
new class extends Context {

@@ -65,3 +65,3 @@ theme = css`

### carbon — *shadow-dom component*
### `slate.shadow_component` — *"carbon"*

@@ -71,3 +71,3 @@ ```ts

export const MyCarbon = slate.carbon({styles}, use => {
export const MyCarbon = slate.shadow_component({styles}, use => {
const count = use.signal(0)

@@ -83,6 +83,6 @@ const increment = () => count.value++

### oxygen — *light-dom component*
### `slate.light_component` — *"oxygen"*
```ts
export const MyOxygen = slate.oxygen(use => {
export const MyOxygen = slate.light_component(use => {
const count = use.signal(0)

@@ -126,3 +126,3 @@ const increment = () => count.value++

### obsidian — *shadow-dom view*
### `slate.shadow_view` — *"obsidian"*

@@ -132,3 +132,3 @@ ```ts

export const MyObsidian = slate.obsidian({styles}, use => (start: number) => {
export const MyObsidian = slate.shadow_view({styles}, use => (start: number) => {
const count = use.signal(start)

@@ -149,6 +149,6 @@ const increment = () => count.value++

### quartz — *light-dom view*
### `slate.light_view` — *"quartz"*
```ts
export const MyQuartz = slate.quartz(use => (start: number) => {
export const MyQuartz = slate.light_view(use => (start: number) => {
const count = use.signal(start)

@@ -394,3 +394,3 @@ const increment = () => count.value++

```ts
export const slate = prepare_frontend(new class extends Context {
export const slate = setup(new class extends Context {
my_cool_thing = {my_awesome_data: 123}

@@ -407,3 +407,3 @@ })

export slate = prepare_frontend<MyContext>()
export slate = setup<MyContext>()

@@ -410,0 +410,0 @@ //

import {CSSResultGroup} from "lit"
import {setup} from "../shiny/frontend.js"
import {Context} from "../shiny/context.js"
import {prepare_frontend} from "../shiny/frontend.js"

@@ -12,3 +12,3 @@ export class DemoContext extends Context {

export const slate = prepare_frontend<DemoContext>()
export const slate = setup<DemoContext>()

@@ -17,3 +17,3 @@

export * from "./shiny/parts/use/tailored.js"
export * from "./shiny/parts/use/parts/initiator.js"
export * from "./shiny/parts/use/parts/helpers.js"
export * from "./shiny/parts/use/parts/types.js"

@@ -20,0 +20,0 @@ export * from "./shiny/parts/use/parts/use.js"

@@ -11,5 +11,5 @@

export type SlateFor<C extends Context> = ReturnType<typeof prepare_frontend<C>>
export type SlateFor<C extends Context> = ReturnType<typeof setup<C>>
export function prepare_frontend<C extends Context>(context?: C) {
export function setup<C extends Context>(context?: C) {
const shell = new Shell<C>(context)

@@ -45,6 +45,6 @@

lightComponent: oxygen,
shadowComponent: carbon,
lightView: quartz,
shadowView: obsidian,
light_component: oxygen,
shadow_component: carbon,
light_view: quartz,
shadow_view: obsidian,

@@ -51,0 +51,0 @@ components: <E extends BaseElementClasses>(elements: E) => (

export type Setdown = () => void
export type Setup = () => Setdown
export type SetupFn = () => Setdown
export type InitResult<R> = [R, Setdown]
export type InitFunction<R> = () => InitResult<R>
export type InitFn<R> = () => InitResult<R>
import {Context} from "../../../context.js"
import {InitFn, SetupFn, Setdown} from "./types.js"
import {Signal} from "../../../../signals/signal.js"
import {maptool} from "../../../../tools/maptool.js"
import {InitFunction, Setdown, Setup} from "./types.js"
import {OpSignal} from "../../../../signals/op_signal.js"

@@ -48,6 +48,6 @@

#setups = new Map<number, Setup>()
#setups = new Map<number, SetupFn>()
#setdowns = new Set<Setdown>()
#initStarts = new Map<number, InitFunction<any>>()
#initStarts = new Map<number, InitFn<any>>()
#initResults = new Map<number, any>()

@@ -74,15 +74,15 @@ #initDowns = new Set<Setdown>()

setup(up: Setup) {
setup(func: SetupFn) {
const count = this.#counter.pull()
if (!this.#setups.has(count)) {
this.#setups.set(count, up)
this.#setdowns.add(up())
this.#setups.set(count, func)
this.#setdowns.add(func())
}
}
init<R>(start: InitFunction<R>): R {
init<R>(func: InitFn<R>): R {
const count = this.#counter.pull()
if (!this.#initStarts.has(count)) {
this.#initStarts.set(count, start)
const [result, down] = start()
this.#initStarts.set(count, func)
const [result, down] = func()
this.#initResults.set(count, result)

@@ -89,0 +89,0 @@ this.#initDowns.add(down)

@@ -364,3 +364,3 @@ import { CSSResultGroup } from "lit";

}>) => import("lit-html/directive.js").DirectiveResult<any>;
lightComponent: (renderer: import("../index.js").OxygenRenderer<DemoContext>) => {
light_component: (renderer: import("../index.js").OxygenRenderer<DemoContext>) => {
new (): {

@@ -712,5 +712,5 @@ [x: string]: any;

};
shadowComponent: (settings: import("../index.js").ShadowSettings, renderer: import("../index.js").CarbonRenderer<DemoContext>) => typeof import("../index.js").GoldElement;
lightView: <P extends any[]>(renderer: import("../index.js").QuartzRenderer<DemoContext, P>) => (...props: P) => import("lit-html/directive.js").DirectiveResult<any>;
shadowView: <P_1 extends any[]>(settings: import("../index.js").ShadowSettings | undefined, renderer: import("../index.js").ObsidianRenderer<DemoContext, P_1>) => (props: P_1, meta?: Partial<{
shadow_component: (settings: import("../index.js").ShadowSettings, renderer: import("../index.js").CarbonRenderer<DemoContext>) => typeof import("../index.js").GoldElement;
light_view: <P extends any[]>(renderer: import("../index.js").QuartzRenderer<DemoContext, P>) => (...props: P) => import("lit-html/directive.js").DirectiveResult<any>;
shadow_view: <P_1 extends any[]>(settings: import("../index.js").ShadowSettings | undefined, renderer: import("../index.js").ObsidianRenderer<DemoContext, P_1>) => (props: P_1, meta?: Partial<{
content: import("lit-html").TemplateResult;

@@ -717,0 +717,0 @@ auto_exportparts: boolean;

@@ -0,3 +1,3 @@

import { setup } from "../shiny/frontend.js";
import { Context } from "../shiny/context.js";
import { prepare_frontend } from "../shiny/frontend.js";
export class DemoContext extends Context {

@@ -10,3 +10,3 @@ theme;

}
export const slate = prepare_frontend();
export const slate = setup();
//# sourceMappingURL=frontend.js.map

@@ -12,3 +12,3 @@ export * from "./base/addons/attributes.js";

export * from "./shiny/parts/use/tailored.js";
export * from "./shiny/parts/use/parts/initiator.js";
export * from "./shiny/parts/use/parts/helpers.js";
export * from "./shiny/parts/use/parts/types.js";

@@ -15,0 +15,0 @@ export * from "./shiny/parts/use/parts/use.js";

@@ -12,3 +12,3 @@ export * from "./base/addons/attributes.js";

export * from "./shiny/parts/use/tailored.js";
export * from "./shiny/parts/use/parts/initiator.js";
export * from "./shiny/parts/use/parts/helpers.js";
export * from "./shiny/parts/use/parts/types.js";

@@ -15,0 +15,0 @@ export * from "./shiny/parts/use/parts/use.js";

@@ -33,611 +33,2 @@

class Locker {
#locked = false;
lock(fun) {
this.#locked = true;
fun();
this.#locked = false;
}
get locked() {
return this.#locked;
}
}
const make_map = () => new Map();
const make_set = () => new Set();
function maptool(map) {
return new MapTool(map);
}
class MapTool {
map;
constructor(map) {
this.map = map;
}
grab(key, make) {
const { map } = this;
if (map.has(key))
return map.get(key);
else {
const value = make();
map.set(key, value);
return value;
}
}
}
class Tracker {
#tracking = new WeakMap();
grab_keymap(state) {
const keymap = maptool(this.#tracking).grab(state, make_map);
return {
keymap,
grab_symbolmap(key) {
return maptool(keymap).grab(key, make_map);
},
};
}
clear() {
this.#tracking = new WeakMap();
}
}
class Stopper {
#map = new Map;
stop(symbol) {
const stop = this.#map.get(symbol);
if (stop) {
this.#map.delete(symbol);
stop();
}
}
add(symbol, fun) {
this.#map.set(symbol, fun);
}
}
class Recorder {
#recordings = [];
record(fun) {
const recording = make_map();
this.#recordings.push(recording);
fun();
this.#recordings.pop();
return recording;
}
record_that_key_was_accessed(state, key) {
const recording = this.#recordings.at(-1);
if (recording) {
const keyset = maptool(recording).grab(state, make_set);
keyset.add(key);
}
}
}
class FlatstateError extends Error {
name = this.constructor.name;
}
class CircularFlatstateError extends FlatstateError {
constructor(key) {
super(`forbidden circularity, rejected assignment to "${key}"`);
}
}
class ReadonlyError extends FlatstateError {
constructor(key) {
super(`forbidden assignment to readonly property "${key}"`);
}
}
function readonly(s) {
return new Proxy(s, {
get(target, key) {
return target[key];
},
set(_, key) {
throw new ReadonlyError(key);
},
});
}
function debounce(delay, action) {
let latestArgs;
let timeout;
let waitingQueue = [];
function reset() {
latestArgs = [];
if (timeout)
clearTimeout(timeout);
timeout = undefined;
waitingQueue = [];
}
reset();
return ((...args) => {
latestArgs = args;
if (timeout)
clearTimeout(timeout);
const promise = new Promise((resolve, reject) => {
waitingQueue.push({ resolve, reject });
});
timeout = setTimeout(() => {
Promise.resolve()
.then(() => action(...latestArgs))
.then(r => {
for (const { resolve } of waitingQueue)
resolve(r);
reset();
})
.catch(err => {
for (const { reject } of waitingQueue)
reject(err);
reset();
});
}, delay);
return promise;
});
}
class Scheduler {
#queue = new Map();
#wait = Promise.resolve();
#actuate = debounce(0, () => {
const functions = [...this.#queue.values()];
this.#queue.clear();
for (const fun of functions)
fun();
});
get wait() {
return this.#wait;
}
add(symbol, fun) {
this.#queue.set(symbol, fun);
this.#wait = this.#actuate();
}
}
function collectivize(state) {
return function (collector) {
return () => {
const s = typeof state === "function"
? state()
: state;
return collector(s);
};
};
}
function save_reaction(symbol, recording, tracker, reaction) {
const stoppers = [];
for (const [state, keyset] of recording) {
const { grab_symbolmap } = tracker.grab_keymap(state);
for (const key of keyset) {
const symbolmap = grab_symbolmap(key);
symbolmap.set(symbol, reaction);
stoppers.push(() => symbolmap.delete(symbol));
}
}
return () => stoppers.forEach(stop => stop());
}
function proxy_handlers(tracker, recorder, locker, stopper, scheduler) {
function respond_and_run_discovery([symbol, reaction]) {
locker.lock(reaction.responder);
if (reaction.discover) {
stopper.stop(symbol);
const recorded = recorder.record(() => locker.lock(reaction.collector));
stopper.add(symbol, save_reaction(symbol, recorded, tracker, reaction));
}
}
return {
get: (state, key) => {
recorder.record_that_key_was_accessed(state, key);
return state[key];
},
set: (state, key, value) => {
if (locker.locked)
throw new CircularFlatstateError(key);
state[key] = value;
const reactions = [...tracker.grab_keymap(state).grab_symbolmap(key)];
for (const entry of reactions) {
const [symbol, reaction] = entry;
if (reaction.debounce)
scheduler.add(symbol, () => respond_and_run_discovery(entry));
else
respond_and_run_discovery(entry);
}
return true;
},
};
}
class Flat {
static readonly = readonly;
static collectivize = collectivize;
#tracker = new Tracker();
#recorder = new Recorder();
#locker = new Locker();
#stopper = new Stopper();
#scheduler = new Scheduler();
#proxy_handlers = proxy_handlers(this.#tracker, this.#recorder, this.#locker, this.#stopper, this.#scheduler);
get wait() {
return this.#scheduler.wait;
}
state(state) {
return new Proxy(state, this.#proxy_handlers);
}
manual(reaction) {
const symbol = Symbol();
const recorded = this.#recorder.record(() => this.#locker.lock(reaction.collector));
this.#stopper.add(symbol, save_reaction(symbol, recorded, this.#tracker, reaction));
return () => this.#stopper.stop(symbol);
}
auto({ debounce, discover, collector, responder }) {
return this.manual({
debounce,
discover,
collector,
responder: responder
? () => responder(collector())
: collector,
});
}
reaction(collector, responder) {
return this.auto({
debounce: true,
discover: false,
collector,
responder,
});
}
deepReaction(collector, responder) {
return this.auto({
debounce: true,
discover: true,
collector,
responder,
});
}
clear() {
this.#tracker.clear();
}
}
var ob;
(function (ob) {
ob.map = (o, transform) => (Object.fromEntries(Object.entries(o)
.map(([key, value]) => [key, transform(value, key)])));
ob.filter = (o, judge) => Object.fromEntries(Object.entries(o)
.filter(([key, value]) => judge(value, key)));
(function (pipe) {
pipe.map = (transform) => ((o) => ob.map(o, transform));
pipe.filter = (transform) => ((o) => ob.filter(o, transform));
})(ob.pipe || (ob.pipe = {}));
})(ob || (ob = {}));
class SignalCircularError extends Error {
name = this.constructor.name;
}
class Signal {
#value;
#lock = false;
#wait;
#listeners = new Set();
accessed = false;
constructor(v) {
this.#value = v;
this.#wait = Promise.resolve(v);
}
subscribe(listener) {
this.#listeners.add(listener);
return () => void this.#listeners.delete(listener);
}
once(listener) {
const actual_listener = v => {
listener(v);
this.#listeners.delete(actual_listener);
};
this.#listeners.add(actual_listener);
return () => void this.#listeners.delete(actual_listener);
}
clear() {
return this.#listeners.clear();
}
#invoke_listeners = debounce(0, () => {
const value = this.#value;
this.#lock = true;
for (const listener of this.#listeners)
listener(value);
this.#lock = false;
return value;
});
async publish() {
this.#wait = this.#invoke_listeners();
await this.#wait;
}
get wait() {
return this.#wait;
}
get value() {
this.accessed = true;
return this.#value;
}
set value(s) {
if (this.#lock)
throw new SignalCircularError("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");
this.#value = s;
this.publish();
}
}
const JsError = Error;
var Op;
(function (Op) {
Op.loading = () => ({ mode: "loading" });
Op.error = (reason) => ({ mode: "error", reason });
Op.ready = (payload) => ({ mode: "ready", payload });
Op.is = Object.freeze({
loading: (op) => op.mode === "loading",
error: (op) => op.mode === "error",
ready: (op) => op.mode === "ready",
});
function payload(op) {
return (op.mode === "ready")
? op.payload
: undefined;
}
Op.payload = payload;
function select(op, choices) {
switch (op.mode) {
case "loading":
return choices.loading();
case "error":
return choices.error(op.reason);
case "ready":
return choices.ready(op.payload);
default:
console.error("op", op);
throw new JsError("invalid op mode");
}
}
Op.select = select;
async function run(set_op, operation) {
set_op(Op.loading());
try {
const payload = await operation();
set_op(Op.ready(payload));
return payload;
}
catch (err) {
const reason = (err instanceof JsError)
? err.message
: (typeof err === "string")
? err
: "error";
set_op(Op.error(reason));
}
}
Op.run = run;
function morph(op, transmute) {
return select(op, {
loading: () => Op.loading(),
error: reason => Op.error(reason),
ready: a => Op.ready(transmute(a)),
});
}
Op.morph = morph;
})(Op || (Op = {}));
class OpSignal extends Signal {
constructor() {
super(Op.loading());
}
async run(operation) {
return Op.run(op => this.value = op, operation);
}
setLoading() {
this.value = Op.loading();
}
setError(reason) {
this.value = Op.error(reason);
}
setReady(payload) {
this.value = Op.ready(payload);
}
get loading() {
return Op.is.loading(this.value);
}
get error() {
return Op.is.error(this.value);
}
get ready() {
return Op.is.ready(this.value);
}
get payload() {
return Op.payload(this.value);
}
select(choices) {
return Op.select(this.value, choices);
}
}
class SignalTower {
// TODO wrap all signals in WeakRef, to promote garbage collection?
#signals = new Set();
#waiters = new Set();
signal(value) {
const signal = new Signal(value);
this.#signals.add(signal);
return signal;
}
computed(fun) {
const signal = this.signal(fun());
this.track(() => { signal.value = fun(); });
return signal;
}
op() {
const signal = new OpSignal();
this.#signals.add(signal);
return signal;
}
many(states) {
return (ob.map(states, state => this.signal(state)));
}
track(reader, actor = reader) {
const actuate = debounce(0, actor);
const accessed = [];
for (const signal of this.#signals)
signal.accessed = false;
reader();
for (const signal of this.#signals)
if (signal.accessed)
accessed.push(signal);
const unsubscribe_functions = accessed.map(signal => {
return signal.subscribe(() => {
const promise = actuate();
this.#waiters.add(promise);
});
});
return () => unsubscribe_functions
.forEach(unsub => unsub());
}
get wait() {
return Promise.all([...this.#signals].map(s => s.wait))
.then(() => Promise.all([...this.#waiters]))
.then(() => { this.#waiters.clear(); });
}
}
class Slice {
#options;
constructor(options) {
this.#options = options;
}
get state() {
return this.#options.getter(this.#options.parent.state);
}
transmute(fun) {
this.#options.parent.transmute(state => {
const x1 = this.#options.getter(state);
const x2 = fun(x1);
const new_state = this.#options.setter(state, x2);
return new_state;
});
}
slice({ getter, setter }) {
return new Slice({
parent: this,
getter,
setter,
});
}
}
function deepFreeze(obj) {
if (obj === null || typeof obj !== 'object')
return obj;
Object.values(obj).forEach(value => {
if (typeof value === 'object' && value !== null)
deepFreeze(value);
});
return Object.freeze(obj);
}
class StateTree {
#state;
#readable;
#onChange;
#circularity_lock = false;
#make_frozen_clone() {
return deepFreeze(structuredClone(this.#state));
}
constructor(state, onChange = () => { }) {
this.#state = structuredClone(state);
this.#readable = this.#make_frozen_clone();
this.#onChange = onChange;
}
get state() {
return this.#readable;
}
transmute(fun) {
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();
this.#circularity_lock = false;
}
slice({ getter, setter }) {
return new Slice({
parent: this,
getter,
setter,
});
}
}
const deepEqual = (alpha, bravo) => {
if (alpha === bravo)
return true;
if (typeof alpha !== 'object' || alpha === null || typeof bravo !== 'object' || bravo === null)
return false;
const keys1 = Object.keys(alpha);
const keys2 = Object.keys(bravo);
if (keys1.length !== keys2.length)
return false;
for (const key of keys1) {
if (!keys2.includes(key))
return false;
if (!deepEqual(alpha[key], bravo[key]))
return false;
}
return true;
};
class WatchTower {
#computeds = new Set();
#listeners = new Set();
#memory = new Map();
dispatch() {
for (const computed of this.#computeds)
computed();
for (const listener of this.#listeners)
listener();
}
computed(fun) {
let data = fun();
this.#computeds.add(() => { data = fun(); });
return {
get value() {
return data;
}
};
}
track(collector, responder) {
let first = true;
const listener = () => {
const current = collector();
const previous = this.#memory.get(collector);
if (first || !deepEqual(current, previous)) {
first = false;
this.#memory.set(collector, current);
responder(current);
}
};
listener();
this.#listeners.add(listener);
return collector();
}
stateTree(state) {
return new StateTree(state, () => this.dispatch());
}
}
class Context {
theme = i$3 ``;
flat = new Flat();
signals = new SignalTower();
watch = new WatchTower();
}
class Shell {

@@ -755,2 +146,14 @@ #context;

var ob;
(function (ob) {
ob.map = (o, transform) => (Object.fromEntries(Object.entries(o)
.map(([key, value]) => [key, transform(value, key)])));
ob.filter = (o, judge) => Object.fromEntries(Object.entries(o)
.filter(([key, value]) => judge(value, key)));
(function (pipe) {
pipe.map = (transform) => ((o) => ob.map(o, transform));
pipe.filter = (transform) => ((o) => ob.filter(o, transform));
})(ob.pipe || (ob.pipe = {}));
})(ob || (ob = {}));
class Pipe {

@@ -810,2 +213,39 @@ static with(input) {

function debounce(delay, action) {
let latestArgs;
let timeout;
let waitingQueue = [];
function reset() {
latestArgs = [];
if (timeout)
clearTimeout(timeout);
timeout = undefined;
waitingQueue = [];
}
reset();
return ((...args) => {
latestArgs = args;
if (timeout)
clearTimeout(timeout);
const promise = new Promise((resolve, reject) => {
waitingQueue.push({ resolve, reject });
});
timeout = setTimeout(() => {
Promise.resolve()
.then(() => action(...latestArgs))
.then(r => {
for (const { resolve } of waitingQueue)
resolve(r);
reset();
})
.catch(err => {
for (const { reject } of waitingQueue)
reject(err);
reset();
});
}, delay);
return promise;
});
}
function explode_promise() {

@@ -878,2 +318,22 @@ let resolve;

function maptool(map) {
return new MapTool(map);
}
class MapTool {
map;
constructor(map) {
this.map = map;
}
grab(key, make) {
const { map } = this;
if (map.has(key))
return map.get(key);
else {
const value = make();
map.set(key, value);
return value;
}
}
}
class Use {

@@ -930,14 +390,14 @@ static wrap(use, fun) {

}
setup(up) {
setup(func) {
const count = this.#counter.pull();
if (!this.#setups.has(count)) {
this.#setups.set(count, up);
this.#setdowns.add(up());
this.#setups.set(count, func);
this.#setdowns.add(func());
}
}
init(start) {
init(func) {
const count = this.#counter.pull();
if (!this.#initStarts.has(count)) {
this.#initStarts.set(count, start);
const [result, down] = start();
this.#initStarts.set(count, func);
const [result, down] = func();
this.#initResults.set(count, result);

@@ -1465,3 +925,3 @@ this.#initDowns.add(down);

function prepare_frontend(context) {
function setup(context) {
const shell = new Shell(context);

@@ -1488,6 +948,6 @@ const oxygen = prepare_oxygen(shell);

obsidian,
lightComponent: oxygen,
shadowComponent: carbon,
lightView: quartz,
shadowView: obsidian,
light_component: oxygen,
shadow_component: carbon,
light_view: quartz,
shadow_view: obsidian,
components: (elements) => (apply.context(shell.context)(elements)),

@@ -1497,2 +957,542 @@ };

class Locker {
#locked = false;
lock(fun) {
this.#locked = true;
fun();
this.#locked = false;
}
get locked() {
return this.#locked;
}
}
const make_map = () => new Map();
const make_set = () => new Set();
class Tracker {
#tracking = new WeakMap();
grab_keymap(state) {
const keymap = maptool(this.#tracking).grab(state, make_map);
return {
keymap,
grab_symbolmap(key) {
return maptool(keymap).grab(key, make_map);
},
};
}
clear() {
this.#tracking = new WeakMap();
}
}
class Stopper {
#map = new Map;
stop(symbol) {
const stop = this.#map.get(symbol);
if (stop) {
this.#map.delete(symbol);
stop();
}
}
add(symbol, fun) {
this.#map.set(symbol, fun);
}
}
class Recorder {
#recordings = [];
record(fun) {
const recording = make_map();
this.#recordings.push(recording);
fun();
this.#recordings.pop();
return recording;
}
record_that_key_was_accessed(state, key) {
const recording = this.#recordings.at(-1);
if (recording) {
const keyset = maptool(recording).grab(state, make_set);
keyset.add(key);
}
}
}
class FlatstateError extends Error {
name = this.constructor.name;
}
class CircularFlatstateError extends FlatstateError {
constructor(key) {
super(`forbidden circularity, rejected assignment to "${key}"`);
}
}
class ReadonlyError extends FlatstateError {
constructor(key) {
super(`forbidden assignment to readonly property "${key}"`);
}
}
function readonly(s) {
return new Proxy(s, {
get(target, key) {
return target[key];
},
set(_, key) {
throw new ReadonlyError(key);
},
});
}
class Scheduler {
#queue = new Map();
#wait = Promise.resolve();
#actuate = debounce(0, () => {
const functions = [...this.#queue.values()];
this.#queue.clear();
for (const fun of functions)
fun();
});
get wait() {
return this.#wait;
}
add(symbol, fun) {
this.#queue.set(symbol, fun);
this.#wait = this.#actuate();
}
}
function collectivize(state) {
return function (collector) {
return () => {
const s = typeof state === "function"
? state()
: state;
return collector(s);
};
};
}
function save_reaction(symbol, recording, tracker, reaction) {
const stoppers = [];
for (const [state, keyset] of recording) {
const { grab_symbolmap } = tracker.grab_keymap(state);
for (const key of keyset) {
const symbolmap = grab_symbolmap(key);
symbolmap.set(symbol, reaction);
stoppers.push(() => symbolmap.delete(symbol));
}
}
return () => stoppers.forEach(stop => stop());
}
function proxy_handlers(tracker, recorder, locker, stopper, scheduler) {
function respond_and_run_discovery([symbol, reaction]) {
locker.lock(reaction.responder);
if (reaction.discover) {
stopper.stop(symbol);
const recorded = recorder.record(() => locker.lock(reaction.collector));
stopper.add(symbol, save_reaction(symbol, recorded, tracker, reaction));
}
}
return {
get: (state, key) => {
recorder.record_that_key_was_accessed(state, key);
return state[key];
},
set: (state, key, value) => {
if (locker.locked)
throw new CircularFlatstateError(key);
state[key] = value;
const reactions = [...tracker.grab_keymap(state).grab_symbolmap(key)];
for (const entry of reactions) {
const [symbol, reaction] = entry;
if (reaction.debounce)
scheduler.add(symbol, () => respond_and_run_discovery(entry));
else
respond_and_run_discovery(entry);
}
return true;
},
};
}
class Flat {
static readonly = readonly;
static collectivize = collectivize;
#tracker = new Tracker();
#recorder = new Recorder();
#locker = new Locker();
#stopper = new Stopper();
#scheduler = new Scheduler();
#proxy_handlers = proxy_handlers(this.#tracker, this.#recorder, this.#locker, this.#stopper, this.#scheduler);
get wait() {
return this.#scheduler.wait;
}
state(state) {
return new Proxy(state, this.#proxy_handlers);
}
manual(reaction) {
const symbol = Symbol();
const recorded = this.#recorder.record(() => this.#locker.lock(reaction.collector));
this.#stopper.add(symbol, save_reaction(symbol, recorded, this.#tracker, reaction));
return () => this.#stopper.stop(symbol);
}
auto({ debounce, discover, collector, responder }) {
return this.manual({
debounce,
discover,
collector,
responder: responder
? () => responder(collector())
: collector,
});
}
reaction(collector, responder) {
return this.auto({
debounce: true,
discover: false,
collector,
responder,
});
}
deepReaction(collector, responder) {
return this.auto({
debounce: true,
discover: true,
collector,
responder,
});
}
clear() {
this.#tracker.clear();
}
}
class SignalCircularError extends Error {
name = this.constructor.name;
}
class Signal {
#value;
#lock = false;
#wait;
#listeners = new Set();
accessed = false;
constructor(v) {
this.#value = v;
this.#wait = Promise.resolve(v);
}
subscribe(listener) {
this.#listeners.add(listener);
return () => void this.#listeners.delete(listener);
}
once(listener) {
const actual_listener = v => {
listener(v);
this.#listeners.delete(actual_listener);
};
this.#listeners.add(actual_listener);
return () => void this.#listeners.delete(actual_listener);
}
clear() {
return this.#listeners.clear();
}
#invoke_listeners = debounce(0, () => {
const value = this.#value;
this.#lock = true;
for (const listener of this.#listeners)
listener(value);
this.#lock = false;
return value;
});
async publish() {
this.#wait = this.#invoke_listeners();
await this.#wait;
}
get wait() {
return this.#wait;
}
get value() {
this.accessed = true;
return this.#value;
}
set value(s) {
if (this.#lock)
throw new SignalCircularError("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");
this.#value = s;
this.publish();
}
}
const JsError = Error;
var Op;
(function (Op) {
Op.loading = () => ({ mode: "loading" });
Op.error = (reason) => ({ mode: "error", reason });
Op.ready = (payload) => ({ mode: "ready", payload });
Op.is = Object.freeze({
loading: (op) => op.mode === "loading",
error: (op) => op.mode === "error",
ready: (op) => op.mode === "ready",
});
function payload(op) {
return (op.mode === "ready")
? op.payload
: undefined;
}
Op.payload = payload;
function select(op, choices) {
switch (op.mode) {
case "loading":
return choices.loading();
case "error":
return choices.error(op.reason);
case "ready":
return choices.ready(op.payload);
default:
console.error("op", op);
throw new JsError("invalid op mode");
}
}
Op.select = select;
async function run(set_op, operation) {
set_op(Op.loading());
try {
const payload = await operation();
set_op(Op.ready(payload));
return payload;
}
catch (err) {
const reason = (err instanceof JsError)
? err.message
: (typeof err === "string")
? err
: "error";
set_op(Op.error(reason));
}
}
Op.run = run;
function morph(op, transmute) {
return select(op, {
loading: () => Op.loading(),
error: reason => Op.error(reason),
ready: a => Op.ready(transmute(a)),
});
}
Op.morph = morph;
})(Op || (Op = {}));
class OpSignal extends Signal {
constructor() {
super(Op.loading());
}
async run(operation) {
return Op.run(op => this.value = op, operation);
}
setLoading() {
this.value = Op.loading();
}
setError(reason) {
this.value = Op.error(reason);
}
setReady(payload) {
this.value = Op.ready(payload);
}
get loading() {
return Op.is.loading(this.value);
}
get error() {
return Op.is.error(this.value);
}
get ready() {
return Op.is.ready(this.value);
}
get payload() {
return Op.payload(this.value);
}
select(choices) {
return Op.select(this.value, choices);
}
}
class SignalTower {
// TODO wrap all signals in WeakRef, to promote garbage collection?
#signals = new Set();
#waiters = new Set();
signal(value) {
const signal = new Signal(value);
this.#signals.add(signal);
return signal;
}
computed(fun) {
const signal = this.signal(fun());
this.track(() => { signal.value = fun(); });
return signal;
}
op() {
const signal = new OpSignal();
this.#signals.add(signal);
return signal;
}
many(states) {
return (ob.map(states, state => this.signal(state)));
}
track(reader, actor = reader) {
const actuate = debounce(0, actor);
const accessed = [];
for (const signal of this.#signals)
signal.accessed = false;
reader();
for (const signal of this.#signals)
if (signal.accessed)
accessed.push(signal);
const unsubscribe_functions = accessed.map(signal => {
return signal.subscribe(() => {
const promise = actuate();
this.#waiters.add(promise);
});
});
return () => unsubscribe_functions
.forEach(unsub => unsub());
}
get wait() {
return Promise.all([...this.#signals].map(s => s.wait))
.then(() => Promise.all([...this.#waiters]))
.then(() => { this.#waiters.clear(); });
}
}
class Slice {
#options;
constructor(options) {
this.#options = options;
}
get state() {
return this.#options.getter(this.#options.parent.state);
}
transmute(fun) {
this.#options.parent.transmute(state => {
const x1 = this.#options.getter(state);
const x2 = fun(x1);
const new_state = this.#options.setter(state, x2);
return new_state;
});
}
slice({ getter, setter }) {
return new Slice({
parent: this,
getter,
setter,
});
}
}
function deepFreeze(obj) {
if (obj === null || typeof obj !== 'object')
return obj;
Object.values(obj).forEach(value => {
if (typeof value === 'object' && value !== null)
deepFreeze(value);
});
return Object.freeze(obj);
}
class StateTree {
#state;
#readable;
#onChange;
#circularity_lock = false;
#make_frozen_clone() {
return deepFreeze(structuredClone(this.#state));
}
constructor(state, onChange = () => { }) {
this.#state = structuredClone(state);
this.#readable = this.#make_frozen_clone();
this.#onChange = onChange;
}
get state() {
return this.#readable;
}
transmute(fun) {
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();
this.#circularity_lock = false;
}
slice({ getter, setter }) {
return new Slice({
parent: this,
getter,
setter,
});
}
}
const deepEqual = (alpha, bravo) => {
if (alpha === bravo)
return true;
if (typeof alpha !== 'object' || alpha === null || typeof bravo !== 'object' || bravo === null)
return false;
const keys1 = Object.keys(alpha);
const keys2 = Object.keys(bravo);
if (keys1.length !== keys2.length)
return false;
for (const key of keys1) {
if (!keys2.includes(key))
return false;
if (!deepEqual(alpha[key], bravo[key]))
return false;
}
return true;
};
class WatchTower {
#computeds = new Set();
#listeners = new Set();
#memory = new Map();
dispatch() {
for (const computed of this.#computeds)
computed();
for (const listener of this.#listeners)
listener();
}
computed(fun) {
let data = fun();
this.#computeds.add(() => { data = fun(); });
return {
get value() {
return data;
}
};
}
track(collector, responder) {
let first = true;
const listener = () => {
const current = collector();
const previous = this.#memory.get(collector);
if (first || !deepEqual(current, previous)) {
first = false;
this.#memory.set(collector, current);
responder(current);
}
};
listener();
this.#listeners.add(listener);
return collector();
}
stateTree(state) {
return new StateTree(state, () => this.dispatch());
}
}
class Context {
theme = i$3 ``;
flat = new Flat();
signals = new SignalTower();
watch = new WatchTower();
}
class DemoContext extends Context {

@@ -1505,3 +1505,3 @@ theme;

}
const slate = prepare_frontend();
const slate = setup();

@@ -1508,0 +1508,0 @@ class SlateGold extends GoldElement {

@@ -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(),n=new WeakMap;let r=class{constructor(t,e,n){if(this._$cssResult$=!0,n!==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=n.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&n.set(s,t))}return t}toString(){return this.cssText}};const i=(t,...e)=>{const n=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 r(n,t,s)},o=(s,n)=>{if(e)s.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),r=t.litNonce;void 0!==r&&n.setAttribute("nonce",r),n.textContent=e.cssText,s.appendChild(n)}},a=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new r("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 A 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(),n=this.getPropertyDescriptor(t,s,e);void 0!==n&&h(this.prototype,t,n)}}static getPropertyDescriptor(t,e,s){const{get:n,set:r}=l(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)??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),n=this.constructor._$Eu(t,s);if(void 0!==n&&!0===s.reflect){const r=(void 0!==s.converter?.toAttribute?s.converter:y).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:y;this._$Em=n,this[n]=r.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,s,n=!1,r){if(void 0!==t){if(s??=this.constructor.getPropertyOptions(t),!(s.hasChanged??b)(n?r: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){}}A.elementStyles=[],A.shadowRootOptions={mode:"open"},A[m("elementProperties")]=new Map,A[m("finalized")]=new Map,$?.({ReactiveElement:A}),(f.reactiveElementVersions??=[]).push("2.0.0");const v=globalThis,x=v.trustedTypes,S=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,k="$lit$",C=`lit$${(Math.random()+"").slice(9)}$`,E="?"+C,M=`<${E}>`,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!==S?S.createHTML(e):e}const K=(t,e)=>{const s=t.length-1,n=[];let r,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])&&(r=RegExp("</"+c[2],"g")),o=z):void 0!==c[3]&&(o=z):o===z?">"===c[0]?(o=r??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,r=void 0);const u=o===z&&t[e+1].startsWith("/>")?" ":"";i+=o===H?s+M:h>=0?(n.push(a),s.slice(0,h)+k+s.slice(h)+C+u):s+C+(-2===h?e:u)}return[J(t,i+(t[s]||"<?>")+(2===e?"</svg>":"")),n]};class G{constructor({strings:t,_$litType$:e},s){let n;this.parts=[];let r=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!==(n=Z.nextNode())&&a.length<o;){if(1===n.nodeType){if(n.hasAttributes())for(const t of n.getAttributeNames())if(t.endsWith(k)){const e=h[i++],s=n.getAttribute(t).split(C),o=/([.?@])?(.*)/.exec(e);a.push({type:1,index:r,name:o[2],strings:s,ctor:"."===o[1]?tt:"?"===o[1]?et:"@"===o[1]?st:Y}),n.removeAttribute(t)}else t.startsWith(C)&&(a.push({type:6,index:r}),n.removeAttribute(t));if(L.test(n.tagName)){const t=n.textContent.split(C),e=t.length-1;if(e>0){n.textContent=x?x.emptyScript:"";for(let s=0;s<e;s++)n.append(t[s],U()),Z.nextNode(),a.push({type:2,index:++r});n.append(t[e],U())}}}else if(8===n.nodeType)if(n.data===E)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=n.data.indexOf(C,t+1));)a.push({type:7,index:r}),t+=C.length-1}r++}}static createElement(t,e){const s=P.createElement("template");return s.innerHTML=t,s}}function Q(t,e,s=t,n){if(e===I)return e;let r=void 0!==n?s._$Co?.[n]:s._$Cl;const i=O(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=Q(t,r._$AS(t,e.values),r,n)),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,n=(t?.creationScope??P).importNode(e,!0);Z.currentNode=n;let r=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(r,r.nextSibling,this,t):1===a.type?e=new a.ctor(r,a.name,a.strings,this,t):6===a.type&&(e=new nt(r,this,t)),this._$AV.push(e),a=s[++o]}i!==a?.index&&(r=Z.nextNode(),i++)}return Z.currentNode=P,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 X{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,n){this.type=2,this._$AH=V,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=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,n="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===n)this._$AH.p(e);else{const t=new F(n,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,n=0;for(const r of t)n===e.length?e.push(s=new X(this.k(U()),this.k(U()),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 Y{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,n,r){this.type=1,this._$AH=V,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=V}_$AI(t,e=this,s,n){const r=this.strings;let i=!1;if(void 0===r)t=Q(this,t,e,0),i=!O(t)||t!==this._$AH&&t!==I,i&&(this._$AH=t);else{const n=t;let o,a;for(t=r[0],o=0;o<r.length-1;o++)a=Q(this,n[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??"")+r[o+1]),this._$AH[o]=a}i&&!n&&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,n,r){super(t,e,s,n,r),this.type=5}_$AI(t,e=this){if((t=Q(this,t,e,0)??V)===I)return;const s=this._$AH,n=t===V&&s!==V||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==V&&(s===V||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 nt{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 rt=v.litHtmlPolyfillSupport;rt?.(G,X),(v.litHtmlVersions??=[]).push("3.0.0");const it=(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 X(e.insertBefore(U(),t),t,void 0,s??{})}return r._$AI(t),r};let ot=class extends A{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 n=e();return s.set(t,n),n}}}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{#n=[];record(t){const e=ht();return this.#n.push(e),t(),this.#n.pop(),e}record_that_key_was_accessed(t,e){const s=this.#n.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,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 wt{#r=new Map;#i=Promise.resolve();#o=bt(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 At(t){return function(e){return()=>{const s="function"==typeof t?t():t;return e(s)}}}function vt(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()))}class xt{static readonly=yt;static collectivize=At;#a=new pt;#c=new gt;#h=new ct;#l=new ft;#u=new wt;#d=function(t,e,s,n,r){function i([r,i]){if(s.lock(i.responder),i.discover){n.stop(r);const o=e.record((()=>s.lock(i.collector)));n.add(r,vt(r,o,t,i))}}return{get:(t,s)=>(e.record_that_key_was_accessed(t,s),t[s]),set:(e,n,o)=>{if(s.locked)throw new $t(n);e[n]=o;const a=[...t.grab_keymap(e).grab_symbolmap(n)];for(const t of a){const[e,s]=t;s.debounce?r.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,vt(e,s,this.#a,t)),()=>this.#l.stop(e)}auto({debounce:t,discover:e,collector:s,responder:n}){return this.manual({debounce:t,discover:e,collector:s,responder:n?()=>n(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 St;!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)}(St||(St={}));class kt extends Error{name=this.constructor.name}class Ct{#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)}}once(t){const e=s=>{t(s),this.#g.delete(e)};return this.#g.add(e),()=>{this.#g.delete(e)}}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 kt("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");this.#p=t,this.publish()}}const Et=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 Et("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 n=await s();return e(t.ready(n)),n}catch(s){const n=s instanceof Et?s.message:"string"==typeof s?s:"error";e(t.error(n))}},t.morph=function(s,n){return e(s,{loading:()=>t.loading(),error:e=>t.error(e),ready:e=>t.ready(n(e))})}}(Mt||(Mt={}));class Pt extends Ct{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 Ct(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 St.map(t,(t=>this.signal(t)))}track(t,e=t){const s=bt(0,e),n=[];for(const t of this.#$)t.accessed=!1;t();for(const t of this.#$)t.accessed&&n.push(t);const r=n.map((t=>t.subscribe((()=>{const t=s();this.#m.add(t)}))));return()=>r.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),n=t(s);return this.#y.setter(e,n)}))}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;#A;#v=!1;#x(){return Tt(structuredClone(this.#b))}constructor(t,e=(()=>{})){this.#b=structuredClone(t),this.#w=this.#x(),this.#A=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.#x(),this.#A(),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),n=Object.keys(e);if(s.length!==n.length)return!1;for(const r of s){if(!n.includes(r))return!1;if(!Ht(t[r],e[r]))return!1}return!0};class jt{#S=new Set;#g=new Set;#k=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 n=()=>{const n=t(),r=this.#k.get(t);!s&&Ht(n,r)||(s=!1,this.#k.set(t,n),e(n))};return n(),this.#g.add(n),t()}stateTree(t){return new Nt(t,(()=>this.dispatch()))}}class Rt{theme=i``;flat=new xt;signals=new Ut;watch=new jt}class zt{#C;constructor(t){this.#C=t}get context(){if(this.#C)return this.#C;throw new Error("slate.context was not set, but it's necessary")}set context(t){this.#C=t}}var qt;function Dt(t){return[t].flat().filter((t=>!!t))}!function(t){t.css=function(...t){return function(e){return class extends e{static get styles(){return Bt(e.styles,t)}}}},t.css_deferred=function(t){return function(e){return class extends e{static get styles(){return Bt(e.styles,t())}}}},t.signals=function(t){return function(e){return class extends e{#E=[];connectedCallback(){super.connectedCallback(),this.#E.push(t.track((()=>this.render()),(()=>this.requestUpdate())))}disconnectedCallback(){super.disconnectedCallback();for(const t of this.#E)t();this.#E=[]}}}},t.flat=function(t){return function(e){return class extends e{#M=void 0;render(){let e;return this.#M&&this.#M(),this.#M=t.manual({debounce:!1,discover:!1,collector:()=>{e=super.render()},responder:()=>{this.requestUpdate()}}),e}disconnectedCallback(){super.disconnectedCallback(),this.#M&&this.#M(),this.#M=void 0}}}}}(qt||(qt={}));const Lt=t=>void 0!==t;function Bt(t,e){return[...Dt(t)??[],...Dt(e)].flat().filter(Lt)}class It{static with(t){return new this(t)}#P;constructor(t){this.#P=t}to(t){return new It(t(this.#P))}done(){return this.#P}}var Vt,Wt;!function(t){t.css=t=>e=>St.map(e,(e=>qt.css(t)(e))),t.flat=t=>e=>St.map(e,(e=>qt.flat(t)(e))),t.signals=t=>e=>St.map(e,(e=>qt.signals(t)(e))),t.context=e=>s=>It.with(s).to(t.css(e.theme)).to(t.flat(e.flat)).to(t.signals(e.signals)).done()}(Vt||(Vt={}));class Zt extends(function(t){return class extends t{#U=(new Set).add((()=>this.setup()));#O=new Set;register_setup(t){this.#U.add(t)}setup(){return()=>{}}connectedCallback(){for(const t of this.#U)this.#O.add(t())}disconnectedCallback(){for(const t of this.#O)t();this.#O.clear()}}}(HTMLElement)){}function Jt(){let t,e;return{promise:new Promise(((s,n)=>{t=s,e=n})),resolve:t,reject:e}}function Kt(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 Gt extends Zt{static get styles(){}#T;#N=Jt();#i=this.#N.promise;init(){}constructor(){super(),this.#T=this.attachShadow({mode:"open"});const t=this.constructor;Kt(this.#T,t.styles),this.init()}get root(){return this.#T}get updateComplete(){return this.#i.then((()=>!0))}render(){}#H=bt(0,(()=>{const t=this.#T,e=this.render();e&&it(e,t,{host:this})}));async requestUpdate(){const t=this.#H();return this.#N&&(t.then(this.#N.resolve),this.#N=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}class Qt{static wrap(t,e){return(...s)=>(t.#j.reset(),e(...s))}static disconnect(t){for(const e of t.#O)e();t.#O.clear();for(const e of t.#R)e();t.#R.clear(),t.#z.clear()}static reconnect(t){for(const e of t.#U.values())t.#O.add(e());for(const[e,s]of t.#q.entries()){const[n,r]=s();t.#z.set(e,n),t.#R.add(r)}}#C;#D;#j=new Ft;#U=new Map;#O=new Set;#q=new Map;#z=new Map;#R=new Set;#L=new Map;#B=new Map;#I=new Map;#$=new Map;constructor(t,e){this.#D=t,this.#C=e}get context(){return this.#C}rerender(){this.#D()}setup(t){const e=this.#j.pull();this.#U.has(e)||(this.#U.set(e,t),this.#O.add(t()))}init(t){const e=this.#j.pull();if(!this.#q.has(e)){this.#q.set(e,t);const[s,n]=t();return this.#z.set(e,s),this.#R.add(n),s}return this.#z.get(e)}prepare(t){const e=this.#j.pull();return ut(this.#B).grab(e,t)}state(t){const e=this.#j.pull();return[ut(this.#L).grab(e,(()=>"function"==typeof t?t():t)),t=>{this.#L.set(e,t),this.#D()},()=>this.#L.get(e)]}flatstate(t){const e=this.#j.pull();return ut(this.#I).grab(e,(()=>this.#C.flat.state("function"==typeof t?t():t)))}signal(t){const e=this.#j.pull();return ut(this.#$).grab(e,(()=>this.#C.signals.signal("function"==typeof t?t():t)))}computed(t){const e=this.#j.pull();return ut(this.#$).grab(e,(()=>this.#C.signals.computed(t)))}op(){const t=this.#j.pull();return ut(this.#$).grab(t,(()=>this.#C.signals.op()))}#V=new Map;watch(t){const e=this.#j.pull();return ut(this.#V).grab(e,(()=>this.#C.watch.track(t,(t=>{this.#V.set(e,t),this.#D()}))))}}class Ft{#p=0;pull(){return this.#p++}reset(){this.#p=0}}class Xt extends Qt{#W;get element(){return this.#W}#Z;get shadow(){return this.#Z}constructor(t,e,s,n){super(s,n),this.#W=t,this.#Z=e}}function Yt(t){let e;return function(s){return e||(e=function(t,e){return Wt.on_change(t,(()=>t.requestUpdate())),Wt.proxy(t,e)}(t,s)),e}}!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()}}(Wt||(Wt={}));class te extends Xt{attrs;constructor(t,e,s,n){super(t,e,s,n),this.attrs=Yt(t)}}class ee extends Qt{#W;get element(){return this.#W}attrs;constructor(t,e,s){super(e,s),this.#W=t,this.attrs=Yt(t)}}class se extends te{}class ne extends ee{}class re extends Qt{}class ie extends Xt{}function oe(t,e,s){let n,r;return function(...i){let o;return r&&r(),r=t.flat.manual({debounce:!0,discover:!1,collector:()=>{o=function(...r){let i;return n&&n(),n=t.signals.track((()=>{i=e(...r)}),s),i}(...i)},responder:s}),o}}const ae=t=>(e,s)=>class extends Gt{static name=e.name;static get styles(){return[t.context.theme,e.styles??i``]}#J=new se(this,this.root,(()=>{this.requestUpdate()}),t.context);#K=se.wrap(this.#J,(()=>s(this.#J)));#G=oe(t.context,this.#K,(()=>{this.requestUpdate()}));render(){return this.#G()}connectedCallback(){super.connectedCallback(),se.reconnect(this.#J)}disconnectedCallback(){super.disconnectedCallback(),se.disconnect(this.#J)}};class ce extends Zt{#N=Jt();#i=this.#N.promise;init(){}constructor(){super(),this.init()}get updateComplete(){return this.#i.then((()=>!0))}render(){}#H=bt(0,(()=>{const t=this.render();it(t,this,{host:this})}));async requestUpdate(){const t=this.#H();return this.#N&&(t.then(this.#N.resolve),this.#N=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}const he=t=>e=>class extends ce{#J=new ne(this,(()=>{this.requestUpdate()}),t.context);#K=ne.wrap(this.#J,(()=>e(this.#J)));#G=oe(t.context,this.#K,(()=>{this.requestUpdate()}));render(){return this.#G()}connectedCallback(){super.connectedCallback(),ne.reconnect(this.#J)}disconnectedCallback(){super.disconnectedCallback(),ne.disconnect(this.#J)}},le=2;class ue{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 de=(t,e)=>{const s=t._$AN;if(void 0===s)return!1;for(const t of s)t._$AO?.(e,!1),de(t,e);return!0},pe=t=>{let e,s;do{if(void 0===(e=t._$AM))break;s=e._$AN,s.delete(t),t=e}while(0===s?.size)},fe=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),$e(e)}};function ge(t){void 0!==this._$AN?(pe(this),this._$AM=t,fe(this)):this._$AM=t}function _e(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++)de(n[t],!1),pe(n[t]);else null!=n&&(de(n,!1),pe(n));else de(this,t)}const $e=t=>{t.type==le&&(t._$AP??=_e,t._$AQ??=ge)};class me extends ue{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,s){super._$AT(t,e,s),fe(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(de(this,t),pe(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 ye=t=>e=>(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends me{#Q;#D=bt(0,(()=>{this.#Q&&this.setValue(this.render(...this.#Q))}));#J=new re(this.#D,t.context);#K=re.wrap(this.#J,e(this.#J));#G=oe(t.context,this.#K,this.#D);render(...t){return this.#Q=t,this.#G(...t)}reconnected(){re.reconnect(this.#J)}disconnected(){re.disconnect(this.#J)}});function be(){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}const we=t=>{for(const[e,s]of Object.entries(t))customElements.define(e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase(),s)};class Ae extends HTMLElement{static tag="obsidian-view";onConnected=be();onDisconnected=be();connectedCallback(){this.onConnected.publish()}disconnectedCallback(){this.onDisconnected.publish()}}function ve(...t){const e=new Set,s=t.map((t=>t??"")).flatMap(xe);for(const t of s)e.add(t);return e}function xe(t){return t.split(/\s+/).map((t=>t.trim())).filter((t=>!!t))}function Se(t){return t.split(",").map((t=>t.trim())).filter((t=>!!t)).map((t=>t.includes(":")?t.split(":").map((t=>t.trim()))[1]:t))}function ke(t,e){const s=ve(t.getAttribute("part")),n=ve(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(xe),...r.exportparts.flatMap(Se)]),o=new Set([...r.gpart.flatMap(xe),...r.gexportparts.flatMap(xe)]);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 Ce(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&&it(n,t,{host:t})}we({ObsidianView:Ae});const Ee=t=>(e={},s)=>(t=>(e,s={})=>({_$litDirective$:t,values:[{meta:s,props:e}]}))(class extends me{#P;#F=!0;#T=function({name:t,css:e,onConnected:s,onDisconnected:n}){const r=document.createElement(Ae.tag);r.setAttribute("view",t),r.onConnected(s),r.onDisconnected(n);const i=r.attachShadow({mode:"open"});Kt(i,e);let o=!1;return{container:r,shadow:i,set auto_exportparts(t){o=t},render_into_shadow:t=>(it(t,i),o&&ke(r,i),r)}}({name:e.name??"",css:[t.context.theme,e.styles??i``],onDisconnected:()=>this.disconnected(),onConnected:()=>{this.#F||this.reconnected(),this.#F=!1}});#D=bt(0,(()=>{this.#P&&this.setValue(this.#T.render_into_shadow(this.render(this.#P)))}));#J=new ie(this.#T.container,this.#T.shadow,this.#D,t.context);#K=ie.wrap(this.#J,s(this.#J));#G=oe(t.context,this.#K,this.#D);update(t,e){return this.#T.render_into_shadow(this.render(...e))}render(t){return Ce(this.#T.container,t.meta,this.#P?.meta),this.#P=t,this.#T.auto_exportparts=t.meta.auto_exportparts??e.auto_exportparts??!0,this.#G(...t.props)}reconnected(){ie.reconnect(this.#J)}disconnected(){ie.disconnect(this.#J)}});const Me=function(t){const e=new zt(t),s=he(e),n=ae(e),r=ye(e),i=Ee(e);return{shell:e,get context(){return e.context},set context(t){e.context=t},oxygen:s,carbon:n,quartz:r,obsidian:i,lightComponent:s,shadowComponent:n,lightView:r,shadowView:i,components:t=>Vt.context(e.context)(t)}}();class Pe extends Gt{static styles=i`span {color: orange}`;#b=Me.context.flat.state({count:0});render(){return B`
<span>${this.#b.count}</span>
<button @click=${()=>this.#b.count++}>gold</button>
`}}const Ue=(t,...e)=>B(t,...e.map((t=>t instanceof Ct?t.value:t))),Oe=Me.quartz((t=>e=>{const[s,n]=t.state(e),r=t.flatstate({count:e}),i=t.signal(e);return Ue`
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(),n=new WeakMap;let r=class{constructor(t,e,n){if(this._$cssResult$=!0,n!==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=n.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&n.set(s,t))}return t}toString(){return this.cssText}};const i=(t,...e)=>{const n=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 r(n,t,s)},o=(s,n)=>{if(e)s.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),r=t.litNonce;void 0!==r&&n.setAttribute("nonce",r),n.textContent=e.cssText,s.appendChild(n)}},a=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new r("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(),n=this.getPropertyDescriptor(t,s,e);void 0!==n&&h(this.prototype,t,n)}}static getPropertyDescriptor(t,e,s){const{get:n,set:r}=l(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)??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),n=this.constructor._$Eu(t,s);if(void 0!==n&&!0===s.reflect){const r=(void 0!==s.converter?.toAttribute?s.converter:y).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:y;this._$Em=n,this[n]=r.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,s,n=!1,r){if(void 0!==t){if(s??=this.constructor.getPropertyOptions(t),!(s.hasChanged??b)(n?r: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,x=A.trustedTypes,S=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,k="$lit$",C=`lit$${(Math.random()+"").slice(9)}$`,E="?"+C,M=`<${E}>`,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!==S?S.createHTML(e):e}const K=(t,e)=>{const s=t.length-1,n=[];let r,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])&&(r=RegExp("</"+c[2],"g")),o=z):void 0!==c[3]&&(o=z):o===z?">"===c[0]?(o=r??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,r=void 0);const u=o===z&&t[e+1].startsWith("/>")?" ":"";i+=o===H?s+M:h>=0?(n.push(a),s.slice(0,h)+k+s.slice(h)+C+u):s+C+(-2===h?e:u)}return[J(t,i+(t[s]||"<?>")+(2===e?"</svg>":"")),n]};class G{constructor({strings:t,_$litType$:e},s){let n;this.parts=[];let r=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!==(n=Z.nextNode())&&a.length<o;){if(1===n.nodeType){if(n.hasAttributes())for(const t of n.getAttributeNames())if(t.endsWith(k)){const e=h[i++],s=n.getAttribute(t).split(C),o=/([.?@])?(.*)/.exec(e);a.push({type:1,index:r,name:o[2],strings:s,ctor:"."===o[1]?tt:"?"===o[1]?et:"@"===o[1]?st:Y}),n.removeAttribute(t)}else t.startsWith(C)&&(a.push({type:6,index:r}),n.removeAttribute(t));if(L.test(n.tagName)){const t=n.textContent.split(C),e=t.length-1;if(e>0){n.textContent=x?x.emptyScript:"";for(let s=0;s<e;s++)n.append(t[s],U()),Z.nextNode(),a.push({type:2,index:++r});n.append(t[e],U())}}}else if(8===n.nodeType)if(n.data===E)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=n.data.indexOf(C,t+1));)a.push({type:7,index:r}),t+=C.length-1}r++}}static createElement(t,e){const s=P.createElement("template");return s.innerHTML=t,s}}function Q(t,e,s=t,n){if(e===I)return e;let r=void 0!==n?s._$Co?.[n]:s._$Cl;const i=O(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=Q(t,r._$AS(t,e.values),r,n)),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,n=(t?.creationScope??P).importNode(e,!0);Z.currentNode=n;let r=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(r,r.nextSibling,this,t):1===a.type?e=new a.ctor(r,a.name,a.strings,this,t):6===a.type&&(e=new nt(r,this,t)),this._$AV.push(e),a=s[++o]}i!==a?.index&&(r=Z.nextNode(),i++)}return Z.currentNode=P,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 X{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,n){this.type=2,this._$AH=V,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=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,n="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===n)this._$AH.p(e);else{const t=new F(n,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,n=0;for(const r of t)n===e.length?e.push(s=new X(this.k(U()),this.k(U()),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 Y{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,n,r){this.type=1,this._$AH=V,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=V}_$AI(t,e=this,s,n){const r=this.strings;let i=!1;if(void 0===r)t=Q(this,t,e,0),i=!O(t)||t!==this._$AH&&t!==I,i&&(this._$AH=t);else{const n=t;let o,a;for(t=r[0],o=0;o<r.length-1;o++)a=Q(this,n[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??"")+r[o+1]),this._$AH[o]=a}i&&!n&&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,n,r){super(t,e,s,n,r),this.type=5}_$AI(t,e=this){if((t=Q(this,t,e,0)??V)===I)return;const s=this._$AH,n=t===V&&s!==V||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==V&&(s===V||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 nt{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 rt=A.litHtmlPolyfillSupport;rt?.(G,X),(A.litHtmlVersions??=[]).push("3.0.0");const it=(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 X(e.insertBefore(U(),t),t,void 0,s??{})}return r._$AI(t),r};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;constructor(t){this.#t=t}get context(){if(this.#t)return this.#t;throw new Error("slate.context was not set, but it's necessary")}set context(t){this.#t=t}}var ht;function lt(t){return[t].flat().filter((t=>!!t))}!function(t){t.css=function(...t){return function(e){return class extends e{static get styles(){return dt(e.styles,t)}}}},t.css_deferred=function(t){return function(e){return class extends e{static get styles(){return dt(e.styles,t())}}}},t.signals=function(t){return function(e){return class extends e{#e=[];connectedCallback(){super.connectedCallback(),this.#e.push(t.track((()=>this.render()),(()=>this.requestUpdate())))}disconnectedCallback(){super.disconnectedCallback();for(const t of this.#e)t();this.#e=[]}}}},t.flat=function(t){return function(e){return class extends e{#s=void 0;render(){let e;return this.#s&&this.#s(),this.#s=t.manual({debounce:!1,discover:!1,collector:()=>{e=super.render()},responder:()=>{this.requestUpdate()}}),e}disconnectedCallback(){super.disconnectedCallback(),this.#s&&this.#s(),this.#s=void 0}}}}}(ht||(ht={}));const ut=t=>void 0!==t;function dt(t,e){return[...lt(t)??[],...lt(e)].flat().filter(ut)}var pt,ft,_t;!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)}(pt||(pt={}));class gt{static with(t){return new this(t)}#n;constructor(t){this.#n=t}to(t){return new gt(t(this.#n))}done(){return this.#n}}!function(t){t.css=t=>e=>pt.map(e,(e=>ht.css(t)(e))),t.flat=t=>e=>pt.map(e,(e=>ht.flat(t)(e))),t.signals=t=>e=>pt.map(e,(e=>ht.signals(t)(e))),t.context=e=>s=>gt.with(s).to(t.css(e.theme)).to(t.flat(e.flat)).to(t.signals(e.signals)).done()}(ft||(ft={}));class $t extends(function(t){return class extends t{#r=(new Set).add((()=>this.setup()));#i=new Set;register_setup(t){this.#r.add(t)}setup(){return()=>{}}connectedCallback(){for(const t of this.#r)this.#i.add(t())}disconnectedCallback(){for(const t of this.#i)t();this.#i.clear()}}}(HTMLElement)){}function mt(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}}function yt(){let t,e;return{promise:new Promise(((s,n)=>{t=s,e=n})),resolve:t,reject:e}}function bt(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 wt extends $t{static get styles(){}#o;#a=yt();#c=this.#a.promise;init(){}constructor(){super(),this.#o=this.attachShadow({mode:"open"});const t=this.constructor;bt(this.#o,t.styles),this.init()}get root(){return this.#o}get updateComplete(){return this.#c.then((()=>!0))}render(){}#h=mt(0,(()=>{const t=this.#o,e=this.render();e&&it(e,t,{host:this})}));async requestUpdate(){const t=this.#h();return this.#a&&(t.then(this.#a.resolve),this.#a=void 0),this.#c=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}function vt(t){return new At(t)}class At{map;constructor(t){this.map=t}grab(t,e){const{map:s}=this;if(s.has(t))return s.get(t);{const n=e();return s.set(t,n),n}}}class xt{static wrap(t,e){return(...s)=>(t.#l.reset(),e(...s))}static disconnect(t){for(const e of t.#i)e();t.#i.clear();for(const e of t.#u)e();t.#u.clear(),t.#d.clear()}static reconnect(t){for(const e of t.#r.values())t.#i.add(e());for(const[e,s]of t.#p.entries()){const[n,r]=s();t.#d.set(e,n),t.#u.add(r)}}#t;#f;#l=new St;#r=new Map;#i=new Set;#p=new Map;#d=new Map;#u=new Set;#_=new Map;#g=new Map;#$=new Map;#m=new Map;constructor(t,e){this.#f=t,this.#t=e}get context(){return this.#t}rerender(){this.#f()}setup(t){const e=this.#l.pull();this.#r.has(e)||(this.#r.set(e,t),this.#i.add(t()))}init(t){const e=this.#l.pull();if(!this.#p.has(e)){this.#p.set(e,t);const[s,n]=t();return this.#d.set(e,s),this.#u.add(n),s}return this.#d.get(e)}prepare(t){const e=this.#l.pull();return vt(this.#g).grab(e,t)}state(t){const e=this.#l.pull();return[vt(this.#_).grab(e,(()=>"function"==typeof t?t():t)),t=>{this.#_.set(e,t),this.#f()},()=>this.#_.get(e)]}flatstate(t){const e=this.#l.pull();return vt(this.#$).grab(e,(()=>this.#t.flat.state("function"==typeof t?t():t)))}signal(t){const e=this.#l.pull();return vt(this.#m).grab(e,(()=>this.#t.signals.signal("function"==typeof t?t():t)))}computed(t){const e=this.#l.pull();return vt(this.#m).grab(e,(()=>this.#t.signals.computed(t)))}op(){const t=this.#l.pull();return vt(this.#m).grab(t,(()=>this.#t.signals.op()))}#y=new Map;watch(t){const e=this.#l.pull();return vt(this.#y).grab(e,(()=>this.#t.watch.track(t,(t=>{this.#y.set(e,t),this.#f()}))))}}class St{#b=0;pull(){return this.#b++}reset(){this.#b=0}}class kt extends xt{#w;get element(){return this.#w}#v;get shadow(){return this.#v}constructor(t,e,s,n){super(s,n),this.#w=t,this.#v=e}}function Ct(t){let e;return function(s){return e||(e=function(t,e){return _t.on_change(t,(()=>t.requestUpdate())),_t.proxy(t,e)}(t,s)),e}}!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()}}(_t||(_t={}));class Et extends kt{attrs;constructor(t,e,s,n){super(t,e,s,n),this.attrs=Ct(t)}}class Mt extends xt{#w;get element(){return this.#w}attrs;constructor(t,e,s){super(e,s),this.#w=t,this.attrs=Ct(t)}}class Pt extends Et{}class Ut extends Mt{}class Ot extends xt{}class Tt extends kt{}function Nt(t,e,s){let n,r;return function(...i){let o;return r&&r(),r=t.flat.manual({debounce:!0,discover:!1,collector:()=>{o=function(...r){let i;return n&&n(),n=t.signals.track((()=>{i=e(...r)}),s),i}(...i)},responder:s}),o}}const Ht=t=>(e,s)=>class extends wt{static name=e.name;static get styles(){return[t.context.theme,e.styles??i``]}#A=new Pt(this,this.root,(()=>{this.requestUpdate()}),t.context);#x=Pt.wrap(this.#A,(()=>s(this.#A)));#S=Nt(t.context,this.#x,(()=>{this.requestUpdate()}));render(){return this.#S()}connectedCallback(){super.connectedCallback(),Pt.reconnect(this.#A)}disconnectedCallback(){super.disconnectedCallback(),Pt.disconnect(this.#A)}};class jt extends $t{#a=yt();#c=this.#a.promise;init(){}constructor(){super(),this.init()}get updateComplete(){return this.#c.then((()=>!0))}render(){}#h=mt(0,(()=>{const t=this.render();it(t,this,{host:this})}));async requestUpdate(){const t=this.#h();return this.#a&&(t.then(this.#a.resolve),this.#a=void 0),this.#c=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}const Rt=t=>e=>class extends jt{#A=new Ut(this,(()=>{this.requestUpdate()}),t.context);#x=Ut.wrap(this.#A,(()=>e(this.#A)));#S=Nt(t.context,this.#x,(()=>{this.requestUpdate()}));render(){return this.#S()}connectedCallback(){super.connectedCallback(),Ut.reconnect(this.#A)}disconnectedCallback(){super.disconnectedCallback(),Ut.disconnect(this.#A)}},zt=2;class qt{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 Dt=(t,e)=>{const s=t._$AN;if(void 0===s)return!1;for(const t of s)t._$AO?.(e,!1),Dt(t,e);return!0},Lt=t=>{let e,s;do{if(void 0===(e=t._$AM))break;s=e._$AN,s.delete(t),t=e}while(0===s?.size)},Bt=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),Wt(e)}};function It(t){void 0!==this._$AN?(Lt(this),this._$AM=t,Bt(this)):this._$AM=t}function Vt(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++)Dt(n[t],!1),Lt(n[t]);else null!=n&&(Dt(n,!1),Lt(n));else Dt(this,t)}const Wt=t=>{t.type==zt&&(t._$AP??=Vt,t._$AQ??=It)};class Zt extends qt{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,s){super._$AT(t,e,s),Bt(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(Dt(this,t),Lt(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 Jt=t=>e=>(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Zt{#k;#f=mt(0,(()=>{this.#k&&this.setValue(this.render(...this.#k))}));#A=new Ot(this.#f,t.context);#x=Ot.wrap(this.#A,e(this.#A));#S=Nt(t.context,this.#x,this.#f);render(...t){return this.#k=t,this.#S(...t)}reconnected(){Ot.reconnect(this.#A)}disconnected(){Ot.disconnect(this.#A)}});function Kt(){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}const Gt=t=>{for(const[e,s]of Object.entries(t))customElements.define(e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase(),s)};class Qt extends HTMLElement{static tag="obsidian-view";onConnected=Kt();onDisconnected=Kt();connectedCallback(){this.onConnected.publish()}disconnectedCallback(){this.onDisconnected.publish()}}function Ft(...t){const e=new Set,s=t.map((t=>t??"")).flatMap(Xt);for(const t of s)e.add(t);return e}function Xt(t){return t.split(/\s+/).map((t=>t.trim())).filter((t=>!!t))}function Yt(t){return t.split(",").map((t=>t.trim())).filter((t=>!!t)).map((t=>t.includes(":")?t.split(":").map((t=>t.trim()))[1]:t))}function te(t,e){const s=Ft(t.getAttribute("part")),n=Ft(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(Xt),...r.exportparts.flatMap(Yt)]),o=new Set([...r.gpart.flatMap(Xt),...r.gexportparts.flatMap(Xt)]);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 ee(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&&it(n,t,{host:t})}Gt({ObsidianView:Qt});const se=t=>(e={},s)=>(t=>(e,s={})=>({_$litDirective$:t,values:[{meta:s,props:e}]}))(class extends Zt{#n;#C=!0;#o=function({name:t,css:e,onConnected:s,onDisconnected:n}){const r=document.createElement(Qt.tag);r.setAttribute("view",t),r.onConnected(s),r.onDisconnected(n);const i=r.attachShadow({mode:"open"});bt(i,e);let o=!1;return{container:r,shadow:i,set auto_exportparts(t){o=t},render_into_shadow:t=>(it(t,i),o&&te(r,i),r)}}({name:e.name??"",css:[t.context.theme,e.styles??i``],onDisconnected:()=>this.disconnected(),onConnected:()=>{this.#C||this.reconnected(),this.#C=!1}});#f=mt(0,(()=>{this.#n&&this.setValue(this.#o.render_into_shadow(this.render(this.#n)))}));#A=new Tt(this.#o.container,this.#o.shadow,this.#f,t.context);#x=Tt.wrap(this.#A,s(this.#A));#S=Nt(t.context,this.#x,this.#f);update(t,e){return this.#o.render_into_shadow(this.render(...e))}render(t){return ee(this.#o.container,t.meta,this.#n?.meta),this.#n=t,this.#o.auto_exportparts=t.meta.auto_exportparts??e.auto_exportparts??!0,this.#S(...t.props)}reconnected(){Tt.reconnect(this.#A)}disconnected(){Tt.disconnect(this.#A)}});class ne{#E=!1;lock(t){this.#E=!0,t(),this.#E=!1}get locked(){return this.#E}}const re=()=>new Map,ie=()=>new Set;class oe{#M=new WeakMap;grab_keymap(t){const e=vt(this.#M).grab(t,re);return{keymap:e,grab_symbolmap:t=>vt(e).grab(t,re)}}clear(){this.#M=new WeakMap}}class ae{#P=new Map;stop(t){const e=this.#P.get(t);e&&(this.#P.delete(t),e())}add(t,e){this.#P.set(t,e)}}class ce{#U=[];record(t){const e=re();return this.#U.push(e),t(),this.#U.pop(),e}record_that_key_was_accessed(t,e){const s=this.#U.at(-1);if(s){vt(s).grab(t,ie).add(e)}}}class he extends Error{name=this.constructor.name}class le extends he{constructor(t){super(`forbidden circularity, rejected assignment to "${t}"`)}}class ue extends he{constructor(t){super(`forbidden assignment to readonly property "${t}"`)}}function de(t){return new Proxy(t,{get:(t,e)=>t[e],set(t,e){throw new ue(e)}})}class pe{#O=new Map;#c=Promise.resolve();#T=mt(0,(()=>{const t=[...this.#O.values()];this.#O.clear();for(const e of t)e()}));get wait(){return this.#c}add(t,e){this.#O.set(t,e),this.#c=this.#T()}}function fe(t){return function(e){return()=>{const s="function"==typeof t?t():t;return e(s)}}}function _e(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()))}class ge{static readonly=de;static collectivize=fe;#N=new oe;#H=new ce;#j=new ne;#R=new ae;#z=new pe;#q=function(t,e,s,n,r){function i([r,i]){if(s.lock(i.responder),i.discover){n.stop(r);const o=e.record((()=>s.lock(i.collector)));n.add(r,_e(r,o,t,i))}}return{get:(t,s)=>(e.record_that_key_was_accessed(t,s),t[s]),set:(e,n,o)=>{if(s.locked)throw new le(n);e[n]=o;const a=[...t.grab_keymap(e).grab_symbolmap(n)];for(const t of a){const[e,s]=t;s.debounce?r.add(e,(()=>i(t))):i(t)}return!0}}}(this.#N,this.#H,this.#j,this.#R,this.#z);get wait(){return this.#z.wait}state(t){return new Proxy(t,this.#q)}manual(t){const e=Symbol(),s=this.#H.record((()=>this.#j.lock(t.collector)));return this.#R.add(e,_e(e,s,this.#N,t)),()=>this.#R.stop(e)}auto({debounce:t,discover:e,collector:s,responder:n}){return this.manual({debounce:t,discover:e,collector:s,responder:n?()=>n(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.#N.clear()}}class $e extends Error{name=this.constructor.name}class me{#b;#D=!1;#c;#L=new Set;accessed=!1;constructor(t){this.#b=t,this.#c=Promise.resolve(t)}subscribe(t){return this.#L.add(t),()=>{this.#L.delete(t)}}once(t){const e=s=>{t(s),this.#L.delete(e)};return this.#L.add(e),()=>{this.#L.delete(e)}}clear(){return this.#L.clear()}#B=mt(0,(()=>{const t=this.#b;this.#D=!0;for(const e of this.#L)e(t);return this.#D=!1,t}));async publish(){this.#c=this.#B(),await this.#c}get wait(){return this.#c}get value(){return this.accessed=!0,this.#b}set value(t){if(this.#D)throw new $e("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");this.#b=t,this.publish()}}const ye=Error;var be;!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 ye("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 n=await s();return e(t.ready(n)),n}catch(s){const n=s instanceof ye?s.message:"string"==typeof s?s:"error";e(t.error(n))}},t.morph=function(s,n){return e(s,{loading:()=>t.loading(),error:e=>t.error(e),ready:e=>t.ready(n(e))})}}(be||(be={}));class we extends me{constructor(){super(be.loading())}async run(t){return be.run((t=>this.value=t),t)}setLoading(){this.value=be.loading()}setError(t){this.value=be.error(t)}setReady(t){this.value=be.ready(t)}get loading(){return be.is.loading(this.value)}get error(){return be.is.error(this.value)}get ready(){return be.is.ready(this.value)}get payload(){return be.payload(this.value)}select(t){return be.select(this.value,t)}}class ve{#m=new Set;#I=new Set;signal(t){const e=new me(t);return this.#m.add(e),e}computed(t){const e=this.signal(t());return this.track((()=>{e.value=t()})),e}op(){const t=new we;return this.#m.add(t),t}many(t){return pt.map(t,(t=>this.signal(t)))}track(t,e=t){const s=mt(0,e),n=[];for(const t of this.#m)t.accessed=!1;t();for(const t of this.#m)t.accessed&&n.push(t);const r=n.map((t=>t.subscribe((()=>{const t=s();this.#I.add(t)}))));return()=>r.forEach((t=>t()))}get wait(){return Promise.all([...this.#m].map((t=>t.wait))).then((()=>Promise.all([...this.#I]))).then((()=>{this.#I.clear()}))}}class Ae{#V;constructor(t){this.#V=t}get state(){return this.#V.getter(this.#V.parent.state)}transmute(t){this.#V.parent.transmute((e=>{const s=this.#V.getter(e),n=t(s);return this.#V.setter(e,n)}))}slice({getter:t,setter:e}){return new Ae({parent:this,getter:t,setter:e})}}function xe(t){return null===t||"object"!=typeof t?t:(Object.values(t).forEach((t=>{"object"==typeof t&&null!==t&&xe(t)})),Object.freeze(t))}class Se{#W;#Z;#J;#K=!1;#G(){return xe(structuredClone(this.#W))}constructor(t,e=(()=>{})){this.#W=structuredClone(t),this.#Z=this.#G(),this.#J=e}get state(){return this.#Z}transmute(t){if(this.#K)throw new Error("circular error");this.#K=!0,this.#W=t(structuredClone(this.#W)),this.#Z=this.#G(),this.#J(),this.#K=!1}slice({getter:t,setter:e}){return new Ae({parent:this,getter:t,setter:e})}}const ke=(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),n=Object.keys(e);if(s.length!==n.length)return!1;for(const r of s){if(!n.includes(r))return!1;if(!ke(t[r],e[r]))return!1}return!0};class Ce{#Q=new Set;#L=new Set;#F=new Map;dispatch(){for(const t of this.#Q)t();for(const t of this.#L)t()}computed(t){let e=t();return this.#Q.add((()=>{e=t()})),{get value(){return e}}}track(t,e){let s=!0;const n=()=>{const n=t(),r=this.#F.get(t);!s&&ke(n,r)||(s=!1,this.#F.set(t,n),e(n))};return n(),this.#L.add(n),t()}stateTree(t){return new Se(t,(()=>this.dispatch()))}}class Ee{theme=i``;flat=new ge;signals=new ve;watch=new Ce}const Me=function(t){const e=new ct(t),s=Rt(e),n=Ht(e),r=Jt(e),i=se(e);return{shell:e,get context(){return e.context},set context(t){e.context=t},oxygen:s,carbon:n,quartz:r,obsidian:i,light_component:s,shadow_component:n,light_view:r,shadow_view:i,components:t=>ft.context(e.context)(t)}}();class Pe extends wt{static styles=i`span {color: orange}`;#W=Me.context.flat.state({count:0});render(){return B`
<span>${this.#W.count}</span>
<button @click=${()=>this.#W.count++}>gold</button>
`}}const Ue=(t,...e)=>B(t,...e.map((t=>t instanceof me?t.value:t))),Oe=Me.quartz((t=>e=>{const[s,n]=t.state(e),r=t.flatstate({count:e}),i=t.signal(e);return Ue`
<span>${s}</span>

@@ -22,3 +22,3 @@ <button @click=${()=>n(3*s)}>quartz-a</button>

<button @click=${()=>e.value-=8}>oxygen</button>
`}));Me.context=new class extends Rt{theme;constructor(t){super(),this.theme=t}}(i`
`}));Me.context=new class extends Ee{theme;constructor(t){super(),this.theme=t}}(i`
button {

@@ -28,5 +28,5 @@ font-weight: bold;

}
`),we({SlateCarbon:Re,SlateOxygen:ze,...Me.components({SlateGold:Pe,SlateSilver:class extends ce{render(){return B`
`),Gt({SlateCarbon:Re,SlateOxygen:ze,...Me.components({SlateGold:Pe,SlateSilver:class extends jt{render(){return B`
${Oe(1)}
${Ne([33])}
`}}})});
import { Shell } from "./shell.js";
import { Context } from "./context.js";
import { BaseElementClasses } from "../base/element.js";
export type SlateFor<C extends Context> = ReturnType<typeof prepare_frontend<C>>;
export declare function prepare_frontend<C extends Context>(context?: C): {
export type SlateFor<C extends Context> = ReturnType<typeof setup<C>>;
export declare function setup<C extends Context>(context?: C): {
shell: Shell<C>;

@@ -27,3 +27,3 @@ context: C;

"__#21@#render_debounced": import("../tools/debounce/types.js").DebounceReturn<() => void>;
requestUpdate(): Promise<void>; /** shadow-dom component */
requestUpdate(): Promise<void>;
"__#19@#setups": Set<() => () => void>;

@@ -367,3 +367,3 @@ "__#19@#setdowns": Set<() => void>;

}>) => import("lit-html/directive.js").DirectiveResult<any>;
lightComponent: (renderer: import("./parts/types.js").OxygenRenderer<C>) => {
light_component: (renderer: import("./parts/types.js").OxygenRenderer<C>) => {
new (): {

@@ -386,3 +386,3 @@ [x: string]: any;

"__#21@#render_debounced": import("../tools/debounce/types.js").DebounceReturn<() => void>;
requestUpdate(): Promise<void>; /** shadow-dom component */
requestUpdate(): Promise<void>;
"__#19@#setups": Set<() => () => void>;

@@ -716,5 +716,5 @@ "__#19@#setdowns": Set<() => void>;

};
shadowComponent: (settings: import("./parts/types.js").ShadowSettings, renderer: import("./parts/types.js").CarbonRenderer<C>) => typeof import("../index.js").GoldElement;
lightView: <P extends any[]>(renderer: import("./parts/types.js").QuartzRenderer<C, P>) => (...props: P) => import("lit-html/directive.js").DirectiveResult<any>;
shadowView: <P_1 extends any[]>(settings: import("./parts/types.js").ShadowSettings | undefined, renderer: import("./parts/types.js").ObsidianRenderer<C, P_1>) => (props: P_1, meta?: Partial<{
shadow_component: (settings: import("./parts/types.js").ShadowSettings, renderer: import("./parts/types.js").CarbonRenderer<C>) => typeof import("../index.js").GoldElement;
light_view: <P extends any[]>(renderer: import("./parts/types.js").QuartzRenderer<C, P>) => (...props: P) => import("lit-html/directive.js").DirectiveResult<any>;
shadow_view: <P_1 extends any[]>(settings: import("./parts/types.js").ShadowSettings | undefined, renderer: import("./parts/types.js").ObsidianRenderer<C, P_1>) => (props: P_1, meta?: Partial<{
content: import("lit-html").TemplateResult;

@@ -721,0 +721,0 @@ auto_exportparts: boolean;

@@ -7,3 +7,3 @@ import { Shell } from "./shell.js";

import { prepare_obsidian } from "./units/obsidian.js";
export function prepare_frontend(context) {
export function setup(context) {
const shell = new Shell(context);

@@ -30,6 +30,6 @@ const oxygen = prepare_oxygen(shell);

obsidian,
lightComponent: oxygen,
shadowComponent: carbon,
lightView: quartz,
shadowView: obsidian,
light_component: oxygen,
shadow_component: carbon,
light_view: quartz,
shadow_view: obsidian,
components: (elements) => (apply.context(shell.context)(elements)),

@@ -36,0 +36,0 @@ };

export type Setdown = () => void;
export type Setup = () => Setdown;
export type SetupFn = () => Setdown;
export type InitResult<R> = [R, Setdown];
export type InitFunction<R> = () => InitResult<R>;
export type InitFn<R> = () => InitResult<R>;
import { Context } from "../../../context.js";
import { InitFn, SetupFn } from "./types.js";
import { Signal } from "../../../../signals/signal.js";
import { InitFunction, Setup } from "./types.js";
import { OpSignal } from "../../../../signals/op_signal.js";

@@ -13,4 +13,4 @@ export declare class Use<C extends Context = Context> {

rerender(): void;
setup(up: Setup): void;
init<R>(start: InitFunction<R>): R;
setup(func: SetupFn): void;
init<R>(func: InitFn<R>): R;
prepare<T>(prep: () => T): T;

@@ -17,0 +17,0 @@ state<T>(init: T | (() => T)): readonly [T, (v: T) => void, () => T];

@@ -53,14 +53,14 @@ import { maptool } from "../../../../tools/maptool.js";

}
setup(up) {
setup(func) {
const count = this.#counter.pull();
if (!this.#setups.has(count)) {
this.#setups.set(count, up);
this.#setdowns.add(up());
this.#setups.set(count, func);
this.#setdowns.add(func());
}
}
init(start) {
init(func) {
const count = this.#counter.pull();
if (!this.#initStarts.has(count)) {
this.#initStarts.set(count, start);
const [result, down] = start();
this.#initStarts.set(count, func);
const [result, down] = func();
this.#initResults.set(count, result);

@@ -67,0 +67,0 @@ this.#initDowns.add(down);

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc