mancha 0.17.0 → 0.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ on:
10
10
  permissions:
11
11
  contents: read
12
12
  pages: write
13
- id-token: write
13
+ id-token: write # Required for GitHub Pages and npm OIDC trusted publishing
14
14
 
15
15
  concurrency:
16
16
  group: "pages"
@@ -27,7 +27,7 @@ jobs:
27
27
  - name: Setup Node.js
28
28
  uses: actions/setup-node@v4
29
29
  with:
30
- node-version: '22'
30
+ node-version: '24'
31
31
  registry-url: 'https://registry.npmjs.org'
32
32
 
33
33
  - name: Install dependencies
@@ -77,6 +77,9 @@ jobs:
77
77
  runs-on: ubuntu-latest
78
78
  name: Publish to NPM
79
79
  if: startsWith(github.ref, 'refs/tags/v')
80
+ permissions:
81
+ contents: read
82
+ id-token: write # Required for npm OIDC trusted publishing
80
83
  steps:
81
84
  - name: Checkout code
82
85
  uses: actions/checkout@v4
@@ -84,7 +87,7 @@ jobs:
84
87
  - name: Setup Node.js
85
88
  uses: actions/setup-node@v4
86
89
  with:
87
- node-version: '22'
90
+ node-version: '24'
88
91
  registry-url: 'https://registry.npmjs.org'
89
92
 
90
93
  - name: Install dependencies
@@ -96,7 +99,5 @@ jobs:
96
99
  name: build-artifacts
97
100
  path: dist/
98
101
 
99
- - name: Publish to NPM
100
- run: npm publish
101
- env:
102
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
102
+ - name: Publish to NPM with provenance
103
+ run: npm publish --provenance --access public
package/README.md CHANGED
@@ -157,6 +157,17 @@ element tag or attributes match a specific criteria. Here's the list of attribut
157
157
  ```html
158
158
  <video :prop:src="buildSrc()"></video>
159
159
  ```
160
+ - `:render` links an element to a JavaScript ES module for initialization
161
+ ```html
162
+ <canvas :render="./chart-init.js"></canvas>
163
+ ```
164
+ The module's default export is called with the element and renderer:
165
+ ```js
166
+ // chart-init.js
167
+ export default function (elem, renderer) {
168
+ new Chart(elem, { type: "bar" });
169
+ }
170
+ ```
160
171
  - `{{ value }}` replaces `value` in text nodes
161
172
  ```html
162
173
  <button :data="{label: 'Click Me'}">{{ label }}</button>
@@ -250,7 +261,7 @@ illustrated with an example:
250
261
  <!-- Hello, stranger -->
251
262
  <h1>Hello, {{ name }}</h1>
252
263
 
253
- <!-- undefined -->
264
+ <!-- Initially "undefined", but reactive to later changes -->
254
265
  <span>{{ message }}</span>
255
266
 
256
267
  <!-- How are you, danger? The secret message is "secret" and the key is "1234" -->
@@ -263,8 +274,10 @@ illustrated with an example:
263
274
  By default, the target root element is the `body` tag. So, any variables defined in the body's
264
275
  `:data` attribute are available to the main renderer.
265
276
 
266
- In the example above, the variable `message` is only available to the `<p>` tag and all elements
267
- under that tag, if any. Since the variables are not accessible via the global object, you'll need
277
+ In the example above, the `<span>` references `message` which is not defined in the body's `:data`.
278
+ This auto-initializes `message` to `undefined` and attaches an observer, so setting `$.message`
279
+ later will update the `<span>` content. The `<p>` tag has its own local `message` variable which
280
+ shadows any parent value. Since the variables are not accessible via the global object, you'll need
268
281
  to retrieve the renderer from the element's properties:
269
282
 
270
283
  ```js
@@ -275,8 +288,9 @@ await $.mount(document.body);
275
288
  // This modifies the `name` variable in all the renderer contexts.
276
289
  $.name = "world";
277
290
 
278
- // This has no effect in the output, because the content of the `<p>` tag is
279
- // bound to its local variable and `message` was undefined at rendering time.
291
+ // This updates the `<span>` content to "bandit" because `message` was
292
+ // auto-initialized when the template referenced it. However, the `<p>` tag
293
+ // still shows "secret" because it has its own local `message` variable.
280
294
  $.message = "bandit";
281
295
 
282
296
  // We extract the subrenderer from the element's properties. Only elements
@@ -289,7 +303,7 @@ subrenderer.$.message = "banana";
289
303
 
290
304
  When accessing variables, `mancha` searches the current renderer first, then the parent, the
291
305
  parent's parent, and so forth until the root renderer is reached. If the requested variable is not
292
- found in the current renderer or any of the ancestor renderers, then `null` is returned:
306
+ found in the current renderer or any of the ancestor renderers, then `undefined` is returned:
293
307
 
294
308
  ```html
295
309
  <body :data="{ name: 'stranger' }">
@@ -298,6 +312,52 @@ found in the current renderer or any of the ancestor renderers, then `null` is r
298
312
  </body>
299
313
  ```
300
314
 
315
+ ### Reactive Undefined Variables
316
+
317
+ When a variable is referenced in a template expression but not yet defined, `mancha` automatically
318
+ initializes it to `undefined` and attaches an observer. This means you can set the variable later
319
+ using the same renderer (or a subrenderer) and the template will reactively update:
320
+
321
+ ```html
322
+ <body>
323
+ <!-- Initially shows "undefined", but updates reactively when `message` is set -->
324
+ <p>{{ message }}</p>
325
+ </body>
326
+ <script type="module">
327
+ const { $ } = Mancha;
328
+ await $.mount(document.body);
329
+
330
+ // The template initially renders with `message` as undefined.
331
+ // Setting it now will trigger a reactive update.
332
+ $.message = "Hello, World!";
333
+ </script>
334
+ ```
335
+
336
+ This behavior is particularly useful with the `:render` attribute, where a JavaScript module can
337
+ set variables that are already referenced in the template:
338
+
339
+ ```html
340
+ <div :render="./init.js">
341
+ <!-- These variables are set by the :render callback -->
342
+ <span>{{ title }}</span>
343
+ <ul :for="item in items">
344
+ <li>{{ item }}</li>
345
+ </ul>
346
+ </div>
347
+ ```
348
+
349
+ ```js
350
+ // init.js
351
+ export default async function (elem, renderer) {
352
+ await renderer.set("title", "My List");
353
+ await renderer.set("items", ["a", "b", "c"]);
354
+ }
355
+ ```
356
+
357
+ The auto-initialization only happens when variables are accessed during an effect (such as template
358
+ rendering). Accessing a variable outside of an effect context will return `undefined` without
359
+ creating an observer.
360
+
301
361
  When setting a variable, there are 3 possible cases:
302
362
 
303
363
  1. The variable has already been defined in the current renderer. Then it gets updated in the
package/dist/browser.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { IRenderer } from "./renderer.js";
2
2
  import type { StoreState } from "./store.js";
3
3
  import type { ParserParams, RenderParams } from "./interfaces.js";
4
+ export { IRenderer } from "./renderer.js";
5
+ export type { ParserParams, RenderParams, RendererPlugin } from "./interfaces.js";
4
6
  export { default as basicCssRules } from "./css_gen_basic.js";
5
7
  export { default as utilsCssRules } from "./css_gen_utils.js";
