mancha 0.13.2 → 0.13.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/dist/browser.js CHANGED
@@ -1 +1 @@
1
- class e{iterable;constructor(e){this.iterable=e}filter(t){return new e(e.filterGenerator(t,this.iterable))}map(t){return new e(e.mapGenerator(t,this.iterable))}find(e){for(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}}const t=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function r(e){if(!function(e){const r=!t.test(e);return r}(e))return e}function i(e){return r(e)}const n={};function s(e){0}"undefined"!=typeof window&&window.TrustedScriptURL;class o{constructor(e,t){this.privateDoNotAccessOrElseWrappedAttributePrefix=t}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const a=o;function l(e){if(function(e){return e instanceof o}(e))return e.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}"undefined"!=typeof window&&window.TrustedHTML;function c(e,t,r,i){if(0===e.length){throw new Error("")}const n=e.map((e=>l(e))),s=r.toLowerCase();if(n.every((e=>0!==s.indexOf(e))))throw new Error(`Attribute "${r}" does not match any of the allowed prefixes.`);t.setAttribute(r,i)}"undefined"!=typeof window&&window.TrustedScript;class h{}class u extends h{constructor(e,t){super(),s(),this.privateDoNotAccessOrElseWrappedStyleSheet=e}toString(){return this.privateDoNotAccessOrElseWrappedStyleSheet}}function p(e){return new u(e,n)}function d(e){if(e instanceof u)return e.privateDoNotAccessOrElseWrappedStyleSheet;throw new Error("")}Error;function f(e){return Object.isFrozen(e)&&Object.isFrozen(e.raw)}function m(e){return-1===e.toString().indexOf("`")}m((e=>e``))||m((e=>e`\0`))||m((e=>e`\n`))||m((e=>e`\u0000`)),f``&&f`\0`&&f`\n`&&f`\u0000`;function _(e){const t=e[0].toLowerCase();return new a(n,t)}var g,$;function v(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"}(g||(g={}));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:$.KEEP};const i=this.globalAttributePolicies.get(e);return i||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((t=>0===e.indexOf(t)))?{policyAction:$.KEEP}:{policyAction:$.DROP})}}!function(e){e[e.DROP=0]="DROP",e[e.KEEP=1]="KEEP",e[e.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",e[e.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",e[e.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}($||($={}));new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const w=["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"],b=[["A",new Map([["href",{policyAction:$.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:$.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],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"],y=[["dir",{policyAction:$.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:$.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:$.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:$.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:$.KEEP_AND_SANITIZE_URL}],["target",{policyAction:$.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["target",new Set(["_self","_blank"])]])))}]];new x(new Set(w),new Map(b),new Set(E),new Map(y)),new x(new Set(v((()=>w.concat(["STYLE"])))),new Map(b),new Set(v((()=>E.concat(["id","name","class"])))),new Map(v((()=>y.concat([["style",{policyAction:$.KEEP_AND_SANITIZE_STYLE}]])))));function A(e){return p(e[0])}const R=[_`:`,_`style`,_`class`];function*O(e,t=new Set){const r=new Set,i=Array.from(e.childNodes).filter((e=>!t.has(e)));for(yield e;i.length;){const e=i.shift();r.has(e)||(r.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter((e=>!t.has(e))).forEach((e=>i.push(e)))}}function I(e,t){return void 0!==e?.[t]}function N(e,t){return"function"==typeof e?.[t]}function k(e){return e.replace(/-./g,(e=>e[1].toUpperCase()))}function T(e,t){return I(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function P(e,t,r=""){return T(e,r+t)||(e.dataset?.[k(t)]??null)}function S(e,t,r){I(e,"attribs")?e.attribs[t]=r:e.setAttribute?.(t,r)}function C(e,t,r){I(e,"attribs")?e.attribs[t]=r:c(R,e,t,r)}function L(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 D(e,t){I(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function M(e,t,r=""){D(e,`${r}${t}`),D(e,`data-${t}`)}function U(e,t,r){if(I(e,"attribs")&&I(t,"attribs"))t.attribs[r]=e.attribs[r];else if(r.startsWith("data-")){const i=k(r.slice(5));t.dataset[i]=e.dataset?.[i]}else{const i=e?.getAttribute?.(r);C(t,r,i||"")}}function z(e){if(I(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 F(e,...t){N(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function G(e,t){return N(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function K(e,t){return N(t,"removeChild")?e.removeChild(t):(F(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function W(e,t,r){return r?N(e,"insertBefore")?e.insertBefore(t,r):(j(r,t,r),t):G(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 H(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}var V;!function(t){t.resolveIncludes=async function(e,t){const r=e,i=r.tagName?.toLowerCase();if(!["include","link"].includes(i))return;if("link"===i&&"subresource"!==T(r,"rel"))return;this.log("include directive found in:\n",B(e,128)),this.log("include params:",t);const n="link"===r.tagName.toLocaleLowerCase()?"href":"src",s=T(r,n);if(!s)throw new Error(`"${n}" attribute missing from ${B(e,128)}.`);const o=[];"include"===i&&o.push("src"),"link"===i&&o.push("rel","href");const a=t=>{const i=z(t);for(const e of Array.from(r.attributes))i&&!o.includes(e.name)&&U(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)}},t.rebaseRelativePaths=async function(e,t){const r=e,n=r.tagName?.toLowerCase();if(!t?.dirpath)return;const s=T(r,"src"),o=T(r,"href"),a=s||o;if(!a||((l=a).includes("://")||l.startsWith("/")||l.startsWith("#")||l.startsWith("data:")))return;var l;const c=`${t.dirpath}/${a}`;this.log("Rebasing relative path as:",c),I(r,"attribs")?C(r,s?"src":"href",c):"img"===n?r.src=c:"a"===n?function(e,t){const r=i(t);void 0!==r&&(e.href=r)}(r,c):"source"===n||"audio"===n||"video"===n||"track"===n||"input"===n?r.src=c:"area"===n?function(e,t){const r=i(t);void 0!==r&&(e.href=r)}(r,c):this.log("Unable to rebase relative path for element:",n)},t.registerCustomElements=async function(e,t){const r=e,i=r.tagName?.toLowerCase(),n=(T(r,"is")||T(r,"alt"))?.toLowerCase();if(["template","div"].includes(i)&&n){if("div"===i&&"template"!==T(r,"role"))return;this._customElements.has(n)||(this.log(`Registering custom element: ${n}\n`,B(r,128)),this._customElements.set(n,r),K(r.parentNode,r))}},t.resolveCustomElements=async function(t,r){const i=t,n=i.tagName?.toLowerCase();let s=n;if("div"===s&&(s=T(i,"role")?.toLowerCase()||s),s&&this._customElements.has(s)){this.log(`Processing custom element: ${s}\n`,B(i,128));const r=this._customElements.get(s),o=(r.content||r).cloneNode(!0),a=z(o);if(a)for(const e of Array.from(i.attributes))"div"===n&&"role"===e.name||U(i,a,e.name);const l=new e(O(o)).find((e=>"slot"===e.tagName?.toLowerCase()));l&&j(l,...i.childNodes),j(t,...o.childNodes)}},t.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}))},t.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)),M(r,"data",":");const n=t?.rootNode===e?this:this.subrenderer();e.renderer=n;const s=n.eval(i,{$elem:e});if(await Promise.all(Object.entries(s).map((([e,t])=>n.set(e,t)))),n!==this)for(const t of O(e,this._skipNodes))this._skipNodes.add(t);await n.mount(e,t)}},t.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)),M(r,"class",":");const t=T(r,"class")||"";return this.effect((function(){const n=this.eval(i,{$elem:e});C(r,"class",(n?`${t} ${n}`:t).trim())}))}},t.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)),M(r,"text",":");const t=t=>this.textContent(e,t);return this.effect((function(){t(this.eval(i,{$elem:e}))}))}},t.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)),M(r,"html",":"),this.effect((function(){const n=this.eval(i,{$elem:e});return new Promise((async e=>{const i=await this.preprocessString(n,t);await this.renderNode(i),F(r,i),e()}))}))):void 0},t.resolveEventAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){const i=t.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!i)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",B(e,128)),D(r,t.name);const n="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,(r=>(n&&r.preventDefault(),this.eval(t.value,{$elem:e,$event:r}))))}},t.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)),M(r,"for",":");for(const t of O(e,this._skipNodes))this._skipNodes.add(t);const n=T(r,"style")||"";S(r,"style","display: none;");const s=e.parentNode,o=this.createElement("template",e.ownerDocument);W(s,o,e),K(s,e),G(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=>{K(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.set(c,s);const o=e.cloneNode(!0);S(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)W(s,e,a);return Promise.all(i)}))}},t.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=T(r,":bind:on")?.split(",")||r.dataset?.bindOn?.split(",")||t;M(r,"bind",":"),D(r,":bind:on"),D(r,"data-bind-on");const s="checkbox"===T(r,"type")?"checked":"value";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})))}},t.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)),M(r,"show",":");const t="none"===r.style?.display?"":r.style?.display??T(r,"style")?.split(";")?.find((e=>"display"===e.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const n=this.eval(i,{$elem:e});r.style?r.style.display=n?t:"none":C(r,"style",`display: ${n?t:"none"};`)}))}},t.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)),D(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});S(r,s,i)}))}}},t.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)),D(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1),o=k(s);this.effect((function(){const i=this.eval(t.value,{$elem:e});L(r,o,i)}))}}}}(V||(V={}));const Z=["this"],q=["+","-","!"],Q=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],X={"!":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},J=["==","!=","<=",">=","||","&&","??","|>"],ee=["===","!=="];var te;!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"}(te||(te={}));const re=(e,t,r=0)=>({kind:e,value:t,precedence:r}),ie=e=>95===e||36===e||65<=(e&=-33)&&e<=90,ne=e=>48<=e&&e<=57;class se{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;9===(e=this._next)||10===e||13===e||32===e;)this._advance(!0);var e;if((e=>34===e||39===e)(this._next))return this._tokenizeString();if(ie(this._next))return this._tokenizeIdentOrKeyword();if(ne(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=re(te.STRING,this._getValue().replace(/\\(.)/g,((e,t)=>{switch(t){case"n":return"\n";case"r":return"\r";case"t":return"\t";case"b":return"\b";case"f":return"\f";default:return t}})));return this._advance(),r}_tokenizeIdentOrKeyword(){do{this._advance()}while(e=this._next,ie(e)||ne(e));var e;const t=this._getValue(),r=(i=t,-1!==Z.indexOf(i)?te.KEYWORD:te.IDENTIFIER);var i;return re(r,t)}_tokenizeNumber(){do{this._advance()}while(ne(this._next));return 46===this._next?this._tokenizeDot():re(te.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),ne(this._next)?this._tokenizeFraction():(this._clearValue(),re(te.DOT,".",13))}_tokenizeComma(){return this._advance(!0),re(te.COMMA,",")}_tokenizeColon(){return this._advance(!0),re(te.COLON,":")}_tokenizeFraction(){do{this._advance()}while(ne(this._next));return re(te.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(-1!==ee.indexOf(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),re(te.ARROW,e);-1!==J.indexOf(e)&&this._advance()}return e=this._getValue(),re(te.OPERATOR,e,X[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=re(te.GROUPER,e,X[e]);return this._advance(!0),t}}class oe{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new se(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(te.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(te.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(te.DOT)){this._advance();const t=this._parseUnary();e=this._makeInvokeOrGetter(e,t)}else{if(this._matches(te.KEYWORD))break;if(!(this._matches(te.OPERATOR)&&this._token.precedence>=t))break;e="?"===this._value?this._parseTernary(e):this._parseBinary(e,this._token)}return e}_makeInvokeOrGetter(e,t){if(void 0===t)throw new Error("expected identifier");if("ID"===t.type)return this._ast.getter(e,t.value);if("Invoke"===t.type&&"ID"===t.receiver.type){const r=t.receiver;return this._ast.invoke(e,r.value,t.arguments)}throw new Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(-1===Q.indexOf(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let r=this._parseUnary();for(;(this._kind===te.OPERATOR||this._kind===te.DOT||this._kind===te.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(te.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(te.INTEGER))return this._parseInteger(e);if(this._matches(te.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(te.OPERATOR,"?");const t=this._parseExpression();this._advance(te.COLON);const r=this._parseExpression();return this._ast.ternary(e,t,r)}_parsePrimary(){switch(this._kind){case te.KEYWORD:const e=this._value;if("this"===e)return this._advance(),this._ast.id(e);if(-1!==Z.indexOf(e))throw new Error(`unexpected keyword: ${e}`);throw new Error(`unrecognized keyword: ${e}`);case te.IDENTIFIER:return this._parseInvokeOrIdentifier();case te.STRING:return this._parseString();case te.INTEGER:return this._parseInteger();case te.DECIMAL:return this._parseDecimal();case te.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case te.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(te.GROUPER,"]"))break;e.push(this._parseExpression())}while(this._matches(te.COMMA));return this._advance(te.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e={};do{if(this._advance(),this._matches(te.GROUPER,"}"))break;const t=this._value;(this._matches(te.STRING)||this._matches(te.IDENTIFIER))&&this._advance(),this._advance(te.COLON),e[t]=this._parseExpression()}while(this._matches(te.COMMA));return this._advance(te.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(te.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(te.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(te.GROUPER,")"))break;const t=this._parseExpression();e.push(t)}while(this._matches(te.COMMA));return this._advance(te.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(te.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(te.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 ae={"+":(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)},le={"+":e=>e,"-":e=>-e,"!":e=>!e};class ce{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 he=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=le[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=ae[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 ue(e,t){if(e.has(t))return e.get(t);if(e.has("$parent")){return ue(e.get("$parent"),t)}return null}function pe(e,t){if(e.has(t))return e;if(e.has("$parent")){return pe(e.get("$parent"),t)}return null}class de extends ce{evalkeys=["$elem","$event"];expressionCache=new Map;store=new Map;observers=new Map;_observer=null;_lock=Promise.resolve();constructor(e){super();for(let[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof de||r.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>r in e&&(delete e[r],t(),!0),set:(r,i,n,s)=>{"object"==typeof n&&null!=e&&(n=this.wrapObject(n,t));const o=Reflect.set(r,i,n,s);return t(),o},get:(e,t,r)=>"__is_proxy__"===t||Reflect.get(e,t,r)});var r}watch(e,t){this.observers.has(e)||this.observers.set(e,new Set),this.observers.get(e)?.has(t)||this.observers.get(e)?.add(t)}async notify(e,t=10){const r=Array.from(this.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(r.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),ue(this.store,e)}async set(e,t){if(t===this.store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=pe(e,t);i?i.set(t,r):e.set(t,r)}(this.store,e,t),await r()}del(e){this.store.delete(e),this.observers.delete(e)}has(e){return this.store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this.store.entries()).map((([e])=>e)),r=Object.fromEntries(t.map((e=>[e,void 0])));return new Proxy(r,{get:(t,r,i)=>"string"==typeof r&&pe(this.store,r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes(" = ")){const[r,i]=e.split(" = ");t=r.trim(),e=i.trim()}return(r,i)=>{const n=((e,t)=>new oe(e,t).parse())(e,he),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}}}}class fe extends de{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(e){return this.debugging=e,this}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??"default"}).then((e=>e.text()))}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log("Preprocessing string content with params:\n",t);const r=this.parseHTML(e,t);return await this.preprocessNode(r,t),r}async preprocessRemote(e,t){const r={};t?.cache&&(r.cache=t.cache);const i=await fetch(e,r).then((e=>e.text()));return this.preprocessString(i,{...t,dirpath:H(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:H(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}subrenderer(){const e=(new this.constructor).debug(this.debugging);return e.set("$parent",this),e.set("$rootRenderer",this.get("$rootRenderer")??this),e._customElements=this._customElements,e}log(...e){this.debugging&&console.debug(...e)}async preprocessNode(t,r){r={dirpath:this.dirpath,maxdepth:10,...r};const i=new e(O(t,this._skipNodes)).map((async e=>{this.log("Preprocessing node:\n",B(e,128)),await V.resolveIncludes.call(this,e,r),await V.rebaseRelativePaths.call(this,e,r),await V.registerCustomElements.call(this,e,r),await V.resolveCustomElements.call(this,e,r)}));return await Promise.all(i.generator()),t}async renderNode(e,t){for(const r of O(e,this._skipNodes))this.log("Rendering node:\n",B(r,128)),await V.resolveForAttribute.call(this,r,t),await V.resolveDataAttribute.call(this,r,t),await V.resolveTextAttributes.call(this,r,t),await V.resolveHtmlAttribute.call(this,r,t),await V.resolveShowAttribute.call(this,r,t),await V.resolveClassAttribute.call(this,r,t),await V.resolveBindAttribute.call(this,r,t),await V.resolveEventAttributes.call(this,r,t),await V.resolveTextNodeExpressions.call(this,r,t),await V.resolveCustomAttribute.call(this,r,t),await V.resolveCustomProperty.call(this,r,t);return e}async mount(e,t){t={...t,rootNode:e},L(e,"renderer",this),this.set("$rootNode",e),await this.preprocessNode(e,t),await this.renderNode(e,t)}}function me(){return p([A`html{`,A`max-width: 70ch;`,A`padding: 2em 1em;`,A`margin: auto;`,A`line-height: 1.75;`,A`font-size: 1.25em;`,A`font-family: sans-serif;`,A`}`,A`h1,h2,h3,h4,h5,h6{`,A`margin: 1em 0 0.5em;`,A`}`,A`p,ul,ol{`,A`margin-bottom: 1em;`,A`color: #1d1d1d;`,A`}`].map(d).join(""))}const _e={sm:640,md:768,lg:1024,xl:1280},ge=.25,$e=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],ve=[...$e,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(_e)],xe=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],we=[75,100,150,200,300,500,700,1e3],be=["hover","focus","disabled","active"],Ee={margin:"m",padding:"p"},ye={width:"w",height:"h"},Ae={top:"top",right:"right",bottom:"bottom",left:"left"},Re={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},Oe={"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"},"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},"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"}},Ie=["@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 }"],Ne={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 ke(e){return`#${e.toString(16).padStart(6,"0")}`}function Te(e){return be.map((t=>`.${t}\\:${e}:${t}`))}function Pe(e,t){return Object.entries(_e).map((([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`))}function Se(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function Ce(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100vw`],[`${t}-full`,`${e}: 100%`],...ve.map((r=>[`${t}-${r}`,`${e}: ${r*ge}rem`])),...ve.map((r=>[`-${t}-${r}`,`${e}: -${r*ge}rem`])),...ve.map((r=>[`${t}-${r}px`,`${e}: ${r}px`])),...ve.map((r=>[`-${t}-${r}px`,`${e}: -${r}px`])),...xe.map((r=>[`${t}-${r}\\%`,`${e}: ${r}%`])),...xe.map((r=>[`-${t}-${r}\\%`,`${e}: -${r}%`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)]))}function Le(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;`],...ve.map((e=>[e,e*ge])).map((([r,i])=>[`${t}x-${r}`,`${e}-left: ${i}rem; ${e}-right: ${i}rem;`])),...ve.map((e=>[e,e*ge])).map((([r,i])=>[`${t}y-${r}`,`${e}-top: ${i}rem; ${e}-bottom: ${i}rem;`])),...ve.map((r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`])),...ve.map((r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`])),...xe.map((r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`])),...xe.map((r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)]))}function De(){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(Ne).flatMap((([e,t])=>[[`text-${e}`,`color: ${ke(t[500])}`],[`fill-${e}`,`fill: ${ke(t[500])}`],[`bg-${e}`,`background-color: ${ke(t[500])}`],[`border-${e}`,`border-color: ${ke(t[500])}`]])),r=Object.entries(Ne).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[[`text-${e}-${t}`,`color: ${ke(r)}`],[`fill-${e}-${t}`,`fill: ${ke(r)}`],[`bg-${e}-${t}`,`background-color: ${ke(r)}`],[`border-${e}-${t}`,`border-color: ${ke(r)}`]]))));return[].concat(e).concat(t).concat(r).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)]))}function Me(){return[...Ie,...Object.entries(Oe).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[`.${e} { ${t}: ${r} }`,`${Te(e).join(",")} { ${t}: ${r} }`,...Pe(e,`${t}: ${r}`)])))),...De(),...[["opacity-0","opacity: 0"],...xe.map((e=>[`opacity-${e}`,"opacity: "+e/100]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)])),...[...xe.map((e=>[`z-${e}`,`z-index: ${e}`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)])),...[...we.map((e=>[`duration-${e}`,`transition-duration: ${e}ms`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)])),...Ce(Ae),...Ce(ye),...Le(ye),...(e=Ee,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=>[...ve.map((e=>[e,e*ge])).map((([i,n])=>[`${r}${t}t-${i}`,`${e}-top: ${r}${n}rem`])),...ve.map((e=>[e,e*ge])).map((([i,n])=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${n}rem`])),...ve.map((e=>[e,e*ge])).map((([i,n])=>[`${r}${t}l-${i}`,`${e}-left: ${r}${n}rem`])),...ve.map((e=>[e,e*ge])).map((([i,n])=>[`${r}${t}r-${i}`,`${e}-right: ${r}${n}rem`])),...ve.map((i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`])),...ve.map((i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`])),...ve.map((i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`])),...ve.map((i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`])),...xe.map((i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`])),...xe.map((i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%;`])),...xe.map((i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`])),...xe.map((i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`]))]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)]))),...Ce(Ee),...Le(Ee),...[["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...ve.map((e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*ge}rem`])),...ve.map((e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*ge}rem`])),...ve.map((e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`])),...ve.map((e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`])),["gap-0","gap: 0"],...ve.map((e=>[`gap-${e}`,`gap: ${e*ge}rem`])),...ve.map((e=>[`gap-${e}px`,`gap: ${e}px`])),...ve.map((e=>[`gap-x-${e}`,`column-gap: ${e*ge}rem`])),...ve.map((e=>[`gap-y-${e}`,`row-gap: ${e*ge}rem`])),...ve.map((e=>[`gap-x-${e}px`,`column-gap: ${e}px`])),...ve.map((e=>[`gap-y-${e}px`,`row-gap: ${e}px`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)])),...Ce(Re),...[["border","border: 1px"],["border-x","border-inline-width: 1px"],["border-y","border-block-width: 1px"],...[0,...$e].map((e=>[`border-${e}`,`border-width: ${e}px`])),...[0,...$e].map((e=>[`border-x-${e}`,`border-inline-width: ${e}px;`])),...[0,...$e].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,...$e].map((t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`]))]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(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*ge)).map((e=>[`text-${e}rem`,`font-size: ${e}rem`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)]))].sort(Se).join("\n");var e}class Ue extends fe{impl="browser";dirpath=H(globalThis.location?.href??"http://localhost/");parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return(new DOMParser).parseFromString(e,"text/html");{const t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}const ze=new Ue;export{ze as Mancha,Ue as Renderer,me as basicCssRules,Me as utilsCssRules};
1
+ class e{iterable;constructor(e){this.iterable=e}filter(t){return new e(e.filterGenerator(t,this.iterable))}map(t){return new e(e.mapGenerator(t,this.iterable))}find(e){for(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}}const t=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function r(e){if(!function(e){const r=!t.test(e);return r}(e))return e}function i(e){return r(e)}const n={};function s(e){0}"undefined"!=typeof window&&window.TrustedScriptURL;class o{constructor(e,t){this.privateDoNotAccessOrElseWrappedAttributePrefix=t}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const a=o;function l(e){if(function(e){return e instanceof o}(e))return e.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}"undefined"!=typeof window&&window.TrustedHTML;function c(e,t,r,i){if(0===e.length){throw new Error("")}const n=e.map((e=>l(e))),s=r.toLowerCase();if(n.every((e=>0!==s.indexOf(e))))throw new Error(`Attribute "${r}" does not match any of the allowed prefixes.`);t.setAttribute(r,i)}"undefined"!=typeof window&&window.TrustedScript;class h{}class u extends h{constructor(e,t){super(),s(),this.privateDoNotAccessOrElseWrappedStyleSheet=e}toString(){return this.privateDoNotAccessOrElseWrappedStyleSheet}}function p(e){return new u(e,n)}function d(e){if(e instanceof u)return e.privateDoNotAccessOrElseWrappedStyleSheet;throw new Error("")}Error;function f(e){return Object.isFrozen(e)&&Object.isFrozen(e.raw)}function m(e){return-1===e.toString().indexOf("`")}m((e=>e``))||m((e=>e`\0`))||m((e=>e`\n`))||m((e=>e`\u0000`)),f``&&f`\0`&&f`\n`&&f`\u0000`;function _(e){const t=e[0].toLowerCase();return new a(n,t)}var g,$;function v(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"}(g||(g={}));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:$.KEEP};const i=this.globalAttributePolicies.get(e);return i||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((t=>0===e.indexOf(t)))?{policyAction:$.KEEP}:{policyAction:$.DROP})}}!function(e){e[e.DROP=0]="DROP",e[e.KEEP=1]="KEEP",e[e.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",e[e.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",e[e.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}($||($={}));new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const w=["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"],b=[["A",new Map([["href",{policyAction:$.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:$.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:$.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],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"],y=[["dir",{policyAction:$.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:$.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:$.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:$.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:$.KEEP_AND_SANITIZE_URL}],["target",{policyAction:$.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["target",new Set(["_self","_blank"])]])))}]];new x(new Set(w),new Map(b),new Set(E),new Map(y)),new x(new Set(v((()=>w.concat(["STYLE"])))),new Map(b),new Set(v((()=>E.concat(["id","name","class"])))),new Map(v((()=>y.concat([["style",{policyAction:$.KEEP_AND_SANITIZE_STYLE}]])))));function A(e){return p(e[0])}const R=[_`:`,_`style`,_`class`];function*O(e,t=new Set){const r=new Set,i=Array.from(e.childNodes).filter((e=>!t.has(e)));for(yield e;i.length;){const e=i.shift();r.has(e)||(r.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter((e=>!t.has(e))).forEach((e=>i.push(e)))}}function I(e,t){return void 0!==e?.[t]}function N(e,t){return"function"==typeof e?.[t]}function k(e){return e.replace(/-./g,(e=>e[1].toUpperCase()))}function T(e,t){return I(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function P(e,t,r=""){return T(e,r+t)||(e.dataset?.[k(t)]??null)}function S(e,t,r){I(e,"attribs")?e.attribs[t]=r:e.setAttribute?.(t,r)}function C(e,t,r){I(e,"attribs")?e.attribs[t]=r:c(R,e,t,r)}function L(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 D(e,t){I(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function M(e,t,r=""){D(e,`${r}${t}`),D(e,`data-${t}`)}function U(e,t,r){if(I(e,"attribs")&&I(t,"attribs"))t.attribs[r]=e.attribs[r];else if(r.startsWith("data-")){const i=k(r.slice(5));t.dataset[i]=e.dataset?.[i]}else{const i=e?.getAttribute?.(r);C(t,r,i||"")}}function z(e){if(I(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 F(e,...t){N(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function G(e,t){return N(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function K(e,t){return N(t,"removeChild")?e.removeChild(t):(F(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function W(e,t,r){return r?N(e,"insertBefore")?e.insertBefore(t,r):(j(r,t,r),t):G(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 H(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}var V;!function(t){t.resolveIncludes=async function(e,t){const r=e,i=r.tagName?.toLowerCase();if(!["include","link"].includes(i))return;if("link"===i&&"subresource"!==T(r,"rel"))return;this.log("include directive found in:\n",B(e,128)),this.log("include params:",t);const n="link"===r.tagName.toLocaleLowerCase()?"href":"src",s=T(r,n);if(!s)throw new Error(`"${n}" attribute missing from ${B(e,128)}.`);const o=[];"include"===i&&o.push("src"),"link"===i&&o.push("rel","href");const a=t=>{const i=z(t);for(const e of Array.from(r.attributes))i&&!o.includes(e.name)&&U(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)}},t.rebaseRelativePaths=async function(e,t){const r=e,n=r.tagName?.toLowerCase();if(!t?.dirpath)return;const s=T(r,"src"),o=T(r,"href"),a=s||o;if(!a||((l=a).includes("://")||l.startsWith("/")||l.startsWith("#")||l.startsWith("data:")))return;var l;const c=`${t.dirpath}/${a}`;this.log("Rebasing relative path as:",c),I(r,"attribs")?C(r,s?"src":"href",c):"img"===n?r.src=c:"a"===n?function(e,t){const r=i(t);void 0!==r&&(e.href=r)}(r,c):"source"===n||"audio"===n||"video"===n||"track"===n||"input"===n?r.src=c:"area"===n?function(e,t){const r=i(t);void 0!==r&&(e.href=r)}(r,c):this.log("Unable to rebase relative path for element:",n)},t.registerCustomElements=async function(e,t){const r=e,i=r.tagName?.toLowerCase(),n=(T(r,"is")||T(r,"alt"))?.toLowerCase();if(["template","div"].includes(i)&&n){if("div"===i&&"template"!==T(r,"role"))return;this._customElements.has(n)||(this.log(`Registering custom element: ${n}\n`,B(r,128)),this._customElements.set(n,r),K(r.parentNode,r))}},t.resolveCustomElements=async function(t,r){const i=t,n=i.tagName?.toLowerCase();let s=n;if("div"===s&&(s=T(i,"role")?.toLowerCase()||s),s&&this._customElements.has(s)){this.log(`Processing custom element: ${s}\n`,B(i,128));const r=this._customElements.get(s),o=(r.content||r).cloneNode(!0),a=z(o);if(a)for(const e of Array.from(i.attributes))"div"===n&&"role"===e.name||U(i,a,e.name);const l=new e(O(o)).find((e=>"slot"===e.tagName?.toLowerCase()));l&&j(l,...i.childNodes),j(t,...o.childNodes)}},t.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}))},t.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)),M(r,"data",":");const n=t?.rootNode===e?this:this.subrenderer();e.renderer=n;const s=n.eval(i,{$elem:e});if(await Promise.all(Object.entries(s).map((([e,t])=>n.set(e,t)))),n!==this)for(const t of O(e,this._skipNodes))this._skipNodes.add(t);await n.mount(e,t)}},t.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)),M(r,"class",":");const t=T(r,"class")||"";return this.effect((function(){const n=this.eval(i,{$elem:e});C(r,"class",(n?`${t} ${n}`:t).trim())}))}},t.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)),M(r,"text",":");const t=t=>this.textContent(e,t);return this.effect((function(){t(this.eval(i,{$elem:e}))}))}},t.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)),M(r,"html",":"),this.effect((function(){const n=this.eval(i,{$elem:e});return new Promise((async e=>{const i=await this.preprocessString(n,t);await this.renderNode(i),F(r,i),e()}))}))):void 0},t.resolveEventAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){const i=t.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!i)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",B(e,128)),D(r,t.name);const n="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,(r=>(n&&r.preventDefault(),this.eval(t.value,{$elem:e,$event:r}))))}},t.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)),M(r,"for",":");for(const t of O(e,this._skipNodes))this._skipNodes.add(t);const n=T(r,"style")||"";S(r,"style","display: none;");const s=e.parentNode,o=this.createElement("template",e.ownerDocument);W(s,o,e),K(s,e),G(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=>{K(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.set(c,s);const o=e.cloneNode(!0);S(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)W(s,e,a);return Promise.all(i)}))}},t.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=T(r,":bind:on")?.split(",")||r.dataset?.bindOn?.split(",")||t;M(r,"bind",":"),D(r,":bind:on"),D(r,"data-bind-on");const s="checkbox"===T(r,"type")?"checked":"value";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})))}},t.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)),M(r,"show",":");const t="none"===r.style?.display?"":r.style?.display??T(r,"style")?.split(";")?.find((e=>"display"===e.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const n=this.eval(i,{$elem:e});r.style?r.style.display=n?t:"none":C(r,"style",`display: ${n?t:"none"};`)}))}},t.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)),D(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});S(r,s,i)}))}}},t.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)),D(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1),o=k(s);this.effect((function(){const i=this.eval(t.value,{$elem:e});L(r,o,i)}))}}}}(V||(V={}));const Z=["this"],q=["+","-","!"],Q=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],X={"!":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},J=["==","!=","<=",">=","||","&&","??","|>"],ee=["===","!=="];var te;!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"}(te||(te={}));const re=(e,t,r=0)=>({kind:e,value:t,precedence:r}),ie=e=>95===e||36===e||65<=(e&=-33)&&e<=90,ne=e=>48<=e&&e<=57;class se{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;9===(e=this._next)||10===e||13===e||32===e;)this._advance(!0);var e;if((e=>34===e||39===e)(this._next))return this._tokenizeString();if(ie(this._next))return this._tokenizeIdentOrKeyword();if(ne(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=re(te.STRING,this._getValue().replace(/\\(.)/g,((e,t)=>{switch(t){case"n":return"\n";case"r":return"\r";case"t":return"\t";case"b":return"\b";case"f":return"\f";default:return t}})));return this._advance(),r}_tokenizeIdentOrKeyword(){do{this._advance()}while(e=this._next,ie(e)||ne(e));var e;const t=this._getValue(),r=(i=t,-1!==Z.indexOf(i)?te.KEYWORD:te.IDENTIFIER);var i;return re(r,t)}_tokenizeNumber(){do{this._advance()}while(ne(this._next));return 46===this._next?this._tokenizeDot():re(te.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),ne(this._next)?this._tokenizeFraction():(this._clearValue(),re(te.DOT,".",13))}_tokenizeComma(){return this._advance(!0),re(te.COMMA,",")}_tokenizeColon(){return this._advance(!0),re(te.COLON,":")}_tokenizeFraction(){do{this._advance()}while(ne(this._next));return re(te.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(-1!==ee.indexOf(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),re(te.ARROW,e);-1!==J.indexOf(e)&&this._advance()}return e=this._getValue(),re(te.OPERATOR,e,X[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=re(te.GROUPER,e,X[e]);return this._advance(!0),t}}class oe{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new se(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(te.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(te.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(te.DOT)){this._advance();const t=this._parseUnary();e=this._makeInvokeOrGetter(e,t)}else{if(this._matches(te.KEYWORD))break;if(!(this._matches(te.OPERATOR)&&this._token.precedence>=t))break;e="?"===this._value?this._parseTernary(e):this._parseBinary(e,this._token)}return e}_makeInvokeOrGetter(e,t){if(void 0===t)throw new Error("expected identifier");if("ID"===t.type)return this._ast.getter(e,t.value);if("Invoke"===t.type&&"ID"===t.receiver.type){const r=t.receiver;return this._ast.invoke(e,r.value,t.arguments)}throw new Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(-1===Q.indexOf(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let r=this._parseUnary();for(;(this._kind===te.OPERATOR||this._kind===te.DOT||this._kind===te.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(te.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(te.INTEGER))return this._parseInteger(e);if(this._matches(te.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(te.OPERATOR,"?");const t=this._parseExpression();this._advance(te.COLON);const r=this._parseExpression();return this._ast.ternary(e,t,r)}_parsePrimary(){switch(this._kind){case te.KEYWORD:const e=this._value;if("this"===e)return this._advance(),this._ast.id(e);if(-1!==Z.indexOf(e))throw new Error(`unexpected keyword: ${e}`);throw new Error(`unrecognized keyword: ${e}`);case te.IDENTIFIER:return this._parseInvokeOrIdentifier();case te.STRING:return this._parseString();case te.INTEGER:return this._parseInteger();case te.DECIMAL:return this._parseDecimal();case te.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case te.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(te.GROUPER,"]"))break;e.push(this._parseExpression())}while(this._matches(te.COMMA));return this._advance(te.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e={};do{if(this._advance(),this._matches(te.GROUPER,"}"))break;const t=this._value;(this._matches(te.STRING)||this._matches(te.IDENTIFIER))&&this._advance(),this._advance(te.COLON),e[t]=this._parseExpression()}while(this._matches(te.COMMA));return this._advance(te.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(te.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(te.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(te.GROUPER,")"))break;const t=this._parseExpression();e.push(t)}while(this._matches(te.COMMA));return this._advance(te.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(te.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(te.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 ae={"+":(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)},le={"+":e=>e,"-":e=>-e,"!":e=>!e};class ce{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 he=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=le[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=ae[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 ue(e,t){if(e.has(t))return e.get(t);if(e.has("$parent")){return ue(e.get("$parent"),t)}return null}function pe(e,t){if(e.has(t))return e;if(e.has("$parent")){return pe(e.get("$parent"),t)}return null}class de extends ce{evalkeys=["$elem","$event"];expressionCache=new Map;store=new Map;observers=new Map;_observer=null;_lock=Promise.resolve();constructor(e){super();for(let[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof de||r.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>r in e&&(delete e[r],t(),!0),set:(r,i,n,s)=>{"object"==typeof n&&null!=e&&(n=this.wrapObject(n,t));const o=Reflect.set(r,i,n,s);return t(),o},get:(e,t,r)=>"__is_proxy__"===t||Reflect.get(e,t,r)});var r}watch(e,t){this.observers.has(e)||this.observers.set(e,new Set),this.observers.get(e)?.has(t)||this.observers.get(e)?.add(t)}async notify(e,t=10){const r=Array.from(this.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(r.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),ue(this.store,e)}async set(e,t){if(t===this.store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=pe(e,t);i?i.set(t,r):e.set(t,r)}(this.store,e,t),await r()}del(e){this.store.delete(e),this.observers.delete(e)}has(e){return this.store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this.store.entries()).map((([e])=>e)),r=Object.fromEntries(t.map((e=>[e,void 0])));return new Proxy(r,{get:(t,r,i)=>"string"==typeof r&&pe(this.store,r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes(" = ")){const[r,i]=e.split(" = ");t=r.trim(),e=i.trim()}return(r,i)=>{const n=((e,t)=>new oe(e,t).parse())(e,he),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}}}}class fe extends de{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(e){return this.debugging=e,this}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??"default"}).then((e=>e.text()))}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log("Preprocessing string content with params:\n",t);const r=this.parseHTML(e,t);return await this.preprocessNode(r,t),r}async preprocessRemote(e,t){const r={};t?.cache&&(r.cache=t.cache);const i=await fetch(e,r).then((e=>e.text()));return this.preprocessString(i,{...t,dirpath:H(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:H(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(t,r){r={dirpath:this.dirpath,maxdepth:10,...r};const i=new e(O(t,this._skipNodes)).map((async e=>{this.log("Preprocessing node:\n",B(e,128)),await V.resolveIncludes.call(this,e,r),await V.rebaseRelativePaths.call(this,e,r),await V.registerCustomElements.call(this,e,r),await V.resolveCustomElements.call(this,e,r)}));return await Promise.all(i.generator()),t}async renderNode(e,t){for(const r of O(e,this._skipNodes))this.log("Rendering node:\n",B(r,128)),await V.resolveForAttribute.call(this,r,t),await V.resolveDataAttribute.call(this,r,t),await V.resolveTextAttributes.call(this,r,t),await V.resolveHtmlAttribute.call(this,r,t),await V.resolveShowAttribute.call(this,r,t),await V.resolveClassAttribute.call(this,r,t),await V.resolveBindAttribute.call(this,r,t),await V.resolveEventAttributes.call(this,r,t),await V.resolveTextNodeExpressions.call(this,r,t),await V.resolveCustomAttribute.call(this,r,t),await V.resolveCustomProperty.call(this,r,t);return e}async mount(e,t){t={...t,rootNode:e},L(e,"renderer",this),this.store.set("$rootNode",e),await this.preprocessNode(e,t),await this.renderNode(e,t)}}function me(){return p([A`html{`,A`max-width: 70ch;`,A`padding: 2em 1em;`,A`margin: auto;`,A`line-height: 1.75;`,A`font-size: 1.25em;`,A`font-family: sans-serif;`,A`}`,A`h1,h2,h3,h4,h5,h6{`,A`margin: 1em 0 0.5em;`,A`}`,A`p,ul,ol{`,A`margin-bottom: 1em;`,A`color: #1d1d1d;`,A`}`].map(d).join(""))}const _e={sm:640,md:768,lg:1024,xl:1280},ge=.25,$e=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],ve=[...$e,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(_e)],xe=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],we=[75,100,150,200,300,500,700,1e3],be=["hover","focus","disabled","active"],Ee={margin:"m",padding:"p"},ye={width:"w",height:"h"},Ae={top:"top",right:"right",bottom:"bottom",left:"left"},Re={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},Oe={"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"},"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},"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"}},Ie=["@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 }"],Ne={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 ke(e){return`#${e.toString(16).padStart(6,"0")}`}function Te(e){return be.map((t=>`.${t}\\:${e}:${t}`))}function Pe(e,t){return Object.entries(_e).map((([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`))}function Se(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function Ce(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100vw`],[`${t}-full`,`${e}: 100%`],...ve.map((r=>[`${t}-${r}`,`${e}: ${r*ge}rem`])),...ve.map((r=>[`-${t}-${r}`,`${e}: -${r*ge}rem`])),...ve.map((r=>[`${t}-${r}px`,`${e}: ${r}px`])),...ve.map((r=>[`-${t}-${r}px`,`${e}: -${r}px`])),...xe.map((r=>[`${t}-${r}\\%`,`${e}: ${r}%`])),...xe.map((r=>[`-${t}-${r}\\%`,`${e}: -${r}%`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)]))}function Le(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;`],...ve.map((e=>[e,e*ge])).map((([r,i])=>[`${t}x-${r}`,`${e}-left: ${i}rem; ${e}-right: ${i}rem;`])),...ve.map((e=>[e,e*ge])).map((([r,i])=>[`${t}y-${r}`,`${e}-top: ${i}rem; ${e}-bottom: ${i}rem;`])),...ve.map((r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`])),...ve.map((r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`])),...xe.map((r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`])),...xe.map((r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)]))}function De(){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(Ne).flatMap((([e,t])=>[[`text-${e}`,`color: ${ke(t[500])}`],[`fill-${e}`,`fill: ${ke(t[500])}`],[`bg-${e}`,`background-color: ${ke(t[500])}`],[`border-${e}`,`border-color: ${ke(t[500])}`]])),r=Object.entries(Ne).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[[`text-${e}-${t}`,`color: ${ke(r)}`],[`fill-${e}-${t}`,`fill: ${ke(r)}`],[`bg-${e}-${t}`,`background-color: ${ke(r)}`],[`border-${e}-${t}`,`border-color: ${ke(r)}`]]))));return[].concat(e).concat(t).concat(r).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)]))}function Me(){return[...Ie,...Object.entries(Oe).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[`.${e} { ${t}: ${r} }`,`${Te(e).join(",")} { ${t}: ${r} }`,...Pe(e,`${t}: ${r}`)])))),...De(),...[["opacity-0","opacity: 0"],...xe.map((e=>[`opacity-${e}`,"opacity: "+e/100]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)])),...[...xe.map((e=>[`z-${e}`,`z-index: ${e}`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)])),...[...we.map((e=>[`duration-${e}`,`transition-duration: ${e}ms`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)])),...Ce(Ae),...Ce(ye),...Le(ye),...(e=Ee,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=>[...ve.map((e=>[e,e*ge])).map((([i,n])=>[`${r}${t}t-${i}`,`${e}-top: ${r}${n}rem`])),...ve.map((e=>[e,e*ge])).map((([i,n])=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${n}rem`])),...ve.map((e=>[e,e*ge])).map((([i,n])=>[`${r}${t}l-${i}`,`${e}-left: ${r}${n}rem`])),...ve.map((e=>[e,e*ge])).map((([i,n])=>[`${r}${t}r-${i}`,`${e}-right: ${r}${n}rem`])),...ve.map((i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`])),...ve.map((i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`])),...ve.map((i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`])),...ve.map((i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`])),...xe.map((i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`])),...xe.map((i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%;`])),...xe.map((i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`])),...xe.map((i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`]))]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)]))),...Ce(Ee),...Le(Ee),...[["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...ve.map((e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*ge}rem`])),...ve.map((e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*ge}rem`])),...ve.map((e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`])),...ve.map((e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`])),["gap-0","gap: 0"],...ve.map((e=>[`gap-${e}`,`gap: ${e*ge}rem`])),...ve.map((e=>[`gap-${e}px`,`gap: ${e}px`])),...ve.map((e=>[`gap-x-${e}`,`column-gap: ${e*ge}rem`])),...ve.map((e=>[`gap-y-${e}`,`row-gap: ${e*ge}rem`])),...ve.map((e=>[`gap-x-${e}px`,`column-gap: ${e}px`])),...ve.map((e=>[`gap-y-${e}px`,`row-gap: ${e}px`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)])),...Ce(Re),...[["border","border: 1px"],["border-x","border-inline-width: 1px"],["border-y","border-block-width: 1px"],...[0,...$e].map((e=>[`border-${e}`,`border-width: ${e}px`])),...[0,...$e].map((e=>[`border-x-${e}`,`border-inline-width: ${e}px;`])),...[0,...$e].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,...$e].map((t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`]))]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(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*ge)).map((e=>[`text-${e}rem`,`font-size: ${e}rem`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Te(e).join(",")} { ${t} }`,...Pe(e,t)]))].sort(Se).join("\n");var e}class Ue extends fe{impl="browser";dirpath=H(globalThis.location?.href??"http://localhost/");parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return(new DOMParser).parseFromString(e,"text/html");{const t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}const ze=new Ue;export{ze as Mancha,Ue as Renderer,me as basicCssRules,Me as utilsCssRules};
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 u(e){return new h(e,i)}function d(e){if(e instanceof h)return e.privateDoNotAccessOrElseWrappedStyleSheet;throw new Error("")}function p(e,t){e.textContent=d(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 _(e){return-1===e.toString().indexOf("`")}_((e=>e``))||_((e=>e`\0`))||_((e=>e`\n`))||_((e=>e`\u0000`)),m``&&m`\0`&&m`\n`&&m`\u0000`;function g(e){const t=e[0].toLowerCase();return new o(i,t)}var $,v;function x(e){return{valueOf:e}.valueOf()}!function(e){e[e.STYLE_TAG=0]="STYLE_TAG",e[e.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",e[e.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}($||($={}));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 w=["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}]])]],y=["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:x((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:v.KEEP_AND_NORMALIZE,conditions:x((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:v.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:v.KEEP_AND_NORMALIZE,conditions:x((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:v.KEEP_AND_SANITIZE_URL}],["target",{policyAction:v.KEEP_AND_NORMALIZE,conditions:x((()=>new Map([["target",new Set(["_self","_blank"])]])))}]];new b(new Set(w),new Map(E),new Set(y),new Map(A)),new b(new Set(x((()=>w.concat(["STYLE"])))),new Map(E),new Set(x((()=>y.concat(["id","name","class"])))),new Map(x((()=>A.concat([["style",{policyAction:v.KEEP_AND_SANITIZE_STYLE}]])))));function R(e){return u(e[0])}const O=[g`:`,g`style`,g`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 T(e,t){return"function"==typeof e?.[t]}function k(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?.[k(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=k(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(T(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){T(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function K(e,t){return T(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function W(e,t){return T(t,"removeChild")?e.removeChild(t):(G(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function Y(e,t,r){return r?T(e,"insertBefore")?e.insertBefore(t,r):(F(r,t,r),t):K(e,t)}function B(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function H(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map((e=>H(e,t))).join(""):B(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",H(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 ${H(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`,H(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`,H(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",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=P(r,"data",":");if(i){this.log(":data attribute found in:\n",H(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.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",H(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",H(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",H(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-")){const i=t.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!i)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",H(e,128)),M(r,t.name);const n="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,(r=>(n&&r.preventDefault(),this.eval(t.value,{$elem:e,$event:r}))))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"for",":")?.trim();if(i){this.log(":for attribute found in:\n",H(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);Y(s,o,e),W(s,e),K(o,e),this.log(":for template:\n",H(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.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",H(o,128))}const a=o.nextSibling;for(const e of l)Y(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",H(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";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",H(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",H(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",H(e,128)),M(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1),o=k(s);this.effect((function(){const i=this.eval(t.value,{$elem:e});D(r,o,i)}))}}}}(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=>95===e||36===e||65<=(e&=-33)&&e<=90,se=e=>48<=e&&e<=57;class oe{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;9===(e=this._next)||10===e||13===e||32===e;)this._advance(!0);var e;if((e=>34===e||39===e)(this._next))return this._tokenizeString();if(ne(this._next))return this._tokenizeIdentOrKeyword();if(se(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(e=this._next,ne(e)||se(e));var e;const t=this._getValue(),r=(i=t,-1!==q.indexOf(i)?re.KEYWORD:re.IDENTIFIER);var i;return ie(r,t)}_tokenizeNumber(){do{this._advance()}while(se(this._next));return 46===this._next?this._tokenizeDot():ie(re.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),se(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(se(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 ae{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new oe(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 le={"+":(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)},ce={"+":e=>e,"-":e=>-e,"!":e=>!e};class he{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 ue=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=ce[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=le[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 de(e,t){if(e.has(t))return e.get(t);if(e.has("$parent")){return de(e.get("$parent"),t)}return null}function pe(e,t){if(e.has(t))return e;if(e.has("$parent")){return pe(e.get("$parent"),t)}return null}class fe extends he{evalkeys=["$elem","$event"];expressionCache=new Map;store=new Map;observers=new Map;_observer=null;_lock=Promise.resolve();constructor(e){super();for(let[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof fe||r.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>r in e&&(delete e[r],t(),!0),set:(r,i,n,s)=>{"object"==typeof n&&null!=e&&(n=this.wrapObject(n,t));const o=Reflect.set(r,i,n,s);return t(),o},get:(e,t,r)=>"__is_proxy__"===t||Reflect.get(e,t,r)});var r}watch(e,t){this.observers.has(e)||this.observers.set(e,new Set),this.observers.get(e)?.has(t)||this.observers.get(e)?.add(t)}async notify(e,t=10){const r=Array.from(this.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(r.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),de(this.store,e)}async set(e,t){if(t===this.store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=pe(e,t);i?i.set(t,r):e.set(t,r)}(this.store,e,t),await r()}del(e){this.store.delete(e),this.observers.delete(e)}has(e){return this.store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this.store.entries()).map((([e])=>e)),r=Object.fromEntries(t.map((e=>[e,void 0])));return new Proxy(r,{get:(t,r,i)=>"string"==typeof r&&pe(this.store,r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes(" = ")){const[r,i]=e.split(" = ");t=r.trim(),e=i.trim()}return(r,i)=>{const n=((e,t)=>new ae(e,t).parse())(e,ue),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}}}}class me extends fe{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.set("$parent",this),e.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",H(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",H(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);return e}async mount(e,t){t={...t,rootNode:e},D(e,"renderer",this),this.set("$rootNode",e),await this.preprocessNode(e,t),await this.renderNode(e,t)}}function _e(){return u([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(d).join(""))}const ge={sm:640,md:768,lg:1024,xl:1280},$e=.25,ve=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],xe=[...ve,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(ge)],be=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],we=[75,100,150,200,300,500,700,1e3],Ee=["hover","focus","disabled","active"],ye={margin:"m",padding:"p"},Ae={width:"w",height:"h"},Re={top:"top",right:"right",bottom:"bottom",left:"left"},Oe={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},Ie={"font-mono":{"font-family":"monospace"},"font-sans":{"font-family":"sans-serif"},"font-serif":{"font-family":"serif"},"font-cursive":{"font-family":"cursive"},"text-xs":{"font-size":".75rem","line-height":"calc(1 / 0.75)"},"text-sm":{"font-size":".875rem","line-height":"calc(1.25 / 0.875)"},"text-base":{"font-size":"1rem","line-height":"calc(1.5 / 1)"},"text-lg":{"font-size":"1.125rem","line-height":"calc(1.75 / 1.125)"},"text-xl":{"font-size":"1.25rem","line-height":"calc(1.75 / 1.25)"},"text-2xl":{"font-size":"1.5rem","line-height":"calc(2 / 1.5)"},"text-3xl":{"font-size":"1.875rem","line-height":"calc(2.25 / 1.875)"},"text-4xl":{"font-size":"2.25rem","line-height":"calc(2.5 / 2.25)"},"text-5xl":{"font-size":"3rem","line-height":"1"},"text-6xl":{"font-size":"3.75rem","line-height":"1"},"text-7xl":{"font-size":"4.5rem","line-height":"1"},"font-thin":{"font-weight":100},"font-extralight":{"font-weight":200},"font-light":{"font-weight":300},"font-normal":{"font-weight":400},"font-medium":{"font-weight":500},"font-semibold":{"font-weight":600},"font-bold":{"font-weight":700},"font-extrabold":{"font-weight":800},"font-black":{"font-weight":900},italic:{"font-style":"italic"},"not-italic":{"font-style":"normal"},"w-max":{width:"max-content"},"w-min":{width:"min-content"},"w-fit":{width:"fit-content"},"h-max":{height:"max-content"},"h-min":{height:"min-content"},"h-fit":{height:"fit-content"},"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},"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"}},Ne=["@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 }"],Te={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 ke(e){return`#${e.toString(16).padStart(6,"0")}`}function Se(e){return Ee.map((t=>`.${t}\\:${e}:${t}`))}function Pe(e,t){return Object.entries(ge).map((([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`))}function Ce(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function Le(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100vw`],[`${t}-full`,`${e}: 100%`],...xe.map((r=>[`${t}-${r}`,`${e}: ${r*$e}rem`])),...xe.map((r=>[`-${t}-${r}`,`${e}: -${r*$e}rem`])),...xe.map((r=>[`${t}-${r}px`,`${e}: ${r}px`])),...xe.map((r=>[`-${t}-${r}px`,`${e}: -${r}px`])),...be.map((r=>[`${t}-${r}\\%`,`${e}: ${r}%`])),...be.map((r=>[`-${t}-${r}\\%`,`${e}: -${r}%`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)]))}function De(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;`],...xe.map((e=>[e,e*$e])).map((([r,i])=>[`${t}x-${r}`,`${e}-left: ${i}rem; ${e}-right: ${i}rem;`])),...xe.map((e=>[e,e*$e])).map((([r,i])=>[`${t}y-${r}`,`${e}-top: ${i}rem; ${e}-bottom: ${i}rem;`])),...xe.map((r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`])),...xe.map((r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`])),...be.map((r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`])),...be.map((r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)]))}function Me(){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(Te).flatMap((([e,t])=>[[`text-${e}`,`color: ${ke(t[500])}`],[`fill-${e}`,`fill: ${ke(t[500])}`],[`bg-${e}`,`background-color: ${ke(t[500])}`],[`border-${e}`,`border-color: ${ke(t[500])}`]])),r=Object.entries(Te).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[[`text-${e}-${t}`,`color: ${ke(r)}`],[`fill-${e}-${t}`,`fill: ${ke(r)}`],[`bg-${e}-${t}`,`background-color: ${ke(r)}`],[`border-${e}-${t}`,`border-color: ${ke(r)}`]]))));return[].concat(e).concat(t).concat(r).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)]))}class Ue extends me{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 Ue;const ze=new Ue;globalThis.Mancha=ze;const je=globalThis.document?.currentScript;if(globalThis.document?.currentScript?.hasAttribute("init")){const e=je?.hasAttribute("debug"),t=je?.getAttribute("cache"),r=je?.getAttribute("target")?.split("+")||["body"];window.addEventListener("load",(()=>{r.map((async r=>{const i=globalThis.document.querySelector(r);await ze.debug(e).mount(i,{cache:t})}))}))}if(globalThis.document?.currentScript?.hasAttribute("css")){const e=je?.getAttribute("css")?.split("+");for(const t of e){const e=document.createElement("style");switch(t){case"basic":p(e,_e());break;case"utils":e.textContent=(Fe=void 0,[...Ne,...Object.entries(Ie).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[`.${e} { ${t}: ${r} }`,`${Se(e).join(",")} { ${t}: ${r} }`,...Pe(e,`${t}: ${r}`)])))),...Me(),...[["opacity-0","opacity: 0"],...be.map((e=>[`opacity-${e}`,"opacity: "+e/100]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)])),...[...be.map((e=>[`z-${e}`,`z-index: ${e}`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)])),...[...we.map((e=>[`duration-${e}`,`transition-duration: ${e}ms`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)])),...Le(Re),...Le(Ae),...De(Ae),...(Fe=ye,Object.entries(Fe).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=>[...xe.map((e=>[e,e*$e])).map((([i,n])=>[`${r}${t}t-${i}`,`${e}-top: ${r}${n}rem`])),...xe.map((e=>[e,e*$e])).map((([i,n])=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${n}rem`])),...xe.map((e=>[e,e*$e])).map((([i,n])=>[`${r}${t}l-${i}`,`${e}-left: ${r}${n}rem`])),...xe.map((e=>[e,e*$e])).map((([i,n])=>[`${r}${t}r-${i}`,`${e}-right: ${r}${n}rem`])),...xe.map((i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`])),...xe.map((i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`])),...xe.map((i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`])),...xe.map((i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`])),...be.map((i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`])),...be.map((i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%;`])),...be.map((i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`])),...be.map((i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`]))]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)]))),...Le(ye),...De(ye),...[["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...xe.map((e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*$e}rem`])),...xe.map((e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*$e}rem`])),...xe.map((e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`])),...xe.map((e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`])),["gap-0","gap: 0"],...xe.map((e=>[`gap-${e}`,`gap: ${e*$e}rem`])),...xe.map((e=>[`gap-${e}px`,`gap: ${e}px`])),...xe.map((e=>[`gap-x-${e}`,`column-gap: ${e*$e}rem`])),...xe.map((e=>[`gap-y-${e}`,`row-gap: ${e*$e}rem`])),...xe.map((e=>[`gap-x-${e}px`,`column-gap: ${e}px`])),...xe.map((e=>[`gap-y-${e}px`,`row-gap: ${e}px`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)])),...Le(Oe),...[["border","border: 1px"],["border-x","border-inline-width: 1px"],["border-y","border-block-width: 1px"],...[0,...ve].map((e=>[`border-${e}`,`border-width: ${e}px`])),...[0,...ve].map((e=>[`border-x-${e}`,`border-inline-width: ${e}px;`])),...[0,...ve].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,...ve].map((t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`]))]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(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*$e)).map((e=>[`text-${e}rem`,`font-size: ${e}rem`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)]))].sort(Ce).join("\n"));break;default:console.error(`Unknown style name: "${t}"`)}globalThis.document.head.appendChild(e)}}var Fe})();
1
+ (()=>{"use strict";const e=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function t(t){if(!function(t){const r=!e.test(t);return r}(t))return t}function r(e){return t(e)}const i={};function n(e){0}"undefined"!=typeof window&&window.TrustedScriptURL;class s{constructor(e,t){this.privateDoNotAccessOrElseWrappedAttributePrefix=t}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const o=s;function a(e){if(function(e){return e instanceof s}(e))return e.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}"undefined"!=typeof window&&window.TrustedHTML;function l(e,t,r,i){if(0===e.length){throw new Error("")}const n=e.map((e=>a(e))),s=r.toLowerCase();if(n.every((e=>0!==s.indexOf(e))))throw new Error(`Attribute "${r}" does not match any of the allowed prefixes.`);t.setAttribute(r,i)}"undefined"!=typeof window&&window.TrustedScript;class c{}class h extends c{constructor(e,t){super(),n(),this.privateDoNotAccessOrElseWrappedStyleSheet=e}toString(){return this.privateDoNotAccessOrElseWrappedStyleSheet}}function u(e){return new h(e,i)}function d(e){if(e instanceof h)return e.privateDoNotAccessOrElseWrappedStyleSheet;throw new Error("")}function p(e,t){e.textContent=d(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 _(e){return-1===e.toString().indexOf("`")}_((e=>e``))||_((e=>e`\0`))||_((e=>e`\n`))||_((e=>e`\u0000`)),m``&&m`\0`&&m`\n`&&m`\u0000`;function g(e){const t=e[0].toLowerCase();return new o(i,t)}var $,v;function x(e){return{valueOf:e}.valueOf()}!function(e){e[e.STYLE_TAG=0]="STYLE_TAG",e[e.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",e[e.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}($||($={}));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 w=["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}]])]],y=["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:x((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:v.KEEP_AND_NORMALIZE,conditions:x((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:v.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:v.KEEP_AND_NORMALIZE,conditions:x((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:v.KEEP_AND_SANITIZE_URL}],["target",{policyAction:v.KEEP_AND_NORMALIZE,conditions:x((()=>new Map([["target",new Set(["_self","_blank"])]])))}]];new b(new Set(w),new Map(E),new Set(y),new Map(A)),new b(new Set(x((()=>w.concat(["STYLE"])))),new Map(E),new Set(x((()=>y.concat(["id","name","class"])))),new Map(x((()=>A.concat([["style",{policyAction:v.KEEP_AND_SANITIZE_STYLE}]])))));function R(e){return u(e[0])}const O=[g`:`,g`style`,g`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 T(e,t){return"function"==typeof e?.[t]}function k(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?.[k(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=k(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(T(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){T(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function K(e,t){return T(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function W(e,t){return T(t,"removeChild")?e.removeChild(t):(G(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function Y(e,t,r){return r?T(e,"insertBefore")?e.insertBefore(t,r):(F(r,t,r),t):K(e,t)}function B(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function H(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map((e=>H(e,t))).join(""):B(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",H(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 ${H(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`,H(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`,H(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",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=P(r,"data",":");if(i){this.log(":data attribute found in:\n",H(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.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",H(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",H(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",H(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-")){const i=t.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!i)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",H(e,128)),M(r,t.name);const n="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,(r=>(n&&r.preventDefault(),this.eval(t.value,{$elem:e,$event:r}))))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"for",":")?.trim();if(i){this.log(":for attribute found in:\n",H(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);Y(s,o,e),W(s,e),K(o,e),this.log(":for template:\n",H(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.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",H(o,128))}const a=o.nextSibling;for(const e of l)Y(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",H(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";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",H(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",H(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",H(e,128)),M(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1),o=k(s);this.effect((function(){const i=this.eval(t.value,{$elem:e});D(r,o,i)}))}}}}(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=>95===e||36===e||65<=(e&=-33)&&e<=90,se=e=>48<=e&&e<=57;class oe{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;9===(e=this._next)||10===e||13===e||32===e;)this._advance(!0);var e;if((e=>34===e||39===e)(this._next))return this._tokenizeString();if(ne(this._next))return this._tokenizeIdentOrKeyword();if(se(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(e=this._next,ne(e)||se(e));var e;const t=this._getValue(),r=(i=t,-1!==q.indexOf(i)?re.KEYWORD:re.IDENTIFIER);var i;return ie(r,t)}_tokenizeNumber(){do{this._advance()}while(se(this._next));return 46===this._next?this._tokenizeDot():ie(re.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),se(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(se(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 ae{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new oe(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 le={"+":(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)},ce={"+":e=>e,"-":e=>-e,"!":e=>!e};class he{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 ue=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=ce[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=le[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 de(e,t){if(e.has(t))return e.get(t);if(e.has("$parent")){return de(e.get("$parent"),t)}return null}function pe(e,t){if(e.has(t))return e;if(e.has("$parent")){return pe(e.get("$parent"),t)}return null}class fe extends he{evalkeys=["$elem","$event"];expressionCache=new Map;store=new Map;observers=new Map;_observer=null;_lock=Promise.resolve();constructor(e){super();for(let[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof fe||r.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>r in e&&(delete e[r],t(),!0),set:(r,i,n,s)=>{"object"==typeof n&&null!=e&&(n=this.wrapObject(n,t));const o=Reflect.set(r,i,n,s);return t(),o},get:(e,t,r)=>"__is_proxy__"===t||Reflect.get(e,t,r)});var r}watch(e,t){this.observers.has(e)||this.observers.set(e,new Set),this.observers.get(e)?.has(t)||this.observers.get(e)?.add(t)}async notify(e,t=10){const r=Array.from(this.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(r.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),de(this.store,e)}async set(e,t){if(t===this.store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=pe(e,t);i?i.set(t,r):e.set(t,r)}(this.store,e,t),await r()}del(e){this.store.delete(e),this.observers.delete(e)}has(e){return this.store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this.store.entries()).map((([e])=>e)),r=Object.fromEntries(t.map((e=>[e,void 0])));return new Proxy(r,{get:(t,r,i)=>"string"==typeof r&&pe(this.store,r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes(" = ")){const[r,i]=e.split(" = ");t=r.trim(),e=i.trim()}return(r,i)=>{const n=((e,t)=>new ae(e,t).parse())(e,ue),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}}}}class me extends fe{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",H(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",H(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);return e}async mount(e,t){t={...t,rootNode:e},D(e,"renderer",this),this.store.set("$rootNode",e),await this.preprocessNode(e,t),await this.renderNode(e,t)}}function _e(){return u([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(d).join(""))}const ge={sm:640,md:768,lg:1024,xl:1280},$e=.25,ve=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],xe=[...ve,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(ge)],be=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],we=[75,100,150,200,300,500,700,1e3],Ee=["hover","focus","disabled","active"],ye={margin:"m",padding:"p"},Ae={width:"w",height:"h"},Re={top:"top",right:"right",bottom:"bottom",left:"left"},Oe={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},Ie={"font-mono":{"font-family":"monospace"},"font-sans":{"font-family":"sans-serif"},"font-serif":{"font-family":"serif"},"font-cursive":{"font-family":"cursive"},"text-xs":{"font-size":".75rem","line-height":"calc(1 / 0.75)"},"text-sm":{"font-size":".875rem","line-height":"calc(1.25 / 0.875)"},"text-base":{"font-size":"1rem","line-height":"calc(1.5 / 1)"},"text-lg":{"font-size":"1.125rem","line-height":"calc(1.75 / 1.125)"},"text-xl":{"font-size":"1.25rem","line-height":"calc(1.75 / 1.25)"},"text-2xl":{"font-size":"1.5rem","line-height":"calc(2 / 1.5)"},"text-3xl":{"font-size":"1.875rem","line-height":"calc(2.25 / 1.875)"},"text-4xl":{"font-size":"2.25rem","line-height":"calc(2.5 / 2.25)"},"text-5xl":{"font-size":"3rem","line-height":"1"},"text-6xl":{"font-size":"3.75rem","line-height":"1"},"text-7xl":{"font-size":"4.5rem","line-height":"1"},"font-thin":{"font-weight":100},"font-extralight":{"font-weight":200},"font-light":{"font-weight":300},"font-normal":{"font-weight":400},"font-medium":{"font-weight":500},"font-semibold":{"font-weight":600},"font-bold":{"font-weight":700},"font-extrabold":{"font-weight":800},"font-black":{"font-weight":900},italic:{"font-style":"italic"},"not-italic":{"font-style":"normal"},"w-max":{width:"max-content"},"w-min":{width:"min-content"},"w-fit":{width:"fit-content"},"h-max":{height:"max-content"},"h-min":{height:"min-content"},"h-fit":{height:"fit-content"},"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},"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"}},Ne=["@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 }"],Te={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 ke(e){return`#${e.toString(16).padStart(6,"0")}`}function Se(e){return Ee.map((t=>`.${t}\\:${e}:${t}`))}function Pe(e,t){return Object.entries(ge).map((([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`))}function Ce(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function Le(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100vw`],[`${t}-full`,`${e}: 100%`],...xe.map((r=>[`${t}-${r}`,`${e}: ${r*$e}rem`])),...xe.map((r=>[`-${t}-${r}`,`${e}: -${r*$e}rem`])),...xe.map((r=>[`${t}-${r}px`,`${e}: ${r}px`])),...xe.map((r=>[`-${t}-${r}px`,`${e}: -${r}px`])),...be.map((r=>[`${t}-${r}\\%`,`${e}: ${r}%`])),...be.map((r=>[`-${t}-${r}\\%`,`${e}: -${r}%`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)]))}function De(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;`],...xe.map((e=>[e,e*$e])).map((([r,i])=>[`${t}x-${r}`,`${e}-left: ${i}rem; ${e}-right: ${i}rem;`])),...xe.map((e=>[e,e*$e])).map((([r,i])=>[`${t}y-${r}`,`${e}-top: ${i}rem; ${e}-bottom: ${i}rem;`])),...xe.map((r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`])),...xe.map((r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`])),...be.map((r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`])),...be.map((r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)]))}function Me(){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(Te).flatMap((([e,t])=>[[`text-${e}`,`color: ${ke(t[500])}`],[`fill-${e}`,`fill: ${ke(t[500])}`],[`bg-${e}`,`background-color: ${ke(t[500])}`],[`border-${e}`,`border-color: ${ke(t[500])}`]])),r=Object.entries(Te).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[[`text-${e}-${t}`,`color: ${ke(r)}`],[`fill-${e}-${t}`,`fill: ${ke(r)}`],[`bg-${e}-${t}`,`background-color: ${ke(r)}`],[`border-${e}-${t}`,`border-color: ${ke(r)}`]]))));return[].concat(e).concat(t).concat(r).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)]))}class Ue extends me{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 Ue;const ze=new Ue;globalThis.Mancha=ze;const je=globalThis.document?.currentScript;if(globalThis.document?.currentScript?.hasAttribute("init")){const e=je?.hasAttribute("debug"),t=je?.getAttribute("cache"),r=je?.getAttribute("target")?.split("+")||["body"];window.addEventListener("load",(()=>{r.map((async r=>{const i=globalThis.document.querySelector(r);await ze.debug(e).mount(i,{cache:t})}))}))}if(globalThis.document?.currentScript?.hasAttribute("css")){const e=je?.getAttribute("css")?.split("+");for(const t of e){const e=document.createElement("style");switch(t){case"basic":p(e,_e());break;case"utils":e.textContent=(Fe=void 0,[...Ne,...Object.entries(Ie).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[`.${e} { ${t}: ${r} }`,`${Se(e).join(",")} { ${t}: ${r} }`,...Pe(e,`${t}: ${r}`)])))),...Me(),...[["opacity-0","opacity: 0"],...be.map((e=>[`opacity-${e}`,"opacity: "+e/100]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)])),...[...be.map((e=>[`z-${e}`,`z-index: ${e}`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)])),...[...we.map((e=>[`duration-${e}`,`transition-duration: ${e}ms`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)])),...Le(Re),...Le(Ae),...De(Ae),...(Fe=ye,Object.entries(Fe).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=>[...xe.map((e=>[e,e*$e])).map((([i,n])=>[`${r}${t}t-${i}`,`${e}-top: ${r}${n}rem`])),...xe.map((e=>[e,e*$e])).map((([i,n])=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${n}rem`])),...xe.map((e=>[e,e*$e])).map((([i,n])=>[`${r}${t}l-${i}`,`${e}-left: ${r}${n}rem`])),...xe.map((e=>[e,e*$e])).map((([i,n])=>[`${r}${t}r-${i}`,`${e}-right: ${r}${n}rem`])),...xe.map((i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`])),...xe.map((i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`])),...xe.map((i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`])),...xe.map((i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`])),...be.map((i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`])),...be.map((i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%;`])),...be.map((i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`])),...be.map((i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`]))]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)]))),...Le(ye),...De(ye),...[["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...xe.map((e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*$e}rem`])),...xe.map((e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*$e}rem`])),...xe.map((e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`])),...xe.map((e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`])),["gap-0","gap: 0"],...xe.map((e=>[`gap-${e}`,`gap: ${e*$e}rem`])),...xe.map((e=>[`gap-${e}px`,`gap: ${e}px`])),...xe.map((e=>[`gap-x-${e}`,`column-gap: ${e*$e}rem`])),...xe.map((e=>[`gap-y-${e}`,`row-gap: ${e*$e}rem`])),...xe.map((e=>[`gap-x-${e}px`,`column-gap: ${e}px`])),...xe.map((e=>[`gap-y-${e}px`,`row-gap: ${e}px`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)])),...Le(Oe),...[["border","border: 1px"],["border-x","border-inline-width: 1px"],["border-y","border-block-width: 1px"],...[0,...ve].map((e=>[`border-${e}`,`border-width: ${e}px`])),...[0,...ve].map((e=>[`border-x-${e}`,`border-inline-width: ${e}px;`])),...[0,...ve].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,...ve].map((t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`]))]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(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*$e)).map((e=>[`text-${e}rem`,`font-size: ${e}rem`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Se(e).join(",")} { ${t} }`,...Pe(e,t)]))].sort(Ce).join("\n"));break;default:console.error(`Unknown style name: "${t}"`)}globalThis.document.head.appendChild(e)}}var Fe})();
package/dist/renderer.js CHANGED
@@ -90,10 +90,11 @@ export class IRenderer extends SignalStore {
90
90
  */
91
91
  subrenderer() {
92
92
  const instance = new this.constructor().debug(this.debugging);
93
+ // NOTE: Using the store object directly to avoid modifying ancestor values.
93
94
  // Attach ourselves as the parent of the new instance.
94
- instance.set("$parent", this);
95
+ instance.store.set("$parent", this);
95
96
  // Add a reference to the root renderer, or assume that we are the root renderer.
96
- instance.set("$rootRenderer", this.get("$rootRenderer") ?? this);
97
+ instance.store.set("$rootRenderer", this.get("$rootRenderer") ?? this);
97
98
  // Custom elements are shared across all instances.
98
99
  instance._customElements = this._customElements;
99
100
  return instance;
@@ -182,8 +183,9 @@ export class IRenderer extends SignalStore {
182
183
  params = { ...params, rootNode: root };
183
184
  // Attach ourselves to the HTML node.
184
185
  setProperty(root, "renderer", this);
185
- // Attach the HTML node to the root renderer.
186
- this.set("$rootNode", root);
186
+ // Attach the HTML node to the renderer instance.
187
+ // NOTE: Using the store object directly to avoid modifying ancestor values.
188
+ this.store.set("$rootNode", root);
187
189
  // Preprocess all the elements recursively first.
188
190
  await this.preprocessNode(root, params);
189
191
  // Now that the DOM is complete, render all the nodes.
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIzC;;;GAGG;AACH,MAAM,OAAgB,SAAU,SAAQ,WAAW;IAEvC,SAAS,GAAY,KAAK,CAAC;IAClB,OAAO,GAAW,EAAE,CAAC;IAC/B,UAAU,GAAc,IAAI,GAAG,EAAE,CAAC;IAClC,eAAe,GAAsB,IAAI,GAAG,EAAE,CAAC;IAMxD;;;;;OAKG;IACH,KAAK,CAAC,IAAa;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CAAC,KAAa,EAAE,MAAqB;QACpD,OAAO,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACvF,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CAAC,KAAa,EAAE,MAAqB;QACnD,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,gBAAgB,CACpB,OAAe,EACf,MAAoC;QAEpC,IAAI,CAAC,GAAG,CAAC,6CAA6C,EAAE,MAAM,CAAC,CAAC;QAChE,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACjD,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,gBAAgB,CACpB,KAAa,EACb,MAAoC;QAEpC,MAAM,YAAY,GAAgB,EAAE,CAAC;QACrC,IAAI,MAAM,EAAE,KAAK;YAAE,YAAY,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QACrD,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE;YACpC,GAAG,MAAM;YACT,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;YACvB,YAAY,EAAE,MAAM,EAAE,YAAY,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;SACnE,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CACnB,KAAa,EACb,MAAoC;QAEpC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE;YACpC,GAAG,MAAM;YACT,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;YACvB,YAAY,EAAE,MAAM,EAAE,YAAY,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;SACnE,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,MAAM,QAAQ,GAAG,IAAK,IAAI,CAAC,WAAmB,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAc,CAAC;QAEpF,sDAAsD;QACtD,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAE9B,iFAAiF;QACjF,QAAQ,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,CAAC;QAEjE,mDAAmD;QAClD,QAAgB,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAEzD,OAAO,QAAqB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,GAAG,IAAW;QAChB,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,cAAc,CAClB,IAAO,EACP,MAAqB;QAErB,MAAM,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC;QAE5D,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAChF,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YAC3D,wCAAwC;YACxC,MAAM,eAAe,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YAC/D,8CAA8C;YAC9C,MAAM,eAAe,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACnE,gDAAgD;YAChD,MAAM,eAAe,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACtE,+CAA+C;YAC/C,MAAM,eAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;QAEH,qDAAqD;QACrD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;QAExC,iEAAiE;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU,CACd,IAAO,EACP,MAAqB;QAErB,6DAA6D;QAC7D,uEAAuE;QACvE,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YACvD,0CAA0C;YAC1C,MAAM,eAAe,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACnE,2CAA2C;YAC3C,MAAM,eAAe,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACpE,2CAA2C;YAC3C,MAAM,eAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACrE,2CAA2C;YAC3C,MAAM,eAAe,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACpE,2CAA2C;YAC3C,MAAM,eAAe,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACpE,4CAA4C;YAC5C,MAAM,eAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACrE,2CAA2C;YAC3C,MAAM,eAAe,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACpE,gDAAgD;YAChD,MAAM,eAAe,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACtE,+CAA+C;YAC/C,MAAM,eAAe,CAAC,0BAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YAC1E,kDAAkD;YAClD,MAAM,eAAe,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACtE,kDAAkD;YAClD,MAAM,eAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACvE,CAAC;QAED,6DAA6D;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CAAC,IAAwC,EAAE,MAAqB;QACzE,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAEvC,qCAAqC;QACrC,WAAW,CAAC,IAAe,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QAE/C,6CAA6C;QAC7C,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAE5B,iDAAiD;QACjD,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAExC,sDAAsD;QACtD,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;CACF"}
1
+ {"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIzC;;;GAGG;AACH,MAAM,OAAgB,SAAU,SAAQ,WAAW;IAEvC,SAAS,GAAY,KAAK,CAAC;IAClB,OAAO,GAAW,EAAE,CAAC;IAC/B,UAAU,GAAc,IAAI,GAAG,EAAE,CAAC;IAClC,eAAe,GAAsB,IAAI,GAAG,EAAE,CAAC;IAMxD;;;;;OAKG;IACH,KAAK,CAAC,IAAa;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CAAC,KAAa,EAAE,MAAqB;QACpD,OAAO,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACvF,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CAAC,KAAa,EAAE,MAAqB;QACnD,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,gBAAgB,CACpB,OAAe,EACf,MAAoC;QAEpC,IAAI,CAAC,GAAG,CAAC,6CAA6C,EAAE,MAAM,CAAC,CAAC;QAChE,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACjD,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,gBAAgB,CACpB,KAAa,EACb,MAAoC;QAEpC,MAAM,YAAY,GAAgB,EAAE,CAAC;QACrC,IAAI,MAAM,EAAE,KAAK;YAAE,YAAY,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QACrD,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE;YACpC,GAAG,MAAM;YACT,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;YACvB,YAAY,EAAE,MAAM,EAAE,YAAY,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;SACnE,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CACnB,KAAa,EACb,MAAoC;QAEpC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE;YACpC,GAAG,MAAM;YACT,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;YACvB,YAAY,EAAE,MAAM,EAAE,YAAY,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;SACnE,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,MAAM,QAAQ,GAAG,IAAK,IAAI,CAAC,WAAmB,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAc,CAAC;QAEpF,4EAA4E;QAE5E,sDAAsD;QACtD,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAEpC,iFAAiF;QACjF,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,CAAC;QAEvE,mDAAmD;QAClD,QAAgB,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAEzD,OAAO,QAAqB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,GAAG,IAAW;QAChB,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,cAAc,CAClB,IAAO,EACP,MAAqB;QAErB,MAAM,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC;QAE5D,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAChF,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YAC3D,wCAAwC;YACxC,MAAM,eAAe,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YAC/D,8CAA8C;YAC9C,MAAM,eAAe,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACnE,gDAAgD;YAChD,MAAM,eAAe,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACtE,+CAA+C;YAC/C,MAAM,eAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;QAEH,qDAAqD;QACrD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;QAExC,iEAAiE;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU,CACd,IAAO,EACP,MAAqB;QAErB,6DAA6D;QAC7D,uEAAuE;QACvE,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YACvD,0CAA0C;YAC1C,MAAM,eAAe,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACnE,2CAA2C;YAC3C,MAAM,eAAe,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACpE,2CAA2C;YAC3C,MAAM,eAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACrE,2CAA2C;YAC3C,MAAM,eAAe,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACpE,2CAA2C;YAC3C,MAAM,eAAe,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACpE,4CAA4C;YAC5C,MAAM,eAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACrE,2CAA2C;YAC3C,MAAM,eAAe,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACpE,gDAAgD;YAChD,MAAM,eAAe,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACtE,+CAA+C;YAC/C,MAAM,eAAe,CAAC,0BAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YAC1E,kDAAkD;YAClD,MAAM,eAAe,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YACtE,kDAAkD;YAClD,MAAM,eAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACvE,CAAC;QAED,6DAA6D;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CAAC,IAAwC,EAAE,MAAqB;QACzE,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAEvC,qCAAqC;QACrC,WAAW,CAAC,IAAe,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QAE/C,iDAAiD;QACjD,4EAA4E;QAC5E,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAElC,iDAAiD;QACjD,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAExC,sDAAsD;QACtD,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;CACF"}
@@ -1 +1 @@
1
- const e={};function t(e){0}class i{constructor(e,t){this.privateDoNotAccessOrElseWrappedAttributePrefix=t}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const r=i;function s(e){if(function(e){return e instanceof i}(e))return e.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}function n(e){return Object.isFrozen(e)&&Object.isFrozen(e.raw)}function a(e){return-1===e.toString().indexOf("`")}a((e=>e``))||a((e=>e`\0`))||a((e=>e`\n`))||a((e=>e`\u0000`)),n``&&n`\0`&&n`\n`&&n`\u0000`;function o(t){const i=t[0].toLowerCase();return new r(e,i)}let l,c="google#safe";function h(){var e;return""!==c&&null!==(e=function(){if("undefined"!=typeof window)return window.trustedTypes}())&&void 0!==e?e:null}class u{constructor(e,i){t(),this.privateDoNotAccessOrElseWrappedHtml=e}toString(){return this.privateDoNotAccessOrElseWrappedHtml.toString()}}function d(t,i){return null!=i?i:new u(t,e)}"undefined"!=typeof window&&window.TrustedHTML;function p(e){var t;const i=e;return d(i,null===(t=function(){var e,t;if(void 0===l)try{l=null!==(t=null===(e=h())||void 0===e?void 0:e.createPolicy(c,{createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e}))&&void 0!==t?t:null}catch(e){l=null}return l}())||void 0===t?void 0:t.createHTML(i))}function f(e){var t;if(null===(t=h())||void 0===t?void 0:t.isHTML(e))return e;if(e instanceof u)return e.privateDoNotAccessOrElseWrappedHtml;throw new Error("")}"undefined"!=typeof window&&window.TrustedScriptURL;"undefined"!=typeof window&&window.TrustedScript;function _(e,t){t.appendChild(e);let i=(new XMLSerializer).serializeToString(t);return i=i.slice(i.indexOf(">")+1,i.lastIndexOf("</")),p(i)}const m=["data:","http:","https:","mailto:","ftp:"],E=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function v(e){if(!function(e){const t=!E.test(e);return t}(e))return e}function w(e){return v(e)}function b(e){const t=function(e){let t;try{t=new URL(e)}catch(e){return"https:"}return t.protocol}(e);return void 0!==t&&-1!==m.indexOf(t.toLowerCase())?e:"about:invalid#zClosurez"}function g(e,t){const i=t.createRange();i.selectNode(t.body);return function(e,t){return e.createContextualFragment(f(t))}(i,p(e))}function A(e){const t=e.nodeName;return"string"==typeof t?t:"FORM"}function y(e){return 3===e.nodeType}function T(e){const t=e.nodeType;return 1===t||"number"!=typeof t}var R,O;function N(e){try{return new URL(e,window.document.baseURI)}catch(e){return new URL("about:invalid")}}function I(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"}(R||(R={}));class P{constructor(e,t,i,r,s){this.allowedElements=e,this.elementPolicies=t,this.allowedGlobalAttributes=i,this.globalAttributePolicies=r,this.globallyAllowedAttributePrefixes=s}isAllowedElement(e){return"FORM"!==e&&(this.allowedElements.has(e)||this.elementPolicies.has(e))}getAttributePolicy(e,t){const i=this.elementPolicies.get(t);if(null==i?void 0:i.has(e))return i.get(e);if(this.allowedGlobalAttributes.has(e))return{policyAction:O.KEEP};const r=this.globalAttributePolicies.get(e);return r||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((t=>0===e.indexOf(t)))?{policyAction:O.KEEP}:{policyAction:O.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"}(O||(O={}));const x=new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const S=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],C=[["A",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],L=["title","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-current","aria-disabled","aria-dropeffect","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-live","aria-multiline","aria-multiselectable","aria-orientation","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","alt","align","autocapitalize","autocomplete","autocorrect","autofocus","autoplay","bgcolor","border","cellpadding","cellspacing","checked","color","cols","colspan","controls","datetime","disabled","download","draggable","enctype","face","formenctype","frameborder","height","hreflang","hidden","ismap","label","lang","loop","max","maxlength","media","minlength","min","multiple","muted","nonce","open","placeholder","preload","rel","required","reversed","role","rows","rowspan","selected","shape","size","sizes","slot","span","spellcheck","start","step","summary","translate","type","valign","value","width","wrap","itemscope","itemtype","itemid","itemprop","itemref"],k=[["dir",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:O.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:O.KEEP_AND_SANITIZE_URL}],["target",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["target",new Set(["_self","_blank"])]])))}]],D=new P(new Set(S),new Map(C),new Set(L),new Map(k));new P(new Set(I((()=>S.concat(["STYLE"])))),new Map(C),new Set(I((()=>L.concat(["id","name","class"])))),new Map(I((()=>k.concat([["style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}]])))));class U{constructor(e,i,r,s,n){this.sanitizerTable=e,this.styleElementSanitizer=r,this.styleAttributeSanitizer=s,this.resourceUrlPolicy=n,this.changes=[],t()}sanitizeAssertUnchanged(e){return this.sanitize(e)}sanitize(e){const t=document.implementation.createHTMLDocument("");return _(this.sanitizeToFragmentInternal(e,t),t.body)}sanitizeToFragment(e){const t=document.implementation.createHTMLDocument("");return this.sanitizeToFragmentInternal(e,t)}sanitizeToFragmentInternal(e,t){const i=g(e,t),r=document.createTreeWalker(i,5,(e=>this.nodeFilter(e)));let s=r.nextNode();const n=t.createDocumentFragment();let a=n;for(;null!==s;){let e;if(y(s))if(this.styleElementSanitizer&&"STYLE"===a.nodeName){const t=this.styleElementSanitizer(s.data);e=this.createTextNode(t)}else e=this.sanitizeTextNode(s);else{if(!T(s)){throw new Error("")}e=this.sanitizeElementNode(s,t)}if(a.appendChild(e),s=r.firstChild(),s)a=e;else for(;!(s=r.nextSibling())&&(s=r.parentNode());)a=a.parentNode}return n}createTextNode(e){return document.createTextNode(e)}sanitizeTextNode(e){return this.createTextNode(e.data)}sanitizeElementNode(e,t){const i=A(e),r=t.createElement(i),s=e.attributes;for(const{name:e,value:t}of s){const n=this.sanitizerTable.getAttributePolicy(e,i);if(this.satisfiesAllConditions(n.conditions,s))switch(n.policyAction){case O.KEEP:z(r,e,t);break;case O.KEEP_AND_SANITIZE_URL:const s=b(t);s!==t&&this.recordChange(`Url in attribute ${e} was modified during sanitization. Original url:"${t}" was sanitized to: "${s}"`),z(r,e,s);break;case O.KEEP_AND_NORMALIZE:z(r,e,t.toLowerCase());break;case O.KEEP_AND_SANITIZE_STYLE:if(this.styleAttributeSanitizer){z(r,e,this.styleAttributeSanitizer(t))}else z(r,e,t);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY:if(this.resourceUrlPolicy){const s={type:R.HTML_ATTRIBUTE,attributeName:e,tagName:i},n=N(t),a=this.resourceUrlPolicy(n,s);a&&z(r,e,a.toString())}else z(r,e,t);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET:if(this.resourceUrlPolicy){const s={type:R.HTML_ATTRIBUTE,attributeName:e,tagName:i},n=$(t),a={parts:[]};for(const e of n.parts){const t=N(e.url),i=this.resourceUrlPolicy(t,s);i&&a.parts.push({url:i.toString(),descriptor:e.descriptor})}z(r,e,M(a))}else z(r,e,t);break;case O.DROP:this.recordChange(`Attribute: ${e} was dropped`)}else this.recordChange(`Not all conditions satisfied for attribute: ${e}.`)}return r}nodeFilter(e){if(y(e))return 1;if(!T(e))return 2;const t=A(e);return null===t?(this.recordChange(`Node name was null for node: ${e}`),2):this.sanitizerTable.isAllowedElement(t)?1:(this.recordChange(`Element: ${t} was dropped`),2)}recordChange(e){0}satisfiesAllConditions(e,t){var i;if(!e)return!0;for(const[r,s]of e){const e=null===(i=t.getNamedItem(r))||void 0===i?void 0:i.value;if(e&&!s.has(e))return!1}return!0}}function z(e,t,i){e.setAttribute(t,i)}function $(e){const t=[];for(const i of e.split(",")){const[e,r]=i.trim().split(/\s+/,2);t.push({url:e,descriptor:r})}return{parts:t}}function M(e){return e.parts.map((e=>{const{url:t,descriptor:i}=e;return`${t}${i?` ${i}`:""}`})).join(" , ")}class F{constructor(){this.calledBuild=!1,this.sanitizerTable=D}onlyAllowElements(e){const t=new Set,i=new Map;for(let r of e){if(r=r.toUpperCase(),!this.sanitizerTable.isAllowedElement(r))throw new Error(`Element: ${r}, is not allowed by html5_contract.textpb`);const e=this.sanitizerTable.elementPolicies.get(r);void 0!==e?i.set(r,e):t.add(r)}return this.sanitizerTable=new P(t,i,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}allowCustomElement(e,t){const i=new Set(this.sanitizerTable.allowedElements),r=new Map(this.sanitizerTable.elementPolicies);if(e=e.toUpperCase(),s=e,x.has(s.toUpperCase())||!/^[a-z][-_.a-z0-9]*-[-_.a-z0-9]*$/i.test(s))throw new Error(`Element: ${e} is not a custom element`);var s;if(t){const i=new Map;for(const e of t)i.set(e,{policyAction:O.KEEP});r.set(e,i)}else i.add(e);return this.sanitizerTable=new P(i,r,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}onlyAllowAttributes(e){const t=new Set,i=new Map,r=new Map;for(const r of e)this.sanitizerTable.allowedGlobalAttributes.has(r)&&t.add(r),this.sanitizerTable.globalAttributePolicies.has(r)&&i.set(r,this.sanitizerTable.globalAttributePolicies.get(r));for(const[t,i]of this.sanitizerTable.elementPolicies.entries()){const s=new Map;for(const[t,r]of i.entries())e.has(t)&&s.set(t,r);r.set(t,s)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,r,t,i),this}allowDataAttributes(e){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);for(const i of e){if(0!==i.indexOf("data-"))throw new Error(`data attribute: ${i} does not begin with the prefix "data-"`);t.add(i)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}allowStyleAttributes(){const e=new Map(this.sanitizerTable.globalAttributePolicies);return e.set("style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,this.sanitizerTable.allowedGlobalAttributes,e),this}allowClassAttributes(){const e=new Set(this.sanitizerTable.allowedGlobalAttributes);return e.add("class"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,e,this.sanitizerTable.globalAttributePolicies),this}allowIdAttributes(){const e=new Set(this.sanitizerTable.allowedGlobalAttributes);return e.add("id"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,e,this.sanitizerTable.globalAttributePolicies),this}allowIdReferenceAttributes(){const e=new Set(this.sanitizerTable.allowedGlobalAttributes);return e.add("aria-activedescendant").add("aria-controls").add("aria-labelledby").add("aria-owns").add("for").add("list"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,e,this.sanitizerTable.globalAttributePolicies),this}withResourceUrlPolicy(e){return this.resourceUrlPolicy=e,this}build(){if(this.calledBuild)throw new Error("this sanitizer has already called build");return this.calledBuild=!0,new U(this.sanitizerTable,e,void 0,void 0,this.resourceUrlPolicy)}}function G(e,t,i,r){if(0===e.length){throw new Error("")}const n=e.map((e=>s(e))),a=i.toLowerCase();if(n.every((e=>0!==a.indexOf(e))))throw new Error(`Attribute "${i}" does not match any of the allowed prefixes.`);t.setAttribute(i,r)}function K(e,t,i){return e.parseFromString(f(t),i)}Error;const W=[o`:`,o`style`,o`class`];function*Y(e,t=new Set){const i=new Set,r=Array.from(e.childNodes).filter((e=>!t.has(e)));for(yield e;r.length;){const e=r.shift();i.has(e)||(i.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter((e=>!t.has(e))).forEach((e=>r.push(e)))}}function H(e,t){return void 0!==e?.[t]}function B(e,t){return"function"==typeof e?.[t]}function V(e){return e.replace(/-./g,(e=>e[1].toUpperCase()))}function Z(e,t){return H(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function j(e,t,i=""){return Z(e,i+t)||(e.dataset?.[V(t)]??null)}function q(e,t,i){H(e,"attribs")?e.attribs[t]=i:e.setAttribute?.(t,i)}function X(e,t,i){H(e,"attribs")?e.attribs[t]=i:G(W,e,t,i)}function Q(e,t,i){switch(t){case"disabled":return void(e.disabled=i);case"selected":return void(e.selected=i);case"checked":return void(e.checked=i);default:e[t]=i}}function J(e,t){H(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function ee(e,t,i=""){J(e,`${i}${t}`),J(e,`data-${t}`)}function te(e,t,i){if(H(e,"attribs")&&H(t,"attribs"))t.attribs[i]=e.attribs[i];else if(i.startsWith("data-")){const r=V(i.slice(5));t.dataset[r]=e.dataset?.[r]}else{const r=e?.getAttribute?.(i);X(t,i,r||"")}}function ie(e){if(H(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find((e=>1===e.nodeType))}function re(e,...t){if(B(e,"replaceWith"))return e.replaceWith(...t);{const i=e,r=i.parentNode,s=Array.from(r.childNodes).indexOf(i);t.forEach((e=>e.parentNode=r)),r.childNodes=[].concat(Array.from(r.childNodes).slice(0,s)).concat(t).concat(Array.from(r.childNodes).slice(s+1))}}function se(e,...t){B(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function ne(e,t){return B(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function ae(e,t){return B(t,"removeChild")?e.removeChild(t):(se(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function oe(e,t,i){return i?B(e,"insertBefore")?e.insertBefore(t,i):(re(i,t,i),t):ne(e,t)}function le(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function ce(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map((e=>ce(e,t))).join(""):le(e.outerHTML||e.nodeValue||String(e),t)}function he(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}class ue{iterable;constructor(e){this.iterable=e}filter(e){return new ue(ue.filterGenerator(e,this.iterable))}map(e){return new ue(ue.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 i of t)e(i)&&(yield i)}static*mapGenerator(e,t){for(const i of t)yield e(i)}static equals(e,t){const i=e[Symbol.iterator](),r=t[Symbol.iterator]();let s=i.next(),n=r.next();for(;!s.done&&!n.done;){if(s.value!==n.value)return!1;s=i.next(),n=r.next()}return s.done===n.done}}var de;!function(e){e.resolveIncludes=async function(e,t){const i=e,r=i.tagName?.toLowerCase();if(!["include","link"].includes(r))return;if("link"===r&&"subresource"!==Z(i,"rel"))return;this.log("include directive found in:\n",ce(e,128)),this.log("include params:",t);const s="link"===i.tagName.toLocaleLowerCase()?"href":"src",n=Z(i,s);if(!n)throw new Error(`"${s}" attribute missing from ${ce(e,128)}.`);const a=[];"include"===r&&a.push("src"),"link"===r&&a.push("rel","href");const o=t=>{const r=ie(t);for(const e of Array.from(i.attributes))r&&!a.includes(e.name)&&te(i,r,e.name);re(e,...t.childNodes)},l={...t,rootDocument:!1,maxdepth:t?.maxdepth-1};if(0===l.maxdepth)throw new Error("Maximum recursion depth reached.");if(n.includes("://")||n.startsWith("//"))this.log("Including remote file from absolute path:",n),await this.preprocessRemote(n,l).then(o);else if(t?.dirpath?.includes("://")||t?.dirpath?.startsWith("//")){const e=n.startsWith("/")?n:`${t.dirpath}/${n}`;this.log("Including remote file from relative path:",e),await this.preprocessRemote(e,l).then(o)}else if("/"===n.charAt(0))this.log("Including local file from absolute path:",n),await this.preprocessLocal(n,l).then(o);else{const e=t?.dirpath&&"."!==t?.dirpath?`${t?.dirpath}/${n}`:n;this.log("Including local file from relative path:",e),await this.preprocessLocal(e,l).then(o)}},e.rebaseRelativePaths=async function(e,t){const i=e,r=i.tagName?.toLowerCase();if(!t?.dirpath)return;const s=Z(i,"src"),n=Z(i,"href"),a=s||n;if(!a||((o=a).includes("://")||o.startsWith("/")||o.startsWith("#")||o.startsWith("data:")))return;var o;const l=`${t.dirpath}/${a}`;this.log("Rebasing relative path as:",l),H(i,"attribs")?X(i,s?"src":"href",l):"img"===r?i.src=l:"a"===r?function(e,t){const i=w(t);void 0!==i&&(e.href=i)}(i,l):"source"===r||"audio"===r||"video"===r||"track"===r||"input"===r?i.src=l:"area"===r?function(e,t){const i=w(t);void 0!==i&&(e.href=i)}(i,l):this.log("Unable to rebase relative path for element:",r)},e.registerCustomElements=async function(e,t){const i=e,r=i.tagName?.toLowerCase(),s=(Z(i,"is")||Z(i,"alt"))?.toLowerCase();if(["template","div"].includes(r)&&s){if("div"===r&&"template"!==Z(i,"role"))return;this._customElements.has(s)||(this.log(`Registering custom element: ${s}\n`,ce(i,128)),this._customElements.set(s,i),ae(i.parentNode,i))}},e.resolveCustomElements=async function(e,t){const i=e,r=i.tagName?.toLowerCase();let s=r;if("div"===s&&(s=Z(i,"role")?.toLowerCase()||s),s&&this._customElements.has(s)){this.log(`Processing custom element: ${s}\n`,ce(i,128));const t=this._customElements.get(s),n=(t.content||t).cloneNode(!0),a=ie(n);if(a)for(const e of Array.from(i.attributes))"div"===r&&"role"===e.name||te(i,a,e.name);const o=new ue(Y(n)).find((e=>"slot"===e.tagName?.toLowerCase()));o&&re(o,...i.childNodes),re(e,...n.childNodes)}},e.resolveTextNodeExpressions=async function(e,t){const i=e.nodeValue||"";if(3!==e.nodeType||!i?.trim())return;this.log("Processing node content value:\n",le(i,128));const r=new RegExp(/{{ ([^}]+) }}/gm),s=Array.from(i.matchAll(r)).map((e=>e[1]));return this.effect((function(){let t=i;for(const i of s){const r=this.eval(i,{$elem:e});t=t.replace(`{{ ${i} }}`,String(r))}e.nodeValue=t}))},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"data",":");if(r){this.log(":data attribute found in:\n",ce(e,128)),ee(i,"data",":");const s=t?.rootNode===e?this:this.subrenderer();e.renderer=s;const n=s.eval(r,{$elem:e});if(await Promise.all(Object.entries(n).map((([e,t])=>s.set(e,t)))),s!==this)for(const t of Y(e,this._skipNodes))this._skipNodes.add(t);await s.mount(e,t)}},e.resolveClassAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"class",":");if(r){this.log(":class attribute found in:\n",ce(e,128)),ee(i,"class",":");const t=Z(i,"class")||"";return this.effect((function(){const s=this.eval(r,{$elem:e});X(i,"class",(s?`${t} ${s}`:t).trim())}))}},e.resolveTextAttributes=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"text",":");if(r){this.log(":text attribute found in:\n",ce(e,128)),ee(i,"text",":");const t=t=>this.textContent(e,t);return this.effect((function(){t(this.eval(r,{$elem:e}))}))}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"html",":");return r?(this.log(":html attribute found in:\n",ce(e,128)),ee(i,"html",":"),this.effect((function(){const s=this.eval(r,{$elem:e});return new Promise((async e=>{const r=await this.preprocessString(s,t);await this.renderNode(r),se(i,r),e()}))}))):void 0},e.resolveEventAttributes=async function(e,t){if(this._skipNodes.has(e))return;const i=e;for(const t of Array.from(i.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){const r=t.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!r)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",ce(e,128)),J(i,t.name);const s="submit"===r&&"FORM"===i.tagName.toUpperCase();e.addEventListener?.(r,(i=>(s&&i.preventDefault(),this.eval(t.value,{$elem:e,$event:i}))))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"for",":")?.trim();if(r){this.log(":for attribute found in:\n",ce(e,128)),ee(i,"for",":");for(const t of Y(e,this._skipNodes))this._skipNodes.add(t);const s=Z(i,"style")||"";q(i,"style","display: none;");const n=e.parentNode,a=this.createElement("template",e.ownerDocument);oe(n,a,e),ae(n,e),ne(a,e),this.log(":for template:\n",ce(a,128));const o=r.split(" in ",2);if(2!==o.length)throw new Error(`Invalid :for format: \`${r}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=o;await this.effect((function(){const i=this.eval(h,{$elem:e});if(this.log(":for list items:",i),l.splice(0,l.length).forEach((e=>{ae(n,e),this._skipNodes.delete(e)})),!Array.isArray(i))return console.error(`Expression did not yield a list: \`${h}\` => \`${i}\``),Promise.resolve();const r=[];for(const n of i){const i=this.subrenderer();i.set(c,n);const a=e.cloneNode(!0);q(a,"style",s),l.push(a),this._skipNodes.add(a),r.push(i.mount(a,t)),this.log("Rendered list child:\n",ce(a,128))}const o=a.nextSibling;for(const e of l)oe(n,e,o);return Promise.all(r)}))}},e.resolveBindAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"bind",":");if(r){this.log(":bind attribute found in:\n",ce(e,128));const t=["change","input"],s=Z(i,":bind:on")?.split(",")||i.dataset?.bindOn?.split(",")||t;ee(i,"bind",":"),J(i,":bind:on"),J(i,"data-bind-on");const n="checkbox"===Z(i,"type")?"checked":"value";this.effect((function(){const t=this.eval(r,{$elem:e});"checked"===n?i.checked=!!t:i.value=t}));const a=`${r} = $elem.${n}`;for(const t of s)e.addEventListener(t,(()=>this.eval(a,{$elem:e})))}},e.resolveShowAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"show",":");if(r){this.log(":show attribute found in:\n",ce(e,128)),ee(i,"show",":");const t="none"===i.style?.display?"":i.style?.display??Z(i,"style")?.split(";")?.find((e=>"display"===e.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const s=this.eval(r,{$elem:e});i.style?i.style.display=s?t:"none":X(i,"style",`display: ${s?t:"none"};`)}))}},e.resolveCustomAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e;for(const t of Array.from(i.attributes||[])){const r=":attr:",s="data-attr-";if(t.name.startsWith(r)||t.name.startsWith(s)){this.log(t.name,"attribute found in:\n",ce(e,128)),J(i,t.name);const n=t.name.split(r,2).at(-1)?.split(s,2).at(-1);this.effect((function(){const r=this.eval(t.value,{$elem:e});q(i,n,r)}))}}},e.resolveCustomProperty=async function(e,t){if(this._skipNodes.has(e))return;const i=e;for(const t of Array.from(i.attributes||[])){const r=":prop:",s="data-prop-";if(t.name.startsWith(r)||t.name.startsWith(s)){this.log(t.name,"property found in:\n",ce(e,128)),J(i,t.name);const n=t.name.split(r,2).at(-1)?.split(s,2).at(-1),a=V(n);this.effect((function(){const r=this.eval(t.value,{$elem:e});Q(i,a,r)}))}}}}(de||(de={}));const pe=["this"],fe=["+","-","!"],_e=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],me={"!":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=["==","!=","<=",">=","||","&&","??","|>"],ve=["===","!=="];var we;!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"}(we||(we={}));const be=(e,t,i=0)=>({kind:e,value:t,precedence:i}),ge=e=>95===e||36===e||65<=(e&=-33)&&e<=90,Ae=e=>48<=e&&e<=57;class ye{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;9===(e=this._next)||10===e||13===e||32===e;)this._advance(!0);var e;if((e=>34===e||39===e)(this._next))return this._tokenizeString();if(ge(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 i=be(we.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(),i}_tokenizeIdentOrKeyword(){do{this._advance()}while(e=this._next,ge(e)||Ae(e));var e;const t=this._getValue(),i=(r=t,-1!==pe.indexOf(r)?we.KEYWORD:we.IDENTIFIER);var r;return be(i,t)}_tokenizeNumber(){do{this._advance()}while(Ae(this._next));return 46===this._next?this._tokenizeDot():be(we.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),Ae(this._next)?this._tokenizeFraction():(this._clearValue(),be(we.DOT,".",13))}_tokenizeComma(){return this._advance(!0),be(we.COMMA,",")}_tokenizeColon(){return this._advance(!0),be(we.COLON,":")}_tokenizeFraction(){do{this._advance()}while(Ae(this._next));return be(we.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(-1!==ve.indexOf(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),be(we.ARROW,e);-1!==Ee.indexOf(e)&&this._advance()}return e=this._getValue(),be(we.OPERATOR,e,me[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=be(we.GROUPER,e,me[e]);return this._advance(!0),t}}class Te{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new ye(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 i=this._tokenizer.nextToken();this._token=i,this._kind=i?.kind,this._value=i?.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(we.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(we.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(we.DOT)){this._advance();const t=this._parseUnary();e=this._makeInvokeOrGetter(e,t)}else{if(this._matches(we.KEYWORD))break;if(!(this._matches(we.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 i=t.receiver;return this._ast.invoke(e,i.value,t.arguments)}throw new Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(-1===_e.indexOf(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let i=this._parseUnary();for(;(this._kind===we.OPERATOR||this._kind===we.DOT||this._kind===we.GROUPER)&&this._token.precedence>t.precedence;)i=this._parsePrecedence(i,this._token.precedence);return this._ast.binary(e,t.value,i)}_parseUnary(){if(this._matches(we.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(we.INTEGER))return this._parseInteger(e);if(this._matches(we.DECIMAL))return this._parseDecimal(e)}if(-1===fe.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(we.OPERATOR,"?");const t=this._parseExpression();this._advance(we.COLON);const i=this._parseExpression();return this._ast.ternary(e,t,i)}_parsePrimary(){switch(this._kind){case we.KEYWORD:const e=this._value;if("this"===e)return this._advance(),this._ast.id(e);if(-1!==pe.indexOf(e))throw new Error(`unexpected keyword: ${e}`);throw new Error(`unrecognized keyword: ${e}`);case we.IDENTIFIER:return this._parseInvokeOrIdentifier();case we.STRING:return this._parseString();case we.INTEGER:return this._parseInteger();case we.DECIMAL:return this._parseDecimal();case we.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case we.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(we.GROUPER,"]"))break;e.push(this._parseExpression())}while(this._matches(we.COMMA));return this._advance(we.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e={};do{if(this._advance(),this._matches(we.GROUPER,"}"))break;const t=this._value;(this._matches(we.STRING)||this._matches(we.IDENTIFIER))&&this._advance(),this._advance(we.COLON),e[t]=this._parseExpression()}while(this._matches(we.COMMA));return this._advance(we.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(),i=this._parseArguments();return i?this._ast.invoke(t,void 0,i):t}_parseIdentifier(){if(!this._matches(we.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(we.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(we.GROUPER,")"))break;const t=this._parseExpression();e.push(t)}while(this._matches(we.COMMA));return this._advance(we.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(we.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(we.ARROW)){this._advance();const t=this._parseExpression(),i=e?.map((e=>e.value))??[];return this._ast.arrowFunction(i,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 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),"|>":(e,t)=>t(e)},Oe={"+":e=>e,"-":e=>-e,"!":e=>!e};class Ne{timeouts=new Map;debounce(e,t){return new Promise(((i,r)=>{const s=this.timeouts.get(t);s&&clearTimeout(s),this.timeouts.set(t,setTimeout((()=>{try{i(t()),this.timeouts.delete(t)}catch(e){r(e)}}),e))}))}}const Ie=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 i=Oe[e];return{type:"Unary",operator:e,child:t,evaluate(e){return i(this.child.evaluate(e))},getIds(e){return this.child.getIds(e)}}}binary(e,t,i){const r=Re[t];return{type:"Binary",operator:t,left:e,right:i,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 i,r;return"Getter"===this.left.type?(i=this.left.receiver.evaluate(e),r=this.left.name):"Index"===this.left.type?(i=this.left.receiver.evaluate(e),r=this.left.argument.evaluate(e)):"ID"===this.left.type&&(i=e,r=this.left.value),void 0===i?void 0:i[r]=t}return r(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,i){if(null!=t&&"string"!=typeof t)throw new Error("method not a string");return{type:"Invoke",receiver:e,method:t,arguments:i,evaluate(e){const i=this.receiver.evaluate(e),r=this.method?i:e?.this??e,s=this.method?i?.[t]:i,n=(this.arguments??[]).map((t=>t?.evaluate(e)));return s?.apply?.(r,n)},getIds(e){return this.receiver.getIds(e),this.arguments?.forEach((t=>t?.getIds(e))),e}}}paren(e){return e}index(e,t){return{type:"Index",receiver:e,argument:t,evaluate(e){return this.receiver.evaluate(e)?.[this.argument.evaluate(e)]},getIds(e){return this.receiver.getIds(e),e}}}ternary(e,t,i){return{type:"Ternary",condition:e,trueExpr:t,falseExpr:i,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 i={};if(e&&this.entries)for(const r in e){const e=this.entries[r];e&&(i[r]=e.evaluate(t))}return i},getIds(t){if(e&&this.entries)for(const i in e){const e=this.entries[i];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,i=this.body;return function(...r){const s=Object.fromEntries(t.map(((e,t)=>[e,r[t]]))),n=new Proxy(e??{},{set:(e,t,i)=>(s.hasOwnProperty(t)&&(s[t]=i),e[t]=i),get:(e,t)=>s.hasOwnProperty(t)?s[t]:e[t]});return i.evaluate(n)}},getIds(e){return this.body.getIds(e).filter((e=>!this.params.includes(e)))}}}};function Pe(e,t){if(e.has(t))return e.get(t);if(e.has("$parent")){return Pe(e.get("$parent"),t)}return null}function xe(e,t){if(e.has(t))return e;if(e.has("$parent")){return xe(e.get("$parent"),t)}return null}class Se extends Ne{evalkeys=["$elem","$event"];expressionCache=new Map;store=new Map;observers=new Map;_observer=null;_lock=Promise.resolve();constructor(e){super();for(let[t,i]of Object.entries(e||{}))this.set(t,i)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((i=e)instanceof Se||i.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,i)=>i in e&&(delete e[i],t(),!0),set:(i,r,s,n)=>{"object"==typeof s&&null!=e&&(s=this.wrapObject(s,t));const a=Reflect.set(i,r,s,n);return t(),a},get:(e,t,i)=>"__is_proxy__"===t||Reflect.get(e,t,i)});var i}watch(e,t){this.observers.has(e)||this.observers.set(e,new Set),this.observers.get(e)?.has(t)||this.observers.get(e)?.add(t)}async notify(e,t=10){const i=Array.from(this.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),Pe(this.store,e)}async set(e,t){if(t===this.store.get(e))return;const i=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,i)),function(e,t,i){const r=xe(e,t);r?r.set(t,i):e.set(t,i)}(this.store,e,t),await i()}del(e){this.store.delete(e),this.observers.delete(e)}has(e){return this.store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this.store.entries()).map((([e])=>e)),i=Object.fromEntries(t.map((e=>[e,void 0])));return new Proxy(i,{get:(t,i,r)=>"string"==typeof i&&xe(this.store,i)?this.get(i,e):"$"===i?this.proxify(e):Reflect.get(this,i,r),set:(e,t,i,r)=>("string"!=typeof t||t in this?Reflect.set(this,t,i,r):this.set(t,i),!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[i,r]=e.split(" = ");t=i.trim(),e=r.trim()}return(i,r)=>{const s=((e,t)=>new Te(e,t).parse())(e,Ie),n=s?.getIds([])?.map((e=>[e,r[e]??i[e]??globalThis[e]])),a=s?.evaluate(Object.fromEntries(n||[]));if(!t)return a;!function(e,t,i){const r=t.split(".");for(let t=0;t<r.length-1;t++)r[t]in e||(e[r[t]]={}),e=e[r[t]];e[r[r.length-1]]=i}(i,t,a)}}cachedExpressionFunction(e){return e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e)),this.expressionCache.get(e)}eval(e,t={}){const i=this._observer?this:this.$;if(this.store.has(e))return i[e];{const r=this.cachedExpressionFunction(e);try{return r(i,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}}class Ce extends Se{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 i=this.parseHTML(e,t);return await this.preprocessNode(i,t),i}async preprocessRemote(e,t){const i={};t?.cache&&(i.cache=t.cache);const r=await fetch(e,i).then((e=>e.text()));return this.preprocessString(r,{...t,dirpath:he(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}async preprocessLocal(e,t){const i=await this.fetchLocal(e,t);return this.preprocessString(i,{...t,dirpath:he(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}subrenderer(){const e=(new this.constructor).debug(this.debugging);return e.set("$parent",this),e.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 i=new ue(Y(e,this._skipNodes)).map((async e=>{this.log("Preprocessing node:\n",ce(e,128)),await de.resolveIncludes.call(this,e,t),await de.rebaseRelativePaths.call(this,e,t),await de.registerCustomElements.call(this,e,t),await de.resolveCustomElements.call(this,e,t)}));return await Promise.all(i.generator()),e}async renderNode(e,t){for(const i of Y(e,this._skipNodes))this.log("Rendering node:\n",ce(i,128)),await de.resolveForAttribute.call(this,i,t),await de.resolveDataAttribute.call(this,i,t),await de.resolveTextAttributes.call(this,i,t),await de.resolveHtmlAttribute.call(this,i,t),await de.resolveShowAttribute.call(this,i,t),await de.resolveClassAttribute.call(this,i,t),await de.resolveBindAttribute.call(this,i,t),await de.resolveEventAttributes.call(this,i,t),await de.resolveTextNodeExpressions.call(this,i,t),await de.resolveCustomAttribute.call(this,i,t),await de.resolveCustomProperty.call(this,i,t);return e}async mount(e,t){t={...t,rootNode:e},Q(e,"renderer",this),this.set("$rootNode",e),await this.preprocessNode(e,t),await this.renderNode(e,t)}}const Le=[":data",":for",":text",":html",":show",":class",":bind",":on:click",":on:input",":on:change",":on:submit",":attr:src",":attr:href",":attr:title",":prop:checked",":prop:selected",":prop:disabled"];class ke extends Ce{impl="safe_browser";dirpath=he(globalThis.location?.href??"http://localhost/");parseHTML(e,t={rootDocument:!1}){for(const t of Le)e=e.replace(new RegExp(`\\s:${t.slice(1)}=`,"g"),` data-${t.slice(1).replace(":","-")}=`);e=(e=(e=e.replace(/<include(.*) src="([^"]+)"(.*)><\/include>/g,'<link $1 rel="subresource" href="$2" $3>')).replace(/<template is="([^"]+)">([\s\S]*)<\/template>/g,'<div role="template" alt="$1">$2</div>')).replace(/<(\w+)-(\w+)(.*)>([\s\S]*)<\/(\w+)-(\w+)>/g,'<div role="$1-$2" $3>$4</div>');const i=Le.map((e=>`data-${e.slice(1).replace(":","-")}`));i.push("data-testid");const r=(new F).allowDataAttributes(i).allowClassAttributes().allowStyleAttributes().build();if(this.log("parseHTML",e),this.log("sanitized",String(r.sanitize(e))),t.rootDocument){return K(new DOMParser,r.sanitize(e),"text/html")}return r.sanitizeToFragment(e)}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}const De=new ke;export{De as Mancha,ke as Renderer};
1
+ const e={};function t(e){0}class i{constructor(e,t){this.privateDoNotAccessOrElseWrappedAttributePrefix=t}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const r=i;function s(e){if(function(e){return e instanceof i}(e))return e.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}function n(e){return Object.isFrozen(e)&&Object.isFrozen(e.raw)}function a(e){return-1===e.toString().indexOf("`")}a((e=>e``))||a((e=>e`\0`))||a((e=>e`\n`))||a((e=>e`\u0000`)),n``&&n`\0`&&n`\n`&&n`\u0000`;function o(t){const i=t[0].toLowerCase();return new r(e,i)}let l,c="google#safe";function h(){var e;return""!==c&&null!==(e=function(){if("undefined"!=typeof window)return window.trustedTypes}())&&void 0!==e?e:null}class u{constructor(e,i){t(),this.privateDoNotAccessOrElseWrappedHtml=e}toString(){return this.privateDoNotAccessOrElseWrappedHtml.toString()}}function d(t,i){return null!=i?i:new u(t,e)}"undefined"!=typeof window&&window.TrustedHTML;function p(e){var t;const i=e;return d(i,null===(t=function(){var e,t;if(void 0===l)try{l=null!==(t=null===(e=h())||void 0===e?void 0:e.createPolicy(c,{createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e}))&&void 0!==t?t:null}catch(e){l=null}return l}())||void 0===t?void 0:t.createHTML(i))}function f(e){var t;if(null===(t=h())||void 0===t?void 0:t.isHTML(e))return e;if(e instanceof u)return e.privateDoNotAccessOrElseWrappedHtml;throw new Error("")}"undefined"!=typeof window&&window.TrustedScriptURL;"undefined"!=typeof window&&window.TrustedScript;function _(e,t){t.appendChild(e);let i=(new XMLSerializer).serializeToString(t);return i=i.slice(i.indexOf(">")+1,i.lastIndexOf("</")),p(i)}const m=["data:","http:","https:","mailto:","ftp:"],E=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function v(e){if(!function(e){const t=!E.test(e);return t}(e))return e}function w(e){return v(e)}function b(e){const t=function(e){let t;try{t=new URL(e)}catch(e){return"https:"}return t.protocol}(e);return void 0!==t&&-1!==m.indexOf(t.toLowerCase())?e:"about:invalid#zClosurez"}function g(e,t){const i=t.createRange();i.selectNode(t.body);return function(e,t){return e.createContextualFragment(f(t))}(i,p(e))}function A(e){const t=e.nodeName;return"string"==typeof t?t:"FORM"}function y(e){return 3===e.nodeType}function T(e){const t=e.nodeType;return 1===t||"number"!=typeof t}var R,O;function N(e){try{return new URL(e,window.document.baseURI)}catch(e){return new URL("about:invalid")}}function I(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"}(R||(R={}));class P{constructor(e,t,i,r,s){this.allowedElements=e,this.elementPolicies=t,this.allowedGlobalAttributes=i,this.globalAttributePolicies=r,this.globallyAllowedAttributePrefixes=s}isAllowedElement(e){return"FORM"!==e&&(this.allowedElements.has(e)||this.elementPolicies.has(e))}getAttributePolicy(e,t){const i=this.elementPolicies.get(t);if(null==i?void 0:i.has(e))return i.get(e);if(this.allowedGlobalAttributes.has(e))return{policyAction:O.KEEP};const r=this.globalAttributePolicies.get(e);return r||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((t=>0===e.indexOf(t)))?{policyAction:O.KEEP}:{policyAction:O.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"}(O||(O={}));const x=new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const S=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],C=[["A",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],L=["title","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-current","aria-disabled","aria-dropeffect","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-live","aria-multiline","aria-multiselectable","aria-orientation","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","alt","align","autocapitalize","autocomplete","autocorrect","autofocus","autoplay","bgcolor","border","cellpadding","cellspacing","checked","color","cols","colspan","controls","datetime","disabled","download","draggable","enctype","face","formenctype","frameborder","height","hreflang","hidden","ismap","label","lang","loop","max","maxlength","media","minlength","min","multiple","muted","nonce","open","placeholder","preload","rel","required","reversed","role","rows","rowspan","selected","shape","size","sizes","slot","span","spellcheck","start","step","summary","translate","type","valign","value","width","wrap","itemscope","itemtype","itemid","itemprop","itemref"],k=[["dir",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:O.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:O.KEEP_AND_SANITIZE_URL}],["target",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["target",new Set(["_self","_blank"])]])))}]],D=new P(new Set(S),new Map(C),new Set(L),new Map(k));new P(new Set(I((()=>S.concat(["STYLE"])))),new Map(C),new Set(I((()=>L.concat(["id","name","class"])))),new Map(I((()=>k.concat([["style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}]])))));class U{constructor(e,i,r,s,n){this.sanitizerTable=e,this.styleElementSanitizer=r,this.styleAttributeSanitizer=s,this.resourceUrlPolicy=n,this.changes=[],t()}sanitizeAssertUnchanged(e){return this.sanitize(e)}sanitize(e){const t=document.implementation.createHTMLDocument("");return _(this.sanitizeToFragmentInternal(e,t),t.body)}sanitizeToFragment(e){const t=document.implementation.createHTMLDocument("");return this.sanitizeToFragmentInternal(e,t)}sanitizeToFragmentInternal(e,t){const i=g(e,t),r=document.createTreeWalker(i,5,(e=>this.nodeFilter(e)));let s=r.nextNode();const n=t.createDocumentFragment();let a=n;for(;null!==s;){let e;if(y(s))if(this.styleElementSanitizer&&"STYLE"===a.nodeName){const t=this.styleElementSanitizer(s.data);e=this.createTextNode(t)}else e=this.sanitizeTextNode(s);else{if(!T(s)){throw new Error("")}e=this.sanitizeElementNode(s,t)}if(a.appendChild(e),s=r.firstChild(),s)a=e;else for(;!(s=r.nextSibling())&&(s=r.parentNode());)a=a.parentNode}return n}createTextNode(e){return document.createTextNode(e)}sanitizeTextNode(e){return this.createTextNode(e.data)}sanitizeElementNode(e,t){const i=A(e),r=t.createElement(i),s=e.attributes;for(const{name:e,value:t}of s){const n=this.sanitizerTable.getAttributePolicy(e,i);if(this.satisfiesAllConditions(n.conditions,s))switch(n.policyAction){case O.KEEP:z(r,e,t);break;case O.KEEP_AND_SANITIZE_URL:const s=b(t);s!==t&&this.recordChange(`Url in attribute ${e} was modified during sanitization. Original url:"${t}" was sanitized to: "${s}"`),z(r,e,s);break;case O.KEEP_AND_NORMALIZE:z(r,e,t.toLowerCase());break;case O.KEEP_AND_SANITIZE_STYLE:if(this.styleAttributeSanitizer){z(r,e,this.styleAttributeSanitizer(t))}else z(r,e,t);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY:if(this.resourceUrlPolicy){const s={type:R.HTML_ATTRIBUTE,attributeName:e,tagName:i},n=N(t),a=this.resourceUrlPolicy(n,s);a&&z(r,e,a.toString())}else z(r,e,t);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET:if(this.resourceUrlPolicy){const s={type:R.HTML_ATTRIBUTE,attributeName:e,tagName:i},n=$(t),a={parts:[]};for(const e of n.parts){const t=N(e.url),i=this.resourceUrlPolicy(t,s);i&&a.parts.push({url:i.toString(),descriptor:e.descriptor})}z(r,e,M(a))}else z(r,e,t);break;case O.DROP:this.recordChange(`Attribute: ${e} was dropped`)}else this.recordChange(`Not all conditions satisfied for attribute: ${e}.`)}return r}nodeFilter(e){if(y(e))return 1;if(!T(e))return 2;const t=A(e);return null===t?(this.recordChange(`Node name was null for node: ${e}`),2):this.sanitizerTable.isAllowedElement(t)?1:(this.recordChange(`Element: ${t} was dropped`),2)}recordChange(e){0}satisfiesAllConditions(e,t){var i;if(!e)return!0;for(const[r,s]of e){const e=null===(i=t.getNamedItem(r))||void 0===i?void 0:i.value;if(e&&!s.has(e))return!1}return!0}}function z(e,t,i){e.setAttribute(t,i)}function $(e){const t=[];for(const i of e.split(",")){const[e,r]=i.trim().split(/\s+/,2);t.push({url:e,descriptor:r})}return{parts:t}}function M(e){return e.parts.map((e=>{const{url:t,descriptor:i}=e;return`${t}${i?` ${i}`:""}`})).join(" , ")}class F{constructor(){this.calledBuild=!1,this.sanitizerTable=D}onlyAllowElements(e){const t=new Set,i=new Map;for(let r of e){if(r=r.toUpperCase(),!this.sanitizerTable.isAllowedElement(r))throw new Error(`Element: ${r}, is not allowed by html5_contract.textpb`);const e=this.sanitizerTable.elementPolicies.get(r);void 0!==e?i.set(r,e):t.add(r)}return this.sanitizerTable=new P(t,i,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}allowCustomElement(e,t){const i=new Set(this.sanitizerTable.allowedElements),r=new Map(this.sanitizerTable.elementPolicies);if(e=e.toUpperCase(),s=e,x.has(s.toUpperCase())||!/^[a-z][-_.a-z0-9]*-[-_.a-z0-9]*$/i.test(s))throw new Error(`Element: ${e} is not a custom element`);var s;if(t){const i=new Map;for(const e of t)i.set(e,{policyAction:O.KEEP});r.set(e,i)}else i.add(e);return this.sanitizerTable=new P(i,r,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}onlyAllowAttributes(e){const t=new Set,i=new Map,r=new Map;for(const r of e)this.sanitizerTable.allowedGlobalAttributes.has(r)&&t.add(r),this.sanitizerTable.globalAttributePolicies.has(r)&&i.set(r,this.sanitizerTable.globalAttributePolicies.get(r));for(const[t,i]of this.sanitizerTable.elementPolicies.entries()){const s=new Map;for(const[t,r]of i.entries())e.has(t)&&s.set(t,r);r.set(t,s)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,r,t,i),this}allowDataAttributes(e){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);for(const i of e){if(0!==i.indexOf("data-"))throw new Error(`data attribute: ${i} does not begin with the prefix "data-"`);t.add(i)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}allowStyleAttributes(){const e=new Map(this.sanitizerTable.globalAttributePolicies);return e.set("style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,this.sanitizerTable.allowedGlobalAttributes,e),this}allowClassAttributes(){const e=new Set(this.sanitizerTable.allowedGlobalAttributes);return e.add("class"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,e,this.sanitizerTable.globalAttributePolicies),this}allowIdAttributes(){const e=new Set(this.sanitizerTable.allowedGlobalAttributes);return e.add("id"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,e,this.sanitizerTable.globalAttributePolicies),this}allowIdReferenceAttributes(){const e=new Set(this.sanitizerTable.allowedGlobalAttributes);return e.add("aria-activedescendant").add("aria-controls").add("aria-labelledby").add("aria-owns").add("for").add("list"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,e,this.sanitizerTable.globalAttributePolicies),this}withResourceUrlPolicy(e){return this.resourceUrlPolicy=e,this}build(){if(this.calledBuild)throw new Error("this sanitizer has already called build");return this.calledBuild=!0,new U(this.sanitizerTable,e,void 0,void 0,this.resourceUrlPolicy)}}function G(e,t,i,r){if(0===e.length){throw new Error("")}const n=e.map((e=>s(e))),a=i.toLowerCase();if(n.every((e=>0!==a.indexOf(e))))throw new Error(`Attribute "${i}" does not match any of the allowed prefixes.`);t.setAttribute(i,r)}function K(e,t,i){return e.parseFromString(f(t),i)}Error;const W=[o`:`,o`style`,o`class`];function*Y(e,t=new Set){const i=new Set,r=Array.from(e.childNodes).filter((e=>!t.has(e)));for(yield e;r.length;){const e=r.shift();i.has(e)||(i.add(e),yield e),e.childNodes&&Array.from(e.childNodes).filter((e=>!t.has(e))).forEach((e=>r.push(e)))}}function H(e,t){return void 0!==e?.[t]}function B(e,t){return"function"==typeof e?.[t]}function V(e){return e.replace(/-./g,(e=>e[1].toUpperCase()))}function Z(e,t){return H(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function j(e,t,i=""){return Z(e,i+t)||(e.dataset?.[V(t)]??null)}function q(e,t,i){H(e,"attribs")?e.attribs[t]=i:e.setAttribute?.(t,i)}function X(e,t,i){H(e,"attribs")?e.attribs[t]=i:G(W,e,t,i)}function Q(e,t,i){switch(t){case"disabled":return void(e.disabled=i);case"selected":return void(e.selected=i);case"checked":return void(e.checked=i);default:e[t]=i}}function J(e,t){H(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function ee(e,t,i=""){J(e,`${i}${t}`),J(e,`data-${t}`)}function te(e,t,i){if(H(e,"attribs")&&H(t,"attribs"))t.attribs[i]=e.attribs[i];else if(i.startsWith("data-")){const r=V(i.slice(5));t.dataset[r]=e.dataset?.[r]}else{const r=e?.getAttribute?.(i);X(t,i,r||"")}}function ie(e){if(H(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find((e=>1===e.nodeType))}function re(e,...t){if(B(e,"replaceWith"))return e.replaceWith(...t);{const i=e,r=i.parentNode,s=Array.from(r.childNodes).indexOf(i);t.forEach((e=>e.parentNode=r)),r.childNodes=[].concat(Array.from(r.childNodes).slice(0,s)).concat(t).concat(Array.from(r.childNodes).slice(s+1))}}function se(e,...t){B(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function ne(e,t){return B(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function ae(e,t){return B(t,"removeChild")?e.removeChild(t):(se(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function oe(e,t,i){return i?B(e,"insertBefore")?e.insertBefore(t,i):(re(i,t,i),t):ne(e,t)}function le(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function ce(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map((e=>ce(e,t))).join(""):le(e.outerHTML||e.nodeValue||String(e),t)}function he(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}class ue{iterable;constructor(e){this.iterable=e}filter(e){return new ue(ue.filterGenerator(e,this.iterable))}map(e){return new ue(ue.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 i of t)e(i)&&(yield i)}static*mapGenerator(e,t){for(const i of t)yield e(i)}static equals(e,t){const i=e[Symbol.iterator](),r=t[Symbol.iterator]();let s=i.next(),n=r.next();for(;!s.done&&!n.done;){if(s.value!==n.value)return!1;s=i.next(),n=r.next()}return s.done===n.done}}var de;!function(e){e.resolveIncludes=async function(e,t){const i=e,r=i.tagName?.toLowerCase();if(!["include","link"].includes(r))return;if("link"===r&&"subresource"!==Z(i,"rel"))return;this.log("include directive found in:\n",ce(e,128)),this.log("include params:",t);const s="link"===i.tagName.toLocaleLowerCase()?"href":"src",n=Z(i,s);if(!n)throw new Error(`"${s}" attribute missing from ${ce(e,128)}.`);const a=[];"include"===r&&a.push("src"),"link"===r&&a.push("rel","href");const o=t=>{const r=ie(t);for(const e of Array.from(i.attributes))r&&!a.includes(e.name)&&te(i,r,e.name);re(e,...t.childNodes)},l={...t,rootDocument:!1,maxdepth:t?.maxdepth-1};if(0===l.maxdepth)throw new Error("Maximum recursion depth reached.");if(n.includes("://")||n.startsWith("//"))this.log("Including remote file from absolute path:",n),await this.preprocessRemote(n,l).then(o);else if(t?.dirpath?.includes("://")||t?.dirpath?.startsWith("//")){const e=n.startsWith("/")?n:`${t.dirpath}/${n}`;this.log("Including remote file from relative path:",e),await this.preprocessRemote(e,l).then(o)}else if("/"===n.charAt(0))this.log("Including local file from absolute path:",n),await this.preprocessLocal(n,l).then(o);else{const e=t?.dirpath&&"."!==t?.dirpath?`${t?.dirpath}/${n}`:n;this.log("Including local file from relative path:",e),await this.preprocessLocal(e,l).then(o)}},e.rebaseRelativePaths=async function(e,t){const i=e,r=i.tagName?.toLowerCase();if(!t?.dirpath)return;const s=Z(i,"src"),n=Z(i,"href"),a=s||n;if(!a||((o=a).includes("://")||o.startsWith("/")||o.startsWith("#")||o.startsWith("data:")))return;var o;const l=`${t.dirpath}/${a}`;this.log("Rebasing relative path as:",l),H(i,"attribs")?X(i,s?"src":"href",l):"img"===r?i.src=l:"a"===r?function(e,t){const i=w(t);void 0!==i&&(e.href=i)}(i,l):"source"===r||"audio"===r||"video"===r||"track"===r||"input"===r?i.src=l:"area"===r?function(e,t){const i=w(t);void 0!==i&&(e.href=i)}(i,l):this.log("Unable to rebase relative path for element:",r)},e.registerCustomElements=async function(e,t){const i=e,r=i.tagName?.toLowerCase(),s=(Z(i,"is")||Z(i,"alt"))?.toLowerCase();if(["template","div"].includes(r)&&s){if("div"===r&&"template"!==Z(i,"role"))return;this._customElements.has(s)||(this.log(`Registering custom element: ${s}\n`,ce(i,128)),this._customElements.set(s,i),ae(i.parentNode,i))}},e.resolveCustomElements=async function(e,t){const i=e,r=i.tagName?.toLowerCase();let s=r;if("div"===s&&(s=Z(i,"role")?.toLowerCase()||s),s&&this._customElements.has(s)){this.log(`Processing custom element: ${s}\n`,ce(i,128));const t=this._customElements.get(s),n=(t.content||t).cloneNode(!0),a=ie(n);if(a)for(const e of Array.from(i.attributes))"div"===r&&"role"===e.name||te(i,a,e.name);const o=new ue(Y(n)).find((e=>"slot"===e.tagName?.toLowerCase()));o&&re(o,...i.childNodes),re(e,...n.childNodes)}},e.resolveTextNodeExpressions=async function(e,t){const i=e.nodeValue||"";if(3!==e.nodeType||!i?.trim())return;this.log("Processing node content value:\n",le(i,128));const r=new RegExp(/{{ ([^}]+) }}/gm),s=Array.from(i.matchAll(r)).map((e=>e[1]));return this.effect((function(){let t=i;for(const i of s){const r=this.eval(i,{$elem:e});t=t.replace(`{{ ${i} }}`,String(r))}e.nodeValue=t}))},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"data",":");if(r){this.log(":data attribute found in:\n",ce(e,128)),ee(i,"data",":");const s=t?.rootNode===e?this:this.subrenderer();e.renderer=s;const n=s.eval(r,{$elem:e});if(await Promise.all(Object.entries(n).map((([e,t])=>s.set(e,t)))),s!==this)for(const t of Y(e,this._skipNodes))this._skipNodes.add(t);await s.mount(e,t)}},e.resolveClassAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"class",":");if(r){this.log(":class attribute found in:\n",ce(e,128)),ee(i,"class",":");const t=Z(i,"class")||"";return this.effect((function(){const s=this.eval(r,{$elem:e});X(i,"class",(s?`${t} ${s}`:t).trim())}))}},e.resolveTextAttributes=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"text",":");if(r){this.log(":text attribute found in:\n",ce(e,128)),ee(i,"text",":");const t=t=>this.textContent(e,t);return this.effect((function(){t(this.eval(r,{$elem:e}))}))}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"html",":");return r?(this.log(":html attribute found in:\n",ce(e,128)),ee(i,"html",":"),this.effect((function(){const s=this.eval(r,{$elem:e});return new Promise((async e=>{const r=await this.preprocessString(s,t);await this.renderNode(r),se(i,r),e()}))}))):void 0},e.resolveEventAttributes=async function(e,t){if(this._skipNodes.has(e))return;const i=e;for(const t of Array.from(i.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){const r=t.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!r)throw new Error(`Invalid event attribute: ${t.name}`);this.log(t.name,"attribute found in:\n",ce(e,128)),J(i,t.name);const s="submit"===r&&"FORM"===i.tagName.toUpperCase();e.addEventListener?.(r,(i=>(s&&i.preventDefault(),this.eval(t.value,{$elem:e,$event:i}))))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"for",":")?.trim();if(r){this.log(":for attribute found in:\n",ce(e,128)),ee(i,"for",":");for(const t of Y(e,this._skipNodes))this._skipNodes.add(t);const s=Z(i,"style")||"";q(i,"style","display: none;");const n=e.parentNode,a=this.createElement("template",e.ownerDocument);oe(n,a,e),ae(n,e),ne(a,e),this.log(":for template:\n",ce(a,128));const o=r.split(" in ",2);if(2!==o.length)throw new Error(`Invalid :for format: \`${r}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=o;await this.effect((function(){const i=this.eval(h,{$elem:e});if(this.log(":for list items:",i),l.splice(0,l.length).forEach((e=>{ae(n,e),this._skipNodes.delete(e)})),!Array.isArray(i))return console.error(`Expression did not yield a list: \`${h}\` => \`${i}\``),Promise.resolve();const r=[];for(const n of i){const i=this.subrenderer();i.set(c,n);const a=e.cloneNode(!0);q(a,"style",s),l.push(a),this._skipNodes.add(a),r.push(i.mount(a,t)),this.log("Rendered list child:\n",ce(a,128))}const o=a.nextSibling;for(const e of l)oe(n,e,o);return Promise.all(r)}))}},e.resolveBindAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"bind",":");if(r){this.log(":bind attribute found in:\n",ce(e,128));const t=["change","input"],s=Z(i,":bind:on")?.split(",")||i.dataset?.bindOn?.split(",")||t;ee(i,"bind",":"),J(i,":bind:on"),J(i,"data-bind-on");const n="checkbox"===Z(i,"type")?"checked":"value";this.effect((function(){const t=this.eval(r,{$elem:e});"checked"===n?i.checked=!!t:i.value=t}));const a=`${r} = $elem.${n}`;for(const t of s)e.addEventListener(t,(()=>this.eval(a,{$elem:e})))}},e.resolveShowAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e,r=j(i,"show",":");if(r){this.log(":show attribute found in:\n",ce(e,128)),ee(i,"show",":");const t="none"===i.style?.display?"":i.style?.display??Z(i,"style")?.split(";")?.find((e=>"display"===e.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const s=this.eval(r,{$elem:e});i.style?i.style.display=s?t:"none":X(i,"style",`display: ${s?t:"none"};`)}))}},e.resolveCustomAttribute=async function(e,t){if(this._skipNodes.has(e))return;const i=e;for(const t of Array.from(i.attributes||[])){const r=":attr:",s="data-attr-";if(t.name.startsWith(r)||t.name.startsWith(s)){this.log(t.name,"attribute found in:\n",ce(e,128)),J(i,t.name);const n=t.name.split(r,2).at(-1)?.split(s,2).at(-1);this.effect((function(){const r=this.eval(t.value,{$elem:e});q(i,n,r)}))}}},e.resolveCustomProperty=async function(e,t){if(this._skipNodes.has(e))return;const i=e;for(const t of Array.from(i.attributes||[])){const r=":prop:",s="data-prop-";if(t.name.startsWith(r)||t.name.startsWith(s)){this.log(t.name,"property found in:\n",ce(e,128)),J(i,t.name);const n=t.name.split(r,2).at(-1)?.split(s,2).at(-1),a=V(n);this.effect((function(){const r=this.eval(t.value,{$elem:e});Q(i,a,r)}))}}}}(de||(de={}));const pe=["this"],fe=["+","-","!"],_e=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],me={"!":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=["==","!=","<=",">=","||","&&","??","|>"],ve=["===","!=="];var we;!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"}(we||(we={}));const be=(e,t,i=0)=>({kind:e,value:t,precedence:i}),ge=e=>95===e||36===e||65<=(e&=-33)&&e<=90,Ae=e=>48<=e&&e<=57;class ye{_input;_index=-1;_tokenStart=0;_next;constructor(e){this._input=e,this._advance()}nextToken(){for(;9===(e=this._next)||10===e||13===e||32===e;)this._advance(!0);var e;if((e=>34===e||39===e)(this._next))return this._tokenizeString();if(ge(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 i=be(we.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(),i}_tokenizeIdentOrKeyword(){do{this._advance()}while(e=this._next,ge(e)||Ae(e));var e;const t=this._getValue(),i=(r=t,-1!==pe.indexOf(r)?we.KEYWORD:we.IDENTIFIER);var r;return be(i,t)}_tokenizeNumber(){do{this._advance()}while(Ae(this._next));return 46===this._next?this._tokenizeDot():be(we.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),Ae(this._next)?this._tokenizeFraction():(this._clearValue(),be(we.DOT,".",13))}_tokenizeComma(){return this._advance(!0),be(we.COMMA,",")}_tokenizeColon(){return this._advance(!0),be(we.COLON,":")}_tokenizeFraction(){do{this._advance()}while(Ae(this._next));return be(we.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(-1!==ve.indexOf(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),be(we.ARROW,e);-1!==Ee.indexOf(e)&&this._advance()}return e=this._getValue(),be(we.OPERATOR,e,me[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=be(we.GROUPER,e,me[e]);return this._advance(!0),t}}class Te{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new ye(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 i=this._tokenizer.nextToken();this._token=i,this._kind=i?.kind,this._value=i?.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(we.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(we.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(we.DOT)){this._advance();const t=this._parseUnary();e=this._makeInvokeOrGetter(e,t)}else{if(this._matches(we.KEYWORD))break;if(!(this._matches(we.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 i=t.receiver;return this._ast.invoke(e,i.value,t.arguments)}throw new Error(`expected identifier: ${t}`)}_parseBinary(e,t){if(-1===_e.indexOf(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let i=this._parseUnary();for(;(this._kind===we.OPERATOR||this._kind===we.DOT||this._kind===we.GROUPER)&&this._token.precedence>t.precedence;)i=this._parsePrecedence(i,this._token.precedence);return this._ast.binary(e,t.value,i)}_parseUnary(){if(this._matches(we.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(we.INTEGER))return this._parseInteger(e);if(this._matches(we.DECIMAL))return this._parseDecimal(e)}if(-1===fe.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(we.OPERATOR,"?");const t=this._parseExpression();this._advance(we.COLON);const i=this._parseExpression();return this._ast.ternary(e,t,i)}_parsePrimary(){switch(this._kind){case we.KEYWORD:const e=this._value;if("this"===e)return this._advance(),this._ast.id(e);if(-1!==pe.indexOf(e))throw new Error(`unexpected keyword: ${e}`);throw new Error(`unrecognized keyword: ${e}`);case we.IDENTIFIER:return this._parseInvokeOrIdentifier();case we.STRING:return this._parseString();case we.INTEGER:return this._parseInteger();case we.DECIMAL:return this._parseDecimal();case we.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case we.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(we.GROUPER,"]"))break;e.push(this._parseExpression())}while(this._matches(we.COMMA));return this._advance(we.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e={};do{if(this._advance(),this._matches(we.GROUPER,"}"))break;const t=this._value;(this._matches(we.STRING)||this._matches(we.IDENTIFIER))&&this._advance(),this._advance(we.COLON),e[t]=this._parseExpression()}while(this._matches(we.COMMA));return this._advance(we.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(),i=this._parseArguments();return i?this._ast.invoke(t,void 0,i):t}_parseIdentifier(){if(!this._matches(we.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(we.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(we.GROUPER,")"))break;const t=this._parseExpression();e.push(t)}while(this._matches(we.COMMA));return this._advance(we.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(we.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(we.ARROW)){this._advance();const t=this._parseExpression(),i=e?.map((e=>e.value))??[];return this._ast.arrowFunction(i,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 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),"|>":(e,t)=>t(e)},Oe={"+":e=>e,"-":e=>-e,"!":e=>!e};class Ne{timeouts=new Map;debounce(e,t){return new Promise(((i,r)=>{const s=this.timeouts.get(t);s&&clearTimeout(s),this.timeouts.set(t,setTimeout((()=>{try{i(t()),this.timeouts.delete(t)}catch(e){r(e)}}),e))}))}}const Ie=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 i=Oe[e];return{type:"Unary",operator:e,child:t,evaluate(e){return i(this.child.evaluate(e))},getIds(e){return this.child.getIds(e)}}}binary(e,t,i){const r=Re[t];return{type:"Binary",operator:t,left:e,right:i,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 i,r;return"Getter"===this.left.type?(i=this.left.receiver.evaluate(e),r=this.left.name):"Index"===this.left.type?(i=this.left.receiver.evaluate(e),r=this.left.argument.evaluate(e)):"ID"===this.left.type&&(i=e,r=this.left.value),void 0===i?void 0:i[r]=t}return r(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,i){if(null!=t&&"string"!=typeof t)throw new Error("method not a string");return{type:"Invoke",receiver:e,method:t,arguments:i,evaluate(e){const i=this.receiver.evaluate(e),r=this.method?i:e?.this??e,s=this.method?i?.[t]:i,n=(this.arguments??[]).map((t=>t?.evaluate(e)));return s?.apply?.(r,n)},getIds(e){return this.receiver.getIds(e),this.arguments?.forEach((t=>t?.getIds(e))),e}}}paren(e){return e}index(e,t){return{type:"Index",receiver:e,argument:t,evaluate(e){return this.receiver.evaluate(e)?.[this.argument.evaluate(e)]},getIds(e){return this.receiver.getIds(e),e}}}ternary(e,t,i){return{type:"Ternary",condition:e,trueExpr:t,falseExpr:i,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 i={};if(e&&this.entries)for(const r in e){const e=this.entries[r];e&&(i[r]=e.evaluate(t))}return i},getIds(t){if(e&&this.entries)for(const i in e){const e=this.entries[i];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,i=this.body;return function(...r){const s=Object.fromEntries(t.map(((e,t)=>[e,r[t]]))),n=new Proxy(e??{},{set:(e,t,i)=>(s.hasOwnProperty(t)&&(s[t]=i),e[t]=i),get:(e,t)=>s.hasOwnProperty(t)?s[t]:e[t]});return i.evaluate(n)}},getIds(e){return this.body.getIds(e).filter((e=>!this.params.includes(e)))}}}};function Pe(e,t){if(e.has(t))return e.get(t);if(e.has("$parent")){return Pe(e.get("$parent"),t)}return null}function xe(e,t){if(e.has(t))return e;if(e.has("$parent")){return xe(e.get("$parent"),t)}return null}class Se extends Ne{evalkeys=["$elem","$event"];expressionCache=new Map;store=new Map;observers=new Map;_observer=null;_lock=Promise.resolve();constructor(e){super();for(let[t,i]of Object.entries(e||{}))this.set(t,i)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((i=e)instanceof Se||i.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,i)=>i in e&&(delete e[i],t(),!0),set:(i,r,s,n)=>{"object"==typeof s&&null!=e&&(s=this.wrapObject(s,t));const a=Reflect.set(i,r,s,n);return t(),a},get:(e,t,i)=>"__is_proxy__"===t||Reflect.get(e,t,i)});var i}watch(e,t){this.observers.has(e)||this.observers.set(e,new Set),this.observers.get(e)?.has(t)||this.observers.get(e)?.add(t)}async notify(e,t=10){const i=Array.from(this.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),Pe(this.store,e)}async set(e,t){if(t===this.store.get(e))return;const i=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,i)),function(e,t,i){const r=xe(e,t);r?r.set(t,i):e.set(t,i)}(this.store,e,t),await i()}del(e){this.store.delete(e),this.observers.delete(e)}has(e){return this.store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this.store.entries()).map((([e])=>e)),i=Object.fromEntries(t.map((e=>[e,void 0])));return new Proxy(i,{get:(t,i,r)=>"string"==typeof i&&xe(this.store,i)?this.get(i,e):"$"===i?this.proxify(e):Reflect.get(this,i,r),set:(e,t,i,r)=>("string"!=typeof t||t in this?Reflect.set(this,t,i,r):this.set(t,i),!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[i,r]=e.split(" = ");t=i.trim(),e=r.trim()}return(i,r)=>{const s=((e,t)=>new Te(e,t).parse())(e,Ie),n=s?.getIds([])?.map((e=>[e,r[e]??i[e]??globalThis[e]])),a=s?.evaluate(Object.fromEntries(n||[]));if(!t)return a;!function(e,t,i){const r=t.split(".");for(let t=0;t<r.length-1;t++)r[t]in e||(e[r[t]]={}),e=e[r[t]];e[r[r.length-1]]=i}(i,t,a)}}cachedExpressionFunction(e){return e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e)),this.expressionCache.get(e)}eval(e,t={}){const i=this._observer?this:this.$;if(this.store.has(e))return i[e];{const r=this.cachedExpressionFunction(e);try{return r(i,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}}class Ce extends Se{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 i=this.parseHTML(e,t);return await this.preprocessNode(i,t),i}async preprocessRemote(e,t){const i={};t?.cache&&(i.cache=t.cache);const r=await fetch(e,i).then((e=>e.text()));return this.preprocessString(r,{...t,dirpath:he(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}async preprocessLocal(e,t){const i=await this.fetchLocal(e,t);return this.preprocessString(i,{...t,dirpath:he(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 i=new ue(Y(e,this._skipNodes)).map((async e=>{this.log("Preprocessing node:\n",ce(e,128)),await de.resolveIncludes.call(this,e,t),await de.rebaseRelativePaths.call(this,e,t),await de.registerCustomElements.call(this,e,t),await de.resolveCustomElements.call(this,e,t)}));return await Promise.all(i.generator()),e}async renderNode(e,t){for(const i of Y(e,this._skipNodes))this.log("Rendering node:\n",ce(i,128)),await de.resolveForAttribute.call(this,i,t),await de.resolveDataAttribute.call(this,i,t),await de.resolveTextAttributes.call(this,i,t),await de.resolveHtmlAttribute.call(this,i,t),await de.resolveShowAttribute.call(this,i,t),await de.resolveClassAttribute.call(this,i,t),await de.resolveBindAttribute.call(this,i,t),await de.resolveEventAttributes.call(this,i,t),await de.resolveTextNodeExpressions.call(this,i,t),await de.resolveCustomAttribute.call(this,i,t),await de.resolveCustomProperty.call(this,i,t);return e}async mount(e,t){t={...t,rootNode:e},Q(e,"renderer",this),this.store.set("$rootNode",e),await this.preprocessNode(e,t),await this.renderNode(e,t)}}const Le=[":data",":for",":text",":html",":show",":class",":bind",":on:click",":on:input",":on:change",":on:submit",":attr:src",":attr:href",":attr:title",":prop:checked",":prop:selected",":prop:disabled"];class ke extends Ce{impl="safe_browser";dirpath=he(globalThis.location?.href??"http://localhost/");parseHTML(e,t={rootDocument:!1}){for(const t of Le)e=e.replace(new RegExp(`\\s:${t.slice(1)}=`,"g"),` data-${t.slice(1).replace(":","-")}=`);e=(e=(e=e.replace(/<include(.*) src="([^"]+)"(.*)><\/include>/g,'<link $1 rel="subresource" href="$2" $3>')).replace(/<template is="([^"]+)">([\s\S]*)<\/template>/g,'<div role="template" alt="$1">$2</div>')).replace(/<(\w+)-(\w+)(.*)>([\s\S]*)<\/(\w+)-(\w+)>/g,'<div role="$1-$2" $3>$4</div>');const i=Le.map((e=>`data-${e.slice(1).replace(":","-")}`));i.push("data-testid");const r=(new F).allowDataAttributes(i).allowClassAttributes().allowStyleAttributes().build();if(this.log("parseHTML",e),this.log("sanitized",String(r.sanitize(e))),t.rootDocument){return K(new DOMParser,r.sanitize(e),"text/html")}return r.sanitizeToFragment(e)}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}const De=new ke;export{De as Mancha,ke as Renderer};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mancha",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "description": "Javscript HTML rendering engine",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",