/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ "use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; // src/main.ts var main_exports = {}; __export(main_exports, { default: () => main_default }); module.exports = __toCommonJS(main_exports); // src/plugin.ts var import_obsidian6 = require("obsidian"); // node_modules/solid-js/dist/solid.js var sharedConfig = { context: void 0, registry: void 0 }; function setHydrateContext(context) { sharedConfig.context = context; } function nextHydrateContext() { return { ...sharedConfig.context, id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`, count: 0 }; } var equalFn = (a, b) => a === b; var $PROXY = Symbol("solid-proxy"); var $TRACK = Symbol("solid-track"); var $DEVCOMP = Symbol("solid-dev-component"); var signalOptions = { equals: equalFn }; var ERROR = null; var runEffects = runQueue; var STALE = 1; var PENDING = 2; var UNOWNED = { owned: null, cleanups: null, context: null, owner: null }; var Owner = null; var Transition = null; var Scheduler = null; var ExternalSourceFactory = null; var Listener = null; var Updates = null; var Effects = null; var ExecCount = 0; var [transPending, setTransPending] = /* @__PURE__ */ createSignal(false); function createRoot(fn, detachedOwner) { const listener = Listener, owner = Owner, unowned = fn.length === 0, root = unowned ? UNOWNED : { owned: null, cleanups: null, context: null, owner: detachedOwner === void 0 ? owner : detachedOwner }, updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root))); Owner = root; Listener = null; try { return runUpdates(updateFn, true); } finally { Listener = listener; Owner = owner; } } function createSignal(value, options) { options = options ? Object.assign({}, signalOptions, options) : signalOptions; const s = { value, observers: null, observerSlots: null, comparator: options.equals || void 0 }; const setter = (value2) => { if (typeof value2 === "function") { if (Transition && Transition.running && Transition.sources.has(s)) value2 = value2(s.tValue); else value2 = value2(s.value); } return writeSignal(s, value2); }; return [readSignal.bind(s), setter]; } function createRenderEffect(fn, value, options) { const c = createComputation(fn, value, false, STALE); if (Scheduler && Transition && Transition.running) Updates.push(c); else updateComputation(c); } function createEffect(fn, value, options) { runEffects = runUserEffects; const c = createComputation(fn, value, false, STALE), s = SuspenseContext && lookup(Owner, SuspenseContext.id); if (s) c.suspense = s; if (!options || !options.render) c.user = true; Effects ? Effects.push(c) : updateComputation(c); } function createMemo(fn, value, options) { options = options ? Object.assign({}, signalOptions, options) : signalOptions; const c = createComputation(fn, value, true, 0); c.observers = null; c.observerSlots = null; c.comparator = options.equals || void 0; if (Scheduler && Transition && Transition.running) { c.tState = STALE; Updates.push(c); } else updateComputation(c); return readSignal.bind(c); } function untrack(fn) { if (Listener === null) return fn(); const listener = Listener; Listener = null; try { return fn(); } finally { Listener = listener; } } function onMount(fn) { createEffect(() => untrack(fn)); } function onCleanup(fn) { if (Owner === null) ; else if (Owner.cleanups === null) Owner.cleanups = [fn]; else Owner.cleanups.push(fn); return fn; } function catchError(fn, handler) { ERROR || (ERROR = Symbol("error")); Owner = createComputation(void 0, void 0, true); Owner.context = { [ERROR]: [handler] }; if (Transition && Transition.running) Transition.sources.add(Owner); try { return fn(); } catch (err) { handleError(err); } finally { Owner = Owner.owner; } } function startTransition(fn) { if (Transition && Transition.running) { fn(); return Transition.done; } const l = Listener; const o = Owner; return Promise.resolve().then(() => { Listener = l; Owner = o; let t; if (Scheduler || SuspenseContext) { t = Transition || (Transition = { sources: /* @__PURE__ */ new Set(), effects: [], promises: /* @__PURE__ */ new Set(), disposed: /* @__PURE__ */ new Set(), queue: /* @__PURE__ */ new Set(), running: true }); t.done || (t.done = new Promise((res) => t.resolve = res)); t.running = true; } runUpdates(fn, false); Listener = Owner = null; return t ? t.done : void 0; }); } function createContext(defaultValue, options) { const id = Symbol("context"); return { id, Provider: createProvider(id), defaultValue }; } function useContext(context) { let ctx; return (ctx = lookup(Owner, context.id)) !== void 0 ? ctx : context.defaultValue; } function children(fn) { const children2 = createMemo(fn); const memo = createMemo(() => resolveChildren(children2())); memo.toArray = () => { const c = memo(); return Array.isArray(c) ? c : c != null ? [c] : []; }; return memo; } var SuspenseContext; function readSignal() { const runningTransition = Transition && Transition.running; if (this.sources && (runningTransition ? this.tState : this.state)) { if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this); else { const updates = Updates; Updates = null; runUpdates(() => lookUpstream(this), false); Updates = updates; } } if (Listener) { const sSlot = this.observers ? this.observers.length : 0; if (!Listener.sources) { Listener.sources = [this]; Listener.sourceSlots = [sSlot]; } else { Listener.sources.push(this); Listener.sourceSlots.push(sSlot); } if (!this.observers) { this.observers = [Listener]; this.observerSlots = [Listener.sources.length - 1]; } else { this.observers.push(Listener); this.observerSlots.push(Listener.sources.length - 1); } } if (runningTransition && Transition.sources.has(this)) return this.tValue; return this.value; } function writeSignal(node, value, isComp) { let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value; if (!node.comparator || !node.comparator(current, value)) { if (Transition) { const TransitionRunning = Transition.running; if (TransitionRunning || !isComp && Transition.sources.has(node)) { Transition.sources.add(node); node.tValue = value; } if (!TransitionRunning) node.value = value; } else node.value = value; if (node.observers && node.observers.length) { runUpdates(() => { for (let i = 0; i < node.observers.length; i += 1) { const o = node.observers[i]; const TransitionRunning = Transition && Transition.running; if (TransitionRunning && Transition.disposed.has(o)) continue; if (TransitionRunning ? !o.tState : !o.state) { if (o.pure) Updates.push(o); else Effects.push(o); if (o.observers) markDownstream(o); } if (!TransitionRunning) o.state = STALE; else o.tState = STALE; } if (Updates.length > 1e6) { Updates = []; if (false) ; throw new Error(); } }, false); } } return value; } function updateComputation(node) { if (!node.fn) return; cleanNode(node); const owner = Owner, listener = Listener, time = ExecCount; Listener = Owner = node; runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time); if (Transition && !Transition.running && Transition.sources.has(node)) { queueMicrotask(() => { runUpdates(() => { Transition && (Transition.running = true); Listener = Owner = node; runComputation(node, node.tValue, time); Listener = Owner = null; }, false); }); } Listener = listener; Owner = owner; } function runComputation(node, value, time) { let nextValue; try { nextValue = node.fn(value); } catch (err) { if (node.pure) { if (Transition && Transition.running) { node.tState = STALE; node.tOwned && node.tOwned.forEach(cleanNode); node.tOwned = void 0; } else { node.state = STALE; node.owned && node.owned.forEach(cleanNode); node.owned = null; } } node.updatedAt = time + 1; return handleError(err); } if (!node.updatedAt || node.updatedAt <= time) { if (node.updatedAt != null && "observers" in node) { writeSignal(node, nextValue, true); } else if (Transition && Transition.running && node.pure) { Transition.sources.add(node); node.tValue = nextValue; } else node.value = nextValue; node.updatedAt = time; } } function createComputation(fn, init, pure, state = STALE, options) { const c = { fn, state, updatedAt: null, owned: null, sources: null, sourceSlots: null, cleanups: null, value: init, owner: Owner, context: null, pure }; if (Transition && Transition.running) { c.state = 0; c.tState = state; } if (Owner === null) ; else if (Owner !== UNOWNED) { if (Transition && Transition.running && Owner.pure) { if (!Owner.tOwned) Owner.tOwned = [c]; else Owner.tOwned.push(c); } else { if (!Owner.owned) Owner.owned = [c]; else Owner.owned.push(c); } } if (ExternalSourceFactory) { const [track, trigger] = createSignal(void 0, { equals: false }); const ordinary = ExternalSourceFactory(c.fn, trigger); onCleanup(() => ordinary.dispose()); const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose()); const inTransition = ExternalSourceFactory(c.fn, triggerInTransition); c.fn = (x) => { track(); return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x); }; } return c; } function runTop(node) { const runningTransition = Transition && Transition.running; if ((runningTransition ? node.tState : node.state) === 0) return; if ((runningTransition ? node.tState : node.state) === PENDING) return lookUpstream(node); if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node); const ancestors = [node]; while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) { if (runningTransition && Transition.disposed.has(node)) return; if (runningTransition ? node.tState : node.state) ancestors.push(node); } for (let i = ancestors.length - 1; i >= 0; i--) { node = ancestors[i]; if (runningTransition) { let top = node, prev = ancestors[i + 1]; while ((top = top.owner) && top !== prev) { if (Transition.disposed.has(top)) return; } } if ((runningTransition ? node.tState : node.state) === STALE) { updateComputation(node); } else if ((runningTransition ? node.tState : node.state) === PENDING) { const updates = Updates; Updates = null; runUpdates(() => lookUpstream(node, ancestors[0]), false); Updates = updates; } } } function runUpdates(fn, init) { if (Updates) return fn(); let wait = false; if (!init) Updates = []; if (Effects) wait = true; else Effects = []; ExecCount++; try { const res = fn(); completeUpdates(wait); return res; } catch (err) { if (!wait) Effects = null; Updates = null; handleError(err); } } function completeUpdates(wait) { if (Updates) { if (Scheduler && Transition && Transition.running) scheduleQueue(Updates); else runQueue(Updates); Updates = null; } if (wait) return; let res; if (Transition) { if (!Transition.promises.size && !Transition.queue.size) { const sources = Transition.sources; const disposed = Transition.disposed; Effects.push.apply(Effects, Transition.effects); res = Transition.resolve; for (const e2 of Effects) { "tState" in e2 && (e2.state = e2.tState); delete e2.tState; } Transition = null; runUpdates(() => { for (const d of disposed) cleanNode(d); for (const v of sources) { v.value = v.tValue; if (v.owned) { for (let i = 0, len = v.owned.length; i < len; i++) cleanNode(v.owned[i]); } if (v.tOwned) v.owned = v.tOwned; delete v.tValue; delete v.tOwned; v.tState = 0; } setTransPending(false); }, false); } else if (Transition.running) { Transition.running = false; Transition.effects.push.apply(Transition.effects, Effects); Effects = null; setTransPending(true); return; } } const e = Effects; Effects = null; if (e.length) runUpdates(() => runEffects(e), false); if (res) res(); } function runQueue(queue) { for (let i = 0; i < queue.length; i++) runTop(queue[i]); } function scheduleQueue(queue) { for (let i = 0; i < queue.length; i++) { const item = queue[i]; const tasks = Transition.queue; if (!tasks.has(item)) { tasks.add(item); Scheduler(() => { tasks.delete(item); runUpdates(() => { Transition.running = true; runTop(item); }, false); Transition && (Transition.running = false); }); } } } function runUserEffects(queue) { let i, userLength = 0; for (i = 0; i < queue.length; i++) { const e = queue[i]; if (!e.user) runTop(e); else queue[userLength++] = e; } if (sharedConfig.context) setHydrateContext(); for (i = 0; i < userLength; i++) runTop(queue[i]); } function lookUpstream(node, ignore) { const runningTransition = Transition && Transition.running; if (runningTransition) node.tState = 0; else node.state = 0; for (let i = 0; i < node.sources.length; i += 1) { const source = node.sources[i]; if (source.sources) { const state = runningTransition ? source.tState : source.state; if (state === STALE) { if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source); } else if (state === PENDING) lookUpstream(source, ignore); } } } function markDownstream(node) { const runningTransition = Transition && Transition.running; for (let i = 0; i < node.observers.length; i += 1) { const o = node.observers[i]; if (runningTransition ? !o.tState : !o.state) { if (runningTransition) o.tState = PENDING; else o.state = PENDING; if (o.pure) Updates.push(o); else Effects.push(o); o.observers && markDownstream(o); } } } function cleanNode(node) { let i; if (node.sources) { while (node.sources.length) { const source = node.sources.pop(), index = node.sourceSlots.pop(), obs = source.observers; if (obs && obs.length) { const n = obs.pop(), s = source.observerSlots.pop(); if (index < obs.length) { n.sourceSlots[s] = index; obs[index] = n; source.observerSlots[index] = s; } } } } if (Transition && Transition.running && node.pure) { if (node.tOwned) { for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]); delete node.tOwned; } reset(node, true); } else if (node.owned) { for (i = node.owned.length - 1; i >= 0; i--) cleanNode(node.owned[i]); node.owned = null; } if (node.cleanups) { for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i](); node.cleanups = null; } if (Transition && Transition.running) node.tState = 0; else node.state = 0; node.context = null; } function reset(node, top) { if (!top) { node.tState = 0; Transition.disposed.add(node); } if (node.owned) { for (let i = 0; i < node.owned.length; i++) reset(node.owned[i]); } } function castError(err) { if (err instanceof Error) return err; return new Error(typeof err === "string" ? err : "Unknown error", { cause: err }); } function handleError(err, owner = Owner) { const fns = ERROR && lookup(owner, ERROR); const error = castError(err); if (!fns) throw error; if (Effects) Effects.push({ fn() { try { for (const f of fns) f(error); } catch (e) { handleError(e, (owner == null ? void 0 : owner.owner) || null); } }, state: STALE }); else { try { for (const f of fns) f(error); } catch (e) { handleError(e, (owner == null ? void 0 : owner.owner) || null); } } } function lookup(owner, key) { return owner ? owner.context && owner.context[key] !== void 0 ? owner.context[key] : lookup(owner.owner, key) : void 0; } function resolveChildren(children2) { if (typeof children2 === "function" && !children2.length) return resolveChildren(children2()); if (Array.isArray(children2)) { const results = []; for (let i = 0; i < children2.length; i++) { const result = resolveChildren(children2[i]); Array.isArray(result) ? results.push.apply(results, result) : results.push(result); } return results; } return children2; } function createProvider(id, options) { return function provider(props) { let res; createRenderEffect(() => res = untrack(() => { Owner.context = { [id]: props.value }; return children(() => props.children); }), void 0); return res; }; } var FALLBACK = Symbol("fallback"); function dispose(d) { for (let i = 0; i < d.length; i++) d[i](); } function mapArray(list, mapFn, options = {}) { let items = [], mapped = [], disposers = [], len = 0, indexes = mapFn.length > 1 ? [] : null; onCleanup(() => dispose(disposers)); return () => { let newItems = list() || [], i, j; newItems[$TRACK]; return untrack(() => { let newLen = newItems.length, newIndices, newIndicesNext, temp, tempdisposers, tempIndexes, start, end, newEnd, item; if (newLen === 0) { if (len !== 0) { dispose(disposers); disposers = []; items = []; mapped = []; len = 0; indexes && (indexes = []); } if (options.fallback) { items = [FALLBACK]; mapped[0] = createRoot((disposer) => { disposers[0] = disposer; return options.fallback(); }); len = 1; } } else if (len === 0) { mapped = new Array(newLen); for (j = 0; j < newLen; j++) { items[j] = newItems[j]; mapped[j] = createRoot(mapper); } len = newLen; } else { temp = new Array(newLen); tempdisposers = new Array(newLen); indexes && (tempIndexes = new Array(newLen)); for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++) ; for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) { temp[newEnd] = mapped[end]; tempdisposers[newEnd] = disposers[end]; indexes && (tempIndexes[newEnd] = indexes[end]); } newIndices = /* @__PURE__ */ new Map(); newIndicesNext = new Array(newEnd + 1); for (j = newEnd; j >= start; j--) { item = newItems[j]; i = newIndices.get(item); newIndicesNext[j] = i === void 0 ? -1 : i; newIndices.set(item, j); } for (i = start; i <= end; i++) { item = items[i]; j = newIndices.get(item); if (j !== void 0 && j !== -1) { temp[j] = mapped[i]; tempdisposers[j] = disposers[i]; indexes && (tempIndexes[j] = indexes[i]); j = newIndicesNext[j]; newIndices.set(item, j); } else disposers[i](); } for (j = start; j < newLen; j++) { if (j in temp) { mapped[j] = temp[j]; disposers[j] = tempdisposers[j]; if (indexes) { indexes[j] = tempIndexes[j]; indexes[j](j); } } else mapped[j] = createRoot(mapper); } mapped = mapped.slice(0, len = newLen); items = newItems.slice(0); } return mapped; }); function mapper(disposer) { disposers[j] = disposer; if (indexes) { const [s, set] = createSignal(j); indexes[j] = set; return mapFn(newItems[j], s); } return mapFn(newItems[j]); } }; } var hydrationEnabled = false; function createComponent(Comp, props) { if (hydrationEnabled) { if (sharedConfig.context) { const c = sharedConfig.context; setHydrateContext(nextHydrateContext()); const r = untrack(() => Comp(props || {})); setHydrateContext(c); return r; } } return untrack(() => Comp(props || {})); } var narrowedError = (name) => `Stale read from <${name}>.`; function For(props) { const fallback = "fallback" in props && { fallback: () => props.fallback }; return createMemo(mapArray(() => props.each, props.children, fallback || void 0)); } function Show(props) { const keyed = props.keyed; const condition = createMemo(() => props.when, void 0, { equals: (a, b) => keyed ? a === b : !a === !b }); return createMemo(() => { const c = condition(); if (c) { const child = props.children; const fn = typeof child === "function" && child.length > 0; return fn ? untrack(() => child(keyed ? c : () => { if (!untrack(condition)) throw narrowedError("Show"); return props.when; })) : child; } return props.fallback; }, void 0, void 0); } function Switch(props) { let keyed = false; const equals = (a, b) => a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]; const conditions = children(() => props.children), evalConditions = createMemo(() => { let conds = conditions(); if (!Array.isArray(conds)) conds = [conds]; for (let i = 0; i < conds.length; i++) { const c = conds[i].when; if (c) { keyed = !!conds[i].keyed; return [i, c, conds[i]]; } } return [-1]; }, void 0, { equals }); return createMemo(() => { const [index, when, cond] = evalConditions(); if (index < 0) return props.fallback; const c = cond.children; const fn = typeof c === "function" && c.length > 0; return fn ? untrack(() => c(keyed ? when : () => { if (untrack(evalConditions)[0] !== index) throw narrowedError("Match"); return cond.when; })) : c; }, void 0, void 0); } function Match(props) { return props; } var Errors; function ErrorBoundary(props) { let err; let v; if (sharedConfig.context && sharedConfig.load && (v = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count))) err = v[0]; const [errored, setErrored] = createSignal(err, void 0); Errors || (Errors = /* @__PURE__ */ new Set()); Errors.add(setErrored); onCleanup(() => Errors.delete(setErrored)); return createMemo(() => { let e; if (e = errored()) { const f = props.fallback; return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f; } return catchError(() => props.children, setErrored); }, void 0, void 0); } var SuspenseListContext = createContext(); // node_modules/solid-js/web/dist/web.js var booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"]; var Properties = /* @__PURE__ */ new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]); function reconcileArrays(parentNode, a, b) { let bLength = b.length, aEnd = a.length, bEnd = bLength, aStart = 0, bStart = 0, after = a[aEnd - 1].nextSibling, map = null; while (aStart < aEnd || bStart < bEnd) { if (a[aStart] === b[bStart]) { aStart++; bStart++; continue; } while (a[aEnd - 1] === b[bEnd - 1]) { aEnd--; bEnd--; } if (aEnd === aStart) { const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling : b[bEnd - bStart] : after; while (bStart < bEnd) parentNode.insertBefore(b[bStart++], node); } else if (bEnd === bStart) { while (aStart < aEnd) { if (!map || !map.has(a[aStart])) a[aStart].remove(); aStart++; } } else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) { const node = a[--aEnd].nextSibling; parentNode.insertBefore(b[bStart++], a[aStart++].nextSibling); parentNode.insertBefore(b[--bEnd], node); a[aEnd] = b[bEnd]; } else { if (!map) { map = /* @__PURE__ */ new Map(); let i = bStart; while (i < bEnd) map.set(b[i], i++); } const index = map.get(a[aStart]); if (index != null) { if (bStart < index && index < bEnd) { let i = aStart, sequence = 1, t; while (++i < aEnd && i < bEnd) { if ((t = map.get(a[i])) == null || t !== index + sequence) break; sequence++; } if (sequence > index - bStart) { const node = a[aStart]; while (bStart < index) parentNode.insertBefore(b[bStart++], node); } else parentNode.replaceChild(b[bStart++], a[aStart++]); } else aStart++; } else a[aStart++].remove(); } } } var $$EVENTS = "_$DX_DELEGATE"; function render(code, element, init, options = {}) { let disposer; createRoot((dispose2) => { disposer = dispose2; element === document ? code() : insert(element, code(), element.firstChild ? null : void 0, init); }, options.owner); return () => { disposer(); element.textContent = ""; }; } function template(html, isCE, isSVG) { let node; const create = () => { const t = document.createElement("template"); t.innerHTML = html; return isSVG ? t.content.firstChild.firstChild : t.content.firstChild; }; const fn = isCE ? () => untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true); fn.cloneNode = fn; return fn; } function delegateEvents(eventNames, document2 = window.document) { const e = document2[$$EVENTS] || (document2[$$EVENTS] = /* @__PURE__ */ new Set()); for (let i = 0, l = eventNames.length; i < l; i++) { const name = eventNames[i]; if (!e.has(name)) { e.add(name); document2.addEventListener(name, eventHandler); } } } function setAttribute(node, name, value) { if (value == null) node.removeAttribute(name); else node.setAttribute(name, value); } function className(node, value) { if (value == null) node.removeAttribute("class"); else node.className = value; } function use(fn, element, arg) { return untrack(() => fn(element, arg)); } function insert(parent, accessor, marker, initial) { if (marker !== void 0 && !initial) initial = []; if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker); createRenderEffect((current) => insertExpression(parent, accessor(), current, marker), initial); } function eventHandler(e) { const key = `$$${e.type}`; let node = e.composedPath && e.composedPath()[0] || e.target; if (e.target !== node) { Object.defineProperty(e, "target", { configurable: true, value: node }); } Object.defineProperty(e, "currentTarget", { configurable: true, get() { return node || document; } }); if (sharedConfig.registry && !sharedConfig.done) sharedConfig.done = _$HY.done = true; while (node) { const handler = node[key]; if (handler && !node.disabled) { const data = node[`${key}Data`]; data !== void 0 ? handler.call(node, data, e) : handler.call(node, e); if (e.cancelBubble) return; } node = node._$host || node.parentNode || node.host; } } function insertExpression(parent, value, current, marker, unwrapArray) { if (sharedConfig.context) { !current && (current = [...parent.childNodes]); let cleaned = []; for (let i = 0; i < current.length; i++) { const node = current[i]; if (node.nodeType === 8 && node.data.slice(0, 2) === "!$") node.remove(); else cleaned.push(node); } current = cleaned; } while (typeof current === "function") current = current(); if (value === current) return current; const t = typeof value, multi = marker !== void 0; parent = multi && current[0] && current[0].parentNode || parent; if (t === "string" || t === "number") { if (sharedConfig.context) return current; if (t === "number") value = value.toString(); if (multi) { let node = current[0]; if (node && node.nodeType === 3) { node.data = value; } else node = document.createTextNode(value); current = cleanChildren(parent, current, marker, node); } else { if (current !== "" && typeof current === "string") { current = parent.firstChild.data = value; } else current = parent.textContent = value; } } else if (value == null || t === "boolean") { if (sharedConfig.context) return current; current = cleanChildren(parent, current, marker); } else if (t === "function") { createRenderEffect(() => { let v = value(); while (typeof v === "function") v = v(); current = insertExpression(parent, v, current, marker); }); return () => current; } else if (Array.isArray(value)) { const array = []; const currentArray = current && Array.isArray(current); if (normalizeIncomingArray(array, value, current, unwrapArray)) { createRenderEffect(() => current = insertExpression(parent, array, current, marker, true)); return () => current; } if (sharedConfig.context) { if (!array.length) return current; for (let i = 0; i < array.length; i++) { if (array[i].parentNode) return current = array; } } if (array.length === 0) { current = cleanChildren(parent, current, marker); if (multi) return current; } else if (currentArray) { if (current.length === 0) { appendNodes(parent, array, marker); } else reconcileArrays(parent, current, array); } else { current && cleanChildren(parent); appendNodes(parent, array); } current = array; } else if (value.nodeType) { if (sharedConfig.context && value.parentNode) return current = multi ? [value] : value; if (Array.isArray(current)) { if (multi) return current = cleanChildren(parent, current, marker, value); cleanChildren(parent, current, null, value); } else if (current == null || current === "" || !parent.firstChild) { parent.appendChild(value); } else parent.replaceChild(value, parent.firstChild); current = value; } else console.warn(`Unrecognized value. Skipped inserting`, value); return current; } function normalizeIncomingArray(normalized, array, current, unwrap) { let dynamic = false; for (let i = 0, len = array.length; i < len; i++) { let item = array[i], prev = current && current[i], t; if (item == null || item === true || item === false) ; else if ((t = typeof item) === "object" && item.nodeType) { normalized.push(item); } else if (Array.isArray(item)) { dynamic = normalizeIncomingArray(normalized, item, prev) || dynamic; } else if (t === "function") { if (unwrap) { while (typeof item === "function") item = item(); dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item], Array.isArray(prev) ? prev : [prev]) || dynamic; } else { normalized.push(item); dynamic = true; } } else { const value = String(item); if (prev && prev.nodeType === 3 && prev.data === value) normalized.push(prev); else normalized.push(document.createTextNode(value)); } } return dynamic; } function appendNodes(parent, array, marker = null) { for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker); } function cleanChildren(parent, current, marker, replacement) { if (marker === void 0) return parent.textContent = ""; const node = replacement || document.createTextNode(""); if (current.length) { let inserted = false; for (let i = current.length - 1; i >= 0; i--) { const el = current[i]; if (node !== el) { const isParent = el.parentNode === parent; if (!inserted && !i) isParent ? parent.replaceChild(node, el) : parent.insertBefore(node, marker); else isParent && el.remove(); } else inserted = true; } } else parent.insertBefore(node, marker); return [node]; } // src/sidebarView.tsx var import_obsidian5 = require("obsidian"); // src/settings.ts var import_obsidian = require("obsidian"); function isOpen(depth, mode) { if (mode == "expanded") { return true; } if (mode == "leaf-collapsed" && depth == 0) { return true; } if (mode == "root-collapsed" && depth != 0) { return true; } return false; } var DEFAULT_SETTINGS = { expansionMode: "expanded", ignoreNulls: false, nullValue: "", skipKey: "metatable", filterKeys: ["metatable", "frontmatter"], filterMode: "ignore", autolinks: false, naked: false, theme: "light" }; var MetatableSettingTab = class extends import_obsidian.PluginSettingTab { constructor(app, plugin) { super(app, plugin); __publicField(this, "plugin"); this.plugin = plugin; } async display() { const { containerEl, plugin } = this; containerEl.empty(); containerEl.createEl("h2", { text: "Metatable Settings" }); new import_obsidian.Setting(containerEl).setName("Expansion level").setDesc("Level of expansion of the metatable tree").addDropdown((drop) => drop.addOption("expanded", "Fully expanded").addOption("leaf-collapsed", "Collapse leafs").addOption("all-collapsed", "Collapse all").addOption("root-collapsed", "Collapse root").setValue(plugin.settings.expansionMode).onChange(async (value) => { plugin.settings.expansionMode = value; await plugin.saveSettings(); })); new import_obsidian.Setting(containerEl).setName("Skip key").setDesc("When this key is found and `true`, the metatable will not be displayed").addText((text) => text.setValue(plugin.settings.skipKey).onChange(async (value) => { plugin.settings.skipKey = value; await plugin.saveSettings(); })); containerEl.createEl("h3", { text: "Nulls" }); new import_obsidian.Setting(containerEl).setName("Ignore null values").setDesc("Ignore any member with a null value.").addToggle((setting) => setting.setValue(plugin.settings.ignoreNulls).onChange(async (value) => { plugin.settings.ignoreNulls = value; await plugin.saveSettings(); this.display(); })); if (!plugin.settings.ignoreNulls) { new import_obsidian.Setting(containerEl).setName("Null value").setDesc("Text to show when a key has no value. Defaults to nothing").addText((text) => text.setValue(plugin.settings.nullValue).onChange(async (value) => { plugin.settings.nullValue = value; await plugin.saveSettings(); })); } containerEl.createEl("h3", { text: "Filter" }); new import_obsidian.Setting(containerEl).setName("Filter mode").setDesc("Either ignore or keep the filter keys").addDropdown((drop) => drop.addOption("ignore", "Ignore").addOption("keep", "Keep").setValue(plugin.settings.filterMode).onChange(async (value) => { plugin.settings.filterMode = value; await plugin.saveSettings(); })); new import_obsidian.Setting(containerEl).setName("Filter keys").setDesc("Any empty field will be ignored."); let keyset = plugin.settings.filterKeys; let filterKeys2 = containerEl.createEl("ol"); for (const [idx, originalValue] of [...keyset].entries()) { if (originalValue === "") { continue; } addFilterInput(originalValue, filterKeys2, keyset, plugin, idx); } new import_obsidian.Setting(containerEl).addButton((x) => x.setButtonText("Add key").onClick(async () => { addFilterInput("", filterKeys2, keyset, plugin, keyset.length); })); containerEl.createEl("h3", { text: "Experimental" }); new import_obsidian.Setting(containerEl).setName("Autolink").setDesc("Enables autolinks for wikilinks `[[target]]`, frontmatter links `%target%` and local links `./deep/target`").addToggle((setting) => setting.setValue(plugin.settings.autolinks).onChange(async (value) => { plugin.settings.autolinks = value; await plugin.saveSettings(); })); new import_obsidian.Setting(containerEl).setName("Naked").setDesc("Removes the Shadow DOM and the default CSS so you can bring your own via CSS snippets.").addToggle((setting) => setting.setValue(plugin.settings.naked).onChange(async (value) => { plugin.settings.naked = value; await plugin.saveSettings(); })); } }; function addFilterInput(originalValue, el, keyset, plugin, idx) { const item = el.createEl("li"); const input = item.createEl("input"); item.setAttribute("id", `filter-${idx}`); input.setAttribute("type", "text"); input.setAttribute("value", originalValue); input.setAttribute("data-prev", originalValue); input.addEventListener("input", async (e) => { let target = e.target; keyset[idx] = target.value; input.setAttribute("data-prev", target.value); plugin.settings.filterKeys = keyset; await plugin.saveSettings(); }); } // src/value.ts function isLeaf(value) { return value === null || ["string", "number", "boolean"].some((kind) => typeof value == kind); } function isSet(value) { return value !== null && typeof value == "object" && !Array.isArray(value); } function isEmptyValue(value) { if (typeof value == "string" || Array.isArray(value)) { return value.length == 0; } if (typeof value == "object" && value != null) { return Object.keys(value).length == 0; } return value == null; } // src/core.ts function observeTheme(el) { const observer = new MutationObserver((mutationList) => { mutationList.forEach((mutation) => { const target = mutation.target; if (target.hasClass("theme-light")) { el.classList.add("light"); el.classList.remove("dark"); } else { el.classList.add("dark"); el.classList.remove("light"); } }); }); const body = document.querySelector("body"); observer.observe(body, { attributes: true, attributeFilter: ["class"] }); return observer; } function queryTheme() { const body = document.querySelector("body"); return body.hasClass("theme-light") ? "light" : "dark"; } function cleanData(data, settings) { if (data === void 0 || data === null) { return; } if (typeof data == "string") { return; } if (data[settings.skipKey] === true) { return; } let entries = Object.entries(data); entries = filterKeys(entries, settings.filterKeys, settings.filterMode); if (settings.ignoreNulls) { entries = filterNulls(entries); } entries = normalise(entries); return entries.length == 0 ? void 0 : Object.fromEntries(entries); } function normalise(entries) { return entries.map(([key, value]) => { if (["tags", "aliases"].includes(key.toLocaleLowerCase())) { return [key, normaliseSpuriousArray(value)]; } return [key, value]; }); } function normaliseSpuriousArray(data) { if (data == null) { return []; } if (!Array.isArray(data) && typeof data != "string") { throw new Error("Tags must be an array or a string"); } const result = typeof data == "string" ? data.split(",").flatMap((x) => x.trim().split(" ")) : data; return result.filter((x) => x && x.length != 0); } function filterKeys(entries, keys, mode) { const predicate = mode == "ignore" ? (x) => !x : (x) => x; return entries.filter(([key, _value]) => predicate(keys.some((x) => x === key))); } function filterNulls(entries) { return entries.filter(([_key, value]) => !isEmptyValue(value)); } // src/mixture.tsx function useMixture() { return useContext(MixtureContext); } var MixtureContext = createContext(); function MixtureProvider(props) { const app = props.app; const settings = props.settings; const workspace = app.workspace; const searchFn = app.internalPlugins.getPluginById("global-search").instance.openGlobalSearch.bind(app.workspace); const openLinkFn = app.workspace.openLinkText.bind(app.workspace); onCleanup(() => { props.themeObserver.disconnect(); }); const mixture = { app, workspace, settings, search(term) { searchFn(term); }, isOpen(depth) { return isOpen(depth, settings.expansionMode); }, isNaked: settings.naked, openTag(tag) { searchFn(`tag:${tag}`); }, openNote(note) { openLinkFn(note, ""); }, cleanData: (data) => cleanData(data, settings) }; return createComponent(MixtureContext.Provider, { value: mixture, get children() { return props.children; } }); } // src/components/Sidebar.tsx var import_obsidian4 = require("obsidian"); // src/components/List.tsx var _tmpl$ = /* @__PURE__ */ template(`
Error: `); var _tmpl$5 = /* @__PURE__ */ template(`