mancha 0.24.2 → 0.25.0

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.
package/README.md CHANGED
@@ -50,7 +50,7 @@ when you move to a bundler or render them on the server.
50
50
  | [htmx][hx] 2.0.10 | 14,996 B | ✔️ | ❌ | ❌ | ❌ |
51
51
  | [Svelte][sv] 5.56.9 | 15,106 B | ❌ | ✔️ | ✔️ | ❌ |
52
52
  | [Alpine.js][al] 3.16.1 | 15,400 B | ✔️ | ❌ | ❌ | ❌ |
53
- | **mancha 0.24.2** | **19,852 B** | ✔️ | ✔️ | ✔️ | ✔️ |
53
+ | **mancha 0.25.0** | **19,852 B** | ✔️ | ✔️ | ✔️ | ✔️ |
54
54
  | [React][re] 19.2.8 | 52,002 B | ❌ | ✔️ | ✔️ | ❌ |
55
55
  | [Vue][vu] 3.5.41 | 54,171 B | ✔️ | ✔️ | ✔️ | ❌ |
56
56
 
package/dist/browser.d.ts CHANGED
@@ -1,13 +1,7 @@
1
1
  import { SafeStyleSheet } from "safevalues";
2
2
 
3
- //#region src/css_custom.d.ts
4
-
5
- /** Scan a DOM tree and inject CSS for all custom values found. Defaults to the whole document. */
6
- declare function scanAndInject(root?: Element | Document | DocumentFragment): void;
7
- /** For testing: reset module state. */
8
- declare function _resetForTesting(): void;
9
- //#endregion
10
3
  //#region src/store.d.ts
4
+
11
5
  /**
12
6
  * Internal store properties that are always present. These are managed by the framework
13
7
  * and should not be set directly by users.
@@ -458,6 +452,10 @@ type PerformanceReport = {
458
452
  };
459
453
  };
460
454
  //#endregion
455
+ //#region src/css_custom.d.ts
456
+ /** Scan a DOM tree and inject CSS for all custom values found. Defaults to the whole document. */
457
+ declare function scanAndInject(root?: Element | Document | DocumentFragment): void;
458
+ //#endregion
461
459
  //#region src/css_gen_basic.d.ts
462
460
  declare function rules(): SafeStyleSheet;
463
461
  //#endregion
