mancha 0.16.7 → 0.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +8 -7
- package/README.md +88 -25
- package/dist/browser.d.ts +42 -3
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/css_gen_utils.js +323 -412
- package/dist/css_gen_utils.js.map +1 -1
- package/dist/dome.d.ts +2 -2
- package/dist/dome.js +17 -0
- package/dist/dome.js.map +1 -1
- package/dist/expressions/ast.d.ts +79 -0
- package/dist/expressions/ast.js +6 -0
- package/dist/expressions/ast.js.map +1 -0
- package/dist/expressions/ast.test.d.ts +1 -0
- package/dist/expressions/ast.test.js +122 -0
- package/dist/expressions/ast.test.js.map +1 -0
- package/dist/expressions/ast_factory.d.ts +37 -0
- package/dist/expressions/ast_factory.js +119 -0
- package/dist/expressions/ast_factory.js.map +1 -0
- package/dist/expressions/ast_factory.test.d.ts +1 -0
- package/dist/expressions/ast_factory.test.js +88 -0
- package/dist/expressions/ast_factory.test.js.map +1 -0
- package/dist/expressions/constants.d.ts +6 -0
- package/dist/expressions/constants.js +72 -0
- package/dist/expressions/constants.js.map +1 -0
- package/dist/expressions/constants.test.d.ts +1 -0
- package/dist/expressions/constants.test.js +84 -0
- package/dist/expressions/constants.test.js.map +1 -0
- package/dist/expressions/eval.d.ts +101 -0
- package/dist/expressions/eval.js +375 -0
- package/dist/expressions/eval.js.map +1 -0
- package/dist/expressions/eval.test.d.ts +1 -0
- package/dist/expressions/eval.test.js +141 -0
- package/dist/expressions/eval.test.js.map +1 -0
- package/dist/expressions/expressions.test.d.ts +6 -0
- package/dist/expressions/expressions.test.js +7 -0
- package/dist/expressions/expressions.test.js.map +1 -0
- package/dist/expressions/index.d.ts +6 -0
- package/dist/expressions/index.js +7 -0
- package/dist/expressions/index.js.map +1 -0
- package/dist/expressions/parser.d.ts +32 -0
- package/dist/expressions/parser.js +341 -0
- package/dist/expressions/parser.js.map +1 -0
- package/dist/expressions/parser.test.d.ts +1 -0
- package/dist/expressions/parser.test.js +176 -0
- package/dist/expressions/parser.test.js.map +1 -0
- package/dist/expressions/tokenizer.d.ts +49 -0
- package/dist/expressions/tokenizer.js +253 -0
- package/dist/expressions/tokenizer.js.map +1 -0
- package/dist/expressions/tokenizer.test.d.ts +1 -0
- package/dist/expressions/tokenizer.test.js +99 -0
- package/dist/expressions/tokenizer.test.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +1 -1
- package/dist/mancha.d.ts +1 -1
- package/dist/mancha.js +1 -1
- package/dist/mancha.js.map +1 -1
- package/dist/plugins.js +94 -23
- package/dist/plugins.js.map +1 -1
- package/dist/renderer.d.ts +5 -2
- package/dist/renderer.js +6 -2
- package/dist/renderer.js.map +1 -1
- package/dist/safe_browser.d.ts +4 -3
- package/dist/safe_browser.js +1 -1
- package/dist/safe_browser.js.map +1 -1
- package/dist/store.d.ts +59 -13
- package/dist/store.js +112 -38
- package/dist/store.js.map +1 -1
- package/dist/test_utils.d.ts +2 -0
- package/dist/test_utils.js +14 -1
- package/dist/test_utils.js.map +1 -1
- package/dist/trusted_attributes.js +2 -0
- package/dist/trusted_attributes.js.map +1 -1
- package/dist/type_checker.d.ts +1 -0
- package/dist/type_checker.js +113 -41
- package/dist/type_checker.js.map +1 -1
- package/dist/worker.d.ts +2 -0
- package/dist/worker.js +1 -0
- package/dist/worker.js.map +1 -1
- package/docs/quickstart.md +200 -0
- package/gulpfile.js +5 -1
- package/package.json +19 -6
- package/tsec_exemptions.json +1 -1
package/dist/mancha.js
CHANGED
|
@@ -1 +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 d(e){return new h(e,i)}function u(e){if(e instanceof h)return e.privateDoNotAccessOrElseWrappedStyleSheet;throw new Error("")}function p(e,t){e.textContent=u(t)}Error;class f{iterable;constructor(e){this.iterable=e}filter(e){return new f(f.filterGenerator(e,this.iterable))}map(e){return new f(f.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 m(e){return Object.isFrozen(e)&&Object.isFrozen(e.raw)}function g(e){return-1===e.toString().indexOf("`")}g(e=>e``)||g(e=>e`\0`)||g(e=>e`\n`)||g(e=>e`\u0000`),m``&&m`\0`&&m`\n`&&m`\u0000`;function _(e){const t=e[0].toLowerCase();return new o(i,t)}var w,v;function $(e){return{valueOf:e}.valueOf()}!function(e){e[e.STYLE_TAG=0]="STYLE_TAG",e[e.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",e[e.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}(w||(w={}));class b{constructor(e,t,r,i,n){this.allowedElements=e,this.elementPolicies=t,this.allowedGlobalAttributes=r,this.globalAttributePolicies=i,this.globallyAllowedAttributePrefixes=n}isAllowedElement(e){return"FORM"!==e&&(this.allowedElements.has(e)||this.elementPolicies.has(e))}getAttributePolicy(e,t){const r=this.elementPolicies.get(t);if(null==r?void 0:r.has(e))return r.get(e);if(this.allowedGlobalAttributes.has(e))return{policyAction:v.KEEP};const i=this.globalAttributePolicies.get(e);return i||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some(t=>0===e.indexOf(t))?{policyAction:v.KEEP}:{policyAction:v.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"}(v||(v={}));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"],y=[["A",new Map([["href",{policyAction:v.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:v.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:v.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:v.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:v.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:v.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:v.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:v.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:v.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],E=["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"],A=[["dir",{policyAction:v.KEEP_AND_NORMALIZE,conditions:$(()=>new Map([["dir",new Set(["auto","ltr","rtl"])]]))}],["async",{policyAction:v.KEEP_AND_NORMALIZE,conditions:$(()=>new Map([["async",new Set(["async"])]]))}],["cite",{policyAction:v.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:v.KEEP_AND_NORMALIZE,conditions:$(()=>new Map([["loading",new Set(["eager","lazy"])]]))}],["poster",{policyAction:v.KEEP_AND_SANITIZE_URL}],["target",{policyAction:v.KEEP_AND_NORMALIZE,conditions:$(()=>new Map([["target",new Set(["_self","_blank"])]]))}]];new b(new Set(x),new Map(y),new Set(E),new Map(A)),new b(new Set($(()=>x.concat(["STYLE"]))),new Map(y),new Set($(()=>E.concat(["id","name","class"]))),new Map($(()=>A.concat([["style",{policyAction:v.KEEP_AND_SANITIZE_STYLE}]]))));function R(e){return d(e[0])}const O=[_`:`,_`style`,_`class`];function*I(e,t=new Set){const r=new Set,i=Array.from(e.childNodes).filter(e=>!t.has(e));for(yield e;i.length;){const e=i.shift();r.has(e)||(r.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter(e=>!t.has(e)).forEach(e=>i.push(e))}}function N(e,t){return void 0!==e?.[t]}function k(e,t){return"function"==typeof e?.[t]}function T(e){return e.replace(/-./g,e=>e[1].toUpperCase())}function S(e,t){return N(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function P(e,t,r=""){return S(e,r+t)||(e.dataset?.[T(t)]??null)}function C(e,t,r){N(e,"attribs")?e.attribs[t]=r:e.setAttribute?.(t,r)}function L(e,t,r){N(e,"attribs")?e.attribs[t]=r:l(O,e,t,r)}function D(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){N(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function U(e,t,r=""){M(e,`${r}${t}`),M(e,`data-${t}`)}function z(e,t,r){if(N(e,"attribs")&&N(t,"attribs"))t.attribs[r]=e.attribs[r];else if(r.startsWith("data-")){const i=T(r.slice(5));t.dataset[i]=e.dataset?.[i]}else{const i=e?.getAttribute?.(r);L(t,r,i||"")}}function j(e){if(N(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find(e=>1===e.nodeType)}function F(e,...t){if(k(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 G(e,...t){k(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach(t=>t.parentNode=e))}function K(e,t){return k(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function W(e,t){return k(t,"removeChild")?e.removeChild(t):(G(e,...Array.from(e.childNodes).filter(e=>e!==t)),t)}function H(e,t,r){return r?k(e,"insertBefore")?e.insertBefore(t,r):(F(r,t,r),t):K(e,t)}function Y(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function B(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map(e=>B(e,t)).join(""):Y(e.outerHTML||e.nodeValue||String(e),t)}function V(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}var Z;!function(e){e.resolveIncludes=async function(e,t){const r=e,i=r.tagName?.toLowerCase();if(!["include","link"].includes(i))return;if("link"===i&&"subresource"!==S(r,"rel"))return;this.log("include directive found in:\n",B(e,128)),this.log("include params:",t);const n="link"===r.tagName.toLocaleLowerCase()?"href":"src",s=S(r,n);if(!s)throw new Error(`"${n}" attribute missing from ${B(e,128)}.`);const o=[];"include"===i&&o.push("src"),"link"===i&&o.push("rel","href");const a=t=>{const i=j(t);for(const e of Array.from(r.attributes))i&&!o.includes(e.name)&&z(r,i,e.name);F(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=S(i,"src"),o=S(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),N(i,"attribs")?L(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=(S(r,"is")||S(r,"alt"))?.toLowerCase();if(["template","div"].includes(i)&&n){if("div"===i&&"template"!==S(r,"role"))return;this._customElements.has(n)||(this.log(`Registering custom element: ${n}\n`,B(r,128)),this._customElements.set(n,r),W(r.parentNode,r))}},e.resolveCustomElements=async function(e,t){const r=e,i=r.tagName?.toLowerCase();let n=i;if("div"===n&&(n=S(r,"role")?.toLowerCase()||n),n&&this._customElements.has(n)){this.log(`Processing custom element: ${n}\n`,B(r,128));const t=this._customElements.get(n),s=(t.content||t).cloneNode(!0),o=j(s);if(o)for(const e of Array.from(r.attributes))"div"===i&&"role"===e.name||z(r,o,e.name);const a=new f(I(s)).find(e=>"slot"===e.tagName?.toLowerCase());a&&F(a,...r.childNodes),F(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",Y(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=P(r,"data",":");if(i){this.log(":data attribute found in:\n",B(e,128)),U(r,"data",":");const n=t?.rootNode===e?this:this.subrenderer();e.renderer=n;const s=n.eval(i,{$elem:e});if(await Promise.all(Object.entries(s).map(([e,t])=>n._store.set(e,t))),n!==this)for(const t of I(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=P(r,"class",":");if(i){this.log(":class attribute found in:\n",B(e,128)),U(r,"class",":");const t=S(r,"class")||"";return this.effect(function(){const n=this.eval(i,{$elem:e});L(r,"class",(n?`${t} ${n}`:t).trim())})}},e.resolveTextAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"text",":");if(i){this.log(":text attribute found in:\n",B(e,128)),U(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=P(r,"html",":");return i?(this.log(":html attribute found in:\n",B(e,128)),U(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),G(r,i),e()})})):void 0},e.resolveEventAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){let i="",n=[];if(t.name.startsWith(":on:")?[i,...n]=t.name.substring(4).split("."):t.name.startsWith("data-on-")&&([i,...n]=t.name.substring(8).split(".")),!i)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",B(e,128)),U(r,t.name);const s="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,r=>((n.includes("prevent")||s)&&r.preventDefault(),this.eval(t.value,{$elem:e,$event:r})))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"for",":")?.trim();if(i){this.log(":for attribute found in:\n",B(e,128)),U(r,"for",":");for(const t of I(e,this._skipNodes))this._skipNodes.add(t);const n=S(r,"style")||"";C(r,"style","display: none;");const s=e.parentNode,o=this.createElement("template",e.ownerDocument);H(s,o,e),W(s,e),K(o,e),this.log(":for template:\n",B(o,128));const a=i.split(" in ",2);if(2!==a.length)throw new Error(`Invalid :for format: \`${i}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=a;await this.effect(function(){const r=this.eval(h,{$elem:e});if(this.log(":for list items:",r),l.splice(0,l.length).forEach(e=>{W(s,e),this._skipNodes.delete(e)}),!Array.isArray(r))return console.error(`Expression did not yield a list: \`${h}\` => \`${r}\``),Promise.resolve();const i=[];for(const s of r){const r=this.subrenderer();r._store.set(c,s);const o=e.cloneNode(!0);C(o,"style",n),l.push(o),this._skipNodes.add(o),i.push(r.mount(o,t)),this.log("Rendered list child:\n",B(o,128))}const a=o.nextSibling;for(const e of l)H(s,e,a);return Promise.all(i)})}},e.resolveBindAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"bind",":");if(i){this.log(":bind attribute found in:\n",B(e,128));const t=["change","input"],n=S(r,":bind:on")?.split(",")||r.dataset?.bindOn?.split(",")||t;U(r,"bind",":"),M(r,":bind:on"),M(r,"data-bind-on");const s="checkbox"===S(r,"type")?"checked":"value";i.includes(".")||this.has(i)||this.set(i,""),this.effect(function(){const t=this.eval(i,{$elem:e});"checked"===s?r.checked=!!t:r.value=t});const o=`${i} = $elem.${s}`;for(const t of n)e.addEventListener(t,()=>this.eval(o,{$elem:e}))}},e.resolveShowAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"show",":");if(i){this.log(":show attribute found in:\n",B(e,128)),U(r,"show",":");const t="none"===r.style?.display?"":r.style?.display??S(r,"style")?.split(";")?.find(e=>"display"===e.split(":")[0])?.split(":")?.at(1)?.trim();this.effect(function(){const n=this.eval(i,{$elem:e});r.style?r.style.display=n?t:"none":L(r,"style",`display: ${n?t:"none"};`)})}},e.resolveCustomAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":attr:",n="data-attr-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"attribute found in:\n",B(e,128)),M(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});C(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",B(e,128)),M(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1),o=T(s);this.effect(function(){const i=this.eval(t.value,{$elem:e});D(r,o,i)})}}},e.stripTypes=async function(e,t){const r=e;S(r,":types")&&M(r,":types"),S(r,"data-types")&&M(r,"data-types")}}(Z||(Z={}));const q=["this"],Q=["+","-","!"],X=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],J={"!":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},ee=["==","!=","<=",">=","||","&&","??","|>"],te=["===","!=="];var re;!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"}(re||(re={}));const ie=(e,t,r=0)=>({kind:e,value:t,precedence:r}),ne=e=>9===e||10===e||13===e||32===e,se=e=>95===e||36===e||65<=(e&=-33)&&e<=90,oe=e=>se(e)||ae(e),ae=e=>48<=e&&e<=57;class le{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;ne(this._next);)this._advance(!0);if(34===(e=this._next)||39===e)return this._tokenizeString();var e;if(se(this._next))return this._tokenizeIdentOrKeyword();if(ae(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=ie(re.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(oe(this._next));const e=this._getValue(),t=(r=e,-1!==q.indexOf(r)?re.KEYWORD:re.IDENTIFIER);var r;return ie(t,e)}_tokenizeNumber(){do{this._advance()}while(ae(this._next));return 46===this._next?this._tokenizeDot():ie(re.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),ae(this._next)?this._tokenizeFraction():(this._clearValue(),ie(re.DOT,".",13))}_tokenizeComma(){return this._advance(!0),ie(re.COMMA,",")}_tokenizeColon(){return this._advance(!0),ie(re.COLON,":")}_tokenizeFraction(){do{this._advance()}while(ae(this._next));return ie(re.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(-1!==te.indexOf(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),ie(re.ARROW,e);-1!==ee.indexOf(e)&&this._advance()}return e=this._getValue(),ie(re.OPERATOR,e,J[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=ie(re.GROUPER,e,J[e]);return this._advance(!0),t}}class ce{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new le(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(re.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(re.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(re.DOT)){this._advance();const t=this._parseUnary();e=this._makeInvokeOrGetter(e,t)}else{if(this._matches(re.KEYWORD))break;if(!(this._matches(re.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===X.indexOf(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let r=this._parseUnary();for(;(this._kind===re.OPERATOR||this._kind===re.DOT||this._kind===re.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(re.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(re.INTEGER))return this._parseInteger(e);if(this._matches(re.DECIMAL))return this._parseDecimal(e)}if(-1===Q.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(re.OPERATOR,"?");const t=this._parseExpression();this._advance(re.COLON);const r=this._parseExpression();return this._ast.ternary(e,t,r)}_parsePrimary(){switch(this._kind){case re.KEYWORD:const e=this._value;if("this"===e)return this._advance(),this._ast.id(e);if(-1!==q.indexOf(e))throw new Error(`unexpected keyword: ${e}`);throw new Error(`unrecognized keyword: ${e}`);case re.IDENTIFIER:return this._parseInvokeOrIdentifier();case re.STRING:return this._parseString();case re.INTEGER:return this._parseInteger();case re.DECIMAL:return this._parseDecimal();case re.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case re.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(re.GROUPER,"]"))break;e.push(this._parseExpression())}while(this._matches(re.COMMA));return this._advance(re.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e={};do{if(this._advance(),this._matches(re.GROUPER,"}"))break;const t=this._value;(this._matches(re.STRING)||this._matches(re.IDENTIFIER))&&this._advance(),this._advance(re.COLON),e[t]=this._parseExpression()}while(this._matches(re.COMMA));return this._advance(re.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(re.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(re.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(re.GROUPER,")"))break;const t=this._parseExpression();e.push(t)}while(this._matches(re.COMMA));return this._advance(re.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(re.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(re.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 he={"+":(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)},de={"+":e=>e,"-":e=>-e,"!":e=>!e};class ue{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 pe=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=de[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=he[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 fe(e,t){const r=e?._store;return r?.has(t)?r.get(t):r?.has("$parent")?fe(r.get("$parent"),t):null}function me(e,t){const r=e?._store;return r?.has(t)?e:r?.has("$parent")?me(r.get("$parent"),t):null}class ge extends ue{evalkeys=["$elem","$event"];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_observer=null;_store=new Map;_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 ge||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){const r=me(this,e);if(!r)throw new Error(`Cannot watch key "${e}" as it does not exist in the store.`);r.observers.has(e)||r.observers.set(e,new Set),r.observers.get(e)?.has(t)||r.observers.get(e)?.add(t)}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e).add(t)}async notify(e,t=10){const r=me(this,e),i=Array.from(r?.observers.get(e)||[]);await this.debounce(t,()=>Promise.all(i.map(e=>e.call(this.proxify(e)))))}get(e,t){return t&&this.watch(e,t),fe(this,e)}async set(e,t){if(t===this._store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=me(e,t);i?i._store.set(t,r):e._store.set(t,r)}(this,e,t);for(const[r,i]of this.keyHandlers.entries())if(r.test(e))for(const r of i)await Promise.resolve(r.call(this.$,e,t));await r()}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e)}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this._store.entries()).map(([e])=>e),r=Object.fromEntries(t.map(e=>[e,null]));return new Proxy(r,{get:(t,r,i)=>"string"==typeof r&&me(this,r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");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 ce(e,t).parse())(e,pe),s=n?.getIds([])?.map(e=>[e,i[e]??r[e]??globalThis[e]]),o=n?.evaluate(Object.fromEntries(s||[]));if(!t)return o;!function(e,t,r){const i=t.split(".");for(let t=0;t<i.length-1;t++)i[t]in e||(e[i[t]]={}),e=e[i[t]];e[i[i.length-1]]=r}(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}}}}const _e="$$";function we(){return new URL(globalThis.window?.location?.href||"http://localhost/")}function ve(e){return`${_e}${e}`}function $e(e){return e.keys().filter(e=>e.startsWith(_e))}function be(e,t,r){const i=function(e){return e.substring(2)}(t);let n=!1;if(r){const t=String(r);e.searchParams.get(i)!==t&&(e.searchParams.set(i,t),n=!0)}else e.searchParams.has(i)&&(e.searchParams.delete(i),n=!0);return n}async function xe(e){const t=we();await async function(e,t){for(const[r,i]of t.searchParams.entries()){const t=ve(r);e.get(t)!==i&&await e.set(t,i)}}(e,t),function(e,t){let r=!1;for(const i of $e(t))be(e,i,t.get(i))&&(r=!0);r&&globalThis.window?.history?.replaceState({},"",e.toString())}(t,e),e.addKeyHandler(new RegExp("^\\$\\$"),(e,t)=>{const r=we();be(r,e,t)&&globalThis.window?.history?.replaceState({},"",r.toString())}),globalThis.window?.addEventListener("popstate",function(e){return async()=>{const t=we(),r=new Set;for(const[i,n]of t.searchParams.entries()){const t=ve(i);r.add(t),e.get(t)!==n&&e.set(t,n)}const i=$e(e);for(const t of i)r.has(t)||e.del(t)}}(e))}class ye extends ge{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:V(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:V(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}subrenderer(){const e=(new this.constructor).debug(this.debugging);return e._store.set("$parent",this),e._store.set("$rootRenderer",this.get("$rootRenderer")??this),e._customElements=this._customElements,e}log(...e){this.debugging&&console.debug(...e)}async preprocessNode(e,t){t={dirpath:this.dirpath,maxdepth:10,...t};const r=new f(I(e,this._skipNodes)).map(async e=>{this.log("Preprocessing node:\n",B(e,128)),await Z.resolveIncludes.call(this,e,t),await Z.rebaseRelativePaths.call(this,e,t),await Z.registerCustomElements.call(this,e,t),await Z.resolveCustomElements.call(this,e,t)});return await Promise.all(r.generator()),e}async renderNode(e,t){for(const r of I(e,this._skipNodes))this.log("Rendering node:\n",B(r,128)),await Z.resolveForAttribute.call(this,r,t),await Z.resolveDataAttribute.call(this,r,t),await Z.resolveTextAttributes.call(this,r,t),await Z.resolveHtmlAttribute.call(this,r,t),await Z.resolveShowAttribute.call(this,r,t),await Z.resolveClassAttribute.call(this,r,t),await Z.resolveBindAttribute.call(this,r,t),await Z.resolveEventAttributes.call(this,r,t),await Z.resolveTextNodeExpressions.call(this,r,t),await Z.resolveCustomAttribute.call(this,r,t),await Z.resolveCustomProperty.call(this,r,t),await Z.stripTypes.call(this,r,t);return e}async mount(e,t){t={...t,rootNode:e},D(e,"renderer",this),this._store.set("$rootNode",e),this.has("$rootRenderer")||this._store.set("$rootRenderer",this),this.get("$rootRenderer")===this&&await xe(this),await this.preprocessNode(e,t),await this.renderNode(e,t)}}function Ee(){return d([R`html{`,R`max-width: 70ch;`,R`padding: 2em 1em;`,R`margin: auto;`,R`line-height: 1.75;`,R`font-size: 1.25em;`,R`font-family: sans-serif;`,R`}`,R`h1,h2,h3,h4,h5,h6{`,R`margin: 1em 0 0.5em;`,R`}`,R`p,ul,ol{`,R`margin-bottom: 1em;`,R`color: #1d1d1d;`,R`}`].map(u).join(""))}const Ae={sm:640,md:768,lg:1024,xl:1280},Re=.25,Oe=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],Ie=[...Oe,16,20,24,25,28,30,32,36,40,44,48,50,52,56,60,64,72,80,96,100,112,128,144,160,192,200,224,256,288,300,320,384,400,448,500,512,...Object.values(Ae)],Ne=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],ke=[75,100,150,200,300,500,700,1e3],Te=["hover","focus","disabled","active"],Se={margin:"m",padding:"p"},Pe={width:"w",height:"h"},Ce={top:"top",right:"right",bottom:"bottom",left:"left"},Le={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},De={"font-mono":{"font-family":"monospace"},"font-sans":{"font-family":"sans-serif"},"font-serif":{"font-family":"serif"},"font-cursive":{"font-family":"cursive"},"text-xs":{"font-size":".75rem","line-height":"calc(1 / 0.75)"},"text-sm":{"font-size":".875rem","line-height":"calc(1.25 / 0.875)"},"text-base":{"font-size":"1rem","line-height":"calc(1.5 / 1)"},"text-lg":{"font-size":"1.125rem","line-height":"calc(1.75 / 1.125)"},"text-xl":{"font-size":"1.25rem","line-height":"calc(1.75 / 1.25)"},"text-2xl":{"font-size":"1.5rem","line-height":"calc(2 / 1.5)"},"text-3xl":{"font-size":"1.875rem","line-height":"calc(2.25 / 1.875)"},"text-4xl":{"font-size":"2.25rem","line-height":"calc(2.5 / 2.25)"},"text-5xl":{"font-size":"3rem","line-height":"1"},"text-6xl":{"font-size":"3.75rem","line-height":"1"},"text-7xl":{"font-size":"4.5rem","line-height":"1"},"font-thin":{"font-weight":100},"font-extralight":{"font-weight":200},"font-light":{"font-weight":300},"font-normal":{"font-weight":400},"font-medium":{"font-weight":500},"font-semibold":{"font-weight":600},"font-bold":{"font-weight":700},"font-extrabold":{"font-weight":800},"font-black":{"font-weight":900},italic:{"font-style":"italic"},"not-italic":{"font-style":"normal"},"w-max":{width:"max-content"},"w-min":{width:"min-content"},"w-fit":{width:"fit-content"},"h-max":{height:"max-content"},"h-min":{height:"min-content"},"h-fit":{height:"fit-content"},"size-auto":{width:"auto",height:"auto"},"size-px":{width:"1px",height:"1px"},"size-full":{width:"100%",height:"100%"},"size-dvw":{width:"100dvw",height:"100dvw"},"size-dvh":{width:"100dvh",height:"100dvh"},"size-lvw":{width:"100lvw",height:"100lvw"},"size-lvh":{width:"100lvh",height:"100lvh"},"size-svw":{width:"100svw",height:"100svw"},"size-svh":{width:"100svh",height:"100svh"},"size-min":{width:"min-content",height:"min-content"},"size-max":{width:"max-content",height:"max-content"},"size-fit":{width:"fit-content",height:"fit-content"},"tracking-tighter":{"letter-spacing":"-0.05em"},"tracking-tight":{"letter-spacing":"-0.025em"},"tracking-normal":{"letter-spacing":"0"},"tracking-wide":{"letter-spacing":"0.025em"},"tracking-wider":{"letter-spacing":"0.05em"},"tracking-widest":{"letter-spacing":"0.1em"},"leading-none":{"line-height":"1"},"leading-tight":{"line-height":"1.25"},"leading-snug":{"line-height":"1.375"},"leading-normal":{"line-height":"1.5"},"leading-relaxed":{"line-height":"1.625"},"leading-loose":{"line-height":"2"},"text-left":{"text-align":"left"},"text-right":{"text-align":"right"},"text-center":{"text-align":"center"},"text-justify":{"text-align":"justify"},underline:{"text-decoration":"underline"},"no-underline":{"text-decoration":"none"},"decoration-none":{"text-decoration":"none"},"line-through":{"text-decoration":"line-through"},uppercase:{"text-transform":"uppercase"},lowercase:{"text-transform":"lowercase"},capitalize:{"text-transform":"capitalize"},truncate:{"white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis"},"text-elipsis":{"text-overflow":"ellipsis"},"text-clip":{"text-overflow":"clip"},"text-wrap":{"text-wrap":"wrap"},"text-nowrap":{"text-wrap":"nowrap"},"text-balance":{"text-wrap":"balance"},"text-pretty":{"text-wrap":"pretty"},"whitespace-normal":{"white-space":"normal"},"whitespace-nowrap":{"white-space":"nowrap"},"whitespace-pre":{"white-space":"pre"},"whitespace-pre-line":{"white-space":"pre-line"},"whitespace-pre-wrap":{"white-space":"pre-wrap"},"whitespace-break-spaces":{"white-space":"break-spaces"},relative:{position:"relative"},fixed:{position:"fixed"},absolute:{position:"absolute"},sticky:{position:"sticky"},"object-contain":{"object-fit":"contain"},"object-cover":{"object-fit":"cover"},"object-fill":{"object-fit":"fill"},"object-none":{"object-fit":"none"},block:{display:"block"},contents:{display:"contents"},hidden:{display:"none"},inline:{display:"inline"},"inline-block":{display:"inline-block"},visible:{visibility:"visible"},invisible:{visibility:"hidden"},collapse:{visibility:"collapse"},"list-none":{"list-style-type":"none"},"list-disc":{"list-style-type":"disc"},"list-decimal":{"list-style-type":"decimal"},flex:{display:"flex"},"flex-1":{flex:"1 1 0%"},"flex-inline":{display:"inline-flex"},"flex-row":{"flex-direction":"row"},"flex-col":{"flex-direction":"column"},"flex-row-reverse":{"flex-direction":"row-reverse"},"flex-col-reverse":{"flex-direction":"column-reverse"},"flex-wrap":{"flex-wrap":"wrap"},"flex-wrap-reverse":{"flex-wrap":"wrap-reverse"},"flex-nowrap":{"flex-wrap":"nowrap"},"justify-start":{"justify-content":"flex-start"},"justify-end":{"justify-content":"flex-end"},"justify-center":{"justify-content":"center"},"justify-between":{"justify-content":"space-between"},"justify-around":{"justify-content":"space-around"},"justify-evenly":{"justify-content":"space-evenly"},"justify-stretch":{"justify-content":"stretch"},"items-start":{"align-items":"flex-start"},"items-end":{"align-items":"flex-end"},"items-center":{"align-items":"center"},"items-stretch":{"align-items":"stretch"},"flex-grow":{"flex-grow":1},"flex-shrink":{"flex-shrink":1},"align-baseline":{"vertical-align":"baseline"},"align-top":{"vertical-align":"top"},"align-middle":{"vertical-align":"middle"},"align-bottom":{"vertical-align":"bottom"},"align-text-top":{"vertical-align":"text-top"},"align-text-bottom":{"vertical-align":"text-bottom"},"overflow-auto":{overflow:"auto"},"overflow-x-auto":{"overflow-x":"auto"},"overflow-y-auto":{"overflow-y":"auto"},"overflow-hidden":{overflow:"hidden"},"overflow-x-hidden":{"overflow-x":"hidden"},"overflow-y-hidden":{"overflow-y":"hidden"},"overflow-visible":{overflow:"visible"},"overscroll-auto":{"overscroll-behavior":"auto"},"overscroll-contain":{"overscroll-behavior":"contain"},"overscroll-none":{"overscroll-behavior":"none"},"overscroll-x-auto":{"overscroll-behavior-x":"auto"},"overscroll-x-contain":{"overscroll-behavior-x":"contain"},"overscroll-x-none":{"overscroll-behavior-x":"none"},"overscroll-y-auto":{"overscroll-behavior-y":"auto"},"overscroll-y-contain":{"overscroll-behavior-y":"contain"},"overscroll-y-none":{"overscroll-behavior-y":"none"},"z-auto":{"z-index":"auto"},"cursor-pointer":{cursor:"pointer"},"cursor-wait":{cursor:"wait"},"cursor-not-allowed":{cursor:"not-allowed"},"select-none":{"user-select":"none"},"select-all":{"user-select":"all"},"pointer-events-auto":{"pointer-events":"auto"},"pointer-events-none":{"pointer-events":"none"},"box-border":{"box-sizing":"border-box"},"box-content":{"box-sizing":"content-box"},resize:{resize:"both"},"resize-x":{resize:"horizontal"},"resize-y":{resize:"vertical"},"resize-none":{resize:"none"},border:{border:"1px solid"},"border-none":{border:"none"},"border-solid":{"border-style":"solid"},"border-dashed":{"border-style":"dashed"},"border-dotted":{"border-style":"dotted"},"border-collapse":{"border-collapse":"collapse"},"rounded-none":{"border-radius":"0"},rounded:{"border-radius":".25rem"},"rounded-sm":{"border-radius":".125rem"},"rounded-md":{"border-radius":".375rem"},"rounded-lg":{"border-radius":".5rem"},"rounded-xl":{"border-radius":".75rem"},"rounded-full":{"border-radius":"9999px"},shadow:{"box-shadow":"0 0 1px 0 rgba(0, 0, 0, 0.05)"},"shadow-sm":{"box-shadow":"0 1px 2px 0 rgba(0, 0, 0, 0.05)"},"shadow-md":{"box-shadow":"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},"shadow-lg":{"box-shadow":"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},"shadow-xl":{"box-shadow":"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)"},"shadow-2xl":{"box-shadow":"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},"shadow-inner":{"box-shadow":"inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)"},"shadow-outline":{"box-shadow":"0 0 0 3px rgba(66, 153, 225, 0.5)"},"shadow-none":{"box-shadow":"none"},"transition-none":{transition:"none"},transition:{transition:"all 150ms ease-in-out"},"animate-none":{animation:"none"},"animate-spin":{animation:"spin 1s linear infinite"},"animate-ping":{animation:"ping 1s cubic-bezier(0, 0, 0.2, 1) infinite"},"animate-pulse":{animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"},"bg-auto":{"background-size":"auto"},"bg-cover":{"background-size":"cover"},"bg-contain":{"background-size":"contain"},"bg-no-repeat":{"background-repeat":"no-repeat"},"bg-fixed":{"background-attachment":"fixed"},"bg-local":{"background-attachment":"local"},"bg-scroll":{"background-attachment":"scroll"}},Me=["@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 }"],Ue={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 ze(e){return`#${e.toString(16).padStart(6,"0")}`}function je(e){return Te.map(t=>`.${t}\\:${e}:${t}`)}function Fe(e,t){return Object.entries(Ae).map(([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`)}function Ge(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function Ke(e){return Object.entries(e).flatMap(([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100v${e.includes("height")?"h":"w"}`],[`${t}-full`,`${e}: 100%`],...Ie.map(r=>[`${t}-${r}`,`${e}: ${r*Re}rem`]),...Ie.map(r=>[`-${t}-${r}`,`${e}: -${r*Re}rem`]),...Ie.map(r=>[`${t}-${r}px`,`${e}: ${r}px`]),...Ie.map(r=>[`-${t}-${r}px`,`${e}: -${r}px`]),...Ne.map(r=>[`${t}-${r}\\%`,`${e}: ${r}%`]),...Ne.map(r=>[`-${t}-${r}\\%`,`${e}: -${r}%`])]).flatMap(([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)])}function We(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;`],...Ie.map(e=>[e,e*Re]).map(([r,i])=>[`${t}x-${r}`,`${e}-left: ${i}rem; ${e}-right: ${i}rem;`]),...Ie.map(e=>[e,e*Re]).map(([r,i])=>[`${t}y-${r}`,`${e}-top: ${i}rem; ${e}-bottom: ${i}rem;`]),...Ie.map(r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`]),...Ie.map(r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`]),...Ne.map(r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`]),...Ne.map(r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`])]).flatMap(([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)])}function He(){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(Ue).flatMap(([e,t])=>[[`text-${e}`,`color: ${ze(t[500])}`],[`fill-${e}`,`fill: ${ze(t[500])}`],[`bg-${e}`,`background-color: ${ze(t[500])}`],[`border-${e}`,`border-color: ${ze(t[500])}`]]),r=Object.entries(Ue).flatMap(([e,t])=>Object.entries(t).flatMap(([t,r])=>[[`text-${e}-${t}`,`color: ${ze(r)}`],[`fill-${e}-${t}`,`fill: ${ze(r)}`],[`bg-${e}-${t}`,`background-color: ${ze(r)}`],[`border-${e}-${t}`,`border-color: ${ze(r)}`]]));return[].concat(e).concat(t).concat(r).flatMap(([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)])}function Ye(){return[...Me,...Object.entries(De).flatMap(([e,t])=>Object.entries(t).flatMap(([t,r])=>[`.${e} { ${t}: ${r} }`,`${je(e).join(",")} { ${t}: ${r} }`,...Fe(e,`${t}: ${r}`)])),...He(),...[["opacity-0","opacity: 0"],...Ne.map(e=>[`opacity-${e}`,"opacity: "+e/100])].flatMap(([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)]),...[...Ne.map(e=>[`z-${e}`,`z-index: ${e}`])].flatMap(([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)]),...[...ke.map(e=>[`duration-${e}`,`transition-duration: ${e}ms`])].flatMap(([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)]),...Ke(Ce),...Ke(Pe),...We(Pe),...(e=Se,Object.entries(e).flatMap(([e,t])=>[[`${t}t-0`,`${e}-top: 0`],[`${t}b-0`,`${e}-bottom: 0`],[`${t}l-0`,`${e}-left: 0`],[`${t}r-0`,`${e}-right: 0`],[`${t}t-auto`,`${e}-top: auto`],[`${t}b-auto`,`${e}-bottom: auto`],[`${t}l-auto`,`${e}-left: auto`],[`${t}r-auto`,`${e}-right: auto`],...["","-"].flatMap(r=>[...Ie.map(e=>[e,e*Re]).map(([i,n])=>[`${r}${t}t-${i}`,`${e}-top: ${r}${n}rem`]),...Ie.map(e=>[e,e*Re]).map(([i,n])=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${n}rem`]),...Ie.map(e=>[e,e*Re]).map(([i,n])=>[`${r}${t}l-${i}`,`${e}-left: ${r}${n}rem`]),...Ie.map(e=>[e,e*Re]).map(([i,n])=>[`${r}${t}r-${i}`,`${e}-right: ${r}${n}rem`]),...Ie.map(i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`]),...Ie.map(i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`]),...Ie.map(i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`]),...Ie.map(i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`]),...Ne.map(i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`]),...Ne.map(i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%;`]),...Ne.map(i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`]),...Ne.map(i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`])])]).flatMap(([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)])),...Ke(Se),...We(Se),...[["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...Ie.map(e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*Re}rem`]),...Ie.map(e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*Re}rem`]),...Ie.map(e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`]),...Ie.map(e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`]),["gap-0","gap: 0"],...Ie.map(e=>[`gap-${e}`,`gap: ${e*Re}rem`]),...Ie.map(e=>[`gap-${e}px`,`gap: ${e}px`]),...Ie.map(e=>[`gap-x-${e}`,`column-gap: ${e*Re}rem`]),...Ie.map(e=>[`gap-y-${e}`,`row-gap: ${e*Re}rem`]),...Ie.map(e=>[`gap-x-${e}px`,`column-gap: ${e}px`]),...Ie.map(e=>[`gap-y-${e}px`,`row-gap: ${e}px`])].flatMap(([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)]),...Ke(Le),...[["border","border: 1px"],["border-x","border-inline-width: 1px"],["border-y","border-block-width: 1px"],...[0,...Oe].map(e=>[`border-${e}`,`border-width: ${e}px`]),...[0,...Oe].map(e=>[`border-x-${e}`,`border-inline-width: ${e}px;`]),...[0,...Oe].map(e=>[`border-y-${e}`,`border-block-width: ${e}px;`]),...["top","bottom","left","right"].flatMap(e=>[[`border-${e.slice(0,1)}`,`border-${e}: 1px`],...[0,...Oe].map(t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`])])].flatMap(([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)]),...[...Array.from({length:100},(e,t)=>t).map(e=>[`text-${e}px`,`font-size: ${e}px`]),...Array.from({length:100},(e,t)=>t*Re).map(e=>[`text-${e}rem`,`font-size: ${e}rem`])].flatMap(([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)])].sort(Ge).join("\n");var e}class Be extends ye{impl="browser";dirpath=V(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 Be;const Ve=new Be;globalThis.Mancha=Ve;const Ze=globalThis.document?.currentScript;if(globalThis.document?.currentScript?.hasAttribute("init")){const e=Ze?.hasAttribute("debug"),t=Ze?.getAttribute("cache"),r=Ze?.getAttribute("target")?.split("+")||["body"];window.addEventListener("load",()=>{r.map(async r=>{const i=globalThis.document.querySelector(r);await Ve.debug(e).mount(i,{cache:t})})})}if(globalThis.document?.currentScript?.hasAttribute("css")){const e=Ze?.getAttribute("css")?.split("+");for(const t of e){const e=document.createElement("style");switch(t){case"basic":p(e,Ee());break;case"utils":e.textContent=Ye();break;default:console.error(`Unknown style name: "${t}"`)}globalThis.document.head.appendChild(e)}}})();
|
|
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 d(e){return new h(e,i)}function u(e){if(e instanceof h)return e.privateDoNotAccessOrElseWrappedStyleSheet;throw new Error("")}function f(e,t){e.textContent=u(t)}Error;class p{iterable;constructor(e){this.iterable=e}filter(e){return new p(p.filterGenerator(e,this.iterable))}map(e){return new p(p.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 m(e){return Object.isFrozen(e)&&Object.isFrozen(e.raw)}function g(e){return-1===e.toString().indexOf("`")}g(e=>e``)||g(e=>e`\0`)||g(e=>e`\n`)||g(e=>e`\u0000`),m``&&m`\0`&&m`\n`&&m`\u0000`;function b(e){const t=e[0].toLowerCase();return new o(i,t)}var _,v;function w(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 x{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:v.KEEP};const i=this.globalAttributePolicies.get(e);return i||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some(t=>0===e.indexOf(t))?{policyAction:v.KEEP}:{policyAction:v.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"}(v||(v={}));new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const y=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],E=[["A",new Map([["href",{policyAction:v.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:v.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:v.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:v.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:v.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:v.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:v.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:v.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:v.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],$=["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"],A=[["dir",{policyAction:v.KEEP_AND_NORMALIZE,conditions:w(()=>new Map([["dir",new Set(["auto","ltr","rtl"])]]))}],["async",{policyAction:v.KEEP_AND_NORMALIZE,conditions:w(()=>new Map([["async",new Set(["async"])]]))}],["cite",{policyAction:v.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:v.KEEP_AND_NORMALIZE,conditions:w(()=>new Map([["loading",new Set(["eager","lazy"])]]))}],["poster",{policyAction:v.KEEP_AND_SANITIZE_URL}],["target",{policyAction:v.KEEP_AND_NORMALIZE,conditions:w(()=>new Map([["target",new Set(["_self","_blank"])]]))}]];new x(new Set(y),new Map(E),new Set($),new Map(A)),new x(new Set(w(()=>y.concat(["STYLE"]))),new Map(E),new Set(w(()=>$.concat(["id","name","class"]))),new Map(w(()=>A.concat([["style",{policyAction:v.KEEP_AND_SANITIZE_STYLE}]]))));function R(e){return d(e[0])}const O=[b`:`,b`style`,b`class`];function*I(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 k(e,t){return void 0!==e?.[t]}function N(e,t){return"function"==typeof e?.[t]}function T(e){return e.replace(/-./g,e=>e[1].toUpperCase())}function P(e,t){return k(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function S(e,t){return k(e,"attribs")?t in(e.attribs||{}):e.hasAttribute?.(t)??!1}function C(e,t,r=""){return P(e,r+t)||P(e,`data-${t}`)||(e.dataset?.[T(t)]??null)}function D(e,t,r){k(e,"attribs")?e.attribs[t]=r:e.setAttribute?.(t,r)}function L(e,t,r){k(e,"attribs")?e.attribs[t]=r:l(O,e,t,r)}function U(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){k(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function z(e,t,r=""){M(e,`${r}${t}`),M(e,`data-${t}`)}function F(e,t,r){if(k(e,"attribs")&&k(t,"attribs"))t.attribs[r]=e.attribs[r];else if(r.startsWith("data-")){const i=T(r.slice(5));t.dataset[i]=e.dataset?.[i]}else{const i=e?.getAttribute?.(r);L(t,r,i||"")}}function G(e){if(k(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find(e=>1===e.nodeType)}function j(e,...t){if(N(e,"replaceWith"))return e.replaceWith(...t);{const r=e,i=r.parentNode,n=Array.from(i.childNodes).indexOf(r);t.forEach(e=>e.parentNode=i),i.childNodes=[].concat(Array.from(i.childNodes).slice(0,n)).concat(t).concat(Array.from(i.childNodes).slice(n+1))}}function K(e,...t){N(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach(t=>t.parentNode=e))}function W(e,t){return N(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function Y(e,t){return N(t,"removeChild")?e.removeChild(t):(K(e,...Array.from(e.childNodes).filter(e=>e!==t)),t)}function H(e,t,r){return r?N(e,"insertBefore")?e.insertBefore(t,r):(j(r,t,r),t):W(e,t)}function B(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function V(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map(e=>V(e,t)).join(""):B(e.outerHTML||e.nodeValue||String(e),t)}function Z(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}var q;!function(e){e.resolveIncludes=async function(e,t){const r=e,i=r.tagName?.toLowerCase();if(!["include","link"].includes(i))return;if("link"===i&&"subresource"!==P(r,"rel"))return;this.log("include directive found in:\n",V(e,128)),this.log("include params:",t);const n="link"===r.tagName.toLocaleLowerCase()?"href":"src",s=P(r,n);if(!s)throw new Error(`"${n}" attribute missing from ${V(e,128)}.`);const o=[];"include"===i&&o.push("src"),"link"===i&&o.push("rel","href");const a=t=>{const i=G(t);for(const e of Array.from(r.attributes))i&&!o.includes(e.name)&&F(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=function(e,t){const i=e,n=i.tagName?.toLowerCase();if(!t?.dirpath)return;const s=P(i,"src"),o=P(i,"href"),a=C(i,"render",":"),l=s||o||a;if(!l||((c=l).includes("://")||c.startsWith("/")||c.startsWith("#")||c.startsWith("data:")))return;var c;const h=`${t.dirpath}/${l}`;this.log("Rebasing relative path as:",h),a?function(e,t,r,i=""){S(e,`${i}${t}`)?D(e,`${i}${t}`,r):S(e,`data-${t}`)?D(e,`data-${t}`,r):D(e,`${i}${t}`,r)}(i,"render",h,":"):k(i,"attribs")?L(i,s?"src":"href",h):"img"===n?i.src=h:"a"===n?function(e,t){const i=r(t);void 0!==i&&(e.href=i)}(i,h):"source"===n||"audio"===n||"video"===n||"track"===n||"input"===n?i.src=h:"area"===n?function(e,t){const i=r(t);void 0!==i&&(e.href=i)}(i,h):this.log("Unable to rebase relative path for element:",n)},e.registerCustomElements=function(t,r){const i=t,n=i.tagName?.toLowerCase(),s=(P(i,"is")||P(i,"alt"))?.toLowerCase();if(["template","div"].includes(n)&&s){if("div"===n&&"template"!==P(i,"role"))return;if(!this._customElements.has(s)){this.log(`Registering custom element: ${s}\n`,V(i,128));const t=i.content||i,n=Array.from(I(t));for(let t=1;t<n.length;t++)e.rebaseRelativePaths.call(this,n[t],r);this._customElements.set(s,i),Y(i.parentNode,i)}}},e.resolveCustomElements=function(e,t){const r=e,i=r.tagName?.toLowerCase();let n=i;if("div"===n&&(n=P(r,"role")?.toLowerCase()||n),n&&this._customElements.has(n)){this.log(`Processing custom element: ${n}\n`,V(r,128));const t=this._customElements.get(n),s=(t.content||t).cloneNode(!0),o=G(s);if(o)for(const e of Array.from(r.attributes))"div"===i&&"role"===e.name||F(r,o,e.name);const a=new p(I(s)).find(e=>"slot"===e.tagName?.toLowerCase());a&&j(a,...r.childNodes),j(e,...s.childNodes)}},e.resolveTextNodeExpressions=function(e,t){const r=e.nodeValue||"";if(3!==e.nodeType||!r?.trim())return;this.log("Processing node content value:\n",B(r,128));const i=new RegExp(/{{ ([^}]+) }}/gm),n=Array.from(r.matchAll(i)).map(e=>e[1]);return this.effect(function(){let t=r;for(const r of n){const i=this.eval(r,{$elem:e});t=t.replace(`{{ ${r} }}`,String(i))}e.nodeValue=t})},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"data",":");if(i){let n;this.log(":data attribute found in:\n",V(e,128)),z(r,"data",":"),k(e,"renderer")?(n=e.renderer,this.log("Reusing existing subrenderer for node:",V(e,64))):(n=this.subrenderer(),U(e,"renderer",n),this.log("Created and attached new subrenderer for node:",V(e,64)));const s=n.eval(i,{$elem:e});if(await Promise.all(Object.entries(s).map(([e,t])=>n._store.set(e,t))),n===this)return;for(const t of I(e,this._skipNodes))this._skipNodes.add(t);await n.mount(e,t)}},e.resolveClassAttribute=function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"class",":");if(i){this.log(":class attribute found in:\n",V(e,128)),z(r,"class",":");const t=P(r,"class")||"";return this.effect(function(){const n=this.eval(i,{$elem:e});L(r,"class",(n?`${t} ${n}`:t).trim())})}},e.resolveTextAttributes=function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"text",":");if(i){this.log(":text attribute found in:\n",V(e,128)),z(r,"text",":");const t=t=>this.textContent(e,t);return this.effect(function(){t(this.eval(i,{$elem:e}))})}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"html",":");return i?(this.log(":html attribute found in:\n",V(e,128)),z(r,"html",":"),this.effect(function(){const n=this.eval(i,{$elem:e});return new Promise(async e=>{const i=await this.preprocessString(n,t);await this.renderNode(i),K(r,i),e()})})):void 0},e.resolveEventAttributes=function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){let i="",n=[];if(t.name.startsWith(":on:")?[i,...n]=t.name.substring(4).split("."):t.name.startsWith("data-on-")&&([i,...n]=t.name.substring(8).split(".")),!i)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",V(e,128)),z(r,t.name);const s="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,r=>((n.includes("prevent")||s)&&r.preventDefault(),this.eval(t.value,{$elem:e,$event:r})))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"for",":")?.trim();if(i){this.log(":for attribute found in:\n",V(e,128)),z(r,"for",":");for(const t of I(e,this._skipNodes))this._skipNodes.add(t);const n=P(r,"style")||"";D(r,"style","display: none;");const s=e.parentNode,o=this.createElement("template",e.ownerDocument);H(s,o,e),Y(s,e),W(o,e),this.log(":for template:\n",V(o,128));const a=i.split(" in ",2);if(2!==a.length)throw new Error(`Invalid :for format: \`${i}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=a;await this.effect(function(){const r=this.eval(h,{$elem:e});if(this.log(":for list items:",r),l.splice(0,l.length).forEach(e=>{Y(s,e),this._skipNodes.delete(e)}),!Array.isArray(r))return console.error(`Expression did not yield a list: \`${h}\` => \`${r}\``),Promise.resolve();const i=[];for(const s of r){const r=this.subrenderer();r._store.set(c,s);const o=e.cloneNode(!0);D(o,"style",n),l.push(o),this._skipNodes.add(o),i.push(r.mount(o,t)),this.log("Rendered list child:\n",V(o,128))}const a=o.nextSibling;for(const e of l)H(s,e,a);return Promise.all(i)})}},e.resolveBindAttribute=function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"bind",":");if(i){this.log(":bind attribute found in:\n",V(e,128));const t=["change","input"],n=P(r,":bind:on")?.split(",")||r.dataset?.bindOn?.split(",")||t;z(r,"bind",":"),M(r,":bind:on"),M(r,"data-bind-on");const s="checkbox"===P(r,"type")?"checked":"value";i.includes(".")||this.has(i)||this.set(i,""),this.effect(function(){const t=this.eval(i,{$elem:e});"checked"===s?r.checked=!!t:r.value=t});const o=`${i} = $elem.${s}`;for(const t of n)e.addEventListener(t,()=>this.eval(o,{$elem:e}))}},e.resolveShowAttribute=function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"show",":");if(i){this.log(":show attribute found in:\n",V(e,128)),z(r,"show",":");const t="none"===r.style?.display?"":r.style?.display??P(r,"style")?.split(";")?.find(e=>"display"===e.split(":")[0])?.split(":")?.at(1)?.trim();this.effect(function(){const n=this.eval(i,{$elem:e});r.style?r.style.display=n?t:"none":L(r,"style",`display: ${n?t:"none"};`)})}},e.resolveCustomAttribute=function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":attr:",n="data-attr-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"attribute found in:\n",V(e,128)),M(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1);this.effect(function(){const i=this.eval(t.value,{$elem:e});D(r,s,i)})}}},e.resolveCustomProperty=function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":prop:",n="data-prop-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"property found in:\n",V(e,128)),M(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1),o=T(s);this.effect(function(){const i=this.eval(t.value,{$elem:e});U(r,o,i)})}}},e.stripTypes=function(e,t){const r=e;P(r,":types")&&M(r,":types"),P(r,"data-types")&&M(r,"data-types")},e.resolveRenderAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=C(r,"render",":");if(!i)return;let n;this.log(`:render attribute found: ${i}`),z(r,"render",":"),k(e,"renderer")?(n=e.renderer,this.log("Reusing existing subrenderer for :render:",V(e,64))):(n=this.subrenderer(),U(r,"renderer",n)),await n.mount(e,t);for(const t of I(e,this._skipNodes))this._skipNodes.add(t);try{const e=await import(i);"function"==typeof e.default?await e.default(r,n):void 0!==e.default&&console.warn(`Module ${i} default export is not a function`)}catch(e){console.error(`Failed to execute render init from ${i}:`,e)}}}(q||(q={}));const Q=new Set(["this","typeof"]),X=new Set(["in"]),J=new Set(["+","-","!","typeof"]),ee=new Set(["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","in"]),te={"!":0,":":0,",":0,")":0,"]":0,"}":0,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,in:10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"?.":13,"{":13},re={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>e>=t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,"||":(e,t)=>e||t,"&&":(e,t)=>e&&t,"??":(e,t)=>e??t,"|":(e,t)=>t(e),in:(e,t)=>e in t},ie={"+":e=>e,"-":e=>-e,"!":e=>!e,typeof:e=>typeof e};const ne=new Set(["==","!=","<=",">=","||","&&","??","?."]),se=new Set(["===","!=="]);var oe;!function(e){e[e.STRING=1]="STRING",e[e.IDENTIFIER=2]="IDENTIFIER",e[e.DOT=3]="DOT",e[e.COMMA=4]="COMMA",e[e.COLON=5]="COLON",e[e.INTEGER=6]="INTEGER",e[e.DECIMAL=7]="DECIMAL",e[e.OPERATOR=8]="OPERATOR",e[e.GROUPER=9]="GROUPER",e[e.KEYWORD=10]="KEYWORD",e[e.ARROW=11]="ARROW",e[e.OPTIONAL_DOT=12]="OPTIONAL_DOT",e[e.SPREAD=13]="SPREAD"}(oe||(oe={}));const ae=(e,t,r=0)=>({kind:e,value:t,precedence:r}),le=e=>9===e||10===e||13===e||32===e,ce=e=>95===e||36===e||65<=(e&=-33)&&e<=90,he=e=>ce(e)||de(e),de=e=>48<=e&&e<=57;class ue{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;le(this._next);)this._advance(!0);if(34===(e=this._next)||39===e)return this._tokenizeString();var e;if(ce(this._next))return this._tokenizeIdentOrKeyword();if(de(this._next))return this._tokenizeNumber();if(46===this._next)return this._tokenizeDot();if(44===this._next)return this._tokenizeComma();if(58===this._next)return this._tokenizeColon();if((e=>43===e||45===e||42===e||47===e||33===e||38===e||37===e||60===e||61===e||62===e||63===e||94===e||124===e)(this._next))return this._tokenizeOperator();if((e=>40===e||41===e||91===e||93===e||123===e||125===e)(this._next))return this._tokenizeGrouper();if(this._advance(),void 0!==this._next)throw new Error(`Expected end of input, got ${this._next}`)}_advance(e){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),!0===e&&(this._tokenStart=this._index)):this._next=void 0}_getValue(e=0){const t=this._input.substring(this._tokenStart,this._index+e);return 0===e&&this._clearValue(),t}_clearValue(){this._tokenStart=this._index}_tokenizeString(){const e="unterminated string",t=this._next;for(this._advance(!0);this._next!==t;){if(void 0===this._next)throw new Error(e);if(92===this._next&&(this._advance(),void 0===this._next))throw new Error(e);this._advance()}const r=ae(oe.STRING,this._getValue().replace(/\\(.)/g,(e,t)=>{switch(t){case"n":return"\n";case"r":return"\r";case"t":return"\t";case"b":return"\b";case"f":return"\f";default:return t}}));return this._advance(),r}_tokenizeIdentOrKeyword(){do{this._advance()}while(he(this._next));const e=this._getValue(),t=(r=e,Q.has(r)?oe.KEYWORD:X.has(e)?oe.OPERATOR:oe.IDENTIFIER);var r;return ae(t,e,te[e]??0)}_tokenizeNumber(){do{this._advance()}while(de(this._next));return 46===this._next?this._tokenizeDot():ae(oe.INTEGER,this._getValue())}_tokenizeDot(){if(this._advance(),de(this._next))return this._tokenizeFraction();if(46===this._next){if(this._advance(),46===this._next)return this._advance(),this._clearValue(),ae(oe.SPREAD,"...");throw new Error("Unexpected token ..")}return this._clearValue(),ae(oe.DOT,".",13)}_tokenizeComma(){return this._advance(!0),ae(oe.COMMA,",")}_tokenizeColon(){return this._advance(!0),ae(oe.COLON,":")}_tokenizeFraction(){do{this._advance()}while(de(this._next));return ae(oe.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(se.has(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),ae(oe.ARROW,e);ne.has(e)&&this._advance()}return e=this._getValue(),"?."===e?ae(oe.OPTIONAL_DOT,e,13):ae(oe.OPERATOR,e,te[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=ae(oe.GROUPER,e,te[e]);return this._advance(!0),t}}class fe{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new ue(e),this._ast=t}parse(){this._advance();const e=this._parseExpression();if(this._token)throw new Error(`Unexpected token: ${this._token.value}`);return e}_advance(e,t){if(!this._matches(e,t))throw new Error(`Expected kind ${e} (${t}), was ${this._token?.kind} (${this._token?.value})`);const r=this._tokenizer.nextToken();this._token=r,this._kind=r?.kind,this._value=r?.value}_matches(e,t){return!(e&&this._kind!==e||t&&this._value!==t)}_parseExpression(){if(!this._token)return this._ast.empty();const e=this._parseUnary();return void 0===e?void 0:this._parsePrecedence(e,0)}_parsePrecedence(e,t){if(void 0===e)throw new Error("Expected left to be defined.");for(;this._token;)if(this._matches(oe.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(oe.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(oe.DOT)||this._matches(oe.OPTIONAL_DOT)){const t=this._kind===oe.OPTIONAL_DOT;if(this._advance(),t&&this._matches(oe.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t,!0)}else if(t&&this._matches(oe.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t,!0)}else{const r=this._parseUnary();e=this._makeInvokeOrGetter(e,r,t)}}else{if(this._matches(oe.KEYWORD))break;if(!(this._matches(oe.OPERATOR)&&this._token.precedence>=t))break;e="?"===this._value?this._parseTernary(e):this._parseBinary(e,this._token)}return e}_makeInvokeOrGetter(e,t,r){if(void 0===t)throw new Error("expected identifier");if("ID"===t.type)return this._ast.getter(e,t.value,r);if("Invoke"===t.type&&"ID"===t.receiver.type){const i=t.receiver;return this._ast.invoke(e,i.value,t.arguments,r)}throw new Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(!ee.has(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let r=this._parseUnary();for(;(this._kind===oe.OPERATOR||this._kind===oe.DOT||this._kind===oe.GROUPER)&&this._token.precedence>t.precedence;)r=this._parsePrecedence(r,this._token.precedence);if(void 0===r)throw new Error(`Expected expression after ${t.value}`);return this._ast.binary(e,t.value,r)}_parseUnary(){if(this._matches(oe.KEYWORD,"typeof")){this._advance();const e=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary("typeof",e)}if(this._matches(oe.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(oe.INTEGER))return this._parseInteger(e);if(this._matches(oe.DECIMAL))return this._parseDecimal(e)}if(!J.has(e))throw new Error(`unexpected token: ${e}`);const t=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(e,t)}return this._parsePrimary()}_parseTernary(e){this._advance(oe.OPERATOR,"?");const t=this._parseExpression();this._advance(oe.COLON);const r=this._parseExpression();return this._ast.ternary(e,t,r)}_parsePrimary(){switch(this._kind){case oe.KEYWORD:const e=this._value;if("this"===e)return this._advance(),this._ast.id(e);if(Q.has(e))throw new Error(`unexpected keyword: ${e}`);throw new Error(`unrecognized keyword: ${e}`);case oe.IDENTIFIER:return this._parseInvokeOrIdentifier();case oe.STRING:return this._parseString();case oe.INTEGER:return this._parseInteger();case oe.DECIMAL:return this._parseDecimal();case oe.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case oe.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(oe.GROUPER,"]"))break;if(this._matches(oe.SPREAD)){this._advance();const t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else e.push(this._parseExpression())}while(this._matches(oe.COMMA));return this._advance(oe.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e=[];do{if(this._advance(),this._matches(oe.GROUPER,"}"))break;if(this._matches(oe.SPREAD)){this._advance();const t=this._parseExpression();t&&e.push(this._ast.spreadProperty(t))}else{const t=this._value;if((this._matches(oe.STRING)||this._matches(oe.IDENTIFIER))&&this._advance(),this._matches(oe.COLON)){this._advance(oe.COLON);const r=this._parseExpression();r&&e.push(this._ast.property(t,r))}else e.push(this._ast.property(t,this._ast.id(t)))}}while(this._matches(oe.COMMA));return this._advance(oe.GROUPER,"}"),this._ast.map(e)}_parseInvokeOrIdentifier(){const e=this._value;if("true"===e)return this._advance(),this._ast.literal(!0);if("false"===e)return this._advance(),this._ast.literal(!1);if("null"===e)return this._advance(),this._ast.literal(null);if("undefined"===e)return this._advance(),this._ast.literal(void 0);const t=this._parseIdentifier(),r=this._parseArguments();return r?this._ast.invoke(t,void 0,r):t}_parseIdentifier(){if(!this._matches(oe.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(oe.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(oe.GROUPER,")"))break;if(this._matches(oe.SPREAD)){this._advance();const t=this._parseExpression();t&&e.push(this._ast.spreadElement(t))}else{const t=this._parseExpression();e.push(t)}}while(this._matches(oe.COMMA));return this._advance(oe.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(oe.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(oe.ARROW)){this._advance();const t=this._parseExpression(),r=e?.map(e=>e.value)??[];return this._ast.arrowFunction(r,t)}return this._ast.paren(e[0])}_parseString(){const e=this._ast.literal(this._value);return this._advance(),e}_parseInteger(e=""){const t=this._ast.literal(parseInt(`${e}${this._value}`,10));return this._advance(),t}_parseDecimal(e=""){const t=this._ast.literal(parseFloat(`${e}${this._value}`));return this._advance(),t}}class pe{timeouts=new Map;debounce(e,t){return new Promise((r,i)=>{const n=this.timeouts.get(t);n&&clearTimeout(n),this.timeouts.set(t,setTimeout(()=>{try{r(t()),this.timeouts.delete(t)}catch(e){i(e)}},e))})}}const me=new class{empty(){return{type:"Empty",evaluate:e=>e,getIds:e=>e}}literal(e){return{type:"Literal",value:e,evaluate(e){return this.value},getIds:e=>e}}id(e){return{type:"ID",value:e,evaluate(e){return"this"===this.value?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(e,t){const r=ie[e];return{type:"Unary",operator:e,child:t,evaluate(e){return r(this.child.evaluate(e))},getIds(e){return this.child.getIds(e)}}}binary(e,t,r){const i=re[t];return{type:"Binary",operator:t,left:e,right:r,evaluate(e){if("="===this.operator){if("ID"!==this.left.type&&"Getter"!==this.left.type&&"Index"!==this.left.type)throw new Error(`Invalid assignment target: ${this.left}`);const t=this.right.evaluate(e);let r,i;return"Getter"===this.left.type?(r=this.left.receiver.evaluate(e),i=this.left.name):"Index"===this.left.type?(r=this.left.receiver.evaluate(e),i=String(this.left.argument.evaluate(e))):"ID"===this.left.type&&(r=e,i=this.left.value),void 0===r?void 0:r[i]=t}return i(this.left.evaluate(e),this.right.evaluate(e))},getIds(e){return this.left.getIds(e),this.right.getIds(e),e}}}getter(e,t,r){return{type:"Getter",receiver:e,name:t,optional:r,evaluate(e){const t=this.receiver.evaluate(e);if(!this.optional||null!=t)return t?.[this.name]},getIds(e){return this.receiver.getIds(e),e}}}invoke(e,t,r,i){if(null!=t&&"string"!=typeof t)throw new Error("method not a string");return{type:"Invoke",receiver:e,method:t,arguments:r,optional:i,evaluate(e){const t=this.receiver.evaluate(e);if(this.optional&&null==t)return;const r=this.method?t:e?.this??e,i=this.method?t?.[this.method]:t,n=this.arguments??[],s=[];for(const t of n)if("SpreadElement"===t?.type){const r=t.evaluate(e);r&&"function"==typeof r[Symbol.iterator]&&s.push(...r)}else s.push(t?.evaluate(e));return i?.apply?.(r,s)},getIds(e){return this.receiver.getIds(e),this.arguments?.forEach(t=>t?.getIds(e)),e}}}paren(e){return e}index(e,t,r){return{type:"Index",receiver:e,argument:t,optional:r,evaluate(e){const t=this.receiver.evaluate(e);if(this.optional&&null==t)return;const r=this.argument.evaluate(e);return t?.[r]},getIds(e){return this.receiver.getIds(e),e}}}ternary(e,t,r){return{type:"Ternary",condition:e,trueExpr:t,falseExpr:r,evaluate(e){return this.condition.evaluate(e)?this.trueExpr.evaluate(e):this.falseExpr.evaluate(e)},getIds(e){return this.condition.getIds(e),this.trueExpr.getIds(e),this.falseExpr.getIds(e),e}}}map(e){return{type:"Map",properties:e,evaluate(t){const r={};if(e&&this.properties)for(const e of this.properties)"SpreadProperty"===e.type?Object.assign(r,e.evaluate(t)):r[e.key]=e.value.evaluate(t);return r},getIds(t){if(e&&this.properties)for(const e of this.properties)"SpreadProperty"===e.type?e.expression.getIds(t):e.value.getIds(t);return t}}}property(e,t){return{type:"Property",key:e,value:t,evaluate(e){return this.value.evaluate(e)},getIds(e){return this.value.getIds(e)}}}list(e){return{type:"List",items:e,evaluate(e){if(!this.items)return[];const t=[];for(const r of this.items)if("SpreadElement"===r?.type){const i=r.evaluate(e);i&&"function"==typeof i[Symbol.iterator]&&t.push(...i)}else t.push(r?.evaluate(e));return t},getIds(e){return this.items?.forEach(t=>t?.getIds(e)),e}}}arrowFunction(e,t){return{type:"ArrowFunction",params:e,body:t,evaluate(e){const t=this.params,r=this.body;return function(...i){const n=Object.fromEntries(t.map((e,t)=>[e,i[t]])),s=new Proxy(e??{},{set:(e,t,r)=>(n.hasOwnProperty(t)&&(n[t]=r),e[t]=r),get:(e,t)=>n.hasOwnProperty(t)?n[t]:e[t]});return r.evaluate(s)}},getIds(e){return this.body.getIds(e).filter(e=>!this.params.includes(e))}}}spreadProperty(e){return{type:"SpreadProperty",expression:e,evaluate(e){return this.expression.evaluate(e)},getIds(e){return this.expression.getIds(e)}}}spreadElement(e){return{type:"SpreadElement",expression:e,evaluate(e){return this.expression.evaluate(e)},getIds(e){return this.expression.getIds(e)}}}},ge="__is_proxy__";function be(e,t){const r=e?._store;return r?.has(t)?r.get(t):r?.has("$parent")?be(r.get("$parent"),t):void 0}function _e(e,t){const r=e?._store;return r?.has(t)?e:r?.has("$parent")?_e(r.get("$parent"),t):null}class ve extends pe{evalkeys=["$elem","$event"];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_observer=null;_store=new Map;_lock=Promise.resolve();constructor(e){super();for(const[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof ve||!0===r[ge])||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>"string"==typeof r&&r in e&&(delete e[r],t(),!0),set:(e,r,i,n)=>{"object"==typeof i&&null!==i&&(i=this.wrapObject(i,t));const s=Reflect.set(e,r,i,n);return t(),s},get:(e,t,r)=>t===ge||Reflect.get(e,t,r)});var r}watch(e,t){const r=_e(this,e);if(!r)throw new Error(`Cannot watch key "${e}" as it does not exist in the store.`);r.observers.has(e)||r.observers.set(e,new Set),r.observers.get(e)?.has(t)||r.observers.get(e)?.add(t)}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e).add(t)}async notify(e,t=10){const r=_e(this,e),i=Array.from(r?.observers.get(e)||[]);await this.debounce(t,()=>Promise.all(i.map(e=>e.call(this.proxify(e)))))}get(e,t){return t&&this.watch(e,t),be(this,e)}async set(e,t){if(this._store.has(e)&&t===this._store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=_e(e,t);i?i._store.set(t,r):e._store.set(t,r)}(this,e,t);for(const[r,i]of this.keyHandlers.entries())if(r.test(e))for(const r of i)await Promise.resolve(r.call(this.$,e,t));await r()}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e)}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this._store.entries()).map(([e])=>e),r=Object.fromEntries(t.map(e=>[e,null]));return new Proxy(r,{has:(e,t)=>{if("string"==typeof t){if(_e(this,t))return!0;if(Reflect.has(this,t))return!0}return Reflect.has(r,t)},get:(t,r,i)=>{if("string"==typeof r){if(_e(this,r))return this.get(r,e);if(e&&r!==ge&&!Reflect.has(this,r))return this.set(r,void 0),this.get(r,e)}return"$"===r?this.proxify(e):Reflect.get(this,r,i)},set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");return(t,r)=>{const i=((e,t)=>new fe(e,t).parse())(e,me),n=new Proxy(r,{has:(e,r)=>r in e||r in t||r in globalThis,get(e,r){if("string"==typeof r)return r in e?e[r]:r in t?t[r]:r in globalThis?globalThis[r]:t[r]},set:(e,r,i)=>"string"==typeof r&&(r in e?(e[r]=i,!0):(t[r]=i,!0))});return i?.evaluate(n)}}cachedExpressionFunction(e){return e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e)),this.expressionCache.get(e)}eval(e,t={}){const r=this._observer?this:this.$;if(this._store.has(e))return r[e];{const i=this.cachedExpressionFunction(e);try{return i(r,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}$resolve(e,t){const r={$pending:!0,$result:null,$error:null};return Promise.resolve().then(()=>e(t)).then(e=>{r.$result=e}).catch(e=>{r.$error=e instanceof Error?e:new Error(String(e))}).finally(()=>{r.$pending=!1}),r}}const we="$$";function xe(){return new URL(globalThis.window?.location?.href||"http://localhost/")}function ye(e){return`${we}${e}`}function Ee(e){return e.keys().filter(e=>e.startsWith(we))}function $e(e,t,r){const i=function(e){return e.substring(2)}(t);let n=!1;if(r){const t=String(r);e.searchParams.get(i)!==t&&(e.searchParams.set(i,t),n=!0)}else e.searchParams.has(i)&&(e.searchParams.delete(i),n=!0);return n}async function Ae(e){const t=xe();await async function(e,t){for(const[r,i]of t.searchParams.entries()){const t=ye(r);e.get(t)!==i&&await e.set(t,i)}}(e,t),function(e,t){let r=!1;for(const i of Ee(t))$e(e,i,t.get(i))&&(r=!0);r&&globalThis.window?.history?.replaceState({},"",e.toString())}(t,e),e.addKeyHandler(new RegExp("^\\$\\$"),(e,t)=>{const r=xe();$e(r,e,t)&&globalThis.window?.history?.replaceState({},"",r.toString())}),globalThis.window?.addEventListener("popstate",function(e){return async()=>{const t=xe(),r=new Set;for(const[i,n]of t.searchParams.entries()){const t=ye(i);r.add(t),e.get(t)!==n&&e.set(t,n)}const i=Ee(e);for(const t of i)r.has(t)||e.del(t)}}(e))}class Re extends ve{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(e){return this.debugging=e,this}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??"default"}).then(e=>e.text())}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log("Preprocessing string content with params:\n",t);const r=this.parseHTML(e,t);return await this.preprocessNode(r,t),r}async preprocessRemote(e,t){const r={};t?.cache&&(r.cache=t.cache);const i=await fetch(e,r).then(e=>e.text());return this.preprocessString(i,{...t,dirpath:Z(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}async preprocessLocal(e,t){const r=await this.fetchLocal(e,t);return this.preprocessString(r,{...t,dirpath:Z(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}subrenderer(){const e=(new this.constructor).debug(this.debugging);return e._store.set("$parent",this),e._store.set("$rootRenderer",this.get("$rootRenderer")??this),e._customElements=this._customElements,e}log(...e){this.debugging&&console.debug(...e)}async preprocessNode(e,t){t={dirpath:this.dirpath,maxdepth:10,...t};const r=new p(I(e,this._skipNodes)).map(async e=>{this.log("Preprocessing node:\n",V(e,128)),await q.resolveIncludes.call(this,e,t),await q.rebaseRelativePaths.call(this,e,t),await q.registerCustomElements.call(this,e,t),await q.resolveCustomElements.call(this,e,t)});return await Promise.all(r.generator()),e}async renderNode(e,t){for(const r of I(e,this._skipNodes))this.log("Rendering node:\n",V(r,128)),await q.resolveForAttribute.call(this,r,t),await q.resolveRenderAttribute.call(this,r,t),await q.resolveDataAttribute.call(this,r,t),await q.resolveTextAttributes.call(this,r,t),await q.resolveHtmlAttribute.call(this,r,t),await q.resolveShowAttribute.call(this,r,t),await q.resolveClassAttribute.call(this,r,t),await q.resolveBindAttribute.call(this,r,t),await q.resolveEventAttributes.call(this,r,t),await q.resolveTextNodeExpressions.call(this,r,t),await q.resolveCustomAttribute.call(this,r,t),await q.resolveCustomProperty.call(this,r,t),await q.stripTypes.call(this,r,t);return e}async mount(e,t){t={...t,rootNode:e},U(e,"renderer",this),this._store.set("$rootNode",e),this.has("$rootRenderer")||this._store.set("$rootRenderer",this),this.get("$rootRenderer")===this&&await Ae(this),await this.preprocessNode(e,t),await this.renderNode(e,t)}}function Oe(){return d([R`html{`,R`max-width: 70ch;`,R`padding: 2em 1em;`,R`margin: auto;`,R`line-height: 1.75;`,R`font-size: 1.25em;`,R`font-family: sans-serif;`,R`}`,R`h1,h2,h3,h4,h5,h6{`,R`margin: 1em 0 0.5em;`,R`}`,R`p,ul,ol{`,R`margin-bottom: 1em;`,R`color: #1d1d1d;`,R`}`].map(u).join(""))}const Ie={sm:640,md:768,lg:1024,xl:1280},ke=Object.entries(Ie),Ne=.25,Te=[...Array(15)].map((e,t)=>t+1),Pe=[...Te,16,20,24,25,28,30,32,36,40,44,48,50,52,56,60,64,72,80,96,100,112,128,144,160,192,200,224,256,288,300,320,384,400,448,500,512,...Object.values(Ie)],Se=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],Ce=[75,100,150,200,300,500,700,1e3],De=["hover","focus","disabled","active"],Le={margin:"m",padding:"p"},Ue={width:"w",height:"h"},Me={top:"top",right:"right",bottom:"bottom",left:"left"},ze={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},Fe={"font-mono":{"font-family":"monospace"},"font-sans":{"font-family":"sans-serif"},"font-serif":{"font-family":"serif"},"font-cursive":{"font-family":"cursive"},"text-xs":{"font-size":".75rem","line-height":"calc(1 / 0.75)"},"text-sm":{"font-size":".875rem","line-height":"calc(1.25 / 0.875)"},"text-base":{"font-size":"1rem","line-height":"calc(1.5 / 1)"},"text-lg":{"font-size":"1.125rem","line-height":"calc(1.75 / 1.125)"},"text-xl":{"font-size":"1.25rem","line-height":"calc(1.75 / 1.25)"},"text-2xl":{"font-size":"1.5rem","line-height":"calc(2 / 1.5)"},"text-3xl":{"font-size":"1.875rem","line-height":"calc(2.25 / 1.875)"},"text-4xl":{"font-size":"2.25rem","line-height":"calc(2.5 / 2.25)"},"text-5xl":{"font-size":"3rem","line-height":"1"},"text-6xl":{"font-size":"3.75rem","line-height":"1"},"text-7xl":{"font-size":"4.5rem","line-height":"1"},"font-thin":{"font-weight":100},"font-extralight":{"font-weight":200},"font-light":{"font-weight":300},"font-normal":{"font-weight":400},"font-medium":{"font-weight":500},"font-semibold":{"font-weight":600},"font-bold":{"font-weight":700},"font-extrabold":{"font-weight":800},"font-black":{"font-weight":900},italic:{"font-style":"italic"},"not-italic":{"font-style":"normal"},"w-max":{width:"max-content"},"w-min":{width:"min-content"},"w-fit":{width:"fit-content"},"h-max":{height:"max-content"},"h-min":{height:"min-content"},"h-fit":{height:"fit-content"},"size-auto":{width:"auto",height:"auto"},"size-px":{width:"1px",height:"1px"},"size-full":{width:"100%",height:"100%"},"size-dvw":{width:"100dvw",height:"100dvw"},"size-dvh":{width:"100dvh",height:"100dvh"},"size-lvw":{width:"100lvw",height:"100lvw"},"size-lvh":{width:"100lvh",height:"100lvh"},"size-svw":{width:"100svw",height:"100svw"},"size-svh":{width:"100svh",height:"100svh"},"size-min":{width:"min-content",height:"min-content"},"size-max":{width:"max-content",height:"max-content"},"size-fit":{width:"fit-content",height:"fit-content"},"tracking-tighter":{"letter-spacing":"-0.05em"},"tracking-tight":{"letter-spacing":"-0.025em"},"tracking-normal":{"letter-spacing":"0"},"tracking-wide":{"letter-spacing":"0.025em"},"tracking-wider":{"letter-spacing":"0.05em"},"tracking-widest":{"letter-spacing":"0.1em"},"leading-none":{"line-height":"1"},"leading-tight":{"line-height":"1.25"},"leading-snug":{"line-height":"1.375"},"leading-normal":{"line-height":"1.5"},"leading-relaxed":{"line-height":"1.625"},"leading-loose":{"line-height":"2"},"text-left":{"text-align":"left"},"text-right":{"text-align":"right"},"text-center":{"text-align":"center"},"text-justify":{"text-align":"justify"},underline:{"text-decoration":"underline"},"no-underline":{"text-decoration":"none"},"decoration-none":{"text-decoration":"none"},"line-through":{"text-decoration":"line-through"},uppercase:{"text-transform":"uppercase"},lowercase:{"text-transform":"lowercase"},capitalize:{"text-transform":"capitalize"},truncate:{"white-space":"nowrap",overflow:"hidden","text-overflow":"ellipsis"},"text-elipsis":{"text-overflow":"ellipsis"},"text-clip":{"text-overflow":"clip"},"text-wrap":{"text-wrap":"wrap"},"text-nowrap":{"text-wrap":"nowrap"},"text-balance":{"text-wrap":"balance"},"text-pretty":{"text-wrap":"pretty"},"whitespace-normal":{"white-space":"normal"},"whitespace-nowrap":{"white-space":"nowrap"},"whitespace-pre":{"white-space":"pre"},"whitespace-pre-line":{"white-space":"pre-line"},"whitespace-pre-wrap":{"white-space":"pre-wrap"},"whitespace-break-spaces":{"white-space":"break-spaces"},relative:{position:"relative"},fixed:{position:"fixed"},absolute:{position:"absolute"},sticky:{position:"sticky"},"object-contain":{"object-fit":"contain"},"object-cover":{"object-fit":"cover"},"object-fill":{"object-fit":"fill"},"object-none":{"object-fit":"none"},block:{display:"block"},contents:{display:"contents"},hidden:{display:"none"},inline:{display:"inline"},"inline-block":{display:"inline-block"},visible:{visibility:"visible"},invisible:{visibility:"hidden"},collapse:{visibility:"collapse"},"list-none":{"list-style-type":"none"},"list-disc":{"list-style-type":"disc"},"list-decimal":{"list-style-type":"decimal"},flex:{display:"flex"},"flex-1":{flex:"1 1 0%"},"flex-inline":{display:"inline-flex"},"flex-row":{"flex-direction":"row"},"flex-col":{"flex-direction":"column"},"flex-row-reverse":{"flex-direction":"row-reverse"},"flex-col-reverse":{"flex-direction":"column-reverse"},"flex-wrap":{"flex-wrap":"wrap"},"flex-wrap-reverse":{"flex-wrap":"wrap-reverse"},"flex-nowrap":{"flex-wrap":"nowrap"},"justify-start":{"justify-content":"flex-start"},"justify-end":{"justify-content":"flex-end"},"justify-center":{"justify-content":"center"},"justify-between":{"justify-content":"space-between"},"justify-around":{"justify-content":"space-around"},"justify-evenly":{"justify-content":"space-evenly"},"justify-stretch":{"justify-content":"stretch"},"items-start":{"align-items":"flex-start"},"items-end":{"align-items":"flex-end"},"items-center":{"align-items":"center"},"items-stretch":{"align-items":"stretch"},"flex-grow":{"flex-grow":1},"flex-shrink":{"flex-shrink":1},"align-baseline":{"vertical-align":"baseline"},"align-top":{"vertical-align":"top"},"align-middle":{"vertical-align":"middle"},"align-bottom":{"vertical-align":"bottom"},"align-text-top":{"vertical-align":"text-top"},"align-text-bottom":{"vertical-align":"text-bottom"},"overflow-auto":{overflow:"auto"},"overflow-x-auto":{"overflow-x":"auto"},"overflow-y-auto":{"overflow-y":"auto"},"overflow-hidden":{overflow:"hidden"},"overflow-x-hidden":{"overflow-x":"hidden"},"overflow-y-hidden":{"overflow-y":"hidden"},"overflow-visible":{overflow:"visible"},"overscroll-auto":{"overscroll-behavior":"auto"},"overscroll-contain":{"overscroll-behavior":"contain"},"overscroll-none":{"overscroll-behavior":"none"},"overscroll-x-auto":{"overscroll-behavior-x":"auto"},"overscroll-x-contain":{"overscroll-behavior-x":"contain"},"overscroll-x-none":{"overscroll-behavior-x":"none"},"overscroll-y-auto":{"overscroll-behavior-y":"auto"},"overscroll-y-contain":{"overscroll-behavior-y":"contain"},"overscroll-y-none":{"overscroll-behavior-y":"none"},"z-auto":{"z-index":"auto"},"cursor-pointer":{cursor:"pointer"},"cursor-wait":{cursor:"wait"},"cursor-not-allowed":{cursor:"not-allowed"},"select-none":{"user-select":"none"},"select-all":{"user-select":"all"},"pointer-events-auto":{"pointer-events":"auto"},"pointer-events-none":{"pointer-events":"none"},"box-border":{"box-sizing":"border-box"},"box-content":{"box-sizing":"content-box"},resize:{resize:"both"},"resize-x":{resize:"horizontal"},"resize-y":{resize:"vertical"},"resize-none":{resize:"none"},border:{border:"1px solid"},"border-none":{border:"none"},"border-solid":{"border-style":"solid"},"border-dashed":{"border-style":"dashed"},"border-dotted":{"border-style":"dotted"},"border-collapse":{"border-collapse":"collapse"},"rounded-none":{"border-radius":"0"},rounded:{"border-radius":".25rem"},"rounded-sm":{"border-radius":".125rem"},"rounded-md":{"border-radius":".375rem"},"rounded-lg":{"border-radius":".5rem"},"rounded-xl":{"border-radius":".75rem"},"rounded-full":{"border-radius":"9999px"},shadow:{"box-shadow":"0 0 1px 0 rgba(0, 0, 0, 0.05)"},"shadow-sm":{"box-shadow":"0 1px 2px 0 rgba(0, 0, 0, 0.05)"},"shadow-md":{"box-shadow":"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},"shadow-lg":{"box-shadow":"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},"shadow-xl":{"box-shadow":"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)"},"shadow-2xl":{"box-shadow":"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},"shadow-inner":{"box-shadow":"inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)"},"shadow-outline":{"box-shadow":"0 0 0 3px rgba(66, 153, 225, 0.5)"},"shadow-none":{"box-shadow":"none"},"transition-none":{transition:"none"},transition:{transition:"all 150ms ease-in-out"},"animate-none":{animation:"none"},"animate-spin":{animation:"spin 1s linear infinite"},"animate-ping":{animation:"ping 1s cubic-bezier(0, 0, 0.2, 1) infinite"},"animate-pulse":{animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"},"bg-auto":{"background-size":"auto"},"bg-cover":{"background-size":"cover"},"bg-contain":{"background-size":"contain"},"bg-no-repeat":{"background-repeat":"no-repeat"},"bg-fixed":{"background-attachment":"fixed"},"bg-local":{"background-attachment":"local"},"bg-scroll":{"background-attachment":"scroll"},"min-h-screen":{"min-height":"100vh"},"max-h-screen":{"max-height":"100vh"},"min-w-screen":{"min-width":"100vw"},"h-dvh":{height:"100dvh"},"h-svh":{height:"100svh"},"h-lvh":{height:"100lvh"},"w-dvw":{width:"100dvw"},"w-svw":{width:"100svw"},"w-lvw":{width:"100lvw"},"min-h-dvh":{"min-height":"100dvh"},"min-h-svh":{"min-height":"100svh"},"min-h-lvh":{"min-height":"100lvh"},"flex-none":{flex:"none"},"flex-auto":{flex:"1 1 auto"},"flex-initial":{flex:"0 1 auto"},grow:{"flex-grow":"1"},"grow-0":{"flex-grow":"0"},shrink:{"flex-shrink":"1"},"shrink-0":{"flex-shrink":"0"},"self-auto":{"align-self":"auto"},"self-start":{"align-self":"flex-start"},"self-end":{"align-self":"flex-end"},"self-center":{"align-self":"center"},"self-stretch":{"align-self":"stretch"},"self-baseline":{"align-self":"baseline"},"content-normal":{"align-content":"normal"},"content-start":{"align-content":"flex-start"},"content-end":{"align-content":"flex-end"},"content-center":{"align-content":"center"},"content-between":{"align-content":"space-between"},"content-around":{"align-content":"space-around"},"content-evenly":{"align-content":"space-evenly"},"content-stretch":{"align-content":"stretch"},"items-baseline":{"align-items":"baseline"},"inset-0":{inset:"0"},"inset-auto":{inset:"auto"},"inset-x-0":{left:"0",right:"0"},"inset-y-0":{top:"0",bottom:"0"},"inset-x-auto":{left:"auto",right:"auto"},"inset-y-auto":{top:"auto",bottom:"auto"},"sr-only":{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)","white-space":"nowrap","border-width":"0"},"not-sr-only":{position:"static",width:"auto",height:"auto",padding:"0",margin:"0",overflow:"visible",clip:"auto","white-space":"normal"}},Ge=["@keyframes spin {\n from { transform: rotate(0deg) }\n to { transform: rotate(360deg) }\n }","@keyframes ping {\n 75%, 100% {\n transform: scale(2);\n opacity: 0;\n }\n }","@keyframes pulse {\n 0%, 100% { opacity: 1 }\n 50% { opacity: .5 }\n }"],je={red:{50:"#ffebee",100:"#ffcdd2",200:"#ef9a9a",300:"#e57373",400:"#ef5350",500:"#f44336",600:"#e53935",700:"#d32f2f",800:"#c62828",900:"#b71c1c"},pink:{50:"#fce4ec",100:"#f8bbd0",200:"#f48fb1",300:"#f06292",400:"#ec407a",500:"#e91e63",600:"#d81b60",700:"#c2185b",800:"#ad1457",900:"#880e4f"},purple:{50:"#f3e5f5",100:"#e1bee7",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",600:"#8e24aa",700:"#7b1fa2",800:"#6a1b9a",900:"#4a148c"},"deep-purple":{50:"#ede7f6",100:"#d1c4e9",200:"#b39ddb",300:"#9575cd",400:"#7e57c2",500:"#673ab7",600:"#5e35b1",700:"#512da8",800:"#4527a0",900:"#311b92"},indigo:{50:"#e8eaf6",100:"#c5cae9",200:"#9fa8da",300:"#7986cb",400:"#5c6bc0",500:"#3f51b5",600:"#3949ab",700:"#303f9f",800:"#283593",900:"#1a237e"},blue:{50:"#e3f2fd",100:"#bbdefb",200:"#90caf9",300:"#64b5f6",400:"#42a5f5",500:"#2196f3",600:"#1e88e5",700:"#1976d2",800:"#1565c0",900:"#0d47a1"},"light-blue":{50:"#e1f5fe",100:"#b3e5fc",200:"#81d4fa",300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",600:"#039be5",700:"#0288d1",800:"#0277bd",900:"#01579b"},cyan:{50:"#e0f7fa",100:"#b2ebf2",200:"#80deea",300:"#4dd0e1",400:"#26c6da",500:"#00bcd4",600:"#00acc1",700:"#0097a7",800:"#00838f",900:"#006064"},teal:{50:"#e0f2f1",100:"#b2dfdb",200:"#80cbc4",300:"#4db6ac",400:"#26a69a",500:"#009688",600:"#00897b",700:"#00796b",800:"#00695c",900:"#004d40"},green:{50:"#e8f5e9",100:"#c8e6c9",200:"#a5d6a7",300:"#81c784",400:"#66bb6a",500:"#4caf50",600:"#43a047",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"},"light-green":{50:"#f1f8e9",100:"#dcedc8",200:"#c5e1a5",300:"#aed581",400:"#9ccc65",500:"#8bc34a",600:"#7cb342",700:"#689f38",800:"#558b2f",900:"#33691e"},lime:{50:"#f9fbe7",100:"#f0f4c3",200:"#e6ee9c",300:"#dce775",400:"#d4e157",500:"#cddc39",600:"#c0ca33",700:"#afb42b",800:"#9e9d24",900:"#827717"},yellow:{50:"#fffde7",100:"#fff9c4",200:"#fff59d",300:"#fff176",400:"#ffee58",500:"#ffeb3b",600:"#fdd835",700:"#fbc02d",800:"#f9a825",900:"#f57f17"},amber:{50:"#fff8e1",100:"#ffecb3",200:"#ffe082",300:"#ffd54f",400:"#ffca28",500:"#ffc107",600:"#ffb300",700:"#ffa000",800:"#ff8f00",900:"#ff6f00"},orange:{50:"#fff3e0",100:"#ffe0b2",200:"#ffcc80",300:"#ffb74d",400:"#ffa726",500:"#ff9800",600:"#fb8c00",700:"#f57c00",800:"#ef6c00",900:"#e65100"},"deep-orange":{50:"#fbe9e7",100:"#ffccbc",200:"#ffab91",300:"#ff8a65",400:"#ff7043",500:"#ff5722",600:"#f4511e",700:"#e64a19",800:"#d84315",900:"#bf360c"},brown:{50:"#efebe9",100:"#d7ccc8",200:"#bcaaa4",300:"#a1887f",400:"#8d6e63",500:"#795548",600:"#6d4c41",700:"#5d4037",800:"#4e342e",900:"#3e2723"},gray:{50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121"},"blue-gray":{50:"#eceff1",100:"#cfd8dc",200:"#b0bec5",300:"#90a4ae",400:"#78909c",500:"#607d8b",600:"#546e7a",700:"#455a64",800:"#37474f",900:"#263238"}};function Ke(e){return De.map(t=>`.${t}\\:${e}:${t}`)}function We(e,t){return ke.map(([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`)}function Ye(e){return e.flatMap(([e,t])=>[`.${e} { ${t} }`,`${Ke(e).join(",")} { ${t} }`,...We(e,t)])}function He(e,t){const r="@"===e[0],i="@"===t[0];return r&&!i?1:!r&&i?-1:e.localeCompare(t)}function Be(e){return Ye(Object.entries(e).flatMap(([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100v${e.includes("height")?"h":"w"}`],[`${t}-full`,`${e}: 100%`],...Pe.map(r=>[`${t}-${r}`,`${e}: ${r*Ne}rem`]),...Pe.map(r=>[`-${t}-${r}`,`${e}: -${r*Ne}rem`]),...Pe.map(r=>[`${t}-${r}px`,`${e}: ${r}px`]),...Pe.map(r=>[`-${t}-${r}px`,`${e}: -${r}px`]),...Se.map(r=>[`${t}-${r}\\%`,`${e}: ${r}%`]),...Se.map(r=>[`-${t}-${r}\\%`,`${e}: -${r}%`])]))}function Ve(e){return Ye(Object.entries(e).flatMap(([e,t])=>[[`${t}-auto`,`${e}: auto`],[`${t}x-auto`,`${e}-left: auto; ${e}-right: auto;`],[`${t}y-auto`,`${e}-top: auto; ${e}-bottom: auto;`],[`${t}x-0`,`${e}-left: 0; ${e}-right: 0;`],[`${t}y-0`,`${e}-top: 0; ${e}-bottom: 0;`],...Pe.map(r=>[`${t}x-${r}`,`${e}-left: ${r*Ne}rem; ${e}-right: ${r*Ne}rem;`]),...Pe.map(r=>[`${t}y-${r}`,`${e}-top: ${r*Ne}rem; ${e}-bottom: ${r*Ne}rem;`]),...Pe.map(r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`]),...Pe.map(r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`]),...Se.map(r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`]),...Se.map(r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`])]))}function Ze(){const e=(e,t)=>[[`text-${e}`,`color: ${t}`],[`fill-${e}`,`fill: ${t}`],[`bg-${e}`,`background-color: ${t}`],[`border-${e}`,`border-color: ${t}`]];return Ye([...e("white","#fff"),...e("black","#000"),...e("transparent","transparent"),...Object.entries(je).flatMap(([t,r])=>[...e(t,r[500]),...Object.entries(r).flatMap(([r,i])=>e(`${t}-${r}`,i))])])}let qe=null;function Qe(){return null!==qe||(qe=[...Ge,...Object.entries(Fe).flatMap(([e,t])=>{const r=Object.entries(t).map(([e,t])=>`${e}: ${t}`).join("; ");return[`.${e} { ${r} }`,`${Ke(e).join(",")} { ${r} }`,...We(e,r)]}),...Ze(),...Ye([["opacity-0","opacity: 0"],...Se.map(e=>[`opacity-${e}`,"opacity: "+e/100])]),...Ye(Se.map(e=>[`z-${e}`,`z-index: ${e}`])),...Ye(Ce.map(e=>[`duration-${e}`,`transition-duration: ${e}ms`])),...Be(Me),...Be(Ue),...Ve(Ue),...(e=Le,Ye(Object.entries(e).flatMap(([e,t])=>[[`${t}t-0`,`${e}-top: 0`],[`${t}b-0`,`${e}-bottom: 0`],[`${t}l-0`,`${e}-left: 0`],[`${t}r-0`,`${e}-right: 0`],[`${t}t-auto`,`${e}-top: auto`],[`${t}b-auto`,`${e}-bottom: auto`],[`${t}l-auto`,`${e}-left: auto`],[`${t}r-auto`,`${e}-right: auto`],...["","-"].flatMap(r=>[...Pe.map(i=>[`${r}${t}t-${i}`,`${e}-top: ${r}${i*Ne}rem`]),...Pe.map(i=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${i*Ne}rem`]),...Pe.map(i=>[`${r}${t}l-${i}`,`${e}-left: ${r}${i*Ne}rem`]),...Pe.map(i=>[`${r}${t}r-${i}`,`${e}-right: ${r}${i*Ne}rem`]),...Pe.map(i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`]),...Pe.map(i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`]),...Pe.map(i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`]),...Pe.map(i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`]),...Se.map(i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`]),...Se.map(i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%`]),...Se.map(i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`]),...Se.map(i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`])])]))),...Be(Le),...Ve(Le),...Ye([["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...Pe.map(e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*Ne}rem`]),...Pe.map(e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*Ne}rem`]),...Pe.map(e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`]),...Pe.map(e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`]),["gap-0","gap: 0"],...Pe.map(e=>[`gap-${e}`,`gap: ${e*Ne}rem`]),...Pe.map(e=>[`gap-${e}px`,`gap: ${e}px`]),...Pe.map(e=>[`gap-x-${e}`,`column-gap: ${e*Ne}rem`]),...Pe.map(e=>[`gap-y-${e}`,`row-gap: ${e*Ne}rem`]),...Pe.map(e=>[`gap-x-${e}px`,`column-gap: ${e}px`]),...Pe.map(e=>[`gap-y-${e}px`,`row-gap: ${e}px`])]),...Be(ze),...Ye([["border","border: 1px"],["border-x","border-inline-width: 1px"],["border-y","border-block-width: 1px"],...[0,...Te].map(e=>[`border-${e}`,`border-width: ${e}px`]),...[0,...Te].map(e=>[`border-x-${e}`,`border-inline-width: ${e}px;`]),...[0,...Te].map(e=>[`border-y-${e}`,`border-block-width: ${e}px;`]),...["top","bottom","left","right"].flatMap(e=>[[`border-${e.slice(0,1)}`,`border-${e}: 1px`],...[0,...Te].map(t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`])])]),...Ye([...Array.from({length:100},(e,t)=>[`text-${t}px`,`font-size: ${t}px`]),...Array.from({length:100},(e,t)=>[`text-${t*Ne}rem`,`font-size: ${t*Ne}rem`])])].sort(He).join("\n")),qe;var e}class Xe extends Re{impl="browser";dirpath=Z(globalThis.location?.href??"http://localhost/");parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return(new DOMParser).parseFromString(e,"text/html");{const t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}new Xe;function Je(e){for(const t of e){const e=document.createElement("style");switch(t){case"basic":f(e,Oe());break;case"utils":e.textContent=Qe();break;default:console.error(`Unknown style name: "${t}"`);continue}globalThis.document.head.appendChild(e)}}const et=new Xe;globalThis.Mancha=et;const tt=globalThis.document?.currentScript;if(globalThis.document?.currentScript?.hasAttribute("init")){const e=tt?.hasAttribute("debug"),t=tt?.getAttribute("cache"),r=tt?.getAttribute("target")?.split("+")||["body"];window.addEventListener("load",()=>{r.map(async r=>{const i=globalThis.document.querySelector(r);await et.debug(e).mount(i,{cache:t})})})}if(globalThis.document?.currentScript?.hasAttribute("css")){const e=tt?.getAttribute("css")?.split("+");Je(e)}})();
|
package/dist/mancha.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mancha.js","sourceRoot":"","sources":["../src/mancha.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"mancha.js","sourceRoot":"","sources":["../src/mancha.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAW,MAAM,cAAc,CAAC;AAE5D,MAAM,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;AAC7B,UAAkB,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;AACvC,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,EAAE,aAAa,CAAC;AAEzD,gFAAgF;AAChF,IAAI,UAAU,CAAC,QAAQ,EAAE,aAAa,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;IAC7D,MAAM,KAAK,GAAG,aAAa,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,WAAW,GAAG,aAAa,EAAE,YAAY,CAAC,OAAO,CAAwB,CAAC;IAChF,MAAM,OAAO,GAAG,aAAa,EAAE,YAAY,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9E,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE;QACnC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAc,EAAE,EAAE;YACnC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAgC,CAAC;YAC1F,MAAM,MAAM,CAAC,KAAK,CAAC,KAAO,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,mEAAmE;AACnE,IAAI,UAAU,CAAC,QAAQ,EAAE,aAAa,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;IAC5D,MAAM,UAAU,GAAG,aAAa,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAc,CAAC;IAC/E,SAAS,CAAC,UAAU,CAAC,CAAC;AACxB,CAAC;AAED,eAAe,MAAM,CAAC"}
|
package/dist/plugins.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { safeAnchorEl, safeAreaEl } from "safevalues/dom";
|
|
2
|
-
import { appendChild, attributeNameToCamelCase, cloneAttribute, ellipsize, firstElementChild, getAttribute, getAttributeOrDataset, insertBefore, isRelativePath, nodeToString, removeAttributeOrDataset, removeAttribute, removeChild, replaceChildren, replaceWith, safeSetAttribute, setAttribute, setProperty, traverse, hasProperty, } from "./dome.js";
|
|
2
|
+
import { appendChild, attributeNameToCamelCase, cloneAttribute, ellipsize, firstElementChild, getAttribute, getAttributeOrDataset, insertBefore, isRelativePath, nodeToString, removeAttributeOrDataset, removeAttribute, removeChild, replaceChildren, replaceWith, safeSetAttribute, setAttribute, setAttributeOrDataset, setProperty, traverse, hasProperty, } from "./dome.js";
|
|
3
3
|
import { Iterator } from "./iterator.js";
|
|
4
4
|
/** @internal */
|
|
5
5
|
export var RendererPlugins;
|
|
@@ -67,7 +67,7 @@ export var RendererPlugins;
|
|
|
67
67
|
await this.preprocessLocal(relpath, subparameters).then(handler);
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
-
RendererPlugins.rebaseRelativePaths =
|
|
70
|
+
RendererPlugins.rebaseRelativePaths = function (node, params) {
|
|
71
71
|
const elem = node;
|
|
72
72
|
const tagName = elem.tagName?.toLowerCase();
|
|
73
73
|
// Early exit: if there is no dirpath, we cannot rebase relative paths.
|
|
@@ -76,13 +76,17 @@ export var RendererPlugins;
|
|
|
76
76
|
// We have to retrieve the attribute, because the node property is always an absolute path.
|
|
77
77
|
const src = getAttribute(elem, "src");
|
|
78
78
|
const href = getAttribute(elem, "href");
|
|
79
|
+
const render = getAttributeOrDataset(elem, "render", ":");
|
|
79
80
|
// Early exit: if there is no element attribute to rebase, we can skip this step.
|
|
80
|
-
const pathref = src || href;
|
|
81
|
+
const pathref = src || href || render;
|
|
81
82
|
if (!pathref || !isRelativePath(pathref))
|
|
82
83
|
return;
|
|
83
84
|
const relpath = `${params.dirpath}/${pathref}`;
|
|
84
85
|
this.log("Rebasing relative path as:", relpath);
|
|
85
|
-
if (
|
|
86
|
+
if (render) {
|
|
87
|
+
setAttributeOrDataset(elem, "render", relpath, ":");
|
|
88
|
+
}
|
|
89
|
+
else if (hasProperty(elem, "attribs")) {
|
|
86
90
|
safeSetAttribute(elem, src ? "src" : "href", relpath);
|
|
87
91
|
}
|
|
88
92
|
else if (tagName === "img") {
|
|
@@ -113,7 +117,7 @@ export var RendererPlugins;
|
|
|
113
117
|
this.log("Unable to rebase relative path for element:", tagName);
|
|
114
118
|
}
|
|
115
119
|
};
|
|
116
|
-
RendererPlugins.registerCustomElements =
|
|
120
|
+
RendererPlugins.registerCustomElements = function (node, params) {
|
|
117
121
|
const elem = node;
|
|
118
122
|
const tagName = elem.tagName?.toLowerCase();
|
|
119
123
|
const customTagName = (getAttribute(elem, "is") || getAttribute(elem, "alt"))?.toLowerCase();
|
|
@@ -122,13 +126,23 @@ export var RendererPlugins;
|
|
|
122
126
|
return;
|
|
123
127
|
if (!this._customElements.has(customTagName)) {
|
|
124
128
|
this.log(`Registering custom element: ${customTagName}\n`, nodeToString(elem, 128));
|
|
129
|
+
// Preprocess template content so paths are rebased BEFORE registration.
|
|
130
|
+
// This must happen synchronously to avoid a race condition where resolveCustomElements
|
|
131
|
+
// clones the template before paths are rebased.
|
|
132
|
+
const content = elem.content || elem;
|
|
133
|
+
const contentNodes = Array.from(traverse(content));
|
|
134
|
+
// Skip the first node (the content/template root itself).
|
|
135
|
+
for (let i = 1; i < contentNodes.length; i++) {
|
|
136
|
+
RendererPlugins.rebaseRelativePaths.call(this, contentNodes[i], params);
|
|
137
|
+
}
|
|
138
|
+
// Now register the template with rebased paths.
|
|
125
139
|
this._customElements.set(customTagName, elem);
|
|
126
140
|
// Remove the original node from the DOM.
|
|
127
141
|
removeChild(elem.parentNode, elem);
|
|
128
142
|
}
|
|
129
143
|
}
|
|
130
144
|
};
|
|
131
|
-
RendererPlugins.resolveCustomElements =
|
|
145
|
+
RendererPlugins.resolveCustomElements = function (node, params) {
|
|
132
146
|
const elem = node;
|
|
133
147
|
const tagName = elem.tagName?.toLowerCase();
|
|
134
148
|
let cusName = tagName;
|
|
@@ -155,7 +169,7 @@ export var RendererPlugins;
|
|
|
155
169
|
replaceWith(node, ...clone.childNodes);
|
|
156
170
|
}
|
|
157
171
|
};
|
|
158
|
-
RendererPlugins.resolveTextNodeExpressions =
|
|
172
|
+
RendererPlugins.resolveTextNodeExpressions = function (node, params) {
|
|
159
173
|
const content = node.nodeValue || "";
|
|
160
174
|
if (node.nodeType !== 3 || !content?.trim())
|
|
161
175
|
return;
|
|
@@ -183,26 +197,36 @@ export var RendererPlugins;
|
|
|
183
197
|
this.log(":data attribute found in:\n", nodeToString(node, 128));
|
|
184
198
|
// Remove the attribute from the node.
|
|
185
199
|
removeAttributeOrDataset(elem, "data", ":");
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
200
|
+
let subrenderer;
|
|
201
|
+
// Check if the element already has a renderer attached.
|
|
202
|
+
if (hasProperty(node, "renderer")) {
|
|
203
|
+
subrenderer = node.renderer;
|
|
204
|
+
this.log("Reusing existing subrenderer for node:", nodeToString(node, 64));
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
subrenderer = this.subrenderer();
|
|
208
|
+
// Attach the subrenderer to the node as a property, using setProperty.
|
|
209
|
+
setProperty(node, "renderer", subrenderer);
|
|
210
|
+
this.log("Created and attached new subrenderer for node:", nodeToString(node, 64));
|
|
211
|
+
}
|
|
190
212
|
// Evaluate the expression.
|
|
191
213
|
const result = subrenderer.eval(dataAttr, { $elem: node });
|
|
192
214
|
// Await any promises in the result object.
|
|
193
215
|
// NOTE: Using the store object directly to avoid modifying ancestor values.
|
|
194
216
|
await Promise.all(Object.entries(result).map(([k, v]) => subrenderer._store.set(k, v)));
|
|
217
|
+
// Optimization: if we are reusing the current renderer, we don't need to re-mount
|
|
218
|
+
// or skip children. The current traversal will handle them.
|
|
219
|
+
if (subrenderer === this)
|
|
220
|
+
return;
|
|
195
221
|
// Skip all the children of the current node, if it's a subrenderer.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
this._skipNodes.add(child);
|
|
199
|
-
}
|
|
222
|
+
for (const child of traverse(node, this._skipNodes)) {
|
|
223
|
+
this._skipNodes.add(child);
|
|
200
224
|
}
|
|
201
225
|
// Mount the current node with the subrenderer.
|
|
202
226
|
await subrenderer.mount(node, params);
|
|
203
227
|
}
|
|
204
228
|
};
|
|
205
|
-
RendererPlugins.resolveClassAttribute =
|
|
229
|
+
RendererPlugins.resolveClassAttribute = function (node, params) {
|
|
206
230
|
if (this._skipNodes.has(node))
|
|
207
231
|
return;
|
|
208
232
|
const elem = node;
|
|
@@ -220,7 +244,7 @@ export var RendererPlugins;
|
|
|
220
244
|
});
|
|
221
245
|
}
|
|
222
246
|
};
|
|
223
|
-
RendererPlugins.resolveTextAttributes =
|
|
247
|
+
RendererPlugins.resolveTextAttributes = function (node, params) {
|
|
224
248
|
if (this._skipNodes.has(node))
|
|
225
249
|
return;
|
|
226
250
|
const elem = node;
|
|
@@ -257,7 +281,7 @@ export var RendererPlugins;
|
|
|
257
281
|
});
|
|
258
282
|
}
|
|
259
283
|
};
|
|
260
|
-
RendererPlugins.resolveEventAttributes =
|
|
284
|
+
RendererPlugins.resolveEventAttributes = function (node, params) {
|
|
261
285
|
if (this._skipNodes.has(node))
|
|
262
286
|
return;
|
|
263
287
|
const elem = node;
|
|
@@ -361,7 +385,7 @@ export var RendererPlugins;
|
|
|
361
385
|
});
|
|
362
386
|
}
|
|
363
387
|
};
|
|
364
|
-
RendererPlugins.resolveBindAttribute =
|
|
388
|
+
RendererPlugins.resolveBindAttribute = function (node, params) {
|
|
365
389
|
if (this._skipNodes.has(node))
|
|
366
390
|
return;
|
|
367
391
|
const elem = node;
|
|
@@ -400,7 +424,7 @@ export var RendererPlugins;
|
|
|
400
424
|
}
|
|
401
425
|
}
|
|
402
426
|
};
|
|
403
|
-
RendererPlugins.resolveShowAttribute =
|
|
427
|
+
RendererPlugins.resolveShowAttribute = function (node, params) {
|
|
404
428
|
if (this._skipNodes.has(node))
|
|
405
429
|
return;
|
|
406
430
|
const elem = node;
|
|
@@ -432,7 +456,7 @@ export var RendererPlugins;
|
|
|
432
456
|
});
|
|
433
457
|
}
|
|
434
458
|
};
|
|
435
|
-
RendererPlugins.resolveCustomAttribute =
|
|
459
|
+
RendererPlugins.resolveCustomAttribute = function (node, params) {
|
|
436
460
|
if (this._skipNodes.has(node))
|
|
437
461
|
return;
|
|
438
462
|
const elem = node;
|
|
@@ -451,7 +475,7 @@ export var RendererPlugins;
|
|
|
451
475
|
}
|
|
452
476
|
}
|
|
453
477
|
};
|
|
454
|
-
RendererPlugins.resolveCustomProperty =
|
|
478
|
+
RendererPlugins.resolveCustomProperty = function (node, params) {
|
|
455
479
|
if (this._skipNodes.has(node))
|
|
456
480
|
return;
|
|
457
481
|
const elem = node;
|
|
@@ -471,7 +495,7 @@ export var RendererPlugins;
|
|
|
471
495
|
}
|
|
472
496
|
}
|
|
473
497
|
};
|
|
474
|
-
RendererPlugins.stripTypes =
|
|
498
|
+
RendererPlugins.stripTypes = function (node, params) {
|
|
475
499
|
const elem = node;
|
|
476
500
|
// Remove :types and data-types attributes
|
|
477
501
|
if (getAttribute(elem, ":types")) {
|
|
@@ -481,5 +505,52 @@ export var RendererPlugins;
|
|
|
481
505
|
removeAttribute(elem, "data-types");
|
|
482
506
|
}
|
|
483
507
|
};
|
|
508
|
+
/**
|
|
509
|
+
* Rendering plugin: creates a subrenderer, mounts it, then imports module from
|
|
510
|
+
* :render/data-render and calls the default export.
|
|
511
|
+
* Path resolution is handled by rebaseRelativePaths during preprocessing.
|
|
512
|
+
*/
|
|
513
|
+
RendererPlugins.resolveRenderAttribute = async function (node, params) {
|
|
514
|
+
if (this._skipNodes.has(node))
|
|
515
|
+
return;
|
|
516
|
+
const elem = node;
|
|
517
|
+
const src = getAttributeOrDataset(elem, "render", ":");
|
|
518
|
+
if (!src)
|
|
519
|
+
return;
|
|
520
|
+
this.log(`:render attribute found: ${src}`);
|
|
521
|
+
// Remove attribute before mounting to prevent re-processing.
|
|
522
|
+
removeAttributeOrDataset(elem, "render", ":");
|
|
523
|
+
let subrenderer;
|
|
524
|
+
// Check if the element already has a renderer attached.
|
|
525
|
+
if (hasProperty(node, "renderer")) {
|
|
526
|
+
subrenderer = node.renderer;
|
|
527
|
+
this.log("Reusing existing subrenderer for :render:", nodeToString(node, 64));
|
|
528
|
+
}
|
|
529
|
+
else {
|
|
530
|
+
// Create a subrenderer to process this node and its descendants.
|
|
531
|
+
subrenderer = this.subrenderer();
|
|
532
|
+
setProperty(elem, "renderer", subrenderer);
|
|
533
|
+
}
|
|
534
|
+
// Mount subrenderer - this processes all descendants.
|
|
535
|
+
await subrenderer.mount(node, params);
|
|
536
|
+
// Skip this node and descendants in parent renderer.
|
|
537
|
+
// We do this AFTER mount to allow recursive mounting (subrenderer === this) to process children first.
|
|
538
|
+
for (const child of traverse(node, this._skipNodes)) {
|
|
539
|
+
this._skipNodes.add(child);
|
|
540
|
+
}
|
|
541
|
+
// Subrenderer is done, descendants are ready - execute init.
|
|
542
|
+
try {
|
|
543
|
+
const module = await import(/* webpackIgnore: true */ src);
|
|
544
|
+
if (typeof module.default === "function") {
|
|
545
|
+
await module.default(elem, subrenderer);
|
|
546
|
+
}
|
|
547
|
+
else if (module.default !== undefined) {
|
|
548
|
+
console.warn(`Module ${src} default export is not a function`);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
catch (err) {
|
|
552
|
+
console.error(`Failed to execute render init from ${src}:`, err);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
484
555
|
})(RendererPlugins || (RendererPlugins = {}));
|
|
485
556
|
//# sourceMappingURL=plugins.js.map
|