6
8
  export declare class Renderer<T extends StoreState = StoreState> extends IRenderer<T> {
package/dist/browser.js CHANGED
@@ -1 +1 @@
1
- var e={};e.d=(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const t=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function r(e){if(!function(e){const r=!t.test(e);return r}(e))return e}function i(e){return r(e)}const n={};function s(e){0}"undefined"!=typeof window&&window.TrustedScriptURL;class o{constructor(e,t){this.privateDoNotAccessOrElseWrappedAttributePrefix=t}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const a=o;function l(e){if(function(e){return e instanceof o}(e))return e.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}"undefined"!=typeof window&&window.TrustedHTML;function c(e,t,r,i){if(0===e.length){throw new Error("")}const n=e.map(e=>l(e)),s=r.toLowerCase();if(n.every(e=>0!==s.indexOf(e)))throw new Error(`Attribute "${r}" does not match any of the allowed prefixes.`);t.setAttribute(r,i)}"undefined"!=typeof window&&window.TrustedScript;class h{}class p extends h{constructor(e,t){super(),s(),this.privateDoNotAccessOrElseWrappedStyleSheet=e}toString(){return this.privateDoNotAccessOrElseWrappedStyleSheet}}function u(e){return new p(e,n)}function d(e){if(e instanceof p)return e.privateDoNotAccessOrElseWrappedStyleSheet;throw new Error("")}function f(e,t){e.textContent=d(t)}Error;class m{iterable;constructor(e){this.iterable=e}filter(e){return new m(m.filterGenerator(e,this.iterable))}map(e){return new m(m.mapGenerator(e,this.iterable))}find(e){for(const t of this.iterable)if(e(t))return t}array(){return Array.from(this.iterable)}*generator(){for(const e of this.iterable)yield e}static*filterGenerator(e,t){for(const r of t)e(r)&&(yield r)}static*mapGenerator(e,t){for(const r of t)yield e(r)}static equals(e,t){const r=e[Symbol.iterator](),i=t[Symbol.iterator]();let n=r.next(),s=i.next();for(;!n.done&&!s.done;){if(n.value!==s.value)return!1;n=r.next(),s=i.next()}return n.done===s.done}}function g(e){return Object.isFrozen(e)&&Object.isFrozen(e.raw)}function _(e){return-1===e.toString().indexOf("`")}_(e=>e``)||_(e=>e`\0`)||_(e=>e`\n`)||_(e=>e`\u0000`),g``&&g`\0`&&g`\n`&&g`\u0000`;function v(e){const t=e[0].toLowerCase();return new a(n,t)}var w,$;function x(e){return{valueOf:e}.valueOf()}!function(e){e[e.STYLE_TAG=0]="STYLE_TAG",e[e.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",e[e.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}(w||(w={}));class b{constructor(e,t,r,i,n){this.allowedElements=e,this.elementPolicies=t,this.allowedGlobalAttributes=r,this.globalAttributePolicies=i,this.globallyAllowedAttributePrefixes=n}isAllowedElement(e){return"FORM"!==e&&(this.allowedElements.has(e)||this.elementPolicies.has(e))}getAttributePolicy(e,t){const r=this.elementPolicies.get(t);if(null==r?void 0:r.has(e))return r.get(e);if(this.allowedGlobalAttributes.has(e))return{policyAction:$.KEEP};const i=this.globalAttributePolicies.get(e);return i||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some(t=>0===e.indexOf(t))?{policyAction:$.KEEP}:{policyAction:$.DROP})}}!function(e){e[e.DROP=0]="DROP",e[e.KEEP=1]="KEEP",e[e.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",e[e.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",e[e.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}($||($={}));new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const y=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],E=[["A",new Map([["href",{policyAction:$.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:$.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],A=["title","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-current","aria-disabled","aria-dropeffect","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-live","aria-multiline","aria-multiselectable","aria-orientation","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","alt","align","autocapitalize","autocomplete","autocorrect","autofocus","autoplay","bgcolor","border","cellpadding","cellspacing","checked","color","cols","colspan","controls","datetime","disabled","download","draggable","enctype","face","formenctype","frameborder","height","hreflang","hidden","ismap","label","lang","loop","max","maxlength","media","minlength","min","multiple","muted","nonce","open","placeholder","preload","rel","required","reversed","role","rows","rowspan","selected","shape","size","sizes","slot","span","spellcheck","start","step","summary","translate","type","valign","value","width","wrap","itemscope","itemtype","itemid","itemprop","itemref"],R=[["dir",{policyAction:$.KEEP_AND_NORMALIZE,conditions:x(()=>new Map([["dir",new Set(["auto","ltr","rtl"])]]))}],["async",{policyAction:$.KEEP_AND_NORMALIZE,conditions:x(()=>new Map([["async",new Set(["async"])]]))}],["cite",{policyAction:$.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:$.KEEP_AND_NORMALIZE,conditions:x(()=>new Map([["loading",new Set(["eager","lazy"])]]))}],["poster",{policyAction:$.KEEP_AND_SANITIZE_URL}],["target",{policyAction:$.KEEP_AND_NORMALIZE,conditions:x(()=>new Map([["target",new Set(["_self","_blank"])]]))}]];new b(new Set(y),new Map(E),new Set(A),new Map(R)),new b(new Set(x(()=>y.concat(["STYLE"]))),new Map(E),new Set(x(()=>A.concat(["id","name","class"]))),new Map(x(()=>R.concat([["style",{policyAction:$.KEEP_AND_SANITIZE_STYLE}]]))));function O(e){return u(e[0])}const I=[v`:`,v`style`,v`class`];function*k(e,t=new Set){const r=new Set,i=Array.from(e.childNodes).filter(e=>!t.has(e));for(yield e;i.length;){const e=i.shift();r.has(e)||(r.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter(e=>!t.has(e)).forEach(e=>i.push(e))}}function N(e,t){return void 0!==e?.[t]}function P(e,t){return"function"==typeof e?.[t]}function S(e){return e.replace(/-./g,e=>e[1].toUpperCase())}function T(e,t){return N(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function C(e,t,r=""){return T(e,r+t)||(e.dataset?.[S(t)]??null)}function D(e,t,r){N(e,"attribs")?e.attribs[t]=r:e.setAttribute?.(t,r)}function L(e,t,r){N(e,"attribs")?e.attribs[t]=r:c(I,e,t,r)}function M(e,t,r){switch(t){case"disabled":return void(e.disabled=r);case"selected":return void(e.selected=r);case"checked":return void(e.checked=r);default:e[t]=r}}function U(e,t){N(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function z(e,t,r=""){U(e,`${r}${t}`),U(e,`data-${t}`)}function j(e,t,r){if(N(e,"attribs")&&N(t,"attribs"))t.attribs[r]=e.attribs[r];else if(r.startsWith("data-")){const i=S(r.slice(5));t.dataset[i]=e.dataset?.[i]}else{const i=e?.getAttribute?.(r);L(t,r,i||"")}}function F(e){if(N(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find(e=>1===e.nodeType)}function G(e,...t){if(P(e,"replaceWith"))return e.replaceWith(...t);{const r=e,i=r.parentNode,n=Array.from(i.childNodes).indexOf(r);t.forEach(e=>e.parentNode=i),i.childNodes=[].concat(Array.from(i.childNodes).slice(0,n)).concat(t).concat(Array.from(i.childNodes).slice(n+1))}}function K(e,...t){P(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach(t=>t.parentNode=e))}function W(e,t){return P(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function Y(e,t){return P(t,"removeChild")?e.removeChild(t):(K(e,...Array.from(e.childNodes).filter(e=>e!==t)),t)}function H(e,t,r){return r?P(e,"insertBefore")?e.insertBefore(t,r):(G(r,t,r),t):W(e,t)}function B(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function V(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map(e=>V(e,t)).join(""):B(e.outerHTML||e.nodeValue||String(e),t)}function Z(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}var q;!function(e){e.resolveIncludes=async function(e,t){const r=e,i=r.tagName?.toLowerCase();if(!["include","link"].includes(i))return;if("link"===i&&"subresource"!==T(r,"rel"))return;this.log("include directive found in:\n",V(e,128)),this.log("include params:",t);const n="link"===r.tagName.toLocaleLowerCase()?"href":"src",s=T(r,n);if(!s)throw new Error(`"${n}" attribute missing from ${V(e,128)}.`);const o=[];"include"===i&&o.push("src"),"link"===i&&o.push("rel","href");const a=t=>{const i=F(t);for(const e of Array.from(r.attributes))i&&!o.includes(e.name)&&j(r,i,e.name);G(e,...t.childNodes)},l={...t,rootDocument:!1,maxdepth:t?.maxdepth-1};if(0===l.maxdepth)throw new Error("Maximum recursion depth reached.");if(s.includes("://")||s.startsWith("//"))this.log("Including remote file from absolute path:",s),await this.preprocessRemote(s,l).then(a);else if(t?.dirpath?.includes("://")||t?.dirpath?.startsWith("//")){const e=s.startsWith("/")?s:`${t.dirpath}/${s}`;this.log("Including remote file from relative path:",e),await this.preprocessRemote(e,l).then(a)}else if("/"===s.charAt(0))this.log("Including local file from absolute path:",s),await this.preprocessLocal(s,l).then(a);else{const e=t?.dirpath&&"."!==t?.dirpath?`${t?.dirpath}/${s}`:s;this.log("Including local file from relative path:",e),await this.preprocessLocal(e,l).then(a)}},e.rebaseRelativePaths=async function(e,t){const r=e,n=r.tagName?.toLowerCase();if(!t?.dirpath)return;const s=T(r,"src"),o=T(r,"href"),a=s||o;if(!a||((l=a).includes("://")||l.startsWith("/")||l.startsWith("#")||l.startsWith("data:")))return;var l;const c=`${t.dirpath}/${a}`;this.log("Rebasing relative path as:",c),N(r,"attribs")?L(r,s?"src":"href",c):"img"===n?r.src=c:"a"===n?function(e,t){const r=i(t);void 0!==r&&(e.href=r)}(r,c):"source"===n||"audio"===n||"video"===n||"track"===n||"input"===n?r.src=c:"area"===n?function(e,t){const r=i(t);void 0!==r&&(e.href=r)}(r,c):this.log("Unable to rebase relative path for element:",n)},e.registerCustomElements=async function(e,t){const r=e,i=r.tagName?.toLowerCase(),n=(T(r,"is")||T(r,"alt"))?.toLowerCase();if(["template","div"].includes(i)&&n){if("div"===i&&"template"!==T(r,"role"))return;this._customElements.has(n)||(this.log(`Registering custom element: ${n}\n`,V(r,128)),this._customElements.set(n,r),Y(r.parentNode,r))}},e.resolveCustomElements=async function(e,t){const r=e,i=r.tagName?.toLowerCase();let n=i;if("div"===n&&(n=T(r,"role")?.toLowerCase()||n),n&&this._customElements.has(n)){this.log(`Processing custom element: ${n}\n`,V(r,128));const t=this._customElements.get(n),s=(t.content||t).cloneNode(!0),o=F(s);if(o)for(const e of Array.from(r.attributes))"div"===i&&"role"===e.name||j(r,o,e.name);const a=new m(k(s)).find(e=>"slot"===e.tagName?.toLowerCase());a&&G(a,...r.childNodes),G(e,...s.childNodes)}},e.resolveTextNodeExpressions=async function(e,t){const r=e.nodeValue||"";if(3!==e.nodeType||!r?.trim())return;this.log("Processing node content value:\n",B(r,128));const i=new RegExp(/{{ ([^}]+) }}/gm),n=Array.from(r.matchAll(i)).map(e=>e[1]);return this.effect(function(){let t=r;for(const r of n){const i=this.eval(r,{$elem:e});t=t.replace(`{{ ${r} }}`,String(i))}e.nodeValue=t})},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"data",":");if(i){this.log(":data attribute found in:\n",V(e,128)),z(r,"data",":");const n=t?.rootNode===e?this:this.subrenderer();e.renderer=n;const s=n.eval(i,{$elem:e});if(await Promise.all(Object.entries(s).map(([e,t])=>n._store.set(e,t))),n!==this)for(const t of k(e,this._skipNodes))this._skipNodes.add(t);await n.mount(e,t)}},e.resolveClassAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"class",":");if(i){this.log(":class attribute found in:\n",V(e,128)),z(r,"class",":");const t=T(r,"class")||"";return this.effect(function(){const n=this.eval(i,{$elem:e});L(r,"class",(n?`${t} ${n}`:t).trim())})}},e.resolveTextAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"text",":");if(i){this.log(":text attribute found in:\n",V(e,128)),z(r,"text",":");const t=t=>this.textContent(e,t);return this.effect(function(){t(this.eval(i,{$elem:e}))})}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"html",":");return i?(this.log(":html attribute found in:\n",V(e,128)),z(r,"html",":"),this.effect(function(){const n=this.eval(i,{$elem:e});return new Promise(async e=>{const i=await this.preprocessString(n,t);await this.renderNode(i),K(r,i),e()})})):void 0},e.resolveEventAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){let i="",n=[];if(t.name.startsWith(":on:")?[i,...n]=t.name.substring(4).split("."):t.name.startsWith("data-on-")&&([i,...n]=t.name.substring(8).split(".")),!i)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",V(e,128)),z(r,t.name);const s="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,r=>((n.includes("prevent")||s)&&r.preventDefault(),this.eval(t.value,{$elem:e,$event:r})))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"for",":")?.trim();if(i){this.log(":for attribute found in:\n",V(e,128)),z(r,"for",":");for(const t of k(e,this._skipNodes))this._skipNodes.add(t);const n=T(r,"style")||"";D(r,"style","display: none;");const s=e.parentNode,o=this.createElement("template",e.ownerDocument);H(s,o,e),Y(s,e),W(o,e),this.log(":for template:\n",V(o,128));const a=i.split(" in ",2);if(2!==a.length)throw new Error(`Invalid :for format: \`${i}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=a;await this.effect(function(){const r=this.eval(h,{$elem:e});if(this.log(":for list items:",r),l.splice(0,l.length).forEach(e=>{Y(s,e),this._skipNodes.delete(e)}),!Array.isArray(r))return console.error(`Expression did not yield a list: \`${h}\` => \`${r}\``),Promise.resolve();const i=[];for(const s of r){const r=this.subrenderer();r._store.set(c,s);const o=e.cloneNode(!0);D(o,"style",n),l.push(o),this._skipNodes.add(o),i.push(r.mount(o,t)),this.log("Rendered list child:\n",V(o,128))}const a=o.nextSibling;for(const e of l)H(s,e,a);return Promise.all(i)})}},e.resolveBindAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"bind",":");if(i){this.log(":bind attribute found in:\n",V(e,128));const t=["change","input"],n=T(r,":bind:on")?.split(",")||r.dataset?.bindOn?.split(",")||t;z(r,"bind",":"),U(r,":bind:on"),U(r,"data-bind-on");const s="checkbox"===T(r,"type")?"checked":"value";i.includes(".")||this.has(i)||this.set(i,""),this.effect(function(){const t=this.eval(i,{$elem:e});"checked"===s?r.checked=!!t:r.value=t});const o=`${i} = $elem.${s}`;for(const t of n)e.addEventListener(t,()=>this.eval(o,{$elem:e}))}},e.resolveShowAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"show",":");if(i){this.log(":show attribute found in:\n",V(e,128)),z(r,"show",":");const t="none"===r.style?.display?"":r.style?.display??T(r,"style")?.split(";")?.find(e=>"display"===e.split(":")[0])?.split(":")?.at(1)?.trim();this.effect(function(){const n=this.eval(i,{$elem:e});r.style?r.style.display=n?t:"none":L(r,"style",`display: ${n?t:"none"};`)})}},e.resolveCustomAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":attr:",n="data-attr-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"attribute found in:\n",V(e,128)),U(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1);this.effect(function(){const i=this.eval(t.value,{$elem:e});D(r,s,i)})}}},e.resolveCustomProperty=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":prop:",n="data-prop-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"property found in:\n",V(e,128)),U(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1),o=S(s);this.effect(function(){const i=this.eval(t.value,{$elem:e});M(r,o,i)})}}},e.stripTypes=async function(e,t){const r=e;T(r,":types")&&U(r,":types"),T(r,"data-types")&&U(r,"data-types")}}(q||(q={}));const Q=new Set(["this","typeof"]),X=new Set(["in"]),J=new Set(["+","-","!","typeof"]),ee=new Set(["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","in"]),te={"!":0,":":0,",":0,")":0,"]":0,"}":0,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,in:10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"?.":13,"{":13},re={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,"||":(e,t)=>e||t,"&&":(e,t)=>e&&t,"??":(e,t)=>e??t,"|":(e,t)=>t(e),in:(e,t)=>e in t},ie={"+":e=>e,"-":e=>-e,"!":e=>!e,typeof:e=>typeof e};const ne=new Set(["==","!=","<=",">=","||","&&","??","?."]),se=new Set(["===","!=="]);var oe;!function(e){e[e.STRING=1]="STRING",e[e.IDENTIFIER=2]="IDENTIFIER",e[e.DOT=3]="DOT",e[e.COMMA=4]="COMMA",e[e.COLON=5]="COLON",e[e.INTEGER=6]="INTEGER",e[e.DECIMAL=7]="DECIMAL",e[e.OPERATOR=8]="OPERATOR",e[e.GROUPER=9]="GROUPER",e[e.KEYWORD=10]="KEYWORD",e[e.ARROW=11]="ARROW",e[e.OPTIONAL_DOT=12]="OPTIONAL_DOT",e[e.SPREAD=13]="SPREAD"}(oe||(oe={}));const ae=(e,t,r=0)=>({kind:e,value:t,precedence:r}),le=e=>9===e||10===e||13===e||32===e,ce=e=>95===e||36===e||65<=(e&=-33)&&e<=90,he=e=>ce(e)||pe(e),pe=e=>48<=e&&e<=57;class ue{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;le(this._next);)this._advance(!0);if(34===(e=this._next)||39===e)return this._tokenizeString();var e;if(ce(this._next))return this._tokenizeIdentOrKeyword();if(pe(this._next))return this._tokenizeNumber();if(46===this._next)return this._tokenizeDot();if(44===this._next)return this._tokenizeComma();if(58===this._next)return this._tokenizeColon();if((e=>43===e||45===e||42===e||47===e||33===e||38===e||37===e||60===e||61===e||62===e||63===e||94===e||124===e)(this._next))return this._tokenizeOperator();if((e=>40===e||41===e||91===e||93===e||123===e||125===e)(this._next))return this._tokenizeGrouper();if(this._advance(),void 0!==this._next)throw new Error(`Expected end of input, got ${this._next}`)}_advance(e){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),!0===e&&(this._tokenStart=this._index)):this._next=void 0}_getValue(e=0){const t=this._input.substring(this._tokenStart,this._index+e);return 0===e&&this._clearValue(),t}_clearValue(){this._tokenStart=this._index}_tokenizeString(){const e="unterminated string",t=this._next;for(this._advance(!0);this._next!==t;){if(void 0===this._next)throw new Error(e);if(92===this._next&&(this._advance(),void 0===this._next))throw new Error(e);this._advance()}const r=ae(oe.STRING,this._getValue().replace(/\\(.)/g,(e,t)=>{switch(t){case"n":return"\n";case"r":return"\r";case"t":return"\t";case"b":return"\b";case"f":return"\f";default:return t}}));return this._advance(),r}_tokenizeIdentOrKeyword(){do{this._advance()}while(he(this._next));const e=this._getValue(),t=(r=e,Q.has(r)?oe.KEYWORD:X.has(e)?oe.OPERATOR:oe.IDENTIFIER);var r;return ae(t,e,te[e]??0)}_tokenizeNumber(){do{this._advance()}while(pe(this._next));return 46===this._next?this._tokenizeDot():ae(oe.INTEGER,this._getValue())}_tokenizeDot(){if(this._advance(),pe(this._next))return this._tokenizeFraction();if(46===this._next){if(this._advance(),46===this._next)return this._advance(),this._clearValue(),ae(oe.SPREAD,"...");throw new Error("Unexpected token ..")}return this._clearValue(),ae(oe.DOT,".",13)}_tokenizeComma(){return this._advance(!0),ae(oe.COMMA,",")}_tokenizeColon(){return this._advance(!0),ae(oe.COLON,":")}_tokenizeFraction(){do{this._advance()}while(pe(this._next));return ae(oe.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(se.has(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),ae(oe.ARROW,e);ne.has(e)&&this._advance()}return e=this._getValue(),"?."===e?ae(oe.OPTIONAL_DOT,e,13):ae(oe.OPERATOR,e,te[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=ae(oe.GROUPER,e,te[e]);return this._advance(!0),t}}class de{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new ue(e),this._ast=t}parse(){this._advance();const e=this._parseExpression();if(this._token)throw new Error(`Unexpected token: ${this._token.value}`);return e}_advance(e,t){if(!this._matches(e,t))throw new Error(`Expected kind ${e} (${t}), was ${this._token?.kind} (${this._token?.value})`);const r=this._tokenizer.nextToken();this._token=r,this._kind=r?.kind,this._value=r?.value}_matches(e,t){return!(e&&this._kind!==e||t&&this._value!==t)}_parseExpression(){if(!this._token)return this._ast.empty();const e=this._parseUnary();return void 0===e?void 0:this._parsePrecedence(e,0)}_parsePrecedence(e,t){if(void 0===e)throw new Error("Expected left to be defined.");for(;this._token;)if(this._matches(oe.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(oe.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(oe.DOT)||this._matches(oe.OPTIONAL_DOT)){const t=this._kind===oe.OPTIONAL_DOT;if(this._advance(),t&&this._matches(oe.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t,!0)}else if(t&&this._matches(oe.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t,!0)}else{const r=this._parseUnary();e=this._makeInvokeOrGetter(e,r,t)}}else{if(this._matches(oe.KEYWORD))break;if(!(this._matches(oe.OPERATOR)&&this._token.precedence>=t))break;e="?"===this._value?this._parseTernary(e):this._parseBinary(e,this._token)}return e}_makeInvokeOrGetter(e,t,r){if(void 0===t)throw new Error("expected identifier");if("ID"===t.type)return this._ast.getter(e,t.value,r);if("Invoke"===t.type&&"ID"===t.receiver.type){const i=t.receiver;return this._ast.invoke(e,i.value,t.arguments,r)}throw new Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(!ee.has(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let r=this._parseUnary();for(;(this._kind===oe.OPERATOR||this._kind===oe.DOT||this._kind===oe.GROUPER)&&this._token.precedence>t.precedence;)r=this._parsePrecedence(r,this._token.precedence);if(void 0===r)throw new Error(`Expected expression after ${t.value}`);return this._ast.binary(e,t.value,r)}_parseUnary(){if(this._matches(oe.KEYWORD,"typeof")){this._advance();const e=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary("typeof",e)}if(this._matches(oe.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(oe.INTEGER))return this._parseInteger(e);if(this._matches(oe.DECIMAL))return this._parseDecimal(e)}if(!J.has(e))throw new Error(`unexpected token: ${e}`);const t=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(e,t)}return this._parsePrimary()}_parseTernary(e){this._advance(oe.OPERATOR,"?");const t=this._parseExpression();this._advance(oe.COLON);const r=this._parseExpression();return this._ast.ternary(e,t,r)}_parsePrimary(){switch(this._kind){case oe.KEYWORD:const e=this._value;if("this"===e)return this._advance(),this._ast.id(e);if(Q.has(e))throw new Error(`unexpected keyword: ${e}`);throw new Error(`unrecognized keyword: ${e}`);case oe.IDENTIFIER:return this._parseInvokeOrIdentifier();case oe.STRING:return this._parseString();case oe.INTEGER:return this._parseInteger();case oe.DECIMAL:return this._parseDecimal();case oe.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case oe.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(oe.GROUPER,"]"))break;if(this._matches(oe.SPREAD)){this._advance();const t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else e.push(this._parseExpression())}while(this._matches(oe.COMMA));return this._advance(oe.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e=[];do{if(this._advance(),this._matches(oe.GROUPER,"}"))break;if(this._matches(oe.SPREAD)){this._advance();const t=this._parseExpression();t&&e.push(this._ast.spreadProperty(t))}else{const t=this._value;(this._matches(oe.STRING)||this._matches(oe.IDENTIFIER))&&this._advance(),this._advance(oe.COLON);const r=this._parseExpression();r&&e.push(this._ast.property(t,r))}}while(this._matches(oe.COMMA));return this._advance(oe.GROUPER,"}"),this._ast.map(e)}_parseInvokeOrIdentifier(){const e=this._value;if("true"===e)return this._advance(),this._ast.literal(!0);if("false"===e)return this._advance(),this._ast.literal(!1);if("null"===e)return this._advance(),this._ast.literal(null);if("undefined"===e)return this._advance(),this._ast.literal(void 0);const t=this._parseIdentifier(),r=this._parseArguments();return r?this._ast.invoke(t,void 0,r):t}_parseIdentifier(){if(!this._matches(oe.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(oe.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(oe.GROUPER,")"))break;if(this._matches(oe.SPREAD)){this._advance();const t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else{const t=this._parseExpression();e.push(t)}}while(this._matches(oe.COMMA));return this._advance(oe.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(oe.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(oe.ARROW)){this._advance();const t=this._parseExpression(),r=e?.map(e=>e.value)??[];return this._ast.arrowFunction(r,t)}return this._ast.paren(e[0])}_parseString(){const e=this._ast.literal(this._value);return this._advance(),e}_parseInteger(e=""){const t=this._ast.literal(parseInt(`${e}${this._value}`,10));return this._advance(),t}_parseDecimal(e=""){const t=this._ast.literal(parseFloat(`${e}${this._value}`));return this._advance(),t}}class fe{timeouts=new Map;debounce(e,t){return new Promise((r,i)=>{const n=this.timeouts.get(t);n&&clearTimeout(n),this.timeouts.set(t,setTimeout(()=>{try{r(t()),this.timeouts.delete(t)}catch(e){i(e)}},e))})}}const me=new class{empty(){return{type:"Empty",evaluate:e=>e,getIds:e=>e}}literal(e){return{type:"Literal",value:e,evaluate(e){return this.value},getIds:e=>e}}id(e){return{type:"ID",value:e,evaluate(e){return"this"===this.value?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(e,t){const r=ie[e];return{type:"Unary",operator:e,child:t,evaluate(e){return r(this.child.evaluate(e))},getIds(e){return this.child.getIds(e)}}}binary(e,t,r){const i=re[t];return{type:"Binary",operator:t,left:e,right:r,evaluate(e){if("="===this.operator){if("ID"!==this.left.type&&"Getter"!==this.left.type&&"Index"!==this.left.type)throw new Error(`Invalid assignment target: ${this.left}`);const t=this.right.evaluate(e);let r,i;return"Getter"===this.left.type?(r=this.left.receiver.evaluate(e),i=this.left.name):"Index"===this.left.type?(r=this.left.receiver.evaluate(e),i=String(this.left.argument.evaluate(e))):"ID"===this.left.type&&(r=e,i=this.left.value),void 0===r?void 0:r[i]=t}return i(this.left.evaluate(e),this.right.evaluate(e))},getIds(e){return this.left.getIds(e),this.right.getIds(e),e}}}getter(e,t,r){return{type:"Getter",receiver:e,name:t,optional:r,evaluate(e){const t=this.receiver.evaluate(e);if(!this.optional||null!=t)return t?.[this.name]},getIds(e){return this.receiver.getIds(e),e}}}invoke(e,t,r,i){if(null!=t&&"string"!=typeof t)throw new Error("method not a string");return{type:"Invoke",receiver:e,method:t,arguments:r,optional:i,evaluate(e){const t=this.receiver.evaluate(e);if(this.optional&&null==t)return;const r=this.method?t:e?.this??e,i=this.method?t?.[this.method]:t,n=this.arguments??[],s=[];for(const t of n)if("SpreadElement"===t?.type){const r=t.evaluate(e);r&&"function"==typeof r[Symbol.iterator]&&s.push(...r)}else s.push(t?.evaluate(e));return i?.apply?.(r,s)},getIds(e){return this.receiver.getIds(e),this.arguments?.forEach(t=>t?.getIds(e)),e}}}paren(e){return e}index(e,t,r){return{type:"Index",receiver:e,argument:t,optional:r,evaluate(e){const t=this.receiver.evaluate(e);if(this.optional&&null==t)return;const r=this.argument.evaluate(e);return t?.[r]},getIds(e){return this.receiver.getIds(e),e}}}ternary(e,t,r){return{type:"Ternary",condition:e,trueExpr:t,falseExpr:r,evaluate(e){return this.condition.evaluate(e)?this.trueExpr.evaluate(e):this.falseExpr.evaluate(e)},getIds(e){return this.condition.getIds(e),this.trueExpr.getIds(e),this.falseExpr.getIds(e),e}}}map(e){return{type:"Map",properties:e,evaluate(t){const r={};if(e&&this.properties)for(const e of this.properties)"SpreadProperty"===e.type?Object.assign(r,e.evaluate(t)):r[e.key]=e.value.evaluate(t);return r},getIds(t){if(e&&this.properties)for(const e of this.properties)"SpreadProperty"===e.type?e.expression.getIds(t):e.value.getIds(t);return t}}}property(e,t){return{type:"Property",key:e,value:t,evaluate(e){return this.value.evaluate(e)},getIds(e){return this.value.getIds(e)}}}list(e){return{type:"List",items:e,evaluate(e){if(!this.items)return[];const t=[];for(const r of this.items)if("SpreadElement"===r?.type){const i=r.evaluate(e);i&&"function"==typeof i[Symbol.iterator]&&t.push(...i)}else t.push(r?.evaluate(e));return t},getIds(e){return this.items?.forEach(t=>t?.getIds(e)),e}}}arrowFunction(e,t){return{type:"ArrowFunction",params:e,body:t,evaluate(e){const t=this.params,r=this.body;return function(...i){const n=Object.fromEntries(t.map((e,t)=>[e,i[t]])),s=new Proxy(e??{},{set:(e,t,r)=>(n.hasOwnProperty(t)&&(n[t]=r),e[t]=r),get:(e,t)=>n.hasOwnProperty(t)?n[t]:e[t]});return r.evaluate(s)}},getIds(e){return this.body.getIds(e).filter(e=>!this.params.includes(e))}}}spreadProperty(e){return{type:"SpreadProperty",expression:e,evaluate(e){return this.expression.evaluate(e)},getIds(e){return this.expression.getIds(e)}}}spreadElement(e){return{type:"SpreadElement",expression:e,evaluate(e){return this.expression.evaluate(e)},getIds(e){return this.expression.getIds(e)}}}},ge="__is_proxy__";function _e(e,t){const r=e?._store;return r?.has(t)?r.get(t):r?.has("$parent")?_e(r.get("$parent"),t):null}function ve(e,t){const r=e?._store;return r?.has(t)?e:r?.has("$parent")?ve(r.get("$parent"),t):null}class we extends fe{evalkeys=["$elem","$event"];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_observer=null;_store=new Map;_lock=Promise.resolve();constructor(e){super();for(const[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof we||!0===r[ge])||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>"string"==typeof r&&r in e&&(delete e[r],t(),!0),set:(e,r,i,n)=>{"object"==typeof i&&null!==i&&(i=this.wrapObject(i,t));const s=Reflect.set(e,r,i,n);return t(),s},get:(e,t,r)=>t===ge||Reflect.get(e,t,r)});var r}watch(e,t){const r=ve(this,e);if(!r)throw new Error(`Cannot watch key "${e}" as it does not exist in the store.`);r.observers.has(e)||r.observers.set(e,new Set),r.observers.get(e)?.has(t)||r.observers.get(e)?.add(t)}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e).add(t)}async notify(e,t=10){const r=ve(this,e),i=Array.from(r?.observers.get(e)||[]);await this.debounce(t,()=>Promise.all(i.map(e=>e.call(this.proxify(e)))))}get(e,t){return t&&this.watch(e,t),_e(this,e)}async set(e,t){if(t===this._store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=ve(e,t);i?i._store.set(t,r):e._store.set(t,r)}(this,e,t);for(const[r,i]of this.keyHandlers.entries())if(r.test(e))for(const r of i)await Promise.resolve(r.call(this.$,e,t));await r()}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e)}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this._store.entries()).map(([e])=>e),r=Object.fromEntries(t.map(e=>[e,null]));return new Proxy(r,{has:(e,t)=>{if("string"==typeof t){if(ve(this,t))return!0;if(Reflect.has(this,t))return!0}return Reflect.has(r,t)},get:(t,r,i)=>"string"==typeof r&&ve(this,r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");return(t,r)=>{const i=((e,t)=>new de(e,t).parse())(e,me),n=new Proxy(r,{has:(e,r)=>r in e||r in t||r in globalThis,get(e,r){if("string"==typeof r)return r in e?e[r]:r in t?t[r]:globalThis[r]},set:(e,r,i)=>"string"==typeof r&&(r in e?(e[r]=i,!0):(t[r]=i,!0))});return i?.evaluate(n)}}cachedExpressionFunction(e){return e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e)),this.expressionCache.get(e)}eval(e,t={}){const r=this._observer?this:this.$;if(this._store.has(e))return r[e];{const i=this.cachedExpressionFunction(e);try{return i(r,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}$resolve(e,t){const r={$pending:!0,$result:null,$error:null};return Promise.resolve().then(()=>e(t)).then(e=>{r.$result=e}).catch(e=>{r.$error=e instanceof Error?e:new Error(String(e))}).finally(()=>{r.$pending=!1}),r}}const $e="$$";function xe(){return new URL(globalThis.window?.location?.href||"http://localhost/")}function be(e){return`${$e}${e}`}function ye(e){return e.keys().filter(e=>e.startsWith($e))}function Ee(e,t,r){const i=function(e){return e.substring(2)}(t);let n=!1;if(r){const t=String(r);e.searchParams.get(i)!==t&&(e.searchParams.set(i,t),n=!0)}else e.searchParams.has(i)&&(e.searchParams.delete(i),n=!0);return n}async function Ae(e){const t=xe();await async function(e,t){for(const[r,i]of t.searchParams.entries()){const t=be(r);e.get(t)!==i&&await e.set(t,i)}}(e,t),function(e,t){let r=!1;for(const i of ye(t))Ee(e,i,t.get(i))&&(r=!0);r&&globalThis.window?.history?.replaceState({},"",e.toString())}(t,e),e.addKeyHandler(new RegExp("^\\$\\$"),(e,t)=>{const r=xe();Ee(r,e,t)&&globalThis.window?.history?.replaceState({},"",r.toString())}),globalThis.window?.addEventListener("popstate",function(e){return async()=>{const t=xe(),r=new Set;for(const[i,n]of t.searchParams.entries()){const t=be(i);r.add(t),e.get(t)!==n&&e.set(t,n)}const i=ye(e);for(const t of i)r.has(t)||e.del(t)}}(e))}class Re extends we{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(e){return this.debugging=e,this}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??"default"}).then(e=>e.text())}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log("Preprocessing string content with params:\n",t);const r=this.parseHTML(e,t);return await this.preprocessNode(r,t),r}async preprocessRemote(e,t){const r={};t?.cache&&(r.cache=t.cache);const i=await fetch(e,r).then(e=>e.text());return this.preprocessString(i,{...t,dirpath:Z(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}async preprocessLocal(e,t){const r=await this.fetchLocal(e,t);return this.preprocessString(r,{...t,dirpath:Z(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}subrenderer(){const e=(new this.constructor).debug(this.debugging);return e._store.set("$parent",this),e._store.set("$rootRenderer",this.get("$rootRenderer")??this),e._customElements=this._customElements,e}log(...e){this.debugging&&console.debug(...e)}async preprocessNode(e,t){t={dirpath:this.dirpath,maxdepth:10,...t};const r=new m(k(e,this._skipNodes)).map(async e=>{this.log("Preprocessing node:\n",V(e,128)),await q.resolveIncludes.call(this,e,t),await q.rebaseRelativePaths.call(this,e,t),await q.registerCustomElements.call(this,e,t),await q.resolveCustomElements.call(this,e,t)});return await Promise.all(r.generator()),e}async renderNode(e,t){for(const r of k(e,this._skipNodes))this.log("Rendering node:\n",V(r,128)),await q.resolveForAttribute.call(this,r,t),await q.resolveDataAttribute.call(this,r,t),await q.resolveTextAttributes.call(this,r,t),await q.resolveHtmlAttribute.call(this,r,t),await q.resolveShowAttribute.call(this,r,t),await q.resolveClassAttribute.call(this,r,t),await q.resolveBindAttribute.call(this,r,t),await q.resolveEventAttributes.call(this,r,t),await q.resolveTextNodeExpressions.call(this,r,t),await q.resolveCustomAttribute.call(this,r,t),await q.resolveCustomProperty.call(this,r,t),await q.stripTypes.call(this,r,t);return e}async mount(e,t){t={...t,rootNode:e},M(e,"renderer",this),this._store.set("$rootNode",e),this.has("$rootRenderer")||this._store.set("$rootRenderer",this),this.get("$rootRenderer")===this&&await Ae(this),await this.preprocessNode(e,t),await this.renderNode(e,t)}}function Oe(){return u([O`html{`,O`max-width: 70ch;`,O`padding: 2em 1em;`,O`margin: auto;`,O`line-height: 1.75;`,O`font-size: 1.25em;`,O`font-family: sans-serif;`,O`}`,O`h1,h2,h3,h4,h5,h6{`,O`margin: 1em 0 0.5em;`,O`}`,O`p,ul,ol{`,O`margin-bottom: 1em;`,O`color: #1d1d1d;`,O`}`].map(d).join(""))}const Ie={sm:640,md:768,lg:1024,xl:1280},ke=.25,Ne=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],Pe=[...Ne,16,20,24,25,28,30,32,36,40,44,48,50,52,56,60,64,72,80,96,100,112,128,144,160,192,200,224,256,288,300,320,384,400,448,500,512,...Object.values(Ie)],Se=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],Te=[75,100,150,200,300,500,700,1e3],Ce=["hover","focus","disabled","active"],De={margin:"m",padding:"p"},Le={width:"w",height:"h"},Me={top:"top",right:"right",bottom:"bottom",left:"left"},Ue={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},ze={"font-mono":{"font-family":"monospace"},"font-sans":{"font-family":"sans-serif"},"font-serif":{"font-family":"serif"},"font-cursive":{"font-family":"cursive"},"text-xs":{"font-size":".75rem","line-height":"calc(1 / 0.75)"},"text-sm":{"font-size":".875rem","line-height":"calc(1.25 / 0.875)"},"text-base":{"font-size":"1rem","line-height":"calc(1.5 / 1)"},"text-lg":{"font-size":"1.125rem","line-height":"calc(1.75 / 1.125)"},"text-xl":{"font-size":"1.25rem","line-height":"calc(1.75 / 1.25)"},"text-2xl":{"font-size":"1.5rem","line-height":"calc(2 / 1.5)"},"text-3xl":{"font-size":"1.875rem","line-height":"calc(2.25 / 1.875)"},"text-4xl":{"font-size":"2.25rem","line-height":"calc(2.5 / 2.25)"},"text-5xl":{"font-size":"3rem","line-height":"1"},"text-6xl":{"font-size":"3.75rem","line-height":"1"},"text-7xl":{"font-size":"4.5rem","line-height":"1"},"font-thin":{"font-weight":100},"font-extralight":{"font-weight":200},"font-light":{"font-weight":300},"font-normal":{"font-weight":400},"font-medium":{"font-weight":500},"font-semibold":{"font-weight":600},"font-bold":{"font-weight":700},"font-extrabold":{"font-weight":800},"font-black":{"font-weight":900},italic:{"font-style":"italic"},"not-italic":{"font-style":"normal"},"w-max":{width:"max-content"},"w-min":{width:"min-content"},"w-fit":{width:"fit-content"},"h-max":{height:"max-content"},"h-min":{height:"min-content"},"h-fit":{height:"fit-content"},"size-auto":{width:"auto",height:"auto"},"size-px":{width:"1px",height:"1px"},"size-full":{width:"100%",height:"100%"},"size-dvw":{width:"100dvw",height:"100dvw"},"size-dvh":{width:"100dvh",height:"100dvh"},"size-lvw":{width:"100lvw",height:"100lvw"},"size-lvh":{width:"100lvh",height:"100lvh"},"size-svw":{width:"100svw",height:"100svw"},"size-svh":{width:"100svh",height:"100svh"},"size-min":{width:"min-content",height:"min-content"},"size-max":{width:"max-content",height:"max-content"},"size-fit":{width:"fit-content",height:"fit-content"},"tracking-tighter":{"letter-spacing":"-0.05em"},"tracking-tight":{"letter-spacing":"-0.025em"},"tracking-normal":{"letter-spacing":"0"},"tracking-wide":{"letter-spacing":"0.025em"},"tracking-wider":{"letter-spacing":"0.05em"},"tracking-widest":{"letter-spacing":"0.1em"},"leading-none":{"line-height":"1"},"leading-tight":{"line-height":"1.25"},"leading-snug":{"line-height":"1.375"},"leading-normal":{"line-height":"1.5"},"leading-relaxed":{"line-height":"1.625"},"leading-loose":{"line-height":"2"},"text-left":{"text-align":"left"},"text-right":{"text-align":"right"},"text-center":{"text-align":"center"},"text-justify":{"text-align":"justify"},underline:{"text-decoration":"underline"},"no-underline":{"text-decoration":"none"},"decoration-none":{"text-decoration":"none"},"line-through":{"text-decoration":"line-through"},uppercase:{"text-transform":"uppercase"},lowercase:{"text-transform":"lowercase"},capitalize:{"text-transform":"capitalize"},truncate:{"white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis"},"text-elipsis":{"text-overflow":"ellipsis"},"text-clip":{"text-overflow":"clip"},"text-wrap":{"text-wrap":"wrap"},"text-nowrap":{"text-wrap":"nowrap"},"text-balance":{"text-wrap":"balance"},"text-pretty":{"text-wrap":"pretty"},"whitespace-normal":{"white-space":"normal"},"whitespace-nowrap":{"white-space":"nowrap"},"whitespace-pre":{"white-space":"pre"},"whitespace-pre-line":{"white-space":"pre-line"},"whitespace-pre-wrap":{"white-space":"pre-wrap"},"whitespace-break-spaces":{"white-space":"break-spaces"},relative:{position:"relative"},fixed:{position:"fixed"},absolute:{position:"absolute"},sticky:{position:"sticky"},"object-contain":{"object-fit":"contain"},"object-cover":{"object-fit":"cover"},"object-fill":{"object-fit":"fill"},"object-none":{"object-fit":"none"},block:{display:"block"},contents:{display:"contents"},hidden:{display:"none"},inline:{display:"inline"},"inline-block":{display:"inline-block"},visible:{visibility:"visible"},invisible:{visibility:"hidden"},collapse:{visibility:"collapse"},"list-none":{"list-style-type":"none"},"list-disc":{"list-style-type":"disc"},"list-decimal":{"list-style-type":"decimal"},flex:{display:"flex"},"flex-1":{flex:"1 1 0%"},"flex-inline":{display:"inline-flex"},"flex-row":{"flex-direction":"row"},"flex-col":{"flex-direction":"column"},"flex-row-reverse":{"flex-direction":"row-reverse"},"flex-col-reverse":{"flex-direction":"column-reverse"},"flex-wrap":{"flex-wrap":"wrap"},"flex-wrap-reverse":{"flex-wrap":"wrap-reverse"},"flex-nowrap":{"flex-wrap":"nowrap"},"justify-start":{"justify-content":"flex-start"},"justify-end":{"justify-content":"flex-end"},"justify-center":{"justify-content":"center"},"justify-between":{"justify-content":"space-between"},"justify-around":{"justify-content":"space-around"},"justify-evenly":{"justify-content":"space-evenly"},"justify-stretch":{"justify-content":"stretch"},"items-start":{"align-items":"flex-start"},"items-end":{"align-items":"flex-end"},"items-center":{"align-items":"center"},"items-stretch":{"align-items":"stretch"},"flex-grow":{"flex-grow":1},"flex-shrink":{"flex-shrink":1},"align-baseline":{"vertical-align":"baseline"},"align-top":{"vertical-align":"top"},"align-middle":{"vertical-align":"middle"},"align-bottom":{"vertical-align":"bottom"},"align-text-top":{"vertical-align":"text-top"},"align-text-bottom":{"vertical-align":"text-bottom"},"overflow-auto":{overflow:"auto"},"overflow-x-auto":{"overflow-x":"auto"},"overflow-y-auto":{"overflow-y":"auto"},"overflow-hidden":{overflow:"hidden"},"overflow-x-hidden":{"overflow-x":"hidden"},"overflow-y-hidden":{"overflow-y":"hidden"},"overflow-visible":{overflow:"visible"},"overscroll-auto":{"overscroll-behavior":"auto"},"overscroll-contain":{"overscroll-behavior":"contain"},"overscroll-none":{"overscroll-behavior":"none"},"overscroll-x-auto":{"overscroll-behavior-x":"auto"},"overscroll-x-contain":{"overscroll-behavior-x":"contain"},"overscroll-x-none":{"overscroll-behavior-x":"none"},"overscroll-y-auto":{"overscroll-behavior-y":"auto"},"overscroll-y-contain":{"overscroll-behavior-y":"contain"},"overscroll-y-none":{"overscroll-behavior-y":"none"},"z-auto":{"z-index":"auto"},"cursor-pointer":{cursor:"pointer"},"cursor-wait":{cursor:"wait"},"cursor-not-allowed":{cursor:"not-allowed"},"select-none":{"user-select":"none"},"select-all":{"user-select":"all"},"pointer-events-auto":{"pointer-events":"auto"},"pointer-events-none":{"pointer-events":"none"},"box-border":{"box-sizing":"border-box"},"box-content":{"box-sizing":"content-box"},resize:{resize:"both"},"resize-x":{resize:"horizontal"},"resize-y":{resize:"vertical"},"resize-none":{resize:"none"},border:{border:"1px solid"},"border-none":{border:"none"},"border-solid":{"border-style":"solid"},"border-dashed":{"border-style":"dashed"},"border-dotted":{"border-style":"dotted"},"border-collapse":{"border-collapse":"collapse"},"rounded-none":{"border-radius":"0"},rounded:{"border-radius":".25rem"},"rounded-sm":{"border-radius":".125rem"},"rounded-md":{"border-radius":".375rem"},"rounded-lg":{"border-radius":".5rem"},"rounded-xl":{"border-radius":".75rem"},"rounded-full":{"border-radius":"9999px"},shadow:{"box-shadow":"0 0 1px 0 rgba(0, 0, 0, 0.05)"},"shadow-sm":{"box-shadow":"0 1px 2px 0 rgba(0, 0, 0, 0.05)"},"shadow-md":{"box-shadow":"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},"shadow-lg":{"box-shadow":"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},"shadow-xl":{"box-shadow":"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)"},"shadow-2xl":{"box-shadow":"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},"shadow-inner":{"box-shadow":"inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)"},"shadow-outline":{"box-shadow":"0 0 0 3px rgba(66, 153, 225, 0.5)"},"shadow-none":{"box-shadow":"none"},"transition-none":{transition:"none"},transition:{transition:"all 150ms ease-in-out"},"animate-none":{animation:"none"},"animate-spin":{animation:"spin 1s linear infinite"},"animate-ping":{animation:"ping 1s cubic-bezier(0, 0, 0.2, 1) infinite"},"animate-pulse":{animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"},"bg-auto":{"background-size":"auto"},"bg-cover":{"background-size":"cover"},"bg-contain":{"background-size":"contain"},"bg-no-repeat":{"background-repeat":"no-repeat"},"bg-fixed":{"background-attachment":"fixed"},"bg-local":{"background-attachment":"local"},"bg-scroll":{"background-attachment":"scroll"}},je=["@keyframes spin {\n from { transform: rotate(0deg) }\n to { transform: rotate(360deg) }\n }","@keyframes ping {\n 75%, 100% {\n transform: scale(2);\n opacity: 0;\n }\n }","@keyframes pulse {\n 0%, 100% { opacity: 1 }\n 50% { opacity: .5 }\n }"],Fe={red:{50:16772078,100:16764370,200:15702682,300:15037299,400:15684432,500:16007990,600:15022389,700:13840175,800:12986408,900:12000284},pink:{50:16573676,100:16301008,200:16027569,300:15753874,400:15483002,500:15277667,600:14162784,700:12720219,800:11342935,900:8916559},purple:{50:15984117,100:14794471,200:13538264,300:12216520,400:11225020,500:10233776,600:9315498,700:8069026,800:6953882,900:4854924},"deep-purple":{50:15591414,100:13747433,200:11771355,300:9795021,400:8280002,500:6765239,600:6174129,700:5320104,800:4532128,900:3218322},indigo:{50:15264502,100:12962537,200:10463450,300:7964363,400:6056896,500:4149685,600:3754411,700:3162015,800:2635155,900:1713022},blue:{50:14938877,100:12312315,200:9489145,300:6600182,400:4367861,500:2201331,600:2001125,700:1668818,800:1402304,900:870305},"light-blue":{50:14808574,100:11789820,200:8508666,300:5227511,400:2733814,500:240116,600:236517,700:166097,800:161725,900:87963},cyan:{50:14743546,100:11725810,200:8445674,300:5099745,400:2541274,500:48340,600:44225,700:38823,800:33679,900:24676},teal:{50:14742257,100:11722715,200:8440772,300:5093036,400:2533018,500:38536,600:35195,700:31083,800:26972,900:19776},green:{50:15267305,100:13166281,200:10868391,300:8505220,400:6732650,500:5025616,600:4431943,700:3706428,800:3046706,900:1793568},"light-green":{50:15857897,100:14478792,200:12968357,300:11457921,400:10275941,500:9159498,600:8172354,700:6856504,800:5606191,900:3369246},lime:{50:16382951,100:15791299,200:15134364,300:14477173,400:13951319,500:13491257,600:12634675,700:11514923,800:10394916,900:8550167},yellow:{50:16776679,100:16775620,200:16774557,300:16773494,400:16772696,500:16771899,600:16635957,700:16498733,800:16361509,900:16088855},amber:{50:16775393,100:16772275,200:16769154,300:16766287,400:16763432,500:16761095,600:16757504,700:16752640,800:16748288,900:16740096},orange:{50:16774112,100:16769202,200:16764032,300:16758605,400:16754470,500:16750592,600:16485376,700:16088064,800:15690752,900:15094016},"deep-orange":{50:16509415,100:16764092,200:16755601,300:16747109,400:16740419,500:16733986,600:16011550,700:15092249,800:14172949,900:12531212},brown:{50:15723497,100:14142664,200:12364452,300:10586239,400:9268835,500:7951688,600:7162945,700:6111287,800:5125166,900:4073251},gray:{50:16448250,100:16119285,200:15658734,300:14737632,400:12434877,500:10395294,600:7697781,700:6381921,800:4342338,900:2171169},"blue-gray":{50:15527921,100:13621468,200:11583173,300:9479342,400:7901340,500:6323595,600:5533306,700:4545124,800:3622735,900:2503224}};function Ge(e){return`#${e.toString(16).padStart(6,"0")}`}function Ke(e){return Ce.map(t=>`.${t}\\:${e}:${t}`)}function We(e,t){return Object.entries(Ie).map(([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`)}function Ye(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function He(e){return Object.entries(e).flatMap(([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100v${e.includes("height")?"h":"w"}`],[`${t}-full`,`${e}: 100%`],...Pe.map(r=>[`${t}-${r}`,`${e}: ${r*ke}rem`]),...Pe.map(r=>[`-${t}-${r}`,`${e}: -${r*ke}rem`]),...Pe.map(r=>[`${t}-${r}px`,`${e}: ${r}px`]),...Pe.map(r=>[`-${t}-${r}px`,`${e}: -${r}px`]),...Se.map(r=>[`${t}-${r}\\%`,`${e}: ${r}%`]),...Se.map(r=>[`-${t}-${r}\\%`,`${e}: -${r}%`])]).flatMap(([e,t])=>[`.${e} { ${t} }`,`${Ke(e).join(",")} { ${t} }`,...We(e,t)])}function Be(e){return Object.entries(e).flatMap(([e,t])=>[[`${t}-auto`,`${e}: auto`],[`${t}x-auto`,`${e}-left: auto; ${e}-right: auto;`],[`${t}y-auto`,`${e}-top: auto; ${e}-bottom: auto;`],[`${t}x-0`,`${e}-left: 0; ${e}-right: 0;`],[`${t}y-0`,`${e}-top: 0; ${e}-bottom: 0;`],...Pe.map(e=>[e,e*ke]).map(([r,i])=>[`${t}x-${r}`,`${e}-left: ${i}rem; ${e}-right: ${i}rem;`]),...Pe.map(e=>[e,e*ke]).map(([r,i])=>[`${t}y-${r}`,`${e}-top: ${i}rem; ${e}-bottom: ${i}rem;`]),...Pe.map(r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`]),...Pe.map(r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`]),...Se.map(r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`]),...Se.map(r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`])]).flatMap(([e,t])=>[`.${e} { ${t} }`,`${Ke(e).join(",")} { ${t} }`,...We(e,t)])}function Ve(){const e=[["white","#fff"],["black","#000"],["transparent","transparent"]].flatMap(([e,t])=>[[`text-${e}`,`color: ${t}`],[`fill-${e}`,`fill: ${t}`],[`bg-${e}`,`background-color: ${t}`],[`border-${e}`,`border-color: ${t}`]]),t=Object.entries(Fe).flatMap(([e,t])=>[[`text-${e}`,`color: ${Ge(t[500])}`],[`fill-${e}`,`fill: ${Ge(t[500])}`],[`bg-${e}`,`background-color: ${Ge(t[500])}`],[`border-${e}`,`border-color: ${Ge(t[500])}`]]),r=Object.entries(Fe).flatMap(([e,t])=>Object.entries(t).flatMap(([t,r])=>[[`text-${e}-${t}`,`color: ${Ge(r)}`],[`fill-${e}-${t}`,`fill: ${Ge(r)}`],[`bg-${e}-${t}`,`background-color: ${Ge(r)}`],[`border-${e}-${t}`,`border-color: ${Ge(r)}`]]));return[].concat(e).concat(t).concat(r).flatMap(([e,t])=>[`.${e} { ${t} }`,`${Ke(e).join(",")} { ${t} }`,...We(e,t)])}function Ze(){return[...je,...Object.entries(ze).flatMap(([e,t])=>Object.entries(t).flatMap(([t,r])=>[`.${e} { ${t}: ${r} }`,`${Ke(e).join(",")} { ${t}: ${r} }`,...We(e,`${t}: ${r}`)])),...Ve(),...[["opacity-0","opacity: 0"],...Se.map(e=>[`opacity-${e}`,"opacity: "+e/100])].flatMap(([e,t])=>[`.${e} { ${t} }`,`${Ke(e).join(",")} { ${t} }`,...We(e,t)]),...[...Se.map(e=>[`z-${e}`,`z-index: ${e}`])].flatMap(([e,t])=>[`.${e} { ${t} }`,`${Ke(e).join(",")} { ${t} }`,...We(e,t)]),...[...Te.map(e=>[`duration-${e}`,`transition-duration: ${e}ms`])].flatMap(([e,t])=>[`.${e} { ${t} }`,`${Ke(e).join(",")} { ${t} }`,...We(e,t)]),...He(Me),...He(Le),...Be(Le),...(e=De,Object.entries(e).flatMap(([e,t])=>[[`${t}t-0`,`${e}-top: 0`],[`${t}b-0`,`${e}-bottom: 0`],[`${t}l-0`,`${e}-left: 0`],[`${t}r-0`,`${e}-right: 0`],[`${t}t-auto`,`${e}-top: auto`],[`${t}b-auto`,`${e}-bottom: auto`],[`${t}l-auto`,`${e}-left: auto`],[`${t}r-auto`,`${e}-right: auto`],...["","-"].flatMap(r=>[...Pe.map(e=>[e,e*ke]).map(([i,n])=>[`${r}${t}t-${i}`,`${e}-top: ${r}${n}rem`]),...Pe.map(e=>[e,e*ke]).map(([i,n])=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${n}rem`]),...Pe.map(e=>[e,e*ke]).map(([i,n])=>[`${r}${t}l-${i}`,`${e}-left: ${r}${n}rem`]),...Pe.map(e=>[e,e*ke]).map(([i,n])=>[`${r}${t}r-${i}`,`${e}-right: ${r}${n}rem`]),...Pe.map(i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`]),...Pe.map(i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`]),...Pe.map(i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`]),...Pe.map(i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`]),...Se.map(i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`]),...Se.map(i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%;`]),...Se.map(i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`]),...Se.map(i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`])])]).flatMap(([e,t])=>[`.${e} { ${t} }`,`${Ke(e).join(",")} { ${t} }`,...We(e,t)])),...He(De),...Be(De),...[["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...Pe.map(e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*ke}rem`]),...Pe.map(e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*ke}rem`]),...Pe.map(e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`]),...Pe.map(e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`]),["gap-0","gap: 0"],...Pe.map(e=>[`gap-${e}`,`gap: ${e*ke}rem`]),...Pe.map(e=>[`gap-${e}px`,`gap: ${e}px`]),...Pe.map(e=>[`gap-x-${e}`,`column-gap: ${e*ke}rem`]),...Pe.map(e=>[`gap-y-${e}`,`row-gap: ${e*ke}rem`]),...Pe.map(e=>[`gap-x-${e}px`,`column-gap: ${e}px`]),...Pe.map(e=>[`gap-y-${e}px`,`row-gap: ${e}px`])].flatMap(([e,t])=>[`.${e} { ${t} }`,`${Ke(e).join(",")} { ${t} }`,...We(e,t)]),...He(Ue),...[["border","border: 1px"],["border-x","border-inline-width: 1px"],["border-y","border-block-width: 1px"],...[0,...Ne].map(e=>[`border-${e}`,`border-width: ${e}px`]),...[0,...Ne].map(e=>[`border-x-${e}`,`border-inline-width: ${e}px;`]),...[0,...Ne].map(e=>[`border-y-${e}`,`border-block-width: ${e}px;`]),...["top","bottom","left","right"].flatMap(e=>[[`border-${e.slice(0,1)}`,`border-${e}: 1px`],...[0,...Ne].map(t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`])])].flatMap(([e,t])=>[`.${e} { ${t} }`,`${Ke(e).join(",")} { ${t} }`,...We(e,t)]),...[...Array.from({length:100},(e,t)=>t).map(e=>[`text-${e}px`,`font-size: ${e}px`]),...Array.from({length:100},(e,t)=>t*ke).map(e=>[`text-${e}rem`,`font-size: ${e}rem`])].flatMap(([e,t])=>[`.${e} { ${t} }`,`${Ke(e).join(",")} { ${t} }`,...We(e,t)])].sort(Ye).join("\n");var e}class qe extends Re{impl="browser";dirpath=Z(globalThis.location?.href??"http://localhost/");parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return(new DOMParser).parseFromString(e,"text/html");{const t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}const Qe=new qe;function Xe(e){for(const t of e){const e=document.createElement("style");switch(t){case"basic":f(e,Oe());break;case"utils":e.textContent=Ze();break;default:console.error(`Unknown style name: "${t}"`);continue}globalThis.document.head.appendChild(e)}}function Je(){Xe(["basic"])}function et(){Xe(["utils"])}async function tt(e={}){const t=new qe;if(e.css&&e.css.length>0&&Xe(e.css),e.debug&&t.debug(!0),e.state)for(const[r,i]of Object.entries(e.state))await t.set(r,i);if(e.target){const r=Array.isArray(e.target)?e.target:[e.target];for(const i of r){const r=globalThis.document.querySelector(i);r?await t.mount(r,{cache:e.cache}):console.error(`Target element not found: "${i}"`)}}return t}export{Qe as Mancha,qe as Renderer,Oe as basicCssRules,tt as initMancha,Je as injectBasicCss,Xe as injectCss,et as injectUtilsCss,Ze as utilsCssRules};
1
+ var e={};e.d=(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const t=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function r(e){if(!function(e){const r=!t.test(e);return r}(e))return e}function i(e){return r(e)}const n={};function s(e){0}"undefined"!=typeof window&&window.TrustedScriptURL;class o{constructor(e,t){this.privateDoNotAccessOrElseWrappedAttributePrefix=t}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const a=o;function l(e){if(function(e){return e instanceof o}(e))return e.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}"undefined"!=typeof window&&window.TrustedHTML;function c(e,t,r,i){if(0===e.length){throw new Error("")}const n=e.map(e=>l(e)),s=r.toLowerCase();if(n.every(e=>0!==s.indexOf(e)))throw new Error(`Attribute "${r}" does not match any of the allowed prefixes.`);t.setAttribute(r,i)}"undefined"!=typeof window&&window.TrustedScript;class h{}class d extends h{constructor(e,t){super(),s(),this.privateDoNotAccessOrElseWrappedStyleSheet=e}toString(){return this.privateDoNotAccessOrElseWrappedStyleSheet}}function u(e){return new d(e,n)}function f(e){if(e instanceof d)return e.privateDoNotAccessOrElseWrappedStyleSheet;throw new Error("")}function p(e,t){e.textContent=f(t)}Error;class m{iterable;constructor(e){this.iterable=e}filter(e){return new m(m.filterGenerator(e,this.iterable))}map(e){return new m(m.mapGenerator(e,this.iterable))}find(e){for(const t of this.iterable)if(e(t))return t}array(){return Array.from(this.iterable)}*generator(){for(const e of this.iterable)yield e}static*filterGenerator(e,t){for(const r of t)e(r)&&(yield r)}static*mapGenerator(e,t){for(const r of t)yield e(r)}static equals(e,t){const r=e[Symbol.iterator](),i=t[Symbol.iterator]();let n=r.next(),s=i.next();for(;!n.done&&!s.done;){if(n.value!==s.value)return!1;n=r.next(),s=i.next()}return n.done===s.done}}function g(e){return Object.isFrozen(e)&&Object.isFrozen(e.raw)}function b(e){return-1===e.toString().indexOf("`")}b(e=>e``)||b(e=>e`\0`)||b(e=>e`\n`)||b(e=>e`\u0000`),g``&&g`\0`&&g`\n`&&g`\u0000`;function _(e){const t=e[0].toLowerCase();return new a(n,t)}var v,w;function x(e){return{valueOf:e}.valueOf()}!function(e){e[e.STYLE_TAG=0]="STYLE_TAG",e[e.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",e[e.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}(v||(v={}));class y{constructor(e,t,r,i,n){this.allowedElements=e,this.elementPolicies=t,this.allowedGlobalAttributes=r,this.globalAttributePolicies=i,this.globallyAllowedAttributePrefixes=n}isAllowedElement(e){return"FORM"!==e&&(this.allowedElements.has(e)||this.elementPolicies.has(e))}getAttributePolicy(e,t){const r=this.elementPolicies.get(t);if(null==r?void 0:r.has(e))return r.get(e);if(this.allowedGlobalAttributes.has(e))return{policyAction:w.KEEP};const i=this.globalAttributePolicies.get(e);return i||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some(t=>0===e.indexOf(t))?{policyAction:w.KEEP}:{policyAction:w.DROP})}}!function(e){e[e.DROP=0]="DROP",e[e.KEEP=1]="KEEP",e[e.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",e[e.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",e[e.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}(w||(w={}));new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const $=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],E=[["A",new Map([["href",{policyAction:w.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:w.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],A=["title","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-current","aria-disabled","aria-dropeffect","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-live","aria-multiline","aria-multiselectable","aria-orientation","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","alt","align","autocapitalize","autocomplete","autocorrect","autofocus","autoplay","bgcolor","border","cellpadding","cellspacing","checked","color","cols","colspan","controls","datetime","disabled","download","draggable","enctype","face","formenctype","frameborder","height","hreflang","hidden","ismap","label","lang","loop","max","maxlength","media","minlength","min","multiple","muted","nonce","open","placeholder","preload","rel","required","reversed","role","rows","rowspan","selected","shape","size","sizes","slot","span","spellcheck","start","step","summary","translate","type","valign","value","width","wrap","itemscope","itemtype","itemid","itemprop","itemref"],R=[["dir",{policyAction:w.KEEP_AND_NORMALIZE,conditions:x(()=>new Map([["dir",new Set(["auto","ltr","rtl"])]]))}],["async",{policyAction:w.KEEP_AND_NORMALIZE,conditions:x(()=>new Map([["async",new Set(["async"])]]))}],["cite",{policyAction:w.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:w.KEEP_AND_NORMALIZE,conditions:x(()=>new Map([["loading",new Set(["eager","lazy"])]]))}],["poster",{policyAction:w.KEEP_AND_SANITIZE_URL}],["target",{policyAction:w.KEEP_AND_NORMALIZE,conditions:x(()=>new Map([["target",new Set(["_self","_blank"])]]))}]];new y(new Set($),new Map(E),new Set(A),new Map(R)),new y(new Set(x(()=>$.concat(["STYLE"]))),new Map(E),new Set(x(()=>A.concat(["id","name","class"]))),new Map(x(()=>R.concat([["style",{policyAction:w.KEEP_AND_SANITIZE_STYLE}]]))));function O(e){return u(e[0])}const I=[_`:`,_`style`,_`class`];function*k(e,t=new Set){const r=new Set,i=Array.from(e.childNodes).filter(e=>!t.has(e));for(yield e;i.length;){const e=i.shift();r.has(e)||(r.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter(e=>!t.has(e)).forEach(e=>i.push(e))}}function N(e,t){return void 0!==e?.[t]}function P(e,t){return"function"==typeof e?.[t]}function T(e){return e.replace(/-./g,e=>e[1].toUpperCase())}function S(e,t){return N(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function C(e,t){return N(e,"attribs")?t in(e.attribs||{}):e.hasAttribute?.(t)??!1}function D(e,t,r=""){return S(e,r+t)||S(e,`data-${t}`)||(e.dataset?.[T(t)]??null)}function L(e,t,r){N(e,"attribs")?e.attribs[t]=r:e.setAttribute?.(t,r)}function U(e,t,r){N(e,"attribs")?e.attribs[t]=r:c(I,e,t,r)}function M(e,t,r){switch(t){case"disabled":return void(e.disabled=r);case"selected":return void(e.selected=r);case"checked":return void(e.checked=r);default:e[t]=r}}function z(e,t){N(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function j(e,t,r=""){z(e,`${r}${t}`),z(e,`data-${t}`)}function F(e,t,r){if(N(e,"attribs")&&N(t,"attribs"))t.attribs[r]=e.attribs[r];else if(r.startsWith("data-")){const i=T(r.slice(5));t.dataset[i]=e.dataset?.[i]}else{const i=e?.getAttribute?.(r);U(t,r,i||"")}}function G(e){if(N(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find(e=>1===e.nodeType)}function K(e,...t){if(P(e,"replaceWith"))return e.replaceWith(...t);{const r=e,i=r.parentNode,n=Array.from(i.childNodes).indexOf(r);t.forEach(e=>e.parentNode=i),i.childNodes=[].concat(Array.from(i.childNodes).slice(0,n)).concat(t).concat(Array.from(i.childNodes).slice(n+1))}}function W(e,...t){P(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach(t=>t.parentNode=e))}function Y(e,t){return P(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function H(e,t){return P(t,"removeChild")?e.removeChild(t):(W(e,...Array.from(e.childNodes).filter(e=>e!==t)),t)}function B(e,t,r){return r?P(e,"insertBefore")?e.insertBefore(t,r):(K(r,t,r),t):Y(e,t)}function V(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function Z(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map(e=>Z(e,t)).join(""):V(e.outerHTML||e.nodeValue||String(e),t)}function q(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}var Q;!function(e){e.resolveIncludes=async function(e,t){const r=e,i=r.tagName?.toLowerCase();if(!["include","link"].includes(i))return;if("link"===i&&"subresource"!==S(r,"rel"))return;this.log("include directive found in:\n",Z(e,128)),this.log("include params:",t);const n="link"===r.tagName.toLocaleLowerCase()?"href":"src",s=S(r,n);if(!s)throw new Error(`"${n}" attribute missing from ${Z(e,128)}.`);const o=[];"include"===i&&o.push("src"),"link"===i&&o.push("rel","href");const a=t=>{const i=G(t);for(const e of Array.from(r.attributes))i&&!o.includes(e.name)&&F(r,i,e.name);K(e,...t.childNodes)},l={...t,rootDocument:!1,maxdepth:t?.maxdepth-1};if(0===l.maxdepth)throw new Error("Maximum recursion depth reached.");if(s.includes("://")||s.startsWith("//"))this.log("Including remote file from absolute path:",s),await this.preprocessRemote(s,l).then(a);else if(t?.dirpath?.includes("://")||t?.dirpath?.startsWith("//")){const e=s.startsWith("/")?s:`${t.dirpath}/${s}`;this.log("Including remote file from relative path:",e),await this.preprocessRemote(e,l).then(a)}else if("/"===s.charAt(0))this.log("Including local file from absolute path:",s),await this.preprocessLocal(s,l).then(a);else{const e=t?.dirpath&&"."!==t?.dirpath?`${t?.dirpath}/${s}`:s;this.log("Including local file from relative path:",e),await this.preprocessLocal(e,l).then(a)}},e.rebaseRelativePaths=function(e,t){const r=e,n=r.tagName?.toLowerCase();if(!t?.dirpath)return;const s=S(r,"src"),o=S(r,"href"),a=D(r,"render",":"),l=s||o||a;if(!l||((c=l).includes("://")||c.startsWith("/")||c.startsWith("#")||c.startsWith("data:")))return;var c;const h=`${t.dirpath}/${l}`;this.log("Rebasing relative path as:",h),a?function(e,t,r,i=""){C(e,`${i}${t}`)?L(e,`${i}${t}`,r):C(e,`data-${t}`)?L(e,`data-${t}`,r):L(e,`${i}${t}`,r)}(r,"render",h,":"):N(r,"attribs")?U(r,s?"src":"href",h):"img"===n?r.src=h:"a"===n?function(e,t){const r=i(t);void 0!==r&&(e.href=r)}(r,h):"source"===n||"audio"===n||"video"===n||"track"===n||"input"===n?r.src=h:"area"===n?function(e,t){const r=i(t);void 0!==r&&(e.href=r)}(r,h):this.log("Unable to rebase relative path for element:",n)},e.registerCustomElements=function(t,r){const i=t,n=i.tagName?.toLowerCase(),s=(S(i,"is")||S(i,"alt"))?.toLowerCase();if(["template","div"].includes(n)&&s){if("div"===n&&"template"!==S(i,"role"))return;if(!this._customElements.has(s)){this.log(`Registering custom element: ${s}\n`,Z(i,128));const t=i.content||i,n=Array.from(k(t));for(let t=1;t<n.length;t++)e.rebaseRelativePaths.call(this,n[t],r);this._customElements.set(s,i),H(i.parentNode,i)}}},e.resolveCustomElements=function(e,t){const r=e,i=r.tagName?.toLowerCase();let n=i;if("div"===n&&(n=S(r,"role")?.toLowerCase()||n),n&&this._customElements.has(n)){this.log(`Processing custom element: ${n}\n`,Z(r,128));const t=this._customElements.get(n),s=(t.content||t).cloneNode(!0),o=G(s);if(o)for(const e of Array.from(r.attributes))"div"===i&&"role"===e.name||F(r,o,e.name);const a=new m(k(s)).find(e=>"slot"===e.tagName?.toLowerCase());a&&K(a,...r.childNodes),K(e,...s.childNodes)}},e.resolveTextNodeExpressions=function(e,t){const r=e.nodeValue||"";if(3!==e.nodeType||!r?.trim())return;this.log("Processing node content value:\n",V(r,128));const i=new RegExp(/{{ ([^}]+) }}/gm),n=Array.from(r.matchAll(i)).map(e=>e[1]);return this.effect(function(){let t=r;for(const r of n){const i=this.eval(r,{$elem:e});t=t.replace(`{{ ${r} }}`,String(i))}e.nodeValue=t})},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=D(r,"data",":");if(i){let n;this.log(":data attribute found in:\n",Z(e,128)),j(r,"data",":"),N(e,"renderer")?(n=e.renderer,this.log("Reusing existing subrenderer for node:",Z(e,64))):(n=this.subrenderer(),M(e,"renderer",n),this.log("Created and attached new subrenderer for node:",Z(e,64)));const s=n.eval(i,{$elem:e});if(await Promise.all(Object.entries(s).map(([e,t])=>n._store.set(e,t))),n===this)return;for(const t of k(e,this._skipNodes))this._skipNodes.add(t);await n.mount(e,t)}},e.resolveClassAttribute=function(e,t){if(this._skipNodes.has(e))return;const r=e,i=D(r,"class",":");if(i){this.log(":class attribute found in:\n",Z(e,128)),j(r,"class",":");const t=S(r,"class")||"";return this.effect(function(){const n=this.eval(i,{$elem:e});U(r,"class",(n?`${t} ${n}`:t).trim())})}},e.resolveTextAttributes=function(e,t){if(this._skipNodes.has(e))return;const r=e,i=D(r,"text",":");if(i){this.log(":text attribute found in:\n",Z(e,128)),j(r,"text",":");const t=t=>this.textContent(e,t);return this.effect(function(){t(this.eval(i,{$elem:e}))})}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=D(r,"html",":");return i?(this.log(":html attribute found in:\n",Z(e,128)),j(r,"html",":"),this.effect(function(){const n=this.eval(i,{$elem:e});return new Promise(async e=>{const i=await this.preprocessString(n,t);await this.renderNode(i),W(r,i),e()})})):void 0},e.resolveEventAttributes=function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){let i="",n=[];if(t.name.startsWith(":on:")?[i,...n]=t.name.substring(4).split("."):t.name.startsWith("data-on-")&&([i,...n]=t.name.substring(8).split(".")),!i)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",Z(e,128)),j(r,t.name);const s="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,r=>((n.includes("prevent")||s)&&r.preventDefault(),this.eval(t.value,{$elem:e,$event:r})))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=D(r,"for",":")?.trim();if(i){this.log(":for attribute found in:\n",Z(e,128)),j(r,"for",":");for(const t of k(e,this._skipNodes))this._skipNodes.add(t);const n=S(r,"style")||"";L(r,"style","display: none;");const s=e.parentNode,o=this.createElement("template",e.ownerDocument);B(s,o,e),H(s,e),Y(o,e),this.log(":for template:\n",Z(o,128));const a=i.split(" in ",2);if(2!==a.length)throw new Error(`Invalid :for format: \`${i}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=a;await this.effect(function(){const r=this.eval(h,{$elem:e});if(this.log(":for list items:",r),l.splice(0,l.length).forEach(e=>{H(s,e),this._skipNodes.delete(e)}),!Array.isArray(r))return console.error(`Expression did not yield a list: \`${h}\` => \`${r}\``),Promise.resolve();const i=[];for(const s of r){const r=this.subrenderer();r._store.set(c,s);const o=e.cloneNode(!0);L(o,"style",n),l.push(o),this._skipNodes.add(o),i.push(r.mount(o,t)),this.log("Rendered list child:\n",Z(o,128))}const a=o.nextSibling;for(const e of l)B(s,e,a);return Promise.all(i)})}},e.resolveBindAttribute=function(e,t){if(this._skipNodes.has(e))return;const r=e,i=D(r,"bind",":");if(i){this.log(":bind attribute found in:\n",Z(e,128));const t=["change","input"],n=S(r,":bind:on")?.split(",")||r.dataset?.bindOn?.split(",")||t;j(r,"bind",":"),z(r,":bind:on"),z(r,"data-bind-on");const s="checkbox"===S(r,"type")?"checked":"value";i.includes(".")||this.has(i)||this.set(i,""),this.effect(function(){const t=this.eval(i,{$elem:e});"checked"===s?r.checked=!!t:r.value=t});const o=`${i} = $elem.${s}`;for(const t of n)e.addEventListener(t,()=>this.eval(o,{$elem:e}))}},e.resolveShowAttribute=function(e,t){if(this._skipNodes.has(e))return;const r=e,i=D(r,"show",":");if(i){this.log(":show attribute found in:\n",Z(e,128)),j(r,"show",":");const t="none"===r.style?.display?"":r.style?.display??S(r,"style")?.split(";")?.find(e=>"display"===e.split(":")[0])?.split(":")?.at(1)?.trim();this.effect(function(){const n=this.eval(i,{$elem:e});r.style?r.style.display=n?t:"none":U(r,"style",`display: ${n?t:"none"};`)})}},e.resolveCustomAttribute=function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":attr:",n="data-attr-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"attribute found in:\n",Z(e,128)),z(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1);this.effect(function(){const i=this.eval(t.value,{$elem:e});L(r,s,i)})}}},e.resolveCustomProperty=function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":prop:",n="data-prop-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"property found in:\n",Z(e,128)),z(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1),o=T(s);this.effect(function(){const i=this.eval(t.value,{$elem:e});M(r,o,i)})}}},e.stripTypes=function(e,t){const r=e;S(r,":types")&&z(r,":types"),S(r,"data-types")&&z(r,"data-types")},e.resolveRenderAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=D(r,"render",":");if(!i)return;let n;this.log(`:render attribute found: ${i}`),j(r,"render",":"),N(e,"renderer")?(n=e.renderer,this.log("Reusing existing subrenderer for :render:",Z(e,64))):(n=this.subrenderer(),M(r,"renderer",n)),await n.mount(e,t);for(const t of k(e,this._skipNodes))this._skipNodes.add(t);try{const e=await import(i);"function"==typeof e.default?await e.default(r,n):void 0!==e.default&&console.warn(`Module ${i} default export is not a function`)}catch(e){console.error(`Failed to execute render init from ${i}:`,e)}}}(Q||(Q={}));const X=new Set(["this","typeof"]),J=new Set(["in"]),ee=new Set(["+","-","!","typeof"]),te=new Set(["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","in"]),re={"!":0,":":0,",":0,")":0,"]":0,"}":0,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,in:10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"?.":13,"{":13},ie={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,"||":(e,t)=>e||t,"&&":(e,t)=>e&&t,"??":(e,t)=>e??t,"|":(e,t)=>t(e),in:(e,t)=>e in t},ne={"+":e=>e,"-":e=>-e,"!":e=>!e,typeof:e=>typeof e};const se=new Set(["==","!=","<=",">=","||","&&","??","?."]),oe=new Set(["===","!=="]);var ae;!function(e){e[e.STRING=1]="STRING",e[e.IDENTIFIER=2]="IDENTIFIER",e[e.DOT=3]="DOT",e[e.COMMA=4]="COMMA",e[e.COLON=5]="COLON",e[e.INTEGER=6]="INTEGER",e[e.DECIMAL=7]="DECIMAL",e[e.OPERATOR=8]="OPERATOR",e[e.GROUPER=9]="GROUPER",e[e.KEYWORD=10]="KEYWORD",e[e.ARROW=11]="ARROW",e[e.OPTIONAL_DOT=12]="OPTIONAL_DOT",e[e.SPREAD=13]="SPREAD"}(ae||(ae={}));const le=(e,t,r=0)=>({kind:e,value:t,precedence:r}),ce=e=>9===e||10===e||13===e||32===e,he=e=>95===e||36===e||65<=(e&=-33)&&e<=90,de=e=>he(e)||ue(e),ue=e=>48<=e&&e<=57;class fe{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;ce(this._next);)this._advance(!0);if(34===(e=this._next)||39===e)return this._tokenizeString();var e;if(he(this._next))return this._tokenizeIdentOrKeyword();if(ue(this._next))return this._tokenizeNumber();if(46===this._next)return this._tokenizeDot();if(44===this._next)return this._tokenizeComma();if(58===this._next)return this._tokenizeColon();if((e=>43===e||45===e||42===e||47===e||33===e||38===e||37===e||60===e||61===e||62===e||63===e||94===e||124===e)(this._next))return this._tokenizeOperator();if((e=>40===e||41===e||91===e||93===e||123===e||125===e)(this._next))return this._tokenizeGrouper();if(this._advance(),void 0!==this._next)throw new Error(`Expected end of input, got ${this._next}`)}_advance(e){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),!0===e&&(this._tokenStart=this._index)):this._next=void 0}_getValue(e=0){const t=this._input.substring(this._tokenStart,this._index+e);return 0===e&&this._clearValue(),t}_clearValue(){this._tokenStart=this._index}_tokenizeString(){const e="unterminated string",t=this._next;for(this._advance(!0);this._next!==t;){if(void 0===this._next)throw new Error(e);if(92===this._next&&(this._advance(),void 0===this._next))throw new Error(e);this._advance()}const r=le(ae.STRING,this._getValue().replace(/\\(.)/g,(e,t)=>{switch(t){case"n":return"\n";case"r":return"\r";case"t":return"\t";case"b":return"\b";case"f":return"\f";default:return t}}));return this._advance(),r}_tokenizeIdentOrKeyword(){do{this._advance()}while(de(this._next));const e=this._getValue(),t=(r=e,X.has(r)?ae.KEYWORD:J.has(e)?ae.OPERATOR:ae.IDENTIFIER);var r;return le(t,e,re[e]??0)}_tokenizeNumber(){do{this._advance()}while(ue(this._next));return 46===this._next?this._tokenizeDot():le(ae.INTEGER,this._getValue())}_tokenizeDot(){if(this._advance(),ue(this._next))return this._tokenizeFraction();if(46===this._next){if(this._advance(),46===this._next)return this._advance(),this._clearValue(),le(ae.SPREAD,"...");throw new Error("Unexpected token ..")}return this._clearValue(),le(ae.DOT,".",13)}_tokenizeComma(){return this._advance(!0),le(ae.COMMA,",")}_tokenizeColon(){return this._advance(!0),le(ae.COLON,":")}_tokenizeFraction(){do{this._advance()}while(ue(this._next));return le(ae.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(oe.has(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),le(ae.ARROW,e);se.has(e)&&this._advance()}return e=this._getValue(),"?."===e?le(ae.OPTIONAL_DOT,e,13):le(ae.OPERATOR,e,re[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=le(ae.GROUPER,e,re[e]);return this._advance(!0),t}}class pe{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new fe(e),this._ast=t}parse(){this._advance();const e=this._parseExpression();if(this._token)throw new Error(`Unexpected token: ${this._token.value}`);return e}_advance(e,t){if(!this._matches(e,t))throw new Error(`Expected kind ${e} (${t}), was ${this._token?.kind} (${this._token?.value})`);const r=this._tokenizer.nextToken();this._token=r,this._kind=r?.kind,this._value=r?.value}_matches(e,t){return!(e&&this._kind!==e||t&&this._value!==t)}_parseExpression(){if(!this._token)return this._ast.empty();const e=this._parseUnary();return void 0===e?void 0:this._parsePrecedence(e,0)}_parsePrecedence(e,t){if(void 0===e)throw new Error("Expected left to be defined.");for(;this._token;)if(this._matches(ae.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(ae.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(ae.DOT)||this._matches(ae.OPTIONAL_DOT)){const t=this._kind===ae.OPTIONAL_DOT;if(this._advance(),t&&this._matches(ae.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t,!0)}else if(t&&this._matches(ae.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t,!0)}else{const r=this._parseUnary();e=this._makeInvokeOrGetter(e,r,t)}}else{if(this._matches(ae.KEYWORD))break;if(!(this._matches(ae.OPERATOR)&&this._token.precedence>=t))break;e="?"===this._value?this._parseTernary(e):this._parseBinary(e,this._token)}return e}_makeInvokeOrGetter(e,t,r){if(void 0===t)throw new Error("expected identifier");if("ID"===t.type)return this._ast.getter(e,t.value,r);if("Invoke"===t.type&&"ID"===t.receiver.type){const i=t.receiver;return this._ast.invoke(e,i.value,t.arguments,r)}throw new Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(!te.has(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let r=this._parseUnary();for(;(this._kind===ae.OPERATOR||this._kind===ae.DOT||this._kind===ae.GROUPER)&&this._token.precedence>t.precedence;)r=this._parsePrecedence(r,this._token.precedence);if(void 0===r)throw new Error(`Expected expression after ${t.value}`);return this._ast.binary(e,t.value,r)}_parseUnary(){if(this._matches(ae.KEYWORD,"typeof")){this._advance();const e=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary("typeof",e)}if(this._matches(ae.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(ae.INTEGER))return this._parseInteger(e);if(this._matches(ae.DECIMAL))return this._parseDecimal(e)}if(!ee.has(e))throw new Error(`unexpected token: ${e}`);const t=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(e,t)}return this._parsePrimary()}_parseTernary(e){this._advance(ae.OPERATOR,"?");const t=this._parseExpression();this._advance(ae.COLON);const r=this._parseExpression();return this._ast.ternary(e,t,r)}_parsePrimary(){switch(this._kind){case ae.KEYWORD:const e=this._value;if("this"===e)return this._advance(),this._ast.id(e);if(X.has(e))throw new Error(`unexpected keyword: ${e}`);throw new Error(`unrecognized keyword: ${e}`);case ae.IDENTIFIER:return this._parseInvokeOrIdentifier();case ae.STRING:return this._parseString();case ae.INTEGER:return this._parseInteger();case ae.DECIMAL:return this._parseDecimal();case ae.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case ae.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(ae.GROUPER,"]"))break;if(this._matches(ae.SPREAD)){this._advance();const t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else e.push(this._parseExpression())}while(this._matches(ae.COMMA));return this._advance(ae.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e=[];do{if(this._advance(),this._matches(ae.GROUPER,"}"))break;if(this._matches(ae.SPREAD)){this._advance();const t=this._parseExpression();t&&e.push(this._ast.spreadProperty(t))}else{const t=this._value;if((this._matches(ae.STRING)||this._matches(ae.IDENTIFIER))&&this._advance(),this._matches(ae.COLON)){this._advance(ae.COLON);const r=this._parseExpression();r&&e.push(this._ast.property(t,r))}else e.push(this._ast.property(t,this._ast.id(t)))}}while(this._matches(ae.COMMA));return this._advance(ae.GROUPER,"}"),this._ast.map(e)}_parseInvokeOrIdentifier(){const e=this._value;if("true"===e)return this._advance(),this._ast.literal(!0);if("false"===e)return this._advance(),this._ast.literal(!1);if("null"===e)return this._advance(),this._ast.literal(null);if("undefined"===e)return this._advance(),this._ast.literal(void 0);const t=this._parseIdentifier(),r=this._parseArguments();return r?this._ast.invoke(t,void 0,r):t}_parseIdentifier(){if(!this._matches(ae.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(ae.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(ae.GROUPER,")"))break;if(this._matches(ae.SPREAD)){this._advance();const t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else{const t=this._parseExpression();e.push(t)}}while(this._matches(ae.COMMA));return this._advance(ae.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(ae.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(ae.ARROW)){this._advance();const t=this._parseExpression(),r=e?.map(e=>e.value)??[];return this._ast.arrowFunction(r,t)}return this._ast.paren(e[0])}_parseString(){const e=this._ast.literal(this._value);return this._advance(),e}_parseInteger(e=""){const t=this._ast.literal(parseInt(`${e}${this._value}`,10));return this._advance(),t}_parseDecimal(e=""){const t=this._ast.literal(parseFloat(`${e}${this._value}`));return this._advance(),t}}class me{timeouts=new Map;debounce(e,t){return new Promise((r,i)=>{const n=this.timeouts.get(t);n&&clearTimeout(n),this.timeouts.set(t,setTimeout(()=>{try{r(t()),this.timeouts.delete(t)}catch(e){i(e)}},e))})}}const ge=new class{empty(){return{type:"Empty",evaluate:e=>e,getIds:e=>e}}literal(e){return{type:"Literal",value:e,evaluate(e){return this.value},getIds:e=>e}}id(e){return{type:"ID",value:e,evaluate(e){return"this"===this.value?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(e,t){const r=ne[e];return{type:"Unary",operator:e,child:t,evaluate(e){return r(this.child.evaluate(e))},getIds(e){return this.child.getIds(e)}}}binary(e,t,r){const i=ie[t];return{type:"Binary",operator:t,left:e,right:r,evaluate(e){if("="===this.operator){if("ID"!==this.left.type&&"Getter"!==this.left.type&&"Index"!==this.left.type)throw new Error(`Invalid assignment target: ${this.left}`);const t=this.right.evaluate(e);let r,i;return"Getter"===this.left.type?(r=this.left.receiver.evaluate(e),i=this.left.name):"Index"===this.left.type?(r=this.left.receiver.evaluate(e),i=String(this.left.argument.evaluate(e))):"ID"===this.left.type&&(r=e,i=this.left.value),void 0===r?void 0:r[i]=t}return i(this.left.evaluate(e),this.right.evaluate(e))},getIds(e){return this.left.getIds(e),this.right.getIds(e),e}}}getter(e,t,r){return{type:"Getter",receiver:e,name:t,optional:r,evaluate(e){const t=this.receiver.evaluate(e);if(!this.optional||null!=t)return t?.[this.name]},getIds(e){return this.receiver.getIds(e),e}}}invoke(e,t,r,i){if(null!=t&&"string"!=typeof t)throw new Error("method not a string");return{type:"Invoke",receiver:e,method:t,arguments:r,optional:i,evaluate(e){const t=this.receiver.evaluate(e);if(this.optional&&null==t)return;const r=this.method?t:e?.this??e,i=this.method?t?.[this.method]:t,n=this.arguments??[],s=[];for(const t of n)if("SpreadElement"===t?.type){const r=t.evaluate(e);r&&"function"==typeof r[Symbol.iterator]&&s.push(...r)}else s.push(t?.evaluate(e));return i?.apply?.(r,s)},getIds(e){return this.receiver.getIds(e),this.arguments?.forEach(t=>t?.getIds(e)),e}}}paren(e){return e}index(e,t,r){return{type:"Index",receiver:e,argument:t,optional:r,evaluate(e){const t=this.receiver.evaluate(e);if(this.optional&&null==t)return;const r=this.argument.evaluate(e);return t?.[r]},getIds(e){return this.receiver.getIds(e),e}}}ternary(e,t,r){return{type:"Ternary",condition:e,trueExpr:t,falseExpr:r,evaluate(e){return this.condition.evaluate(e)?this.trueExpr.evaluate(e):this.falseExpr.evaluate(e)},getIds(e){return this.condition.getIds(e),this.trueExpr.getIds(e),this.falseExpr.getIds(e),e}}}map(e){return{type:"Map",properties:e,evaluate(t){const r={};if(e&&this.properties)for(const e of this.properties)"SpreadProperty"===e.type?Object.assign(r,e.evaluate(t)):r[e.key]=e.value.evaluate(t);return r},getIds(t){if(e&&this.properties)for(const e of this.properties)"SpreadProperty"===e.type?e.expression.getIds(t):e.value.getIds(t);return t}}}property(e,t){return{type:"Property",key:e,value:t,evaluate(e){return this.value.evaluate(e)},getIds(e){return this.value.getIds(e)}}}list(e){return{type:"List",items:e,evaluate(e){if(!this.items)return[];const t=[];for(const r of this.items)if("SpreadElement"===r?.type){const i=r.evaluate(e);i&&"function"==typeof i[Symbol.iterator]&&t.push(...i)}else t.push(r?.evaluate(e));return t},getIds(e){return this.items?.forEach(t=>t?.getIds(e)),e}}}arrowFunction(e,t){return{type:"ArrowFunction",params:e,body:t,evaluate(e){const t=this.params,r=this.body;return function(...i){const n=Object.fromEntries(t.map((e,t)=>[e,i[t]])),s=new Proxy(e??{},{set:(e,t,r)=>(n.hasOwnProperty(t)&&(n[t]=r),e[t]=r),get:(e,t)=>n.hasOwnProperty(t)?n[t]:e[t]});return r.evaluate(s)}},getIds(e){return this.body.getIds(e).filter(e=>!this.params.includes(e))}}}spreadProperty(e){return{type:"SpreadProperty",expression:e,evaluate(e){return this.expression.evaluate(e)},getIds(e){return this.expression.getIds(e)}}}spreadElement(e){return{type:"SpreadElement",expression:e,evaluate(e){return this.expression.evaluate(e)},getIds(e){return this.expression.getIds(e)}}}},be="__is_proxy__";function _e(e,t){const r=e?._store;return r?.has(t)?r.get(t):r?.has("$parent")?_e(r.get("$parent"),t):void 0}function ve(e,t){const r=e?._store;return r?.has(t)?e:r?.has("$parent")?ve(r.get("$parent"),t):null}class we extends me{evalkeys=["$elem","$event"];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_observer=null;_store=new Map;_lock=Promise.resolve();constructor(e){super();for(const[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof we||!0===r[be])||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>"string"==typeof r&&r in e&&(delete e[r],t(),!0),set:(e,r,i,n)=>{"object"==typeof i&&null!==i&&(i=this.wrapObject(i,t));const s=Reflect.set(e,r,i,n);return t(),s},get:(e,t,r)=>t===be||Reflect.get(e,t,r)});var r}watch(e,t){const r=ve(this,e);if(!r)throw new Error(`Cannot watch key "${e}" as it does not exist in the store.`);r.observers.has(e)||r.observers.set(e,new Set),r.observers.get(e)?.has(t)||r.observers.get(e)?.add(t)}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e).add(t)}async notify(e,t=10){const r=ve(this,e),i=Array.from(r?.observers.get(e)||[]);await this.debounce(t,()=>Promise.all(i.map(e=>e.call(this.proxify(e)))))}get(e,t){return t&&this.watch(e,t),_e(this,e)}async set(e,t){if(this._store.has(e)&&t===this._store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=ve(e,t);i?i._store.set(t,r):e._store.set(t,r)}(this,e,t);for(const[r,i]of this.keyHandlers.entries())if(r.test(e))for(const r of i)await Promise.resolve(r.call(this.$,e,t));await r()}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e)}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this._store.entries()).map(([e])=>e),r=Object.fromEntries(t.map(e=>[e,null]));return new Proxy(r,{has:(e,t)=>{if("string"==typeof t){if(ve(this,t))return!0;if(Reflect.has(this,t))return!0}return Reflect.has(r,t)},get:(t,r,i)=>{if("string"==typeof r){if(ve(this,r))return this.get(r,e);if(e&&r!==be&&!Reflect.has(this,r))return this.set(r,void 0),this.get(r,e)}return"$"===r?this.proxify(e):Reflect.get(this,r,i)},set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");return(t,r)=>{const i=((e,t)=>new pe(e,t).parse())(e,ge),n=new Proxy(r,{has:(e,r)=>r in e||r in t||r in globalThis,get(e,r){if("string"==typeof r)return r in e?e[r]:r in t?t[r]:r in globalThis?globalThis[r]:t[r]},set:(e,r,i)=>"string"==typeof r&&(r in e?(e[r]=i,!0):(t[r]=i,!0))});return i?.evaluate(n)}}cachedExpressionFunction(e){return e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e)),this.expressionCache.get(e)}eval(e,t={}){const r=this._observer?this:this.$;if(this._store.has(e))return r[e];{const i=this.cachedExpressionFunction(e);try{return i(r,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}$resolve(e,t){const r={$pending:!0,$result:null,$error:null};return Promise.resolve().then(()=>e(t)).then(e=>{r.$result=e}).catch(e=>{r.$error=e instanceof Error?e:new Error(String(e))}).finally(()=>{r.$pending=!1}),r}}const xe="$$";function ye(){return new URL(globalThis.window?.location?.href||"http://localhost/")}function $e(e){return`${xe}${e}`}function Ee(e){return e.keys().filter(e=>e.startsWith(xe))}function Ae(e,t,r){const i=function(e){return e.substring(2)}(t);let n=!1;if(r){const t=String(r);e.searchParams.get(i)!==t&&(e.searchParams.set(i,t),n=!0)}else e.searchParams.has(i)&&(e.searchParams.delete(i),n=!0);return n}async function Re(e){const t=ye();await async function(e,t){for(const[r,i]of t.searchParams.entries()){const t=$e(r);e.get(t)!==i&&await e.set(t,i)}}(e,t),function(e,t){let r=!1;for(const i of Ee(t))Ae(e,i,t.get(i))&&(r=!0);r&&globalThis.window?.history?.replaceState({},"",e.toString())}(t,e),e.addKeyHandler(new RegExp("^\\$\\$"),(e,t)=>{const r=ye();Ae(r,e,t)&&globalThis.window?.history?.replaceState({},"",r.toString())}),globalThis.window?.addEventListener("popstate",function(e){return async()=>{const t=ye(),r=new Set;for(const[i,n]of t.searchParams.entries()){const t=$e(i);r.add(t),e.get(t)!==n&&e.set(t,n)}const i=Ee(e);for(const t of i)r.has(t)||e.del(t)}}(e))}class Oe extends we{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(e){return this.debugging=e,this}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??"default"}).then(e=>e.text())}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log("Preprocessing string content with params:\n",t);const r=this.parseHTML(e,t);return await this.preprocessNode(r,t),r}async preprocessRemote(e,t){const r={};t?.cache&&(r.cache=t.cache);const i=await fetch(e,r).then(e=>e.text());return this.preprocessString(i,{...t,dirpath:q(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}async preprocessLocal(e,t){const r=await this.fetchLocal(e,t);return this.preprocessString(r,{...t,dirpath:q(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}subrenderer(){const e=(new this.constructor).debug(this.debugging);return e._store.set("$parent",this),e._store.set("$rootRenderer",this.get("$rootRenderer")??this),e._customElements=this._customElements,e}log(...e){this.debugging&&console.debug(...e)}async preprocessNode(e,t){t={dirpath:this.dirpath,maxdepth:10,...t};const r=new m(k(e,this._skipNodes)).map(async e=>{this.log("Preprocessing node:\n",Z(e,128)),await Q.resolveIncludes.call(this,e,t),await Q.rebaseRelativePaths.call(this,e,t),await Q.registerCustomElements.call(this,e,t),await Q.resolveCustomElements.call(this,e,t)});return await Promise.all(r.generator()),e}async renderNode(e,t){for(const r of k(e,this._skipNodes))this.log("Rendering node:\n",Z(r,128)),await Q.resolveForAttribute.call(this,r,t),await Q.resolveRenderAttribute.call(this,r,t),await Q.resolveDataAttribute.call(this,r,t),await Q.resolveTextAttributes.call(this,r,t),await Q.resolveHtmlAttribute.call(this,r,t),await Q.resolveShowAttribute.call(this,r,t),await Q.resolveClassAttribute.call(this,r,t),await Q.resolveBindAttribute.call(this,r,t),await Q.resolveEventAttributes.call(this,r,t),await Q.resolveTextNodeExpressions.call(this,r,t),await Q.resolveCustomAttribute.call(this,r,t),await Q.resolveCustomProperty.call(this,r,t),await Q.stripTypes.call(this,r,t);return e}async mount(e,t){t={...t,rootNode:e},M(e,"renderer",this),this._store.set("$rootNode",e),this.has("$rootRenderer")||this._store.set("$rootRenderer",this),this.get("$rootRenderer")===this&&await Re(this),await this.preprocessNode(e,t),await this.renderNode(e,t)}}function Ie(){return u([O`html{`,O`max-width: 70ch;`,O`padding: 2em 1em;`,O`margin: auto;`,O`line-height: 1.75;`,O`font-size: 1.25em;`,O`font-family: sans-serif;`,O`}`,O`h1,h2,h3,h4,h5,h6{`,O`margin: 1em 0 0.5em;`,O`}`,O`p,ul,ol{`,O`margin-bottom: 1em;`,O`color: #1d1d1d;`,O`}`].map(f).join(""))}const ke={sm:640,md:768,lg:1024,xl:1280},Ne=Object.entries(ke),Pe=.25,Te=[...Array(15)].map((e,t)=>t+1),Se=[...Te,16,20,24,25,28,30,32,36,40,44,48,50,52,56,60,64,72,80,96,100,112,128,144,160,192,200,224,256,288,300,320,384,400,448,500,512,...Object.values(ke)],Ce=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],De=[75,100,150,200,300,500,700,1e3],Le=["hover","focus","disabled","active"],Ue={margin:"m",padding:"p"},Me={width:"w",height:"h"},ze={top:"top",right:"right",bottom:"bottom",left:"left"},je={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},Fe={"font-mono":{"font-family":"monospace"},"font-sans":{"font-family":"sans-serif"},"font-serif":{"font-family":"serif"},"font-cursive":{"font-family":"cursive"},"text-xs":{"font-size":".75rem","line-height":"calc(1 / 0.75)"},"text-sm":{"font-size":".875rem","line-height":"calc(1.25 / 0.875)"},"text-base":{"font-size":"1rem","line-height":"calc(1.5 / 1)"},"text-lg":{"font-size":"1.125rem","line-height":"calc(1.75 / 1.125)"},"text-xl":{"font-size":"1.25rem","line-height":"calc(1.75 / 1.25)"},"text-2xl":{"font-size":"1.5rem","line-height":"calc(2 / 1.5)"},"text-3xl":{"font-size":"1.875rem","line-height":"calc(2.25 / 1.875)"},"text-4xl":{"font-size":"2.25rem","line-height":"calc(2.5 / 2.25)"},"text-5xl":{"font-size":"3rem","line-height":"1"},"text-6xl":{"font-size":"3.75rem","line-height":"1"},"text-7xl":{"font-size":"4.5rem","line-height":"1"},"font-thin":{"font-weight":100},"font-extralight":{"font-weight":200},"font-light":{"font-weight":300},"font-normal":{"font-weight":400},"font-medium":{"font-weight":500},"font-semibold":{"font-weight":600},"font-bold":{"font-weight":700},"font-extrabold":{"font-weight":800},"font-black":{"font-weight":900},italic:{"font-style":"italic"},"not-italic":{"font-style":"normal"},"w-max":{width:"max-content"},"w-min":{width:"min-content"},"w-fit":{width:"fit-content"},"h-max":{height:"max-content"},"h-min":{height:"min-content"},"h-fit":{height:"fit-content"},"size-auto":{width:"auto",height:"auto"},"size-px":{width:"1px",height:"1px"},"size-full":{width:"100%",height:"100%"},"size-dvw":{width:"100dvw",height:"100dvw"},"size-dvh":{width:"100dvh",height:"100dvh"},"size-lvw":{width:"100lvw",height:"100lvw"},"size-lvh":{width:"100lvh",height:"100lvh"},"size-svw":{width:"100svw",height:"100svw"},"size-svh":{width:"100svh",height:"100svh"},"size-min":{width:"min-content",height:"min-content"},"size-max":{width:"max-content",height:"max-content"},"size-fit":{width:"fit-content",height:"fit-content"},"tracking-tighter":{"letter-spacing":"-0.05em"},"tracking-tight":{"letter-spacing":"-0.025em"},"tracking-normal":{"letter-spacing":"0"},"tracking-wide":{"letter-spacing":"0.025em"},"tracking-wider":{"letter-spacing":"0.05em"},"tracking-widest":{"letter-spacing":"0.1em"},"leading-none":{"line-height":"1"},"leading-tight":{"line-height":"1.25"},"leading-snug":{"line-height":"1.375"},"leading-normal":{"line-height":"1.5"},"leading-relaxed":{"line-height":"1.625"},"leading-loose":{"line-height":"2"},"text-left":{"text-align":"left"},"text-right":{"text-align":"right"},"text-center":{"text-align":"center"},"text-justify":{"text-align":"justify"},underline:{"text-decoration":"underline"},"no-underline":{"text-decoration":"none"},"decoration-none":{"text-decoration":"none"},"line-through":{"text-decoration":"line-through"},uppercase:{"text-transform":"uppercase"},lowercase:{"text-transform":"lowercase"},capitalize:{"text-transform":"capitalize"},truncate:{"white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis"},"text-elipsis":{"text-overflow":"ellipsis"},"text-clip":{"text-overflow":"clip"},"text-wrap":{"text-wrap":"wrap"},"text-nowrap":{"text-wrap":"nowrap"},"text-balance":{"text-wrap":"balance"},"text-pretty":{"text-wrap":"pretty"},"whitespace-normal":{"white-space":"normal"},"whitespace-nowrap":{"white-space":"nowrap"},"whitespace-pre":{"white-space":"pre"},"whitespace-pre-line":{"white-space":"pre-line"},"whitespace-pre-wrap":{"white-space":"pre-wrap"},"whitespace-break-spaces":{"white-space":"break-spaces"},relative:{position:"relative"},fixed:{position:"fixed"},absolute:{position:"absolute"},sticky:{position:"sticky"},"object-contain":{"object-fit":"contain"},"object-cover":{"object-fit":"cover"},"object-fill":{"object-fit":"fill"},"object-none":{"object-fit":"none"},block:{display:"block"},contents:{display:"contents"},hidden:{display:"none"},inline:{display:"inline"},"inline-block":{display:"inline-block"},visible:{visibility:"visible"},invisible:{visibility:"hidden"},collapse:{visibility:"collapse"},"list-none":{"list-style-type":"none"},"list-disc":{"list-style-type":"disc"},"list-decimal":{"list-style-type":"decimal"},flex:{display:"flex"},"flex-1":{flex:"1 1 0%"},"flex-inline":{display:"inline-flex"},"flex-row":{"flex-direction":"row"},"flex-col":{"flex-direction":"column"},"flex-row-reverse":{"flex-direction":"row-reverse"},"flex-col-reverse":{"flex-direction":"column-reverse"},"flex-wrap":{"flex-wrap":"wrap"},"flex-wrap-reverse":{"flex-wrap":"wrap-reverse"},"flex-nowrap":{"flex-wrap":"nowrap"},"justify-start":{"justify-content":"flex-start"},"justify-end":{"justify-content":"flex-end"},"justify-center":{"justify-content":"center"},"justify-between":{"justify-content":"space-between"},"justify-around":{"justify-content":"space-around"},"justify-evenly":{"justify-content":"space-evenly"},"justify-stretch":{"justify-content":"stretch"},"items-start":{"align-items":"flex-start"},"items-end":{"align-items":"flex-end"},"items-center":{"align-items":"center"},"items-stretch":{"align-items":"stretch"},"flex-grow":{"flex-grow":1},"flex-shrink":{"flex-shrink":1},"align-baseline":{"vertical-align":"baseline"},"align-top":{"vertical-align":"top"},"align-middle":{"vertical-align":"middle"},"align-bottom":{"vertical-align":"bottom"},"align-text-top":{"vertical-align":"text-top"},"align-text-bottom":{"vertical-align":"text-bottom"},"overflow-auto":{overflow:"auto"},"overflow-x-auto":{"overflow-x":"auto"},"overflow-y-auto":{"overflow-y":"auto"},"overflow-hidden":{overflow:"hidden"},"overflow-x-hidden":{"overflow-x":"hidden"},"overflow-y-hidden":{"overflow-y":"hidden"},"overflow-visible":{overflow:"visible"},"overscroll-auto":{"overscroll-behavior":"auto"},"overscroll-contain":{"overscroll-behavior":"contain"},"overscroll-none":{"overscroll-behavior":"none"},"overscroll-x-auto":{"overscroll-behavior-x":"auto"},"overscroll-x-contain":{"overscroll-behavior-x":"contain"},"overscroll-x-none":{"overscroll-behavior-x":"none"},"overscroll-y-auto":{"overscroll-behavior-y":"auto"},"overscroll-y-contain":{"overscroll-behavior-y":"contain"},"overscroll-y-none":{"overscroll-behavior-y":"none"},"z-auto":{"z-index":"auto"},"cursor-pointer":{cursor:"pointer"},"cursor-wait":{cursor:"wait"},"cursor-not-allowed":{cursor:"not-allowed"},"select-none":{"user-select":"none"},"select-all":{"user-select":"all"},"pointer-events-auto":{"pointer-events":"auto"},"pointer-events-none":{"pointer-events":"none"},"box-border":{"box-sizing":"border-box"},"box-content":{"box-sizing":"content-box"},resize:{resize:"both"},"resize-x":{resize:"horizontal"},"resize-y":{resize:"vertical"},"resize-none":{resize:"none"},border:{border:"1px solid"},"border-none":{border:"none"},"border-solid":{"border-style":"solid"},"border-dashed":{"border-style":"dashed"},"border-dotted":{"border-style":"dotted"},"border-collapse":{"border-collapse":"collapse"},"rounded-none":{"border-radius":"0"},rounded:{"border-radius":".25rem"},"rounded-sm":{"border-radius":".125rem"},"rounded-md":{"border-radius":".375rem"},"rounded-lg":{"border-radius":".5rem"},"rounded-xl":{"border-radius":".75rem"},"rounded-full":{"border-radius":"9999px"},shadow:{"box-shadow":"0 0 1px 0 rgba(0, 0, 0, 0.05)"},"shadow-sm":{"box-shadow":"0 1px 2px 0 rgba(0, 0, 0, 0.05)"},"shadow-md":{"box-shadow":"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},"shadow-lg":{"box-shadow":"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},"shadow-xl":{"box-shadow":"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)"},"shadow-2xl":{"box-shadow":"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},"shadow-inner":{"box-shadow":"inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)"},"shadow-outline":{"box-shadow":"0 0 0 3px rgba(66, 153, 225, 0.5)"},"shadow-none":{"box-shadow":"none"},"transition-none":{transition:"none"},transition:{transition:"all 150ms ease-in-out"},"animate-none":{animation:"none"},"animate-spin":{animation:"spin 1s linear infinite"},"animate-ping":{animation:"ping 1s cubic-bezier(0, 0, 0.2, 1) infinite"},"animate-pulse":{animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"},"bg-auto":{"background-size":"auto"},"bg-cover":{"background-size":"cover"},"bg-contain":{"background-size":"contain"},"bg-no-repeat":{"background-repeat":"no-repeat"},"bg-fixed":{"background-attachment":"fixed"},"bg-local":{"background-attachment":"local"},"bg-scroll":{"background-attachment":"scroll"},"min-h-screen":{"min-height":"100vh"},"max-h-screen":{"max-height":"100vh"},"min-w-screen":{"min-width":"100vw"},"h-dvh":{height:"100dvh"},"h-svh":{height:"100svh"},"h-lvh":{height:"100lvh"},"w-dvw":{width:"100dvw"},"w-svw":{width:"100svw"},"w-lvw":{width:"100lvw"},"min-h-dvh":{"min-height":"100dvh"},"min-h-svh":{"min-height":"100svh"},"min-h-lvh":{"min-height":"100lvh"},"flex-none":{flex:"none"},"flex-auto":{flex:"1 1 auto"},"flex-initial":{flex:"0 1 auto"},grow:{"flex-grow":"1"},"grow-0":{"flex-grow":"0"},shrink:{"flex-shrink":"1"},"shrink-0":{"flex-shrink":"0"},"self-auto":{"align-self":"auto"},"self-start":{"align-self":"flex-start"},"self-end":{"align-self":"flex-end"},"self-center":{"align-self":"center"},"self-stretch":{"align-self":"stretch"},"self-baseline":{"align-self":"baseline"},"content-normal":{"align-content":"normal"},"content-start":{"align-content":"flex-start"},"content-end":{"align-content":"flex-end"},"content-center":{"align-content":"center"},"content-between":{"align-content":"space-between"},"content-around":{"align-content":"space-around"},"content-evenly":{"align-content":"space-evenly"},"content-stretch":{"align-content":"stretch"},"items-baseline":{"align-items":"baseline"},"inset-0":{inset:"0"},"inset-auto":{inset:"auto"},"inset-x-0":{left:"0",right:"0"},"inset-y-0":{top:"0",bottom:"0"},"inset-x-auto":{left:"auto",right:"auto"},"inset-y-auto":{top:"auto",bottom:"auto"},"sr-only":{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)","white-space":"nowrap","border-width":"0"},"not-sr-only":{position:"static",width:"auto",height:"auto",padding:"0",margin:"0",overflow:"visible",clip:"auto","white-space":"normal"}},Ge=["@keyframes spin {\n from { transform: rotate(0deg) }\n to { transform: rotate(360deg) }\n }","@keyframes ping {\n 75%, 100% {\n transform: scale(2);\n opacity: 0;\n }\n }","@keyframes pulse {\n 0%, 100% { opacity: 1 }\n 50% { opacity: .5 }\n }"],Ke={red:{50:"#ffebee",100:"#ffcdd2",200:"#ef9a9a",300:"#e57373",400:"#ef5350",500:"#f44336",600:"#e53935",700:"#d32f2f",800:"#c62828",900:"#b71c1c"},pink:{50:"#fce4ec",100:"#f8bbd0",200:"#f48fb1",300:"#f06292",400:"#ec407a",500:"#e91e63",600:"#d81b60",700:"#c2185b",800:"#ad1457",900:"#880e4f"},purple:{50:"#f3e5f5",100:"#e1bee7",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",600:"#8e24aa",700:"#7b1fa2",800:"#6a1b9a",900:"#4a148c"},"deep-purple":{50:"#ede7f6",100:"#d1c4e9",200:"#b39ddb",300:"#9575cd",400:"#7e57c2",500:"#673ab7",600:"#5e35b1",700:"#512da8",800:"#4527a0",900:"#311b92"},indigo:{50:"#e8eaf6",100:"#c5cae9",200:"#9fa8da",300:"#7986cb",400:"#5c6bc0",500:"#3f51b5",600:"#3949ab",700:"#303f9f",800:"#283593",900:"#1a237e"},blue:{50:"#e3f2fd",100:"#bbdefb",200:"#90caf9",300:"#64b5f6",400:"#42a5f5",500:"#2196f3",600:"#1e88e5",700:"#1976d2",800:"#1565c0",900:"#0d47a1"},"light-blue":{50:"#e1f5fe",100:"#b3e5fc",200:"#81d4fa",300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",600:"#039be5",700:"#0288d1",800:"#0277bd",900:"#01579b"},cyan:{50:"#e0f7fa",100:"#b2ebf2",200:"#80deea",300:"#4dd0e1",400:"#26c6da",500:"#00bcd4",600:"#00acc1",700:"#0097a7",800:"#00838f",900:"#006064"},teal:{50:"#e0f2f1",100:"#b2dfdb",200:"#80cbc4",300:"#4db6ac",400:"#26a69a",500:"#009688",600:"#00897b",700:"#00796b",800:"#00695c",900:"#004d40"},green:{50:"#e8f5e9",100:"#c8e6c9",200:"#a5d6a7",300:"#81c784",400:"#66bb6a",500:"#4caf50",600:"#43a047",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"},"light-green":{50:"#f1f8e9",100:"#dcedc8",200:"#c5e1a5",300:"#aed581",400:"#9ccc65",500:"#8bc34a",600:"#7cb342",700:"#689f38",800:"#558b2f",900:"#33691e"},lime:{50:"#f9fbe7",100:"#f0f4c3",200:"#e6ee9c",300:"#dce775",400:"#d4e157",500:"#cddc39",600:"#c0ca33",700:"#afb42b",800:"#9e9d24",900:"#827717"},yellow:{50:"#fffde7",100:"#fff9c4",200:"#fff59d",300:"#fff176",400:"#ffee58",500:"#ffeb3b",600:"#fdd835",700:"#fbc02d",800:"#f9a825",900:"#f57f17"},amber:{50:"#fff8e1",100:"#ffecb3",200:"#ffe082",300:"#ffd54f",400:"#ffca28",500:"#ffc107",600:"#ffb300",700:"#ffa000",800:"#ff8f00",900:"#ff6f00"},orange:{50:"#fff3e0",100:"#ffe0b2",200:"#ffcc80",300:"#ffb74d",400:"#ffa726",500:"#ff9800",600:"#fb8c00",700:"#f57c00",800:"#ef6c00",900:"#e65100"},"deep-orange":{50:"#fbe9e7",100:"#ffccbc",200:"#ffab91",300:"#ff8a65",400:"#ff7043",500:"#ff5722",600:"#f4511e",700:"#e64a19",800:"#d84315",900:"#bf360c"},brown:{50:"#efebe9",100:"#d7ccc8",200:"#bcaaa4",300:"#a1887f",400:"#8d6e63",500:"#795548",600:"#6d4c41",700:"#5d4037",800:"#4e342e",900:"#3e2723"},gray:{50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121"},"blue-gray":{50:"#eceff1",100:"#cfd8dc",200:"#b0bec5",300:"#90a4ae",400:"#78909c",500:"#607d8b",600:"#546e7a",700:"#455a64",800:"#37474f",900:"#263238"}};function We(e){return Le.map(t=>`.${t}\\:${e}:${t}`)}function Ye(e,t){return Ne.map(([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`)}function He(e){return e.flatMap(([e,t])=>[`.${e} { ${t} }`,`${We(e).join(",")} { ${t} }`,...Ye(e,t)])}function Be(e,t){const r="@"===e[0],i="@"===t[0];return r&&!i?1:!r&&i?-1:e.localeCompare(t)}function Ve(e){return He(Object.entries(e).flatMap(([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100v${e.includes("height")?"h":"w"}`],[`${t}-full`,`${e}: 100%`],...Se.map(r=>[`${t}-${r}`,`${e}: ${r*Pe}rem`]),...Se.map(r=>[`-${t}-${r}`,`${e}: -${r*Pe}rem`]),...Se.map(r=>[`${t}-${r}px`,`${e}: ${r}px`]),...Se.map(r=>[`-${t}-${r}px`,`${e}: -${r}px`]),...Ce.map(r=>[`${t}-${r}\\%`,`${e}: ${r}%`]),...Ce.map(r=>[`-${t}-${r}\\%`,`${e}: -${r}%`])]))}function Ze(e){return He(Object.entries(e).flatMap(([e,t])=>[[`${t}-auto`,`${e}: auto`],[`${t}x-auto`,`${e}-left: auto; ${e}-right: auto;`],[`${t}y-auto`,`${e}-top: auto; ${e}-bottom: auto;`],[`${t}x-0`,`${e}-left: 0; ${e}-right: 0;`],[`${t}y-0`,`${e}-top: 0; ${e}-bottom: 0;`],...Se.map(r=>[`${t}x-${r}`,`${e}-left: ${r*Pe}rem; ${e}-right: ${r*Pe}rem;`]),...Se.map(r=>[`${t}y-${r}`,`${e}-top: ${r*Pe}rem; ${e}-bottom: ${r*Pe}rem;`]),...Se.map(r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`]),...Se.map(r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`]),...Ce.map(r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`]),...Ce.map(r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`])]))}function qe(){const e=(e,t)=>[[`text-${e}`,`color: ${t}`],[`fill-${e}`,`fill: ${t}`],[`bg-${e}`,`background-color: ${t}`],[`border-${e}`,`border-color: ${t}`]];return He([...e("white","#fff"),...e("black","#000"),...e("transparent","transparent"),...Object.entries(Ke).flatMap(([t,r])=>[...e(t,r[500]),...Object.entries(r).flatMap(([r,i])=>e(`${t}-${r}`,i))])])}let Qe=null;function Xe(){return null!==Qe||(Qe=[...Ge,...Object.entries(Fe).flatMap(([e,t])=>{const r=Object.entries(t).map(([e,t])=>`${e}: ${t}`).join("; ");return[`.${e} { ${r} }`,`${We(e).join(",")} { ${r} }`,...Ye(e,r)]}),...qe(),...He([["opacity-0","opacity: 0"],...Ce.map(e=>[`opacity-${e}`,"opacity: "+e/100])]),...He(Ce.map(e=>[`z-${e}`,`z-index: ${e}`])),...He(De.map(e=>[`duration-${e}`,`transition-duration: ${e}ms`])),...Ve(ze),...Ve(Me),...Ze(Me),...(e=Ue,He(Object.entries(e).flatMap(([e,t])=>[[`${t}t-0`,`${e}-top: 0`],[`${t}b-0`,`${e}-bottom: 0`],[`${t}l-0`,`${e}-left: 0`],[`${t}r-0`,`${e}-right: 0`],[`${t}t-auto`,`${e}-top: auto`],[`${t}b-auto`,`${e}-bottom: auto`],[`${t}l-auto`,`${e}-left: auto`],[`${t}r-auto`,`${e}-right: auto`],...["","-"].flatMap(r=>[...Se.map(i=>[`${r}${t}t-${i}`,`${e}-top: ${r}${i*Pe}rem`]),...Se.map(i=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${i*Pe}rem`]),...Se.map(i=>[`${r}${t}l-${i}`,`${e}-left: ${r}${i*Pe}rem`]),...Se.map(i=>[`${r}${t}r-${i}`,`${e}-right: ${r}${i*Pe}rem`]),...Se.map(i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`]),...Se.map(i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`]),...Se.map(i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`]),...Se.map(i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`]),...Ce.map(i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`]),...Ce.map(i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%`]),...Ce.map(i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`]),...Ce.map(i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`])])]))),...Ve(Ue),...Ze(Ue),...He([["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...Se.map(e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*Pe}rem`]),...Se.map(e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*Pe}rem`]),...Se.map(e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`]),...Se.map(e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`]),["gap-0","gap: 0"],...Se.map(e=>[`gap-${e}`,`gap: ${e*Pe}rem`]),...Se.map(e=>[`gap-${e}px`,`gap: ${e}px`]),...Se.map(e=>[`gap-x-${e}`,`column-gap: ${e*Pe}rem`]),...Se.map(e=>[`gap-y-${e}`,`row-gap: ${e*Pe}rem`]),...Se.map(e=>[`gap-x-${e}px`,`column-gap: ${e}px`]),...Se.map(e=>[`gap-y-${e}px`,`row-gap: ${e}px`])]),...Ve(je),...He([["border","border: 1px"],["border-x","border-inline-width: 1px"],["border-y","border-block-width: 1px"],...[0,...Te].map(e=>[`border-${e}`,`border-width: ${e}px`]),...[0,...Te].map(e=>[`border-x-${e}`,`border-inline-width: ${e}px;`]),...[0,...Te].map(e=>[`border-y-${e}`,`border-block-width: ${e}px;`]),...["top","bottom","left","right"].flatMap(e=>[[`border-${e.slice(0,1)}`,`border-${e}: 1px`],...[0,...Te].map(t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`])])]),...He([...Array.from({length:100},(e,t)=>[`text-${t}px`,`font-size: ${t}px`]),...Array.from({length:100},(e,t)=>[`text-${t*Pe}rem`,`font-size: ${t*Pe}rem`])])].sort(Be).join("\n")),Qe;var e}class Je extends Oe{impl="browser";dirpath=q(globalThis.location?.href??"http://localhost/");parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return(new DOMParser).parseFromString(e,"text/html");{const t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}const et=new Je;function tt(e){for(const t of e){const e=document.createElement("style");switch(t){case"basic":p(e,Ie());break;case"utils":e.textContent=Xe();break;default:console.error(`Unknown style name: "${t}"`);continue}globalThis.document.head.appendChild(e)}}function rt(){tt(["basic"])}function it(){tt(["utils"])}async function nt(e={}){const t=new Je;if(e.css&&e.css.length>0&&tt(e.css),e.debug&&t.debug(!0),e.state)for(const[r,i]of Object.entries(e.state))await t.set(r,i);if(e.target){const r=Array.isArray(e.target)?e.target:[e.target];for(const i of r){const r=globalThis.document.querySelector(i);r?await t.mount(r,{cache:e.cache}):console.error(`Target element not found: "${i}"`)}}return t}export{Oe as IRenderer,et as Mancha,Je as Renderer,Ie as basicCssRules,nt as initMancha,rt as injectBasicCss,tt as injectCss,it as injectUtilsCss,Xe as utilsCssRules};
@@ -1 +1 @@
1
- {"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C,MAAM,OAAO,QAA4C,SAAQ,SAAY;IAClE,IAAI,GAAG,SAAS,CAAC;IACP,OAAO,GAAW,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,IAAI,mBAAmB,CAAC,CAAC;IAC/F,SAAS,CACP,OAAe,EACf,SAAuB,EAAE,YAAY,EAAE,KAAK,EAAE;QAE9C,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,OAAO,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC/D,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;YACrC,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACxC,OAAO,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IACD,aAAa,CAAC,IAA6B;QACzC,OAAO,IAAI,aAAa,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;IACvF,CAAC;IACD,eAAe,CACb,KAAa,EACb,MAAoC;QAEpC,6EAA6E;QAC7E,OAAO,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;IACD,aAAa,CAAC,GAAW,EAAE,KAAuB;QAChD,OAAO,CAAC,KAAK,IAAI,QAAQ,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;IACD,WAAW,CAAC,IAAU,EAAE,OAAe;QACrC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;AAKrC;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,KAAgB;IACxC,KAAK,MAAM,SAAS,IAAI,KAAK,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC9C,QAAQ,SAAS,EAAE,CAAC;YAClB,KAAK,OAAO;gBACV,WAAW,CAAC,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;gBACnD,MAAM;YACR,KAAK,OAAO;gBACV,KAAK,CAAC,WAAW,GAAG,aAAa,EAAE,CAAC;gBACpC,MAAM;YACR;gBACE,OAAO,CAAC,KAAK,CAAC,wBAAwB,SAAS,GAAG,CAAC,CAAC;gBACpD,SAAS;QACb,CAAC;QACD,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACvB,CAAC;AAgBD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,UAA6B,EAAE;IAE/B,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAK,CAAC;IAEnC,2BAA2B;IAC3B,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1C,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,kCAAkC;IAClC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED,gEAAgE;IAChE,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzD,MAAM,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,iCAAiC;IACjC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAClF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAC1D,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,QAAQ,CAAC,KAAK,CAAC,OAAsC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;YACzF,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,8BAA8B,MAAM,GAAG,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"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"}