@@ -534,4 +532,4 @@ interface InitManchaOptions<T extends StoreState = StoreState> {
534
532
  */
535
533
  declare function initMancha<T extends StoreState = StoreState>(options?: InitManchaOptions<T>): Promise<Renderer<T>>;
536
534
  //#endregion
537
- export { CloakOptions, CssName, IRenderer, InitManchaOptions, Mancha, type ParserParams, type RenderParams, Renderer, type RendererPlugin, _resetForTesting as _resetCustomCssForTesting, rules as basicCssRules, initMancha, injectCss, rules$1 as minimalCssRules, scanAndInject, rules$2 as utilsCssRules };
535
+ export { CloakOptions, CssName, IRenderer, InitManchaOptions, Mancha, type ParserParams, type RenderParams, Renderer, type RendererPlugin, rules as basicCssRules, initMancha, injectCss, rules$1 as minimalCssRules, scanAndInject, rules$2 as utilsCssRules };
package/dist/browser.js CHANGED
@@ -1,21 +1,21 @@
1
- import{safeAnchorEl as e,safeAreaEl as t,safeElement as n,safeStyleEl as r}from"safevalues/dom";import{concatStyleSheets as i,safeAttrPrefix as a,safeStyleSheet as o}from"safevalues";const s={sm:640,md:768,lg:1024,xl:1280},c=Object.entries(s),l=.25,u=[...Array(15)].map((e,t)=>t+1),d=[16,20,24,28,32,36,40,48,56,64],f=[72,80,96,128,160,192,256,320,384,512],p=[...u,...d,...f,...Object.values(s)],m=Array.from({length:20},(e,t)=>(t+1)*5),h=[25,50,75,100,150,200,300,500,700,1e3],g={margin:`m`},_={padding:`p`},ee={...g,..._},te={width:`w`,height:`h`},ne={top:`top`,right:`right`,bottom:`bottom`,left:`left`},re={"min-width":`min-w`,"min-height":`min-h`,"max-width":`max-w`,"max-height":`max-h`},v=`transition-timing-function: ease-in-out; transition-duration: var(--transition-duration, 150ms)`,ie={"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`,grid:`display: grid`,"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`,"appearance-none":`appearance: none; -webkit-appearance: none; -moz-appearance: 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-2xs":`box-shadow: 0 1px rgb(0 0 0 / 0.05)`,"shadow-xs":`box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05)`,shadow:`box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)`,"shadow-sm":`box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)`,"shadow-md":`box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)`,"shadow-lg":`box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)`,"shadow-xl":`box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)`,"shadow-2xl":`box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25)`,"shadow-inner":`box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.05)`,"shadow-none":`box-shadow: 0 0 #0000`,ring:`box-shadow: var(--ring-inset, ) 0 0 0 3px rgb(59 130 246 / 0.5)`,"ring-0":`box-shadow: var(--ring-inset, ) 0 0 0 0px rgb(59 130 246 / 0.5)`,"ring-1":`box-shadow: var(--ring-inset, ) 0 0 0 1px rgb(59 130 246 / 0.5)`,"ring-2":`box-shadow: var(--ring-inset, ) 0 0 0 2px rgb(59 130 246 / 0.5)`,"ring-4":`box-shadow: var(--ring-inset, ) 0 0 0 4px rgb(59 130 246 / 0.5)`,"ring-8":`box-shadow: var(--ring-inset, ) 0 0 0 8px rgb(59 130 246 / 0.5)`,"ring-inset":`--ring-inset: inset`,outline:`outline-style: solid`,"outline-none":`outline: 2px solid transparent; outline-offset: 2px`,"outline-dashed":`outline-style: dashed`,"outline-dotted":`outline-style: dotted`,"outline-double":`outline-style: double`,"outline-0":`outline-width: 0px`,"outline-1":`outline-width: 1px`,"outline-2":`outline-width: 2px`,"outline-4":`outline-width: 4px`,"outline-8":`outline-width: 8px`,"outline-offset-0":`outline-offset: 0px`,"outline-offset-1":`outline-offset: 1px`,"outline-offset-2":`outline-offset: 2px`,"outline-offset-4":`outline-offset: 4px`,"outline-offset-8":`outline-offset: 8px`,"aspect-auto":`aspect-ratio: auto`,"aspect-square":`aspect-ratio: 1 / 1`,"aspect-video":`aspect-ratio: 16 / 9`,"backdrop-blur-none":`backdrop-filter: blur(0)`,"backdrop-blur-sm":`backdrop-filter: blur(4px)`,"backdrop-blur":`backdrop-filter: blur(8px)`,"backdrop-blur-md":`backdrop-filter: blur(12px)`,"backdrop-blur-lg":`backdrop-filter: blur(16px)`,"backdrop-blur-xl":`backdrop-filter: blur(24px)`,"backdrop-blur-2xl":`backdrop-filter: blur(40px)`,"backdrop-blur-3xl":`backdrop-filter: blur(64px)`,"transition-none":`transition: none`,transition:`transition-property: all; ${v}`,"transition-all":`transition-property: all; ${v}`,"transition-opacity":`transition-property: opacity; ${v}`,"transition-transform":`transition-property: transform; ${v}`,"transition-shadow":`transition-property: box-shadow; ${v}`,"transition-colors":`transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; ${v}`,"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-center":`background-position: center`,"bg-top":`background-position: top`,"bg-bottom":`background-position: bottom`,"bg-left":`background-position: left`,"bg-right":`background-position: right`,"bg-left-top":`background-position: left top`,"bg-left-bottom":`background-position: left bottom`,"bg-right-top":`background-position: right top`,"bg-right-bottom":`background-position: right bottom`,"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`},ae=[`@keyframes spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}`,`@keyframes ping{75%,100%{transform:scale(2);opacity:0}}`,`@keyframes pulse{0%,100%{opacity:1}50%{opacity:.5}}`],oe=`red pink purple deep-purple indigo blue light-blue cyan teal green light-green lime yellow amber orange deep-orange brown gray blue-gray`.split(` `),se=[50,100,200,300,400,500,600,700,800,900],y=Object.fromEntries(oe.map((e,t)=>[e,Object.fromEntries(se.map((e,n)=>{let r=(t*se.length+n)*6;return[e,`#${`ffebeeffcdd2ef9a9ae57373ef5350f44336e53935d32f2fc62828b71c1cfce4ecf8bbd0f48fb1f06292ec407ae91e63d81b60c2185bad1457880e4ff3e5f5e1bee7ce93d8ba68c8ab47bc9c27b08e24aa7b1fa26a1b9a4a148cede7f6d1c4e9b39ddb9575cd7e57c2673ab75e35b1512da84527a0311b92e8eaf6c5cae99fa8da7986cb5c6bc03f51b53949ab303f9f2835931a237ee3f2fdbbdefb90caf964b5f642a5f52196f31e88e51976d21565c00d47a1e1f5feb3e5fc81d4fa4fc3f729b6f603a9f4039be50288d10277bd01579be0f7fab2ebf280deea4dd0e126c6da00bcd400acc10097a700838f006064e0f2f1b2dfdb80cbc44db6ac26a69a00968800897b00796b00695c004d40e8f5e9c8e6c9a5d6a781c78466bb6a4caf5043a047388e3c2e7d321b5e20f1f8e9dcedc8c5e1a5aed5819ccc658bc34a7cb342689f38558b2f33691ef9fbe7f0f4c3e6ee9cdce775d4e157cddc39c0ca33afb42b9e9d24827717fffde7fff9c4fff59dfff176ffee58ffeb3bfdd835fbc02df9a825f57f17fff8e1ffecb3ffe082ffd54fffca28ffc107ffb300ffa000ff8f00ff6f00fff3e0ffe0b2ffcc80ffb74dffa726ff9800fb8c00f57c00ef6c00e65100fbe9e7ffccbcffab91ff8a65ff7043ff5722f4511ee64a19d84315bf360cefebe9d7ccc8bcaaa4a1887f8d6e637955486d4c415d40374e342e3e2723fafafaf5f5f5eeeeeee0e0e0bdbdbd9e9e9e757575616161424242212121eceff1cfd8dcb0bec590a4ae78909c607d8b546e7a455a6437474f263238`.slice(r,r+6)}`]}))]));function b(e){return e.map(([e,t])=>`.${e} { ${t} }`)}const ce=[``,`-`],x=[``],le=[[`top`,`t`],[`bottom`,`b`],[`left`,`l`],[`right`,`r`]];function S(e,t,n){let r=(r,i)=>[`${e}${t(r)}`,n(`${e}${i}`)];return[...p.map(e=>r(`${e}`,`${e*l}rem`)),...p.map(e=>r(`${e}px`,`${e}px`)),...m.map(e=>r(`${e}\\%`,`${e}%`))]}function C(e,t=ce){return b(Object.entries(e).flatMap(([e,n])=>[[`${n}-0`,`${e}: 0`],[`${n}-screen`,`${e}: 100v${e.includes(`height`)?`h`:`w`}`],[`${n}-full`,`${e}: 100%`],...t.flatMap(t=>S(t,e=>`${n}-${e}`,t=>`${e}: ${t}`)),...c.map(([t,r])=>[`${n}-${t}`,`${e}: ${r}px`])]))}function ue(e){return b(Object.entries(e).map(([e,t])=>[`${t}-auto`,`${e}: auto`]))}function de(e){return b(Object.entries(e).flatMap(([e,t])=>[[`${t}x-auto`,`${e}-left: auto; ${e}-right: auto;`],[`${t}y-auto`,`${e}-top: auto; ${e}-bottom: auto;`],...le.map(([n,r])=>[`${t}${r}-auto`,`${e}-${n}: auto`])]))}function fe(e){return b(Object.entries(e).flatMap(([e,t])=>[[`${t}x-0`,`${e}-left: 0; ${e}-right: 0;`],[`${t}y-0`,`${e}-top: 0; ${e}-bottom: 0;`],...S(``,e=>`${t}x-${e}`,t=>`${e}-left: ${t}; ${e}-right: ${t};`),...S(``,e=>`${t}y-${e}`,t=>`${e}-top: ${t}; ${e}-bottom: ${t};`)]))}function pe(e,t=ce){return b(Object.entries(e).flatMap(([e,n])=>[[`${n}t-0`,`${e}-top: 0`],[`${n}b-0`,`${e}-bottom: 0`],[`${n}l-0`,`${e}-left: 0`],[`${n}r-0`,`${e}-right: 0`],...t.flatMap(t=>le.flatMap(([r,i])=>S(t,e=>`${n}${i}-${e}`,t=>`${e}-${r}: ${t}`)))]))}function me(){return b([[`border`,`border-width: 1px`],[`border-x`,`border-inline-width: 1px`],[`border-y`,`border-block-width: 1px`],...[0,...u].map(e=>[`border-${e}`,`border-width: ${e}px`]),...[0,...u].map(e=>[`border-x-${e}`,`border-inline-width: ${e}px;`]),...[0,...u].map(e=>[`border-y-${e}`,`border-block-width: ${e}px;`]),...le.flatMap(([e,t])=>[[`border-${t}`,`border-${e}-width: 1px`],...[0,...u].map(n=>[`border-${t}-${n}`,`border-${e}-width: ${n}px`])])])}function he(){return b(m.map(e=>[`z-${e}`,`z-index: ${e}`]))}function ge(){return b(h.map(e=>[`duration-${e}`,`--transition-duration: ${e}ms; transition-duration: ${e}ms`]))}function _e(){return b([[`space-x-0 > *`,`margin-left: 0`],[`space-y-0 > *`,`margin-top: 0`],...p.map(e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*l}rem`]),...p.map(e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*l}rem`]),...p.map(e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`]),...p.map(e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`]),[`gap-0`,`gap: 0`],...p.map(e=>[`gap-${e}`,`gap: ${e*l}rem`]),...p.map(e=>[`gap-${e}px`,`gap: ${e}px`]),...p.map(e=>[`gap-x-${e}`,`column-gap: ${e*l}rem`]),...p.map(e=>[`gap-y-${e}`,`row-gap: ${e*l}rem`]),...p.map(e=>[`gap-x-${e}px`,`column-gap: ${e}px`]),...p.map(e=>[`gap-y-${e}px`,`row-gap: ${e}px`]),[`divide-x > :not(:last-child)`,`border-inline-end-width: 1px`],[`divide-y > :not(:last-child)`,`border-bottom-width: 1px`],[`divide-x-0 > :not(:last-child)`,`border-inline-end-width: 0px`],[`divide-y-0 > :not(:last-child)`,`border-bottom-width: 0px`],...[2,4,8].map(e=>[`divide-x-${e} > :not(:last-child)`,`border-inline-end-width: ${e}px`]),...[2,4,8].map(e=>[`divide-y-${e} > :not(:last-child)`,`border-bottom-width: ${e}px`]),[`divide-solid > :not(:last-child)`,`border-style: solid`],[`divide-dashed > :not(:last-child)`,`border-style: dashed`],[`divide-dotted > :not(:last-child)`,`border-style: dotted`],[`divide-none > :not(:last-child)`,`border-style: none`]])}function ve(){return b([...Array.from({length:100},(e,t)=>[`text-${t}px`,`font-size: ${t}px`]),...Array.from({length:100},(e,t)=>[`text-${String(t*l).replace(`.`,`\\.`)}rem`,`font-size: ${t*l}rem`])])}function ye(){return b([`column`,`row`].flatMap(e=>{let t=e.slice(0,3);return[...Array.from({length:12},(e,t)=>t+1).map(n=>[`grid-${t}s-${n}`,`grid-template-${e}s: repeat(${n}, minmax(0, 1fr))`]),[`grid-${t}s-none`,`grid-template-${e}s: none`],...Array.from({length:12},(e,t)=>t+1).map(n=>[`${t}-span-${n}`,`grid-${e}: span ${n} / span ${n}`]),[`${t}-span-full`,`grid-${e}: 1 / -1`],...Array.from({length:13},(e,t)=>t+1).map(n=>[`${t}-start-${n}`,`grid-${e}-start: ${n}`]),[`${t}-start-auto`,`grid-${e}-start: auto`],...Array.from({length:13},(e,t)=>t+1).map(n=>[`${t}-end-${n}`,`grid-${e}-end: ${n}`]),[`${t}-end-auto`,`grid-${e}-end: auto`]]}))}function be(){return Object.entries(ie).map(([e,t])=>`.${e} { ${t} }`)}function xe(e){let t=0,n=0,r=0;return e.length===4?(t=parseInt(e[1]+e[1],16),n=parseInt(e[2]+e[2],16),r=parseInt(e[3]+e[3],16)):e.length===7&&(t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16)),`${t} ${n} ${r}`}function Se(){let e=(e,t)=>[[`text-${e}`,`color: ${t}`],[`fill-${e}`,`fill: ${t}`],[`bg-${e}`,`background-color: ${t}`],[`border-${e}`,`border-color: ${t}`],[`divide-${e} > :not(:last-child)`,`border-color: ${t}`]];return b([...e(`white`,`#fff`),...e(`black`,`#000`),...e(`transparent`,`transparent`),...Object.entries(y).flatMap(([t,n])=>[...e(t,n[500]),...Object.entries(n).flatMap(([n,r])=>e(`${t}-${n}`,r))])])}function Ce(){return b([[`opacity-0`,`opacity: 0`],...m.map(e=>[`opacity-${e}`,`opacity: ${e/100}`])])}let w=null;function we(){return w===null&&(w=[...ae,...be(),...Se(),...Ce(),...he(),...ge(),...C(ne),...C(te,x),...ue(te),...C(g),...C(_,x),...ue(g),...de(g),...fe(ee),...pe(g),...pe(_,x),..._e(),...C(re,x),...me(),...ve(),...ye()].join(`
2
- `)),w}const Te={text:`color`,bg:`background-color`,border:`border-color`,fill:`fill`,divide:`border-color`},Ee=/^(text|bg|border|fill|divide)-([\w-]+)\/(\d+)$/,De={w:`width`,h:`height`,"min-w":`min-width`,"min-h":`min-height`,"max-w":`max-width`,"max-h":`max-height`,m:`margin`,mt:`margin-top`,mr:`margin-right`,mb:`margin-bottom`,ml:`margin-left`,mx:`margin-inline`,my:`margin-block`,p:`padding`,pt:`padding-top`,pr:`padding-right`,pb:`padding-bottom`,pl:`padding-left`,px:`padding-inline`,py:`padding-block`,top:`top`,right:`right`,bottom:`bottom`,left:`left`,gap:`gap`,"gap-x":`column-gap`,"gap-y":`row-gap`,text:`font-size`,z:`z-index`,bg:`background-color`,border:`border-color`},Oe=/^(-?)([\w-]+)-\[(.+)\]$/,ke=/^(hover|focus|disabled|sm|md|lg|xl|dark|landscape|portrait):(.+)$/,Ae=[`hover`,`focus`,`disabled`],je=[`landscape`,`portrait`],T=new Set;let E=null;function Me(e){if(typeof document>`u`)return null;let t=`.${Pe(e)}`;for(let e of document.styleSheets)try{for(let n of e.cssRules)if(n instanceof CSSStyleRule&&n.selectorText===t)return n.style.cssText}catch{}return null}function Ne(){return typeof document<`u`&&typeof CSSStyleSheet<`u`&&typeof document.createElement==`function`}function Pe(e){let t=globalThis.CSS;return typeof t?.escape==`function`?t.escape(e):e.replace(/[[\]#.:>+~()'"/%,!]/g,`\\$&`)}function Fe(){if(!Ne())return null;if(E&&!E.ownerNode?.isConnected&&(E=null,T.clear()),E)return E;let e=document.createElement(`style`);return e.setAttribute(`data-mancha`,`custom`),document.head.appendChild(e),e.sheet?(E=e.sheet,E):null}function Ie(e){let t=e.match(Oe);if(!t)return null;let[,n,r,i]=t,a=De[r];if(!a)return null;let o=i.replace(/_/g,` `);return{property:a,value:n?`-${o}`:o}}function Le(e){let t=e.match(Ee);if(!t)return null;let[,n,r,i]=t,a=Te[n];if(!a)return null;let o=Number.parseInt(i,10);if(o<0||o>100)return null;let s=null;if(r===`white`)s=`#fff`;else if(r===`black`)s=`#000`;else{let e=r.lastIndexOf(`-`);if(e>0){let t=r.substring(0,e),n=Number.parseInt(r.substring(e+1),10);s=y[t]?.[n]??null}s||=y[r]?.[500]??null}return s?{property:a,value:`rgb(${xe(s)} / ${o/100})`}:null}function Re(e,t){let n=t?`${t.name}:${e}`:e,r=Fe();if(!r)return!1;if(T.has(n))return!0;let i=Pe(n),a=Ie(e)??Le(e),o=a?`${a.property}: ${a.value};`:Me(e);if(!o)return!1;let c=e.startsWith(`divide-`)?` > :not(:last-child)`:``,l;l=t?t.type===`pseudo`?`.${i}${c}:${t.name} { ${o} }`:t.name===`dark`?`@media (prefers-color-scheme: dark) { .${i}${c} { ${o} } }`:je.includes(t.name)?`@media (orientation: ${t.name}) { .${i}${c} { ${o} } }`:`@media (min-width: ${s[t.name]}px) { .${i}${c} { ${o} } }`:`.${i}${c} { ${o} }`;try{let e=r.insertRule(l,r.cssRules.length),i=r.cssRules[e];return(t?.type===`media`?i.cssRules[0]:i)?.style?.length?(T.add(n),!0):(r.deleteRule(e),console.warn(`Injected CSS rule had no effect: ${l}`),!1)}catch(e){return console.warn(`Failed to inject CSS rule: ${l}`,e),!1}}function ze(e){return e.includes(`[`)||e.includes(`:`)||e.includes(`/`)}function Be(e){if(!(!e||!ze(e)))for(let t of e.trim().split(/\s+/)){let e=t.match(ke);if(e){let[,t,n]=e,r=Ae.includes(t),i=t in s,a=t===`dark`,o=je.includes(t);if(r||i||a||o){Re(n,{type:r?`pseudo`:`media`,name:t});continue}}ze(t)&&Re(t)}}function Ve(e){if(!Ne())return;let t=e??document;if(t instanceof Element){let e=t.getAttribute(`class`);e&&Be(e)}let n=t.querySelectorAll(`[class]`);for(let e of n){let t=e.getAttribute(`class`);t&&Be(t)}}function He(){return Ne()&&document.querySelector(`style[data-mancha="utils"]`)!==null}function Ue(e){if(!He())return;let t=e;typeof t.querySelectorAll==`function`&&Ve(t)}function We(e){!e||!ze(e)||He()&&Be(e)}function Ge(){T.clear(),E?.ownerNode&&E.ownerNode.remove(),E=null}function Ke(e){let t=e.childNodes;for(let e=0;e<t.length;e++){let n=t[e];n.prev=e>0?t[e-1]:null,n.next=e<t.length-1?t[e+1]:null}}const qe=[a`:`,a`style`,a`class`];function*D(e,t=new Set){let n=new Set,r=Array.from(e.childNodes).filter(e=>!t.has(e));for(yield e;r.length;){let e=r.shift();n.has(e)||(n.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter(e=>!t.has(e)).forEach(e=>{r.push(e)})}}function O(e,t){return e?.[t]!==void 0}function k(e,t){return typeof e?.[t]==`function`}function Je(e){return e.replace(/-./g,e=>e[1].toUpperCase())}function A(e,t){return e.attribs?e.attribs[t]??null:e.getAttribute?.(t)??null}function Ye(e,t){return e.attribs?t in e.attribs:e.hasAttribute?.(t)??!1}function j(e,t,n=``){return A(e,n+t)||A(e,`data-${t}`)||(e.dataset?.[Je(t)]??null)}function M(e,t,n){e.attribs?e.attribs[t]=n:e.setAttribute?.(t,n)}function N(e,t,r){e.attribs?e.attribs[t]=r:n.setPrefixedAttribute(qe,e,t,r)}function P(e,t,n){switch(t){case`disabled`:e.disabled=n;return;case`selected`:e.selected=n;return;case`checked`:e.checked=n;return;default:e[t]=n}}function F(e,t){e.attribs?delete e.attribs[t]:e.removeAttribute?.(t)}function Xe(e,t,n,r=``){Ye(e,`${r}${t}`)?M(e,`${r}${t}`,n):Ye(e,`data-${t}`)?M(e,`data-${t}`,n):M(e,`${r}${t}`,n)}function I(e,t,n=``){F(e,`${n}${t}`),F(e,`data-${t}`)}function Ze(e,t,n){if(e.attribs&&t.attribs)t.attribs[n]=e.attribs[n];else if(n.startsWith(`data-`)){let r=Je(n.slice(5));t.dataset&&e.dataset&&(t.dataset[r]=e.dataset[r])}else{let r=e?.getAttribute?.(n);N(t,n,r||``)}}function Qe(e){return O(e,`firstElementChild`)?e.firstElementChild:Array.from(e.children).find(e=>e.nodeType===1)}function L(e,...t){if(k(e,`replaceWith`)){e.replaceWith(...t);return}else{let n=e,r=n.parentNode;if(!r)return;let i=Array.from(r.childNodes).indexOf(n);n.parentNode=null,t.forEach(e=>{e.parentNode=r}),r.childNodes=[].concat(Array.from(r.childNodes).slice(0,i),t,Array.from(r.childNodes).slice(i+1)),Ke(r)}}function $e(e,...t){k(e,`replaceChildren`)?e.replaceChildren(...t):(e.childNodes=t,t.forEach(t=>{t.parentNode=e}),Ke(e))}function R(e,t){return k(t,`appendChild`)?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,Ke(e),t)}function z(e,t){return k(t,`removeChild`)?e.removeChild(t):($e(e,...Array.from(e.childNodes).filter(e=>e!==t)),t)}function B(e,t,n){return n?k(e,`insertBefore`)?e.insertBefore(t,n):(t.parentNode&&z(t.parentNode,t),L(n,t,n),t):R(e,t)}function V(e,t=0){return e?e.length<=t?e:`${e.slice(0,t-1)}…`:``}function H(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map(e=>H(e,t)).join(``):V(e.outerHTML||e.nodeValue||String(e),t)}function U(e){return e.includes(`/`)?e.split(`/`).slice(0,-1).join(`/`):``}function et(e){return!e.includes(`://`)&&!e.startsWith(`/`)&&!e.startsWith(`#`)&&!e.startsWith(`data:`)}var tt=class e{iterable;constructor(e){this.iterable=e}filter(t){return new e(e.filterGenerator(t,this.iterable))}map(t){return new e(e.mapGenerator(t,this.iterable))}find(e){for(let t of this.iterable)if(e(t))return t}array(){return Array.from(this.iterable)}*generator(){for(let e of this.iterable)yield e}static*filterGenerator(e,t){for(let n of t)e(n)&&(yield n)}static*mapGenerator(e,t){for(let n of t)yield e(n)}static equals(e,t){let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(i.value!==a.value)return!1;i=n.next(),a=r.next()}return i.done===a.done}};let W;(function(n){n.resolveIncludes=async function(e,t){let n=e,r=n.tagName?.toLowerCase();if(![`include`,`link`].includes(r)||r===`link`&&A(n,`rel`)!==`subresource`)return;this.log(`include directive found in:
3
- `,H(e,128)),this.log(`include params:`,t);let i=n.tagName.toLocaleLowerCase()===`link`?`href`:`src`,a=A(n,i);if(!a)throw Error(`"${i}" attribute missing from ${H(e,128)}.`);let o=[];r===`include`&&o.push(`src`),r===`link`&&o.push(`rel`,`href`);let s=t=>{let r=Qe(t);for(let e of Array.from(n.attributes))r&&!o.includes(e.name)&&Ze(n,r,e.name);L(e,...t.childNodes)},c={...t,rootDocument:!1,maxdepth:(t?.maxdepth??100)-1};if(c.maxdepth===0)throw Error(`Maximum recursion depth reached.`);if(a.includes(`://`)||a.startsWith(`//`))this.log(`Including remote file from absolute path:`,a),await this.preprocessRemote(a,c).then(s);else if(t?.dirpath?.includes(`://`)||t?.dirpath?.startsWith(`//`)){let e=a.startsWith(`/`)?a:`${t.dirpath}/${a}`;this.log(`Including remote file from relative path:`,e),await this.preprocessRemote(e,c).then(s)}else if(a.charAt(0)===`/`)this.log(`Including local file from absolute path:`,a),await this.preprocessLocal(a,c).then(s);else{let e=t?.dirpath&&t?.dirpath!==`.`?`${t?.dirpath}/${a}`:a;this.log(`Including local file from relative path:`,e),await this.preprocessLocal(e,c).then(s)}},n.rebaseRelativePaths=function(n,r){let i=n,a=i.tagName?.toLowerCase();if(!r?.dirpath)return;let o=A(i,`src`),s=A(i,`href`),c=j(i,`render`,`:`),l=o||s||c;if(!l||!et(l))return;let u=`${r.dirpath}/${l}`;this.log(`Rebasing relative path as:`,u),c?Xe(i,`render`,u,`:`):O(i,`attribs`)?N(i,o?`src`:`href`,u):a===`img`?i.src=u:a===`a`?e.setHref(i,u):a===`source`||a===`audio`||a===`video`||a===`track`||a===`input`?i.src=u:a===`area`?t.setHref(i,u):this.log(`Unable to rebase relative path for element:`,a)},n.registerCustomElements=function(e,t){let n=e,r=n.tagName?.toLowerCase(),i=(A(n,`is`)||A(n,`alt`))?.toLowerCase();if([`template`,`div`].includes(r)&&i){if(r===`div`&&A(n,`role`)!==`template`)return;if(!this._customElements.has(i)){this.log(`Registering custom element: ${i}\n`,H(n,128));let e=n.content||n,r=Array.from(D(e));for(let e=1;e<r.length;e++)W.rebaseRelativePaths.call(this,r[e],t);this._customElements.set(i,n),n?.parentNode&&z(n.parentNode,n)}}},n.resolveCustomElements=function(e,t){let n=e,r=n.tagName?.toLowerCase(),i=r;if(i===`div`&&(i=A(n,`role`)?.toLowerCase()||i),i&&this._customElements.has(i)){this.log(`Processing custom element: ${i}\n`,H(n,128));let t=this._customElements.get(i),a=(t.content||t).cloneNode(!0),o=Qe(a);if(o)for(let e of Array.from(n.attributes))(r!==`div`||e.name!==`role`)&&Ze(n,o,e.name);let s=new tt(D(a)).find(e=>e.tagName?.toLowerCase()===`slot`);s&&L(s,...n.childNodes),L(e,...a.childNodes)}},n.resolveTextNodeExpressions=function(e,t){let n=e.nodeValue||``;if(e.nodeType!==3||!n?.trim())return;this.log(`Processing node content value:
4
- `,V(n,128));let r=new RegExp(/{{ ([^}]+) }}/gm),i=Array.from(n.matchAll(r)).map(e=>e[1]);return this.effect(function(){let t=n;for(let n of i){let r=this.eval(n,{$elem:e});t=t.replace(`{{ ${n} }}`,r==null?``:String(r))}e.nodeValue=t},{directive:`text`,element:e.parentElement??void 0,expression:i.join(`, `)})},n.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=j(n,`data`,`:`);if(r){this.log(`:data attribute found in:
5
- `,H(e,128)),I(n,`data`,`:`);let i;O(e,`renderer`)?(i=e.renderer,this.log(`Reusing existing subrenderer for node:`,H(e,64))):(i=this.subrenderer(),P(e,`renderer`,i),this.log(`Created and attached new subrenderer for node:`,H(e,64)));let a=i.eval(r,{$elem:e});if(await Promise.all(Object.entries(a).map(([e,t])=>e.startsWith(`$$`)?(i._store.get(`$rootRenderer`)||i).set(e,t):i.set(e,t,!0))),i===this)return;for(let t of D(e,this._skipNodes))this._skipNodes.add(t);await i.mount(e,t)}},n.resolveClassAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=j(n,`class`,`:`);if(r){this.log(`:class attribute found in:
6
- `,H(e,128)),I(n,`class`,`:`);let t=A(n,`class`)||``;return this.effect(function(){let i=this.eval(r,{$elem:e}),a=(i?`${t} ${i}`:t).trim();N(n,`class`,a),We(a)},{directive:`class`,element:n,expression:r})}},n.resolveTextAttributes=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=j(n,`text`,`:`);if(r){this.log(`:text attribute found in:
7
- `,H(e,128)),I(n,`text`,`:`);let t=t=>this.textContent(e,t);return this.effect(function(){let n=this.eval(r,{$elem:e});t(n==null?``:String(n))},{directive:`:text`,element:n,expression:r})}},n.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=j(n,`html`,`:`);if(r){this.log(`:html attribute found in:
8
- `,H(e,128)),I(n,`html`,`:`);let i=null;return this.effect(function(){let a=this.eval(r,{$elem:e});return new Promise(e=>{(async()=>{i&&=(i.dispose(),null);let r=this.subrenderer();i=r;let o=await r.preprocessString(a,t);await r.renderNode(o),$e(n,o),Ue(n),r._store.set(`$rootNode`,n),e()})()})},{directive:`:html`,element:n,expression:r})}},n.resolveEventAttributes=function(e,t){if(this._skipNodes.has(e))return;let n=e;for(let t of Array.from(n.attributes||[]))if(t.name.startsWith(`:on:`)||t.name.startsWith(`data-on-`)){let r=``,i=[];if(t.name.startsWith(`:on:`)?[r,...i]=t.name.substring(4).split(`.`):t.name.startsWith(`data-on-`)&&([r,...i]=t.name.substring(8).split(`.`)),!r)throw Error(`Invalid event attribute: ${t.name}`);this.log(t.name,`attribute found in:
9
- `,H(e,128)),I(n,t.name);let a=r===`submit`&&n.tagName.toUpperCase()===`FORM`;e.addEventListener?.(r,n=>((i.includes(`prevent`)||a)&&n.preventDefault(),this.eval(t.value,{$elem:e,$event:n})))}},n.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=j(n,`for`,`:`)?.trim();if(r){this.log(`:for attribute found in:
10
- `,H(e,128)),I(n,`for`,`:`);let i=j(n,`key`,`:`);i&&I(n,`key`,`:`);for(let t of D(e,this._skipNodes))this._skipNodes.add(t);let a=e.parentNode;if(!a)return;this.cloakElement(n);let o=this.createElement(`template`,e.ownerDocument);B(a,o,e),z(a,e),`content`in o?R(o.content,e):R(o,e),this.log(`:for template:
11
- `,H(o,128));let s=r.split(` in `,2);if(s.length!==2)throw Error(`Invalid :for format: \`${r}\`. Expected "{key} in {expression}".`);let c=i?j(n,`data`,`:`):null,l=new Map,u=[],d=[],[f,p]=s;await this.effect(function(){let n=this.eval(p,{$elem:e});if(this.log(`:for list items:`,n),!Array.isArray(n)){console.error(`Expression did not yield a list: \`${p}\` => \`${n}\``);return}if(i){let r=new Set,s=new Map,u=[],d=o.nextSibling;for(let o=0;o<n.length;o++){let p=n[o],m=this.eval(i,{[f]:p,$index:o});r.has(m)&&console.warn(`:for duplicate key detected: ${m}. Using last item.`),r.add(m);let h,g,_=l.get(m);if(_){if(h=_.node,g=_.subrenderer,u.push(g.set(f,p,!0)),u.push(g.set(`$index`,o,!0)),c&&O(h,`renderer`)){let e=h.renderer,t=e.eval(c,{$elem:h});u.push(...Object.entries(t).map(([t,n])=>e.set(t,n,!0)))}h===d||h.nextSibling===d||B(a,h,d)}else{g=this.subrenderer(),g.set(f,p,!0),g.set(`$index`,o,!0);let n=e.cloneNode(!0);this.cloakElement(n),B(a,n,d),this._skipNodes.add(n),u.push(g.mount(n,t).then(()=>{this.uncloakElement(n)})),h=n,this.log(`Rendered list child:
1
+ import{safeAnchorEl as e,safeAreaEl as t,safeElement as n,safeStyleEl as r}from"safevalues/dom";import{concatStyleSheets as i,safeAttrPrefix as a,safeStyleSheet as o}from"safevalues";const s={sm:640,md:768,lg:1024,xl:1280},c=Object.entries(s),l=.25,u=[...Array(15)].map((e,t)=>t+1),d=[16,20,24,28,32,36,40,48,56,64],f=[72,80,96,128,160,192,256,320,384,512],p=[...u,...d,...f,...Object.values(s)],m=Array.from({length:20},(e,t)=>(t+1)*5),h=[25,50,75,100,150,200,300,500,700,1e3],g={margin:`m`},_={padding:`p`},ee={...g,..._},te={width:`w`,height:`h`},ne={top:`top`,right:`right`,bottom:`bottom`,left:`left`},re={"min-width":`min-w`,"min-height":`min-h`,"max-width":`max-w`,"max-height":`max-h`},v=`transition-timing-function: ease-in-out; transition-duration: var(--transition-duration, 150ms)`,ie={"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`,grid:`display: grid`,"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`,"appearance-none":`appearance: none; -webkit-appearance: none; -moz-appearance: 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-2xs":`box-shadow: 0 1px rgb(0 0 0 / 0.05)`,"shadow-xs":`box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05)`,shadow:`box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)`,"shadow-sm":`box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)`,"shadow-md":`box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)`,"shadow-lg":`box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)`,"shadow-xl":`box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)`,"shadow-2xl":`box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25)`,"shadow-inner":`box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.05)`,"shadow-none":`box-shadow: 0 0 #0000`,ring:`box-shadow: var(--ring-inset, ) 0 0 0 3px rgb(59 130 246 / 0.5)`,"ring-0":`box-shadow: var(--ring-inset, ) 0 0 0 0px rgb(59 130 246 / 0.5)`,"ring-1":`box-shadow: var(--ring-inset, ) 0 0 0 1px rgb(59 130 246 / 0.5)`,"ring-2":`box-shadow: var(--ring-inset, ) 0 0 0 2px rgb(59 130 246 / 0.5)`,"ring-4":`box-shadow: var(--ring-inset, ) 0 0 0 4px rgb(59 130 246 / 0.5)`,"ring-8":`box-shadow: var(--ring-inset, ) 0 0 0 8px rgb(59 130 246 / 0.5)`,"ring-inset":`--ring-inset: inset`,outline:`outline-style: solid`,"outline-none":`outline: 2px solid transparent; outline-offset: 2px`,"outline-dashed":`outline-style: dashed`,"outline-dotted":`outline-style: dotted`,"outline-double":`outline-style: double`,"outline-0":`outline-width: 0px`,"outline-1":`outline-width: 1px`,"outline-2":`outline-width: 2px`,"outline-4":`outline-width: 4px`,"outline-8":`outline-width: 8px`,"outline-offset-0":`outline-offset: 0px`,"outline-offset-1":`outline-offset: 1px`,"outline-offset-2":`outline-offset: 2px`,"outline-offset-4":`outline-offset: 4px`,"outline-offset-8":`outline-offset: 8px`,"aspect-auto":`aspect-ratio: auto`,"aspect-square":`aspect-ratio: 1 / 1`,"aspect-video":`aspect-ratio: 16 / 9`,"backdrop-blur-none":`backdrop-filter: blur(0)`,"backdrop-blur-sm":`backdrop-filter: blur(4px)`,"backdrop-blur":`backdrop-filter: blur(8px)`,"backdrop-blur-md":`backdrop-filter: blur(12px)`,"backdrop-blur-lg":`backdrop-filter: blur(16px)`,"backdrop-blur-xl":`backdrop-filter: blur(24px)`,"backdrop-blur-2xl":`backdrop-filter: blur(40px)`,"backdrop-blur-3xl":`backdrop-filter: blur(64px)`,"transition-none":`transition: none`,transition:`transition-property: all; ${v}`,"transition-all":`transition-property: all; ${v}`,"transition-opacity":`transition-property: opacity; ${v}`,"transition-transform":`transition-property: transform; ${v}`,"transition-shadow":`transition-property: box-shadow; ${v}`,"transition-colors":`transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; ${v}`,"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-center":`background-position: center`,"bg-top":`background-position: top`,"bg-bottom":`background-position: bottom`,"bg-left":`background-position: left`,"bg-right":`background-position: right`,"bg-left-top":`background-position: left top`,"bg-left-bottom":`background-position: left bottom`,"bg-right-top":`background-position: right top`,"bg-right-bottom":`background-position: right bottom`,"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`},ae=[`@keyframes spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}`,`@keyframes ping{75%,100%{transform:scale(2);opacity:0}}`,`@keyframes pulse{0%,100%{opacity:1}50%{opacity:.5}}`],oe=`red pink purple deep-purple indigo blue light-blue cyan teal green light-green lime yellow amber orange deep-orange brown gray blue-gray`.split(` `),se=[50,100,200,300,400,500,600,700,800,900],ce=Object.fromEntries(oe.map((e,t)=>[e,Object.fromEntries(se.map((e,n)=>{let r=(t*se.length+n)*6;return[e,`#${`ffebeeffcdd2ef9a9ae57373ef5350f44336e53935d32f2fc62828b71c1cfce4ecf8bbd0f48fb1f06292ec407ae91e63d81b60c2185bad1457880e4ff3e5f5e1bee7ce93d8ba68c8ab47bc9c27b08e24aa7b1fa26a1b9a4a148cede7f6d1c4e9b39ddb9575cd7e57c2673ab75e35b1512da84527a0311b92e8eaf6c5cae99fa8da7986cb5c6bc03f51b53949ab303f9f2835931a237ee3f2fdbbdefb90caf964b5f642a5f52196f31e88e51976d21565c00d47a1e1f5feb3e5fc81d4fa4fc3f729b6f603a9f4039be50288d10277bd01579be0f7fab2ebf280deea4dd0e126c6da00bcd400acc10097a700838f006064e0f2f1b2dfdb80cbc44db6ac26a69a00968800897b00796b00695c004d40e8f5e9c8e6c9a5d6a781c78466bb6a4caf5043a047388e3c2e7d321b5e20f1f8e9dcedc8c5e1a5aed5819ccc658bc34a7cb342689f38558b2f33691ef9fbe7f0f4c3e6ee9cdce775d4e157cddc39c0ca33afb42b9e9d24827717fffde7fff9c4fff59dfff176ffee58ffeb3bfdd835fbc02df9a825f57f17fff8e1ffecb3ffe082ffd54fffca28ffc107ffb300ffa000ff8f00ff6f00fff3e0ffe0b2ffcc80ffb74dffa726ff9800fb8c00f57c00ef6c00e65100fbe9e7ffccbcffab91ff8a65ff7043ff5722f4511ee64a19d84315bf360cefebe9d7ccc8bcaaa4a1887f8d6e637955486d4c415d40374e342e3e2723fafafaf5f5f5eeeeeee0e0e0bdbdbd9e9e9e757575616161424242212121eceff1cfd8dcb0bec590a4ae78909c607d8b546e7a455a6437474f263238`.slice(r,r+6)}`]}))]));function y(e){return e.map(([e,t])=>`.${e} { ${t} }`)}const le=[``,`-`],b=[``],ue=[[`top`,`t`],[`bottom`,`b`],[`left`,`l`],[`right`,`r`]];function x(e,t,n){let r=(r,i)=>[`${e}${t(r)}`,n(`${e}${i}`)];return[...p.map(e=>r(`${e}`,`${e*l}rem`)),...p.map(e=>r(`${e}px`,`${e}px`)),...m.map(e=>r(`${e}\\%`,`${e}%`))]}function S(e,t=le){return y(Object.entries(e).flatMap(([e,n])=>[[`${n}-0`,`${e}: 0`],[`${n}-screen`,`${e}: 100v${e.includes(`height`)?`h`:`w`}`],[`${n}-full`,`${e}: 100%`],...t.flatMap(t=>x(t,e=>`${n}-${e}`,t=>`${e}: ${t}`)),...c.map(([t,r])=>[`${n}-${t}`,`${e}: ${r}px`])]))}function de(e){return y(Object.entries(e).map(([e,t])=>[`${t}-auto`,`${e}: auto`]))}function fe(e){return y(Object.entries(e).flatMap(([e,t])=>[[`${t}x-auto`,`${e}-left: auto; ${e}-right: auto;`],[`${t}y-auto`,`${e}-top: auto; ${e}-bottom: auto;`],...ue.map(([n,r])=>[`${t}${r}-auto`,`${e}-${n}: auto`])]))}function pe(e){return y(Object.entries(e).flatMap(([e,t])=>[[`${t}x-0`,`${e}-left: 0; ${e}-right: 0;`],[`${t}y-0`,`${e}-top: 0; ${e}-bottom: 0;`],...x(``,e=>`${t}x-${e}`,t=>`${e}-left: ${t}; ${e}-right: ${t};`),...x(``,e=>`${t}y-${e}`,t=>`${e}-top: ${t}; ${e}-bottom: ${t};`)]))}function me(e,t=le){return y(Object.entries(e).flatMap(([e,n])=>[[`${n}t-0`,`${e}-top: 0`],[`${n}b-0`,`${e}-bottom: 0`],[`${n}l-0`,`${e}-left: 0`],[`${n}r-0`,`${e}-right: 0`],...t.flatMap(t=>ue.flatMap(([r,i])=>x(t,e=>`${n}${i}-${e}`,t=>`${e}-${r}: ${t}`)))]))}function he(){return y([[`border`,`border-width: 1px`],[`border-x`,`border-inline-width: 1px`],[`border-y`,`border-block-width: 1px`],...[0,...u].map(e=>[`border-${e}`,`border-width: ${e}px`]),...[0,...u].map(e=>[`border-x-${e}`,`border-inline-width: ${e}px;`]),...[0,...u].map(e=>[`border-y-${e}`,`border-block-width: ${e}px;`]),...ue.flatMap(([e,t])=>[[`border-${t}`,`border-${e}-width: 1px`],...[0,...u].map(n=>[`border-${t}-${n}`,`border-${e}-width: ${n}px`])])])}function ge(){return y(m.map(e=>[`z-${e}`,`z-index: ${e}`]))}function _e(){return y(h.map(e=>[`duration-${e}`,`--transition-duration: ${e}ms; transition-duration: ${e}ms`]))}function ve(){return y([[`space-x-0 > *`,`margin-left: 0`],[`space-y-0 > *`,`margin-top: 0`],...p.map(e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*l}rem`]),...p.map(e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*l}rem`]),...p.map(e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`]),...p.map(e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`]),[`gap-0`,`gap: 0`],...p.map(e=>[`gap-${e}`,`gap: ${e*l}rem`]),...p.map(e=>[`gap-${e}px`,`gap: ${e}px`]),...p.map(e=>[`gap-x-${e}`,`column-gap: ${e*l}rem`]),...p.map(e=>[`gap-y-${e}`,`row-gap: ${e*l}rem`]),...p.map(e=>[`gap-x-${e}px`,`column-gap: ${e}px`]),...p.map(e=>[`gap-y-${e}px`,`row-gap: ${e}px`]),[`divide-x > :not(:last-child)`,`border-inline-end-width: 1px`],[`divide-y > :not(:last-child)`,`border-bottom-width: 1px`],[`divide-x-0 > :not(:last-child)`,`border-inline-end-width: 0px`],[`divide-y-0 > :not(:last-child)`,`border-bottom-width: 0px`],...[2,4,8].map(e=>[`divide-x-${e} > :not(:last-child)`,`border-inline-end-width: ${e}px`]),...[2,4,8].map(e=>[`divide-y-${e} > :not(:last-child)`,`border-bottom-width: ${e}px`]),[`divide-solid > :not(:last-child)`,`border-style: solid`],[`divide-dashed > :not(:last-child)`,`border-style: dashed`],[`divide-dotted > :not(:last-child)`,`border-style: dotted`],[`divide-none > :not(:last-child)`,`border-style: none`]])}function ye(){return y([...Array.from({length:100},(e,t)=>[`text-${t}px`,`font-size: ${t}px`]),...Array.from({length:100},(e,t)=>[`text-${String(t*l).replace(`.`,`\\.`)}rem`,`font-size: ${t*l}rem`])])}function be(){return y([`column`,`row`].flatMap(e=>{let t=e.slice(0,3);return[...Array.from({length:12},(e,t)=>t+1).map(n=>[`grid-${t}s-${n}`,`grid-template-${e}s: repeat(${n}, minmax(0, 1fr))`]),[`grid-${t}s-none`,`grid-template-${e}s: none`],...Array.from({length:12},(e,t)=>t+1).map(n=>[`${t}-span-${n}`,`grid-${e}: span ${n} / span ${n}`]),[`${t}-span-full`,`grid-${e}: 1 / -1`],...Array.from({length:13},(e,t)=>t+1).map(n=>[`${t}-start-${n}`,`grid-${e}-start: ${n}`]),[`${t}-start-auto`,`grid-${e}-start: auto`],...Array.from({length:13},(e,t)=>t+1).map(n=>[`${t}-end-${n}`,`grid-${e}-end: ${n}`]),[`${t}-end-auto`,`grid-${e}-end: auto`]]}))}function xe(){return Object.entries(ie).map(([e,t])=>`.${e} { ${t} }`)}function Se(e){let t=0,n=0,r=0;return e.length===4?(t=parseInt(e[1]+e[1],16),n=parseInt(e[2]+e[2],16),r=parseInt(e[3]+e[3],16)):e.length===7&&(t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16)),`${t} ${n} ${r}`}function Ce(){let e=(e,t)=>[[`text-${e}`,`color: ${t}`],[`fill-${e}`,`fill: ${t}`],[`bg-${e}`,`background-color: ${t}`],[`border-${e}`,`border-color: ${t}`],[`divide-${e} > :not(:last-child)`,`border-color: ${t}`]];return y([...e(`white`,`#fff`),...e(`black`,`#000`),...e(`transparent`,`transparent`),...Object.entries(ce).flatMap(([t,n])=>[...e(t,n[500]),...Object.entries(n).flatMap(([n,r])=>e(`${t}-${n}`,r))])])}function we(){return y([[`opacity-0`,`opacity: 0`],...m.map(e=>[`opacity-${e}`,`opacity: ${e/100}`])])}let Te=null;function Ee(){return Te===null&&(Te=[...ae,...xe(),...Ce(),...we(),...ge(),..._e(),...S(ne),...S(te,b),...de(te),...S(g),...S(_,b),...de(g),...fe(g),...pe(ee),...me(g),...me(_,b),...ve(),...S(re,b),...he(),...ye(),...be()].join(`
2
+ `)),Te}const De={text:`color`,bg:`background-color`,border:`border-color`,fill:`fill`,divide:`border-color`},Oe=/^(text|bg|border|fill|divide)-([\w-]+)\/(\d+)$/,ke={w:`width`,h:`height`,"min-w":`min-width`,"min-h":`min-height`,"max-w":`max-width`,"max-h":`max-height`,m:`margin`,mt:`margin-top`,mr:`margin-right`,mb:`margin-bottom`,ml:`margin-left`,mx:`margin-inline`,my:`margin-block`,p:`padding`,pt:`padding-top`,pr:`padding-right`,pb:`padding-bottom`,pl:`padding-left`,px:`padding-inline`,py:`padding-block`,top:`top`,right:`right`,bottom:`bottom`,left:`left`,gap:`gap`,"gap-x":`column-gap`,"gap-y":`row-gap`,text:`font-size`,z:`z-index`,bg:`background-color`,border:`border-color`},Ae=/^(-?)([\w-]+)-\[(.+)\]$/,je=/^(hover|focus|disabled|sm|md|lg|xl|dark|landscape|portrait):(.+)$/,Me=[`hover`,`focus`,`disabled`],Ne=[`landscape`,`portrait`],C=new Set;let w=null;function Pe(e){if(typeof document>`u`)return null;let t=`.${Fe(e)}`;for(let e of document.styleSheets)try{for(let n of e.cssRules)if(n instanceof CSSStyleRule&&n.selectorText===t)return n.style.cssText}catch{}return null}function T(){return typeof document<`u`&&typeof CSSStyleSheet<`u`&&typeof document.createElement==`function`}function Fe(e){let t=globalThis.CSS;return typeof t?.escape==`function`?t.escape(e):e.replace(/[[\]#.:>+~()'"/%,!]/g,`\\$&`)}function Ie(){if(!T())return null;if(w&&!w.ownerNode?.isConnected&&(w=null,C.clear()),w)return w;let e=document.createElement(`style`);return e.setAttribute(`data-mancha`,`custom`),document.head.appendChild(e),e.sheet?(w=e.sheet,w):null}function Le(e){let t=e.match(Ae);if(!t)return null;let[,n,r,i]=t,a=ke[r];if(!a)return null;let o=i.replace(/_/g,` `);return{property:a,value:n?`-${o}`:o}}function Re(e){let t=e.match(Oe);if(!t)return null;let[,n,r,i]=t,a=De[n];if(!a)return null;let o=Number.parseInt(i,10);if(o<0||o>100)return null;let s=null;if(r===`white`)s=`#fff`;else if(r===`black`)s=`#000`;else{let e=r.lastIndexOf(`-`);if(e>0){let t=r.substring(0,e),n=Number.parseInt(r.substring(e+1),10);s=ce[t]?.[n]??null}s||=ce[r]?.[500]??null}return s?{property:a,value:`rgb(${Se(s)} / ${o/100})`}:null}function ze(e,t){let n=t?`${t.name}:${e}`:e,r=Ie();if(!r)return!1;if(C.has(n))return!0;let i=Fe(n),a=Le(e)??Re(e),o=a?`${a.property}: ${a.value};`:Pe(e);if(!o)return!1;let c=e.startsWith(`divide-`)?` > :not(:last-child)`:``,l;l=t?t.type===`pseudo`?`.${i}${c}:${t.name} { ${o} }`:t.name===`dark`?`@media (prefers-color-scheme: dark) { .${i}${c} { ${o} } }`:Ne.includes(t.name)?`@media (orientation: ${t.name}) { .${i}${c} { ${o} } }`:`@media (min-width: ${s[t.name]}px) { .${i}${c} { ${o} } }`:`.${i}${c} { ${o} }`;try{let e=r.insertRule(l,r.cssRules.length),i=r.cssRules[e];return(t?.type===`media`?i.cssRules[0]:i)?.style?.length?(C.add(n),!0):(r.deleteRule(e),console.warn(`Injected CSS rule had no effect: ${l}`),!1)}catch(e){return console.warn(`Failed to inject CSS rule: ${l}`,e),!1}}function E(e){return e.includes(`[`)||e.includes(`:`)||e.includes(`/`)}function D(e){if(!(!e||!E(e)))for(let t of e.trim().split(/\s+/)){let e=t.match(je);if(e){let[,t,n]=e,r=Me.includes(t),i=t in s,a=t===`dark`,o=Ne.includes(t);if(r||i||a||o){ze(n,{type:r?`pseudo`:`media`,name:t});continue}}E(t)&&ze(t)}}function Be(e){if(!T())return;let t=e??document;if(t instanceof Element){let e=t.getAttribute(`class`);e&&D(e)}let n=t.querySelectorAll(`[class]`);for(let e of n){let t=e.getAttribute(`class`);t&&D(t)}}function Ve(){return T()&&document.querySelector(`style[data-mancha="utils"]`)!==null}function He(e){if(!Ve())return;let t=e;typeof t.querySelectorAll==`function`&&Be(t)}function Ue(e){!e||!E(e)||Ve()&&D(e)}function We(e){let t=e.childNodes;for(let e=0;e<t.length;e++){let n=t[e];n.prev=e>0?t[e-1]:null,n.next=e<t.length-1?t[e+1]:null}}const Ge=[a`:`,a`style`,a`class`];function*O(e,t=new Set){let n=new Set,r=Array.from(e.childNodes).filter(e=>!t.has(e));for(yield e;r.length;){let e=r.shift();n.has(e)||(n.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter(e=>!t.has(e)).forEach(e=>{r.push(e)})}}function k(e,t){return e?.[t]!==void 0}function A(e,t){return typeof e?.[t]==`function`}function Ke(e){return e.replace(/-./g,e=>e[1].toUpperCase())}function j(e,t){return e.attribs?e.attribs[t]??null:e.getAttribute?.(t)??null}function qe(e,t){return e.attribs?t in e.attribs:e.hasAttribute?.(t)??!1}function M(e,t,n=``){return j(e,n+t)||j(e,`data-${t}`)||(e.dataset?.[Ke(t)]??null)}function N(e,t,n){e.attribs?e.attribs[t]=n:e.setAttribute?.(t,n)}function P(e,t,r){e.attribs?e.attribs[t]=r:n.setPrefixedAttribute(Ge,e,t,r)}function F(e,t,n){switch(t){case`disabled`:e.disabled=n;return;case`selected`:e.selected=n;return;case`checked`:e.checked=n;return;default:e[t]=n}}function I(e,t){e.attribs?delete e.attribs[t]:e.removeAttribute?.(t)}function Je(e,t,n,r=``){qe(e,`${r}${t}`)?N(e,`${r}${t}`,n):qe(e,`data-${t}`)?N(e,`data-${t}`,n):N(e,`${r}${t}`,n)}function L(e,t,n=``){I(e,`${n}${t}`),I(e,`data-${t}`)}function Ye(e,t,n){if(e.attribs&&t.attribs)t.attribs[n]=e.attribs[n];else if(n.startsWith(`data-`)){let r=Ke(n.slice(5));t.dataset&&e.dataset&&(t.dataset[r]=e.dataset[r])}else{let r=e?.getAttribute?.(n);P(t,n,r||``)}}function Xe(e){return k(e,`firstElementChild`)?e.firstElementChild:Array.from(e.children).find(e=>e.nodeType===1)}function R(e,...t){if(A(e,`replaceWith`)){e.replaceWith(...t);return}else{let n=e,r=n.parentNode;if(!r)return;let i=Array.from(r.childNodes).indexOf(n);n.parentNode=null,t.forEach(e=>{e.parentNode=r}),r.childNodes=[].concat(Array.from(r.childNodes).slice(0,i),t,Array.from(r.childNodes).slice(i+1)),We(r)}}function Ze(e,...t){A(e,`replaceChildren`)?e.replaceChildren(...t):(e.childNodes=t,t.forEach(t=>{t.parentNode=e}),We(e))}function Qe(e,t){return A(t,`appendChild`)?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,We(e),t)}function z(e,t){return A(t,`removeChild`)?e.removeChild(t):(Ze(e,...Array.from(e.childNodes).filter(e=>e!==t)),t)}function B(e,t,n){return n?A(e,`insertBefore`)?e.insertBefore(t,n):(t.parentNode&&z(t.parentNode,t),R(n,t,n),t):Qe(e,t)}function V(e,t=0){return e?e.length<=t?e:`${e.slice(0,t-1)}…`:``}function H(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map(e=>H(e,t)).join(``):V(e.outerHTML||e.nodeValue||String(e),t)}function $e(e){return e.includes(`/`)?e.split(`/`).slice(0,-1).join(`/`):``}function et(e){return!e.includes(`://`)&&!e.startsWith(`/`)&&!e.startsWith(`#`)&&!e.startsWith(`data:`)}var tt=class e{iterable;constructor(e){this.iterable=e}filter(t){return new e(e.filterGenerator(t,this.iterable))}map(t){return new e(e.mapGenerator(t,this.iterable))}find(e){for(let t of this.iterable)if(e(t))return t}array(){return Array.from(this.iterable)}*generator(){for(let e of this.iterable)yield e}static*filterGenerator(e,t){for(let n of t)e(n)&&(yield n)}static*mapGenerator(e,t){for(let n of t)yield e(n)}static equals(e,t){let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(i.value!==a.value)return!1;i=n.next(),a=r.next()}return i.done===a.done}};let U;(function(n){n.resolveIncludes=async function(e,t){let n=e,r=n.tagName?.toLowerCase();if(![`include`,`link`].includes(r)||r===`link`&&j(n,`rel`)!==`subresource`)return;this.log(`include directive found in:
3
+ `,H(e,128)),this.log(`include params:`,t);let i=n.tagName.toLocaleLowerCase()===`link`?`href`:`src`,a=j(n,i);if(!a)throw Error(`"${i}" attribute missing from ${H(e,128)}.`);let o=[];r===`include`&&o.push(`src`),r===`link`&&o.push(`rel`,`href`);let s=t=>{let r=Xe(t);for(let e of Array.from(n.attributes))r&&!o.includes(e.name)&&Ye(n,r,e.name);R(e,...t.childNodes)},c={...t,rootDocument:!1,maxdepth:(t?.maxdepth??100)-1};if(c.maxdepth===0)throw Error(`Maximum recursion depth reached.`);if(a.includes(`://`)||a.startsWith(`//`))this.log(`Including remote file from absolute path:`,a),await this.preprocessRemote(a,c).then(s);else if(t?.dirpath?.includes(`://`)||t?.dirpath?.startsWith(`//`)){let e=a.startsWith(`/`)?a:`${t.dirpath}/${a}`;this.log(`Including remote file from relative path:`,e),await this.preprocessRemote(e,c).then(s)}else if(a.charAt(0)===`/`)this.log(`Including local file from absolute path:`,a),await this.preprocessLocal(a,c).then(s);else{let e=t?.dirpath&&t?.dirpath!==`.`?`${t?.dirpath}/${a}`:a;this.log(`Including local file from relative path:`,e),await this.preprocessLocal(e,c).then(s)}},n.rebaseRelativePaths=function(n,r){let i=n,a=i.tagName?.toLowerCase();if(!r?.dirpath)return;let o=j(i,`src`),s=j(i,`href`),c=M(i,`render`,`:`),l=o||s||c;if(!l||!et(l))return;let u=`${r.dirpath}/${l}`;this.log(`Rebasing relative path as:`,u),c?Je(i,`render`,u,`:`):k(i,`attribs`)?P(i,o?`src`:`href`,u):a===`img`?i.src=u:a===`a`?e.setHref(i,u):a===`source`||a===`audio`||a===`video`||a===`track`||a===`input`?i.src=u:a===`area`?t.setHref(i,u):this.log(`Unable to rebase relative path for element:`,a)},n.registerCustomElements=function(e,t){let n=e,r=n.tagName?.toLowerCase(),i=(j(n,`is`)||j(n,`alt`))?.toLowerCase();if([`template`,`div`].includes(r)&&i){if(r===`div`&&j(n,`role`)!==`template`)return;if(!this._customElements.has(i)){this.log(`Registering custom element: ${i}\n`,H(n,128));let e=n.content||n,r=Array.from(O(e));for(let e=1;e<r.length;e++)U.rebaseRelativePaths.call(this,r[e],t);this._customElements.set(i,n),n?.parentNode&&z(n.parentNode,n)}}},n.resolveCustomElements=function(e,t){let n=e,r=n.tagName?.toLowerCase(),i=r;if(i===`div`&&(i=j(n,`role`)?.toLowerCase()||i),i&&this._customElements.has(i)){this.log(`Processing custom element: ${i}\n`,H(n,128));let t=this._customElements.get(i),a=(t.content||t).cloneNode(!0),o=Xe(a);if(o)for(let e of Array.from(n.attributes))(r!==`div`||e.name!==`role`)&&Ye(n,o,e.name);let s=new tt(O(a)).find(e=>e.tagName?.toLowerCase()===`slot`);s&&R(s,...n.childNodes),R(e,...a.childNodes)}},n.resolveTextNodeExpressions=function(e,t){let n=e.nodeValue||``;if(e.nodeType!==3||!n?.trim())return;this.log(`Processing node content value:
4
+ `,V(n,128));let r=new RegExp(/{{ ([^}]+) }}/gm),i=Array.from(n.matchAll(r)).map(e=>e[1]);return this.effect(function(){let t=n;for(let n of i){let r=this.eval(n,{$elem:e});t=t.replace(`{{ ${n} }}`,r==null?``:String(r))}e.nodeValue=t},{directive:`text`,element:e.parentElement??void 0,expression:i.join(`, `)})},n.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=M(n,`data`,`:`);if(r){this.log(`:data attribute found in:
5
+ `,H(e,128)),L(n,`data`,`:`);let i;k(e,`renderer`)?(i=e.renderer,this.log(`Reusing existing subrenderer for node:`,H(e,64))):(i=this.subrenderer(),F(e,`renderer`,i),this.log(`Created and attached new subrenderer for node:`,H(e,64)));let a=i.eval(r,{$elem:e});if(await Promise.all(Object.entries(a).map(([e,t])=>e.startsWith(`$$`)?(i._store.get(`$rootRenderer`)||i).set(e,t):i.set(e,t,!0))),i===this)return;for(let t of O(e,this._skipNodes))this._skipNodes.add(t);await i.mount(e,t)}},n.resolveClassAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=M(n,`class`,`:`);if(r){this.log(`:class attribute found in:
6
+ `,H(e,128)),L(n,`class`,`:`);let t=j(n,`class`)||``;return this.effect(function(){let i=this.eval(r,{$elem:e}),a=(i?`${t} ${i}`:t).trim();P(n,`class`,a),Ue(a)},{directive:`class`,element:n,expression:r})}},n.resolveTextAttributes=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=M(n,`text`,`:`);if(r){this.log(`:text attribute found in:
7
+ `,H(e,128)),L(n,`text`,`:`);let t=t=>this.textContent(e,t);return this.effect(function(){let n=this.eval(r,{$elem:e});t(n==null?``:String(n))},{directive:`:text`,element:n,expression:r})}},n.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=M(n,`html`,`:`);if(r){this.log(`:html attribute found in:
8
+ `,H(e,128)),L(n,`html`,`:`);let i=null;return this.effect(function(){let a=this.eval(r,{$elem:e});return new Promise(e=>{(async()=>{i&&=(i.dispose(),null);let r=this.subrenderer();i=r;let o=await r.preprocessString(a,t);await r.renderNode(o),Ze(n,o),He(n),r._store.set(`$rootNode`,n),e()})()})},{directive:`:html`,element:n,expression:r})}},n.resolveEventAttributes=function(e,t){if(this._skipNodes.has(e))return;let n=e;for(let t of Array.from(n.attributes||[]))if(t.name.startsWith(`:on:`)||t.name.startsWith(`data-on-`)){let r=``,i=[];if(t.name.startsWith(`:on:`)?[r,...i]=t.name.substring(4).split(`.`):t.name.startsWith(`data-on-`)&&([r,...i]=t.name.substring(8).split(`.`)),!r)throw Error(`Invalid event attribute: ${t.name}`);this.log(t.name,`attribute found in:
9
+ `,H(e,128)),L(n,t.name);let a=r===`submit`&&n.tagName.toUpperCase()===`FORM`;e.addEventListener?.(r,n=>((i.includes(`prevent`)||a)&&n.preventDefault(),this.eval(t.value,{$elem:e,$event:n})))}},n.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=M(n,`for`,`:`)?.trim();if(r){this.log(`:for attribute found in:
10
+ `,H(e,128)),L(n,`for`,`:`);let i=M(n,`key`,`:`);i&&L(n,`key`,`:`);for(let t of O(e,this._skipNodes))this._skipNodes.add(t);let a=e.parentNode;if(!a)return;this.cloakElement(n);let o=this.createElement(`template`,e.ownerDocument);B(a,o,e),z(a,e),`content`in o?Qe(o.content,e):Qe(o,e),this.log(`:for template:
11
+ `,H(o,128));let s=r.split(` in `,2);if(s.length!==2)throw Error(`Invalid :for format: \`${r}\`. Expected "{key} in {expression}".`);let c=i?M(n,`data`,`:`):null,l=new Map,u=[],d=[],[f,p]=s;await this.effect(function(){let n=this.eval(p,{$elem:e});if(this.log(`:for list items:`,n),!Array.isArray(n)){console.error(`Expression did not yield a list: \`${p}\` => \`${n}\``);return}if(i){let r=new Set,s=new Map,u=[],d=o.nextSibling;for(let o=0;o<n.length;o++){let p=n[o],m=this.eval(i,{[f]:p,$index:o});r.has(m)&&console.warn(`:for duplicate key detected: ${m}. Using last item.`),r.add(m);let h,g,_=l.get(m);if(_){if(h=_.node,g=_.subrenderer,u.push(g.set(f,p,!0)),u.push(g.set(`$index`,o,!0)),c&&k(h,`renderer`)){let e=h.renderer,t=e.eval(c,{$elem:h});u.push(...Object.entries(t).map(([t,n])=>e.set(t,n,!0)))}h===d||h.nextSibling===d||B(a,h,d)}else{g=this.subrenderer(),g.set(f,p,!0),g.set(`$index`,o,!0);let n=e.cloneNode(!0);this.cloakElement(n),B(a,n,d),this._skipNodes.add(n),u.push(g.mount(n,t).then(()=>{this.uncloakElement(n)})),h=n,this.log(`Rendered list child:
12
12
  `,H(n,128))}s.set(m,{node:h,subrenderer:g}),d=h.nextSibling}for(let[e,{node:t,subrenderer:n}]of l)r.has(e)||(n.dispose(),t.parentNode&&z(t.parentNode,t),this._skipNodes.delete(t));l.clear();for(let[e,t]of s)l.set(e,t);return Promise.all(u).then(()=>{})}else{d.splice(0,d.length).forEach(e=>{e.dispose()}),u.splice(0,u.length).forEach(e=>{e.parentNode&&z(e.parentNode,e),this._skipNodes.delete(e)});let r=o.nextSibling,i=[];for(let o=0;o<n.length;o++){let s=n[o],c=this.subrenderer();c.set(f,s,!0),c.set(`$index`,o,!0);let l=e.cloneNode(!0);this.cloakElement(l),B(a,l,r),u.push(l),d.push(c),this._skipNodes.add(l),i.push(c.mount(l,t).then(()=>{this.uncloakElement(l)})),this.log(`Rendered list child:
13
- `,H(l,128))}return Promise.all(i).then(()=>{})}},{directive:`:for`,element:n,expression:r})}},n.resolveBindAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=j(n,`bind`,`:`);if(r){this.log(`:bind attribute found in:
14
- `,H(e,128));let t=A(n,`:bind:on`)?.split(`,`)||n.dataset?.bindOn?.split(`,`)||[`change`,`input`];I(n,`bind`,`:`),F(n,`:bind:on`),F(n,`data-bind-on`);let i=A(n,`type`)===`checkbox`?`checked`:`value`;!r.includes(`.`)&&!this.has(r)&&this.set(r,``);let a=this;this.effect(function(){let t=this.eval(r,{$elem:e});i===`checked`?n.checked=!!t:(n.value=t,n.value!==t&&t!=null&&a._pendingValueRetries.push(()=>{n.value=t}))},{directive:`:bind`,element:n,expression:r});let o=`${r} = $elem.${i}`;for(let n of t)e.addEventListener(n,()=>this.eval(o,{$elem:e}))}},n.resolveIfAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=j(n,`if`,`:`);if(r){this.log(`:if attribute found in:
15
- `,H(e,128)),I(n,`if`,`:`);let t=this.createComment(` :if placeholder `,e.ownerDocument);this.effect(function(){this.eval(r,{$elem:e})?!n.parentNode&&t.parentNode&&(L(t,n),Ue(n)):n.parentNode&&L(n,t)},{directive:`:if`,element:n,expression:r})}},n.resolveShowAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=j(n,`show`,`:`);if(r){this.log(`:show attribute found in:
16
- `,H(e,128)),I(n,`show`,`:`);let t=n.style?.display===`none`?``:n.style?.display??A(n,`style`)?.split(`;`)?.find(e=>e.split(`:`)[0]===`display`)?.split(`:`)?.at(1)?.trim();this.effect(function(){let i=this.eval(r,{$elem:e});n.style?n.style.display=i?t:`none`:N(n,`style`,`display: ${i?t:`none`};`)},{directive:`:show`,element:n,expression:r})}},n.resolveCustomAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e;for(let t of Array.from(n.attributes||[])){let r=`:attr:`,i=`data-attr-`;if(t.name.startsWith(r)||t.name.startsWith(i)){this.log(t.name,`attribute found in:
17
- `,H(e,128)),F(n,t.name);let a=(t.name.split(r,2).at(-1)||``).split(i,2).at(-1)??``;this.effect(function(){let r=this.eval(t.value,{$elem:e});M(n,a,r),a===`class`&&We(String(r??``))},{directive:`:attr:${a}`,element:n,expression:t.value})}}},n.resolveCustomProperty=function(e,t){if(this._skipNodes.has(e))return;let n=e;for(let t of Array.from(n.attributes||[])){let r=`:prop:`,i=`data-prop-`;if(t.name.startsWith(r)||t.name.startsWith(i)){this.log(t.name,`property found in:
18
- `,H(e,128)),F(n,t.name);let a=Je((t.name.split(r,2).at(-1)||``).split(i,2).at(-1)??``);this.effect(function(){P(n,a,this.eval(t.value,{$elem:e}))},{directive:`:prop:${a}`,element:n,expression:t.value})}}},n.stripTypes=(e,t)=>{let n=e;A(n,`:types`)&&F(n,`:types`),A(n,`data-types`)&&F(n,`data-types`)},n.resolveRenderAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=j(n,`render`,`:`);if(!r)return;this.log(`:render attribute found: ${r}`),I(n,`render`,`:`);let i;O(e,`renderer`)?(i=e.renderer,this.log(`Reusing existing subrenderer for :render:`,H(e,64))):(i=this.subrenderer(),P(n,`renderer`,i)),await i.mount(e,t);for(let t of D(e,this._skipNodes))this._skipNodes.add(t);try{let e=await import(r);typeof e.default==`function`?await e.default(n,i):e.default!==void 0&&console.warn(`Module ${r} default export is not a function`)}catch(e){console.error(`Failed to execute render init from ${r}:`,e)}}})(W||={});function nt(){return new URL(globalThis.window?.location?.href||`http://localhost/`)}function rt(e){return e.substring(2)}function it(e){return`\$\$${e}`}function at(e){return e.keys().filter(e=>e.startsWith(`$$`))}async function ot(e,t){for(let[n,r]of t.searchParams.entries()){let t=it(n);e.get(t)!==r&&await e.set(t,r)}}function st(e,t,n){let r=rt(t),i=!1;if(!n)e.searchParams.has(r)&&(e.searchParams.delete(r),i=!0);else{let t=String(n);e.searchParams.get(r)!==t&&(e.searchParams.set(r,t),i=!0)}return i}function ct(e,t){let n=!1;for(let r of at(t))st(e,r,t.get(r))&&(n=!0);n&&globalThis.window?.history?.replaceState({},``,e.toString())}function lt(e){return async()=>{let t=nt(),n=new Set;for(let[r,i]of t.searchParams.entries()){let t=it(r);n.add(t),e.get(t)!==i&&e.set(t,i)}let r=at(e);for(let t of r)n.has(t)||e.del(t)}}async function ut(e){let t=nt();await ot(e,t),ct(t,e),e.addKeyHandler(/^\$\$/,(e,t)=>{let n=nt();st(n,e,t)&&globalThis.window?.history?.replaceState({},``,n.toString())}),globalThis.window?.addEventListener(`popstate`,lt(e))}
13
+ `,H(l,128))}return Promise.all(i).then(()=>{})}},{directive:`:for`,element:n,expression:r})}},n.resolveBindAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=M(n,`bind`,`:`);if(r){this.log(`:bind attribute found in:
14
+ `,H(e,128));let t=j(n,`:bind:on`)?.split(`,`)||n.dataset?.bindOn?.split(`,`)||[`change`,`input`];L(n,`bind`,`:`),I(n,`:bind:on`),I(n,`data-bind-on`);let i=j(n,`type`)===`checkbox`?`checked`:`value`;!r.includes(`.`)&&!this.has(r)&&this.set(r,``);let a=this;this.effect(function(){let t=this.eval(r,{$elem:e});i===`checked`?n.checked=!!t:(n.value=t,n.value!==t&&t!=null&&a._pendingValueRetries.push(()=>{n.value=t}))},{directive:`:bind`,element:n,expression:r});let o=`${r} = $elem.${i}`;for(let n of t)e.addEventListener(n,()=>this.eval(o,{$elem:e}))}},n.resolveIfAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=M(n,`if`,`:`);if(r){this.log(`:if attribute found in:
15
+ `,H(e,128)),L(n,`if`,`:`);let t=this.createComment(` :if placeholder `,e.ownerDocument);this.effect(function(){this.eval(r,{$elem:e})?!n.parentNode&&t.parentNode&&(R(t,n),He(n)):n.parentNode&&R(n,t)},{directive:`:if`,element:n,expression:r})}},n.resolveShowAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e,r=M(n,`show`,`:`);if(r){this.log(`:show attribute found in:
16
+ `,H(e,128)),L(n,`show`,`:`);let t=n.style?.display===`none`?``:n.style?.display??j(n,`style`)?.split(`;`)?.find(e=>e.split(`:`)[0]===`display`)?.split(`:`)?.at(1)?.trim();this.effect(function(){let i=this.eval(r,{$elem:e});n.style?n.style.display=i?t:`none`:P(n,`style`,`display: ${i?t:`none`};`)},{directive:`:show`,element:n,expression:r})}},n.resolveCustomAttribute=function(e,t){if(this._skipNodes.has(e))return;let n=e;for(let t of Array.from(n.attributes||[])){let r=`:attr:`,i=`data-attr-`;if(t.name.startsWith(r)||t.name.startsWith(i)){this.log(t.name,`attribute found in:
17
+ `,H(e,128)),I(n,t.name);let a=(t.name.split(r,2).at(-1)||``).split(i,2).at(-1)??``;this.effect(function(){let r=this.eval(t.value,{$elem:e});N(n,a,r),a===`class`&&Ue(String(r??``))},{directive:`:attr:${a}`,element:n,expression:t.value})}}},n.resolveCustomProperty=function(e,t){if(this._skipNodes.has(e))return;let n=e;for(let t of Array.from(n.attributes||[])){let r=`:prop:`,i=`data-prop-`;if(t.name.startsWith(r)||t.name.startsWith(i)){this.log(t.name,`property found in:
18
+ `,H(e,128)),I(n,t.name);let a=Ke((t.name.split(r,2).at(-1)||``).split(i,2).at(-1)??``);this.effect(function(){F(n,a,this.eval(t.value,{$elem:e}))},{directive:`:prop:${a}`,element:n,expression:t.value})}}},n.stripTypes=(e,t)=>{let n=e;j(n,`:types`)&&I(n,`:types`),j(n,`data-types`)&&I(n,`data-types`)},n.resolveRenderAttribute=async function(e,t){if(this._skipNodes.has(e))return;let n=e,r=M(n,`render`,`:`);if(!r)return;this.log(`:render attribute found: ${r}`),L(n,`render`,`:`);let i;k(e,`renderer`)?(i=e.renderer,this.log(`Reusing existing subrenderer for :render:`,H(e,64))):(i=this.subrenderer(),F(n,`renderer`,i)),await i.mount(e,t);for(let t of O(e,this._skipNodes))this._skipNodes.add(t);try{let e=await import(r);typeof e.default==`function`?await e.default(n,i):e.default!==void 0&&console.warn(`Module ${r} default export is not a function`)}catch(e){console.error(`Failed to execute render init from ${r}:`,e)}}})(U||={});function nt(){return new URL(globalThis.window?.location?.href||`http://localhost/`)}function rt(e){return e.substring(2)}function it(e){return`\$\$${e}`}function at(e){return e.keys().filter(e=>e.startsWith(`$$`))}async function ot(e,t){for(let[n,r]of t.searchParams.entries()){let t=it(n);e.get(t)!==r&&await e.set(t,r)}}function st(e,t,n){let r=rt(t),i=!1;if(!n)e.searchParams.has(r)&&(e.searchParams.delete(r),i=!0);else{let t=String(n);e.searchParams.get(r)!==t&&(e.searchParams.set(r,t),i=!0)}return i}function ct(e,t){let n=!1;for(let r of at(t))st(e,r,t.get(r))&&(n=!0);n&&globalThis.window?.history?.replaceState({},``,e.toString())}function lt(e){return async()=>{let t=nt(),n=new Set;for(let[r,i]of t.searchParams.entries()){let t=it(r);n.add(t),e.get(t)!==i&&e.set(t,i)}let r=at(e);for(let t of r)n.has(t)||e.del(t)}}async function ut(e){let t=nt();await ot(e,t),ct(t,e),e.addKeyHandler(/^\$\$/,(e,t)=>{let n=nt();st(n,e,t)&&globalThis.window?.history?.replaceState({},``,n.toString())}),globalThis.window?.addEventListener(`popstate`,lt(e))}
19
19
  /*
20
20
  * @license
21
21
  * Portions Copyright (c) 2013, the Dart project authors.
@@ -25,8 +25,8 @@ const dt=new Set([`this`,`typeof`]),ft=new Set([`in`]),pt=new Set([`+`,`-`,`!`,`
25
25
  * @license
26
26
  * Portions Copyright (c) 2013, the Dart project authors.
27
27
  */
