mancha 0.12.0 → 0.12.2

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
@@ -232,9 +232,9 @@ illustrated with an example:
232
232
  <!-- undefined -->
233
233
  <span>{{ message }}</span>
234
234
 
235
- <!-- How are you, danger? The secret message is "secret" -->
235
+ <!-- How are you, danger? The secret message is "secret" and the key is "1234" -->
236
236
  <p :data="{ name: 'danger', message: 'secret' }">
237
- How are you, {{ name }}? The secret message is: "{{ message }}"".
237
+ How are you, {{ name }}? The secret message is "{{ message }}" and the key is "{{ key }}"
238
238
  </p>
239
239
  </body>
240
240
  ```
@@ -266,18 +266,32 @@ const subrenderer = document.querySelector("p").renderer;
266
266
  subrenderer.$.message = "banana";
267
267
  ```
268
268
 
269
- To access variables defined in the parent renderer, you can use the subrenderer's `$parent`
270
- attribute:
269
+ When accessing variables, `mancha` searches the current renderer first, then the parent, the
270
+ parent's parent, and so forth until the root renderer is reached. If the requested variable is not
271
+ found in the current renderer or any of the ancestor renderers, then `null` is returned:
271
272
 
272
273
  ```html
273
274
  <body :data="{ name: 'stranger' }">
274
275
  <!-- Hello, stranger! -->
275
- <p :data="{}">Hello, {{ $parent.name }}!</p>
276
+ <p :data="{}">Hello, {{ name }}!</p>
276
277
  </body>
277
278
  ```
278
279
 
279
- Renderers also have a `$root` attribute, which references the root element where `mancha` was
280
- mounted and defaults to the document's body, unless explicitly provided.
280
+ When setting a variable, there are 3 possible cases:
281
+
282
+ 1. The variable has already been defined in the current renderer. Then it gets updated in the
283
+ current renderer.
284
+ 1. The variable is undefined in the current renderer but has already been defined in an ancestor
285
+ renderer. Then it gets updated in the corresponding ancestor renderer.
286
+ 1. The variable is not defined in the current renderer or any ancestor renderers. Then it is set in
287
+ the current renderer.
288
+
289
+ NOTE: This does not apply to variables defined via `:data` attribute, which always set a new
290
+ variable for the newly created renderer.
291
+
292
+ Renderers also have a `$parent` and `$root` attributes. The `$parent` attribute references the
293
+ immediate ancestor renderer if any, or it's `null` otherwise. The `$root` attribute references the
294
+ root renderer where `mancha` was mounted, which could be a self-reference.
281
295
 
282
296
  ## Styling