28
- const yt=new Set([`==`,`!=`,`<=`,`>=`,`||`,`&&`,`??`,`?.`]),bt=new Set([`===`,`!==`]);let G=function(e){return 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`,e}({});const K=(e,t,n=0)=>({kind:e,value:t,precedence:n}),xt=e=>e===9||e===10||e===13||e===32,St=e=>{if(e===95||e===36)return!0;let t=e&-33;return 65<=t&&t<=90},Ct=e=>St(e)||q(e),wt=e=>dt.has(e),Tt=e=>e===34||e===39,q=e=>48<=e&&e<=57,Et=e=>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,Dt=e=>e===40||e===41||e===91||e===93||e===123||e===125,Ot=e=>e.replace(/\\(.)/g,(e,t)=>{switch(t){case`n`:return`
29
- `;case`r`:return`\r`;case`t`:return` `;case`b`:return`\b`;case`f`:return`\f`;default:return t}});var kt=class{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;xt(this._next??-1);)this._advance(!0);if(Tt(this._next??-1))return this._tokenizeString();if(St(this._next??-1))return this._tokenizeIdentOrKeyword();if(q(this._next??-1))return this._tokenizeNumber();if(this._next===46)return this._tokenizeDot();if(this._next===44)return this._tokenizeComma();if(this._next===58)return this._tokenizeColon();if(Et(this._next??-1))return this._tokenizeOperator();if(Dt(this._next??-1))return this._tokenizeGrouper();if(this._advance(),this._next!==void 0)throw Error(`Expected end of input, got ${this._next}`)}_advance(e){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),e===!0&&(this._tokenStart=this._index)):this._next=void 0}_getValue(e=0){let t=this._input.substring(this._tokenStart,this._index+e);return e===0&&this._clearValue(),t}_clearValue(){this._tokenStart=this._index}_tokenizeString(){let e=this._next;for(this._advance(!0);this._next!==e;){if(this._next===void 0||this._next===92&&(this._advance(),this._next===void 0))throw Error(`unterminated string`);this._advance()}let t=K(G.STRING,Ot(this._getValue()));return this._advance(),t}_tokenizeIdentOrKeyword(){do this._advance();while(Ct(this._next??-1));let e=this._getValue();return K(wt(e)?G.KEYWORD:ft.has(e)?G.OPERATOR:G.IDENTIFIER,e,ht[e]??0)}_tokenizeNumber(){do this._advance();while(q(this._next??-1));return this._next===46?this._tokenizeDot():K(G.INTEGER,this._getValue())}_tokenizeDot(){if(this._advance(),q(this._next??-1))return this._tokenizeFraction();if(this._next===46){if(this._advance(),this._next===46)return this._advance(),this._clearValue(),K(G.SPREAD,`...`);throw Error(`Unexpected token ..`)}return this._clearValue(),K(G.DOT,`.`,13)}_tokenizeComma(){return this._advance(!0),K(G.COMMA,`,`)}_tokenizeColon(){return this._advance(!0),K(G.COLON,`:`)}_tokenizeFraction(){do this._advance();while(q(this._next??-1));return K(G.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(bt.has(e))this._advance(),this._advance();else{if(e=this._getValue(1),e===`=>`)return this._advance(),K(G.ARROW,e);yt.has(e)&&this._advance()}return e=this._getValue(),e===`?.`?K(G.OPTIONAL_DOT,e,13):K(G.OPERATOR,e,ht[e])}_tokenizeGrouper(){let e=String.fromCharCode(this._next??0),t=K(G.GROUPER,e,ht[e]);return this._advance(!0),t}};const At=(e,t)=>new jt(e,t).parse();var jt=class{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new kt(e),this._ast=t}parse(){this._advance();let e=this._parseExpression();if(this._token)throw Error(`Unexpected token: ${this._token.value}`);return e}_advance(e,t){if(!this._matches(e,t))throw Error(`Expected kind ${e} (${t}), was ${this._token?.kind} (${this._token?.value})`);let n=this._tokenizer.nextToken();this._token=n,this._kind=n?.kind,this._value=n?.value}_matches(e,t){return!(e&&this._kind!==e||t&&this._value!==t)}_parseExpression(){if(!this._token)return this._ast.empty();let e=this._parseUnary();return e===void 0?void 0:this._parsePrecedence(e,0)}_parsePrecedence(e,t){if(e===void 0)throw Error(`Expected left to be defined.`);for(;this._token;)if(this._matches(G.GROUPER,`(`)){let t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(G.GROUPER,`[`)){let t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(G.DOT)||this._matches(G.OPTIONAL_DOT)){let t=this._kind===G.OPTIONAL_DOT;if(this._advance(),t&&this._matches(G.GROUPER,`[`)){let t=this._parseIndex();e=this._ast.index(e,t,!0)}else if(t&&this._matches(G.GROUPER,`(`)){let t=this._parseArguments();e=this._ast.invoke(e,void 0,t,!0)}else{let n=this._parseUnary();e=this._makeInvokeOrGetter(e,n,t)}}else if(this._matches(G.KEYWORD))break;else if(this._matches(G.OPERATOR)&&this._token.precedence>=t)e=this._value===`?`?this._parseTernary(e):this._parseBinary(e,this._token);else break;return e}_makeInvokeOrGetter(e,t,n){if(t===void 0)throw Error(`expected identifier`);if(t.type===`ID`)return this._ast.getter(e,t.value,n);if(t.type===`Invoke`&&t.receiver.type===`ID`){let r=t.receiver;return this._ast.invoke(e,r.value,t.arguments,n)}else throw Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(!mt.has(t.value))throw Error(`unknown operator: ${t.value}`);this._advance();let n=this._parseUnary();for(;(this._kind===G.OPERATOR||this._kind===G.DOT||this._kind===G.GROUPER)&&this._token&&(this._token.precedence??0)>t.precedence;)n=this._parsePrecedence(n,this._token?.precedence??0);if(n===void 0)throw Error(`Expected expression after ${t.value}`);return this._ast.binary(e,t.value,n)}_parseUnary(){if(this._matches(G.KEYWORD,`typeof`)){this._advance();let e=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(`typeof`,e)}if(this._matches(G.OPERATOR)){let e=this._value;if(this._advance(),e===`+`||e===`-`){if(this._matches(G.INTEGER))return this._parseInteger(e);if(this._matches(G.DECIMAL))return this._parseDecimal(e)}if(!e||!pt.has(e))throw Error(`unexpected token: ${e}`);let t=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(e,t)}return this._parsePrimary()}_parseTernary(e){this._advance(G.OPERATOR,`?`);let t=this._parseExpression();this._advance(G.COLON);let n=this._parseExpression();return this._ast.ternary(e,t,n)}_parsePrimary(){switch(this._kind){case G.KEYWORD:{let e=this._value??``;if(e===`this`)return this._advance(),this._ast.id(e);throw dt.has(e)?Error(`unexpected keyword: ${e}`):Error(`unrecognized keyword: ${e}`)}case G.IDENTIFIER:return this._parseInvokeOrIdentifier();case G.STRING:return this._parseString();case G.INTEGER:return this._parseInteger();case G.DECIMAL:return this._parseDecimal();case G.GROUPER:return this._value===`(`?this._parseParenOrFunction():this._value===`{`?this._parseMap():this._value===`[`?this._parseList():void 0;case G.COLON:throw Error(`unexpected token ":"`);default:return}}_parseList(){let e=[];do{if(this._advance(),this._matches(G.GROUPER,`]`))break;if(this._matches(G.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else e.push(this._parseExpression())}while(this._matches(G.COMMA));return this._advance(G.GROUPER,`]`),this._ast.list(e)}_parseMap(){let e=[];do{if(this._advance(),this._matches(G.GROUPER,`}`))break;if(this._matches(G.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadProperty(t))}else{let t=this._value??``;if((this._matches(G.STRING)||this._matches(G.IDENTIFIER))&&this._advance(),this._matches(G.COLON)){this._advance(G.COLON);let n=this._parseExpression();n&&e.push(this._ast.property(t,n))}else e.push(this._ast.property(t,this._ast.id(t)))}}while(this._matches(G.COMMA));return this._advance(G.GROUPER,`}`),this._ast.map(e)}_parseInvokeOrIdentifier(){let e=this._value;if(e===`true`)return this._advance(),this._ast.literal(!0);if(e===`false`)return this._advance(),this._ast.literal(!1);if(e===`null`)return this._advance(),this._ast.literal(null);if(e===`undefined`)return this._advance(),this._ast.literal(void 0);let t=this._parseIdentifier(),n=this._parseArguments();return n?this._ast.invoke(t,void 0,n):t}_parseIdentifier(){if(!this._matches(G.IDENTIFIER))throw Error(`expected identifier: ${this._value}`);let e=this._value;return this._advance(),this._ast.id(e??``)}_parseArguments(){if(!this._matches(G.GROUPER,`(`))return;let e=[];do{if(this._advance(),this._matches(G.GROUPER,`)`))break;if(this._matches(G.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else{let t=this._parseExpression();e.push(t)}}while(this._matches(G.COMMA));return this._advance(G.GROUPER,`)`),e}_parseIndex(){this._advance();let e=this._parseExpression();return this._advance(G.GROUPER,`]`),e}_parseParenOrFunction(){let e=this._parseArguments();if(this._matches(G.ARROW)){this._advance();let t=this._parseExpression(),n=e?.map(e=>e.value)??[];return this._ast.arrowFunction(n,t)}else return this._ast.paren(e?.[0])}_parseString(){let e=this._ast.literal(this._value??``);return this._advance(),e}_parseInteger(e=``){let t=this._ast.literal(parseInt(`${e}${this._value}`,10));return this._advance(),t}_parseDecimal(e=``){let t=this._ast.literal(parseFloat(`${e}${this._value}`));return this._advance(),t}};const J=Symbol(`__computed__`);function Mt(e){return typeof e==`object`&&!!e&&J in e&&e[J]===!0}const Nt=new vt,Pt=`__is_proxy__`;function Ft(e){return e instanceof Ht||e[Pt]===!0}const Y=new WeakMap;function X(e){return typeof e==`object`&&!!e}function Z(e){return X(e)?Y.get(e):void 0}function It(e){return e.subscribers.size===0&&e.holders.size===0}function Lt(e,t){if(!t.has(e)){t.add(e);for(let n of Array.from(e.holders))It(n)?e.holders.delete(n):Lt(n,t);for(let t of Array.from(e.subscribers))t()}}function Rt(e){Lt(e,new Set)}function zt(e,t){Z(e)?.subscribers.add(t)}function Bt(e,t){Z(e)?.subscribers.delete(t)}function Q(e,t){let n=e?._store;if(n?.has(t))return n.get(t);if(n?.has(`$parent`))return Q(n.get(`$parent`),t)}function $(e,t){let n=e?._store;return n?.has(t)?e:n?.has(`$parent`)?$(n.get(`$parent`),t):null}function Vt(e,t,n){let r=$(e,t);r?r._store.set(t,n):e._store.set(t,n)}var Ht=class e{evalkeys=[`$elem`,`$event`];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_store=new Map;_lock=Promise.resolve();_pending=new Map;_executing=new Set;_dirty=new Set;_children=new Set;_mutationCallbacks=new Map;_disposed=!1;_computedDepth=0;constructor(e){for(let[t,n]of Object.entries(e||{}))this.set(t,n)}wrapObject(e){if(e==null||Ft(e)||Object.isFrozen(e)||Object.isSealed(e))return e;let t=Object.getPrototypeOf(e);if(!(t===Object.prototype||t===null)&&!Array.isArray(e))return e;let n=Y.get(e)??{subscribers:new Set,holders:new Set};Y.set(e,n);let r=()=>Rt(n),i=new Proxy(e,{deleteProperty:(e,t)=>typeof t==`string`&&t in e?(delete e[t],r(),!0):!1,set:(e,t,i,a)=>{if(Reflect.get(e,t,a)===i)return!0;X(i)&&(i=this.wrapObject(i),Z(i)?.holders.add(n));let o=Reflect.set(e,t,i,a);return r(),o},get:(e,t,r)=>{if(t===Pt)return!0;let i=Reflect.get(e,t,r);if(!X(i))return i;let a=this.wrapObject(i);return a!==i&&Reflect.set(e,t,a,r),Z(a)?.holders.add(n),a}});return Y.set(i,n),i}watch(e,t){let n=$(this,e);if(!n)throw Error(`Cannot watch key "${e}" as it does not exist in the store.`);n.observers.has(e)||n.observers.set(e,new Set),Array.from(n.observers.get(e)||[]).some(e=>e.observer===t)||n.observers.get(e)?.add({observer:t,store:this})}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e)?.add(t)}tagObserversForComputed(e,t){for(let n of this.observers.values())for(let r of n)r.observer===e&&r.store===this&&(r.computedKey=t);let n=this._store.get(`$parent`);for(;n;){for(let r of n.observers.values())for(let n of r)n.observer===e&&n.store===this&&(n.computedKey=t);n=n._store.get(`$parent`)}}markDependentComputedsDirty(e){let t=$(this,e)?.observers.get(e);if(t){for(let e of t)if(e.computedKey){let t=e.store._store.get(e.computedKey);Mt(t)&&!t.dirty&&(t.dirty=!0,e.store.markDependentComputedsDirty(e.computedKey))}}}runObservers(e){return e.filter(e=>!e.store._disposed).map(e=>e.observer.call(e.store.proxify(e.observer)))}async notify(e,t=10){let n=$(this,e),r=Array.from(n?.observers.get(e)||[]);if(this._executing.has(e)){this._dirty.add(e);return}let i=this._pending.get(e);if(i){for(let e of r)i.entries.includes(e)||i.entries.push(e);return i.done}let a=new Promise(i=>{setTimeout(async()=>{this._pending.delete(e);try{this._executing.add(e);let t=this.runObservers(r);this._dirty.delete(e),await Promise.all(t)}finally{this._executing.delete(e),this._dirty.delete(e)&&this.notify(e,t)}let a=n?.observers.get(e);if(a)for(let e of r){let t=e.store._store.has(`$parent`),n=e.store._store.get(`$rootNode`);t&&n&&!n.isConnected&&!n.parentNode&&a.delete(e)}i()},t)});return this._pending.set(e,{done:a,entries:r}),a}get(e,t){t&&this.watch(e,t);let n=Q(this,e);if(Mt(n)){if(n.dirty){this._computedDepth++;try{let t=this.proxify(n.effectFn);n.value=n.fn.call(t,t),n.dirty=!1,n.effectFn&&this.tagObserversForComputed(n.effectFn,e),this.markDependentComputedsDirty(e)}finally{this._computedDepth--}}return n.value}return n}setupComputed(e,t){let n=this,r={[J]:!0,fn:t,dirty:!0};this._store.set(e,r);let i=function(){n._computedDepth++;try{let i=t.call(this,this);if(r.value!==i){r.value=i;let t=$(n,e),a=Array.from(t?.observers.get(e)||[]);for(let e of a)e.observer.call(e.store.proxify(e.observer))}r.dirty=!1}finally{n._computedDepth--}};r.effectFn=i,this.effect(i,{directive:`computed`,id:e}),this.tagObserversForComputed(i,e)}mutationCallback(e){let t=this._mutationCallbacks.get(e);if(t)return t;let n=()=>{this.markDependentComputedsDirty(e),this.notify(e)};return this._mutationCallbacks.set(e,n),n}async set(e,t,n){if(Mt(t)){this.setupComputed(e,t.fn);return}if(this._store.has(e)&&t===this._store.get(e))return;let r=Q(this,e);if(X(t)&&(t=this.wrapObject(t)),Z(t)||X(r)){let n=this.mutationCallback(e);Bt(r,n),zt(t,n)}if(n?this._store.set(e,t):Vt(this,e,t),!n){for(let[n,r]of this.keyHandlers.entries())if(n.test(e))for(let n of r)await Promise.resolve(n.call(this.$,e,t))}this.markDependentComputedsDirty(e),await this.notify(e)}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e),this._mutationCallbacks.delete(e)}disposeSubtree(e){if(!e.has(this)){e.add(this),this._disposed=!0;for(let t of this._children)t.disposeSubtree(e);this._children.clear();for(let[e,t]of this._mutationCallbacks)Bt(Q(this,e),t);this._mutationCallbacks.clear();for(let e of this.observers.values())e.clear();this.observers.clear()}}dispose(){this._store.get(`$parent`)?._children.delete(this);let e=new Set;this.disposeSubtree(e);let t=this._store.get(`$parent`);for(;t;){for(let n of t.observers.values())for(let t of n)e.has(t.store)&&n.delete(t);t=t._store.get(`$parent`)}}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}getObserverStats(){let e={},t=0;for(let[n,r]of this.observers)e[n]=r.size,t+=r.size;return{totalKeys:this.observers.size,totalObservers:t,byKey:e}}effect(e,t){return e.call(this.proxify(e))}$computed(e){return{[J]:!0,fn:e,dirty:!0}}proxify(t){let n=Array.from(this._store.entries()).map(([e])=>e),r=Object.fromEntries(n.map(e=>[e,null])),i=(e,t,n)=>typeof e==`function`&&t!==`constructor`?(...t)=>e.call(n,...t):e;return new Proxy(r,{has:(e,t)=>typeof t==`string`&&($(this,t)||Reflect.has(this,t))?!0:Reflect.has(r,t),get:(n,r,a)=>{if(typeof r==`string`){if($(this,r)){let n=this.get(r,t);return t&&n instanceof e?n.proxify(t):i(n,r,a)}if(t&&r!==Pt&&!Reflect.has(this,r))return this.set(r,void 0),this.get(r,t)}return r===`$`?this.proxify(t):i(Reflect.get(this,r,a),r,a)},set:(e,t,n,r)=>(typeof t!=`string`||t in this?Reflect.set(this,t,n,r):(this._computedDepth>0&&console.warn(`[mancha] Computed wrote to '${t}'. Computeds should be pure; use $effect for side effects.`),this.set(t,n)),!0)})}get $(){return this.proxify()}makeEvalFunction(e){return(t,n)=>{let r=At(e,Nt),i=new Proxy(n,{has(e,n){return n in e||n in t||n in globalThis},get(e,n){if(typeof n==`string`)return n in e?e[n]:n in t?t[n]:n in globalThis?globalThis[n]:t[n]},set(e,n,r){return typeof n==`string`?n in e?(e[n]=r,!0):(t[n]=r,!0):!1}});return r?.evaluate(i)}}cachedExpressionFunction(e){e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e));let t=this.expressionCache.get(e);if(!t)throw Error(`Failed to retrieve cached expression: ${e}`);return t}eval(e,t={}){let n=this.$;if(this._store.has(e))return n[e];{let r=this.cachedExpressionFunction(e);try{return r(n,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`,t),null}}}$resolve(e,t){let n={$pending:!0,$result:null,$error:null};return Promise.resolve().then(()=>e(t)).then(e=>{n.$result=e}).catch(e=>{n.$error=e instanceof Error?e:Error(String(e))}).finally(()=>{n.$pending=!1}),n}};const Ut=`data-m-cloak`,Wt=`mancha-runtime-cloak`,Gt=o`[data-m-cloak]{display:none!important}`;var Kt=class e extends Ht{_debugLevel=`off`;dirpath=``;_perfData={lifecycle:{},effects:new Map};static DEBUG_LEVELS=[`off`,`lifecycle`,`effects`,`verbose`];_skipNodes=new Set;_customElements=new Map;_pendingValueRetries=[];cloakElement(e){let t=e.ownerDocument??globalThis.document;if(t?.head&&!t.getElementById(Wt)){let e=t.createElement(`style`);e.id=Wt,r.setTextContent(e,Gt),t.head.appendChild(e)}M(e,Ut,``)}uncloakElement(e){F(e,Ut)}debug(e){return typeof e==`boolean`?this._debugLevel=e?`lifecycle`:`off`:this._debugLevel=e,this}get debugging(){return this._debugLevel!==`off`}shouldLog(t){return e.DEBUG_LEVELS.indexOf(this._debugLevel)>=e.DEBUG_LEVELS.indexOf(t)}clearPerformanceReport(){this._perfData={lifecycle:{},effects:new Map}}getNodePath(e){let t=[],n=e;for(;n?.tagName;){let e=n.tagName.toLowerCase(),r=n.parentElement;if(r){let i=Array.from(r.children).filter(t=>t.tagName.toLowerCase()===e);if(i.length>1){let r=i.indexOf(n)+1;t.unshift(`${e}:nth-child(${r})`)}else t.unshift(e)}else t.unshift(e);n=r}return t.join(`>`)}buildObserverId(e){let t=e?.directive??`unknown`,n=V(e?.expression??``,32),r=e?.element,i=e?.id??(r?r.dataset?.perfid??r.id??r.dataset?.testid??this.getNodePath(r):`unknown`);return n?`${t}:${i}:${n}`:`${t}:${i}`}recordObserverExecution(e,t){let n=this.buildObserverId(e),r=this._perfData.effects.get(n)??{count:0,totalTime:0};r.count++,r.totalTime+=t,this._perfData.effects.set(n,r)}getPerformanceReport(){let e=Array.from(this._perfData.effects.entries()),t={};for(let[n,r]of e){let e=n.split(`:`)[0];t[e]||(t[e]={count:0,totalTime:0}),t[e].count+=r.count,t[e].totalTime+=r.totalTime}let n=e.map(([e,t])=>({id:e,executionCount:t.count,totalTime:t.totalTime,avgTime:t.count>0?t.totalTime/t.count:0})).sort((e,t)=>t.totalTime-e.totalTime).slice(0,10);return{lifecycle:this._perfData.lifecycle,effects:{total:e.length,byDirective:t,slowest:n},observers:this.getObserverStats()}}effect(e,t){let n=this;function r(){if(!n.shouldLog(`lifecycle`))return e.call(this);let r=performance.now(),i=e.call(this),a=performance.now()-r;return t&&n.recordObserverExecution(t,a),a>16&&console.warn(`[mancha] Slow observer (${a.toFixed(1)}ms):`,n.buildObserverId(t)),n.shouldLog(`effects`)&&console.debug(`[mancha] Observer (${a.toFixed(2)}ms):`,n.buildObserverId(t)),i}return super.effect(r,t)}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:
30
- `,t);let n=this.parseHTML(e,t);return await this.preprocessNode(n,t),n}async preprocessRemote(e,t){let n={};t?.cache&&(n.cache=t.cache);let r=await fetch(e,n).then(e=>e.text());return this.preprocessString(r,{...t,dirpath:U(e),rootDocument:t?.rootDocument??!e.endsWith(`.tpl.html`)})}async preprocessLocal(e,t){let n=await this.fetchLocal(e,t);return this.preprocessString(n,{...t,dirpath:U(e),rootDocument:t?.rootDocument??!e.endsWith(`.tpl.html`)})}subrenderer(){let e=new this.constructor().debug(this.debugging);return e._store.set(`$parent`,this),this._disposed||this._children.add(e),e._store.set(`$rootRenderer`,this.get(`$rootRenderer`)??this),e._customElements=this._customElements,e}log(...e){this.shouldLog(`verbose`)&&console.debug(...e)}async preprocessNode(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;t={dirpath:this.dirpath,maxdepth:10,...t};let r=new tt(D(e,this._skipNodes)).map(async e=>{this.log(`Preprocessing node:
31
- `,H(e,128)),await W.resolveIncludes.call(this,e,t),await W.rebaseRelativePaths.call(this,e,t),await W.registerCustomElements.call(this,e,t),await W.resolveCustomElements.call(this,e,t)});return await Promise.all(r.generator()),n&&(this._perfData.lifecycle.preprocessTime=(this._perfData.lifecycle.preprocessTime??0)+(performance.now()-n)),e}async renderNode(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;for(let n of D(e,this._skipNodes))this.log(`Rendering node:
32
- `,H(n,128)),await W.resolveForAttribute.call(this,n,t),await W.resolveRenderAttribute.call(this,n,t),await W.resolveDataAttribute.call(this,n,t),await W.resolveTextAttributes.call(this,n,t),await W.resolveHtmlAttribute.call(this,n,t),await W.resolveIfAttribute.call(this,n,t),await W.resolveShowAttribute.call(this,n,t),await W.resolveClassAttribute.call(this,n,t),await W.resolveBindAttribute.call(this,n,t),await W.resolveEventAttributes.call(this,n,t),await W.resolveTextNodeExpressions.call(this,n,t),await W.resolveCustomAttribute.call(this,n,t),await W.resolveCustomProperty.call(this,n,t),await W.stripTypes.call(this,n,t);for(let e of this._pendingValueRetries.splice(0))e();return n&&(this._perfData.lifecycle.renderTime=(this._perfData.lifecycle.renderTime??0)+(performance.now()-n)),e}async mount(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;n&&this.clearPerformanceReport(),t={...t,rootNode:e},P(e,`renderer`,this),this._store.set(`$rootNode`,e),this.has(`$rootRenderer`)||this._store.set(`$rootRenderer`,this),this.get(`$rootRenderer`)===this&&await ut(this),await this.preprocessNode(e,t),await this.renderNode(e,t),Ue(e),n&&(this._perfData.lifecycle.mountTime=performance.now()-n)}};function qt(){return i([o`*,::before,::after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}`,o`html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal}`,o`body{margin:0;line-height:inherit}`,o`hr{height:0;color:inherit;border-top-width:1px}`,o`abbr:where([title]){text-decoration:underline dotted}`,o`b,strong{font-weight:bolder}`,o`code,kbd,samp,pre{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;font-size:1em}`,o`small{font-size:80%}`,o`sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}`,o`sub{bottom:-0.25em}`,o`sup{top:-0.5em}`,o`button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}`,o`button,select{text-transform:none}`,o`button,[type='button'],[type='reset'],[type='submit']{-webkit-appearance:button;background-color:transparent;background-image:none;cursor:pointer}`,o`:-moz-focusring{outline:auto}`,o`:-moz-ui-invalid{box-shadow:none}`,o`progress{vertical-align:baseline}`,o`::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}`,o`[type='search']{-webkit-appearance:textfield;outline-offset:-2px}`,o`::-webkit-search-decoration{-webkit-appearance:none}`,o`::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}`,o`summary{display:list-item}`,o`blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}`,o`fieldset{margin:0;padding:0}`,o`legend{padding:0}`,o`ol,ul,menu{list-style:none;margin:0;padding:0}`,o`textarea{resize:vertical}`,o`::placeholder{opacity:1;color:#9ca3af}`,o`button,[role="button"]{cursor:pointer}`,o`:disabled{cursor:default;pointer-events:none;opacity:0.75}`,o`img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}`,o`img,video{max-width:100%;height:auto}`,o`[hidden]{display:none}`,o`dialog{padding:0}`,o`dialog::backdrop{background:rgba(0,0,0,0.5)}`])}function Jt(){return i([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`}`])}var Yt=class extends Kt{impl=`browser`;dirpath=U(globalThis.location?.href??`http://localhost/`);parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return new DOMParser().parseFromString(e,`text/html`);{let 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)}createComment(e,t){return(t||document).createComment(e)}textContent(e,t){e.textContent=t}};const Xt=new Yt;function Zt(e){for(let t of e){t=t.trim();let e=document.createElement(`style`);switch(t){case`minimal`:r.setTextContent(e,Jt());break;case`basic`:case`custom`:continue;case`utils`:{r.setTextContent(e,qt()),e.setAttribute(`data-mancha`,`basic`),globalThis.document.head.appendChild(e);let t=document.createElement(`style`);t.textContent=we(),t.setAttribute(`data-mancha`,`utils`),globalThis.document.head.appendChild(t),Ve(document);continue}default:console.error(`Unknown style name: "${t}"`);continue}globalThis.document.head.appendChild(e)}}const Qt=`mancha-cloak`;function $t(e,t){let n=`${e.join(`, `)} { opacity: 0 !important; ${t>0?`transition: opacity ${t}ms ease-in-out !important;`:``} }`,r=document.getElementById(Qt);r||(r=document.createElement(`style`),r.id=Qt,document.head.appendChild(r)),r.textContent=n}function en(e){let t=!1;return async()=>{if(t)return;t=!0;let n=document.getElementById(Qt);if(n){if(e!==!1){let t=n.sheet;t&&t.cssRules.length>0&&t.cssRules[0].style.setProperty(`opacity`,`1`,`important`),await new Promise(t=>setTimeout(t,e))}typeof globalThis.requestAnimationFrame==`function`&&(await new Promise(e=>globalThis.requestAnimationFrame(e)),await new Promise(e=>globalThis.requestAnimationFrame(e))),n.remove()}}}async function tn(e={}){let t;document.documentElement.classList.add(`mancha-loading`);let n=e.cloak?e.cloak===!0?{}:e.cloak:void 0;if(n){let r=e.target?Array.isArray(e.target)?e.target:[e.target]:[`body`],i=n.selector&&(Array.isArray(n.selector)||typeof n.selector==`string`)?Array.isArray(n.selector)?n.selector:[n.selector]:r,a=n.duration??0;$t(i,a),t=en(a>0?a:!1)}else t=en(!1);document.readyState===`loading`&&await new Promise(e=>{window.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0})});let r=e.renderer??new Yt;if(e.css&&e.css.length>0&&Zt(e.css),e.debug&&r.debug(!0),e.state)for(let[t,n]of Object.entries(e.state))await r.set(t,n);try{if(e.callback)await e.callback(r);else if(e.target){let t=Array.isArray(e.target)?e.target:[e.target];for(let n of t){let t=globalThis.document.querySelector(n);t?await r.mount(t,{cache:e.cache}):console.error(`Target element not found: "${n}"`)}}}finally{document.documentElement.classList.remove(`mancha-loading`),t&&await t()}return r}export{Kt as IRenderer,Xt as Mancha,Yt as Renderer,Ge as _resetCustomCssForTesting,qt as basicCssRules,tn as initMancha,Zt as injectCss,Jt as minimalCssRules,Ve as scanAndInject,we as utilsCssRules};
28
+ const yt=new Set([`==`,`!=`,`<=`,`>=`,`||`,`&&`,`??`,`?.`]),bt=new Set([`===`,`!==`]);let W=function(e){return 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`,e}({});const G=(e,t,n=0)=>({kind:e,value:t,precedence:n}),xt=e=>e===9||e===10||e===13||e===32,St=e=>{if(e===95||e===36)return!0;let t=e&-33;return 65<=t&&t<=90},Ct=e=>St(e)||K(e),wt=e=>dt.has(e),Tt=e=>e===34||e===39,K=e=>48<=e&&e<=57,Et=e=>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,Dt=e=>e===40||e===41||e===91||e===93||e===123||e===125,Ot=e=>e.replace(/\\(.)/g,(e,t)=>{switch(t){case`n`:return`
29
+ `;case`r`:return`\r`;case`t`:return` `;case`b`:return`\b`;case`f`:return`\f`;default:return t}});var kt=class{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;xt(this._next??-1);)this._advance(!0);if(Tt(this._next??-1))return this._tokenizeString();if(St(this._next??-1))return this._tokenizeIdentOrKeyword();if(K(this._next??-1))return this._tokenizeNumber();if(this._next===46)return this._tokenizeDot();if(this._next===44)return this._tokenizeComma();if(this._next===58)return this._tokenizeColon();if(Et(this._next??-1))return this._tokenizeOperator();if(Dt(this._next??-1))return this._tokenizeGrouper();if(this._advance(),this._next!==void 0)throw Error(`Expected end of input, got ${this._next}`)}_advance(e){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),e===!0&&(this._tokenStart=this._index)):this._next=void 0}_getValue(e=0){let t=this._input.substring(this._tokenStart,this._index+e);return e===0&&this._clearValue(),t}_clearValue(){this._tokenStart=this._index}_tokenizeString(){let e=this._next;for(this._advance(!0);this._next!==e;){if(this._next===void 0||this._next===92&&(this._advance(),this._next===void 0))throw Error(`unterminated string`);this._advance()}let t=G(W.STRING,Ot(this._getValue()));return this._advance(),t}_tokenizeIdentOrKeyword(){do this._advance();while(Ct(this._next??-1));let e=this._getValue();return G(wt(e)?W.KEYWORD:ft.has(e)?W.OPERATOR:W.IDENTIFIER,e,ht[e]??0)}_tokenizeNumber(){do this._advance();while(K(this._next??-1));return this._next===46?this._tokenizeDot():G(W.INTEGER,this._getValue())}_tokenizeDot(){if(this._advance(),K(this._next??-1))return this._tokenizeFraction();if(this._next===46){if(this._advance(),this._next===46)return this._advance(),this._clearValue(),G(W.SPREAD,`...`);throw Error(`Unexpected token ..`)}return this._clearValue(),G(W.DOT,`.`,13)}_tokenizeComma(){return this._advance(!0),G(W.COMMA,`,`)}_tokenizeColon(){return this._advance(!0),G(W.COLON,`:`)}_tokenizeFraction(){do this._advance();while(K(this._next??-1));return G(W.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(bt.has(e))this._advance(),this._advance();else{if(e=this._getValue(1),e===`=>`)return this._advance(),G(W.ARROW,e);yt.has(e)&&this._advance()}return e=this._getValue(),e===`?.`?G(W.OPTIONAL_DOT,e,13):G(W.OPERATOR,e,ht[e])}_tokenizeGrouper(){let e=String.fromCharCode(this._next??0),t=G(W.GROUPER,e,ht[e]);return this._advance(!0),t}};const At=(e,t)=>new jt(e,t).parse();var jt=class{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new kt(e),this._ast=t}parse(){this._advance();let e=this._parseExpression();if(this._token)throw Error(`Unexpected token: ${this._token.value}`);return e}_advance(e,t){if(!this._matches(e,t))throw Error(`Expected kind ${e} (${t}), was ${this._token?.kind} (${this._token?.value})`);let n=this._tokenizer.nextToken();this._token=n,this._kind=n?.kind,this._value=n?.value}_matches(e,t){return!(e&&this._kind!==e||t&&this._value!==t)}_parseExpression(){if(!this._token)return this._ast.empty();let e=this._parseUnary();return e===void 0?void 0:this._parsePrecedence(e,0)}_parsePrecedence(e,t){if(e===void 0)throw Error(`Expected left to be defined.`);for(;this._token;)if(this._matches(W.GROUPER,`(`)){let t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(W.GROUPER,`[`)){let t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(W.DOT)||this._matches(W.OPTIONAL_DOT)){let t=this._kind===W.OPTIONAL_DOT;if(this._advance(),t&&this._matches(W.GROUPER,`[`)){let t=this._parseIndex();e=this._ast.index(e,t,!0)}else if(t&&this._matches(W.GROUPER,`(`)){let t=this._parseArguments();e=this._ast.invoke(e,void 0,t,!0)}else{let n=this._parseUnary();e=this._makeInvokeOrGetter(e,n,t)}}else if(this._matches(W.KEYWORD))break;else if(this._matches(W.OPERATOR)&&this._token.precedence>=t)e=this._value===`?`?this._parseTernary(e):this._parseBinary(e,this._token);else break;return e}_makeInvokeOrGetter(e,t,n){if(t===void 0)throw Error(`expected identifier`);if(t.type===`ID`)return this._ast.getter(e,t.value,n);if(t.type===`Invoke`&&t.receiver.type===`ID`){let r=t.receiver;return this._ast.invoke(e,r.value,t.arguments,n)}else throw Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(!mt.has(t.value))throw Error(`unknown operator: ${t.value}`);this._advance();let n=this._parseUnary();for(;(this._kind===W.OPERATOR||this._kind===W.DOT||this._kind===W.GROUPER)&&this._token&&(this._token.precedence??0)>t.precedence;)n=this._parsePrecedence(n,this._token?.precedence??0);if(n===void 0)throw Error(`Expected expression after ${t.value}`);return this._ast.binary(e,t.value,n)}_parseUnary(){if(this._matches(W.KEYWORD,`typeof`)){this._advance();let e=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(`typeof`,e)}if(this._matches(W.OPERATOR)){let e=this._value;if(this._advance(),e===`+`||e===`-`){if(this._matches(W.INTEGER))return this._parseInteger(e);if(this._matches(W.DECIMAL))return this._parseDecimal(e)}if(!e||!pt.has(e))throw Error(`unexpected token: ${e}`);let t=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(e,t)}return this._parsePrimary()}_parseTernary(e){this._advance(W.OPERATOR,`?`);let t=this._parseExpression();this._advance(W.COLON);let n=this._parseExpression();return this._ast.ternary(e,t,n)}_parsePrimary(){switch(this._kind){case W.KEYWORD:{let e=this._value??``;if(e===`this`)return this._advance(),this._ast.id(e);throw dt.has(e)?Error(`unexpected keyword: ${e}`):Error(`unrecognized keyword: ${e}`)}case W.IDENTIFIER:return this._parseInvokeOrIdentifier();case W.STRING:return this._parseString();case W.INTEGER:return this._parseInteger();case W.DECIMAL:return this._parseDecimal();case W.GROUPER:return this._value===`(`?this._parseParenOrFunction():this._value===`{`?this._parseMap():this._value===`[`?this._parseList():void 0;case W.COLON:throw Error(`unexpected token ":"`);default:return}}_parseList(){let e=[];do{if(this._advance(),this._matches(W.GROUPER,`]`))break;if(this._matches(W.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else e.push(this._parseExpression())}while(this._matches(W.COMMA));return this._advance(W.GROUPER,`]`),this._ast.list(e)}_parseMap(){let e=[];do{if(this._advance(),this._matches(W.GROUPER,`}`))break;if(this._matches(W.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadProperty(t))}else{let t=this._value??``;if((this._matches(W.STRING)||this._matches(W.IDENTIFIER))&&this._advance(),this._matches(W.COLON)){this._advance(W.COLON);let n=this._parseExpression();n&&e.push(this._ast.property(t,n))}else e.push(this._ast.property(t,this._ast.id(t)))}}while(this._matches(W.COMMA));return this._advance(W.GROUPER,`}`),this._ast.map(e)}_parseInvokeOrIdentifier(){let e=this._value;if(e===`true`)return this._advance(),this._ast.literal(!0);if(e===`false`)return this._advance(),this._ast.literal(!1);if(e===`null`)return this._advance(),this._ast.literal(null);if(e===`undefined`)return this._advance(),this._ast.literal(void 0);let t=this._parseIdentifier(),n=this._parseArguments();return n?this._ast.invoke(t,void 0,n):t}_parseIdentifier(){if(!this._matches(W.IDENTIFIER))throw Error(`expected identifier: ${this._value}`);let e=this._value;return this._advance(),this._ast.id(e??``)}_parseArguments(){if(!this._matches(W.GROUPER,`(`))return;let e=[];do{if(this._advance(),this._matches(W.GROUPER,`)`))break;if(this._matches(W.SPREAD)){this._advance();let t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else{let t=this._parseExpression();e.push(t)}}while(this._matches(W.COMMA));return this._advance(W.GROUPER,`)`),e}_parseIndex(){this._advance();let e=this._parseExpression();return this._advance(W.GROUPER,`]`),e}_parseParenOrFunction(){let e=this._parseArguments();if(this._matches(W.ARROW)){this._advance();let t=this._parseExpression(),n=e?.map(e=>e.value)??[];return this._ast.arrowFunction(n,t)}else return this._ast.paren(e?.[0])}_parseString(){let e=this._ast.literal(this._value??``);return this._advance(),e}_parseInteger(e=``){let t=this._ast.literal(parseInt(`${e}${this._value}`,10));return this._advance(),t}_parseDecimal(e=``){let t=this._ast.literal(parseFloat(`${e}${this._value}`));return this._advance(),t}};const q=Symbol(`__computed__`);function Mt(e){return typeof e==`object`&&!!e&&q in e&&e[q]===!0}const Nt=new vt,Pt=`__is_proxy__`;function Ft(e){return e instanceof Ht||e[Pt]===!0}const J=new WeakMap;function Y(e){return typeof e==`object`&&!!e}function X(e){return Y(e)?J.get(e):void 0}function It(e){return e.subscribers.size===0&&e.holders.size===0}function Lt(e,t){if(!t.has(e)){t.add(e);for(let n of Array.from(e.holders))It(n)?e.holders.delete(n):Lt(n,t);for(let t of Array.from(e.subscribers))t()}}function Rt(e){Lt(e,new Set)}function zt(e,t){X(e)?.subscribers.add(t)}function Bt(e,t){X(e)?.subscribers.delete(t)}function Z(e,t){let n=e?._store;if(n?.has(t))return n.get(t);if(n?.has(`$parent`))return Z(n.get(`$parent`),t)}function Q(e,t){let n=e?._store;return n?.has(t)?e:n?.has(`$parent`)?Q(n.get(`$parent`),t):null}function Vt(e,t,n){let r=Q(e,t);r?r._store.set(t,n):e._store.set(t,n)}var Ht=class e{evalkeys=[`$elem`,`$event`];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_store=new Map;_lock=Promise.resolve();_pending=new Map;_executing=new Set;_dirty=new Set;_children=new Set;_mutationCallbacks=new Map;_disposed=!1;_computedDepth=0;constructor(e){for(let[t,n]of Object.entries(e||{}))this.set(t,n)}wrapObject(e){if(e==null||Ft(e)||Object.isFrozen(e)||Object.isSealed(e))return e;let t=Object.getPrototypeOf(e);if(!(t===Object.prototype||t===null)&&!Array.isArray(e))return e;let n=J.get(e)??{subscribers:new Set,holders:new Set};J.set(e,n);let r=()=>Rt(n),i=new Proxy(e,{deleteProperty:(e,t)=>typeof t==`string`&&t in e?(delete e[t],r(),!0):!1,set:(e,t,i,a)=>{if(Reflect.get(e,t,a)===i)return!0;Y(i)&&(i=this.wrapObject(i),X(i)?.holders.add(n));let o=Reflect.set(e,t,i,a);return r(),o},get:(e,t,r)=>{if(t===Pt)return!0;let i=Reflect.get(e,t,r);if(!Y(i))return i;let a=this.wrapObject(i);return a!==i&&Reflect.set(e,t,a,r),X(a)?.holders.add(n),a}});return J.set(i,n),i}watch(e,t){let n=Q(this,e);if(!n)throw Error(`Cannot watch key "${e}" as it does not exist in the store.`);n.observers.has(e)||n.observers.set(e,new Set),Array.from(n.observers.get(e)||[]).some(e=>e.observer===t)||n.observers.get(e)?.add({observer:t,store:this})}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e)?.add(t)}tagObserversForComputed(e,t){for(let n of this.observers.values())for(let r of n)r.observer===e&&r.store===this&&(r.computedKey=t);let n=this._store.get(`$parent`);for(;n;){for(let r of n.observers.values())for(let n of r)n.observer===e&&n.store===this&&(n.computedKey=t);n=n._store.get(`$parent`)}}markDependentComputedsDirty(e){let t=Q(this,e)?.observers.get(e);if(t){for(let e of t)if(e.computedKey){let t=e.store._store.get(e.computedKey);Mt(t)&&!t.dirty&&(t.dirty=!0,e.store.markDependentComputedsDirty(e.computedKey))}}}runObservers(e){return e.filter(e=>!e.store._disposed).map(e=>e.observer.call(e.store.proxify(e.observer)))}async notify(e,t=10){let n=Q(this,e),r=Array.from(n?.observers.get(e)||[]);if(this._executing.has(e)){this._dirty.add(e);return}let i=this._pending.get(e);if(i){for(let e of r)i.entries.includes(e)||i.entries.push(e);return i.done}let a=new Promise(i=>{setTimeout(async()=>{this._pending.delete(e);try{this._executing.add(e);let t=this.runObservers(r);this._dirty.delete(e),await Promise.all(t)}finally{this._executing.delete(e),this._dirty.delete(e)&&this.notify(e,t)}let a=n?.observers.get(e);if(a)for(let e of r){let t=e.store._store.has(`$parent`),n=e.store._store.get(`$rootNode`);t&&n&&!n.isConnected&&!n.parentNode&&a.delete(e)}i()},t)});return this._pending.set(e,{done:a,entries:r}),a}get(e,t){t&&this.watch(e,t);let n=Z(this,e);if(Mt(n)){if(n.dirty){this._computedDepth++;try{let t=this.proxify(n.effectFn);n.value=n.fn.call(t,t),n.dirty=!1,n.effectFn&&this.tagObserversForComputed(n.effectFn,e),this.markDependentComputedsDirty(e)}finally{this._computedDepth--}}return n.value}return n}setupComputed(e,t){let n=this,r={[q]:!0,fn:t,dirty:!0};this._store.set(e,r);let i=function(){n._computedDepth++;try{let i=t.call(this,this);if(r.value!==i){r.value=i;let t=Q(n,e),a=Array.from(t?.observers.get(e)||[]);for(let e of a)e.observer.call(e.store.proxify(e.observer))}r.dirty=!1}finally{n._computedDepth--}};r.effectFn=i,this.effect(i,{directive:`computed`,id:e}),this.tagObserversForComputed(i,e)}mutationCallback(e){let t=this._mutationCallbacks.get(e);if(t)return t;let n=()=>{this.markDependentComputedsDirty(e),this.notify(e)};return this._mutationCallbacks.set(e,n),n}async set(e,t,n){if(Mt(t)){this.setupComputed(e,t.fn);return}if(this._store.has(e)&&t===this._store.get(e))return;let r=Z(this,e);if(Y(t)&&(t=this.wrapObject(t)),X(t)||Y(r)){let n=this.mutationCallback(e);Bt(r,n),zt(t,n)}if(n?this._store.set(e,t):Vt(this,e,t),!n){for(let[n,r]of this.keyHandlers.entries())if(n.test(e))for(let n of r)await Promise.resolve(n.call(this.$,e,t))}this.markDependentComputedsDirty(e),await this.notify(e)}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e),this._mutationCallbacks.delete(e)}disposeSubtree(e){if(!e.has(this)){e.add(this),this._disposed=!0;for(let t of this._children)t.disposeSubtree(e);this._children.clear();for(let[e,t]of this._mutationCallbacks)Bt(Z(this,e),t);this._mutationCallbacks.clear();for(let e of this.observers.values())e.clear();this.observers.clear()}}dispose(){this._store.get(`$parent`)?._children.delete(this);let e=new Set;this.disposeSubtree(e);let t=this._store.get(`$parent`);for(;t;){for(let n of t.observers.values())for(let t of n)e.has(t.store)&&n.delete(t);t=t._store.get(`$parent`)}}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}getObserverStats(){let e={},t=0;for(let[n,r]of this.observers)e[n]=r.size,t+=r.size;return{totalKeys:this.observers.size,totalObservers:t,byKey:e}}effect(e,t){return e.call(this.proxify(e))}$computed(e){return{[q]:!0,fn:e,dirty:!0}}proxify(t){let n=Array.from(this._store.entries()).map(([e])=>e),r=Object.fromEntries(n.map(e=>[e,null])),i=(e,t,n)=>typeof e==`function`&&t!==`constructor`?(...t)=>e.call(n,...t):e;return new Proxy(r,{has:(e,t)=>typeof t==`string`&&(Q(this,t)||Reflect.has(this,t))?!0:Reflect.has(r,t),get:(n,r,a)=>{if(typeof r==`string`){if(Q(this,r)){let n=this.get(r,t);return t&&n instanceof e?n.proxify(t):i(n,r,a)}if(t&&r!==Pt&&!Reflect.has(this,r))return this.set(r,void 0),this.get(r,t)}return r===`$`?this.proxify(t):i(Reflect.get(this,r,a),r,a)},set:(e,t,n,r)=>(typeof t!=`string`||t in this?Reflect.set(this,t,n,r):(this._computedDepth>0&&console.warn(`[mancha] Computed wrote to '${t}'. Computeds should be pure; use $effect for side effects.`),this.set(t,n)),!0)})}get $(){return this.proxify()}makeEvalFunction(e){return(t,n)=>{let r=At(e,Nt),i=new Proxy(n,{has(e,n){return n in e||n in t||n in globalThis},get(e,n){if(typeof n==`string`)return n in e?e[n]:n in t?t[n]:n in globalThis?globalThis[n]:t[n]},set(e,n,r){return typeof n==`string`?n in e?(e[n]=r,!0):(t[n]=r,!0):!1}});return r?.evaluate(i)}}cachedExpressionFunction(e){e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e));let t=this.expressionCache.get(e);if(!t)throw Error(`Failed to retrieve cached expression: ${e}`);return t}eval(e,t={}){let n=this.$;if(this._store.has(e))return n[e];{let r=this.cachedExpressionFunction(e);try{return r(n,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`,t),null}}}$resolve(e,t){let n={$pending:!0,$result:null,$error:null};return Promise.resolve().then(()=>e(t)).then(e=>{n.$result=e}).catch(e=>{n.$error=e instanceof Error?e:Error(String(e))}).finally(()=>{n.$pending=!1}),n}};const Ut=`data-m-cloak`,Wt=`mancha-runtime-cloak`,Gt=o`[data-m-cloak]{display:none!important}`;var Kt=class e extends Ht{_debugLevel=`off`;dirpath=``;_perfData={lifecycle:{},effects:new Map};static DEBUG_LEVELS=[`off`,`lifecycle`,`effects`,`verbose`];_skipNodes=new Set;_customElements=new Map;_pendingValueRetries=[];cloakElement(e){let t=e.ownerDocument??globalThis.document;if(t?.head&&!t.getElementById(Wt)){let e=t.createElement(`style`);e.id=Wt,r.setTextContent(e,Gt),t.head.appendChild(e)}N(e,Ut,``)}uncloakElement(e){I(e,Ut)}debug(e){return typeof e==`boolean`?this._debugLevel=e?`lifecycle`:`off`:this._debugLevel=e,this}get debugging(){return this._debugLevel!==`off`}shouldLog(t){return e.DEBUG_LEVELS.indexOf(this._debugLevel)>=e.DEBUG_LEVELS.indexOf(t)}clearPerformanceReport(){this._perfData={lifecycle:{},effects:new Map}}getNodePath(e){let t=[],n=e;for(;n?.tagName;){let e=n.tagName.toLowerCase(),r=n.parentElement;if(r){let i=Array.from(r.children).filter(t=>t.tagName.toLowerCase()===e);if(i.length>1){let r=i.indexOf(n)+1;t.unshift(`${e}:nth-child(${r})`)}else t.unshift(e)}else t.unshift(e);n=r}return t.join(`>`)}buildObserverId(e){let t=e?.directive??`unknown`,n=V(e?.expression??``,32),r=e?.element,i=e?.id??(r?r.dataset?.perfid??r.id??r.dataset?.testid??this.getNodePath(r):`unknown`);return n?`${t}:${i}:${n}`:`${t}:${i}`}recordObserverExecution(e,t){let n=this.buildObserverId(e),r=this._perfData.effects.get(n)??{count:0,totalTime:0};r.count++,r.totalTime+=t,this._perfData.effects.set(n,r)}getPerformanceReport(){let e=Array.from(this._perfData.effects.entries()),t={};for(let[n,r]of e){let e=n.split(`:`)[0];t[e]||(t[e]={count:0,totalTime:0}),t[e].count+=r.count,t[e].totalTime+=r.totalTime}let n=e.map(([e,t])=>({id:e,executionCount:t.count,totalTime:t.totalTime,avgTime:t.count>0?t.totalTime/t.count:0})).sort((e,t)=>t.totalTime-e.totalTime).slice(0,10);return{lifecycle:this._perfData.lifecycle,effects:{total:e.length,byDirective:t,slowest:n},observers:this.getObserverStats()}}effect(e,t){let n=this;function r(){if(!n.shouldLog(`lifecycle`))return e.call(this);let r=performance.now(),i=e.call(this),a=performance.now()-r;return t&&n.recordObserverExecution(t,a),a>16&&console.warn(`[mancha] Slow observer (${a.toFixed(1)}ms):`,n.buildObserverId(t)),n.shouldLog(`effects`)&&console.debug(`[mancha] Observer (${a.toFixed(2)}ms):`,n.buildObserverId(t)),i}return super.effect(r,t)}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:
30
+ `,t);let n=this.parseHTML(e,t);return await this.preprocessNode(n,t),n}async preprocessRemote(e,t){let n={};t?.cache&&(n.cache=t.cache);let r=await fetch(e,n).then(e=>e.text());return this.preprocessString(r,{...t,dirpath:$e(e),rootDocument:t?.rootDocument??!e.endsWith(`.tpl.html`)})}async preprocessLocal(e,t){let n=await this.fetchLocal(e,t);return this.preprocessString(n,{...t,dirpath:$e(e),rootDocument:t?.rootDocument??!e.endsWith(`.tpl.html`)})}subrenderer(){let e=new this.constructor().debug(this.debugging);return e._store.set(`$parent`,this),this._disposed||this._children.add(e),e._store.set(`$rootRenderer`,this.get(`$rootRenderer`)??this),e._customElements=this._customElements,e}log(...e){this.shouldLog(`verbose`)&&console.debug(...e)}async preprocessNode(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;t={dirpath:this.dirpath,maxdepth:10,...t};let r=new tt(O(e,this._skipNodes)).map(async e=>{this.log(`Preprocessing node:
31
+ `,H(e,128)),await U.resolveIncludes.call(this,e,t),await U.rebaseRelativePaths.call(this,e,t),await U.registerCustomElements.call(this,e,t),await U.resolveCustomElements.call(this,e,t)});return await Promise.all(r.generator()),n&&(this._perfData.lifecycle.preprocessTime=(this._perfData.lifecycle.preprocessTime??0)+(performance.now()-n)),e}async renderNode(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;for(let n of O(e,this._skipNodes))this.log(`Rendering node:
32
+ `,H(n,128)),await U.resolveForAttribute.call(this,n,t),await U.resolveRenderAttribute.call(this,n,t),await U.resolveDataAttribute.call(this,n,t),await U.resolveTextAttributes.call(this,n,t),await U.resolveHtmlAttribute.call(this,n,t),await U.resolveIfAttribute.call(this,n,t),await U.resolveShowAttribute.call(this,n,t),await U.resolveClassAttribute.call(this,n,t),await U.resolveBindAttribute.call(this,n,t),await U.resolveEventAttributes.call(this,n,t),await U.resolveTextNodeExpressions.call(this,n,t),await U.resolveCustomAttribute.call(this,n,t),await U.resolveCustomProperty.call(this,n,t),await U.stripTypes.call(this,n,t);for(let e of this._pendingValueRetries.splice(0))e();return n&&(this._perfData.lifecycle.renderTime=(this._perfData.lifecycle.renderTime??0)+(performance.now()-n)),e}async mount(e,t){let n=this.shouldLog(`lifecycle`)?performance.now():0;n&&this.clearPerformanceReport(),t={...t,rootNode:e},F(e,`renderer`,this),this._store.set(`$rootNode`,e),this.has(`$rootRenderer`)||this._store.set(`$rootRenderer`,this),this.get(`$rootRenderer`)===this&&await ut(this),await this.preprocessNode(e,t),await this.renderNode(e,t),He(e),n&&(this._perfData.lifecycle.mountTime=performance.now()-n)}};function qt(){return i([o`*,::before,::after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}`,o`html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal}`,o`body{margin:0;line-height:inherit}`,o`hr{height:0;color:inherit;border-top-width:1px}`,o`abbr:where([title]){text-decoration:underline dotted}`,o`b,strong{font-weight:bolder}`,o`code,kbd,samp,pre{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;font-size:1em}`,o`small{font-size:80%}`,o`sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}`,o`sub{bottom:-0.25em}`,o`sup{top:-0.5em}`,o`button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}`,o`button,select{text-transform:none}`,o`button,[type='button'],[type='reset'],[type='submit']{-webkit-appearance:button;background-color:transparent;background-image:none;cursor:pointer}`,o`:-moz-focusring{outline:auto}`,o`:-moz-ui-invalid{box-shadow:none}`,o`progress{vertical-align:baseline}`,o`::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}`,o`[type='search']{-webkit-appearance:textfield;outline-offset:-2px}`,o`::-webkit-search-decoration{-webkit-appearance:none}`,o`::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}`,o`summary{display:list-item}`,o`blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}`,o`fieldset{margin:0;padding:0}`,o`legend{padding:0}`,o`ol,ul,menu{list-style:none;margin:0;padding:0}`,o`textarea{resize:vertical}`,o`::placeholder{opacity:1;color:#9ca3af}`,o`button,[role="button"]{cursor:pointer}`,o`:disabled{cursor:default;pointer-events:none;opacity:0.75}`,o`img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}`,o`img,video{max-width:100%;height:auto}`,o`[hidden]{display:none}`,o`dialog{padding:0}`,o`dialog::backdrop{background:rgba(0,0,0,0.5)}`])}function Jt(){return i([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`}`])}var Yt=class extends Kt{impl=`browser`;dirpath=$e(globalThis.location?.href??`http://localhost/`);parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return new DOMParser().parseFromString(e,`text/html`);{let 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)}createComment(e,t){return(t||document).createComment(e)}textContent(e,t){e.textContent=t}};const Xt=new Yt;function Zt(e){for(let t of e){t=t.trim();let e=document.createElement(`style`);switch(t){case`minimal`:r.setTextContent(e,Jt());break;case`basic`:case`custom`:continue;case`utils`:{r.setTextContent(e,qt()),e.setAttribute(`data-mancha`,`basic`),globalThis.document.head.appendChild(e);let t=document.createElement(`style`);t.textContent=Ee(),t.setAttribute(`data-mancha`,`utils`),globalThis.document.head.appendChild(t),Be(document);continue}default:console.error(`Unknown style name: "${t}"`);continue}globalThis.document.head.appendChild(e)}}const $=`mancha-cloak`;function Qt(e,t){let n=`${e.join(`, `)} { opacity: 0 !important; ${t>0?`transition: opacity ${t}ms ease-in-out !important;`:``} }`,r=document.getElementById($);r||(r=document.createElement(`style`),r.id=$,document.head.appendChild(r)),r.textContent=n}function $t(e){let t=!1;return async()=>{if(t)return;t=!0;let n=document.getElementById($);if(n){if(e!==!1){let t=n.sheet;t&&t.cssRules.length>0&&t.cssRules[0].style.setProperty(`opacity`,`1`,`important`),await new Promise(t=>setTimeout(t,e))}typeof globalThis.requestAnimationFrame==`function`&&(await new Promise(e=>globalThis.requestAnimationFrame(e)),await new Promise(e=>globalThis.requestAnimationFrame(e))),n.remove()}}}async function en(e={}){let t;document.documentElement.classList.add(`mancha-loading`);let n=e.cloak?e.cloak===!0?{}:e.cloak:void 0;if(n){let r=e.target?Array.isArray(e.target)?e.target:[e.target]:[`body`],i=n.selector&&(Array.isArray(n.selector)||typeof n.selector==`string`)?Array.isArray(n.selector)?n.selector:[n.selector]:r,a=n.duration??0;Qt(i,a),t=$t(a>0?a:!1)}else t=$t(!1);document.readyState===`loading`&&await new Promise(e=>{window.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0})});let r=e.renderer??new Yt;if(e.css&&e.css.length>0&&Zt(e.css),e.debug&&r.debug(!0),e.state)for(let[t,n]of Object.entries(e.state))await r.set(t,n);try{if(e.callback)await e.callback(r);else if(e.target){let t=Array.isArray(e.target)?e.target:[e.target];for(let n of t){let t=globalThis.document.querySelector(n);t?await r.mount(t,{cache:e.cache}):console.error(`Target element not found: "${n}"`)}}}finally{document.documentElement.classList.remove(`mancha-loading`),t&&await t()}return r}export{Kt as IRenderer,Xt as Mancha,Yt as Renderer,qt as basicCssRules,en as initMancha,Zt as injectCss,Jt as minimalCssRules,Be as scanAndInject,Ee as utilsCssRules};
package/docs/05_css.md CHANGED
@@ -655,6 +655,25 @@ Two limitations:
655
655
  - **ESM only**: `scanAndInject` is exported from the module build, not from the global bundle loaded via a `<script>` tag.
656
656
  - **No shadow DOM**: `querySelectorAll` does not pierce a shadow root, so scanning a host element finds nothing inside it. Scanning the shadow root itself does inject rules, but they land in the main document's stylesheet, where shadow-boundary scoping stops them from applying. Style shadow content with its own stylesheet instead.
657
657
 
658
+ ## Getting the Rules as Text
659
+
660
+ `injectCss` appends the stylesheets to `document.head`, which is the right thing almost always. When you need the CSS itself rather than a style tag in the head, each stylesheet is also exported as a function returning its text:
661
+
662
+ ```js
663
+ import { basicCssRules, minimalCssRules, utilsCssRules } from "mancha/browser";
664
+
665
+ minimalCssRules(); // Same rules as injectCss(["minimal"]).
666
+ basicCssRules(); // The reset half of injectCss(["utils"]).
667
+ utilsCssRules(); // The utility-class half of injectCss(["utils"]).
668
+ ```
669
+
670
+ They take no arguments, touch no DOM, and return the same text on every call, so they can also run at build time or on the server. The two cases that need them:
671
+
672
+ - **Shadow DOM**: rules in `document.head` do not cross a shadow boundary, so give the shadow root its own stylesheet built from these.
673
+ - **Serving the CSS yourself**: write the text to a file at build time and link it, rather than shipping the rules inside the JavaScript bundle.
674
+
675
+ Note that these are the full stylesheets. Rules for custom values like `w-[200px]` are injected on demand as Mancha renders them and are not part of this text.
676
+
658
677
  ---
659
678
 
660
679
  *Generated automatically from `src/css_gen_utils.ts`*
package/docs/06_ssr.md CHANGED
@@ -58,7 +58,7 @@ For a more complete example, see [examples/express](../examples/express).
58
58
  For servers hosted as worker runtimes, such as `Cloudflare Workers`, you will need to import a stripped down version of `mancha` that does not have the ability to read local files.
59
59
 
60
60
  ```js
61
- import { Renderer } from "mancha/dist/worker.js";
61
+ import { Renderer } from "mancha/worker";
62
62
  import htmlIndex from "./index.html";
63
63
  import vars from "./vars.json";
64
64
 
@@ -28,6 +28,30 @@ renderer.$.user = { name: "Alice", email: "alice@example.com" };
28
28
 
29
29
  The `$` proxy provides typed access to store values. Without a type parameter, the store accepts any properties.
30
30
 
31
+ ## The Shared Renderer Type
32
+
33
+ Each entry point exports its own `Renderer`: `mancha` parses with jsdom, `mancha/browser` with the DOM, and `mancha/worker` with htmlparser2. All three extend `IRenderer`, which every entry point exports alongside them. It is the type to reach for when code has to work against whichever renderer it is handed — typically logic shared between the server and the client:
34
+
35
+ ```typescript
36
+ import type { IRenderer } from "mancha";
37
+
38
+ // Accepts the jsdom, browser and worker renderers alike.
39
+ async function renderPage(renderer: IRenderer, html: string): Promise<string> {
40
+ const fragment = renderer.parseHTML(html);
41
+ return renderer.serializeHTML(await renderer.renderNode(fragment));
42
+ }
43
+ ```
44
+
45
+ `IRenderer` is also the `this` type of `RendererPlugin`, so it is needed to annotate a plugin written as a standalone function:
46
+
47
+ ```typescript
48
+ import type { IRenderer, RendererPlugin } from "mancha";
49
+
50
+ const logNodes: RendererPlugin = function (this: IRenderer, node) {
51
+ console.log(this.impl, node.nodeName);
52
+ };
53
+ ```
54
+
31
55
  ## Type Checking (Experimental)
32
56
 
33
57
  **⚠️ This feature is experimental and may change in future versions.**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mancha",
3
- "version": "0.24.2",
3
+ "version": "0.25.0",
4
4
  "description": "Javscript HTML rendering engine",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -15,10 +15,11 @@
15
15
  "types": "./dist/browser.d.ts",
16
16
  "default": "./dist/browser.js"
17
17
  },
18
- "./dist/*.js": {
19
- "types": "./dist/*.d.ts",
20
- "default": "./dist/*.js"
21
- }
18
+ "./worker": {
19
+ "types": "./dist/worker.d.ts",
20
+ "default": "./dist/worker.js"
21
+ },
22
+ "./package.json": "./package.json"
22
23
  },
23
24
  "files": [
24
25
  "dist",