283
297
 
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var e={5883:(e,t,r)=>{r.d(t,{b:()=>i});r(4934);var s=r(8003);r(9825);function i(e){const t=e[0].toLowerCase();return(0,s.Sd)(t)}},5133:(e,t,r)=>{r(4934),r(7274),r(9825)},5114:(e,t,r)=>{r(7274),r(5611),r(9788)},8543:(e,t,r)=>{r(4934),r(723),r(5114),r(4184),r(9847),r(8245),r(4153),r(6691)},8527:(e,t,r)=>{r(723),r(8543),r(4153),r(6691)},9847:(e,t,r)=>{r(8526),r(4934),r(7274)},8245:(e,t,r)=>{var s;!function(e){e[e.STYLE_TAG=0]="STYLE_TAG",e[e.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",e[e.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}(s||(s={}))},4153:(e,t,r)=>{var s=r(1514),i=r(6691);const n=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],a=[["A",new Map([["href",{policyAction:i.He.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:i.He.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:i.He.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:i.He.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:i.He.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:i.He.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:i.He.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:i.He.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:i.He.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],o=["title","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-current","aria-disabled","aria-dropeffect","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-live","aria-multiline","aria-multiselectable","aria-orientation","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","alt","align","autocapitalize","autocomplete","autocorrect","autofocus","autoplay","bgcolor","border","cellpadding","cellspacing","checked","color","cols","colspan","controls","datetime","disabled","download","draggable","enctype","face","formenctype","frameborder","height","hreflang","hidden","ismap","label","lang","loop","max","maxlength","media","minlength","min","multiple","muted","nonce","open","placeholder","preload","rel","required","reversed","role","rows","rowspan","selected","shape","size","sizes","slot","span","spellcheck","start","step","summary","translate","type","valign","value","width","wrap","itemscope","itemtype","itemid","itemprop","itemref"],c=[["dir",{policyAction:i.He.KEEP_AND_NORMALIZE,conditions:(0,s.L)((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:i.He.KEEP_AND_NORMALIZE,conditions:(0,s.L)((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:i.He.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:i.He.KEEP_AND_NORMALIZE,conditions:(0,s.L)((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:i.He.KEEP_AND_SANITIZE_URL}],["target",{policyAction:i.He.KEEP_AND_NORMALIZE,conditions:(0,s.L)((()=>new Map([["target",new Set(["_self","_blank"])]])))}]];new i.uC(new Set(n),new Map(a),new Set(o),new Map(c)),new i.uC(new Set((0,s.L)((()=>n.concat(["STYLE"])))),new Map(a),new Set((0,s.L)((()=>o.concat(["id","name","class"])))),new Map((0,s.L)((()=>c.concat([["style",{policyAction:i.He.KEEP_AND_SANITIZE_STYLE}]])))))},6691:(e,t,r)=>{r.d(t,{He:()=>i,uC:()=>s});class s{constructor(e,t,r,s,i){this.allowedElements=e,this.elementPolicies=t,this.allowedGlobalAttributes=r,this.globalAttributePolicies=s,this.globallyAllowedAttributePrefixes=i}isAllowedElement(e){return"FORM"!==e&&(this.allowedElements.has(e)||this.elementPolicies.has(e))}getAttributePolicy(e,t){const r=this.elementPolicies.get(t);if(null==r?void 0:r.has(e))return r.get(e);if(this.allowedGlobalAttributes.has(e))return{policyAction:i.KEEP};const s=this.globalAttributePolicies.get(e);return s||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((t=>0===e.indexOf(t)))?{policyAction:i.KEEP}:{policyAction:i.DROP})}}var i;!function(e){e[e.DROP=0]="DROP",e[e.KEEP=1]="KEEP",e[e.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",e[e.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",e[e.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}(i||(i={}));new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"])},5619:(e,t,r)=>{r(4934),r(5611),r(9788),r(9825)},4780:(e,t,r)=>{r(4934),r(9788),r(9825)},448:(e,t,r)=>{r(4934),r(9825),r(3116)},4184:(e,t,r)=>{r.d(t,{Bi:()=>n});r(4934);const s=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function i(e){if(!function(e){const t=!s.test(e);return t}(e))return e}function n(e){return i(e)}},791:(e,t,r)=>{r.r(t),r.d(t,{setHref:()=>i});var s=r(4184);function i(e,t){const r=(0,s.Bi)(t);void 0!==r&&(e.href=r)}},4007:(e,t,r)=>{r.r(t),r.d(t,{setHref:()=>i});var s=r(4184);function i(e,t){const r=(0,s.Bi)(t);void 0!==r&&(e.href=r)}},7411:(e,t,r)=>{r(5611)},9334:(e,t,r)=>{r(4184)},2320:(e,t,r)=>{r.r(t),r.d(t,{buildPrefixedAttributeSetter:()=>c,insertAdjacentHtml:()=>o,setInnerHtml:()=>n,setOuterHtml:()=>a,setPrefixedAttribute:()=>l});r(4934);var s=r(8003),i=r(7274);function n(e,t){(function(e){return 1===e.nodeType})(e)&&h(e),e.innerHTML=(0,i.$_)(t)}function a(e,t){const r=e.parentElement;null!==r&&h(r),e.outerHTML=(0,i.$_)(t)}function o(e,t,r){const s="beforebegin"===t||"afterend"===t?e.parentElement:e;null!==s&&h(s),e.insertAdjacentHTML(t,(0,i.$_)(r))}function c(e,...t){const r=[e,...t];return(e,t,s)=>{l(r,e,t,s)}}function l(e,t,r,i){if(0===e.length){throw new Error("")}const n=e.map((e=>(0,s._j)(e))),a=r.toLowerCase();if(n.every((e=>0!==a.indexOf(e))))throw new Error(`Attribute "${r}" does not match any of the allowed prefixes.`);t.setAttribute(r,i)}function h(e){const t=e.tagName;if("SCRIPT"===t||"STYLE"===t)throw new Error("")}},7573:(e,t,r)=>{r(5611)},8944:(e,t,r)=>{r(4184)},8774:(e,t,r)=>{r(7274),r(5611)},4444:(e,t,r)=>{r(4184)},7854:(e,t,r)=>{r(4184),r(5611)},3881:(e,t,r)=>{r(5611)},169:(e,t,r)=>{r(5611),r(9788),r(8259)},9997:(e,t,r)=>{r(3116)},1926:(e,t,r)=>{r(4934)},2506:(e,t,r)=>{r(4184),r(4934)},2898:(e,t,r)=>{r(7274)},6225:(e,t,r)=>{r(4934),r(7274)},3183:(e,t,r)=>{r(7274),r(5611),r(9788),r(3116);Error},6716:(e,t,r)=>{r(9788),r(3183)},1332:(e,t,r)=>{r(4184)},8526:(e,t,r)=>{r(7274)},285:(e,t,r)=>{r(5611)},8259:(e,t,r)=>{r(4184)},2089:(e,t,r)=>{r(5611)},4744:(e,t,r)=>{r.d(t,{Cw:()=>i,Om:()=>n,aS:()=>s});var s=r(791),i=r(4007),n=(r(7411),r(9334),r(2320));r(7573),r(8944),r(8774),r(4444),r(7854),r(3881),r(169),r(9997),r(1926),r(2506),r(2898),r(6225),r(6716),r(1332),r(8526),r(285),r(8259),r(2089)},4934:()=>{},9743:(e,t,r)=>{r.d(t,{bc:()=>s.b});var s=r(5883);r(5133),r(5114),r(8543),r(8527),r(5619),r(4780),r(448),r(8003),r(7274),r(5611),r(9788),r(3116)},8003:(e,t,r)=>{r.d(t,{Sd:()=>a,_j:()=>o});r(4934);var s=r(723);class i{constructor(e,t){this.privateDoNotAccessOrElseWrappedAttributePrefix=t}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const n=i;function a(e){return new n(s.I,e)}function o(e){if(function(e){return e instanceof i}(e))return e.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}},7274:(e,t,r)=>{r.d(t,{$_:()=>a});r(4934);var s=r(723),i=r(7539);class n{constructor(e,t){(0,s.q)(t),this.privateDoNotAccessOrElseWrappedHtml=e}toString(){return this.privateDoNotAccessOrElseWrappedHtml.toString()}}"undefined"!=typeof window&&window.TrustedHTML;function a(e){var t;if(null===(t=(0,i.Xi)())||void 0===t?void 0:t.isHTML(e))return e;if(e instanceof n)return e.privateDoNotAccessOrElseWrappedHtml;throw new Error("")}},1514:(e,t,r)=>{function s(e){return{valueOf:e}.valueOf()}r.d(t,{L:()=>s})},5611:(e,t,r)=>{r(4934),r(723),r(7539);"undefined"!=typeof window&&window.TrustedScriptURL},9788:(e,t,r)=>{r(4934),r(723),r(7539);"undefined"!=typeof window&&window.TrustedScript},723:(e,t,r)=>{r.d(t,{I:()=>s,q:()=>i});r(4934);const s={};function i(e){0}},9825:(e,t,r)=>{function s(e){return Object.isFrozen(e)&&Object.isFrozen(e.raw)}function i(e){return-1===e.toString().indexOf("`")}i((e=>e``))||i((e=>e`\0`))||i((e=>e`\n`))||i((e=>e`\u0000`)),s``&&s`\0`&&s`\n`&&s`\u0000`},3116:(e,t,r)=>{r(4934),r(723)},7539:(e,t,r)=>{r.d(t,{Xi:()=>i});let s="google#safe";function i(){var e;return""!==s&&null!==(e=function(){if("undefined"!=typeof window)return window.trustedTypes}())&&void 0!==e?e:null}}},t={};function r(s){var i=t[s];if(void 0!==i)return i.exports;var n=t[s]={exports:{}};return e[s](n,n.exports,r),n.exports}r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};class s{iterable;constructor(e){this.iterable=e}filter(e){return new s(s.filterGenerator(e,this.iterable))}map(e){return new s(s.mapGenerator(e,this.iterable))}find(e){for(const t of this.iterable)if(e(t))return t}array(){return Array.from(this.iterable)}*generator(){for(const e of this.iterable)yield e}static*filterGenerator(e,t){for(const r of t)e(r)&&(yield r)}static*mapGenerator(e,t){for(const r of t)yield e(r)}static equals(e,t){const r=e[Symbol.iterator](),s=t[Symbol.iterator]();let i=r.next(),n=s.next();for(;!i.done&&!n.done;){if(i.value!==n.value)return!1;i=r.next(),n=s.next()}return i.done===n.done}}var i=r(4744),n=r(9743);const a=[n.bc`:`,n.bc`style`,n.bc`class`];function*o(e,t=new Set){const r=new Set,s=Array.from(e.childNodes).filter((e=>!t.has(e)));for(yield e;s.length;){const e=s.shift();r.has(e)||(r.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter((e=>!t.has(e))).forEach((e=>s.push(e)))}}function c(e,t){return void 0!==e?.[t]}function l(e,t){return"function"==typeof e?.[t]}function h(e){return e.replace(/-./g,(e=>e[1].toUpperCase()))}function u(e,t){return c(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function d(e,t,r=""){return u(e,r+t)||(e.dataset?.[h(t)]??null)}function p(e,t,r){c(e,"attribs")?e.attribs[t]=r:e.setAttribute?.(t,r)}function f(e,t,r){c(e,"attribs")?e.attribs[t]=r:i.Om.setPrefixedAttribute(a,e,t,r)}function _(e,t,r){switch(t){case"disabled":return void(e.disabled=r);case"selected":return void(e.selected=r);case"checked":return void(e.checked=r);default:e[t]=r}}function m(e,t){c(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function E(e,t,r=""){m(e,`${r}${t}`),m(e,`data-${t}`)}function v(e,t,r){if(c(e,"attribs")&&c(t,"attribs"))t.attribs[r]=e.attribs[r];else if(r.startsWith("data-")){const s=h(r.slice(5));t.dataset[s]=e.dataset?.[s]}else{const s=e?.getAttribute?.(r);f(t,r,s||"")}}function g(e){if(c(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find((e=>1===e.nodeType))}function w(e,...t){if(l(e,"replaceWith"))return e.replaceWith(...t);{const r=e,s=r.parentNode,i=Array.from(s.childNodes).indexOf(r);t.forEach((e=>e.parentNode=s)),s.childNodes=[].concat(Array.from(s.childNodes).slice(0,i)).concat(t).concat(Array.from(s.childNodes).slice(i+1))}}function A(e,...t){l(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function y(e,t){return l(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function R(e,t){return l(t,"removeChild")?e.removeChild(t):(A(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function O(e,t,r){return r?l(e,"insertBefore")?e.insertBefore(t,r):(w(r,t,r),t):y(e,t)}function b(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function I(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map((e=>I(e,t))).join(""):b(e.outerHTML||e.nodeValue||String(e),t)}function N(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}var x;!function(e){e.resolveIncludes=async function(e,t){const r=e,s=r.tagName?.toLowerCase();if(!["include","link"].includes(s))return;if("link"===s&&"subresource"!==u(r,"rel"))return;this.log("include directive found in:\n",I(e,128)),this.log("include params:",t);const i="link"===r.tagName.toLocaleLowerCase()?"href":"src",n=u(r,i);if(!n)throw new Error(`"${i}" attribute missing from ${I(e,128)}.`);const a=[];"include"===s&&a.push("src"),"link"===s&&a.push("rel","href");const o=t=>{const s=g(t);for(const e of Array.from(r.attributes))s&&!a.includes(e.name)&&v(r,s,e.name);w(e,...t.childNodes)},c={...t,rootDocument:!1,maxdepth:t?.maxdepth-1};if(0===c.maxdepth)throw new Error("Maximum recursion depth reached.");if(n.includes("://")||n.startsWith("//"))this.log("Including remote file from absolute path:",n),await this.preprocessRemote(n,c).then(o);else if(t?.dirpath?.includes("://")||t?.dirpath?.startsWith("//")){const e=n.startsWith("/")?n:`${t.dirpath}/${n}`;this.log("Including remote file from relative path:",e),await this.preprocessRemote(e,c).then(o)}else if("/"===n.charAt(0))this.log("Including local file from absolute path:",n),await this.preprocessLocal(n,c).then(o);else{const e=t?.dirpath&&"."!==t?.dirpath?`${t?.dirpath}/${n}`:n;this.log("Including local file from relative path:",e),await this.preprocessLocal(e,c).then(o)}},e.rebaseRelativePaths=async function(e,t){const r=e,s=r.tagName?.toLowerCase();if(!t?.dirpath)return;const n=u(r,"src"),a=u(r,"href"),o=n||a;if(!o||((l=o).includes("://")||l.startsWith("/")||l.startsWith("#")||l.startsWith("data:")))return;var l;const h=`${t.dirpath}/${o}`;this.log("Rebasing relative path as:",h),c(r,"attribs")?f(r,n?"src":"href",h):"img"===s?r.src=h:"a"===s?i.aS.setHref(r,h):"source"===s||"audio"===s||"video"===s||"track"===s||"input"===s?r.src=h:"area"===s?i.Cw.setHref(r,h):this.log("Unable to rebase relative path for element:",s)},e.registerCustomElements=async function(e,t){const r=e,s=r.tagName?.toLowerCase(),i=(u(r,"is")||u(r,"alt"))?.toLowerCase();if(["template","div"].includes(s)&&i){if("div"===s&&"template"!==u(r,"role"))return;this._customElements.has(i)||(this.log(`Registering custom element: ${i}\n`,I(r,128)),this._customElements.set(i,r),R(r.parentNode,r))}},e.resolveCustomElements=async function(e,t){const r=e,i=r.tagName?.toLowerCase();let n=i;if("div"===n&&(n=u(r,"role")?.toLowerCase()||n),n&&this._customElements.has(n)){this.log(`Processing custom element: ${n}\n`,I(r,128));const t=this._customElements.get(n),a=(t.content||t).cloneNode(!0),c=g(a);if(c)for(const e of Array.from(r.attributes))"div"===i&&"role"===e.name||v(r,c,e.name);const l=new s(o(a)).find((e=>"slot"===e.tagName?.toLowerCase()));l&&w(l,...r.childNodes),w(e,...a.childNodes)}},e.resolveTextNodeExpressions=async function(e,t){const r=e.nodeValue||"";if(3!==e.nodeType||!r?.trim())return;this.log("Processing node content value:\n",b(r,128));const s=new RegExp(/{{ ([^}]+) }}/gm),i=Array.from(r.matchAll(s)).map((e=>e[1]));return this.effect((function(){let t=r;for(const r of i){const s=this.eval(r,{$elem:e});t=t.replace(`{{ ${r} }}`,String(s))}e.nodeValue=t}))},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,s=d(r,"data",":");if(s){this.log(":data attribute found in:\n",I(e,128)),E(r,"data",":");const i=t?.rootNode===e?this:this.subrenderer();e.renderer=i;const n=i.eval(s,{$elem:e});if(await Promise.all(Object.entries(n).map((([e,t])=>i.set(e,t)))),i!==this)for(const t of o(e,this._skipNodes))this._skipNodes.add(t);await i.mount(e,t)}},e.resolveClassAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,s=d(r,"class",":");if(s){this.log(":class attribute found in:\n",I(e,128)),E(r,"class",":");const t=u(r,"class")||"";return this.effect((function(){const i=this.eval(s,{$elem:e});f(r,"class",(i?`${t} ${i}`:t).trim())}))}},e.resolveTextAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e,s=d(r,"text",":");if(s){this.log(":text attribute found in:\n",I(e,128)),E(r,"text",":");const t=t=>this.textContent(e,t);return this.effect((function(){t(this.eval(s,{$elem:e}))}))}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,s=d(r,"html",":");return s?(this.log(":html attribute found in:\n",I(e,128)),E(r,"html",":"),this.effect((function(){const i=this.eval(s,{$elem:e});return new Promise((async e=>{const s=await this.preprocessString(i,t);await this.renderNode(s),A(r,s),e()}))}))):void 0},e.resolveEventAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){const s=t.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!s)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",I(e,128)),m(r,t.name);const i="submit"===s&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(s,(r=>(i&&r.preventDefault(),this.eval(t.value,{$elem:e,$event:r}))))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,s=d(r,"for",":")?.trim();if(s){this.log(":for attribute found in:\n",I(e,128)),E(r,"for",":");for(const t of o(e,this._skipNodes))this._skipNodes.add(t);const i=e.parentNode,n=this.createElement("template",e.ownerDocument);O(i,n,e),R(i,e),y(n,e),this.log(":for template:\n",I(n,128));const a=s.split(" in ",2);if(2!==a.length)throw new Error(`Invalid :for format: \`${s}\`. Expected "{key} in {expression}".`);const c=[],[l,h]=a;await this.effect((function(){const r=this.eval(h,{$elem:e});if(this.log(":for list items:",r),c.splice(0,c.length).forEach((e=>{R(i,e),this._skipNodes.delete(e)})),!Array.isArray(r))return console.error(`Expression did not yield a list: \`${h}\` => \`${r}\``),Promise.resolve();const s=[];for(const i of r){const r=this.subrenderer();r.set(l,i);const n=e.cloneNode(!0);c.push(n),this._skipNodes.add(n),s.push(r.mount(n,t)),this.log("Rendered list child:\n",I(n,128))}const a=n.nextSibling;for(const e of c)O(i,e,a);return Promise.all(s)}))}},e.resolveBindAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,s=d(r,"bind",":");if(s){this.log(":bind attribute found in:\n",I(e,128));const t=["change","input"],i=u(r,":bind:on")?.split(",")||r.dataset.bindOn?.split(",")||t;E(r,"bind",":"),m(r,":bind:on"),m(r,"data-bind-on");const n="checkbox"===u(r,"type")?"checked":"value";this.effect((function(){const t=this.eval(s,{$elem:e});r[n]=t}));const a=`${s} = $elem.${n}`;for(const t of i)e.addEventListener(t,(()=>this.eval(a,{$elem:e})))}},e.resolveShowAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,s=d(r,"show",":");if(s){this.log(":show attribute found in:\n",I(e,128)),E(r,"show",":");const t="none"===r.style?.display?"":r.style?.display??u(r,"style")?.split(";")?.find((e=>"display"===e.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const i=this.eval(s,{$elem:e});r.style?r.style.display=i?t:"none":f(r,"style",`display: ${i?t:"none"};`)}))}},e.resolveCustomAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const s=":attr:",i="data-attr-";if(t.name.startsWith(s)||t.name.startsWith(i)){this.log(t.name,"attribute found in:\n",I(e,128)),m(r,t.name);const n=t.name.split(s,2).at(-1)?.split(i,2).at(-1);this.effect((function(){const s=this.eval(t.value,{$elem:e});p(r,n,s)}))}}},e.resolveCustomProperty=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const s=":prop:",i="data-prop-";if(t.name.startsWith(s)||t.name.startsWith(i)){this.log(t.name,"property found in:\n",I(e,128)),m(r,t.name);const n=t.name.split(s,2).at(-1)?.split(i,2).at(-1),a=h(n);this.effect((function(){const s=this.eval(t.value,{$elem:e});_(r,a,s)}))}}}}(x||(x={}));const T=["this"],P=["+","-","!"],S=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],L={"!":0,":":0,",":0,")":0,"]":0,"}":0,"|>":1,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"{":13},C=["==","!=","<=",">=","||","&&","??","|>"],k=["===","!=="];var D;!function(e){e[e.STRING=1]="STRING",e[e.IDENTIFIER=2]="IDENTIFIER",e[e.DOT=3]="DOT",e[e.COMMA=4]="COMMA",e[e.COLON=5]="COLON",e[e.INTEGER=6]="INTEGER",e[e.DECIMAL=7]="DECIMAL",e[e.OPERATOR=8]="OPERATOR",e[e.GROUPER=9]="GROUPER",e[e.KEYWORD=10]="KEYWORD",e[e.ARROW=11]="ARROW"}(D||(D={}));const U=(e,t,r=0)=>({kind:e,value:t,precedence:r}),M=e=>95===e||36===e||65<=(e&=-33)&&e<=90,$=e=>48<=e&&e<=57;class F{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;9===(e=this._next)||10===e||13===e||32===e;)this._advance(!0);var e;if((e=>34===e||39===e)(this._next))return this._tokenizeString();if(M(this._next))return this._tokenizeIdentOrKeyword();if($(this._next))return this._tokenizeNumber();if(46===this._next)return this._tokenizeDot();if(44===this._next)return this._tokenizeComma();if(58===this._next)return this._tokenizeColon();if((e=>43===e||45===e||42===e||47===e||33===e||38===e||37===e||60===e||61===e||62===e||63===e||94===e||124===e)(this._next))return this._tokenizeOperator();if((e=>40===e||41===e||91===e||93===e||123===e||125===e)(this._next))return this._tokenizeGrouper();if(this._advance(),void 0!==this._next)throw new Error(`Expected end of input, got ${this._next}`)}_advance(e){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),!0===e&&(this._tokenStart=this._index)):this._next=void 0}_getValue(e=0){const t=this._input.substring(this._tokenStart,this._index+e);return 0===e&&this._clearValue(),t}_clearValue(){this._tokenStart=this._index}_tokenizeString(){const e="unterminated string",t=this._next;for(this._advance(!0);this._next!==t;){if(void 0===this._next)throw new Error(e);if(92===this._next&&(this._advance(),void 0===this._next))throw new Error(e);this._advance()}const r=U(D.STRING,this._getValue().replace(/\\(.)/g,((e,t)=>{switch(t){case"n":return"\n";case"r":return"\r";case"t":return"\t";case"b":return"\b";case"f":return"\f";default:return t}})));return this._advance(),r}_tokenizeIdentOrKeyword(){do{this._advance()}while(e=this._next,M(e)||$(e));var e;const t=this._getValue(),r=(s=t,-1!==T.indexOf(s)?D.KEYWORD:D.IDENTIFIER);var s;return U(r,t)}_tokenizeNumber(){do{this._advance()}while($(this._next));return 46===this._next?this._tokenizeDot():U(D.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),$(this._next)?this._tokenizeFraction():(this._clearValue(),U(D.DOT,".",13))}_tokenizeComma(){return this._advance(!0),U(D.COMMA,",")}_tokenizeColon(){return this._advance(!0),U(D.COLON,":")}_tokenizeFraction(){do{this._advance()}while($(this._next));return U(D.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(-1!==k.indexOf(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),U(D.ARROW,e);-1!==C.indexOf(e)&&this._advance()}return e=this._getValue(),U(D.OPERATOR,e,L[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=U(D.GROUPER,e,L[e]);return this._advance(!0),t}}class G{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new F(e),this._ast=t}parse(){return this._advance(),this._parseExpression()}_advance(e,t){if(!this._matches(e,t))throw new Error(`Expected kind ${e} (${t}), was ${this._token?.kind} (${this._token?.value})`);const r=this._tokenizer.nextToken();this._token=r,this._kind=r?.kind,this._value=r?.value}_matches(e,t){return!(e&&this._kind!==e||t&&this._value!==t)}_parseExpression(){if(!this._token)return this._ast.empty();const e=this._parseUnary();return void 0===e?void 0:this._parsePrecedence(e,0)}_parsePrecedence(e,t){if(void 0===e)throw new Error("Expected left to be defined.");for(;this._token;)if(this._matches(D.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(D.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(D.DOT)){this._advance();const t=this._parseUnary();e=this._makeInvokeOrGetter(e,t)}else{if(this._matches(D.KEYWORD))break;if(!(this._matches(D.OPERATOR)&&this._token.precedence>=t))break;e="?"===this._value?this._parseTernary(e):this._parseBinary(e,this._token)}return e}_makeInvokeOrGetter(e,t){if(void 0===t)throw new Error("expected identifier");if("ID"===t.type)return this._ast.getter(e,t.value);if("Invoke"===t.type&&"ID"===t.receiver.type){const r=t.receiver;return this._ast.invoke(e,r.value,t.arguments)}throw new Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(-1===S.indexOf(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let r=this._parseUnary();for(;(this._kind===D.OPERATOR||this._kind===D.DOT||this._kind===D.GROUPER)&&this._token.precedence>t.precedence;)r=this._parsePrecedence(r,this._token.precedence);return this._ast.binary(e,t.value,r)}_parseUnary(){if(this._matches(D.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(D.INTEGER))return this._parseInteger(e);if(this._matches(D.DECIMAL))return this._parseDecimal(e)}if(-1===P.indexOf(e))throw new Error(`unexpected token: ${e}`);const t=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(e,t)}return this._parsePrimary()}_parseTernary(e){this._advance(D.OPERATOR,"?");const t=this._parseExpression();this._advance(D.COLON);const r=this._parseExpression();return this._ast.ternary(e,t,r)}_parsePrimary(){switch(this._kind){case D.KEYWORD:const e=this._value;if("this"===e)return this._advance(),this._ast.id(e);if(-1!==T.indexOf(e))throw new Error(`unexpected keyword: ${e}`);throw new Error(`unrecognized keyword: ${e}`);case D.IDENTIFIER:return this._parseInvokeOrIdentifier();case D.STRING:return this._parseString();case D.INTEGER:return this._parseInteger();case D.DECIMAL:return this._parseDecimal();case D.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case D.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(D.GROUPER,"]"))break;e.push(this._parseExpression())}while(this._matches(D.COMMA));return this._advance(D.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e={};do{if(this._advance(),this._matches(D.GROUPER,"}"))break;const t=this._value;(this._matches(D.STRING)||this._matches(D.IDENTIFIER))&&this._advance(),this._advance(D.COLON),e[t]=this._parseExpression()}while(this._matches(D.COMMA));return this._advance(D.GROUPER,"}"),this._ast.map(e)}_parseInvokeOrIdentifier(){const e=this._value;if("true"===e)return this._advance(),this._ast.literal(!0);if("false"===e)return this._advance(),this._ast.literal(!1);if("null"===e)return this._advance(),this._ast.literal(null);if("undefined"===e)return this._advance(),this._ast.literal(void 0);const t=this._parseIdentifier(),r=this._parseArguments();return r?this._ast.invoke(t,void 0,r):t}_parseIdentifier(){if(!this._matches(D.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(D.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(D.GROUPER,")"))break;const t=this._parseExpression();e.push(t)}while(this._matches(D.COMMA));return this._advance(D.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(D.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(D.ARROW)){this._advance();const t=this._parseExpression(),r=e?.map((e=>e.value))??[];return this._ast.arrowFunction(r,t)}return this._ast.paren(e[0])}_parseString(){const e=this._ast.literal(this._value);return this._advance(),e}_parseInteger(e=""){const t=this._ast.literal(parseInt(`${e}${this._value}`,10));return this._advance(),t}_parseDecimal(e=""){const t=this._ast.literal(parseFloat(`${e}${this._value}`));return this._advance(),t}}const H={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,"||":(e,t)=>e||t,"&&":(e,t)=>e&&t,"??":(e,t)=>e??t,"|":(e,t)=>t(e),"|>":(e,t)=>t(e)},K={"+":e=>e,"-":e=>-e,"!":e=>!e};class z{timeouts=new Map;debounce(e,t){return new Promise(((r,s)=>{const i=this.timeouts.get(t);i&&clearTimeout(i),this.timeouts.set(t,setTimeout((()=>{try{r(t()),this.timeouts.delete(t)}catch(e){s(e)}}),e))}))}}const W=new class{empty(){return{type:"Empty",evaluate:e=>e,getIds:e=>e}}literal(e){return{type:"Literal",value:e,evaluate(e){return this.value},getIds:e=>e}}id(e){return{type:"ID",value:e,evaluate(e){return"this"===this.value?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(e,t){const r=K[e];return{type:"Unary",operator:e,child:t,evaluate(e){return r(this.child.evaluate(e))},getIds(e){return this.child.getIds(e)}}}binary(e,t,r){const s=H[t];return{type:"Binary",operator:t,left:e,right:r,evaluate(e){if("="===this.operator){if("ID"!==this.left.type&&"Getter"!==this.left.type&&"Index"!==this.left.type)throw new Error(`Invalid assignment target: ${this.left}`);const t=this.right.evaluate(e);let r,s;return"Getter"===this.left.type?(r=this.left.receiver.evaluate(e),s=this.left.name):"Index"===this.left.type?(r=this.left.receiver.evaluate(e),s=this.left.argument.evaluate(e)):"ID"===this.left.type&&(r=e,s=this.left.value),void 0===r?void 0:r[s]=t}return s(this.left.evaluate(e),this.right.evaluate(e))},getIds(e){return this.left.getIds(e),this.right.getIds(e),e}}}getter(e,t){return{type:"Getter",receiver:e,name:t,evaluate(e){return this.receiver.evaluate(e)?.[this.name]},getIds(e){return this.receiver.getIds(e),e}}}invoke(e,t,r){if(null!=t&&"string"!=typeof t)throw new Error("method not a string");return{type:"Invoke",receiver:e,method:t,arguments:r,evaluate(e){const r=this.receiver.evaluate(e),s=this.method?r:e?.this??e,i=this.method?r?.[t]:r,n=(this.arguments??[]).map((t=>t?.evaluate(e)));return i?.apply?.(s,n)},getIds(e){return this.receiver.getIds(e),this.arguments?.forEach((t=>t?.getIds(e))),e}}}paren(e){return e}index(e,t){return{type:"Index",receiver:e,argument:t,evaluate(e){return this.receiver.evaluate(e)?.[this.argument.evaluate(e)]},getIds(e){return this.receiver.getIds(e),e}}}ternary(e,t,r){return{type:"Ternary",condition:e,trueExpr:t,falseExpr:r,evaluate(e){return this.condition.evaluate(e)?this.trueExpr.evaluate(e):this.falseExpr.evaluate(e)},getIds(e){return this.condition.getIds(e),this.trueExpr.getIds(e),this.falseExpr.getIds(e),e}}}map(e){return{type:"Map",entries:e,evaluate(t){const r={};if(e&&this.entries)for(const s in e){const e=this.entries[s];e&&(r[s]=e.evaluate(t))}return r},getIds(t){if(e&&this.entries)for(const r in e){const e=this.entries[r];e&&e.getIds(t)}return t}}}list(e){return{type:"List",items:e,evaluate(e){return this.items?.map((t=>t?.evaluate(e)))},getIds(e){return this.items?.forEach((t=>t?.getIds(e))),e}}}arrowFunction(e,t){return{type:"ArrowFunction",params:e,body:t,evaluate(e){const t=this.params,r=this.body;return function(...s){const i=Object.fromEntries(t.map(((e,t)=>[e,s[t]]))),n=new Proxy(e??{},{set:(e,t,r)=>(i.hasOwnProperty(t)&&(i[t]=r),e[t]=r),get:(e,t)=>i.hasOwnProperty(t)?i[t]:e[t]});return r.evaluate(n)}},getIds(e){return this.body.getIds(e).filter((e=>!this.params.includes(e)))}}}};function B(e,t){if(e.has(t))return e.get(t);if(e.has("$parent")){return B(e.get("$parent"),t)}return null}function Y(e,t){if(e.has(t))return e;if(e.has("$parent")){return Y(e.get("$parent"),t)}return null}class j extends z{evalkeys=["$elem","$event"];expressionCache=new Map;store=new Map;observers=new Map;_observer=null;_lock=Promise.resolve();constructor(e){super();for(let[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof j||r.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>r in e&&(delete e[r],t(),!0),set:(r,s,i,n)=>{"object"==typeof i&&null!=e&&(i=this.wrapObject(i,t));const a=Reflect.set(r,s,i,n);return t(),a},get:(e,t,r)=>"__is_proxy__"===t||Reflect.get(e,t,r)});var r}watch(e,t){this.observers.has(e)||this.observers.set(e,new Set),this.observers.get(e)?.has(t)||this.observers.get(e)?.add(t)}async notify(e,t=10){const r=Array.from(this.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(r.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),B(this.store,e)}async set(e,t){if(t===this.store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const s=Y(e,t);s?s.set(t,r):e.set(t,r)}(this.store,e,t),await r()}del(e){this.store.delete(e),this.observers.delete(e)}has(e){return this.store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this.store.entries()).map((([e])=>e)),r=Object.fromEntries(t.map((e=>[e,void 0])));return new Proxy(r,{get:(t,r,s)=>"string"==typeof r&&Y(this.store,r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,s),set:(e,t,r,s)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,s):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes(" = ")){const[r,s]=e.split(" = ");t=r.trim(),e=s.trim()}return(r,s)=>{const i=((e,t)=>new G(e,t).parse())(e,W),n=i?.getIds([])?.map((e=>[e,s[e]??r[e]??globalThis[e]])),a=i?.evaluate(Object.fromEntries(n||[]));if(!t)return a;r[t]=a}}cachedExpressionFunction(e){return e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e)),this.expressionCache.get(e)}eval(e,t={}){const r=this._observer?this:this.$;if(this.store.has(e))return r[e];{const s=this.cachedExpressionFunction(e);try{return s(r,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}}class V extends j{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(e){return this.debugging=e,this}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??"default"}).then((e=>e.text()))}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log("Preprocessing string content with params:\n",t);const r=this.parseHTML(e,t);return await this.preprocessNode(r,t),r}async preprocessRemote(e,t){const r={};t?.cache&&(r.cache=t.cache);const s=await fetch(e,r).then((e=>e.text()));return this.preprocessString(s,{...t,dirpath:N(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}async preprocessLocal(e,t){const r=await this.fetchLocal(e,t);return this.preprocessString(r,{...t,dirpath:N(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}subrenderer(){const e=(new this.constructor).debug(this.debugging);return e.set("$parent",this),e.set("$root",this.get("$root")??this),e._customElements=this._customElements,e}log(...e){this.debugging&&console.debug(...e)}async preprocessNode(e,t){t={dirpath:this.dirpath,maxdepth:10,...t};const r=new s(o(e,this._skipNodes)).map((async e=>{this.log("Preprocessing node:\n",I(e,128)),await x.resolveIncludes.call(this,e,t),await x.rebaseRelativePaths.call(this,e,t),await x.registerCustomElements.call(this,e,t),await x.resolveCustomElements.call(this,e,t)}));return await Promise.all(r.generator()),e}async renderNode(e,t){for(const r of o(e,this._skipNodes))this.log("Rendering node:\n",I(r,128)),await x.resolveForAttribute.call(this,r,t),await x.resolveDataAttribute.call(this,r,t),await x.resolveTextAttributes.call(this,r,t),await x.resolveHtmlAttribute.call(this,r,t),await x.resolveShowAttribute.call(this,r,t),await x.resolveClassAttribute.call(this,r,t),await x.resolveBindAttribute.call(this,r,t),await x.resolveEventAttributes.call(this,r,t),await x.resolveTextNodeExpressions.call(this,r,t),await x.resolveCustomAttribute.call(this,r,t),await x.resolveCustomProperty.call(this,r,t);return e}async mount(e,t){t={...t,rootNode:e},await this.preprocessNode(e,t),await this.renderNode(e,t),_(e,"renderer",this)}}new class extends V{impl="browser";dirpath=N(globalThis.location?.href??"http://localhost/");parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return(new DOMParser).parseFromString(e,"text/html");{const t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}})();
@@ -1,22 +1,21 @@
1
- import { safeStyleSheet } from "safevalues";
1
+ import { concatStyleSheets, safeStyleSheet } from "safevalues";
2
2
  export default function rules() {
3
3
  // Based on https://www.swyx.io/css-100-bytes.
4
- return safeStyleSheet `
5
- html {
6
- max-width: 70ch;
7
- padding: 2em 1em;
8
- margin: auto;
9
- line-height: 1.75;
10
- font-size: 1.25em;
11
- font-family: sans-serif;
12
- }
13
-
14
- h1,h2,h3,h4,h5,h6 {
15
- margin: 1em 0 0.5em;
16
- }
17
-
18
- p,ul,ol {
19
- margin-bottom: 1em;
20
- color: #1d1d1d;
21
- }`;
4
+ return concatStyleSheets([
5
+ safeStyleSheet `html{`,
6
+ safeStyleSheet `max-width: 70ch;`,
7
+ safeStyleSheet `padding: 2em 1em;`,
8
+ safeStyleSheet `margin: auto;`,
9
+ safeStyleSheet `line-height: 1.75;`,
10
+ safeStyleSheet `font-size: 1.25em;`,
11
+ safeStyleSheet `font-family: sans-serif;`,
12
+ safeStyleSheet `}`,
13
+ safeStyleSheet `h1,h2,h3,h4,h5,h6{`,
14
+ safeStyleSheet `margin: 1em 0 0.5em;`,
15
+ safeStyleSheet `}`,
16
+ safeStyleSheet `p,ul,ol{`,
17
+ safeStyleSheet `margin-bottom: 1em;`,
18
+ safeStyleSheet `color: #1d1d1d;`,
19
+ safeStyleSheet `}`,
20
+ ]);
22
21
  }
@@ -116,6 +116,8 @@ const PROPS_CUSTOM = {
116
116
  "overflow-x-auto": { "overflow-x": "auto" },
117
117
  "overflow-y-auto": { "overflow-y": "auto" },
118
118
  "overflow-hidden": { overflow: "hidden" },
119
+ "overflow-x-hidden": { "overflow-x": "hidden" },
120
+ "overflow-y-hidden": { "overflow-y": "hidden" },
119
121
  "overflow-visible": { overflow: "visible" },
120
122
  // Cursors.
121
123
  "cursor-pointer": { cursor: "pointer" },
@@ -483,9 +485,15 @@ function autoxy(props) {
483
485
  // Zero y-axis.
484
486
  [`${klass}y-0`, `${prop}-top: 0; ${prop}-bottom: 0;`],
485
487
  // Positive REM units x-axis.
486
- ...UNITS_ALL.map((v) => [v, v * REM_UNIT]).map(([k, v]) => [`${klass}x-${k}`, `${prop}-left: ${v}rem; ${prop}-right: ${v}rem;`]),
488
+ ...UNITS_ALL.map((v) => [v, v * REM_UNIT]).map(([k, v]) => [
489
+ `${klass}x-${k}`,
490
+ `${prop}-left: ${v}rem; ${prop}-right: ${v}rem;`,
491
+ ]),
487
492
  // Positive REM units y-axis.
488
- ...UNITS_ALL.map((v) => [v, v * REM_UNIT]).map(([k, v]) => [`${klass}y-${k}`, `${prop}-top: ${v}rem; ${prop}-bottom: ${v}rem;`]),
493
+ ...UNITS_ALL.map((v) => [v, v * REM_UNIT]).map(([k, v]) => [
494
+ `${klass}y-${k}`,
495
+ `${prop}-top: ${v}rem; ${prop}-bottom: ${v}rem;`,
496
+ ]),
489
497
  // Positive PX units x-axis.
490
498
  ...UNITS_ALL.map((v) => [`${klass}x-${v}px`, `${prop}-left: ${v}px; ${prop}-right: ${v}px;`]),
491
499
  // Positive PX units y-axis.
@@ -583,9 +591,15 @@ function between() {
583
591
  // Zero for y margin.
584
592
  [`space-y-0 > *`, `margin-top: 0`],
585
593
  // Positive REM units for x margin.
586
- ...UNITS_ALL.map((v) => [`space-x-${v} > :not(:first-child)`, `margin-left: ${v * REM_UNIT}rem`]),
594
+ ...UNITS_ALL.map((v) => [
595
+ `space-x-${v} > :not(:first-child)`,
596
+ `margin-left: ${v * REM_UNIT}rem`,
597
+ ]),
587
598
  // Positive REM units for y margin.
588
- ...UNITS_ALL.map((v) => [`space-y-${v} > :not(:first-child)`, `margin-top: ${v * REM_UNIT}rem`]),
599
+ ...UNITS_ALL.map((v) => [
600
+ `space-y-${v} > :not(:first-child)`,
601
+ `margin-top: ${v * REM_UNIT}rem`,
602
+ ]),
589
603
  // Positive PX units for x margin.
590
604
  ...UNITS_ALL.map((v) => [`space-x-${v}px > :not(:first-child)`, `margin-left: ${v}px`]),
591
605
  // Positive PX units for y margin.
package/dist/mancha.js CHANGED
@@ -1,18 +1 @@
1
- (()=>{"use strict";const e=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function t(t){if(!function(t){const r=!e.test(t);return r}(t))return t}function r(e){return t(e)}const i={};function n(e){0}"undefined"!=typeof window&&window.TrustedScriptURL;class s{constructor(e,t){this.privateDoNotAccessOrElseWrappedAttributePrefix=t}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const o=s;function a(e){if(function(e){return e instanceof s}(e))return e.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}"undefined"!=typeof window&&window.TrustedHTML;function l(e,t,r,i){if(0===e.length){throw new Error("")}const n=e.map((e=>a(e))),s=r.toLowerCase();if(n.every((e=>0!==s.indexOf(e))))throw new Error(`Attribute "${r}" does not match any of the allowed prefixes.`);t.setAttribute(r,i)}"undefined"!=typeof window&&window.TrustedScript;class c{}class h extends c{constructor(e,t){super(),n(),this.privateDoNotAccessOrElseWrappedStyleSheet=e}toString(){return this.privateDoNotAccessOrElseWrappedStyleSheet}}function u(e,t){e.textContent=function(e){if(e instanceof h)return e.privateDoNotAccessOrElseWrappedStyleSheet;throw new Error("")}(t)}Error;class d{iterable;constructor(e){this.iterable=e}filter(e){return new d(d.filterGenerator(e,this.iterable))}map(e){return new d(d.mapGenerator(e,this.iterable))}find(e){for(const t of this.iterable)if(e(t))return t}array(){return Array.from(this.iterable)}*generator(){for(const e of this.iterable)yield e}static*filterGenerator(e,t){for(const r of t)e(r)&&(yield r)}static*mapGenerator(e,t){for(const r of t)yield e(r)}static equals(e,t){const r=e[Symbol.iterator](),i=t[Symbol.iterator]();let n=r.next(),s=i.next();for(;!n.done&&!s.done;){if(n.value!==s.value)return!1;n=r.next(),s=i.next()}return n.done===s.done}}function p(e){return Object.isFrozen(e)&&Object.isFrozen(e.raw)}function f(e){return-1===e.toString().indexOf("`")}f((e=>e``))||f((e=>e`\0`))||f((e=>e`\n`))||f((e=>e`\u0000`)),p``&&p`\0`&&p`\n`&&p`\u0000`;function m(e){const t=e[0].toLowerCase();return new o(i,t)}var _,$;function g(e){return{valueOf:e}.valueOf()}!function(e){e[e.STYLE_TAG=0]="STYLE_TAG",e[e.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",e[e.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}(_||(_={}));class v{constructor(e,t,r,i,n){this.allowedElements=e,this.elementPolicies=t,this.allowedGlobalAttributes=r,this.globalAttributePolicies=i,this.globallyAllowedAttributePrefixes=n}isAllowedElement(e){return"FORM"!==e&&(this.allowedElements.has(e)||this.elementPolicies.has(e))}getAttributePolicy(e,t){const r=this.elementPolicies.get(t);if(null==r?void 0:r.has(e))return r.get(e);if(this.allowedGlobalAttributes.has(e))return{policyAction:$.KEEP};const i=this.globalAttributePolicies.get(e);return i||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((t=>0===e.indexOf(t)))?{policyAction:$.KEEP}:{policyAction:$.DROP})}}!function(e){e[e.DROP=0]="DROP",e[e.KEEP=1]="KEEP",e[e.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",e[e.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",e[e.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}($||($={}));new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const b=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],E=[["A",new Map([["href",{policyAction:$.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:$.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],x=["title","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-current","aria-disabled","aria-dropeffect","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-live","aria-multiline","aria-multiselectable","aria-orientation","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","alt","align","autocapitalize","autocomplete","autocorrect","autofocus","autoplay","bgcolor","border","cellpadding","cellspacing","checked","color","cols","colspan","controls","datetime","disabled","download","draggable","enctype","face","formenctype","frameborder","height","hreflang","hidden","ismap","label","lang","loop","max","maxlength","media","minlength","min","multiple","muted","nonce","open","placeholder","preload","rel","required","reversed","role","rows","rowspan","selected","shape","size","sizes","slot","span","spellcheck","start","step","summary","translate","type","valign","value","width","wrap","itemscope","itemtype","itemid","itemprop","itemref"],w=[["dir",{policyAction:$.KEEP_AND_NORMALIZE,conditions:g((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:$.KEEP_AND_NORMALIZE,conditions:g((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:$.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:$.KEEP_AND_NORMALIZE,conditions:g((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:$.KEEP_AND_SANITIZE_URL}],["target",{policyAction:$.KEEP_AND_NORMALIZE,conditions:g((()=>new Map([["target",new Set(["_self","_blank"])]])))}]];new v(new Set(b),new Map(E),new Set(x),new Map(w)),new v(new Set(g((()=>b.concat(["STYLE"])))),new Map(E),new Set(g((()=>x.concat(["id","name","class"])))),new Map(g((()=>w.concat([["style",{policyAction:$.KEEP_AND_SANITIZE_STYLE}]])))));function y(e){return function(e){return new h(e,i)}(e[0])}const A=[m`:`,m`style`,m`class`];function*O(e,t=new Set){const r=new Set,i=Array.from(e.childNodes).filter((e=>!t.has(e)));for(yield e;i.length;){const e=i.shift();r.has(e)||(r.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter((e=>!t.has(e))).forEach((e=>i.push(e)))}}function R(e,t){return void 0!==e?.[t]}function I(e,t){return"function"==typeof e?.[t]}function N(e){return e.replace(/-./g,(e=>e[1].toUpperCase()))}function T(e,t){return R(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function S(e,t,r=""){return T(e,r+t)||(e.dataset?.[N(t)]??null)}function P(e,t,r){R(e,"attribs")?e.attribs[t]=r:e.setAttribute?.(t,r)}function k(e,t,r){R(e,"attribs")?e.attribs[t]=r:l(A,e,t,r)}function C(e,t,r){switch(t){case"disabled":return void(e.disabled=r);case"selected":return void(e.selected=r);case"checked":return void(e.checked=r);default:e[t]=r}}function L(e,t){R(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function D(e,t,r=""){L(e,`${r}${t}`),L(e,`data-${t}`)}function M(e,t,r){if(R(e,"attribs")&&R(t,"attribs"))t.attribs[r]=e.attribs[r];else if(r.startsWith("data-")){const i=N(r.slice(5));t.dataset[i]=e.dataset?.[i]}else{const i=e?.getAttribute?.(r);k(t,r,i||"")}}function U(e){if(R(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find((e=>1===e.nodeType))}function j(e,...t){if(I(e,"replaceWith"))return e.replaceWith(...t);{const r=e,i=r.parentNode,n=Array.from(i.childNodes).indexOf(r);t.forEach((e=>e.parentNode=i)),i.childNodes=[].concat(Array.from(i.childNodes).slice(0,n)).concat(t).concat(Array.from(i.childNodes).slice(n+1))}}function F(e,...t){I(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function z(e,t){return I(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function G(e,t){return I(t,"removeChild")?e.removeChild(t):(F(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function K(e,t,r){return r?I(e,"insertBefore")?e.insertBefore(t,r):(j(r,t,r),t):z(e,t)}function W(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function Y(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map((e=>Y(e,t))).join(""):W(e.outerHTML||e.nodeValue||String(e),t)}function B(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}var H;!function(e){e.resolveIncludes=async function(e,t){const r=e,i=r.tagName?.toLowerCase();if(!["include","link"].includes(i))return;if("link"===i&&"subresource"!==T(r,"rel"))return;this.log("include directive found in:\n",Y(e,128)),this.log("include params:",t);const n="link"===r.tagName.toLocaleLowerCase()?"href":"src",s=T(r,n);if(!s)throw new Error(`"${n}" attribute missing from ${Y(e,128)}.`);const o=[];"include"===i&&o.push("src"),"link"===i&&o.push("rel","href");const a=t=>{const i=U(t);for(const e of Array.from(r.attributes))i&&!o.includes(e.name)&&M(r,i,e.name);j(e,...t.childNodes)},l={...t,rootDocument:!1,maxdepth:t?.maxdepth-1};if(0===l.maxdepth)throw new Error("Maximum recursion depth reached.");if(s.includes("://")||s.startsWith("//"))this.log("Including remote file from absolute path:",s),await this.preprocessRemote(s,l).then(a);else if(t?.dirpath?.includes("://")||t?.dirpath?.startsWith("//")){const e=s.startsWith("/")?s:`${t.dirpath}/${s}`;this.log("Including remote file from relative path:",e),await this.preprocessRemote(e,l).then(a)}else if("/"===s.charAt(0))this.log("Including local file from absolute path:",s),await this.preprocessLocal(s,l).then(a);else{const e=t?.dirpath&&"."!==t?.dirpath?`${t?.dirpath}/${s}`:s;this.log("Including local file from relative path:",e),await this.preprocessLocal(e,l).then(a)}},e.rebaseRelativePaths=async function(e,t){const i=e,n=i.tagName?.toLowerCase();if(!t?.dirpath)return;const s=T(i,"src"),o=T(i,"href"),a=s||o;if(!a||((l=a).includes("://")||l.startsWith("/")||l.startsWith("#")||l.startsWith("data:")))return;var l;const c=`${t.dirpath}/${a}`;this.log("Rebasing relative path as:",c),R(i,"attribs")?k(i,s?"src":"href",c):"img"===n?i.src=c:"a"===n?function(e,t){const i=r(t);void 0!==i&&(e.href=i)}(i,c):"source"===n||"audio"===n||"video"===n||"track"===n||"input"===n?i.src=c:"area"===n?function(e,t){const i=r(t);void 0!==i&&(e.href=i)}(i,c):this.log("Unable to rebase relative path for element:",n)},e.registerCustomElements=async function(e,t){const r=e,i=r.tagName?.toLowerCase(),n=(T(r,"is")||T(r,"alt"))?.toLowerCase();if(["template","div"].includes(i)&&n){if("div"===i&&"template"!==T(r,"role"))return;this._customElements.has(n)||(this.log(`Registering custom element: ${n}\n`,Y(r,128)),this._customElements.set(n,r),G(r.parentNode,r))}},e.resolveCustomElements=async function(e,t){const r=e,i=r.tagName?.toLowerCase();let n=i;if("div"===n&&(n=T(r,"role")?.toLowerCase()||n),n&&this._customElements.has(n)){this.log(`Processing custom element: ${n}\n`,Y(r,128));const t=this._customElements.get(n),s=(t.content||t).cloneNode(!0),o=U(s);if(o)for(const e of Array.from(r.attributes))"div"===i&&"role"===e.name||M(r,o,e.name);const a=new d(O(s)).find((e=>"slot"===e.tagName?.toLowerCase()));a&&j(a,...r.childNodes),j(e,...s.childNodes)}},e.resolveTextNodeExpressions=async function(e,t){const r=e.nodeValue||"";if(3!==e.nodeType||!r?.trim())return;this.log("Processing node content value:\n",W(r,128));const i=new RegExp(/{{ ([^}]+) }}/gm),n=Array.from(r.matchAll(i)).map((e=>e[1]));return this.effect((function(){let t=r;for(const r of n){const i=this.eval(r,{$elem:e});t=t.replace(`{{ ${r} }}`,String(i))}e.nodeValue=t}))},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=S(r,"data",":");if(i){this.log(":data attribute found in:\n",Y(e,128)),D(r,"data",":");const n=t?.rootNode===e?this:this.subrenderer();e.renderer=n;const s=n.eval(i,{$elem:e});if(await Promise.all(Object.entries(s).map((([e,t])=>n.set(e,t)))),n!==this)for(const t of O(e,this._skipNodes))this._skipNodes.add(t);await n.mount(e,t)}},e.resolveClassAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=S(r,"class",":");if(i){this.log(":class attribute found in:\n",Y(e,128)),D(r,"class",":");const t=T(r,"class")||"";return this.effect((function(){const n=this.eval(i,{$elem:e});k(r,"class",(n?`${t} ${n}`:t).trim())}))}},e.resolveTextAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=S(r,"text",":");if(i){this.log(":text attribute found in:\n",Y(e,128)),D(r,"text",":");const t=t=>this.textContent(e,t);return this.effect((function(){t(this.eval(i,{$elem:e}))}))}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=S(r,"html",":");return i?(this.log(":html attribute found in:\n",Y(e,128)),D(r,"html",":"),this.effect((function(){const n=this.eval(i,{$elem:e});return new Promise((async e=>{const i=await this.preprocessString(n,t);await this.renderNode(i),F(r,i),e()}))}))):void 0},e.resolveEventAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){const i=t.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!i)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",Y(e,128)),L(r,t.name);const n="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,(r=>(n&&r.preventDefault(),this.eval(t.value,{$elem:e,$event:r}))))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=S(r,"for",":")?.trim();if(i){this.log(":for attribute found in:\n",Y(e,128)),D(r,"for",":");for(const t of O(e,this._skipNodes))this._skipNodes.add(t);const n=e.parentNode,s=this.createElement("template",e.ownerDocument);K(n,s,e),G(n,e),z(s,e),this.log(":for template:\n",Y(s,128));const o=i.split(" in ",2);if(2!==o.length)throw new Error(`Invalid :for format: \`${i}\`. Expected "{key} in {expression}".`);const a=[],[l,c]=o;await this.effect((function(){const r=this.eval(c,{$elem:e});if(this.log(":for list items:",r),a.splice(0,a.length).forEach((e=>{G(n,e),this._skipNodes.delete(e)})),!Array.isArray(r))return console.error(`Expression did not yield a list: \`${c}\` => \`${r}\``),Promise.resolve();const i=[];for(const n of r){const r=this.subrenderer();r.set(l,n);const s=e.cloneNode(!0);a.push(s),this._skipNodes.add(s),i.push(r.mount(s,t)),this.log("Rendered list child:\n",Y(s,128))}const o=s.nextSibling;for(const e of a)K(n,e,o);return Promise.all(i)}))}},e.resolveBindAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=S(r,"bind",":");if(i){this.log(":bind attribute found in:\n",Y(e,128));const t=["change","input"],n=T(r,":bind:on")?.split(",")||r.dataset.bindOn?.split(",")||t;D(r,"bind",":"),L(r,":bind:on"),L(r,"data-bind-on");const s="checkbox"===T(r,"type")?"checked":"value";this.effect((function(){const t=this.eval(i,{$elem:e});r[s]=t}));const o=`${i} = $elem.${s}`;for(const t of n)e.addEventListener(t,(()=>this.eval(o,{$elem:e})))}},e.resolveShowAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=S(r,"show",":");if(i){this.log(":show attribute found in:\n",Y(e,128)),D(r,"show",":");const t="none"===r.style?.display?"":r.style?.display??T(r,"style")?.split(";")?.find((e=>"display"===e.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const n=this.eval(i,{$elem:e});r.style?r.style.display=n?t:"none":k(r,"style",`display: ${n?t:"none"};`)}))}},e.resolveCustomAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":attr:",n="data-attr-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"attribute found in:\n",Y(e,128)),L(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1);this.effect((function(){const i=this.eval(t.value,{$elem:e});P(r,s,i)}))}}},e.resolveCustomProperty=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":prop:",n="data-prop-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"property found in:\n",Y(e,128)),L(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1),o=N(s);this.effect((function(){const i=this.eval(t.value,{$elem:e});C(r,o,i)}))}}}}(H||(H={}));const V=["this"],Z=["+","-","!"],q=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],Q={"!":0,":":0,",":0,")":0,"]":0,"}":0,"|>":1,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"{":13},X=["==","!=","<=",">=","||","&&","??","|>"],J=["===","!=="];var ee;!function(e){e[e.STRING=1]="STRING",e[e.IDENTIFIER=2]="IDENTIFIER",e[e.DOT=3]="DOT",e[e.COMMA=4]="COMMA",e[e.COLON=5]="COLON",e[e.INTEGER=6]="INTEGER",e[e.DECIMAL=7]="DECIMAL",e[e.OPERATOR=8]="OPERATOR",e[e.GROUPER=9]="GROUPER",e[e.KEYWORD=10]="KEYWORD",e[e.ARROW=11]="ARROW"}(ee||(ee={}));const te=(e,t,r=0)=>({kind:e,value:t,precedence:r}),re=e=>95===e||36===e||65<=(e&=-33)&&e<=90,ie=e=>48<=e&&e<=57;class ne{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;9===(e=this._next)||10===e||13===e||32===e;)this._advance(!0);var e;if((e=>34===e||39===e)(this._next))return this._tokenizeString();if(re(this._next))return this._tokenizeIdentOrKeyword();if(ie(this._next))return this._tokenizeNumber();if(46===this._next)return this._tokenizeDot();if(44===this._next)return this._tokenizeComma();if(58===this._next)return this._tokenizeColon();if((e=>43===e||45===e||42===e||47===e||33===e||38===e||37===e||60===e||61===e||62===e||63===e||94===e||124===e)(this._next))return this._tokenizeOperator();if((e=>40===e||41===e||91===e||93===e||123===e||125===e)(this._next))return this._tokenizeGrouper();if(this._advance(),void 0!==this._next)throw new Error(`Expected end of input, got ${this._next}`)}_advance(e){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),!0===e&&(this._tokenStart=this._index)):this._next=void 0}_getValue(e=0){const t=this._input.substring(this._tokenStart,this._index+e);return 0===e&&this._clearValue(),t}_clearValue(){this._tokenStart=this._index}_tokenizeString(){const e="unterminated string",t=this._next;for(this._advance(!0);this._next!==t;){if(void 0===this._next)throw new Error(e);if(92===this._next&&(this._advance(),void 0===this._next))throw new Error(e);this._advance()}const r=te(ee.STRING,this._getValue().replace(/\\(.)/g,((e,t)=>{switch(t){case"n":return"\n";case"r":return"\r";case"t":return"\t";case"b":return"\b";case"f":return"\f";default:return t}})));return this._advance(),r}_tokenizeIdentOrKeyword(){do{this._advance()}while(e=this._next,re(e)||ie(e));var e;const t=this._getValue(),r=(i=t,-1!==V.indexOf(i)?ee.KEYWORD:ee.IDENTIFIER);var i;return te(r,t)}_tokenizeNumber(){do{this._advance()}while(ie(this._next));return 46===this._next?this._tokenizeDot():te(ee.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),ie(this._next)?this._tokenizeFraction():(this._clearValue(),te(ee.DOT,".",13))}_tokenizeComma(){return this._advance(!0),te(ee.COMMA,",")}_tokenizeColon(){return this._advance(!0),te(ee.COLON,":")}_tokenizeFraction(){do{this._advance()}while(ie(this._next));return te(ee.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(-1!==J.indexOf(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),te(ee.ARROW,e);-1!==X.indexOf(e)&&this._advance()}return e=this._getValue(),te(ee.OPERATOR,e,Q[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=te(ee.GROUPER,e,Q[e]);return this._advance(!0),t}}class se{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new ne(e),this._ast=t}parse(){return this._advance(),this._parseExpression()}_advance(e,t){if(!this._matches(e,t))throw new Error(`Expected kind ${e} (${t}), was ${this._token?.kind} (${this._token?.value})`);const r=this._tokenizer.nextToken();this._token=r,this._kind=r?.kind,this._value=r?.value}_matches(e,t){return!(e&&this._kind!==e||t&&this._value!==t)}_parseExpression(){if(!this._token)return this._ast.empty();const e=this._parseUnary();return void 0===e?void 0:this._parsePrecedence(e,0)}_parsePrecedence(e,t){if(void 0===e)throw new Error("Expected left to be defined.");for(;this._token;)if(this._matches(ee.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(ee.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(ee.DOT)){this._advance();const t=this._parseUnary();e=this._makeInvokeOrGetter(e,t)}else{if(this._matches(ee.KEYWORD))break;if(!(this._matches(ee.OPERATOR)&&this._token.precedence>=t))break;e="?"===this._value?this._parseTernary(e):this._parseBinary(e,this._token)}return e}_makeInvokeOrGetter(e,t){if(void 0===t)throw new Error("expected identifier");if("ID"===t.type)return this._ast.getter(e,t.value);if("Invoke"===t.type&&"ID"===t.receiver.type){const r=t.receiver;return this._ast.invoke(e,r.value,t.arguments)}throw new Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(-1===q.indexOf(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let r=this._parseUnary();for(;(this._kind===ee.OPERATOR||this._kind===ee.DOT||this._kind===ee.GROUPER)&&this._token.precedence>t.precedence;)r=this._parsePrecedence(r,this._token.precedence);return this._ast.binary(e,t.value,r)}_parseUnary(){if(this._matches(ee.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(ee.INTEGER))return this._parseInteger(e);if(this._matches(ee.DECIMAL))return this._parseDecimal(e)}if(-1===Z.indexOf(e))throw new Error(`unexpected token: ${e}`);const t=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(e,t)}return this._parsePrimary()}_parseTernary(e){this._advance(ee.OPERATOR,"?");const t=this._parseExpression();this._advance(ee.COLON);const r=this._parseExpression();return this._ast.ternary(e,t,r)}_parsePrimary(){switch(this._kind){case ee.KEYWORD:const e=this._value;if("this"===e)return this._advance(),this._ast.id(e);if(-1!==V.indexOf(e))throw new Error(`unexpected keyword: ${e}`);throw new Error(`unrecognized keyword: ${e}`);case ee.IDENTIFIER:return this._parseInvokeOrIdentifier();case ee.STRING:return this._parseString();case ee.INTEGER:return this._parseInteger();case ee.DECIMAL:return this._parseDecimal();case ee.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case ee.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(ee.GROUPER,"]"))break;e.push(this._parseExpression())}while(this._matches(ee.COMMA));return this._advance(ee.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e={};do{if(this._advance(),this._matches(ee.GROUPER,"}"))break;const t=this._value;(this._matches(ee.STRING)||this._matches(ee.IDENTIFIER))&&this._advance(),this._advance(ee.COLON),e[t]=this._parseExpression()}while(this._matches(ee.COMMA));return this._advance(ee.GROUPER,"}"),this._ast.map(e)}_parseInvokeOrIdentifier(){const e=this._value;if("true"===e)return this._advance(),this._ast.literal(!0);if("false"===e)return this._advance(),this._ast.literal(!1);if("null"===e)return this._advance(),this._ast.literal(null);if("undefined"===e)return this._advance(),this._ast.literal(void 0);const t=this._parseIdentifier(),r=this._parseArguments();return r?this._ast.invoke(t,void 0,r):t}_parseIdentifier(){if(!this._matches(ee.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(ee.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(ee.GROUPER,")"))break;const t=this._parseExpression();e.push(t)}while(this._matches(ee.COMMA));return this._advance(ee.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(ee.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(ee.ARROW)){this._advance();const t=this._parseExpression(),r=e?.map((e=>e.value))??[];return this._ast.arrowFunction(r,t)}return this._ast.paren(e[0])}_parseString(){const e=this._ast.literal(this._value);return this._advance(),e}_parseInteger(e=""){const t=this._ast.literal(parseInt(`${e}${this._value}`,10));return this._advance(),t}_parseDecimal(e=""){const t=this._ast.literal(parseFloat(`${e}${this._value}`));return this._advance(),t}}const oe={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,"||":(e,t)=>e||t,"&&":(e,t)=>e&&t,"??":(e,t)=>e??t,"|":(e,t)=>t(e),"|>":(e,t)=>t(e)},ae={"+":e=>e,"-":e=>-e,"!":e=>!e};class le{timeouts=new Map;debounce(e,t){return new Promise(((r,i)=>{const n=this.timeouts.get(t);n&&clearTimeout(n),this.timeouts.set(t,setTimeout((()=>{try{r(t()),this.timeouts.delete(t)}catch(e){i(e)}}),e))}))}}const ce=new class{empty(){return{type:"Empty",evaluate:e=>e,getIds:e=>e}}literal(e){return{type:"Literal",value:e,evaluate(e){return this.value},getIds:e=>e}}id(e){return{type:"ID",value:e,evaluate(e){return"this"===this.value?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(e,t){const r=ae[e];return{type:"Unary",operator:e,child:t,evaluate(e){return r(this.child.evaluate(e))},getIds(e){return this.child.getIds(e)}}}binary(e,t,r){const i=oe[t];return{type:"Binary",operator:t,left:e,right:r,evaluate(e){if("="===this.operator){if("ID"!==this.left.type&&"Getter"!==this.left.type&&"Index"!==this.left.type)throw new Error(`Invalid assignment target: ${this.left}`);const t=this.right.evaluate(e);let r,i;return"Getter"===this.left.type?(r=this.left.receiver.evaluate(e),i=this.left.name):"Index"===this.left.type?(r=this.left.receiver.evaluate(e),i=this.left.argument.evaluate(e)):"ID"===this.left.type&&(r=e,i=this.left.value),void 0===r?void 0:r[i]=t}return i(this.left.evaluate(e),this.right.evaluate(e))},getIds(e){return this.left.getIds(e),this.right.getIds(e),e}}}getter(e,t){return{type:"Getter",receiver:e,name:t,evaluate(e){return this.receiver.evaluate(e)?.[this.name]},getIds(e){return this.receiver.getIds(e),e}}}invoke(e,t,r){if(null!=t&&"string"!=typeof t)throw new Error("method not a string");return{type:"Invoke",receiver:e,method:t,arguments:r,evaluate(e){const r=this.receiver.evaluate(e),i=this.method?r:e?.this??e,n=this.method?r?.[t]:r,s=(this.arguments??[]).map((t=>t?.evaluate(e)));return n?.apply?.(i,s)},getIds(e){return this.receiver.getIds(e),this.arguments?.forEach((t=>t?.getIds(e))),e}}}paren(e){return e}index(e,t){return{type:"Index",receiver:e,argument:t,evaluate(e){return this.receiver.evaluate(e)?.[this.argument.evaluate(e)]},getIds(e){return this.receiver.getIds(e),e}}}ternary(e,t,r){return{type:"Ternary",condition:e,trueExpr:t,falseExpr:r,evaluate(e){return this.condition.evaluate(e)?this.trueExpr.evaluate(e):this.falseExpr.evaluate(e)},getIds(e){return this.condition.getIds(e),this.trueExpr.getIds(e),this.falseExpr.getIds(e),e}}}map(e){return{type:"Map",entries:e,evaluate(t){const r={};if(e&&this.entries)for(const i in e){const e=this.entries[i];e&&(r[i]=e.evaluate(t))}return r},getIds(t){if(e&&this.entries)for(const r in e){const e=this.entries[r];e&&e.getIds(t)}return t}}}list(e){return{type:"List",items:e,evaluate(e){return this.items?.map((t=>t?.evaluate(e)))},getIds(e){return this.items?.forEach((t=>t?.getIds(e))),e}}}arrowFunction(e,t){return{type:"ArrowFunction",params:e,body:t,evaluate(e){const t=this.params,r=this.body;return function(...i){const n=Object.fromEntries(t.map(((e,t)=>[e,i[t]]))),s=new Proxy(e??{},{set:(e,t,r)=>(n.hasOwnProperty(t)&&(n[t]=r),e[t]=r),get:(e,t)=>n.hasOwnProperty(t)?n[t]:e[t]});return r.evaluate(s)}},getIds(e){return this.body.getIds(e).filter((e=>!this.params.includes(e)))}}}};function he(e,t){if(e.has(t))return e.get(t);if(e.has("$parent")){return he(e.get("$parent"),t)}return null}function ue(e,t){if(e.has(t))return e;if(e.has("$parent")){return ue(e.get("$parent"),t)}return null}class de extends le{evalkeys=["$elem","$event"];expressionCache=new Map;store=new Map;observers=new Map;_observer=null;_lock=Promise.resolve();constructor(e){super();for(let[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof de||r.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>r in e&&(delete e[r],t(),!0),set:(r,i,n,s)=>{"object"==typeof n&&null!=e&&(n=this.wrapObject(n,t));const o=Reflect.set(r,i,n,s);return t(),o},get:(e,t,r)=>"__is_proxy__"===t||Reflect.get(e,t,r)});var r}watch(e,t){this.observers.has(e)||this.observers.set(e,new Set),this.observers.get(e)?.has(t)||this.observers.get(e)?.add(t)}async notify(e,t=10){const r=Array.from(this.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(r.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),he(this.store,e)}async set(e,t){if(t===this.store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=ue(e,t);i?i.set(t,r):e.set(t,r)}(this.store,e,t),await r()}del(e){this.store.delete(e),this.observers.delete(e)}has(e){return this.store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this.store.entries()).map((([e])=>e)),r=Object.fromEntries(t.map((e=>[e,void 0])));return new Proxy(r,{get:(t,r,i)=>"string"==typeof r&&ue(this.store,r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes(" = ")){const[r,i]=e.split(" = ");t=r.trim(),e=i.trim()}return(r,i)=>{const n=((e,t)=>new se(e,t).parse())(e,ce),s=n?.getIds([])?.map((e=>[e,i[e]??r[e]??globalThis[e]])),o=n?.evaluate(Object.fromEntries(s||[]));if(!t)return o;r[t]=o}}cachedExpressionFunction(e){return e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e)),this.expressionCache.get(e)}eval(e,t={}){const r=this._observer?this:this.$;if(this.store.has(e))return r[e];{const i=this.cachedExpressionFunction(e);try{return i(r,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}}class pe extends de{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(e){return this.debugging=e,this}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??"default"}).then((e=>e.text()))}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log("Preprocessing string content with params:\n",t);const r=this.parseHTML(e,t);return await this.preprocessNode(r,t),r}async preprocessRemote(e,t){const r={};t?.cache&&(r.cache=t.cache);const i=await fetch(e,r).then((e=>e.text()));return this.preprocessString(i,{...t,dirpath:B(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}async preprocessLocal(e,t){const r=await this.fetchLocal(e,t);return this.preprocessString(r,{...t,dirpath:B(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}subrenderer(){const e=(new this.constructor).debug(this.debugging);return e.set("$parent",this),e.set("$root",this.get("$root")??this),e._customElements=this._customElements,e}log(...e){this.debugging&&console.debug(...e)}async preprocessNode(e,t){t={dirpath:this.dirpath,maxdepth:10,...t};const r=new d(O(e,this._skipNodes)).map((async e=>{this.log("Preprocessing node:\n",Y(e,128)),await H.resolveIncludes.call(this,e,t),await H.rebaseRelativePaths.call(this,e,t),await H.registerCustomElements.call(this,e,t),await H.resolveCustomElements.call(this,e,t)}));return await Promise.all(r.generator()),e}async renderNode(e,t){for(const r of O(e,this._skipNodes))this.log("Rendering node:\n",Y(r,128)),await H.resolveForAttribute.call(this,r,t),await H.resolveDataAttribute.call(this,r,t),await H.resolveTextAttributes.call(this,r,t),await H.resolveHtmlAttribute.call(this,r,t),await H.resolveShowAttribute.call(this,r,t),await H.resolveClassAttribute.call(this,r,t),await H.resolveBindAttribute.call(this,r,t),await H.resolveEventAttributes.call(this,r,t),await H.resolveTextNodeExpressions.call(this,r,t),await H.resolveCustomAttribute.call(this,r,t),await H.resolveCustomProperty.call(this,r,t);return e}async mount(e,t){t={...t,rootNode:e},await this.preprocessNode(e,t),await this.renderNode(e,t),C(e,"renderer",this)}}class fe extends pe{impl="browser";dirpath=B(globalThis.location?.href??"http://localhost/");parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return(new DOMParser).parseFromString(e,"text/html");{const t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}new fe;const me={sm:640,md:768,lg:1024,xl:1280},_e=.25,$e=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],ge=[...$e,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,112,128,144,160,192,224,256,288,320,384,448,512,...Object.values(me)],ve=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],be=["hover","focus","disabled","active"],Ee={margin:"m",padding:"p"},xe={width:"w",height:"h"},we={top:"top",right:"right",bottom:"bottom",left:"left"},ye={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},Ae={bold:{"font-weight":"bold"},semibold:{"font-weight":600},italic:{"font-style":"italic"},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"},"font-mono":{"font-family":"monospace"},"font-sans":{"font-family":"sans-serif"},"font-serif":{"font-family":"serif"},"font-cursive":{"font-family":"cursive"},"text-left":{"text-align":"left"},"text-right":{"text-align":"right"},"text-center":{"text-align":"center"},"text-justify":{"text-align":"justify"},truncate:{"white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis"},"text-elipsis":{"text-overflow":"ellipsis"},"text-clip":{"text-overflow":"clip"},"text-xs":{"font-size":".75rem"},"text-sm":{"font-size":".875rem"},"text-base":{"font-size":"1rem"},"text-lg":{"font-size":"1.125rem"},"text-xl":{"font-size":"1.25rem"},relative:{position:"relative"},fixed:{position:"fixed"},absolute:{position:"absolute"},sticky:{position:"sticky"},"object-contain":{"object-fit":"contain"},"object-cover":{"object-fit":"cover"},"object-fill":{"object-fit":"fill"},"object-none":{"object-fit":"none"},block:{display:"block"},contents:{display:"contents"},hidden:{display:"none"},inline:{display:"inline"},"inline-block":{display:"inline-block"},visible:{visibility:"visible"},invisible:{visibility:"hidden"},collapse:{visibility:"collapse"},"list-none":{"list-style-type":"none"},"list-disc":{"list-style-type":"disc"},"list-decimal":{"list-style-type":"decimal"},flex:{display:"flex"},"flex-1":{flex:"1 1 0%"},"flex-inline":{display:"inline-flex"},"flex-row":{"flex-direction":"row"},"flex-col":{"flex-direction":"column"},"flex-row-reverse":{"flex-direction":"row-reverse"},"flex-col-reverse":{"flex-direction":"column-reverse"},"flex-wrap":{"flex-wrap":"wrap"},"flex-wrap-reverse":{"flex-wrap":"wrap-reverse"},"flex-nowrap":{"flex-wrap":"nowrap"},"justify-start":{"justify-content":"flex-start"},"justify-end":{"justify-content":"flex-end"},"justify-center":{"justify-content":"center"},"justify-between":{"justify-content":"space-between"},"justify-around":{"justify-content":"space-around"},"justify-evenly":{"justify-content":"space-evenly"},"justify-stretch":{"justify-content":"stretch"},"items-start":{"align-items":"flex-start"},"items-end":{"align-items":"flex-end"},"items-center":{"align-items":"center"},"items-stretch":{"align-items":"stretch"},"flex-grow":{"flex-grow":1},"flex-shrink":{"flex-shrink":1},"overflow-auto":{overflow:"auto"},"overflow-x-auto":{"overflow-x":"auto"},"overflow-y-auto":{"overflow-y":"auto"},"overflow-hidden":{overflow:"hidden"},"overflow-visible":{overflow:"visible"},"cursor-pointer":{cursor:"pointer"},"cursor-wait":{cursor:"wait"},"cursor-not-allowed":{cursor:"not-allowed"},"select-none":{"user-select":"none"},"select-all":{"user-select":"all"},"pointer-events-auto":{"pointer-events":"auto"},"pointer-events-none":{"pointer-events":"none"},"box-border":{"box-sizing":"border-box"},"box-content":{"box-sizing":"content-box"},resize:{resize:"both"},"resize-x":{resize:"horizontal"},"resize-y":{resize:"vertical"},"resize-none":{resize:"none"},border:{border:"1px solid"},"border-none":{border:"none"},"border-solid":{"border-style":"solid"},"border-dashed":{"border-style":"dashed"},"border-dotted":{"border-style":"dotted"},"border-collapse":{"border-collapse":"collapse"},"rounded-none":{"border-radius":"0"},rounded:{"border-radius":".25rem"},"rounded-sm":{"border-radius":".125rem"},"rounded-md":{"border-radius":".375rem"},"rounded-lg":{"border-radius":".5rem"},"rounded-xl":{"border-radius":".75rem"},"rounded-full":{"border-radius":"9999px"},shadow:{"box-shadow":"0 0 1px 0 rgba(0, 0, 0, 0.05)"},"shadow-sm":{"box-shadow":"0 1px 2px 0 rgba(0, 0, 0, 0.05)"},"shadow-md":{"box-shadow":"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},"shadow-lg":{"box-shadow":"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},"shadow-xl":{"box-shadow":"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)"},"shadow-2xl":{"box-shadow":"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},"shadow-inner":{"box-shadow":"inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)"},"shadow-outline":{"box-shadow":"0 0 0 3px rgba(66, 153, 225, 0.5)"},"shadow-none":{"box-shadow":"none"},"transition-none":{transition:"none"},transition:{transition:"all 150ms ease-in-out"},"animate-none":{animation:"none"},"animate-spin":{animation:"spin 1s linear infinite"},"animate-ping":{animation:"ping 1s cubic-bezier(0, 0, 0.2, 1) infinite"},"animate-pulse":{animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}},Oe=["@keyframes spin {\n from { transform: rotate(0deg) }\n to { transform: rotate(360deg) }\n }","@keyframes ping {\n 75%, 100% {\n transform: scale(2);\n opacity: 0;\n }\n }","@keyframes pulse {\n 0%, 100% { opacity: 1 }\n 50% { opacity: .5 }\n }"],Re={red:{50:16772078,100:16764370,200:15702682,300:15037299,400:15684432,500:16007990,600:15022389,700:13840175,800:12986408,900:12000284},pink:{50:16573676,100:16301008,200:16027569,300:15753874,400:15483002,500:15277667,600:14162784,700:12720219,800:11342935,900:8916559},purple:{50:15984117,100:14794471,200:13538264,300:12216520,400:11225020,500:10233776,600:9315498,700:8069026,800:6953882,900:4854924},"deep-purple":{50:15591414,100:13747433,200:11771355,300:9795021,400:8280002,500:6765239,600:6174129,700:5320104,800:4532128,900:3218322},indigo:{50:15264502,100:12962537,200:10463450,300:7964363,400:6056896,500:4149685,600:3754411,700:3162015,800:2635155,900:1713022},blue:{50:14938877,100:12312315,200:9489145,300:6600182,400:4367861,500:2201331,600:2001125,700:1668818,800:1402304,900:870305},"light-blue":{50:14808574,100:11789820,200:8508666,300:5227511,400:2733814,500:240116,600:236517,700:166097,800:161725,900:87963},cyan:{50:14743546,100:11725810,200:8445674,300:5099745,400:2541274,500:48340,600:44225,700:38823,800:33679,900:24676},teal:{50:14742257,100:11722715,200:8440772,300:5093036,400:2533018,500:38536,600:35195,700:31083,800:26972,900:19776},green:{50:15267305,100:13166281,200:10868391,300:8505220,400:6732650,500:5025616,600:4431943,700:3706428,800:3046706,900:1793568},"light-green":{50:15857897,100:14478792,200:12968357,300:11457921,400:10275941,500:9159498,600:8172354,700:6856504,800:5606191,900:3369246},lime:{50:16382951,100:15791299,200:15134364,300:14477173,400:13951319,500:13491257,600:12634675,700:11514923,800:10394916,900:8550167},yellow:{50:16776679,100:16775620,200:16774557,300:16773494,400:16772696,500:16771899,600:16635957,700:16498733,800:16361509,900:16088855},amber:{50:16775393,100:16772275,200:16769154,300:16766287,400:16763432,500:16761095,600:16757504,700:16752640,800:16748288,900:16740096},orange:{50:16774112,100:16769202,200:16764032,300:16758605,400:16754470,500:16750592,600:16485376,700:16088064,800:15690752,900:15094016},"deep-orange":{50:16509415,100:16764092,200:16755601,300:16747109,400:16740419,500:16733986,600:16011550,700:15092249,800:14172949,900:12531212},brown:{50:15723497,100:14142664,200:12364452,300:10586239,400:9268835,500:7951688,600:7162945,700:6111287,800:5125166,900:4073251},gray:{50:16448250,100:16119285,200:15658734,300:14737632,400:12434877,500:10395294,600:7697781,700:6381921,800:4342338,900:2171169},"blue-gray":{50:15527921,100:13621468,200:11583173,300:9479342,400:7901340,500:6323595,600:5533306,700:4545124,800:3622735,900:2503224}};function Ie(e){return`#${e.toString(16).padStart(6,"0")}`}function Ne(e){return be.map((t=>`.${t}\\:${e}:${t}`))}function Te(e,t){return Object.entries(me).map((([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`))}function Se(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function Pe(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100vw`],[`${t}-full`,`${e}: 100%`],...ge.map((r=>[`${t}-${r}`,`${e}: ${r*_e}rem`])),...ge.map((r=>[`-${t}-${r}`,`${e}: -${r*_e}rem`])),...ge.map((r=>[`${t}-${r}px`,`${e}: ${r}px`])),...ge.map((r=>[`-${t}-${r}px`,`${e}: -${r}px`])),...ve.map((r=>[`${t}-${r}\\%`,`${e}: ${r}%`])),...ve.map((r=>[`-${t}-${r}\\%`,`${e}: -${r}%`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ne(e).join(",")} { ${t} }`,...Te(e,t)]))}function ke(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-auto`,`${e}: auto`],[`${t}x-auto`,`${e}-left: auto; ${e}-right: auto;`],[`${t}y-auto`,`${e}-top: auto; ${e}-bottom: auto;`],[`${t}x-0`,`${e}-left: 0; ${e}-right: 0;`],[`${t}y-0`,`${e}-top: 0; ${e}-bottom: 0;`],...ge.map((e=>[e,e*_e])).map((([r,i])=>[`${t}x-${r}`,`${e}-left: ${i}rem; ${e}-right: ${i}rem;`])),...ge.map((e=>[e,e*_e])).map((([r,i])=>[`${t}y-${r}`,`${e}-top: ${i}rem; ${e}-bottom: ${i}rem;`])),...ge.map((r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`])),...ge.map((r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`])),...ve.map((r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`])),...ve.map((r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ne(e).join(",")} { ${t} }`,...Te(e,t)]))}function Ce(){const e=[["white","#fff"],["black","#000"],["transparent","transparent"]].flatMap((([e,t])=>[[`text-${e}`,`color: ${t}`],[`fill-${e}`,`fill: ${t}`],[`bg-${e}`,`background-color: ${t}`],[`border-${e}`,`border-color: ${t}`]])),t=Object.entries(Re).flatMap((([e,t])=>[[`text-${e}`,`color: ${Ie(t[500])}`],[`fill-${e}`,`fill: ${Ie(t[500])}`],[`bg-${e}`,`background-color: ${Ie(t[500])}`],[`border-${e}`,`border-color: ${Ie(t[500])}`]])),r=Object.entries(Re).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[[`text-${e}-${t}`,`color: ${Ie(r)}`],[`fill-${e}-${t}`,`fill: ${Ie(r)}`],[`bg-${e}-${t}`,`background-color: ${Ie(r)}`],[`border-${e}-${t}`,`border-color: ${Ie(r)}`]]))));return[].concat(e).concat(t).concat(r).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ne(e).join(",")} { ${t} }`,...Te(e,t)]))}const Le=new fe;globalThis.Mancha=Le;const De=globalThis.document?.currentScript;if(globalThis.document?.currentScript?.hasAttribute("init")){const e=De?.hasAttribute("debug"),t=De?.getAttribute("cache"),r=De?.getAttribute("target")?.split("+")||["body"];window.addEventListener("load",(()=>{r.map((async r=>{const i=globalThis.document.querySelector(r);await Le.debug(e).mount(i,{cache:t})}))}))}if(globalThis.document?.currentScript?.hasAttribute("css")){const e=De?.getAttribute("css")?.split("+");for(const t of e){const e=document.createElement("style");switch(t){case"basic":u(e,y`
2
- html {
3
- max-width: 70ch;
4
- padding: 2em 1em;
5
- margin: auto;
6
- line-height: 1.75;
7
- font-size: 1.25em;
8
- font-family: sans-serif;
9
- }
10
-
11
- h1,h2,h3,h4,h5,h6 {
12
- margin: 1em 0 0.5em;
13
- }
14
-
15
- p,ul,ol {
16
- margin-bottom: 1em;
17
- color: #1d1d1d;
18
- }`);break;case"utils":e.textContent=(Me=void 0,[...Oe,...Object.entries(Ae).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[`.${e} { ${t}: ${r} }`,`${Ne(e).join(",")} { ${t}: ${r} }`,...Te(e,`${t}: ${r}`)])))),...Ce(),...[["opacity-0","opacity: 0"],...ve.map((e=>[`opacity-${e}`,"opacity: "+e/100]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ne(e).join(",")} { ${t} }`,...Te(e,t)])),...Pe(we),...Pe(xe),...ke(xe),...(Me=Ee,Object.entries(Me).flatMap((([e,t])=>[[`${t}t-0`,`${e}-top: 0`],[`${t}b-0`,`${e}-bottom: 0`],[`${t}l-0`,`${e}-left: 0`],[`${t}r-0`,`${e}-right: 0`],[`${t}t-auto`,`${e}-top: auto`],[`${t}b-auto`,`${e}-bottom: auto`],[`${t}l-auto`,`${e}-left: auto`],[`${t}r-auto`,`${e}-right: auto`],...["","-"].flatMap((r=>[...ge.map((e=>[e,e*_e])).map((([i,n])=>[`${r}${t}t-${i}`,`${e}-top: ${r}${n}rem`])),...ge.map((e=>[e,e*_e])).map((([i,n])=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${n}rem`])),...ge.map((e=>[e,e*_e])).map((([i,n])=>[`${r}${t}l-${i}`,`${e}-left: ${r}${n}rem`])),...ge.map((e=>[e,e*_e])).map((([i,n])=>[`${r}${t}r-${i}`,`${e}-right: ${r}${n}rem`])),...ge.map((i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`])),...ge.map((i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`])),...ge.map((i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`])),...ge.map((i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`])),...ve.map((i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`])),...ve.map((i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%;`])),...ve.map((i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`])),...ve.map((i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`]))]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ne(e).join(",")} { ${t} }`,...Te(e,t)]))),...Pe(Ee),...ke(Ee),...[["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...ge.map((e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*_e}rem`])),...ge.map((e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*_e}rem`])),...ge.map((e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`])),...ge.map((e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`])),["gap-0","gap: 0"],...ge.map((e=>[`gap-${e}`,`gap: ${e*_e}rem`])),...ge.map((e=>[`gap-${e}px`,`gap: ${e}px`])),...ge.map((e=>[`gap-x-${e}`,`column-gap: ${e*_e}rem`])),...ge.map((e=>[`gap-y-${e}`,`row-gap: ${e*_e}rem`])),...ge.map((e=>[`gap-x-${e}px`,`column-gap: ${e}px`])),...ge.map((e=>[`gap-y-${e}px`,`row-gap: ${e}px`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ne(e).join(",")} { ${t} }`,...Te(e,t)])),...Pe(ye),...[...$e.map((e=>[`border-${e}`,`border-width: ${e}px`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ne(e).join(",")} { ${t} }`,...Te(e,t)]))].sort(Se).join("\n"));break;default:console.error(`Unknown style name: "${t}"`)}globalThis.document.head.appendChild(e)}}var Me})();
1
+ (()=>{"use strict";var e={1741:(e,t,r)=>{r.d(t,{A:()=>Z});class i{iterable;constructor(e){this.iterable=e}filter(e){return new i(i.filterGenerator(e,this.iterable))}map(e){return new i(i.mapGenerator(e,this.iterable))}find(e){for(const t of this.iterable)if(e(t))return t}array(){return Array.from(this.iterable)}*generator(){for(const e of this.iterable)yield e}static*filterGenerator(e,t){for(const r of t)e(r)&&(yield r)}static*mapGenerator(e,t){for(const r of t)yield e(r)}static equals(e,t){const r=e[Symbol.iterator](),i=t[Symbol.iterator]();let n=r.next(),s=i.next();for(;!n.done&&!s.done;){if(n.value!==s.value)return!1;n=r.next(),s=i.next()}return n.done===s.done}}var n=r(4744),s=r(9743);const o=[s.bc`:`,s.bc`style`,s.bc`class`];function*a(e,t=new Set){const r=new Set,i=Array.from(e.childNodes).filter((e=>!t.has(e)));for(yield e;i.length;){const e=i.shift();r.has(e)||(r.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter((e=>!t.has(e))).forEach((e=>i.push(e)))}}function l(e,t){return void 0!==e?.[t]}function c(e,t){return"function"==typeof e?.[t]}function h(e){return e.replace(/-./g,(e=>e[1].toUpperCase()))}function u(e,t){return l(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function d(e,t,r=""){return u(e,r+t)||(e.dataset?.[h(t)]??null)}function p(e,t,r){l(e,"attribs")?e.attribs[t]=r:e.setAttribute?.(t,r)}function f(e,t,r){l(e,"attribs")?e.attribs[t]=r:n.Om.setPrefixedAttribute(o,e,t,r)}function m(e,t,r){switch(t){case"disabled":return void(e.disabled=r);case"selected":return void(e.selected=r);case"checked":return void(e.checked=r);default:e[t]=r}}function _(e,t){l(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function v(e,t,r=""){_(e,`${r}${t}`),_(e,`data-${t}`)}function $(e,t,r){if(l(e,"attribs")&&l(t,"attribs"))t.attribs[r]=e.attribs[r];else if(r.startsWith("data-")){const i=h(r.slice(5));t.dataset[i]=e.dataset?.[i]}else{const i=e?.getAttribute?.(r);f(t,r,i||"")}}function b(e){if(l(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find((e=>1===e.nodeType))}function g(e,...t){if(c(e,"replaceWith"))return e.replaceWith(...t);{const r=e,i=r.parentNode,n=Array.from(i.childNodes).indexOf(r);t.forEach((e=>e.parentNode=i)),i.childNodes=[].concat(Array.from(i.childNodes).slice(0,n)).concat(t).concat(Array.from(i.childNodes).slice(n+1))}}function E(e,...t){c(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function x(e,t){return c(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function w(e,t){return c(t,"removeChild")?e.removeChild(t):(E(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function y(e,t,r){return r?c(e,"insertBefore")?e.insertBefore(t,r):(g(r,t,r),t):x(e,t)}function A(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function O(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map((e=>O(e,t))).join(""):A(e.outerHTML||e.nodeValue||String(e),t)}function R(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}var I;!function(e){e.resolveIncludes=async function(e,t){const r=e,i=r.tagName?.toLowerCase();if(!["include","link"].includes(i))return;if("link"===i&&"subresource"!==u(r,"rel"))return;this.log("include directive found in:\n",O(e,128)),this.log("include params:",t);const n="link"===r.tagName.toLocaleLowerCase()?"href":"src",s=u(r,n);if(!s)throw new Error(`"${n}" attribute missing from ${O(e,128)}.`);const o=[];"include"===i&&o.push("src"),"link"===i&&o.push("rel","href");const a=t=>{const i=b(t);for(const e of Array.from(r.attributes))i&&!o.includes(e.name)&&$(r,i,e.name);g(e,...t.childNodes)},l={...t,rootDocument:!1,maxdepth:t?.maxdepth-1};if(0===l.maxdepth)throw new Error("Maximum recursion depth reached.");if(s.includes("://")||s.startsWith("//"))this.log("Including remote file from absolute path:",s),await this.preprocessRemote(s,l).then(a);else if(t?.dirpath?.includes("://")||t?.dirpath?.startsWith("//")){const e=s.startsWith("/")?s:`${t.dirpath}/${s}`;this.log("Including remote file from relative path:",e),await this.preprocessRemote(e,l).then(a)}else if("/"===s.charAt(0))this.log("Including local file from absolute path:",s),await this.preprocessLocal(s,l).then(a);else{const e=t?.dirpath&&"."!==t?.dirpath?`${t?.dirpath}/${s}`:s;this.log("Including local file from relative path:",e),await this.preprocessLocal(e,l).then(a)}},e.rebaseRelativePaths=async function(e,t){const r=e,i=r.tagName?.toLowerCase();if(!t?.dirpath)return;const s=u(r,"src"),o=u(r,"href"),a=s||o;if(!a||((c=a).includes("://")||c.startsWith("/")||c.startsWith("#")||c.startsWith("data:")))return;var c;const h=`${t.dirpath}/${a}`;this.log("Rebasing relative path as:",h),l(r,"attribs")?f(r,s?"src":"href",h):"img"===i?r.src=h:"a"===i?n.aS.setHref(r,h):"source"===i||"audio"===i||"video"===i||"track"===i||"input"===i?r.src=h:"area"===i?n.Cw.setHref(r,h):this.log("Unable to rebase relative path for element:",i)},e.registerCustomElements=async function(e,t){const r=e,i=r.tagName?.toLowerCase(),n=(u(r,"is")||u(r,"alt"))?.toLowerCase();if(["template","div"].includes(i)&&n){if("div"===i&&"template"!==u(r,"role"))return;this._customElements.has(n)||(this.log(`Registering custom element: ${n}\n`,O(r,128)),this._customElements.set(n,r),w(r.parentNode,r))}},e.resolveCustomElements=async function(e,t){const r=e,n=r.tagName?.toLowerCase();let s=n;if("div"===s&&(s=u(r,"role")?.toLowerCase()||s),s&&this._customElements.has(s)){this.log(`Processing custom element: ${s}\n`,O(r,128));const t=this._customElements.get(s),o=(t.content||t).cloneNode(!0),l=b(o);if(l)for(const e of Array.from(r.attributes))"div"===n&&"role"===e.name||$(r,l,e.name);const c=new i(a(o)).find((e=>"slot"===e.tagName?.toLowerCase()));c&&g(c,...r.childNodes),g(e,...o.childNodes)}},e.resolveTextNodeExpressions=async function(e,t){const r=e.nodeValue||"";if(3!==e.nodeType||!r?.trim())return;this.log("Processing node content value:\n",A(r,128));const i=new RegExp(/{{ ([^}]+) }}/gm),n=Array.from(r.matchAll(i)).map((e=>e[1]));return this.effect((function(){let t=r;for(const r of n){const i=this.eval(r,{$elem:e});t=t.replace(`{{ ${r} }}`,String(i))}e.nodeValue=t}))},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=d(r,"data",":");if(i){this.log(":data attribute found in:\n",O(e,128)),v(r,"data",":");const n=t?.rootNode===e?this:this.subrenderer();e.renderer=n;const s=n.eval(i,{$elem:e});if(await Promise.all(Object.entries(s).map((([e,t])=>n.set(e,t)))),n!==this)for(const t of a(e,this._skipNodes))this._skipNodes.add(t);await n.mount(e,t)}},e.resolveClassAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=d(r,"class",":");if(i){this.log(":class attribute found in:\n",O(e,128)),v(r,"class",":");const t=u(r,"class")||"";return this.effect((function(){const n=this.eval(i,{$elem:e});f(r,"class",(n?`${t} ${n}`:t).trim())}))}},e.resolveTextAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=d(r,"text",":");if(i){this.log(":text attribute found in:\n",O(e,128)),v(r,"text",":");const t=t=>this.textContent(e,t);return this.effect((function(){t(this.eval(i,{$elem:e}))}))}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=d(r,"html",":");return i?(this.log(":html attribute found in:\n",O(e,128)),v(r,"html",":"),this.effect((function(){const n=this.eval(i,{$elem:e});return new Promise((async e=>{const i=await this.preprocessString(n,t);await this.renderNode(i),E(r,i),e()}))}))):void 0},e.resolveEventAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){const i=t.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!i)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",O(e,128)),_(r,t.name);const n="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,(r=>(n&&r.preventDefault(),this.eval(t.value,{$elem:e,$event:r}))))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=d(r,"for",":")?.trim();if(i){this.log(":for attribute found in:\n",O(e,128)),v(r,"for",":");for(const t of a(e,this._skipNodes))this._skipNodes.add(t);const n=e.parentNode,s=this.createElement("template",e.ownerDocument);y(n,s,e),w(n,e),x(s,e),this.log(":for template:\n",O(s,128));const o=i.split(" in ",2);if(2!==o.length)throw new Error(`Invalid :for format: \`${i}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=o;await this.effect((function(){const r=this.eval(h,{$elem:e});if(this.log(":for list items:",r),l.splice(0,l.length).forEach((e=>{w(n,e),this._skipNodes.delete(e)})),!Array.isArray(r))return console.error(`Expression did not yield a list: \`${h}\` => \`${r}\``),Promise.resolve();const i=[];for(const n of r){const r=this.subrenderer();r.set(c,n);const s=e.cloneNode(!0);l.push(s),this._skipNodes.add(s),i.push(r.mount(s,t)),this.log("Rendered list child:\n",O(s,128))}const o=s.nextSibling;for(const e of l)y(n,e,o);return Promise.all(i)}))}},e.resolveBindAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=d(r,"bind",":");if(i){this.log(":bind attribute found in:\n",O(e,128));const t=["change","input"],n=u(r,":bind:on")?.split(",")||r.dataset.bindOn?.split(",")||t;v(r,"bind",":"),_(r,":bind:on"),_(r,"data-bind-on");const s="checkbox"===u(r,"type")?"checked":"value";this.effect((function(){const t=this.eval(i,{$elem:e});r[s]=t}));const o=`${i} = $elem.${s}`;for(const t of n)e.addEventListener(t,(()=>this.eval(o,{$elem:e})))}},e.resolveShowAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=d(r,"show",":");if(i){this.log(":show attribute found in:\n",O(e,128)),v(r,"show",":");const t="none"===r.style?.display?"":r.style?.display??u(r,"style")?.split(";")?.find((e=>"display"===e.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const n=this.eval(i,{$elem:e});r.style?r.style.display=n?t:"none":f(r,"style",`display: ${n?t:"none"};`)}))}},e.resolveCustomAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":attr:",n="data-attr-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"attribute found in:\n",O(e,128)),_(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1);this.effect((function(){const i=this.eval(t.value,{$elem:e});p(r,s,i)}))}}},e.resolveCustomProperty=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":prop:",n="data-prop-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"property found in:\n",O(e,128)),_(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1),o=h(s);this.effect((function(){const i=this.eval(t.value,{$elem:e});m(r,o,i)}))}}}}(I||(I={}));const N=["this"],T=["+","-","!"],S=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],C={"!":0,":":0,",":0,")":0,"]":0,"}":0,"|>":1,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"{":13},P=["==","!=","<=",">=","||","&&","??","|>"],k=["===","!=="];var L;!function(e){e[e.STRING=1]="STRING",e[e.IDENTIFIER=2]="IDENTIFIER",e[e.DOT=3]="DOT",e[e.COMMA=4]="COMMA",e[e.COLON=5]="COLON",e[e.INTEGER=6]="INTEGER",e[e.DECIMAL=7]="DECIMAL",e[e.OPERATOR=8]="OPERATOR",e[e.GROUPER=9]="GROUPER",e[e.KEYWORD=10]="KEYWORD",e[e.ARROW=11]="ARROW"}(L||(L={}));const M=(e,t,r=0)=>({kind:e,value:t,precedence:r}),D=e=>95===e||36===e||65<=(e&=-33)&&e<=90,U=e=>48<=e&&e<=57;class j{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;9===(e=this._next)||10===e||13===e||32===e;)this._advance(!0);var e;if((e=>34===e||39===e)(this._next))return this._tokenizeString();if(D(this._next))return this._tokenizeIdentOrKeyword();if(U(this._next))return this._tokenizeNumber();if(46===this._next)return this._tokenizeDot();if(44===this._next)return this._tokenizeComma();if(58===this._next)return this._tokenizeColon();if((e=>43===e||45===e||42===e||47===e||33===e||38===e||37===e||60===e||61===e||62===e||63===e||94===e||124===e)(this._next))return this._tokenizeOperator();if((e=>40===e||41===e||91===e||93===e||123===e||125===e)(this._next))return this._tokenizeGrouper();if(this._advance(),void 0!==this._next)throw new Error(`Expected end of input, got ${this._next}`)}_advance(e){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),!0===e&&(this._tokenStart=this._index)):this._next=void 0}_getValue(e=0){const t=this._input.substring(this._tokenStart,this._index+e);return 0===e&&this._clearValue(),t}_clearValue(){this._tokenStart=this._index}_tokenizeString(){const e="unterminated string",t=this._next;for(this._advance(!0);this._next!==t;){if(void 0===this._next)throw new Error(e);if(92===this._next&&(this._advance(),void 0===this._next))throw new Error(e);this._advance()}const r=M(L.STRING,this._getValue().replace(/\\(.)/g,((e,t)=>{switch(t){case"n":return"\n";case"r":return"\r";case"t":return"\t";case"b":return"\b";case"f":return"\f";default:return t}})));return this._advance(),r}_tokenizeIdentOrKeyword(){do{this._advance()}while(e=this._next,D(e)||U(e));var e;const t=this._getValue(),r=(i=t,-1!==N.indexOf(i)?L.KEYWORD:L.IDENTIFIER);var i;return M(r,t)}_tokenizeNumber(){do{this._advance()}while(U(this._next));return 46===this._next?this._tokenizeDot():M(L.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),U(this._next)?this._tokenizeFraction():(this._clearValue(),M(L.DOT,".",13))}_tokenizeComma(){return this._advance(!0),M(L.COMMA,",")}_tokenizeColon(){return this._advance(!0),M(L.COLON,":")}_tokenizeFraction(){do{this._advance()}while(U(this._next));return M(L.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(-1!==k.indexOf(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),M(L.ARROW,e);-1!==P.indexOf(e)&&this._advance()}return e=this._getValue(),M(L.OPERATOR,e,C[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=M(L.GROUPER,e,C[e]);return this._advance(!0),t}}class G{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new j(e),this._ast=t}parse(){return this._advance(),this._parseExpression()}_advance(e,t){if(!this._matches(e,t))throw new Error(`Expected kind ${e} (${t}), was ${this._token?.kind} (${this._token?.value})`);const r=this._tokenizer.nextToken();this._token=r,this._kind=r?.kind,this._value=r?.value}_matches(e,t){return!(e&&this._kind!==e||t&&this._value!==t)}_parseExpression(){if(!this._token)return this._ast.empty();const e=this._parseUnary();return void 0===e?void 0:this._parsePrecedence(e,0)}_parsePrecedence(e,t){if(void 0===e)throw new Error("Expected left to be defined.");for(;this._token;)if(this._matches(L.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(L.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(L.DOT)){this._advance();const t=this._parseUnary();e=this._makeInvokeOrGetter(e,t)}else{if(this._matches(L.KEYWORD))break;if(!(this._matches(L.OPERATOR)&&this._token.precedence>=t))break;e="?"===this._value?this._parseTernary(e):this._parseBinary(e,this._token)}return e}_makeInvokeOrGetter(e,t){if(void 0===t)throw new Error("expected identifier");if("ID"===t.type)return this._ast.getter(e,t.value);if("Invoke"===t.type&&"ID"===t.receiver.type){const r=t.receiver;return this._ast.invoke(e,r.value,t.arguments)}throw new Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(-1===S.indexOf(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let r=this._parseUnary();for(;(this._kind===L.OPERATOR||this._kind===L.DOT||this._kind===L.GROUPER)&&this._token.precedence>t.precedence;)r=this._parsePrecedence(r,this._token.precedence);return this._ast.binary(e,t.value,r)}_parseUnary(){if(this._matches(L.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(L.INTEGER))return this._parseInteger(e);if(this._matches(L.DECIMAL))return this._parseDecimal(e)}if(-1===T.indexOf(e))throw new Error(`unexpected token: ${e}`);const t=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(e,t)}return this._parsePrimary()}_parseTernary(e){this._advance(L.OPERATOR,"?");const t=this._parseExpression();this._advance(L.COLON);const r=this._parseExpression();return this._ast.ternary(e,t,r)}_parsePrimary(){switch(this._kind){case L.KEYWORD:const e=this._value;if("this"===e)return this._advance(),this._ast.id(e);if(-1!==N.indexOf(e))throw new Error(`unexpected keyword: ${e}`);throw new Error(`unrecognized keyword: ${e}`);case L.IDENTIFIER:return this._parseInvokeOrIdentifier();case L.STRING:return this._parseString();case L.INTEGER:return this._parseInteger();case L.DECIMAL:return this._parseDecimal();case L.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case L.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(L.GROUPER,"]"))break;e.push(this._parseExpression())}while(this._matches(L.COMMA));return this._advance(L.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e={};do{if(this._advance(),this._matches(L.GROUPER,"}"))break;const t=this._value;(this._matches(L.STRING)||this._matches(L.IDENTIFIER))&&this._advance(),this._advance(L.COLON),e[t]=this._parseExpression()}while(this._matches(L.COMMA));return this._advance(L.GROUPER,"}"),this._ast.map(e)}_parseInvokeOrIdentifier(){const e=this._value;if("true"===e)return this._advance(),this._ast.literal(!0);if("false"===e)return this._advance(),this._ast.literal(!1);if("null"===e)return this._advance(),this._ast.literal(null);if("undefined"===e)return this._advance(),this._ast.literal(void 0);const t=this._parseIdentifier(),r=this._parseArguments();return r?this._ast.invoke(t,void 0,r):t}_parseIdentifier(){if(!this._matches(L.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(L.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(L.GROUPER,")"))break;const t=this._parseExpression();e.push(t)}while(this._matches(L.COMMA));return this._advance(L.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(L.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(L.ARROW)){this._advance();const t=this._parseExpression(),r=e?.map((e=>e.value))??[];return this._ast.arrowFunction(r,t)}return this._ast.paren(e[0])}_parseString(){const e=this._ast.literal(this._value);return this._advance(),e}_parseInteger(e=""){const t=this._ast.literal(parseInt(`${e}${this._value}`,10));return this._advance(),t}_parseDecimal(e=""){const t=this._ast.literal(parseFloat(`${e}${this._value}`));return this._advance(),t}}const F={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,"||":(e,t)=>e||t,"&&":(e,t)=>e&&t,"??":(e,t)=>e??t,"|":(e,t)=>t(e),"|>":(e,t)=>t(e)},z={"+":e=>e,"-":e=>-e,"!":e=>!e};class H{timeouts=new Map;debounce(e,t){return new Promise(((r,i)=>{const n=this.timeouts.get(t);n&&clearTimeout(n),this.timeouts.set(t,setTimeout((()=>{try{r(t()),this.timeouts.delete(t)}catch(e){i(e)}}),e))}))}}const K=new class{empty(){return{type:"Empty",evaluate:e=>e,getIds:e=>e}}literal(e){return{type:"Literal",value:e,evaluate(e){return this.value},getIds:e=>e}}id(e){return{type:"ID",value:e,evaluate(e){return"this"===this.value?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(e,t){const r=z[e];return{type:"Unary",operator:e,child:t,evaluate(e){return r(this.child.evaluate(e))},getIds(e){return this.child.getIds(e)}}}binary(e,t,r){const i=F[t];return{type:"Binary",operator:t,left:e,right:r,evaluate(e){if("="===this.operator){if("ID"!==this.left.type&&"Getter"!==this.left.type&&"Index"!==this.left.type)throw new Error(`Invalid assignment target: ${this.left}`);const t=this.right.evaluate(e);let r,i;return"Getter"===this.left.type?(r=this.left.receiver.evaluate(e),i=this.left.name):"Index"===this.left.type?(r=this.left.receiver.evaluate(e),i=this.left.argument.evaluate(e)):"ID"===this.left.type&&(r=e,i=this.left.value),void 0===r?void 0:r[i]=t}return i(this.left.evaluate(e),this.right.evaluate(e))},getIds(e){return this.left.getIds(e),this.right.getIds(e),e}}}getter(e,t){return{type:"Getter",receiver:e,name:t,evaluate(e){return this.receiver.evaluate(e)?.[this.name]},getIds(e){return this.receiver.getIds(e),e}}}invoke(e,t,r){if(null!=t&&"string"!=typeof t)throw new Error("method not a string");return{type:"Invoke",receiver:e,method:t,arguments:r,evaluate(e){const r=this.receiver.evaluate(e),i=this.method?r:e?.this??e,n=this.method?r?.[t]:r,s=(this.arguments??[]).map((t=>t?.evaluate(e)));return n?.apply?.(i,s)},getIds(e){return this.receiver.getIds(e),this.arguments?.forEach((t=>t?.getIds(e))),e}}}paren(e){return e}index(e,t){return{type:"Index",receiver:e,argument:t,evaluate(e){return this.receiver.evaluate(e)?.[this.argument.evaluate(e)]},getIds(e){return this.receiver.getIds(e),e}}}ternary(e,t,r){return{type:"Ternary",condition:e,trueExpr:t,falseExpr:r,evaluate(e){return this.condition.evaluate(e)?this.trueExpr.evaluate(e):this.falseExpr.evaluate(e)},getIds(e){return this.condition.getIds(e),this.trueExpr.getIds(e),this.falseExpr.getIds(e),e}}}map(e){return{type:"Map",entries:e,evaluate(t){const r={};if(e&&this.entries)for(const i in e){const e=this.entries[i];e&&(r[i]=e.evaluate(t))}return r},getIds(t){if(e&&this.entries)for(const r in e){const e=this.entries[r];e&&e.getIds(t)}return t}}}list(e){return{type:"List",items:e,evaluate(e){return this.items?.map((t=>t?.evaluate(e)))},getIds(e){return this.items?.forEach((t=>t?.getIds(e))),e}}}arrowFunction(e,t){return{type:"ArrowFunction",params:e,body:t,evaluate(e){const t=this.params,r=this.body;return function(...i){const n=Object.fromEntries(t.map(((e,t)=>[e,i[t]]))),s=new Proxy(e??{},{set:(e,t,r)=>(n.hasOwnProperty(t)&&(n[t]=r),e[t]=r),get:(e,t)=>n.hasOwnProperty(t)?n[t]:e[t]});return r.evaluate(s)}},getIds(e){return this.body.getIds(e).filter((e=>!this.params.includes(e)))}}}};function W(e,t){if(e.has(t))return e.get(t);if(e.has("$parent")){return W(e.get("$parent"),t)}return null}function B(e,t){if(e.has(t))return e;if(e.has("$parent")){return B(e.get("$parent"),t)}return null}class Y extends H{evalkeys=["$elem","$event"];expressionCache=new Map;store=new Map;observers=new Map;_observer=null;_lock=Promise.resolve();constructor(e){super();for(let[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof Y||r.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>r in e&&(delete e[r],t(),!0),set:(r,i,n,s)=>{"object"==typeof n&&null!=e&&(n=this.wrapObject(n,t));const o=Reflect.set(r,i,n,s);return t(),o},get:(e,t,r)=>"__is_proxy__"===t||Reflect.get(e,t,r)});var r}watch(e,t){this.observers.has(e)||this.observers.set(e,new Set),this.observers.get(e)?.has(t)||this.observers.get(e)?.add(t)}async notify(e,t=10){const r=Array.from(this.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(r.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),W(this.store,e)}async set(e,t){if(t===this.store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=B(e,t);i?i.set(t,r):e.set(t,r)}(this.store,e,t),await r()}del(e){this.store.delete(e),this.observers.delete(e)}has(e){return this.store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this.store.entries()).map((([e])=>e)),r=Object.fromEntries(t.map((e=>[e,void 0])));return new Proxy(r,{get:(t,r,i)=>"string"==typeof r&&B(this.store,r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes(" = ")){const[r,i]=e.split(" = ");t=r.trim(),e=i.trim()}return(r,i)=>{const n=((e,t)=>new G(e,t).parse())(e,K),s=n?.getIds([])?.map((e=>[e,i[e]??r[e]??globalThis[e]])),o=n?.evaluate(Object.fromEntries(s||[]));if(!t)return o;r[t]=o}}cachedExpressionFunction(e){return e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e)),this.expressionCache.get(e)}eval(e,t={}){const r=this._observer?this:this.$;if(this.store.has(e))return r[e];{const i=this.cachedExpressionFunction(e);try{return i(r,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}}class V extends Y{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(e){return this.debugging=e,this}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??"default"}).then((e=>e.text()))}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log("Preprocessing string content with params:\n",t);const r=this.parseHTML(e,t);return await this.preprocessNode(r,t),r}async preprocessRemote(e,t){const r={};t?.cache&&(r.cache=t.cache);const i=await fetch(e,r).then((e=>e.text()));return this.preprocessString(i,{...t,dirpath:R(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}async preprocessLocal(e,t){const r=await this.fetchLocal(e,t);return this.preprocessString(r,{...t,dirpath:R(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}subrenderer(){const e=(new this.constructor).debug(this.debugging);return e.set("$parent",this),e.set("$root",this.get("$root")??this),e._customElements=this._customElements,e}log(...e){this.debugging&&console.debug(...e)}async preprocessNode(e,t){t={dirpath:this.dirpath,maxdepth:10,...t};const r=new i(a(e,this._skipNodes)).map((async e=>{this.log("Preprocessing node:\n",O(e,128)),await I.resolveIncludes.call(this,e,t),await I.rebaseRelativePaths.call(this,e,t),await I.registerCustomElements.call(this,e,t),await I.resolveCustomElements.call(this,e,t)}));return await Promise.all(r.generator()),e}async renderNode(e,t){for(const r of a(e,this._skipNodes))this.log("Rendering node:\n",O(r,128)),await I.resolveForAttribute.call(this,r,t),await I.resolveDataAttribute.call(this,r,t),await I.resolveTextAttributes.call(this,r,t),await I.resolveHtmlAttribute.call(this,r,t),await I.resolveShowAttribute.call(this,r,t),await I.resolveClassAttribute.call(this,r,t),await I.resolveBindAttribute.call(this,r,t),await I.resolveEventAttributes.call(this,r,t),await I.resolveTextNodeExpressions.call(this,r,t),await I.resolveCustomAttribute.call(this,r,t),await I.resolveCustomProperty.call(this,r,t);return e}async mount(e,t){t={...t,rootNode:e},await this.preprocessNode(e,t),await this.renderNode(e,t),m(e,"renderer",this)}}class Z extends V{impl="browser";dirpath=R(globalThis.location?.href??"http://localhost/");parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return(new DOMParser).parseFromString(e,"text/html");{const t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}new Z},5883:(e,t,r)=>{r.d(t,{b:()=>n});r(4934);var i=r(8003);r(9825);function n(e){const t=e[0].toLowerCase();return(0,i.Sd)(t)}},5133:(e,t,r)=>{r(4934),r(7274),r(9825)},5114:(e,t,r)=>{r(7274),r(5611),r(9788)},8543:(e,t,r)=>{r(4934),r(723),r(5114),r(4184),r(9847),r(8245),r(4153),r(6691)},8527:(e,t,r)=>{r(723),r(8543),r(4153),r(6691)},9847:(e,t,r)=>{r(8526),r(4934),r(7274)},8245:(e,t,r)=>{var i;!function(e){e[e.STYLE_TAG=0]="STYLE_TAG",e[e.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",e[e.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}(i||(i={}))},4153:(e,t,r)=>{var i=r(1514),n=r(6691);const s=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],o=[["A",new Map([["href",{policyAction:n.He.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:n.He.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:n.He.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:n.He.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:n.He.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:n.He.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:n.He.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:n.He.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:n.He.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],a=["title","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-current","aria-disabled","aria-dropeffect","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-live","aria-multiline","aria-multiselectable","aria-orientation","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","alt","align","autocapitalize","autocomplete","autocorrect","autofocus","autoplay","bgcolor","border","cellpadding","cellspacing","checked","color","cols","colspan","controls","datetime","disabled","download","draggable","enctype","face","formenctype","frameborder","height","hreflang","hidden","ismap","label","lang","loop","max","maxlength","media","minlength","min","multiple","muted","nonce","open","placeholder","preload","rel","required","reversed","role","rows","rowspan","selected","shape","size","sizes","slot","span","spellcheck","start","step","summary","translate","type","valign","value","width","wrap","itemscope","itemtype","itemid","itemprop","itemref"],l=[["dir",{policyAction:n.He.KEEP_AND_NORMALIZE,conditions:(0,i.L)((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:n.He.KEEP_AND_NORMALIZE,conditions:(0,i.L)((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:n.He.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:n.He.KEEP_AND_NORMALIZE,conditions:(0,i.L)((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:n.He.KEEP_AND_SANITIZE_URL}],["target",{policyAction:n.He.KEEP_AND_NORMALIZE,conditions:(0,i.L)((()=>new Map([["target",new Set(["_self","_blank"])]])))}]];new n.uC(new Set(s),new Map(o),new Set(a),new Map(l)),new n.uC(new Set((0,i.L)((()=>s.concat(["STYLE"])))),new Map(o),new Set((0,i.L)((()=>a.concat(["id","name","class"])))),new Map((0,i.L)((()=>l.concat([["style",{policyAction:n.He.KEEP_AND_SANITIZE_STYLE}]])))))},6691:(e,t,r)=>{r.d(t,{He:()=>n,uC:()=>i});class i{constructor(e,t,r,i,n){this.allowedElements=e,this.elementPolicies=t,this.allowedGlobalAttributes=r,this.globalAttributePolicies=i,this.globallyAllowedAttributePrefixes=n}isAllowedElement(e){return"FORM"!==e&&(this.allowedElements.has(e)||this.elementPolicies.has(e))}getAttributePolicy(e,t){const r=this.elementPolicies.get(t);if(null==r?void 0:r.has(e))return r.get(e);if(this.allowedGlobalAttributes.has(e))return{policyAction:n.KEEP};const i=this.globalAttributePolicies.get(e);return i||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((t=>0===e.indexOf(t)))?{policyAction:n.KEEP}:{policyAction:n.DROP})}}var n;!function(e){e[e.DROP=0]="DROP",e[e.KEEP=1]="KEEP",e[e.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",e[e.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",e[e.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}(n||(n={}));new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"])},5619:(e,t,r)=>{r(4934),r(5611),r(9788),r(9825)},4780:(e,t,r)=>{r(4934),r(9788),r(9825)},448:(e,t,r)=>{r.d(t,{C:()=>n,c:()=>s});r(4934),r(9825);var i=r(3116);function n(e){const t=e[0];return(0,i.GU)(t)}function s(e){return(0,i.GU)(e.map(i._9).join(""))}},4184:(e,t,r)=>{r.d(t,{Bi:()=>s});r(4934);const i=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function n(e){if(!function(e){const t=!i.test(e);return t}(e))return e}function s(e){return n(e)}},791:(e,t,r)=>{r.r(t),r.d(t,{setHref:()=>n});var i=r(4184);function n(e,t){const r=(0,i.Bi)(t);void 0!==r&&(e.href=r)}},4007:(e,t,r)=>{r.r(t),r.d(t,{setHref:()=>n});var i=r(4184);function n(e,t){const r=(0,i.Bi)(t);void 0!==r&&(e.href=r)}},7411:(e,t,r)=>{r(5611)},9334:(e,t,r)=>{r(4184)},2320:(e,t,r)=>{r.r(t),r.d(t,{buildPrefixedAttributeSetter:()=>l,insertAdjacentHtml:()=>a,setInnerHtml:()=>s,setOuterHtml:()=>o,setPrefixedAttribute:()=>c});r(4934);var i=r(8003),n=r(7274);function s(e,t){(function(e){return 1===e.nodeType})(e)&&h(e),e.innerHTML=(0,n.$_)(t)}function o(e,t){const r=e.parentElement;null!==r&&h(r),e.outerHTML=(0,n.$_)(t)}function a(e,t,r){const i="beforebegin"===t||"afterend"===t?e.parentElement:e;null!==i&&h(i),e.insertAdjacentHTML(t,(0,n.$_)(r))}function l(e,...t){const r=[e,...t];return(e,t,i)=>{c(r,e,t,i)}}function c(e,t,r,n){if(0===e.length){throw new Error("")}const s=e.map((e=>(0,i._j)(e))),o=r.toLowerCase();if(s.every((e=>0!==o.indexOf(e))))throw new Error(`Attribute "${r}" does not match any of the allowed prefixes.`);t.setAttribute(r,n)}function h(e){const t=e.tagName;if("SCRIPT"===t||"STYLE"===t)throw new Error("")}},7573:(e,t,r)=>{r(5611)},8944:(e,t,r)=>{r(4184)},8774:(e,t,r)=>{r(7274),r(5611)},4444:(e,t,r)=>{r(4184)},7854:(e,t,r)=>{r(4184),r(5611)},3881:(e,t,r)=>{r(5611)},169:(e,t,r)=>{r(5611),r(9788),r(8259)},9997:(e,t,r)=>{r.r(t),r.d(t,{setTextContent:()=>n});var i=r(3116);function n(e,t){e.textContent=(0,i._9)(t)}},1926:(e,t,r)=>{r(4934)},2506:(e,t,r)=>{r(4184),r(4934)},2898:(e,t,r)=>{r(7274)},6225:(e,t,r)=>{r(4934),r(7274)},3183:(e,t,r)=>{r(7274),r(5611),r(9788),r(3116);Error},6716:(e,t,r)=>{r(9788),r(3183)},1332:(e,t,r)=>{r(4184)},8526:(e,t,r)=>{r(7274)},285:(e,t,r)=>{r(5611)},8259:(e,t,r)=>{r(4184)},2089:(e,t,r)=>{r(5611)},4744:(e,t,r)=>{r.d(t,{Cw:()=>n,Om:()=>s,aS:()=>i,cZ:()=>o});var i=r(791),n=r(4007),s=(r(7411),r(9334),r(2320)),o=(r(7573),r(8944),r(8774),r(4444),r(7854),r(3881),r(169),r(9997));r(1926),r(2506),r(2898),r(6225),r(6716),r(1332),r(8526),r(285),r(8259),r(2089)},4934:()=>{},9743:(e,t,r)=>{r.d(t,{CM:()=>n.C,bc:()=>i.b,cu:()=>n.c});var i=r(5883),n=(r(5133),r(5114),r(8543),r(8527),r(5619),r(4780),r(448));r(8003),r(7274),r(5611),r(9788),r(3116)},8003:(e,t,r)=>{r.d(t,{Sd:()=>o,_j:()=>a});r(4934);var i=r(723);class n{constructor(e,t){this.privateDoNotAccessOrElseWrappedAttributePrefix=t}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const s=n;function o(e){return new s(i.I,e)}function a(e){if(function(e){return e instanceof n}(e))return e.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}},7274:(e,t,r)=>{r.d(t,{$_:()=>o});r(4934);var i=r(723),n=r(7539);class s{constructor(e,t){(0,i.q)(t),this.privateDoNotAccessOrElseWrappedHtml=e}toString(){return this.privateDoNotAccessOrElseWrappedHtml.toString()}}"undefined"!=typeof window&&window.TrustedHTML;function o(e){var t;if(null===(t=(0,n.Xi)())||void 0===t?void 0:t.isHTML(e))return e;if(e instanceof s)return e.privateDoNotAccessOrElseWrappedHtml;throw new Error("")}},1514:(e,t,r)=>{function i(e){return{valueOf:e}.valueOf()}r.d(t,{L:()=>i})},5611:(e,t,r)=>{r(4934),r(723),r(7539);"undefined"!=typeof window&&window.TrustedScriptURL},9788:(e,t,r)=>{r(4934),r(723),r(7539);"undefined"!=typeof window&&window.TrustedScript},723:(e,t,r)=>{r.d(t,{I:()=>i,q:()=>n});r(4934);const i={};function n(e){0}},9825:(e,t,r)=>{function i(e){return Object.isFrozen(e)&&Object.isFrozen(e.raw)}function n(e){return-1===e.toString().indexOf("`")}n((e=>e``))||n((e=>e`\0`))||n((e=>e`\n`))||n((e=>e`\u0000`)),i``&&i`\0`&&i`\n`&&i`\u0000`},3116:(e,t,r)=>{r.d(t,{GU:()=>o,_9:()=>a});r(4934);var i=r(723);class n{}class s extends n{constructor(e,t){super(),(0,i.q)(t),this.privateDoNotAccessOrElseWrappedStyleSheet=e}toString(){return this.privateDoNotAccessOrElseWrappedStyleSheet}}function o(e){return new s(e,i.I)}function a(e){if(e instanceof s)return e.privateDoNotAccessOrElseWrappedStyleSheet;throw new Error("")}},7539:(e,t,r)=>{r.d(t,{Xi:()=>n});let i="google#safe";function n(){var e;return""!==i&&null!==(e=function(){if("undefined"!=typeof window)return window.trustedTypes}())&&void 0!==e?e:null}}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,r),s.exports}r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i=r(4744),n=r(1741),s=r(9743);const o={sm:640,md:768,lg:1024,xl:1280},a=.25,l=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],c=[...l,16,20,24,28,32,36,40,44,48,52,56,60,64,72,80,96,112,128,144,160,192,224,256,288,320,384,448,512,...Object.values(o)],h=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],u=["hover","focus","disabled","active"],d={margin:"m",padding:"p"},p={width:"w",height:"h"},f={top:"top",right:"right",bottom:"bottom",left:"left"},m={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},_={bold:{"font-weight":"bold"},semibold:{"font-weight":600},italic:{"font-style":"italic"},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"},"font-mono":{"font-family":"monospace"},"font-sans":{"font-family":"sans-serif"},"font-serif":{"font-family":"serif"},"font-cursive":{"font-family":"cursive"},"text-left":{"text-align":"left"},"text-right":{"text-align":"right"},"text-center":{"text-align":"center"},"text-justify":{"text-align":"justify"},truncate:{"white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis"},"text-elipsis":{"text-overflow":"ellipsis"},"text-clip":{"text-overflow":"clip"},"text-xs":{"font-size":".75rem"},"text-sm":{"font-size":".875rem"},"text-base":{"font-size":"1rem"},"text-lg":{"font-size":"1.125rem"},"text-xl":{"font-size":"1.25rem"},relative:{position:"relative"},fixed:{position:"fixed"},absolute:{position:"absolute"},sticky:{position:"sticky"},"object-contain":{"object-fit":"contain"},"object-cover":{"object-fit":"cover"},"object-fill":{"object-fit":"fill"},"object-none":{"object-fit":"none"},block:{display:"block"},contents:{display:"contents"},hidden:{display:"none"},inline:{display:"inline"},"inline-block":{display:"inline-block"},visible:{visibility:"visible"},invisible:{visibility:"hidden"},collapse:{visibility:"collapse"},"list-none":{"list-style-type":"none"},"list-disc":{"list-style-type":"disc"},"list-decimal":{"list-style-type":"decimal"},flex:{display:"flex"},"flex-1":{flex:"1 1 0%"},"flex-inline":{display:"inline-flex"},"flex-row":{"flex-direction":"row"},"flex-col":{"flex-direction":"column"},"flex-row-reverse":{"flex-direction":"row-reverse"},"flex-col-reverse":{"flex-direction":"column-reverse"},"flex-wrap":{"flex-wrap":"wrap"},"flex-wrap-reverse":{"flex-wrap":"wrap-reverse"},"flex-nowrap":{"flex-wrap":"nowrap"},"justify-start":{"justify-content":"flex-start"},"justify-end":{"justify-content":"flex-end"},"justify-center":{"justify-content":"center"},"justify-between":{"justify-content":"space-between"},"justify-around":{"justify-content":"space-around"},"justify-evenly":{"justify-content":"space-evenly"},"justify-stretch":{"justify-content":"stretch"},"items-start":{"align-items":"flex-start"},"items-end":{"align-items":"flex-end"},"items-center":{"align-items":"center"},"items-stretch":{"align-items":"stretch"},"flex-grow":{"flex-grow":1},"flex-shrink":{"flex-shrink":1},"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"},"cursor-pointer":{cursor:"pointer"},"cursor-wait":{cursor:"wait"},"cursor-not-allowed":{cursor:"not-allowed"},"select-none":{"user-select":"none"},"select-all":{"user-select":"all"},"pointer-events-auto":{"pointer-events":"auto"},"pointer-events-none":{"pointer-events":"none"},"box-border":{"box-sizing":"border-box"},"box-content":{"box-sizing":"content-box"},resize:{resize:"both"},"resize-x":{resize:"horizontal"},"resize-y":{resize:"vertical"},"resize-none":{resize:"none"},border:{border:"1px solid"},"border-none":{border:"none"},"border-solid":{"border-style":"solid"},"border-dashed":{"border-style":"dashed"},"border-dotted":{"border-style":"dotted"},"border-collapse":{"border-collapse":"collapse"},"rounded-none":{"border-radius":"0"},rounded:{"border-radius":".25rem"},"rounded-sm":{"border-radius":".125rem"},"rounded-md":{"border-radius":".375rem"},"rounded-lg":{"border-radius":".5rem"},"rounded-xl":{"border-radius":".75rem"},"rounded-full":{"border-radius":"9999px"},shadow:{"box-shadow":"0 0 1px 0 rgba(0, 0, 0, 0.05)"},"shadow-sm":{"box-shadow":"0 1px 2px 0 rgba(0, 0, 0, 0.05)"},"shadow-md":{"box-shadow":"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},"shadow-lg":{"box-shadow":"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},"shadow-xl":{"box-shadow":"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)"},"shadow-2xl":{"box-shadow":"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},"shadow-inner":{"box-shadow":"inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)"},"shadow-outline":{"box-shadow":"0 0 0 3px rgba(66, 153, 225, 0.5)"},"shadow-none":{"box-shadow":"none"},"transition-none":{transition:"none"},transition:{transition:"all 150ms ease-in-out"},"animate-none":{animation:"none"},"animate-spin":{animation:"spin 1s linear infinite"},"animate-ping":{animation:"ping 1s cubic-bezier(0, 0, 0.2, 1) infinite"},"animate-pulse":{animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}},v=["@keyframes spin {\n from { transform: rotate(0deg) }\n to { transform: rotate(360deg) }\n }","@keyframes ping {\n 75%, 100% {\n transform: scale(2);\n opacity: 0;\n }\n }","@keyframes pulse {\n 0%, 100% { opacity: 1 }\n 50% { opacity: .5 }\n }"],$={red:{50:16772078,100:16764370,200:15702682,300:15037299,400:15684432,500:16007990,600:15022389,700:13840175,800:12986408,900:12000284},pink:{50:16573676,100:16301008,200:16027569,300:15753874,400:15483002,500:15277667,600:14162784,700:12720219,800:11342935,900:8916559},purple:{50:15984117,100:14794471,200:13538264,300:12216520,400:11225020,500:10233776,600:9315498,700:8069026,800:6953882,900:4854924},"deep-purple":{50:15591414,100:13747433,200:11771355,300:9795021,400:8280002,500:6765239,600:6174129,700:5320104,800:4532128,900:3218322},indigo:{50:15264502,100:12962537,200:10463450,300:7964363,400:6056896,500:4149685,600:3754411,700:3162015,800:2635155,900:1713022},blue:{50:14938877,100:12312315,200:9489145,300:6600182,400:4367861,500:2201331,600:2001125,700:1668818,800:1402304,900:870305},"light-blue":{50:14808574,100:11789820,200:8508666,300:5227511,400:2733814,500:240116,600:236517,700:166097,800:161725,900:87963},cyan:{50:14743546,100:11725810,200:8445674,300:5099745,400:2541274,500:48340,600:44225,700:38823,800:33679,900:24676},teal:{50:14742257,100:11722715,200:8440772,300:5093036,400:2533018,500:38536,600:35195,700:31083,800:26972,900:19776},green:{50:15267305,100:13166281,200:10868391,300:8505220,400:6732650,500:5025616,600:4431943,700:3706428,800:3046706,900:1793568},"light-green":{50:15857897,100:14478792,200:12968357,300:11457921,400:10275941,500:9159498,600:8172354,700:6856504,800:5606191,900:3369246},lime:{50:16382951,100:15791299,200:15134364,300:14477173,400:13951319,500:13491257,600:12634675,700:11514923,800:10394916,900:8550167},yellow:{50:16776679,100:16775620,200:16774557,300:16773494,400:16772696,500:16771899,600:16635957,700:16498733,800:16361509,900:16088855},amber:{50:16775393,100:16772275,200:16769154,300:16766287,400:16763432,500:16761095,600:16757504,700:16752640,800:16748288,900:16740096},orange:{50:16774112,100:16769202,200:16764032,300:16758605,400:16754470,500:16750592,600:16485376,700:16088064,800:15690752,900:15094016},"deep-orange":{50:16509415,100:16764092,200:16755601,300:16747109,400:16740419,500:16733986,600:16011550,700:15092249,800:14172949,900:12531212},brown:{50:15723497,100:14142664,200:12364452,300:10586239,400:9268835,500:7951688,600:7162945,700:6111287,800:5125166,900:4073251},gray:{50:16448250,100:16119285,200:15658734,300:14737632,400:12434877,500:10395294,600:7697781,700:6381921,800:4342338,900:2171169},"blue-gray":{50:15527921,100:13621468,200:11583173,300:9479342,400:7901340,500:6323595,600:5533306,700:4545124,800:3622735,900:2503224}};function b(e){return`#${e.toString(16).padStart(6,"0")}`}function g(e){return u.map((t=>`.${t}\\:${e}:${t}`))}function E(e,t){return Object.entries(o).map((([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`))}function x(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function w(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100vw`],[`${t}-full`,`${e}: 100%`],...c.map((r=>[`${t}-${r}`,`${e}: ${r*a}rem`])),...c.map((r=>[`-${t}-${r}`,`${e}: -${r*a}rem`])),...c.map((r=>[`${t}-${r}px`,`${e}: ${r}px`])),...c.map((r=>[`-${t}-${r}px`,`${e}: -${r}px`])),...h.map((r=>[`${t}-${r}\\%`,`${e}: ${r}%`])),...h.map((r=>[`-${t}-${r}\\%`,`${e}: -${r}%`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${g(e).join(",")} { ${t} }`,...E(e,t)]))}function y(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-auto`,`${e}: auto`],[`${t}x-auto`,`${e}-left: auto; ${e}-right: auto;`],[`${t}y-auto`,`${e}-top: auto; ${e}-bottom: auto;`],[`${t}x-0`,`${e}-left: 0; ${e}-right: 0;`],[`${t}y-0`,`${e}-top: 0; ${e}-bottom: 0;`],...c.map((e=>[e,e*a])).map((([r,i])=>[`${t}x-${r}`,`${e}-left: ${i}rem; ${e}-right: ${i}rem;`])),...c.map((e=>[e,e*a])).map((([r,i])=>[`${t}y-${r}`,`${e}-top: ${i}rem; ${e}-bottom: ${i}rem;`])),...c.map((r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`])),...c.map((r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`])),...h.map((r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`])),...h.map((r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${g(e).join(",")} { ${t} }`,...E(e,t)]))}function A(){const e=[["white","#fff"],["black","#000"],["transparent","transparent"]].flatMap((([e,t])=>[[`text-${e}`,`color: ${t}`],[`fill-${e}`,`fill: ${t}`],[`bg-${e}`,`background-color: ${t}`],[`border-${e}`,`border-color: ${t}`]])),t=Object.entries($).flatMap((([e,t])=>[[`text-${e}`,`color: ${b(t[500])}`],[`fill-${e}`,`fill: ${b(t[500])}`],[`bg-${e}`,`background-color: ${b(t[500])}`],[`border-${e}`,`border-color: ${b(t[500])}`]])),r=Object.entries($).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[[`text-${e}-${t}`,`color: ${b(r)}`],[`fill-${e}-${t}`,`fill: ${b(r)}`],[`bg-${e}-${t}`,`background-color: ${b(r)}`],[`border-${e}-${t}`,`border-color: ${b(r)}`]]))));return[].concat(e).concat(t).concat(r).flatMap((([e,t])=>[`.${e} { ${t} }`,`${g(e).join(",")} { ${t} }`,...E(e,t)]))}const O=new n.A;globalThis.Mancha=O;const R=globalThis.document?.currentScript;if(globalThis.document?.currentScript?.hasAttribute("init")){const e=R?.hasAttribute("debug"),t=R?.getAttribute("cache"),r=R?.getAttribute("target")?.split("+")||["body"];window.addEventListener("load",(()=>{r.map((async r=>{const i=globalThis.document.querySelector(r);await O.debug(e).mount(i,{cache:t})}))}))}if(globalThis.document?.currentScript?.hasAttribute("css")){const e=R?.getAttribute("css")?.split("+");for(const t of e){const e=document.createElement("style");switch(t){case"basic":i.cZ.setTextContent(e,(0,s.cu)([s.CM`html{`,s.CM`max-width: 70ch;`,s.CM`padding: 2em 1em;`,s.CM`margin: auto;`,s.CM`line-height: 1.75;`,s.CM`font-size: 1.25em;`,s.CM`font-family: sans-serif;`,s.CM`}`,s.CM`h1,h2,h3,h4,h5,h6{`,s.CM`margin: 1em 0 0.5em;`,s.CM`}`,s.CM`p,ul,ol{`,s.CM`margin-bottom: 1em;`,s.CM`color: #1d1d1d;`,s.CM`}`]));break;case"utils":e.textContent=(I=void 0,[...v,...Object.entries(_).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[`.${e} { ${t}: ${r} }`,`${g(e).join(",")} { ${t}: ${r} }`,...E(e,`${t}: ${r}`)])))),...A(),...[["opacity-0","opacity: 0"],...h.map((e=>[`opacity-${e}`,"opacity: "+e/100]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${g(e).join(",")} { ${t} }`,...E(e,t)])),...w(f),...w(p),...y(p),...(I=d,Object.entries(I).flatMap((([e,t])=>[[`${t}t-0`,`${e}-top: 0`],[`${t}b-0`,`${e}-bottom: 0`],[`${t}l-0`,`${e}-left: 0`],[`${t}r-0`,`${e}-right: 0`],[`${t}t-auto`,`${e}-top: auto`],[`${t}b-auto`,`${e}-bottom: auto`],[`${t}l-auto`,`${e}-left: auto`],[`${t}r-auto`,`${e}-right: auto`],...["","-"].flatMap((r=>[...c.map((e=>[e,e*a])).map((([i,n])=>[`${r}${t}t-${i}`,`${e}-top: ${r}${n}rem`])),...c.map((e=>[e,e*a])).map((([i,n])=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${n}rem`])),...c.map((e=>[e,e*a])).map((([i,n])=>[`${r}${t}l-${i}`,`${e}-left: ${r}${n}rem`])),...c.map((e=>[e,e*a])).map((([i,n])=>[`${r}${t}r-${i}`,`${e}-right: ${r}${n}rem`])),...c.map((i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`])),...c.map((i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`])),...c.map((i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`])),...c.map((i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`])),...h.map((i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`])),...h.map((i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%;`])),...h.map((i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`])),...h.map((i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`]))]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${g(e).join(",")} { ${t} }`,...E(e,t)]))),...w(d),...y(d),...[["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...c.map((e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*a}rem`])),...c.map((e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*a}rem`])),...c.map((e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`])),...c.map((e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`])),["gap-0","gap: 0"],...c.map((e=>[`gap-${e}`,`gap: ${e*a}rem`])),...c.map((e=>[`gap-${e}px`,`gap: ${e}px`])),...c.map((e=>[`gap-x-${e}`,`column-gap: ${e*a}rem`])),...c.map((e=>[`gap-y-${e}`,`row-gap: ${e*a}rem`])),...c.map((e=>[`gap-x-${e}px`,`column-gap: ${e}px`])),...c.map((e=>[`gap-y-${e}px`,`row-gap: ${e}px`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${g(e).join(",")} { ${t} }`,...E(e,t)])),...w(m),...[...l.map((e=>[`border-${e}`,`border-width: ${e}px`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${g(e).join(",")} { ${t} }`,...E(e,t)]))].sort(x).join("\n"));break;default:console.error(`Unknown style name: "${t}"`)}globalThis.document.head.appendChild(e)}}var I})();
@@ -0,0 +1 @@
1
+ (()=>{"use strict";const t={};function e(t){0}class i{constructor(t,e){this.privateDoNotAccessOrElseWrappedAttributePrefix=e}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const r=i;function s(t){if(function(t){return t instanceof i}(t))return t.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}function n(t){return Object.isFrozen(t)&&Object.isFrozen(t.raw)}function a(t){return-1===t.toString().indexOf("`")}a((t=>t``))||a((t=>t`\0`))||a((t=>t`\n`))||a((t=>t`\u0000`)),n``&&n`\0`&&n`\n`&&n`\u0000`;function o(e){const i=e[0].toLowerCase();return new r(t,i)}let l,c="google#safe";function h(){var t;return""!==c&&null!==(t=function(){if("undefined"!=typeof window)return window.trustedTypes}())&&void 0!==t?t:null}class u{constructor(t,i){e(),this.privateDoNotAccessOrElseWrappedHtml=t}toString(){return this.privateDoNotAccessOrElseWrappedHtml.toString()}}function d(e,i){return null!=i?i:new u(e,t)}"undefined"!=typeof window&&window.TrustedHTML;function p(t){var e;const i=t;return d(i,null===(e=function(){var t,e;if(void 0===l)try{l=null!==(e=null===(t=h())||void 0===t?void 0:t.createPolicy(c,{createHTML:t=>t,createScript:t=>t,createScriptURL:t=>t}))&&void 0!==e?e:null}catch(t){l=null}return l}())||void 0===e?void 0:e.createHTML(i))}function f(t){var e;if(null===(e=h())||void 0===e?void 0:e.isHTML(t))return t;if(t instanceof u)return t.privateDoNotAccessOrElseWrappedHtml;throw new Error("")}"undefined"!=typeof window&&window.TrustedScriptURL;"undefined"!=typeof window&&window.TrustedScript;function _(t,e){e.appendChild(t);let i=(new XMLSerializer).serializeToString(e);return i=i.slice(i.indexOf(">")+1,i.lastIndexOf("</")),p(i)}const m=["data:","http:","https:","mailto:","ftp:"],E=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function v(t){if(!function(t){const e=!E.test(t);return e}(t))return t}function w(t){return v(t)}function b(t){const e=function(t){let e;try{e=new URL(t)}catch(t){return"https:"}return e.protocol}(t);return void 0!==e&&-1!==m.indexOf(e.toLowerCase())?t:"about:invalid#zClosurez"}function g(t,e){const i=e.createRange();i.selectNode(e.body);return function(t,e){return t.createContextualFragment(f(e))}(i,p(t))}function A(t){const e=t.nodeName;return"string"==typeof e?e:"FORM"}function y(t){return 3===t.nodeType}function T(t){const e=t.nodeType;return 1===e||"number"!=typeof e}var R,O;function N(t){try{return new URL(t,window.document.baseURI)}catch(t){return new URL("about:invalid")}}function I(t){return{valueOf:t}.valueOf()}!function(t){t[t.STYLE_TAG=0]="STYLE_TAG",t[t.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",t[t.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}(R||(R={}));class P{constructor(t,e,i,r,s){this.allowedElements=t,this.elementPolicies=e,this.allowedGlobalAttributes=i,this.globalAttributePolicies=r,this.globallyAllowedAttributePrefixes=s}isAllowedElement(t){return"FORM"!==t&&(this.allowedElements.has(t)||this.elementPolicies.has(t))}getAttributePolicy(t,e){const i=this.elementPolicies.get(e);if(null==i?void 0:i.has(t))return i.get(t);if(this.allowedGlobalAttributes.has(t))return{policyAction:O.KEEP};const r=this.globalAttributePolicies.get(t);return r||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((e=>0===t.indexOf(e)))?{policyAction:O.KEEP}:{policyAction:O.DROP})}}!function(t){t[t.DROP=0]="DROP",t[t.KEEP=1]="KEEP",t[t.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",t[t.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",t[t.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",t[t.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",t[t.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}(O||(O={}));const S=new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const x=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],C=[["A",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],L=["title","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-current","aria-disabled","aria-dropeffect","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-live","aria-multiline","aria-multiselectable","aria-orientation","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","alt","align","autocapitalize","autocomplete","autocorrect","autofocus","autoplay","bgcolor","border","cellpadding","cellspacing","checked","color","cols","colspan","controls","datetime","disabled","download","draggable","enctype","face","formenctype","frameborder","height","hreflang","hidden","ismap","label","lang","loop","max","maxlength","media","minlength","min","multiple","muted","nonce","open","placeholder","preload","rel","required","reversed","role","rows","rowspan","selected","shape","size","sizes","slot","span","spellcheck","start","step","summary","translate","type","valign","value","width","wrap","itemscope","itemtype","itemid","itemprop","itemref"],k=[["dir",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:O.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:O.KEEP_AND_SANITIZE_URL}],["target",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["target",new Set(["_self","_blank"])]])))}]],D=new P(new Set(x),new Map(C),new Set(L),new Map(k));new P(new Set(I((()=>x.concat(["STYLE"])))),new Map(C),new Set(I((()=>L.concat(["id","name","class"])))),new Map(I((()=>k.concat([["style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}]])))));class U{constructor(t,i,r,s,n){this.sanitizerTable=t,this.styleElementSanitizer=r,this.styleAttributeSanitizer=s,this.resourceUrlPolicy=n,this.changes=[],e()}sanitizeAssertUnchanged(t){return this.sanitize(t)}sanitize(t){const e=document.implementation.createHTMLDocument("");return _(this.sanitizeToFragmentInternal(t,e),e.body)}sanitizeToFragment(t){const e=document.implementation.createHTMLDocument("");return this.sanitizeToFragmentInternal(t,e)}sanitizeToFragmentInternal(t,e){const i=g(t,e),r=document.createTreeWalker(i,5,(t=>this.nodeFilter(t)));let s=r.nextNode();const n=e.createDocumentFragment();let a=n;for(;null!==s;){let t;if(y(s))if(this.styleElementSanitizer&&"STYLE"===a.nodeName){const e=this.styleElementSanitizer(s.data);t=this.createTextNode(e)}else t=this.sanitizeTextNode(s);else{if(!T(s)){throw new Error("")}t=this.sanitizeElementNode(s,e)}if(a.appendChild(t),s=r.firstChild(),s)a=t;else for(;!(s=r.nextSibling())&&(s=r.parentNode());)a=a.parentNode}return n}createTextNode(t){return document.createTextNode(t)}sanitizeTextNode(t){return this.createTextNode(t.data)}sanitizeElementNode(t,e){const i=A(t),r=e.createElement(i),s=t.attributes;for(const{name:t,value:e}of s){const n=this.sanitizerTable.getAttributePolicy(t,i);if(this.satisfiesAllConditions(n.conditions,s))switch(n.policyAction){case O.KEEP:z(r,t,e);break;case O.KEEP_AND_SANITIZE_URL:const s=b(e);s!==e&&this.recordChange(`Url in attribute ${t} was modified during sanitization. Original url:"${e}" was sanitized to: "${s}"`),z(r,t,s);break;case O.KEEP_AND_NORMALIZE:z(r,t,e.toLowerCase());break;case O.KEEP_AND_SANITIZE_STYLE:if(this.styleAttributeSanitizer){z(r,t,this.styleAttributeSanitizer(e))}else z(r,t,e);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY:if(this.resourceUrlPolicy){const s={type:R.HTML_ATTRIBUTE,attributeName:t,tagName:i},n=N(e),a=this.resourceUrlPolicy(n,s);a&&z(r,t,a.toString())}else z(r,t,e);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET:if(this.resourceUrlPolicy){const s={type:R.HTML_ATTRIBUTE,attributeName:t,tagName:i},n=$(e),a={parts:[]};for(const t of n.parts){const e=N(t.url),i=this.resourceUrlPolicy(e,s);i&&a.parts.push({url:i.toString(),descriptor:t.descriptor})}z(r,t,M(a))}else z(r,t,e);break;case O.DROP:this.recordChange(`Attribute: ${t} was dropped`)}else this.recordChange(`Not all conditions satisfied for attribute: ${t}.`)}return r}nodeFilter(t){if(y(t))return 1;if(!T(t))return 2;const e=A(t);return null===e?(this.recordChange(`Node name was null for node: ${t}`),2):this.sanitizerTable.isAllowedElement(e)?1:(this.recordChange(`Element: ${e} was dropped`),2)}recordChange(t){0}satisfiesAllConditions(t,e){var i;if(!t)return!0;for(const[r,s]of t){const t=null===(i=e.getNamedItem(r))||void 0===i?void 0:i.value;if(t&&!s.has(t))return!1}return!0}}function z(t,e,i){t.setAttribute(e,i)}function $(t){const e=[];for(const i of t.split(",")){const[t,r]=i.trim().split(/\s+/,2);e.push({url:t,descriptor:r})}return{parts:e}}function M(t){return t.parts.map((t=>{const{url:e,descriptor:i}=t;return`${e}${i?` ${i}`:""}`})).join(" , ")}class F{constructor(){this.calledBuild=!1,this.sanitizerTable=D}onlyAllowElements(t){const e=new Set,i=new Map;for(let r of t){if(r=r.toUpperCase(),!this.sanitizerTable.isAllowedElement(r))throw new Error(`Element: ${r}, is not allowed by html5_contract.textpb`);const t=this.sanitizerTable.elementPolicies.get(r);void 0!==t?i.set(r,t):e.add(r)}return this.sanitizerTable=new P(e,i,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}allowCustomElement(t,e){const i=new Set(this.sanitizerTable.allowedElements),r=new Map(this.sanitizerTable.elementPolicies);if(t=t.toUpperCase(),s=t,S.has(s.toUpperCase())||!/^[a-z][-_.a-z0-9]*-[-_.a-z0-9]*$/i.test(s))throw new Error(`Element: ${t} is not a custom element`);var s;if(e){const i=new Map;for(const t of e)i.set(t,{policyAction:O.KEEP});r.set(t,i)}else i.add(t);return this.sanitizerTable=new P(i,r,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}onlyAllowAttributes(t){const e=new Set,i=new Map,r=new Map;for(const r of t)this.sanitizerTable.allowedGlobalAttributes.has(r)&&e.add(r),this.sanitizerTable.globalAttributePolicies.has(r)&&i.set(r,this.sanitizerTable.globalAttributePolicies.get(r));for(const[e,i]of this.sanitizerTable.elementPolicies.entries()){const s=new Map;for(const[e,r]of i.entries())t.has(e)&&s.set(e,r);r.set(e,s)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,r,e,i),this}allowDataAttributes(t){const e=new Set(this.sanitizerTable.allowedGlobalAttributes);for(const i of t){if(0!==i.indexOf("data-"))throw new Error(`data attribute: ${i} does not begin with the prefix "data-"`);e.add(i)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,e,this.sanitizerTable.globalAttributePolicies),this}allowStyleAttributes(){const t=new Map(this.sanitizerTable.globalAttributePolicies);return t.set("style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,this.sanitizerTable.allowedGlobalAttributes,t),this}allowClassAttributes(){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);return t.add("class"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}allowIdAttributes(){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);return t.add("id"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}allowIdReferenceAttributes(){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);return t.add("aria-activedescendant").add("aria-controls").add("aria-labelledby").add("aria-owns").add("for").add("list"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}withResourceUrlPolicy(t){return this.resourceUrlPolicy=t,this}build(){if(this.calledBuild)throw new Error("this sanitizer has already called build");return this.calledBuild=!0,new U(this.sanitizerTable,t,void 0,void 0,this.resourceUrlPolicy)}}function G(t,e,i,r){if(0===t.length){throw new Error("")}const n=t.map((t=>s(t))),a=i.toLowerCase();if(n.every((t=>0!==a.indexOf(t))))throw new Error(`Attribute "${i}" does not match any of the allowed prefixes.`);e.setAttribute(i,r)}function K(t,e,i){return t.parseFromString(f(e),i)}Error;const W=[o`:`,o`style`,o`class`];function*Y(t,e=new Set){const i=new Set,r=Array.from(t.childNodes).filter((t=>!e.has(t)));for(yield t;r.length;){const t=r.shift();i.has(t)||(i.add(t),yield t),t.childNodes&&Array.from(t.childNodes).filter((t=>!e.has(t))).forEach((t=>r.push(t)))}}function H(t,e){return void 0!==t?.[e]}function B(t,e){return"function"==typeof t?.[e]}function V(t){return t.replace(/-./g,(t=>t[1].toUpperCase()))}function Z(t,e){return H(t,"attribs")?t.attribs?.[e]??null:t.getAttribute?.(e)??null}function j(t,e,i=""){return Z(t,i+e)||(t.dataset?.[V(e)]??null)}function q(t,e,i){H(t,"attribs")?t.attribs[e]=i:t.setAttribute?.(e,i)}function X(t,e,i){H(t,"attribs")?t.attribs[e]=i:G(W,t,e,i)}function Q(t,e,i){switch(e){case"disabled":return void(t.disabled=i);case"selected":return void(t.selected=i);case"checked":return void(t.checked=i);default:t[e]=i}}function J(t,e){H(t,"attribs")?delete t.attribs[e]:t.removeAttribute?.(e)}function tt(t,e,i=""){J(t,`${i}${e}`),J(t,`data-${e}`)}function et(t,e,i){if(H(t,"attribs")&&H(e,"attribs"))e.attribs[i]=t.attribs[i];else if(i.startsWith("data-")){const r=V(i.slice(5));e.dataset[r]=t.dataset?.[r]}else{const r=t?.getAttribute?.(i);X(e,i,r||"")}}function it(t){if(H(t,"firstElementChild"))return t.firstElementChild;return Array.from(t.children).find((t=>1===t.nodeType))}function rt(t,...e){if(B(t,"replaceWith"))return t.replaceWith(...e);{const i=t,r=i.parentNode,s=Array.from(r.childNodes).indexOf(i);e.forEach((t=>t.parentNode=r)),r.childNodes=[].concat(Array.from(r.childNodes).slice(0,s)).concat(e).concat(Array.from(r.childNodes).slice(s+1))}}function st(t,...e){B(t,"replaceChildren")?t.replaceChildren(...e):(t.childNodes=e,e.forEach((e=>e.parentNode=t)))}function nt(t,e){return B(e,"appendChild")?t.appendChild(e):(t.childNodes.push(e),e.parentNode=t,e)}function at(t,e){return B(e,"removeChild")?t.removeChild(e):(st(t,...Array.from(t.childNodes).filter((t=>t!==e))),e)}function ot(t,e,i){return i?B(t,"insertBefore")?t.insertBefore(e,i):(rt(i,e,i),e):nt(t,e)}function lt(t,e=0){return t?t.length<=e?t:t.slice(0,e-1)+"…":""}function ct(t,e=0){return globalThis.DocumentFragment&&t instanceof DocumentFragment?Array.from(t.childNodes).map((t=>ct(t,e))).join(""):lt(t.outerHTML||t.nodeValue||String(t),e)}function ht(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):""}class ut{iterable;constructor(t){this.iterable=t}filter(t){return new ut(ut.filterGenerator(t,this.iterable))}map(t){return new ut(ut.mapGenerator(t,this.iterable))}find(t){for(const e of this.iterable)if(t(e))return e}array(){return Array.from(this.iterable)}*generator(){for(const t of this.iterable)yield t}static*filterGenerator(t,e){for(const i of e)t(i)&&(yield i)}static*mapGenerator(t,e){for(const i of e)yield t(i)}static equals(t,e){const i=t[Symbol.iterator](),r=e[Symbol.iterator]();let s=i.next(),n=r.next();for(;!s.done&&!n.done;){if(s.value!==n.value)return!1;s=i.next(),n=r.next()}return s.done===n.done}}var dt;!function(t){t.resolveIncludes=async function(t,e){const i=t,r=i.tagName?.toLowerCase();if(!["include","link"].includes(r))return;if("link"===r&&"subresource"!==Z(i,"rel"))return;this.log("include directive found in:\n",ct(t,128)),this.log("include params:",e);const s="link"===i.tagName.toLocaleLowerCase()?"href":"src",n=Z(i,s);if(!n)throw new Error(`"${s}" attribute missing from ${ct(t,128)}.`);const a=[];"include"===r&&a.push("src"),"link"===r&&a.push("rel","href");const o=e=>{const r=it(e);for(const t of Array.from(i.attributes))r&&!a.includes(t.name)&&et(i,r,t.name);rt(t,...e.childNodes)},l={...e,rootDocument:!1,maxdepth:e?.maxdepth-1};if(0===l.maxdepth)throw new Error("Maximum recursion depth reached.");if(n.includes("://")||n.startsWith("//"))this.log("Including remote file from absolute path:",n),await this.preprocessRemote(n,l).then(o);else if(e?.dirpath?.includes("://")||e?.dirpath?.startsWith("//")){const t=n.startsWith("/")?n:`${e.dirpath}/${n}`;this.log("Including remote file from relative path:",t),await this.preprocessRemote(t,l).then(o)}else if("/"===n.charAt(0))this.log("Including local file from absolute path:",n),await this.preprocessLocal(n,l).then(o);else{const t=e?.dirpath&&"."!==e?.dirpath?`${e?.dirpath}/${n}`:n;this.log("Including local file from relative path:",t),await this.preprocessLocal(t,l).then(o)}},t.rebaseRelativePaths=async function(t,e){const i=t,r=i.tagName?.toLowerCase();if(!e?.dirpath)return;const s=Z(i,"src"),n=Z(i,"href"),a=s||n;if(!a||((o=a).includes("://")||o.startsWith("/")||o.startsWith("#")||o.startsWith("data:")))return;var o;const l=`${e.dirpath}/${a}`;this.log("Rebasing relative path as:",l),H(i,"attribs")?X(i,s?"src":"href",l):"img"===r?i.src=l:"a"===r?function(t,e){const i=w(e);void 0!==i&&(t.href=i)}(i,l):"source"===r||"audio"===r||"video"===r||"track"===r||"input"===r?i.src=l:"area"===r?function(t,e){const i=w(e);void 0!==i&&(t.href=i)}(i,l):this.log("Unable to rebase relative path for element:",r)},t.registerCustomElements=async function(t,e){const i=t,r=i.tagName?.toLowerCase(),s=(Z(i,"is")||Z(i,"alt"))?.toLowerCase();if(["template","div"].includes(r)&&s){if("div"===r&&"template"!==Z(i,"role"))return;this._customElements.has(s)||(this.log(`Registering custom element: ${s}\n`,ct(i,128)),this._customElements.set(s,i),at(i.parentNode,i))}},t.resolveCustomElements=async function(t,e){const i=t,r=i.tagName?.toLowerCase();let s=r;if("div"===s&&(s=Z(i,"role")?.toLowerCase()||s),s&&this._customElements.has(s)){this.log(`Processing custom element: ${s}\n`,ct(i,128));const e=this._customElements.get(s),n=(e.content||e).cloneNode(!0),a=it(n);if(a)for(const t of Array.from(i.attributes))"div"===r&&"role"===t.name||et(i,a,t.name);const o=new ut(Y(n)).find((t=>"slot"===t.tagName?.toLowerCase()));o&&rt(o,...i.childNodes),rt(t,...n.childNodes)}},t.resolveTextNodeExpressions=async function(t,e){const i=t.nodeValue||"";if(3!==t.nodeType||!i?.trim())return;this.log("Processing node content value:\n",lt(i,128));const r=new RegExp(/{{ ([^}]+) }}/gm),s=Array.from(i.matchAll(r)).map((t=>t[1]));return this.effect((function(){let e=i;for(const i of s){const r=this.eval(i,{$elem:t});e=e.replace(`{{ ${i} }}`,String(r))}t.nodeValue=e}))},t.resolveDataAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,r=j(i,"data",":");if(r){this.log(":data attribute found in:\n",ct(t,128)),tt(i,"data",":");const s=e?.rootNode===t?this:this.subrenderer();t.renderer=s;const n=s.eval(r,{$elem:t});if(await Promise.all(Object.entries(n).map((([t,e])=>s.set(t,e)))),s!==this)for(const e of Y(t,this._skipNodes))this._skipNodes.add(e);await s.mount(t,e)}},t.resolveClassAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,r=j(i,"class",":");if(r){this.log(":class attribute found in:\n",ct(t,128)),tt(i,"class",":");const e=Z(i,"class")||"";return this.effect((function(){const s=this.eval(r,{$elem:t});X(i,"class",(s?`${e} ${s}`:e).trim())}))}},t.resolveTextAttributes=async function(t,e){if(this._skipNodes.has(t))return;const i=t,r=j(i,"text",":");if(r){this.log(":text attribute found in:\n",ct(t,128)),tt(i,"text",":");const e=e=>this.textContent(t,e);return this.effect((function(){e(this.eval(r,{$elem:t}))}))}},t.resolveHtmlAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,r=j(i,"html",":");return r?(this.log(":html attribute found in:\n",ct(t,128)),tt(i,"html",":"),this.effect((function(){const s=this.eval(r,{$elem:t});return new Promise((async t=>{const r=await this.preprocessString(s,e);await this.renderNode(r),st(i,r),t()}))}))):void 0},t.resolveEventAttributes=async function(t,e){if(this._skipNodes.has(t))return;const i=t;for(const e of Array.from(i.attributes||[]))if(e.name.startsWith(":on:")||e.name.startsWith("data-on-")){const r=e.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!r)throw new Error(`Invalid event attribute: ${e.name}`);this.log(e.name,"attribute found in:\n",ct(t,128)),J(i,e.name);const s="submit"===r&&"FORM"===i.tagName.toUpperCase();t.addEventListener?.(r,(i=>(s&&i.preventDefault(),this.eval(e.value,{$elem:t,$event:i}))))}},t.resolveForAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,r=j(i,"for",":")?.trim();if(r){this.log(":for attribute found in:\n",ct(t,128)),tt(i,"for",":");for(const e of Y(t,this._skipNodes))this._skipNodes.add(e);const s=t.parentNode,n=this.createElement("template",t.ownerDocument);ot(s,n,t),at(s,t),nt(n,t),this.log(":for template:\n",ct(n,128));const a=r.split(" in ",2);if(2!==a.length)throw new Error(`Invalid :for format: \`${r}\`. Expected "{key} in {expression}".`);const o=[],[l,c]=a;await this.effect((function(){const i=this.eval(c,{$elem:t});if(this.log(":for list items:",i),o.splice(0,o.length).forEach((t=>{at(s,t),this._skipNodes.delete(t)})),!Array.isArray(i))return console.error(`Expression did not yield a list: \`${c}\` => \`${i}\``),Promise.resolve();const r=[];for(const s of i){const i=this.subrenderer();i.set(l,s);const n=t.cloneNode(!0);o.push(n),this._skipNodes.add(n),r.push(i.mount(n,e)),this.log("Rendered list child:\n",ct(n,128))}const a=n.nextSibling;for(const t of o)ot(s,t,a);return Promise.all(r)}))}},t.resolveBindAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,r=j(i,"bind",":");if(r){this.log(":bind attribute found in:\n",ct(t,128));const e=["change","input"],s=Z(i,":bind:on")?.split(",")||i.dataset.bindOn?.split(",")||e;tt(i,"bind",":"),J(i,":bind:on"),J(i,"data-bind-on");const n="checkbox"===Z(i,"type")?"checked":"value";this.effect((function(){const e=this.eval(r,{$elem:t});i[n]=e}));const a=`${r} = $elem.${n}`;for(const e of s)t.addEventListener(e,(()=>this.eval(a,{$elem:t})))}},t.resolveShowAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,r=j(i,"show",":");if(r){this.log(":show attribute found in:\n",ct(t,128)),tt(i,"show",":");const e="none"===i.style?.display?"":i.style?.display??Z(i,"style")?.split(";")?.find((t=>"display"===t.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const s=this.eval(r,{$elem:t});i.style?i.style.display=s?e:"none":X(i,"style",`display: ${s?e:"none"};`)}))}},t.resolveCustomAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t;for(const e of Array.from(i.attributes||[])){const r=":attr:",s="data-attr-";if(e.name.startsWith(r)||e.name.startsWith(s)){this.log(e.name,"attribute found in:\n",ct(t,128)),J(i,e.name);const n=e.name.split(r,2).at(-1)?.split(s,2).at(-1);this.effect((function(){const r=this.eval(e.value,{$elem:t});q(i,n,r)}))}}},t.resolveCustomProperty=async function(t,e){if(this._skipNodes.has(t))return;const i=t;for(const e of Array.from(i.attributes||[])){const r=":prop:",s="data-prop-";if(e.name.startsWith(r)||e.name.startsWith(s)){this.log(e.name,"property found in:\n",ct(t,128)),J(i,e.name);const n=e.name.split(r,2).at(-1)?.split(s,2).at(-1),a=V(n);this.effect((function(){const r=this.eval(e.value,{$elem:t});Q(i,a,r)}))}}}}(dt||(dt={}));const pt=["this"],ft=["+","-","!"],_t=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],mt={"!":0,":":0,",":0,")":0,"]":0,"}":0,"|>":1,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"{":13},Et=["==","!=","<=",">=","||","&&","??","|>"],vt=["===","!=="];var wt;!function(t){t[t.STRING=1]="STRING",t[t.IDENTIFIER=2]="IDENTIFIER",t[t.DOT=3]="DOT",t[t.COMMA=4]="COMMA",t[t.COLON=5]="COLON",t[t.INTEGER=6]="INTEGER",t[t.DECIMAL=7]="DECIMAL",t[t.OPERATOR=8]="OPERATOR",t[t.GROUPER=9]="GROUPER",t[t.KEYWORD=10]="KEYWORD",t[t.ARROW=11]="ARROW"}(wt||(wt={}));const bt=(t,e,i=0)=>({kind:t,value:e,precedence:i}),gt=t=>95===t||36===t||65<=(t&=-33)&&t<=90,At=t=>48<=t&&t<=57;class yt{_input;_index=-1;_tokenStart=0;_next;constructor(t){this._input=t,this._advance()}nextToken(){for(;9===(t=this._next)||10===t||13===t||32===t;)this._advance(!0);var t;if((t=>34===t||39===t)(this._next))return this._tokenizeString();if(gt(this._next))return this._tokenizeIdentOrKeyword();if(At(this._next))return this._tokenizeNumber();if(46===this._next)return this._tokenizeDot();if(44===this._next)return this._tokenizeComma();if(58===this._next)return this._tokenizeColon();if((t=>43===t||45===t||42===t||47===t||33===t||38===t||37===t||60===t||61===t||62===t||63===t||94===t||124===t)(this._next))return this._tokenizeOperator();if((t=>40===t||41===t||91===t||93===t||123===t||125===t)(this._next))return this._tokenizeGrouper();if(this._advance(),void 0!==this._next)throw new Error(`Expected end of input, got ${this._next}`)}_advance(t){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),!0===t&&(this._tokenStart=this._index)):this._next=void 0}_getValue(t=0){const e=this._input.substring(this._tokenStart,this._index+t);return 0===t&&this._clearValue(),e}_clearValue(){this._tokenStart=this._index}_tokenizeString(){const t="unterminated string",e=this._next;for(this._advance(!0);this._next!==e;){if(void 0===this._next)throw new Error(t);if(92===this._next&&(this._advance(),void 0===this._next))throw new Error(t);this._advance()}const i=bt(wt.STRING,this._getValue().replace(/\\(.)/g,((t,e)=>{switch(e){case"n":return"\n";case"r":return"\r";case"t":return"\t";case"b":return"\b";case"f":return"\f";default:return e}})));return this._advance(),i}_tokenizeIdentOrKeyword(){do{this._advance()}while(t=this._next,gt(t)||At(t));var t;const e=this._getValue(),i=(r=e,-1!==pt.indexOf(r)?wt.KEYWORD:wt.IDENTIFIER);var r;return bt(i,e)}_tokenizeNumber(){do{this._advance()}while(At(this._next));return 46===this._next?this._tokenizeDot():bt(wt.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),At(this._next)?this._tokenizeFraction():(this._clearValue(),bt(wt.DOT,".",13))}_tokenizeComma(){return this._advance(!0),bt(wt.COMMA,",")}_tokenizeColon(){return this._advance(!0),bt(wt.COLON,":")}_tokenizeFraction(){do{this._advance()}while(At(this._next));return bt(wt.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let t=this._getValue(2);if(-1!==vt.indexOf(t))this._advance(),this._advance();else{if(t=this._getValue(1),"=>"===t)return this._advance(),bt(wt.ARROW,t);-1!==Et.indexOf(t)&&this._advance()}return t=this._getValue(),bt(wt.OPERATOR,t,mt[t])}_tokenizeGrouper(){const t=String.fromCharCode(this._next),e=bt(wt.GROUPER,t,mt[t]);return this._advance(!0),e}}class Tt{_kind;_tokenizer;_ast;_token;_value;constructor(t,e){this._tokenizer=new yt(t),this._ast=e}parse(){return this._advance(),this._parseExpression()}_advance(t,e){if(!this._matches(t,e))throw new Error(`Expected kind ${t} (${e}), was ${this._token?.kind} (${this._token?.value})`);const i=this._tokenizer.nextToken();this._token=i,this._kind=i?.kind,this._value=i?.value}_matches(t,e){return!(t&&this._kind!==t||e&&this._value!==e)}_parseExpression(){if(!this._token)return this._ast.empty();const t=this._parseUnary();return void 0===t?void 0:this._parsePrecedence(t,0)}_parsePrecedence(t,e){if(void 0===t)throw new Error("Expected left to be defined.");for(;this._token;)if(this._matches(wt.GROUPER,"(")){const e=this._parseArguments();t=this._ast.invoke(t,void 0,e)}else if(this._matches(wt.GROUPER,"[")){const e=this._parseIndex();t=this._ast.index(t,e)}else if(this._matches(wt.DOT)){this._advance();const e=this._parseUnary();t=this._makeInvokeOrGetter(t,e)}else{if(this._matches(wt.KEYWORD))break;if(!(this._matches(wt.OPERATOR)&&this._token.precedence>=e))break;t="?"===this._value?this._parseTernary(t):this._parseBinary(t,this._token)}return t}_makeInvokeOrGetter(t,e){if(void 0===e)throw new Error("expected identifier");if("ID"===e.type)return this._ast.getter(t,e.value);if("Invoke"===e.type&&"ID"===e.receiver.type){const i=e.receiver;return this._ast.invoke(t,i.value,e.arguments)}throw new Error(`expected identifier: ${e}`)}_parseBinary(t,e){if(-1===_t.indexOf(e.value))throw new Error(`unknown operator: ${e.value}`);this._advance();let i=this._parseUnary();for(;(this._kind===wt.OPERATOR||this._kind===wt.DOT||this._kind===wt.GROUPER)&&this._token.precedence>e.precedence;)i=this._parsePrecedence(i,this._token.precedence);return this._ast.binary(t,e.value,i)}_parseUnary(){if(this._matches(wt.OPERATOR)){const t=this._value;if(this._advance(),"+"===t||"-"===t){if(this._matches(wt.INTEGER))return this._parseInteger(t);if(this._matches(wt.DECIMAL))return this._parseDecimal(t)}if(-1===ft.indexOf(t))throw new Error(`unexpected token: ${t}`);const e=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(t,e)}return this._parsePrimary()}_parseTernary(t){this._advance(wt.OPERATOR,"?");const e=this._parseExpression();this._advance(wt.COLON);const i=this._parseExpression();return this._ast.ternary(t,e,i)}_parsePrimary(){switch(this._kind){case wt.KEYWORD:const t=this._value;if("this"===t)return this._advance(),this._ast.id(t);if(-1!==pt.indexOf(t))throw new Error(`unexpected keyword: ${t}`);throw new Error(`unrecognized keyword: ${t}`);case wt.IDENTIFIER:return this._parseInvokeOrIdentifier();case wt.STRING:return this._parseString();case wt.INTEGER:return this._parseInteger();case wt.DECIMAL:return this._parseDecimal();case wt.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case wt.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const t=[];do{if(this._advance(),this._matches(wt.GROUPER,"]"))break;t.push(this._parseExpression())}while(this._matches(wt.COMMA));return this._advance(wt.GROUPER,"]"),this._ast.list(t)}_parseMap(){const t={};do{if(this._advance(),this._matches(wt.GROUPER,"}"))break;const e=this._value;(this._matches(wt.STRING)||this._matches(wt.IDENTIFIER))&&this._advance(),this._advance(wt.COLON),t[e]=this._parseExpression()}while(this._matches(wt.COMMA));return this._advance(wt.GROUPER,"}"),this._ast.map(t)}_parseInvokeOrIdentifier(){const t=this._value;if("true"===t)return this._advance(),this._ast.literal(!0);if("false"===t)return this._advance(),this._ast.literal(!1);if("null"===t)return this._advance(),this._ast.literal(null);if("undefined"===t)return this._advance(),this._ast.literal(void 0);const e=this._parseIdentifier(),i=this._parseArguments();return i?this._ast.invoke(e,void 0,i):e}_parseIdentifier(){if(!this._matches(wt.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const t=this._value;return this._advance(),this._ast.id(t)}_parseArguments(){if(!this._matches(wt.GROUPER,"("))return;const t=[];do{if(this._advance(),this._matches(wt.GROUPER,")"))break;const e=this._parseExpression();t.push(e)}while(this._matches(wt.COMMA));return this._advance(wt.GROUPER,")"),t}_parseIndex(){this._advance();const t=this._parseExpression();return this._advance(wt.GROUPER,"]"),t}_parseParenOrFunction(){const t=this._parseArguments();if(this._matches(wt.ARROW)){this._advance();const e=this._parseExpression(),i=t?.map((t=>t.value))??[];return this._ast.arrowFunction(i,e)}return this._ast.paren(t[0])}_parseString(){const t=this._ast.literal(this._value);return this._advance(),t}_parseInteger(t=""){const e=this._ast.literal(parseInt(`${t}${this._value}`,10));return this._advance(),e}_parseDecimal(t=""){const e=this._ast.literal(parseFloat(`${t}${this._value}`));return this._advance(),e}}const Rt={"+":(t,e)=>t+e,"-":(t,e)=>t-e,"*":(t,e)=>t*e,"/":(t,e)=>t/e,"%":(t,e)=>t%e,"==":(t,e)=>t==e,"!=":(t,e)=>t!=e,"===":(t,e)=>t===e,"!==":(t,e)=>t!==e,">":(t,e)=>t>e,">=":(t,e)=>t>=e,"<":(t,e)=>t<e,"<=":(t,e)=>t<=e,"||":(t,e)=>t||e,"&&":(t,e)=>t&&e,"??":(t,e)=>t??e,"|":(t,e)=>e(t),"|>":(t,e)=>e(t)},Ot={"+":t=>t,"-":t=>-t,"!":t=>!t};class Nt{timeouts=new Map;debounce(t,e){return new Promise(((i,r)=>{const s=this.timeouts.get(e);s&&clearTimeout(s),this.timeouts.set(e,setTimeout((()=>{try{i(e()),this.timeouts.delete(e)}catch(t){r(t)}}),t))}))}}const It=new class{empty(){return{type:"Empty",evaluate:t=>t,getIds:t=>t}}literal(t){return{type:"Literal",value:t,evaluate(t){return this.value},getIds:t=>t}}id(t){return{type:"ID",value:t,evaluate(t){return"this"===this.value?t:t?.[this.value]},getIds(t){return t.push(this.value),t}}}unary(t,e){const i=Ot[t];return{type:"Unary",operator:t,child:e,evaluate(t){return i(this.child.evaluate(t))},getIds(t){return this.child.getIds(t)}}}binary(t,e,i){const r=Rt[e];return{type:"Binary",operator:e,left:t,right:i,evaluate(t){if("="===this.operator){if("ID"!==this.left.type&&"Getter"!==this.left.type&&"Index"!==this.left.type)throw new Error(`Invalid assignment target: ${this.left}`);const e=this.right.evaluate(t);let i,r;return"Getter"===this.left.type?(i=this.left.receiver.evaluate(t),r=this.left.name):"Index"===this.left.type?(i=this.left.receiver.evaluate(t),r=this.left.argument.evaluate(t)):"ID"===this.left.type&&(i=t,r=this.left.value),void 0===i?void 0:i[r]=e}return r(this.left.evaluate(t),this.right.evaluate(t))},getIds(t){return this.left.getIds(t),this.right.getIds(t),t}}}getter(t,e){return{type:"Getter",receiver:t,name:e,evaluate(t){return this.receiver.evaluate(t)?.[this.name]},getIds(t){return this.receiver.getIds(t),t}}}invoke(t,e,i){if(null!=e&&"string"!=typeof e)throw new Error("method not a string");return{type:"Invoke",receiver:t,method:e,arguments:i,evaluate(t){const i=this.receiver.evaluate(t),r=this.method?i:t?.this??t,s=this.method?i?.[e]:i,n=(this.arguments??[]).map((e=>e?.evaluate(t)));return s?.apply?.(r,n)},getIds(t){return this.receiver.getIds(t),this.arguments?.forEach((e=>e?.getIds(t))),t}}}paren(t){return t}index(t,e){return{type:"Index",receiver:t,argument:e,evaluate(t){return this.receiver.evaluate(t)?.[this.argument.evaluate(t)]},getIds(t){return this.receiver.getIds(t),t}}}ternary(t,e,i){return{type:"Ternary",condition:t,trueExpr:e,falseExpr:i,evaluate(t){return this.condition.evaluate(t)?this.trueExpr.evaluate(t):this.falseExpr.evaluate(t)},getIds(t){return this.condition.getIds(t),this.trueExpr.getIds(t),this.falseExpr.getIds(t),t}}}map(t){return{type:"Map",entries:t,evaluate(e){const i={};if(t&&this.entries)for(const r in t){const t=this.entries[r];t&&(i[r]=t.evaluate(e))}return i},getIds(e){if(t&&this.entries)for(const i in t){const t=this.entries[i];t&&t.getIds(e)}return e}}}list(t){return{type:"List",items:t,evaluate(t){return this.items?.map((e=>e?.evaluate(t)))},getIds(t){return this.items?.forEach((e=>e?.getIds(t))),t}}}arrowFunction(t,e){return{type:"ArrowFunction",params:t,body:e,evaluate(t){const e=this.params,i=this.body;return function(...r){const s=Object.fromEntries(e.map(((t,e)=>[t,r[e]]))),n=new Proxy(t??{},{set:(t,e,i)=>(s.hasOwnProperty(e)&&(s[e]=i),t[e]=i),get:(t,e)=>s.hasOwnProperty(e)?s[e]:t[e]});return i.evaluate(n)}},getIds(t){return this.body.getIds(t).filter((t=>!this.params.includes(t)))}}}};function Pt(t,e){if(t.has(e))return t.get(e);if(t.has("$parent")){return Pt(t.get("$parent"),e)}return null}function St(t,e){if(t.has(e))return t;if(t.has("$parent")){return St(t.get("$parent"),e)}return null}class xt extends Nt{evalkeys=["$elem","$event"];expressionCache=new Map;store=new Map;observers=new Map;_observer=null;_lock=Promise.resolve();constructor(t){super();for(let[e,i]of Object.entries(t||{}))this.set(e,i)}wrapFunction(t){return(...e)=>t.call(this.$,...e)}wrapObject(t,e){return null==t||((i=t)instanceof xt||i.__is_proxy__)||t.constructor!==Object&&!Array.isArray(t)?t:new Proxy(t,{deleteProperty:(t,i)=>i in t&&(delete t[i],e(),!0),set:(i,r,s,n)=>{"object"==typeof s&&null!=t&&(s=this.wrapObject(s,e));const a=Reflect.set(i,r,s,n);return e(),a},get:(t,e,i)=>"__is_proxy__"===e||Reflect.get(t,e,i)});var i}watch(t,e){this.observers.has(t)||this.observers.set(t,new Set),this.observers.get(t)?.has(e)||this.observers.get(t)?.add(e)}async notify(t,e=10){const i=Array.from(this.observers.get(t)||[]);await this.debounce(e,(()=>Promise.all(i.map((t=>t.call(this.proxify(t)))))))}get(t,e){return e&&this.watch(t,e),Pt(this.store,t)}async set(t,e){if(e===this.store.get(t))return;const i=()=>this.notify(t);e&&"function"==typeof e&&(e=this.wrapFunction(e)),e&&"object"==typeof e&&(e=this.wrapObject(e,i)),function(t,e,i){const r=St(t,e);r?r.set(e,i):t.set(e,i)}(this.store,t,e),await i()}del(t){this.store.delete(t),this.observers.delete(t)}has(t){return this.store.has(t)}effect(t){return t.call(this.proxify(t))}proxify(t){const e=Array.from(this.store.entries()).map((([t])=>t)),i=Object.fromEntries(e.map((t=>[t,void 0])));return new Proxy(i,{get:(e,i,r)=>"string"==typeof i&&St(this.store,i)?this.get(i,t):"$"===i?this.proxify(t):Reflect.get(this,i,r),set:(t,e,i,r)=>("string"!=typeof e||e in this?Reflect.set(this,e,i,r):this.set(e,i),!0)})}get $(){return this.proxify()}makeEvalFunction(t){if(t.includes(";"))throw new Error("Complex expressions are not supported.");let e=null;if(t.includes(" = ")){const[i,r]=t.split(" = ");e=i.trim(),t=r.trim()}return(i,r)=>{const s=((t,e)=>new Tt(t,e).parse())(t,It),n=s?.getIds([])?.map((t=>[t,r[t]??i[t]??globalThis[t]])),a=s?.evaluate(Object.fromEntries(n||[]));if(!e)return a;i[e]=a}}cachedExpressionFunction(t){return t=t.trim(),this.expressionCache.has(t)||this.expressionCache.set(t,this.makeEvalFunction(t)),this.expressionCache.get(t)}eval(t,e={}){const i=this._observer?this:this.$;if(this.store.has(t))return i[t];{const r=this.cachedExpressionFunction(t);try{return r(i,e)}catch(e){return console.error(`Failed to evaluate expression: ${t}`),console.error(e),null}}}}class Ct extends xt{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(t){return this.debugging=t,this}async fetchRemote(t,e){return fetch(t,{cache:e?.cache??"default"}).then((t=>t.text()))}async fetchLocal(t,e){return this.fetchRemote(t,e)}async preprocessString(t,e){this.log("Preprocessing string content with params:\n",e);const i=this.parseHTML(t,e);return await this.preprocessNode(i,e),i}async preprocessRemote(t,e){const i={};e?.cache&&(i.cache=e.cache);const r=await fetch(t,i).then((t=>t.text()));return this.preprocessString(r,{...e,dirpath:ht(t),rootDocument:e?.rootDocument??!t.endsWith(".tpl.html")})}async preprocessLocal(t,e){const i=await this.fetchLocal(t,e);return this.preprocessString(i,{...e,dirpath:ht(t),rootDocument:e?.rootDocument??!t.endsWith(".tpl.html")})}subrenderer(){const t=(new this.constructor).debug(this.debugging);return t.set("$parent",this),t.set("$root",this.get("$root")??this),t._customElements=this._customElements,t}log(...t){this.debugging&&console.debug(...t)}async preprocessNode(t,e){e={dirpath:this.dirpath,maxdepth:10,...e};const i=new ut(Y(t,this._skipNodes)).map((async t=>{this.log("Preprocessing node:\n",ct(t,128)),await dt.resolveIncludes.call(this,t,e),await dt.rebaseRelativePaths.call(this,t,e),await dt.registerCustomElements.call(this,t,e),await dt.resolveCustomElements.call(this,t,e)}));return await Promise.all(i.generator()),t}async renderNode(t,e){for(const i of Y(t,this._skipNodes))this.log("Rendering node:\n",ct(i,128)),await dt.resolveForAttribute.call(this,i,e),await dt.resolveDataAttribute.call(this,i,e),await dt.resolveTextAttributes.call(this,i,e),await dt.resolveHtmlAttribute.call(this,i,e),await dt.resolveShowAttribute.call(this,i,e),await dt.resolveClassAttribute.call(this,i,e),await dt.resolveBindAttribute.call(this,i,e),await dt.resolveEventAttributes.call(this,i,e),await dt.resolveTextNodeExpressions.call(this,i,e),await dt.resolveCustomAttribute.call(this,i,e),await dt.resolveCustomProperty.call(this,i,e);return t}async mount(t,e){e={...e,rootNode:t},await this.preprocessNode(t,e),await this.renderNode(t,e),Q(t,"renderer",this)}}const Lt=[":data",":for",":text",":html",":show",":class",":bind",":on:click",":on:input",":on:change",":on:submit",":attr:src",":attr:href",":attr:title",":prop:checked",":prop:selected",":prop:disabled"];new class extends Ct{impl="safe_browser";dirpath=ht(globalThis.location?.href??"http://localhost/");parseHTML(t,e={rootDocument:!1}){for(const e of Lt)t=t.replace(new RegExp(`\\s:${e.slice(1)}=`,"g"),` data-${e.slice(1).replace(":","-")}=`);t=(t=(t=t.replace(/<include(.*) src="([^"]+)"(.*)><\/include>/g,'<link $1 rel="subresource" href="$2" $3>')).replace(/<template is="([^"]+)">([\s\S]*)<\/template>/g,'<div role="template" alt="$1">$2</div>')).replace(/<(\w+)-(\w+)(.*)>([\s\S]*)<\/(\w+)-(\w+)>/g,'<div role="$1-$2" $3>$4</div>'),this.log("allowed attribs:",Lt.map((t=>`data-${t.slice(1).replace(":","-")}`)));const i=(new F).allowClassAttributes().allowStyleAttributes().allowDataAttributes(Lt.map((t=>`data-${t.slice(1).replace(":","-")}`))).build();if(this.log("parseHTML",t),this.log("sanitized",String(i.sanitize(t))),e.rootDocument){return K(new DOMParser,i.sanitize(t),"text/html")}return i.sanitizeToFragment(t)}serializeHTML(t){return(new XMLSerializer).serializeToString(t).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(t,e){return this.preprocessRemote(t,e)}createElement(t,e){return(e||document).createElement(t)}textContent(t,e){t.textContent=e}}})();
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "mancha",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "Javscript HTML rendering engine",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "types": "dist/index.d.ts",
8
- "unpkg": "mancha.js",
8
+ "unpkg": "dist/mancha.js",
9
9
  "scripts": {
10
10
  "clean": "rm -rf dist/",
11
11
  "webpack": "webpack",
package/webpack.config.js CHANGED
@@ -5,6 +5,8 @@ export default {
5
5
  mode: "production",
6
6
  entry: {
7
7
  mancha: "./dist/mancha.js",
8
+ "browser.min": "./dist/browser.js",
9
+ "safe_browser.min": "./dist/safe_browser.js",
8
10
  },
9
11
  output: {
10
12
  filename: "[name].js",