mancha 0.14.2 → 0.14.4
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 +1 -1
- package/dist/mancha.js +1 -1
- package/dist/query.js +10 -6
- package/dist/query.js.map +1 -1
- package/dist/safe_browser.js +1 -1
- package/dist/test_utils.d.ts +1 -0
- package/dist/test_utils.js +18 -15
- package/dist/test_utils.js.map +1 -1
- package/package.json +1 -2
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 d extends h{constructor(e,t){super(),s(),this.privateDoNotAccessOrElseWrappedStyleSheet=e}toString(){return this.privateDoNotAccessOrElseWrappedStyleSheet}}function u(e){return new d(e,n)}function p(e){if(e instanceof d)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 w(e){return{valueOf:e}.valueOf()}!function(e){e[e.STYLE_TAG=0]="STYLE_TAG",e[e.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",e[e.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}(g||(g={}));class v{constructor(e,t,r,i,n){this.allowedElements=e,this.elementPolicies=t,this.allowedGlobalAttributes=r,this.globalAttributePolicies=i,this.globallyAllowedAttributePrefixes=n}isAllowedElement(e){return"FORM"!==e&&(this.allowedElements.has(e)||this.elementPolicies.has(e))}getAttributePolicy(e,t){const r=this.elementPolicies.get(t);if(null==r?void 0:r.has(e))return r.get(e);if(this.allowedGlobalAttributes.has(e))return{policyAction:$.KEEP};const i=this.globalAttributePolicies.get(e);return i||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((t=>0===e.indexOf(t)))?{policyAction:$.KEEP}:{policyAction:$.DROP})}}!function(e){e[e.DROP=0]="DROP",e[e.KEEP=1]="KEEP",e[e.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",e[e.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",e[e.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}($||($={}));new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const x=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],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:w((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:$.KEEP_AND_NORMALIZE,conditions:w((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:$.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:$.KEEP_AND_NORMALIZE,conditions:w((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:$.KEEP_AND_SANITIZE_URL}],["target",{policyAction:$.KEEP_AND_NORMALIZE,conditions:w((()=>new Map([["target",new Set(["_self","_blank"])]])))}]];new v(new Set(x),new Map(b),new Set(E),new Map(y)),new v(new Set(w((()=>x.concat(["STYLE"])))),new Map(b),new Set(w((()=>E.concat(["id","name","class"])))),new Map(w((()=>y.concat([["style",{policyAction:$.KEEP_AND_SANITIZE_STYLE}]])))));function A(e){return u(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=""){return function(e,t){return I(e,"attribs")?t in(e.attribs||{}):e.hasAttribute?.(t)??!1}(e,r+t)||I(e.dataset,k(t))}function C(e,t,r){I(e,"attribs")?e.attribs[t]=r:e.setAttribute?.(t,r)}function L(e,t,r){I(e,"attribs")?e.attribs[t]=r:c(R,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){I(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(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);L(t,r,i||"")}}function j(e){if(I(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find((e=>1===e.nodeType))}function F(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 G(e,...t){N(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function K(e,t){return N(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function W(e,t){return N(t,"removeChild")?e.removeChild(t):(G(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function H(e,t,r){return r?N(e,"insertBefore")?e.insertBefore(t,r):(F(r,t,r),t):K(e,t)}function Y(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function B(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map((e=>B(e,t))).join(""):Y(e.outerHTML||e.nodeValue||String(e),t)}function V(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}var Z;!function(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=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)}},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")?L(r,s?"src":"href",c):"img"===n?r.src=c:"a"===n?function(e,t){const r=i(t);void 0!==r&&(e.href=r)}(r,c):"source"===n||"audio"===n||"video"===n||"track"===n||"input"===n?r.src=c:"area"===n?function(e,t){const r=i(t);void 0!==r&&(e.href=r)}(r,c):this.log("Unable to rebase relative path for element:",n)},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),W(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=j(o);if(a)for(const e of Array.from(i.attributes))"div"===n&&"role"===e.name||z(i,a,e.name);const l=new e(O(o)).find((e=>"slot"===e.tagName?.toLowerCase()));l&&F(l,...i.childNodes),F(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)),U(r,"data",":");const n=t?.rootNode===e?this:this.subrenderer();e.renderer=n;const s=n.eval(i,{$elem:e});if(await Promise.all(Object.entries(s).map((([e,t])=>n._store.set(e,t)))),n!==this)for(const t of 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)),U(r,"class",":");const t=T(r,"class")||"";return this.effect((function(){const n=this.eval(i,{$elem:e});L(r,"class",(n?`${t} ${n}`:t).trim())}))}},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)),U(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)),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},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));const n=S(r,"prevent",":");U(r,t.name),U(r,"prevent",":");const s="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,(r=>((n||s)&&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)),U(r,"for",":");for(const t of O(e,this._skipNodes))this._skipNodes.add(t);const n=T(r,"style")||"";C(r,"style","display: none;");const s=e.parentNode,o=this.createElement("template",e.ownerDocument);H(s,o,e),W(s,e),K(o,e),this.log(":for template:\n",B(o,128));const a=i.split(" in ",2);if(2!==a.length)throw new Error(`Invalid :for format: \`${i}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=a;await this.effect((function(){const r=this.eval(h,{$elem:e});if(this.log(":for list items:",r),l.splice(0,l.length).forEach((e=>{W(s,e),this._skipNodes.delete(e)})),!Array.isArray(r))return console.error(`Expression did not yield a list: \`${h}\` => \`${r}\``),Promise.resolve();const i=[];for(const s of r){const r=this.subrenderer();r._store.set(c,s);const o=e.cloneNode(!0);C(o,"style",n),l.push(o),this._skipNodes.add(o),i.push(r.mount(o,t)),this.log("Rendered list child:\n",B(o,128))}const a=o.nextSibling;for(const e of l)H(s,e,a);return Promise.all(i)}))}},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;U(r,"bind",":"),M(r,":bind:on"),M(r,"data-bind-on");const s="checkbox"===T(r,"type")?"checked":"value";i.includes(".")||this.has(i)||this.set(i,""),this.effect((function(){const t=this.eval(i,{$elem:e});"checked"===s?r.checked=!!t:r.value=t}));const o=`${i} = $elem.${s}`;for(const t of n)e.addEventListener(t,(()=>this.eval(o,{$elem:e})))}},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)),U(r,"show",":");const t="none"===r.style?.display?"":r.style?.display??T(r,"style")?.split(";")?.find((e=>"display"===e.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const n=this.eval(i,{$elem:e});r.style?r.style.display=n?t:"none":L(r,"style",`display: ${n?t:"none"};`)}))}},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)),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)}))}}},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)),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 de=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 ue(e,t){const r=e?._store;return r?.has(t)?r.get(t):r?.has("$parent")?ue(r.get("$parent"),t):null}function pe(e,t){const r=e?._store;return r?.has(t)?e:r?.has("$parent")?pe(r.get("$parent"),t):null}class fe extends he{evalkeys=["$elem","$event"];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_observer=null;_store=new Map;_lock=Promise.resolve();constructor(e){super();for(let[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof 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){const r=pe(this,e);if(!r)throw new Error(`Cannot watch key "${e}" as it does not exist in the store.`);r.observers.has(e)||r.observers.set(e,new Set),r.observers.get(e)?.has(t)||r.observers.get(e)?.add(t)}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e).add(t)}async notify(e,t=10){const r=pe(this,e),i=Array.from(r?.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(i.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),ue(this,e)}async set(e,t){if(t===this._store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=pe(e,t);i?i._store.set(t,r):e._store.set(t,r)}(this,e,t);for(const[r,i]of this.keyHandlers.entries())if(r.test(e))for(const r of i)await Promise.resolve(r.call(this.$,e,t));await r()}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e)}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this._store.entries()).map((([e])=>e)),r=Object.fromEntries(t.map((e=>[e,null])));return new Proxy(r,{get:(t,r,i)=>"string"==typeof r&&pe(this,r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes(" = ")){const[r,i]=e.split(" = ");t=r.trim(),e=i.trim()}return(r,i)=>{const n=((e,t)=>new ae(e,t).parse())(e,de),s=n?.getIds([])?.map((e=>[e,i[e]??r[e]??globalThis[e]])),o=n?.evaluate(Object.fromEntries(s||[]));if(!t)return o;!function(e,t,r){const i=t.split(".");for(let t=0;t<i.length-1;t++)i[t]in e||(e[i[t]]={}),e=e[i[t]];e[i[i.length-1]]=r}(r,t,o)}}cachedExpressionFunction(e){return e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e)),this.expressionCache.get(e)}eval(e,t={}){const r=this._observer?this:this.$;if(this._store.has(e))return r[e];{const i=this.cachedExpressionFunction(e);try{return i(r,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}}const me="$$";function _e(e){return`${me}${e}`}function ge(e){return e.keys().filter((e=>e.startsWith(me)))}function $e(e,t,r){const i=function(e){return e.substring(me.length)}(t);let n=!1;if(r){const t=String(r);e.searchParams.get(i)!==t&&(e.searchParams.set(i,t),n=!0)}else e.searchParams.has(i)&&(e.searchParams.delete(i),n=!0);return n}async function we(e){const t=new URL(window.location.href);await async function(e,t){for(const[r,i]of t.searchParams.entries()){const t=_e(r);e.get(t)!==i&&await e.set(t,i)}}(e,t),function(e,t){let r=!1;for(const i of ge(t))$e(e,i,t.get(i))&&(r=!0);r&&window.history.replaceState({},"",e.toString())}(t,e),e.addKeyHandler(new RegExp("^\\$\\$"),((e,t)=>{const r=new URL(window.location.href);$e(r,e,t)&&window.history.replaceState({},"",r.toString())})),window.addEventListener("popstate",function(e){return async()=>{const t=new URL(window.location.href),r=new Set;for(const[i,n]of t.searchParams.entries()){const t=_e(i);r.add(t),e.get(t)!==n&&e.set(t,n)}const i=ge(e);for(const t of i)r.has(t)||e.del(t)}}(e))}class ve 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(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 Z.resolveIncludes.call(this,e,r),await Z.rebaseRelativePaths.call(this,e,r),await Z.registerCustomElements.call(this,e,r),await Z.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 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),this.has("$rootRenderer")||this._store.set("$rootRenderer",this),this.get("$rootRenderer")===this&&await we(this),await this.preprocessNode(e,t),await this.renderNode(e,t)}}function xe(){return u([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(p).join(""))}const be={sm:640,md:768,lg:1024,xl:1280},Ee=.25,ye=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],Ae=[...ye,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(be)],Re=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],Oe=[75,100,150,200,300,500,700,1e3],Ie=["hover","focus","disabled","active"],Ne={margin:"m",padding:"p"},ke={width:"w",height:"h"},Te={top:"top",right:"right",bottom:"bottom",left:"left"},Pe={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},Se={"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"}},Ce=["@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 }"],Le={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 De(e){return`#${e.toString(16).padStart(6,"0")}`}function Me(e){return Ie.map((t=>`.${t}\\:${e}:${t}`))}function Ue(e,t){return Object.entries(be).map((([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`))}function ze(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function je(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100vw`],[`${t}-full`,`${e}: 100%`],...Ae.map((r=>[`${t}-${r}`,`${e}: ${r*Ee}rem`])),...Ae.map((r=>[`-${t}-${r}`,`${e}: -${r*Ee}rem`])),...Ae.map((r=>[`${t}-${r}px`,`${e}: ${r}px`])),...Ae.map((r=>[`-${t}-${r}px`,`${e}: -${r}px`])),...Re.map((r=>[`${t}-${r}\\%`,`${e}: ${r}%`])),...Re.map((r=>[`-${t}-${r}\\%`,`${e}: -${r}%`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Me(e).join(",")} { ${t} }`,...Ue(e,t)]))}function Fe(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;`],...Ae.map((e=>[e,e*Ee])).map((([r,i])=>[`${t}x-${r}`,`${e}-left: ${i}rem; ${e}-right: ${i}rem;`])),...Ae.map((e=>[e,e*Ee])).map((([r,i])=>[`${t}y-${r}`,`${e}-top: ${i}rem; ${e}-bottom: ${i}rem;`])),...Ae.map((r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`])),...Ae.map((r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`])),...Re.map((r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`])),...Re.map((r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Me(e).join(",")} { ${t} }`,...Ue(e,t)]))}function Ge(){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(Le).flatMap((([e,t])=>[[`text-${e}`,`color: ${De(t[500])}`],[`fill-${e}`,`fill: ${De(t[500])}`],[`bg-${e}`,`background-color: ${De(t[500])}`],[`border-${e}`,`border-color: ${De(t[500])}`]])),r=Object.entries(Le).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[[`text-${e}-${t}`,`color: ${De(r)}`],[`fill-${e}-${t}`,`fill: ${De(r)}`],[`bg-${e}-${t}`,`background-color: ${De(r)}`],[`border-${e}-${t}`,`border-color: ${De(r)}`]]))));return[].concat(e).concat(t).concat(r).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Me(e).join(",")} { ${t} }`,...Ue(e,t)]))}function Ke(){return[...Ce,...Object.entries(Se).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[`.${e} { ${t}: ${r} }`,`${Me(e).join(",")} { ${t}: ${r} }`,...Ue(e,`${t}: ${r}`)])))),...Ge(),...[["opacity-0","opacity: 0"],...Re.map((e=>[`opacity-${e}`,"opacity: "+e/100]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Me(e).join(",")} { ${t} }`,...Ue(e,t)])),...[...Re.map((e=>[`z-${e}`,`z-index: ${e}`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Me(e).join(",")} { ${t} }`,...Ue(e,t)])),...[...Oe.map((e=>[`duration-${e}`,`transition-duration: ${e}ms`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Me(e).join(",")} { ${t} }`,...Ue(e,t)])),...je(Te),...je(ke),...Fe(ke),...(e=Ne,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=>[...Ae.map((e=>[e,e*Ee])).map((([i,n])=>[`${r}${t}t-${i}`,`${e}-top: ${r}${n}rem`])),...Ae.map((e=>[e,e*Ee])).map((([i,n])=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${n}rem`])),...Ae.map((e=>[e,e*Ee])).map((([i,n])=>[`${r}${t}l-${i}`,`${e}-left: ${r}${n}rem`])),...Ae.map((e=>[e,e*Ee])).map((([i,n])=>[`${r}${t}r-${i}`,`${e}-right: ${r}${n}rem`])),...Ae.map((i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`])),...Ae.map((i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`])),...Ae.map((i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`])),...Ae.map((i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`])),...Re.map((i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`])),...Re.map((i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%;`])),...Re.map((i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`])),...Re.map((i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`]))]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Me(e).join(",")} { ${t} }`,...Ue(e,t)]))),...je(Ne),...Fe(Ne),...[["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...Ae.map((e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*Ee}rem`])),...Ae.map((e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*Ee}rem`])),...Ae.map((e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`])),...Ae.map((e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`])),["gap-0","gap: 0"],...Ae.map((e=>[`gap-${e}`,`gap: ${e*Ee}rem`])),...Ae.map((e=>[`gap-${e}px`,`gap: ${e}px`])),...Ae.map((e=>[`gap-x-${e}`,`column-gap: ${e*Ee}rem`])),...Ae.map((e=>[`gap-y-${e}`,`row-gap: ${e*Ee}rem`])),...Ae.map((e=>[`gap-x-${e}px`,`column-gap: ${e}px`])),...Ae.map((e=>[`gap-y-${e}px`,`row-gap: ${e}px`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Me(e).join(",")} { ${t} }`,...Ue(e,t)])),...je(Pe),...[["border","border: 1px"],["border-x","border-inline-width: 1px"],["border-y","border-block-width: 1px"],...[0,...ye].map((e=>[`border-${e}`,`border-width: ${e}px`])),...[0,...ye].map((e=>[`border-x-${e}`,`border-inline-width: ${e}px;`])),...[0,...ye].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,...ye].map((t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`]))]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Me(e).join(",")} { ${t} }`,...Ue(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*Ee)).map((e=>[`text-${e}rem`,`font-size: ${e}rem`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Me(e).join(",")} { ${t} }`,...Ue(e,t)]))].sort(ze).join("\n");var e}class We extends ve{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}}const He=new We;export{He as Mancha,We as Renderer,xe as basicCssRules,Ke 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 d(e){return new u(e,n)}function p(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 w{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 x=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],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 w(new Set(x),new Map(b),new Set(E),new Map(y)),new w(new Set(v((()=>x.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 d(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=""){return function(e,t){return I(e,"attribs")?t in(e.attribs||{}):e.hasAttribute?.(t)??!1}(e,r+t)||I(e.dataset,k(t))}function C(e,t,r){I(e,"attribs")?e.attribs[t]=r:e.setAttribute?.(t,r)}function L(e,t,r){I(e,"attribs")?e.attribs[t]=r:c(R,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){I(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(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);L(t,r,i||"")}}function j(e){if(I(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find((e=>1===e.nodeType))}function F(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 G(e,...t){N(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function K(e,t){return N(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function W(e,t){return N(t,"removeChild")?e.removeChild(t):(G(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function H(e,t,r){return r?N(e,"insertBefore")?e.insertBefore(t,r):(F(r,t,r),t):K(e,t)}function Y(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function B(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map((e=>B(e,t))).join(""):Y(e.outerHTML||e.nodeValue||String(e),t)}function V(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}var Z;!function(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=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)}},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")?L(r,s?"src":"href",c):"img"===n?r.src=c:"a"===n?function(e,t){const r=i(t);void 0!==r&&(e.href=r)}(r,c):"source"===n||"audio"===n||"video"===n||"track"===n||"input"===n?r.src=c:"area"===n?function(e,t){const r=i(t);void 0!==r&&(e.href=r)}(r,c):this.log("Unable to rebase relative path for element:",n)},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),W(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=j(o);if(a)for(const e of Array.from(i.attributes))"div"===n&&"role"===e.name||z(i,a,e.name);const l=new e(O(o)).find((e=>"slot"===e.tagName?.toLowerCase()));l&&F(l,...i.childNodes),F(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)),U(r,"data",":");const n=t?.rootNode===e?this:this.subrenderer();e.renderer=n;const s=n.eval(i,{$elem:e});if(await Promise.all(Object.entries(s).map((([e,t])=>n._store.set(e,t)))),n!==this)for(const t of 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)),U(r,"class",":");const t=T(r,"class")||"";return this.effect((function(){const n=this.eval(i,{$elem:e});L(r,"class",(n?`${t} ${n}`:t).trim())}))}},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)),U(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)),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},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));const n=S(r,"prevent",":");U(r,t.name),U(r,"prevent",":");const s="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,(r=>((n||s)&&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)),U(r,"for",":");for(const t of O(e,this._skipNodes))this._skipNodes.add(t);const n=T(r,"style")||"";C(r,"style","display: none;");const s=e.parentNode,o=this.createElement("template",e.ownerDocument);H(s,o,e),W(s,e),K(o,e),this.log(":for template:\n",B(o,128));const a=i.split(" in ",2);if(2!==a.length)throw new Error(`Invalid :for format: \`${i}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=a;await this.effect((function(){const r=this.eval(h,{$elem:e});if(this.log(":for list items:",r),l.splice(0,l.length).forEach((e=>{W(s,e),this._skipNodes.delete(e)})),!Array.isArray(r))return console.error(`Expression did not yield a list: \`${h}\` => \`${r}\``),Promise.resolve();const i=[];for(const s of r){const r=this.subrenderer();r._store.set(c,s);const o=e.cloneNode(!0);C(o,"style",n),l.push(o),this._skipNodes.add(o),i.push(r.mount(o,t)),this.log("Rendered list child:\n",B(o,128))}const a=o.nextSibling;for(const e of l)H(s,e,a);return Promise.all(i)}))}},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;U(r,"bind",":"),M(r,":bind:on"),M(r,"data-bind-on");const s="checkbox"===T(r,"type")?"checked":"value";i.includes(".")||this.has(i)||this.set(i,""),this.effect((function(){const t=this.eval(i,{$elem:e});"checked"===s?r.checked=!!t:r.value=t}));const o=`${i} = $elem.${s}`;for(const t of n)e.addEventListener(t,(()=>this.eval(o,{$elem:e})))}},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)),U(r,"show",":");const t="none"===r.style?.display?"":r.style?.display??T(r,"style")?.split(";")?.find((e=>"display"===e.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const n=this.eval(i,{$elem:e});r.style?r.style.display=n?t:"none":L(r,"style",`display: ${n?t:"none"};`)}))}},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)),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)}))}}},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)),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){const r=e?._store;return r?.has(t)?r.get(t):r?.has("$parent")?de(r.get("$parent"),t):null}function pe(e,t){const r=e?._store;return r?.has(t)?e:r?.has("$parent")?pe(r.get("$parent"),t):null}class fe extends he{evalkeys=["$elem","$event"];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_observer=null;_store=new Map;_lock=Promise.resolve();constructor(e){super();for(let[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof 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){const r=pe(this,e);if(!r)throw new Error(`Cannot watch key "${e}" as it does not exist in the store.`);r.observers.has(e)||r.observers.set(e,new Set),r.observers.get(e)?.has(t)||r.observers.get(e)?.add(t)}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e).add(t)}async notify(e,t=10){const r=pe(this,e),i=Array.from(r?.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(i.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),de(this,e)}async set(e,t){if(t===this._store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=pe(e,t);i?i._store.set(t,r):e._store.set(t,r)}(this,e,t);for(const[r,i]of this.keyHandlers.entries())if(r.test(e))for(const r of i)await Promise.resolve(r.call(this.$,e,t));await r()}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e)}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this._store.entries()).map((([e])=>e)),r=Object.fromEntries(t.map((e=>[e,null])));return new Proxy(r,{get:(t,r,i)=>"string"==typeof r&&pe(this,r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes(" = ")){const[r,i]=e.split(" = ");t=r.trim(),e=i.trim()}return(r,i)=>{const n=((e,t)=>new 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}}}}const me="$$",_e="http://localhost/";function ge(){return new URL(globalThis.window?.location?.href||_e)}function $e(e){return`${me}${e}`}function ve(e){return e.keys().filter((e=>e.startsWith(me)))}function we(e,t,r){const i=function(e){return e.substring(me.length)}(t);let n=!1;if(r){const t=String(r);e.searchParams.get(i)!==t&&(e.searchParams.set(i,t),n=!0)}else e.searchParams.has(i)&&(e.searchParams.delete(i),n=!0);return n}async function xe(e){const t=ge();await async function(e,t){for(const[r,i]of t.searchParams.entries()){const t=$e(r);e.get(t)!==i&&await e.set(t,i)}}(e,t),function(e,t){let r=!1;for(const i of ve(t))we(e,i,t.get(i))&&(r=!0);r&&globalThis.window?.history?.replaceState({},"",e.toString())}(t,e),e.addKeyHandler(new RegExp("^\\$\\$"),((e,t)=>{const r=ge();we(r,e,t)&&globalThis.window?.history?.replaceState({},"",r.toString())})),globalThis.window?.addEventListener("popstate",function(e){return async()=>{const t=ge(),r=new Set;for(const[i,n]of t.searchParams.entries()){const t=$e(i);r.add(t),e.get(t)!==n&&e.set(t,n)}const i=ve(e);for(const t of i)r.has(t)||e.del(t)}}(e))}class be 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(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 Z.resolveIncludes.call(this,e,r),await Z.rebaseRelativePaths.call(this,e,r),await Z.registerCustomElements.call(this,e,r),await Z.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 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),this.has("$rootRenderer")||this._store.set("$rootRenderer",this),this.get("$rootRenderer")===this&&await xe(this),await this.preprocessNode(e,t),await this.renderNode(e,t)}}function Ee(){return d([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(p).join(""))}const ye={sm:640,md:768,lg:1024,xl:1280},Ae=.25,Re=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],Oe=[...Re,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(ye)],Ie=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],Ne=[75,100,150,200,300,500,700,1e3],ke=["hover","focus","disabled","active"],Te={margin:"m",padding:"p"},Pe={width:"w",height:"h"},Se={top:"top",right:"right",bottom:"bottom",left:"left"},Ce={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},Le={"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"}},De=["@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 }"],Me={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 Ue(e){return`#${e.toString(16).padStart(6,"0")}`}function ze(e){return ke.map((t=>`.${t}\\:${e}:${t}`))}function je(e,t){return Object.entries(ye).map((([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`))}function Fe(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function Ge(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100vw`],[`${t}-full`,`${e}: 100%`],...Oe.map((r=>[`${t}-${r}`,`${e}: ${r*Ae}rem`])),...Oe.map((r=>[`-${t}-${r}`,`${e}: -${r*Ae}rem`])),...Oe.map((r=>[`${t}-${r}px`,`${e}: ${r}px`])),...Oe.map((r=>[`-${t}-${r}px`,`${e}: -${r}px`])),...Ie.map((r=>[`${t}-${r}\\%`,`${e}: ${r}%`])),...Ie.map((r=>[`-${t}-${r}\\%`,`${e}: -${r}%`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${ze(e).join(",")} { ${t} }`,...je(e,t)]))}function Ke(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-auto`,`${e}: auto`],[`${t}x-auto`,`${e}-left: auto; ${e}-right: auto;`],[`${t}y-auto`,`${e}-top: auto; ${e}-bottom: auto;`],[`${t}x-0`,`${e}-left: 0; ${e}-right: 0;`],[`${t}y-0`,`${e}-top: 0; ${e}-bottom: 0;`],...Oe.map((e=>[e,e*Ae])).map((([r,i])=>[`${t}x-${r}`,`${e}-left: ${i}rem; ${e}-right: ${i}rem;`])),...Oe.map((e=>[e,e*Ae])).map((([r,i])=>[`${t}y-${r}`,`${e}-top: ${i}rem; ${e}-bottom: ${i}rem;`])),...Oe.map((r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`])),...Oe.map((r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`])),...Ie.map((r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`])),...Ie.map((r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${ze(e).join(",")} { ${t} }`,...je(e,t)]))}function We(){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(Me).flatMap((([e,t])=>[[`text-${e}`,`color: ${Ue(t[500])}`],[`fill-${e}`,`fill: ${Ue(t[500])}`],[`bg-${e}`,`background-color: ${Ue(t[500])}`],[`border-${e}`,`border-color: ${Ue(t[500])}`]])),r=Object.entries(Me).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[[`text-${e}-${t}`,`color: ${Ue(r)}`],[`fill-${e}-${t}`,`fill: ${Ue(r)}`],[`bg-${e}-${t}`,`background-color: ${Ue(r)}`],[`border-${e}-${t}`,`border-color: ${Ue(r)}`]]))));return[].concat(e).concat(t).concat(r).flatMap((([e,t])=>[`.${e} { ${t} }`,`${ze(e).join(",")} { ${t} }`,...je(e,t)]))}function He(){return[...De,...Object.entries(Le).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[`.${e} { ${t}: ${r} }`,`${ze(e).join(",")} { ${t}: ${r} }`,...je(e,`${t}: ${r}`)])))),...We(),...[["opacity-0","opacity: 0"],...Ie.map((e=>[`opacity-${e}`,"opacity: "+e/100]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${ze(e).join(",")} { ${t} }`,...je(e,t)])),...[...Ie.map((e=>[`z-${e}`,`z-index: ${e}`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${ze(e).join(",")} { ${t} }`,...je(e,t)])),...[...Ne.map((e=>[`duration-${e}`,`transition-duration: ${e}ms`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${ze(e).join(",")} { ${t} }`,...je(e,t)])),...Ge(Se),...Ge(Pe),...Ke(Pe),...(e=Te,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=>[...Oe.map((e=>[e,e*Ae])).map((([i,n])=>[`${r}${t}t-${i}`,`${e}-top: ${r}${n}rem`])),...Oe.map((e=>[e,e*Ae])).map((([i,n])=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${n}rem`])),...Oe.map((e=>[e,e*Ae])).map((([i,n])=>[`${r}${t}l-${i}`,`${e}-left: ${r}${n}rem`])),...Oe.map((e=>[e,e*Ae])).map((([i,n])=>[`${r}${t}r-${i}`,`${e}-right: ${r}${n}rem`])),...Oe.map((i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`])),...Oe.map((i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`])),...Oe.map((i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`])),...Oe.map((i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`])),...Ie.map((i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`])),...Ie.map((i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%;`])),...Ie.map((i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`])),...Ie.map((i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`]))]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${ze(e).join(",")} { ${t} }`,...je(e,t)]))),...Ge(Te),...Ke(Te),...[["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...Oe.map((e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*Ae}rem`])),...Oe.map((e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*Ae}rem`])),...Oe.map((e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`])),...Oe.map((e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`])),["gap-0","gap: 0"],...Oe.map((e=>[`gap-${e}`,`gap: ${e*Ae}rem`])),...Oe.map((e=>[`gap-${e}px`,`gap: ${e}px`])),...Oe.map((e=>[`gap-x-${e}`,`column-gap: ${e*Ae}rem`])),...Oe.map((e=>[`gap-y-${e}`,`row-gap: ${e*Ae}rem`])),...Oe.map((e=>[`gap-x-${e}px`,`column-gap: ${e}px`])),...Oe.map((e=>[`gap-y-${e}px`,`row-gap: ${e}px`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${ze(e).join(",")} { ${t} }`,...je(e,t)])),...Ge(Ce),...[["border","border: 1px"],["border-x","border-inline-width: 1px"],["border-y","border-block-width: 1px"],...[0,...Re].map((e=>[`border-${e}`,`border-width: ${e}px`])),...[0,...Re].map((e=>[`border-x-${e}`,`border-inline-width: ${e}px;`])),...[0,...Re].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,...Re].map((t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`]))]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${ze(e).join(",")} { ${t} }`,...je(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*Ae)).map((e=>[`text-${e}rem`,`font-size: ${e}rem`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${ze(e).join(",")} { ${t} }`,...je(e,t)]))].sort(Fe).join("\n");var e}class Ye extends be{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}}const Be=new Ye;export{Be as Mancha,Ye as Renderer,Ee as basicCssRules,He 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 d(e){return new h(e,i)}function u(e){if(e instanceof h)return e.privateDoNotAccessOrElseWrappedStyleSheet;throw new Error("")}function p(e,t){e.textContent=u(t)}Error;class f{iterable;constructor(e){this.iterable=e}filter(e){return new f(f.filterGenerator(e,this.iterable))}map(e){return new f(f.mapGenerator(e,this.iterable))}find(e){for(const t of this.iterable)if(e(t))return t}array(){return Array.from(this.iterable)}*generator(){for(const e of this.iterable)yield e}static*filterGenerator(e,t){for(const r of t)e(r)&&(yield r)}static*mapGenerator(e,t){for(const r of t)yield e(r)}static equals(e,t){const r=e[Symbol.iterator](),i=t[Symbol.iterator]();let n=r.next(),s=i.next();for(;!n.done&&!s.done;){if(n.value!==s.value)return!1;n=r.next(),s=i.next()}return n.done===s.done}}function m(e){return Object.isFrozen(e)&&Object.isFrozen(e.raw)}function _(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 $,w;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"}($||($={}));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:w.KEEP};const i=this.globalAttributePolicies.get(e);return i||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((t=>0===e.indexOf(t)))?{policyAction:w.KEEP}:{policyAction:w.DROP})}}!function(e){e[e.DROP=0]="DROP",e[e.KEEP=1]="KEEP",e[e.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",e[e.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",e[e.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}(w||(w={}));new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const b=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],E=[["A",new Map([["href",{policyAction:w.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:w.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],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:w.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:w.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:w.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:w.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:w.KEEP_AND_SANITIZE_URL}],["target",{policyAction:w.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["target",new Set(["_self","_blank"])]])))}]];new x(new Set(b),new Map(E),new Set(y),new Map(A)),new x(new Set(v((()=>b.concat(["STYLE"])))),new Map(E),new Set(v((()=>y.concat(["id","name","class"])))),new Map(v((()=>A.concat([["style",{policyAction:w.KEEP_AND_SANITIZE_STYLE}]])))));function R(e){return d(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 k(e,t){return"function"==typeof e?.[t]}function T(e){return e.replace(/-./g,(e=>e[1].toUpperCase()))}function S(e,t){return N(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function P(e,t,r=""){return S(e,r+t)||(e.dataset?.[T(t)]??null)}function C(e,t,r=""){return function(e,t){return N(e,"attribs")?t in(e.attribs||{}):e.hasAttribute?.(t)??!1}(e,r+t)||N(e.dataset,T(t))}function L(e,t,r){N(e,"attribs")?e.attribs[t]=r:e.setAttribute?.(t,r)}function D(e,t,r){N(e,"attribs")?e.attribs[t]=r:l(O,e,t,r)}function M(e,t,r){switch(t){case"disabled":return void(e.disabled=r);case"selected":return void(e.selected=r);case"checked":return void(e.checked=r);default:e[t]=r}}function U(e,t){N(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function z(e,t,r=""){U(e,`${r}${t}`),U(e,`data-${t}`)}function j(e,t,r){if(N(e,"attribs")&&N(t,"attribs"))t.attribs[r]=e.attribs[r];else if(r.startsWith("data-")){const i=T(r.slice(5));t.dataset[i]=e.dataset?.[i]}else{const i=e?.getAttribute?.(r);D(t,r,i||"")}}function F(e){if(N(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find((e=>1===e.nodeType))}function G(e,...t){if(k(e,"replaceWith"))return e.replaceWith(...t);{const r=e,i=r.parentNode,n=Array.from(i.childNodes).indexOf(r);t.forEach((e=>e.parentNode=i)),i.childNodes=[].concat(Array.from(i.childNodes).slice(0,n)).concat(t).concat(Array.from(i.childNodes).slice(n+1))}}function K(e,...t){k(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function W(e,t){return k(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function H(e,t){return k(t,"removeChild")?e.removeChild(t):(K(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function Y(e,t,r){return r?k(e,"insertBefore")?e.insertBefore(t,r):(G(r,t,r),t):W(e,t)}function B(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function V(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map((e=>V(e,t))).join(""):B(e.outerHTML||e.nodeValue||String(e),t)}function Z(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}var q;!function(e){e.resolveIncludes=async function(e,t){const r=e,i=r.tagName?.toLowerCase();if(!["include","link"].includes(i))return;if("link"===i&&"subresource"!==S(r,"rel"))return;this.log("include directive found in:\n",V(e,128)),this.log("include params:",t);const n="link"===r.tagName.toLocaleLowerCase()?"href":"src",s=S(r,n);if(!s)throw new Error(`"${n}" attribute missing from ${V(e,128)}.`);const o=[];"include"===i&&o.push("src"),"link"===i&&o.push("rel","href");const a=t=>{const i=F(t);for(const e of Array.from(r.attributes))i&&!o.includes(e.name)&&j(r,i,e.name);G(e,...t.childNodes)},l={...t,rootDocument:!1,maxdepth:t?.maxdepth-1};if(0===l.maxdepth)throw new Error("Maximum recursion depth reached.");if(s.includes("://")||s.startsWith("//"))this.log("Including remote file from absolute path:",s),await this.preprocessRemote(s,l).then(a);else if(t?.dirpath?.includes("://")||t?.dirpath?.startsWith("//")){const e=s.startsWith("/")?s:`${t.dirpath}/${s}`;this.log("Including remote file from relative path:",e),await this.preprocessRemote(e,l).then(a)}else if("/"===s.charAt(0))this.log("Including local file from absolute path:",s),await this.preprocessLocal(s,l).then(a);else{const e=t?.dirpath&&"."!==t?.dirpath?`${t?.dirpath}/${s}`:s;this.log("Including local file from relative path:",e),await this.preprocessLocal(e,l).then(a)}},e.rebaseRelativePaths=async function(e,t){const 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")?D(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`,V(r,128)),this._customElements.set(n,r),H(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`,V(r,128));const t=this._customElements.get(n),s=(t.content||t).cloneNode(!0),o=F(s);if(o)for(const e of Array.from(r.attributes))"div"===i&&"role"===e.name||j(r,o,e.name);const a=new f(I(s)).find((e=>"slot"===e.tagName?.toLowerCase()));a&&G(a,...r.childNodes),G(e,...s.childNodes)}},e.resolveTextNodeExpressions=async function(e,t){const r=e.nodeValue||"";if(3!==e.nodeType||!r?.trim())return;this.log("Processing node content value:\n",B(r,128));const i=new RegExp(/{{ ([^}]+) }}/gm),n=Array.from(r.matchAll(i)).map((e=>e[1]));return this.effect((function(){let t=r;for(const r of n){const i=this.eval(r,{$elem:e});t=t.replace(`{{ ${r} }}`,String(i))}e.nodeValue=t}))},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"data",":");if(i){this.log(":data attribute found in:\n",V(e,128)),z(r,"data",":");const n=t?.rootNode===e?this:this.subrenderer();e.renderer=n;const s=n.eval(i,{$elem:e});if(await Promise.all(Object.entries(s).map((([e,t])=>n._store.set(e,t)))),n!==this)for(const t of 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",V(e,128)),z(r,"class",":");const t=S(r,"class")||"";return this.effect((function(){const n=this.eval(i,{$elem:e});D(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",V(e,128)),z(r,"text",":");const t=t=>this.textContent(e,t);return this.effect((function(){t(this.eval(i,{$elem:e}))}))}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"html",":");return i?(this.log(":html attribute found in:\n",V(e,128)),z(r,"html",":"),this.effect((function(){const n=this.eval(i,{$elem:e});return new Promise((async e=>{const i=await this.preprocessString(n,t);await this.renderNode(i),K(r,i),e()}))}))):void 0},e.resolveEventAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){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",V(e,128));const n=C(r,"prevent",":");z(r,t.name),z(r,"prevent",":");const s="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,(r=>((n||s)&&r.preventDefault(),this.eval(t.value,{$elem:e,$event:r}))))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"for",":")?.trim();if(i){this.log(":for attribute found in:\n",V(e,128)),z(r,"for",":");for(const t of I(e,this._skipNodes))this._skipNodes.add(t);const n=S(r,"style")||"";L(r,"style","display: none;");const s=e.parentNode,o=this.createElement("template",e.ownerDocument);Y(s,o,e),H(s,e),W(o,e),this.log(":for template:\n",V(o,128));const a=i.split(" in ",2);if(2!==a.length)throw new Error(`Invalid :for format: \`${i}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=a;await this.effect((function(){const r=this.eval(h,{$elem:e});if(this.log(":for list items:",r),l.splice(0,l.length).forEach((e=>{H(s,e),this._skipNodes.delete(e)})),!Array.isArray(r))return console.error(`Expression did not yield a list: \`${h}\` => \`${r}\``),Promise.resolve();const i=[];for(const s of r){const r=this.subrenderer();r._store.set(c,s);const o=e.cloneNode(!0);L(o,"style",n),l.push(o),this._skipNodes.add(o),i.push(r.mount(o,t)),this.log("Rendered list child:\n",V(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",V(e,128));const t=["change","input"],n=S(r,":bind:on")?.split(",")||r.dataset?.bindOn?.split(",")||t;z(r,"bind",":"),U(r,":bind:on"),U(r,"data-bind-on");const s="checkbox"===S(r,"type")?"checked":"value";i.includes(".")||this.has(i)||this.set(i,""),this.effect((function(){const t=this.eval(i,{$elem:e});"checked"===s?r.checked=!!t:r.value=t}));const o=`${i} = $elem.${s}`;for(const t of n)e.addEventListener(t,(()=>this.eval(o,{$elem:e})))}},e.resolveShowAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"show",":");if(i){this.log(":show attribute found in:\n",V(e,128)),z(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":D(r,"style",`display: ${n?t:"none"};`)}))}},e.resolveCustomAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":attr:",n="data-attr-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"attribute found in:\n",V(e,128)),U(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1);this.effect((function(){const i=this.eval(t.value,{$elem:e});L(r,s,i)}))}}},e.resolveCustomProperty=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":prop:",n="data-prop-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"property found in:\n",V(e,128)),U(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1),o=T(s);this.effect((function(){const i=this.eval(t.value,{$elem:e});M(r,o,i)}))}}}}(q||(q={}));const Q=["this"],X=["+","-","!"],J=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],ee={"!":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},te=["==","!=","<=",">=","||","&&","??","|>"],re=["===","!=="];var ie;!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"}(ie||(ie={}));const ne=(e,t,r=0)=>({kind:e,value:t,precedence:r}),se=e=>95===e||36===e||65<=(e&=-33)&&e<=90,oe=e=>48<=e&&e<=57;class ae{_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(se(this._next))return this._tokenizeIdentOrKeyword();if(oe(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=ne(ie.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,se(e)||oe(e));var e;const t=this._getValue(),r=(i=t,-1!==Q.indexOf(i)?ie.KEYWORD:ie.IDENTIFIER);var i;return ne(r,t)}_tokenizeNumber(){do{this._advance()}while(oe(this._next));return 46===this._next?this._tokenizeDot():ne(ie.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),oe(this._next)?this._tokenizeFraction():(this._clearValue(),ne(ie.DOT,".",13))}_tokenizeComma(){return this._advance(!0),ne(ie.COMMA,",")}_tokenizeColon(){return this._advance(!0),ne(ie.COLON,":")}_tokenizeFraction(){do{this._advance()}while(oe(this._next));return ne(ie.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(-1!==re.indexOf(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),ne(ie.ARROW,e);-1!==te.indexOf(e)&&this._advance()}return e=this._getValue(),ne(ie.OPERATOR,e,ee[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=ne(ie.GROUPER,e,ee[e]);return this._advance(!0),t}}class le{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new ae(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(ie.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(ie.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(ie.DOT)){this._advance();const t=this._parseUnary();e=this._makeInvokeOrGetter(e,t)}else{if(this._matches(ie.KEYWORD))break;if(!(this._matches(ie.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===J.indexOf(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let r=this._parseUnary();for(;(this._kind===ie.OPERATOR||this._kind===ie.DOT||this._kind===ie.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(ie.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(ie.INTEGER))return this._parseInteger(e);if(this._matches(ie.DECIMAL))return this._parseDecimal(e)}if(-1===X.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(ie.OPERATOR,"?");const t=this._parseExpression();this._advance(ie.COLON);const r=this._parseExpression();return this._ast.ternary(e,t,r)}_parsePrimary(){switch(this._kind){case ie.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 ie.IDENTIFIER:return this._parseInvokeOrIdentifier();case ie.STRING:return this._parseString();case ie.INTEGER:return this._parseInteger();case ie.DECIMAL:return this._parseDecimal();case ie.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case ie.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(ie.GROUPER,"]"))break;e.push(this._parseExpression())}while(this._matches(ie.COMMA));return this._advance(ie.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e={};do{if(this._advance(),this._matches(ie.GROUPER,"}"))break;const t=this._value;(this._matches(ie.STRING)||this._matches(ie.IDENTIFIER))&&this._advance(),this._advance(ie.COLON),e[t]=this._parseExpression()}while(this._matches(ie.COMMA));return this._advance(ie.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(ie.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(ie.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(ie.GROUPER,")"))break;const t=this._parseExpression();e.push(t)}while(this._matches(ie.COMMA));return this._advance(ie.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(ie.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(ie.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 ce={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>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)},he={"+":e=>e,"-":e=>-e,"!":e=>!e};class de{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=he[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=ce[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 pe(e,t){const r=e?._store;return r?.has(t)?r.get(t):r?.has("$parent")?pe(r.get("$parent"),t):null}function fe(e,t){const r=e?._store;return r?.has(t)?e:r?.has("$parent")?fe(r.get("$parent"),t):null}class me extends de{evalkeys=["$elem","$event"];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_observer=null;_store=new Map;_lock=Promise.resolve();constructor(e){super();for(let[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof me||r.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>r in e&&(delete e[r],t(),!0),set:(r,i,n,s)=>{"object"==typeof n&&null!=e&&(n=this.wrapObject(n,t));const o=Reflect.set(r,i,n,s);return t(),o},get:(e,t,r)=>"__is_proxy__"===t||Reflect.get(e,t,r)});var r}watch(e,t){const r=fe(this,e);if(!r)throw new Error(`Cannot watch key "${e}" as it does not exist in the store.`);r.observers.has(e)||r.observers.set(e,new Set),r.observers.get(e)?.has(t)||r.observers.get(e)?.add(t)}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e).add(t)}async notify(e,t=10){const r=fe(this,e),i=Array.from(r?.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(i.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),pe(this,e)}async set(e,t){if(t===this._store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=fe(e,t);i?i._store.set(t,r):e._store.set(t,r)}(this,e,t);for(const[r,i]of this.keyHandlers.entries())if(r.test(e))for(const r of i)await Promise.resolve(r.call(this.$,e,t));await r()}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e)}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this._store.entries()).map((([e])=>e)),r=Object.fromEntries(t.map((e=>[e,null])));return new Proxy(r,{get:(t,r,i)=>"string"==typeof r&&fe(this,r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes(" = ")){const[r,i]=e.split(" = ");t=r.trim(),e=i.trim()}return(r,i)=>{const n=((e,t)=>new le(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}}}}const _e="$$";function ge(e){return`${_e}${e}`}function $e(e){return e.keys().filter((e=>e.startsWith(_e)))}function we(e,t,r){const i=function(e){return e.substring(_e.length)}(t);let n=!1;if(r){const t=String(r);e.searchParams.get(i)!==t&&(e.searchParams.set(i,t),n=!0)}else e.searchParams.has(i)&&(e.searchParams.delete(i),n=!0);return n}async function ve(e){const t=new URL(window.location.href);await async function(e,t){for(const[r,i]of t.searchParams.entries()){const t=ge(r);e.get(t)!==i&&await e.set(t,i)}}(e,t),function(e,t){let r=!1;for(const i of $e(t))we(e,i,t.get(i))&&(r=!0);r&&window.history.replaceState({},"",e.toString())}(t,e),e.addKeyHandler(new RegExp("^\\$\\$"),((e,t)=>{const r=new URL(window.location.href);we(r,e,t)&&window.history.replaceState({},"",r.toString())})),window.addEventListener("popstate",function(e){return async()=>{const t=new URL(window.location.href),r=new Set;for(const[i,n]of t.searchParams.entries()){const t=ge(i);r.add(t),e.get(t)!==n&&e.set(t,n)}const i=$e(e);for(const t of i)r.has(t)||e.del(t)}}(e))}class xe extends me{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(e){return this.debugging=e,this}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??"default"}).then((e=>e.text()))}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log("Preprocessing string content with params:\n",t);const r=this.parseHTML(e,t);return await this.preprocessNode(r,t),r}async preprocessRemote(e,t){const r={};t?.cache&&(r.cache=t.cache);const i=await fetch(e,r).then((e=>e.text()));return this.preprocessString(i,{...t,dirpath:Z(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}async preprocessLocal(e,t){const r=await this.fetchLocal(e,t);return this.preprocessString(r,{...t,dirpath:Z(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}subrenderer(){const e=(new this.constructor).debug(this.debugging);return e._store.set("$parent",this),e._store.set("$rootRenderer",this.get("$rootRenderer")??this),e._customElements=this._customElements,e}log(...e){this.debugging&&console.debug(...e)}async preprocessNode(e,t){t={dirpath:this.dirpath,maxdepth:10,...t};const r=new f(I(e,this._skipNodes)).map((async e=>{this.log("Preprocessing node:\n",V(e,128)),await q.resolveIncludes.call(this,e,t),await q.rebaseRelativePaths.call(this,e,t),await q.registerCustomElements.call(this,e,t),await q.resolveCustomElements.call(this,e,t)}));return await Promise.all(r.generator()),e}async renderNode(e,t){for(const r of I(e,this._skipNodes))this.log("Rendering node:\n",V(r,128)),await q.resolveForAttribute.call(this,r,t),await q.resolveDataAttribute.call(this,r,t),await q.resolveTextAttributes.call(this,r,t),await q.resolveHtmlAttribute.call(this,r,t),await q.resolveShowAttribute.call(this,r,t),await q.resolveClassAttribute.call(this,r,t),await q.resolveBindAttribute.call(this,r,t),await q.resolveEventAttributes.call(this,r,t),await q.resolveTextNodeExpressions.call(this,r,t),await q.resolveCustomAttribute.call(this,r,t),await q.resolveCustomProperty.call(this,r,t);return e}async mount(e,t){t={...t,rootNode:e},M(e,"renderer",this),this._store.set("$rootNode",e),this.has("$rootRenderer")||this._store.set("$rootRenderer",this),this.get("$rootRenderer")===this&&await ve(this),await this.preprocessNode(e,t),await this.renderNode(e,t)}}function be(){return d([R`html{`,R`max-width: 70ch;`,R`padding: 2em 1em;`,R`margin: auto;`,R`line-height: 1.75;`,R`font-size: 1.25em;`,R`font-family: sans-serif;`,R`}`,R`h1,h2,h3,h4,h5,h6{`,R`margin: 1em 0 0.5em;`,R`}`,R`p,ul,ol{`,R`margin-bottom: 1em;`,R`color: #1d1d1d;`,R`}`].map(u).join(""))}const Ee={sm:640,md:768,lg:1024,xl:1280},ye=.25,Ae=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],Re=[...Ae,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(Ee)],Oe=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],Ie=[75,100,150,200,300,500,700,1e3],Ne=["hover","focus","disabled","active"],ke={margin:"m",padding:"p"},Te={width:"w",height:"h"},Se={top:"top",right:"right",bottom:"bottom",left:"left"},Pe={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},Ce={"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"}},Le=["@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 }"],De={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 Me(e){return`#${e.toString(16).padStart(6,"0")}`}function Ue(e){return Ne.map((t=>`.${t}\\:${e}:${t}`))}function ze(e,t){return Object.entries(Ee).map((([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`))}function je(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function Fe(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100vw`],[`${t}-full`,`${e}: 100%`],...Re.map((r=>[`${t}-${r}`,`${e}: ${r*ye}rem`])),...Re.map((r=>[`-${t}-${r}`,`${e}: -${r*ye}rem`])),...Re.map((r=>[`${t}-${r}px`,`${e}: ${r}px`])),...Re.map((r=>[`-${t}-${r}px`,`${e}: -${r}px`])),...Oe.map((r=>[`${t}-${r}\\%`,`${e}: ${r}%`])),...Oe.map((r=>[`-${t}-${r}\\%`,`${e}: -${r}%`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ue(e).join(",")} { ${t} }`,...ze(e,t)]))}function Ge(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;`],...Re.map((e=>[e,e*ye])).map((([r,i])=>[`${t}x-${r}`,`${e}-left: ${i}rem; ${e}-right: ${i}rem;`])),...Re.map((e=>[e,e*ye])).map((([r,i])=>[`${t}y-${r}`,`${e}-top: ${i}rem; ${e}-bottom: ${i}rem;`])),...Re.map((r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`])),...Re.map((r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`])),...Oe.map((r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`])),...Oe.map((r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ue(e).join(",")} { ${t} }`,...ze(e,t)]))}function Ke(){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(De).flatMap((([e,t])=>[[`text-${e}`,`color: ${Me(t[500])}`],[`fill-${e}`,`fill: ${Me(t[500])}`],[`bg-${e}`,`background-color: ${Me(t[500])}`],[`border-${e}`,`border-color: ${Me(t[500])}`]])),r=Object.entries(De).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[[`text-${e}-${t}`,`color: ${Me(r)}`],[`fill-${e}-${t}`,`fill: ${Me(r)}`],[`bg-${e}-${t}`,`background-color: ${Me(r)}`],[`border-${e}-${t}`,`border-color: ${Me(r)}`]]))));return[].concat(e).concat(t).concat(r).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ue(e).join(",")} { ${t} }`,...ze(e,t)]))}class We extends xe{impl="browser";dirpath=Z(globalThis.location?.href??"http://localhost/");parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return(new DOMParser).parseFromString(e,"text/html");{const t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}new We;const He=new We;globalThis.Mancha=He;const Ye=globalThis.document?.currentScript;if(globalThis.document?.currentScript?.hasAttribute("init")){const e=Ye?.hasAttribute("debug"),t=Ye?.getAttribute("cache"),r=Ye?.getAttribute("target")?.split("+")||["body"];window.addEventListener("load",(()=>{r.map((async r=>{const i=globalThis.document.querySelector(r);await He.debug(e).mount(i,{cache:t})}))}))}if(globalThis.document?.currentScript?.hasAttribute("css")){const e=Ye?.getAttribute("css")?.split("+");for(const t of e){const e=document.createElement("style");switch(t){case"basic":p(e,be());break;case"utils":e.textContent=(Be=void 0,[...Le,...Object.entries(Ce).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[`.${e} { ${t}: ${r} }`,`${Ue(e).join(",")} { ${t}: ${r} }`,...ze(e,`${t}: ${r}`)])))),...Ke(),...[["opacity-0","opacity: 0"],...Oe.map((e=>[`opacity-${e}`,"opacity: "+e/100]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ue(e).join(",")} { ${t} }`,...ze(e,t)])),...[...Oe.map((e=>[`z-${e}`,`z-index: ${e}`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ue(e).join(",")} { ${t} }`,...ze(e,t)])),...[...Ie.map((e=>[`duration-${e}`,`transition-duration: ${e}ms`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ue(e).join(",")} { ${t} }`,...ze(e,t)])),...Fe(Se),...Fe(Te),...Ge(Te),...(Be=ke,Object.entries(Be).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=>[...Re.map((e=>[e,e*ye])).map((([i,n])=>[`${r}${t}t-${i}`,`${e}-top: ${r}${n}rem`])),...Re.map((e=>[e,e*ye])).map((([i,n])=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${n}rem`])),...Re.map((e=>[e,e*ye])).map((([i,n])=>[`${r}${t}l-${i}`,`${e}-left: ${r}${n}rem`])),...Re.map((e=>[e,e*ye])).map((([i,n])=>[`${r}${t}r-${i}`,`${e}-right: ${r}${n}rem`])),...Re.map((i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`])),...Re.map((i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`])),...Re.map((i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`])),...Re.map((i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`])),...Oe.map((i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`])),...Oe.map((i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%;`])),...Oe.map((i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`])),...Oe.map((i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`]))]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ue(e).join(",")} { ${t} }`,...ze(e,t)]))),...Fe(ke),...Ge(ke),...[["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...Re.map((e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*ye}rem`])),...Re.map((e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*ye}rem`])),...Re.map((e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`])),...Re.map((e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`])),["gap-0","gap: 0"],...Re.map((e=>[`gap-${e}`,`gap: ${e*ye}rem`])),...Re.map((e=>[`gap-${e}px`,`gap: ${e}px`])),...Re.map((e=>[`gap-x-${e}`,`column-gap: ${e*ye}rem`])),...Re.map((e=>[`gap-y-${e}`,`row-gap: ${e*ye}rem`])),...Re.map((e=>[`gap-x-${e}px`,`column-gap: ${e}px`])),...Re.map((e=>[`gap-y-${e}px`,`row-gap: ${e}px`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ue(e).join(",")} { ${t} }`,...ze(e,t)])),...Fe(Pe),...[["border","border: 1px"],["border-x","border-inline-width: 1px"],["border-y","border-block-width: 1px"],...[0,...Ae].map((e=>[`border-${e}`,`border-width: ${e}px`])),...[0,...Ae].map((e=>[`border-x-${e}`,`border-inline-width: ${e}px;`])),...[0,...Ae].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,...Ae].map((t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`]))]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ue(e).join(",")} { ${t} }`,...ze(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*ye)).map((e=>[`text-${e}rem`,`font-size: ${e}rem`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${Ue(e).join(",")} { ${t} }`,...ze(e,t)]))].sort(je).join("\n"));break;default:console.error(`Unknown style name: "${t}"`)}globalThis.document.head.appendChild(e)}}var Be})();
|
|
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 $,w;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"}($||($={}));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:w.KEEP};const i=this.globalAttributePolicies.get(e);return i||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((t=>0===e.indexOf(t)))?{policyAction:w.KEEP}:{policyAction:w.DROP})}}!function(e){e[e.DROP=0]="DROP",e[e.KEEP=1]="KEEP",e[e.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",e[e.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",e[e.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",e[e.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}(w||(w={}));new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const x=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],E=[["A",new Map([["href",{policyAction:w.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:w.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:w.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],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:w.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:w.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:w.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:w.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:w.KEEP_AND_SANITIZE_URL}],["target",{policyAction:w.KEEP_AND_NORMALIZE,conditions:v((()=>new Map([["target",new Set(["_self","_blank"])]])))}]];new b(new Set(x),new Map(E),new Set(y),new Map(A)),new b(new Set(v((()=>x.concat(["STYLE"])))),new Map(E),new Set(v((()=>y.concat(["id","name","class"])))),new Map(v((()=>A.concat([["style",{policyAction:w.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 k(e,t){return"function"==typeof e?.[t]}function T(e){return e.replace(/-./g,(e=>e[1].toUpperCase()))}function S(e,t){return N(e,"attribs")?e.attribs?.[t]??null:e.getAttribute?.(t)??null}function P(e,t,r=""){return S(e,r+t)||(e.dataset?.[T(t)]??null)}function C(e,t,r=""){return function(e,t){return N(e,"attribs")?t in(e.attribs||{}):e.hasAttribute?.(t)??!1}(e,r+t)||N(e.dataset,T(t))}function L(e,t,r){N(e,"attribs")?e.attribs[t]=r:e.setAttribute?.(t,r)}function D(e,t,r){N(e,"attribs")?e.attribs[t]=r:l(O,e,t,r)}function M(e,t,r){switch(t){case"disabled":return void(e.disabled=r);case"selected":return void(e.selected=r);case"checked":return void(e.checked=r);default:e[t]=r}}function U(e,t){N(e,"attribs")?delete e.attribs[t]:e.removeAttribute?.(t)}function z(e,t,r=""){U(e,`${r}${t}`),U(e,`data-${t}`)}function j(e,t,r){if(N(e,"attribs")&&N(t,"attribs"))t.attribs[r]=e.attribs[r];else if(r.startsWith("data-")){const i=T(r.slice(5));t.dataset[i]=e.dataset?.[i]}else{const i=e?.getAttribute?.(r);D(t,r,i||"")}}function F(e){if(N(e,"firstElementChild"))return e.firstElementChild;return Array.from(e.children).find((e=>1===e.nodeType))}function G(e,...t){if(k(e,"replaceWith"))return e.replaceWith(...t);{const r=e,i=r.parentNode,n=Array.from(i.childNodes).indexOf(r);t.forEach((e=>e.parentNode=i)),i.childNodes=[].concat(Array.from(i.childNodes).slice(0,n)).concat(t).concat(Array.from(i.childNodes).slice(n+1))}}function K(e,...t){k(e,"replaceChildren")?e.replaceChildren(...t):(e.childNodes=t,t.forEach((t=>t.parentNode=e)))}function W(e,t){return k(t,"appendChild")?e.appendChild(t):(e.childNodes.push(t),t.parentNode=e,t)}function H(e,t){return k(t,"removeChild")?e.removeChild(t):(K(e,...Array.from(e.childNodes).filter((e=>e!==t))),t)}function Y(e,t,r){return r?k(e,"insertBefore")?e.insertBefore(t,r):(G(r,t,r),t):W(e,t)}function B(e,t=0){return e?e.length<=t?e:e.slice(0,t-1)+"…":""}function V(e,t=0){return globalThis.DocumentFragment&&e instanceof DocumentFragment?Array.from(e.childNodes).map((e=>V(e,t))).join(""):B(e.outerHTML||e.nodeValue||String(e),t)}function Z(e){return e.includes("/")?e.split("/").slice(0,-1).join("/"):""}var q;!function(e){e.resolveIncludes=async function(e,t){const r=e,i=r.tagName?.toLowerCase();if(!["include","link"].includes(i))return;if("link"===i&&"subresource"!==S(r,"rel"))return;this.log("include directive found in:\n",V(e,128)),this.log("include params:",t);const n="link"===r.tagName.toLocaleLowerCase()?"href":"src",s=S(r,n);if(!s)throw new Error(`"${n}" attribute missing from ${V(e,128)}.`);const o=[];"include"===i&&o.push("src"),"link"===i&&o.push("rel","href");const a=t=>{const i=F(t);for(const e of Array.from(r.attributes))i&&!o.includes(e.name)&&j(r,i,e.name);G(e,...t.childNodes)},l={...t,rootDocument:!1,maxdepth:t?.maxdepth-1};if(0===l.maxdepth)throw new Error("Maximum recursion depth reached.");if(s.includes("://")||s.startsWith("//"))this.log("Including remote file from absolute path:",s),await this.preprocessRemote(s,l).then(a);else if(t?.dirpath?.includes("://")||t?.dirpath?.startsWith("//")){const e=s.startsWith("/")?s:`${t.dirpath}/${s}`;this.log("Including remote file from relative path:",e),await this.preprocessRemote(e,l).then(a)}else if("/"===s.charAt(0))this.log("Including local file from absolute path:",s),await this.preprocessLocal(s,l).then(a);else{const e=t?.dirpath&&"."!==t?.dirpath?`${t?.dirpath}/${s}`:s;this.log("Including local file from relative path:",e),await this.preprocessLocal(e,l).then(a)}},e.rebaseRelativePaths=async function(e,t){const 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")?D(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`,V(r,128)),this._customElements.set(n,r),H(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`,V(r,128));const t=this._customElements.get(n),s=(t.content||t).cloneNode(!0),o=F(s);if(o)for(const e of Array.from(r.attributes))"div"===i&&"role"===e.name||j(r,o,e.name);const a=new f(I(s)).find((e=>"slot"===e.tagName?.toLowerCase()));a&&G(a,...r.childNodes),G(e,...s.childNodes)}},e.resolveTextNodeExpressions=async function(e,t){const r=e.nodeValue||"";if(3!==e.nodeType||!r?.trim())return;this.log("Processing node content value:\n",B(r,128));const i=new RegExp(/{{ ([^}]+) }}/gm),n=Array.from(r.matchAll(i)).map((e=>e[1]));return this.effect((function(){let t=r;for(const r of n){const i=this.eval(r,{$elem:e});t=t.replace(`{{ ${r} }}`,String(i))}e.nodeValue=t}))},e.resolveDataAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"data",":");if(i){this.log(":data attribute found in:\n",V(e,128)),z(r,"data",":");const n=t?.rootNode===e?this:this.subrenderer();e.renderer=n;const s=n.eval(i,{$elem:e});if(await Promise.all(Object.entries(s).map((([e,t])=>n._store.set(e,t)))),n!==this)for(const t of 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",V(e,128)),z(r,"class",":");const t=S(r,"class")||"";return this.effect((function(){const n=this.eval(i,{$elem:e});D(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",V(e,128)),z(r,"text",":");const t=t=>this.textContent(e,t);return this.effect((function(){t(this.eval(i,{$elem:e}))}))}},e.resolveHtmlAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"html",":");return i?(this.log(":html attribute found in:\n",V(e,128)),z(r,"html",":"),this.effect((function(){const n=this.eval(i,{$elem:e});return new Promise((async e=>{const i=await this.preprocessString(n,t);await this.renderNode(i),K(r,i),e()}))}))):void 0},e.resolveEventAttributes=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[]))if(t.name.startsWith(":on:")||t.name.startsWith("data-on-")){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",V(e,128));const n=C(r,"prevent",":");z(r,t.name),z(r,"prevent",":");const s="submit"===i&&"FORM"===r.tagName.toUpperCase();e.addEventListener?.(i,(r=>((n||s)&&r.preventDefault(),this.eval(t.value,{$elem:e,$event:r}))))}},e.resolveForAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"for",":")?.trim();if(i){this.log(":for attribute found in:\n",V(e,128)),z(r,"for",":");for(const t of I(e,this._skipNodes))this._skipNodes.add(t);const n=S(r,"style")||"";L(r,"style","display: none;");const s=e.parentNode,o=this.createElement("template",e.ownerDocument);Y(s,o,e),H(s,e),W(o,e),this.log(":for template:\n",V(o,128));const a=i.split(" in ",2);if(2!==a.length)throw new Error(`Invalid :for format: \`${i}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=a;await this.effect((function(){const r=this.eval(h,{$elem:e});if(this.log(":for list items:",r),l.splice(0,l.length).forEach((e=>{H(s,e),this._skipNodes.delete(e)})),!Array.isArray(r))return console.error(`Expression did not yield a list: \`${h}\` => \`${r}\``),Promise.resolve();const i=[];for(const s of r){const r=this.subrenderer();r._store.set(c,s);const o=e.cloneNode(!0);L(o,"style",n),l.push(o),this._skipNodes.add(o),i.push(r.mount(o,t)),this.log("Rendered list child:\n",V(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",V(e,128));const t=["change","input"],n=S(r,":bind:on")?.split(",")||r.dataset?.bindOn?.split(",")||t;z(r,"bind",":"),U(r,":bind:on"),U(r,"data-bind-on");const s="checkbox"===S(r,"type")?"checked":"value";i.includes(".")||this.has(i)||this.set(i,""),this.effect((function(){const t=this.eval(i,{$elem:e});"checked"===s?r.checked=!!t:r.value=t}));const o=`${i} = $elem.${s}`;for(const t of n)e.addEventListener(t,(()=>this.eval(o,{$elem:e})))}},e.resolveShowAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e,i=P(r,"show",":");if(i){this.log(":show attribute found in:\n",V(e,128)),z(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":D(r,"style",`display: ${n?t:"none"};`)}))}},e.resolveCustomAttribute=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":attr:",n="data-attr-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"attribute found in:\n",V(e,128)),U(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1);this.effect((function(){const i=this.eval(t.value,{$elem:e});L(r,s,i)}))}}},e.resolveCustomProperty=async function(e,t){if(this._skipNodes.has(e))return;const r=e;for(const t of Array.from(r.attributes||[])){const i=":prop:",n="data-prop-";if(t.name.startsWith(i)||t.name.startsWith(n)){this.log(t.name,"property found in:\n",V(e,128)),U(r,t.name);const s=t.name.split(i,2).at(-1)?.split(n,2).at(-1),o=T(s);this.effect((function(){const i=this.eval(t.value,{$elem:e});M(r,o,i)}))}}}}(q||(q={}));const Q=["this"],X=["+","-","!"],J=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],ee={"!":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},te=["==","!=","<=",">=","||","&&","??","|>"],re=["===","!=="];var ie;!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"}(ie||(ie={}));const ne=(e,t,r=0)=>({kind:e,value:t,precedence:r}),se=e=>95===e||36===e||65<=(e&=-33)&&e<=90,oe=e=>48<=e&&e<=57;class ae{_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(se(this._next))return this._tokenizeIdentOrKeyword();if(oe(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=ne(ie.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,se(e)||oe(e));var e;const t=this._getValue(),r=(i=t,-1!==Q.indexOf(i)?ie.KEYWORD:ie.IDENTIFIER);var i;return ne(r,t)}_tokenizeNumber(){do{this._advance()}while(oe(this._next));return 46===this._next?this._tokenizeDot():ne(ie.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),oe(this._next)?this._tokenizeFraction():(this._clearValue(),ne(ie.DOT,".",13))}_tokenizeComma(){return this._advance(!0),ne(ie.COMMA,",")}_tokenizeColon(){return this._advance(!0),ne(ie.COLON,":")}_tokenizeFraction(){do{this._advance()}while(oe(this._next));return ne(ie.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let e=this._getValue(2);if(-1!==re.indexOf(e))this._advance(),this._advance();else{if(e=this._getValue(1),"=>"===e)return this._advance(),ne(ie.ARROW,e);-1!==te.indexOf(e)&&this._advance()}return e=this._getValue(),ne(ie.OPERATOR,e,ee[e])}_tokenizeGrouper(){const e=String.fromCharCode(this._next),t=ne(ie.GROUPER,e,ee[e]);return this._advance(!0),t}}class le{_kind;_tokenizer;_ast;_token;_value;constructor(e,t){this._tokenizer=new ae(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(ie.GROUPER,"(")){const t=this._parseArguments();e=this._ast.invoke(e,void 0,t)}else if(this._matches(ie.GROUPER,"[")){const t=this._parseIndex();e=this._ast.index(e,t)}else if(this._matches(ie.DOT)){this._advance();const t=this._parseUnary();e=this._makeInvokeOrGetter(e,t)}else{if(this._matches(ie.KEYWORD))break;if(!(this._matches(ie.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===J.indexOf(t.value))throw new Error(`unknown operator: ${t.value}`);this._advance();let r=this._parseUnary();for(;(this._kind===ie.OPERATOR||this._kind===ie.DOT||this._kind===ie.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(ie.OPERATOR)){const e=this._value;if(this._advance(),"+"===e||"-"===e){if(this._matches(ie.INTEGER))return this._parseInteger(e);if(this._matches(ie.DECIMAL))return this._parseDecimal(e)}if(-1===X.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(ie.OPERATOR,"?");const t=this._parseExpression();this._advance(ie.COLON);const r=this._parseExpression();return this._ast.ternary(e,t,r)}_parsePrimary(){switch(this._kind){case ie.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 ie.IDENTIFIER:return this._parseInvokeOrIdentifier();case ie.STRING:return this._parseString();case ie.INTEGER:return this._parseInteger();case ie.DECIMAL:return this._parseDecimal();case ie.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case ie.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const e=[];do{if(this._advance(),this._matches(ie.GROUPER,"]"))break;e.push(this._parseExpression())}while(this._matches(ie.COMMA));return this._advance(ie.GROUPER,"]"),this._ast.list(e)}_parseMap(){const e={};do{if(this._advance(),this._matches(ie.GROUPER,"}"))break;const t=this._value;(this._matches(ie.STRING)||this._matches(ie.IDENTIFIER))&&this._advance(),this._advance(ie.COLON),e[t]=this._parseExpression()}while(this._matches(ie.COMMA));return this._advance(ie.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(ie.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const e=this._value;return this._advance(),this._ast.id(e)}_parseArguments(){if(!this._matches(ie.GROUPER,"("))return;const e=[];do{if(this._advance(),this._matches(ie.GROUPER,")"))break;const t=this._parseExpression();e.push(t)}while(this._matches(ie.COMMA));return this._advance(ie.GROUPER,")"),e}_parseIndex(){this._advance();const e=this._parseExpression();return this._advance(ie.GROUPER,"]"),e}_parseParenOrFunction(){const e=this._parseArguments();if(this._matches(ie.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 ce={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,">":(e,t)=>e>t,">=":(e,t)=>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)},he={"+":e=>e,"-":e=>-e,"!":e=>!e};class ue{timeouts=new Map;debounce(e,t){return new Promise(((r,i)=>{const n=this.timeouts.get(t);n&&clearTimeout(n),this.timeouts.set(t,setTimeout((()=>{try{r(t()),this.timeouts.delete(t)}catch(e){i(e)}}),e))}))}}const de=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=he[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=ce[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 pe(e,t){const r=e?._store;return r?.has(t)?r.get(t):r?.has("$parent")?pe(r.get("$parent"),t):null}function fe(e,t){const r=e?._store;return r?.has(t)?e:r?.has("$parent")?fe(r.get("$parent"),t):null}class me extends ue{evalkeys=["$elem","$event"];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_observer=null;_store=new Map;_lock=Promise.resolve();constructor(e){super();for(let[t,r]of Object.entries(e||{}))this.set(t,r)}wrapFunction(e){return(...t)=>e.call(this.$,...t)}wrapObject(e,t){return null==e||((r=e)instanceof me||r.__is_proxy__)||e.constructor!==Object&&!Array.isArray(e)?e:new Proxy(e,{deleteProperty:(e,r)=>r in e&&(delete e[r],t(),!0),set:(r,i,n,s)=>{"object"==typeof n&&null!=e&&(n=this.wrapObject(n,t));const o=Reflect.set(r,i,n,s);return t(),o},get:(e,t,r)=>"__is_proxy__"===t||Reflect.get(e,t,r)});var r}watch(e,t){const r=fe(this,e);if(!r)throw new Error(`Cannot watch key "${e}" as it does not exist in the store.`);r.observers.has(e)||r.observers.set(e,new Set),r.observers.get(e)?.has(t)||r.observers.get(e)?.add(t)}addKeyHandler(e,t){this.keyHandlers.has(e)||this.keyHandlers.set(e,new Set),this.keyHandlers.get(e).add(t)}async notify(e,t=10){const r=fe(this,e),i=Array.from(r?.observers.get(e)||[]);await this.debounce(t,(()=>Promise.all(i.map((e=>e.call(this.proxify(e)))))))}get(e,t){return t&&this.watch(e,t),pe(this,e)}async set(e,t){if(t===this._store.get(e))return;const r=()=>this.notify(e);t&&"function"==typeof t&&(t=this.wrapFunction(t)),t&&"object"==typeof t&&(t=this.wrapObject(t,r)),function(e,t,r){const i=fe(e,t);i?i._store.set(t,r):e._store.set(t,r)}(this,e,t);for(const[r,i]of this.keyHandlers.entries())if(r.test(e))for(const r of i)await Promise.resolve(r.call(this.$,e,t));await r()}async del(e){await this.set(e,null),this._store.delete(e),this.observers.delete(e)}keys(){return Array.from(this._store.keys())}has(e){return this._store.has(e)}effect(e){return e.call(this.proxify(e))}proxify(e){const t=Array.from(this._store.entries()).map((([e])=>e)),r=Object.fromEntries(t.map((e=>[e,null])));return new Proxy(r,{get:(t,r,i)=>"string"==typeof r&&fe(this,r)?this.get(r,e):"$"===r?this.proxify(e):Reflect.get(this,r,i),set:(e,t,r,i)=>("string"!=typeof t||t in this?Reflect.set(this,t,r,i):this.set(t,r),!0)})}get $(){return this.proxify()}makeEvalFunction(e){if(e.includes(";"))throw new Error("Complex expressions are not supported.");let t=null;if(e.includes(" = ")){const[r,i]=e.split(" = ");t=r.trim(),e=i.trim()}return(r,i)=>{const n=((e,t)=>new le(e,t).parse())(e,de),s=n?.getIds([])?.map((e=>[e,i[e]??r[e]??globalThis[e]])),o=n?.evaluate(Object.fromEntries(s||[]));if(!t)return o;!function(e,t,r){const i=t.split(".");for(let t=0;t<i.length-1;t++)i[t]in e||(e[i[t]]={}),e=e[i[t]];e[i[i.length-1]]=r}(r,t,o)}}cachedExpressionFunction(e){return e=e.trim(),this.expressionCache.has(e)||this.expressionCache.set(e,this.makeEvalFunction(e)),this.expressionCache.get(e)}eval(e,t={}){const r=this._observer?this:this.$;if(this._store.has(e))return r[e];{const i=this.cachedExpressionFunction(e);try{return i(r,t)}catch(t){return console.error(`Failed to evaluate expression: ${e}`),console.error(t),null}}}}const _e="$$",ge="http://localhost/";function $e(){return new URL(globalThis.window?.location?.href||ge)}function we(e){return`${_e}${e}`}function ve(e){return e.keys().filter((e=>e.startsWith(_e)))}function be(e,t,r){const i=function(e){return e.substring(_e.length)}(t);let n=!1;if(r){const t=String(r);e.searchParams.get(i)!==t&&(e.searchParams.set(i,t),n=!0)}else e.searchParams.has(i)&&(e.searchParams.delete(i),n=!0);return n}async function xe(e){const t=$e();await async function(e,t){for(const[r,i]of t.searchParams.entries()){const t=we(r);e.get(t)!==i&&await e.set(t,i)}}(e,t),function(e,t){let r=!1;for(const i of ve(t))be(e,i,t.get(i))&&(r=!0);r&&globalThis.window?.history?.replaceState({},"",e.toString())}(t,e),e.addKeyHandler(new RegExp("^\\$\\$"),((e,t)=>{const r=$e();be(r,e,t)&&globalThis.window?.history?.replaceState({},"",r.toString())})),globalThis.window?.addEventListener("popstate",function(e){return async()=>{const t=$e(),r=new Set;for(const[i,n]of t.searchParams.entries()){const t=we(i);r.add(t),e.get(t)!==n&&e.set(t,n)}const i=ve(e);for(const t of i)r.has(t)||e.del(t)}}(e))}class Ee extends me{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(e){return this.debugging=e,this}async fetchRemote(e,t){return fetch(e,{cache:t?.cache??"default"}).then((e=>e.text()))}async fetchLocal(e,t){return this.fetchRemote(e,t)}async preprocessString(e,t){this.log("Preprocessing string content with params:\n",t);const r=this.parseHTML(e,t);return await this.preprocessNode(r,t),r}async preprocessRemote(e,t){const r={};t?.cache&&(r.cache=t.cache);const i=await fetch(e,r).then((e=>e.text()));return this.preprocessString(i,{...t,dirpath:Z(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}async preprocessLocal(e,t){const r=await this.fetchLocal(e,t);return this.preprocessString(r,{...t,dirpath:Z(e),rootDocument:t?.rootDocument??!e.endsWith(".tpl.html")})}subrenderer(){const e=(new this.constructor).debug(this.debugging);return e._store.set("$parent",this),e._store.set("$rootRenderer",this.get("$rootRenderer")??this),e._customElements=this._customElements,e}log(...e){this.debugging&&console.debug(...e)}async preprocessNode(e,t){t={dirpath:this.dirpath,maxdepth:10,...t};const r=new f(I(e,this._skipNodes)).map((async e=>{this.log("Preprocessing node:\n",V(e,128)),await q.resolveIncludes.call(this,e,t),await q.rebaseRelativePaths.call(this,e,t),await q.registerCustomElements.call(this,e,t),await q.resolveCustomElements.call(this,e,t)}));return await Promise.all(r.generator()),e}async renderNode(e,t){for(const r of I(e,this._skipNodes))this.log("Rendering node:\n",V(r,128)),await q.resolveForAttribute.call(this,r,t),await q.resolveDataAttribute.call(this,r,t),await q.resolveTextAttributes.call(this,r,t),await q.resolveHtmlAttribute.call(this,r,t),await q.resolveShowAttribute.call(this,r,t),await q.resolveClassAttribute.call(this,r,t),await q.resolveBindAttribute.call(this,r,t),await q.resolveEventAttributes.call(this,r,t),await q.resolveTextNodeExpressions.call(this,r,t),await q.resolveCustomAttribute.call(this,r,t),await q.resolveCustomProperty.call(this,r,t);return e}async mount(e,t){t={...t,rootNode:e},M(e,"renderer",this),this._store.set("$rootNode",e),this.has("$rootRenderer")||this._store.set("$rootRenderer",this),this.get("$rootRenderer")===this&&await xe(this),await this.preprocessNode(e,t),await this.renderNode(e,t)}}function ye(){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 Ae={sm:640,md:768,lg:1024,xl:1280},Re=.25,Oe=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],Ie=[...Oe,16,20,24,25,28,30,32,36,40,44,48,50,52,56,60,64,72,80,96,100,112,128,144,160,192,200,224,256,288,300,320,384,400,448,500,512,...Object.values(Ae)],Ne=[1,2,5,10,20,25,30,40,50,60,70,75,80,90,95,98,99,100],ke=[75,100,150,200,300,500,700,1e3],Te=["hover","focus","disabled","active"],Se={margin:"m",padding:"p"},Pe={width:"w",height:"h"},Ce={top:"top",right:"right",bottom:"bottom",left:"left"},Le={"min-width":"min-w","min-height":"min-h","max-width":"max-w","max-height":"max-h"},De={"font-mono":{"font-family":"monospace"},"font-sans":{"font-family":"sans-serif"},"font-serif":{"font-family":"serif"},"font-cursive":{"font-family":"cursive"},"text-xs":{"font-size":".75rem","line-height":"calc(1 / 0.75)"},"text-sm":{"font-size":".875rem","line-height":"calc(1.25 / 0.875)"},"text-base":{"font-size":"1rem","line-height":"calc(1.5 / 1)"},"text-lg":{"font-size":"1.125rem","line-height":"calc(1.75 / 1.125)"},"text-xl":{"font-size":"1.25rem","line-height":"calc(1.75 / 1.25)"},"text-2xl":{"font-size":"1.5rem","line-height":"calc(2 / 1.5)"},"text-3xl":{"font-size":"1.875rem","line-height":"calc(2.25 / 1.875)"},"text-4xl":{"font-size":"2.25rem","line-height":"calc(2.5 / 2.25)"},"text-5xl":{"font-size":"3rem","line-height":"1"},"text-6xl":{"font-size":"3.75rem","line-height":"1"},"text-7xl":{"font-size":"4.5rem","line-height":"1"},"font-thin":{"font-weight":100},"font-extralight":{"font-weight":200},"font-light":{"font-weight":300},"font-normal":{"font-weight":400},"font-medium":{"font-weight":500},"font-semibold":{"font-weight":600},"font-bold":{"font-weight":700},"font-extrabold":{"font-weight":800},"font-black":{"font-weight":900},italic:{"font-style":"italic"},"not-italic":{"font-style":"normal"},"w-max":{width:"max-content"},"w-min":{width:"min-content"},"w-fit":{width:"fit-content"},"h-max":{height:"max-content"},"h-min":{height:"min-content"},"h-fit":{height:"fit-content"},"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"}},Me=["@keyframes spin {\n from { transform: rotate(0deg) }\n to { transform: rotate(360deg) }\n }","@keyframes ping {\n 75%, 100% {\n transform: scale(2);\n opacity: 0;\n }\n }","@keyframes pulse {\n 0%, 100% { opacity: 1 }\n 50% { opacity: .5 }\n }"],Ue={red:{50:16772078,100:16764370,200:15702682,300:15037299,400:15684432,500:16007990,600:15022389,700:13840175,800:12986408,900:12000284},pink:{50:16573676,100:16301008,200:16027569,300:15753874,400:15483002,500:15277667,600:14162784,700:12720219,800:11342935,900:8916559},purple:{50:15984117,100:14794471,200:13538264,300:12216520,400:11225020,500:10233776,600:9315498,700:8069026,800:6953882,900:4854924},"deep-purple":{50:15591414,100:13747433,200:11771355,300:9795021,400:8280002,500:6765239,600:6174129,700:5320104,800:4532128,900:3218322},indigo:{50:15264502,100:12962537,200:10463450,300:7964363,400:6056896,500:4149685,600:3754411,700:3162015,800:2635155,900:1713022},blue:{50:14938877,100:12312315,200:9489145,300:6600182,400:4367861,500:2201331,600:2001125,700:1668818,800:1402304,900:870305},"light-blue":{50:14808574,100:11789820,200:8508666,300:5227511,400:2733814,500:240116,600:236517,700:166097,800:161725,900:87963},cyan:{50:14743546,100:11725810,200:8445674,300:5099745,400:2541274,500:48340,600:44225,700:38823,800:33679,900:24676},teal:{50:14742257,100:11722715,200:8440772,300:5093036,400:2533018,500:38536,600:35195,700:31083,800:26972,900:19776},green:{50:15267305,100:13166281,200:10868391,300:8505220,400:6732650,500:5025616,600:4431943,700:3706428,800:3046706,900:1793568},"light-green":{50:15857897,100:14478792,200:12968357,300:11457921,400:10275941,500:9159498,600:8172354,700:6856504,800:5606191,900:3369246},lime:{50:16382951,100:15791299,200:15134364,300:14477173,400:13951319,500:13491257,600:12634675,700:11514923,800:10394916,900:8550167},yellow:{50:16776679,100:16775620,200:16774557,300:16773494,400:16772696,500:16771899,600:16635957,700:16498733,800:16361509,900:16088855},amber:{50:16775393,100:16772275,200:16769154,300:16766287,400:16763432,500:16761095,600:16757504,700:16752640,800:16748288,900:16740096},orange:{50:16774112,100:16769202,200:16764032,300:16758605,400:16754470,500:16750592,600:16485376,700:16088064,800:15690752,900:15094016},"deep-orange":{50:16509415,100:16764092,200:16755601,300:16747109,400:16740419,500:16733986,600:16011550,700:15092249,800:14172949,900:12531212},brown:{50:15723497,100:14142664,200:12364452,300:10586239,400:9268835,500:7951688,600:7162945,700:6111287,800:5125166,900:4073251},gray:{50:16448250,100:16119285,200:15658734,300:14737632,400:12434877,500:10395294,600:7697781,700:6381921,800:4342338,900:2171169},"blue-gray":{50:15527921,100:13621468,200:11583173,300:9479342,400:7901340,500:6323595,600:5533306,700:4545124,800:3622735,900:2503224}};function ze(e){return`#${e.toString(16).padStart(6,"0")}`}function je(e){return Te.map((t=>`.${t}\\:${e}:${t}`))}function Fe(e,t){return Object.entries(Ae).map((([r,i])=>`@media (min-width: ${i}px) { .${r}\\:${e} { ${t} } }`))}function Ge(e,t){return e.includes("@media")&&!t.includes("@media")?1:!e.includes("@media")&&t.includes("@media")?-1:e.localeCompare(t)}function Ke(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-0`,`${e}: 0`],[`${t}-screen`,`${e}: 100vw`],[`${t}-full`,`${e}: 100%`],...Ie.map((r=>[`${t}-${r}`,`${e}: ${r*Re}rem`])),...Ie.map((r=>[`-${t}-${r}`,`${e}: -${r*Re}rem`])),...Ie.map((r=>[`${t}-${r}px`,`${e}: ${r}px`])),...Ie.map((r=>[`-${t}-${r}px`,`${e}: -${r}px`])),...Ne.map((r=>[`${t}-${r}\\%`,`${e}: ${r}%`])),...Ne.map((r=>[`-${t}-${r}\\%`,`${e}: -${r}%`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)]))}function We(e){return Object.entries(e).flatMap((([e,t])=>[[`${t}-auto`,`${e}: auto`],[`${t}x-auto`,`${e}-left: auto; ${e}-right: auto;`],[`${t}y-auto`,`${e}-top: auto; ${e}-bottom: auto;`],[`${t}x-0`,`${e}-left: 0; ${e}-right: 0;`],[`${t}y-0`,`${e}-top: 0; ${e}-bottom: 0;`],...Ie.map((e=>[e,e*Re])).map((([r,i])=>[`${t}x-${r}`,`${e}-left: ${i}rem; ${e}-right: ${i}rem;`])),...Ie.map((e=>[e,e*Re])).map((([r,i])=>[`${t}y-${r}`,`${e}-top: ${i}rem; ${e}-bottom: ${i}rem;`])),...Ie.map((r=>[`${t}x-${r}px`,`${e}-left: ${r}px; ${e}-right: ${r}px;`])),...Ie.map((r=>[`${t}y-${r}px`,`${e}-top: ${r}px; ${e}-bottom: ${r}px;`])),...Ne.map((r=>[`${t}x-${r}\\%`,`${e}-left: ${r}%; ${e}-right: ${r}%;`])),...Ne.map((r=>[`${t}y-${r}\\%`,`${e}-top: ${r}%; ${e}-bottom: ${r}%;`]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)]))}function He(){const e=[["white","#fff"],["black","#000"],["transparent","transparent"]].flatMap((([e,t])=>[[`text-${e}`,`color: ${t}`],[`fill-${e}`,`fill: ${t}`],[`bg-${e}`,`background-color: ${t}`],[`border-${e}`,`border-color: ${t}`]])),t=Object.entries(Ue).flatMap((([e,t])=>[[`text-${e}`,`color: ${ze(t[500])}`],[`fill-${e}`,`fill: ${ze(t[500])}`],[`bg-${e}`,`background-color: ${ze(t[500])}`],[`border-${e}`,`border-color: ${ze(t[500])}`]])),r=Object.entries(Ue).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[[`text-${e}-${t}`,`color: ${ze(r)}`],[`fill-${e}-${t}`,`fill: ${ze(r)}`],[`bg-${e}-${t}`,`background-color: ${ze(r)}`],[`border-${e}-${t}`,`border-color: ${ze(r)}`]]))));return[].concat(e).concat(t).concat(r).flatMap((([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)]))}class Ye extends Ee{impl="browser";dirpath=Z(globalThis.location?.href??"http://localhost/");parseHTML(e,t={rootDocument:!1}){if(t.rootDocument)return(new DOMParser).parseFromString(e,"text/html");{const t=document.createRange();return t.selectNodeContents(document.body),t.createContextualFragment(e)}}serializeHTML(e){return(new XMLSerializer).serializeToString(e).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(e,t){return this.preprocessRemote(e,t)}createElement(e,t){return(t||document).createElement(e)}textContent(e,t){e.textContent=t}}new Ye;const Be=new Ye;globalThis.Mancha=Be;const Ve=globalThis.document?.currentScript;if(globalThis.document?.currentScript?.hasAttribute("init")){const e=Ve?.hasAttribute("debug"),t=Ve?.getAttribute("cache"),r=Ve?.getAttribute("target")?.split("+")||["body"];window.addEventListener("load",(()=>{r.map((async r=>{const i=globalThis.document.querySelector(r);await Be.debug(e).mount(i,{cache:t})}))}))}if(globalThis.document?.currentScript?.hasAttribute("css")){const e=Ve?.getAttribute("css")?.split("+");for(const t of e){const e=document.createElement("style");switch(t){case"basic":p(e,ye());break;case"utils":e.textContent=(Ze=void 0,[...Me,...Object.entries(De).flatMap((([e,t])=>Object.entries(t).flatMap((([t,r])=>[`.${e} { ${t}: ${r} }`,`${je(e).join(",")} { ${t}: ${r} }`,...Fe(e,`${t}: ${r}`)])))),...He(),...[["opacity-0","opacity: 0"],...Ne.map((e=>[`opacity-${e}`,"opacity: "+e/100]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)])),...[...Ne.map((e=>[`z-${e}`,`z-index: ${e}`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)])),...[...ke.map((e=>[`duration-${e}`,`transition-duration: ${e}ms`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)])),...Ke(Ce),...Ke(Pe),...We(Pe),...(Ze=Se,Object.entries(Ze).flatMap((([e,t])=>[[`${t}t-0`,`${e}-top: 0`],[`${t}b-0`,`${e}-bottom: 0`],[`${t}l-0`,`${e}-left: 0`],[`${t}r-0`,`${e}-right: 0`],[`${t}t-auto`,`${e}-top: auto`],[`${t}b-auto`,`${e}-bottom: auto`],[`${t}l-auto`,`${e}-left: auto`],[`${t}r-auto`,`${e}-right: auto`],...["","-"].flatMap((r=>[...Ie.map((e=>[e,e*Re])).map((([i,n])=>[`${r}${t}t-${i}`,`${e}-top: ${r}${n}rem`])),...Ie.map((e=>[e,e*Re])).map((([i,n])=>[`${r}${t}b-${i}`,`${e}-bottom: ${r}${n}rem`])),...Ie.map((e=>[e,e*Re])).map((([i,n])=>[`${r}${t}l-${i}`,`${e}-left: ${r}${n}rem`])),...Ie.map((e=>[e,e*Re])).map((([i,n])=>[`${r}${t}r-${i}`,`${e}-right: ${r}${n}rem`])),...Ie.map((i=>[`${r}${t}t-${i}px`,`${e}-top: ${r}${i}px`])),...Ie.map((i=>[`${r}${t}b-${i}px`,`${e}-bottom: ${r}${i}px`])),...Ie.map((i=>[`${r}${t}l-${i}px`,`${e}-left: ${r}${i}px`])),...Ie.map((i=>[`${r}${t}r-${i}px`,`${e}-right: ${r}${i}px`])),...Ne.map((i=>[`${r}${t}t-${i}\\%`,`${e}-top: ${r}${i}%`])),...Ne.map((i=>[`${r}${t}b-${i}\\%`,`${e}-bottom: ${r}${i}%;`])),...Ne.map((i=>[`${r}${t}l-${i}\\%`,`${e}-left: ${r}${i}%`])),...Ne.map((i=>[`${r}${t}r-${i}\\%`,`${e}-right: ${r}${i}%`]))]))])).flatMap((([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)]))),...Ke(Se),...We(Se),...[["space-x-0 > *","margin-left: 0"],["space-y-0 > *","margin-top: 0"],...Ie.map((e=>[`space-x-${e} > :not(:first-child)`,`margin-left: ${e*Re}rem`])),...Ie.map((e=>[`space-y-${e} > :not(:first-child)`,`margin-top: ${e*Re}rem`])),...Ie.map((e=>[`space-x-${e}px > :not(:first-child)`,`margin-left: ${e}px`])),...Ie.map((e=>[`space-y-${e}px > :not(:first-child)`,`margin-top: ${e}px`])),["gap-0","gap: 0"],...Ie.map((e=>[`gap-${e}`,`gap: ${e*Re}rem`])),...Ie.map((e=>[`gap-${e}px`,`gap: ${e}px`])),...Ie.map((e=>[`gap-x-${e}`,`column-gap: ${e*Re}rem`])),...Ie.map((e=>[`gap-y-${e}`,`row-gap: ${e*Re}rem`])),...Ie.map((e=>[`gap-x-${e}px`,`column-gap: ${e}px`])),...Ie.map((e=>[`gap-y-${e}px`,`row-gap: ${e}px`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)])),...Ke(Le),...[["border","border: 1px"],["border-x","border-inline-width: 1px"],["border-y","border-block-width: 1px"],...[0,...Oe].map((e=>[`border-${e}`,`border-width: ${e}px`])),...[0,...Oe].map((e=>[`border-x-${e}`,`border-inline-width: ${e}px;`])),...[0,...Oe].map((e=>[`border-y-${e}`,`border-block-width: ${e}px;`])),...["top","bottom","left","right"].flatMap((e=>[[`border-${e.slice(0,1)}`,`border-${e}: 1px`],...[0,...Oe].map((t=>[`border-${e.slice(0,1)}-${t}`,`border-${e}-width: ${t}px`]))]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)])),...[...Array.from({length:100},((e,t)=>t)).map((e=>[`text-${e}px`,`font-size: ${e}px`])),...Array.from({length:100},((e,t)=>t*Re)).map((e=>[`text-${e}rem`,`font-size: ${e}rem`]))].flatMap((([e,t])=>[`.${e} { ${t} }`,`${je(e).join(",")} { ${t} }`,...Fe(e,t)]))].sort(Ge).join("\n"));break;default:console.error(`Unknown style name: "${t}"`)}globalThis.document.head.appendChild(e)}}var Ze})();
|
package/dist/query.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
const KEY_PREFIX = "$$";
|
|
2
|
+
const FALLBACK_URL = "http://localhost/";
|
|
3
|
+
function getWindowURL() {
|
|
4
|
+
return new URL(globalThis.window?.location?.href || FALLBACK_URL);
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* Converts a store key to a URL parameter name by removing the KEY_PREFIX.
|
|
4
8
|
* @param storeKey The store key (e.g., "$$page")
|
|
@@ -75,7 +79,7 @@ function updateUrlFromStore(url, renderer) {
|
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
if (changed) {
|
|
78
|
-
window
|
|
82
|
+
globalThis.window?.history?.replaceState({}, "", url.toString());
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
/**
|
|
@@ -86,7 +90,7 @@ function updateUrlFromStore(url, renderer) {
|
|
|
86
90
|
*/
|
|
87
91
|
function createStoreUpdater(renderer) {
|
|
88
92
|
return async () => {
|
|
89
|
-
const url =
|
|
93
|
+
const url = getWindowURL();
|
|
90
94
|
const presentKeysInUrl = new Set();
|
|
91
95
|
// Add/update params in store from URL
|
|
92
96
|
for (const [key, value] of url.searchParams.entries()) {
|
|
@@ -116,20 +120,20 @@ function createStoreUpdater(renderer) {
|
|
|
116
120
|
* @param renderer The renderer instance.
|
|
117
121
|
*/
|
|
118
122
|
export async function setupQueryParamBindings(renderer) {
|
|
119
|
-
const url =
|
|
123
|
+
const url = getWindowURL();
|
|
120
124
|
// First, update store with URL parameters (URL takes precedence over existing store values)
|
|
121
125
|
await updateStoreFromUrl(renderer, url);
|
|
122
126
|
// Then, update URL with any store defaults that aren't already in the URL
|
|
123
127
|
updateUrlFromStore(url, renderer);
|
|
124
128
|
// Set up the URL updater to listen for changes in the store.
|
|
125
129
|
renderer.addKeyHandler(new RegExp(`^\\$\\$`), (key, value) => {
|
|
126
|
-
const url =
|
|
130
|
+
const url = getWindowURL();
|
|
127
131
|
const changed = updateUrlFromStoreValue(url, key, value);
|
|
128
132
|
if (changed) {
|
|
129
|
-
window
|
|
133
|
+
globalThis.window?.history?.replaceState({}, "", url.toString());
|
|
130
134
|
}
|
|
131
135
|
});
|
|
132
136
|
// Set up the popstate listener to update the store when the URL changes.
|
|
133
|
-
window
|
|
137
|
+
globalThis.window?.addEventListener("popstate", createStoreUpdater(renderer));
|
|
134
138
|
}
|
|
135
139
|
//# sourceMappingURL=query.js.map
|
package/dist/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEzC,SAAS,YAAY;IACnB,OAAO,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,IAAI,YAAY,CAAC,CAAC;AACpE,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,OAAO,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,SAAiB;IAC5C,OAAO,GAAG,UAAU,GAAG,SAAS,EAAE,CAAC;AACrC,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,QAAmB;IAC5C,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,kBAAkB,CAAC,QAAmB,EAAE,GAAQ;IAC7D,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5D,MAAM,QAAQ,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAC;YACrC,MAAM,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAS,uBAAuB,CAAC,GAAQ,EAAE,QAAgB,EAAE,KAAU;IACrE,MAAM,SAAS,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACpC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACnC,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,MAAM,EAAE,CAAC;YAC/C,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YACxC,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,GAAQ,EAAE,QAAmB;IACvD,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,KAAK,MAAM,GAAG,IAAI,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9C,IAAI,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACzD,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;IACD,IAAI,OAAO,EAAE,CAAC;QACZ,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,QAAmB;IAC7C,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,GAAG,GAAG,YAAY,EAAE,CAAC;QAC3B,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;QAE3C,sCAAsC;QACtC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC;YACtD,MAAM,QAAQ,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;YAC1C,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC/B,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAC;gBACrC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QAED,qDAAqD;QACrD,MAAM,YAAY,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QACjD,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;YAC/B,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC/B,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,QAAmB;IAC/D,MAAM,GAAG,GAAG,YAAY,EAAE,CAAC;IAE3B,4FAA4F;IAC5F,MAAM,kBAAkB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAExC,0EAA0E;IAC1E,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAElC,6DAA6D;IAC7D,QAAQ,CAAC,aAAa,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC3D,MAAM,GAAG,GAAG,YAAY,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QAEzD,IAAI,OAAO,EAAE,CAAC;YACZ,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,yEAAyE;IACzE,UAAU,CAAC,MAAM,EAAE,gBAAgB,CAAC,UAAU,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAChF,CAAC"}
|
package/dist/safe_browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t={};function e(t){0}class i{constructor(t,e){this.privateDoNotAccessOrElseWrappedAttributePrefix=e}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const s=i;function r(t){if(function(t){return t instanceof i}(t))return t.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}function n(t){return Object.isFrozen(t)&&Object.isFrozen(t.raw)}function a(t){return-1===t.toString().indexOf("`")}a((t=>t``))||a((t=>t`\0`))||a((t=>t`\n`))||a((t=>t`\u0000`)),n``&&n`\0`&&n`\n`&&n`\u0000`;function o(e){const i=e[0].toLowerCase();return new s(t,i)}let l,c="google#safe";function h(){var t;return""!==c&&null!==(t=function(){if("undefined"!=typeof window)return window.trustedTypes}())&&void 0!==t?t:null}class u{constructor(t,i){e(),this.privateDoNotAccessOrElseWrappedHtml=t}toString(){return this.privateDoNotAccessOrElseWrappedHtml.toString()}}function d(e,i){return null!=i?i:new u(e,t)}"undefined"!=typeof window&&window.TrustedHTML;function p(t){var e;const i=t;return d(i,null===(e=function(){var t,e;if(void 0===l)try{l=null!==(e=null===(t=h())||void 0===t?void 0:t.createPolicy(c,{createHTML:t=>t,createScript:t=>t,createScriptURL:t=>t}))&&void 0!==e?e:null}catch(t){l=null}return l}())||void 0===e?void 0:e.createHTML(i))}function f(t){var e;if(null===(e=h())||void 0===e?void 0:e.isHTML(t))return t;if(t instanceof u)return t.privateDoNotAccessOrElseWrappedHtml;throw new Error("")}"undefined"!=typeof window&&window.TrustedScriptURL;"undefined"!=typeof window&&window.TrustedScript;function _(t,e){e.appendChild(t);let i=(new XMLSerializer).serializeToString(e);return i=i.slice(i.indexOf(">")+1,i.lastIndexOf("</")),p(i)}const m=["data:","http:","https:","mailto:","ftp:"],E=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function w(t){if(!function(t){const e=!E.test(t);return e}(t))return t}function v(t){return w(t)}function b(t){const e=function(t){let e;try{e=new URL(t)}catch(t){return"https:"}return e.protocol}(t);return void 0!==e&&-1!==m.indexOf(e.toLowerCase())?t:"about:invalid#zClosurez"}function g(t,e){const i=e.createRange();i.selectNode(e.body);return function(t,e){return t.createContextualFragment(f(e))}(i,p(t))}function A(t){const e=t.nodeName;return"string"==typeof e?e:"FORM"}function y(t){return 3===t.nodeType}function R(t){const e=t.nodeType;return 1===e||"number"!=typeof e}var T,O;function N(t){try{return new URL(t,window.document.baseURI)}catch(t){return new URL("about:invalid")}}function I(t){return{valueOf:t}.valueOf()}!function(t){t[t.STYLE_TAG=0]="STYLE_TAG",t[t.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",t[t.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}(T||(T={}));class P{constructor(t,e,i,s,r){this.allowedElements=t,this.elementPolicies=e,this.allowedGlobalAttributes=i,this.globalAttributePolicies=s,this.globallyAllowedAttributePrefixes=r}isAllowedElement(t){return"FORM"!==t&&(this.allowedElements.has(t)||this.elementPolicies.has(t))}getAttributePolicy(t,e){const i=this.elementPolicies.get(e);if(null==i?void 0:i.has(t))return i.get(t);if(this.allowedGlobalAttributes.has(t))return{policyAction:O.KEEP};const s=this.globalAttributePolicies.get(t);return s||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((e=>0===t.indexOf(e)))?{policyAction:O.KEEP}:{policyAction:O.DROP})}}!function(t){t[t.DROP=0]="DROP",t[t.KEEP=1]="KEEP",t[t.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",t[t.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",t[t.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",t[t.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",t[t.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}(O||(O={}));const S=new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const x=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],C=[["A",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],L=["title","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-current","aria-disabled","aria-dropeffect","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-live","aria-multiline","aria-multiselectable","aria-orientation","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","alt","align","autocapitalize","autocomplete","autocorrect","autofocus","autoplay","bgcolor","border","cellpadding","cellspacing","checked","color","cols","colspan","controls","datetime","disabled","download","draggable","enctype","face","formenctype","frameborder","height","hreflang","hidden","ismap","label","lang","loop","max","maxlength","media","minlength","min","multiple","muted","nonce","open","placeholder","preload","rel","required","reversed","role","rows","rowspan","selected","shape","size","sizes","slot","span","spellcheck","start","step","summary","translate","type","valign","value","width","wrap","itemscope","itemtype","itemid","itemprop","itemref"],k=[["dir",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:O.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:O.KEEP_AND_SANITIZE_URL}],["target",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["target",new Set(["_self","_blank"])]])))}]],D=new P(new Set(x),new Map(C),new Set(L),new Map(k));new P(new Set(I((()=>x.concat(["STYLE"])))),new Map(C),new Set(I((()=>L.concat(["id","name","class"])))),new Map(I((()=>k.concat([["style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}]])))));class U{constructor(t,i,s,r,n){this.sanitizerTable=t,this.styleElementSanitizer=s,this.styleAttributeSanitizer=r,this.resourceUrlPolicy=n,this.changes=[],e()}sanitizeAssertUnchanged(t){return this.sanitize(t)}sanitize(t){const e=document.implementation.createHTMLDocument("");return _(this.sanitizeToFragmentInternal(t,e),e.body)}sanitizeToFragment(t){const e=document.implementation.createHTMLDocument("");return this.sanitizeToFragmentInternal(t,e)}sanitizeToFragmentInternal(t,e){const i=g(t,e),s=document.createTreeWalker(i,5,(t=>this.nodeFilter(t)));let r=s.nextNode();const n=e.createDocumentFragment();let a=n;for(;null!==r;){let t;if(y(r))if(this.styleElementSanitizer&&"STYLE"===a.nodeName){const e=this.styleElementSanitizer(r.data);t=this.createTextNode(e)}else t=this.sanitizeTextNode(r);else{if(!R(r)){throw new Error("")}t=this.sanitizeElementNode(r,e)}if(a.appendChild(t),r=s.firstChild(),r)a=t;else for(;!(r=s.nextSibling())&&(r=s.parentNode());)a=a.parentNode}return n}createTextNode(t){return document.createTextNode(t)}sanitizeTextNode(t){return this.createTextNode(t.data)}sanitizeElementNode(t,e){const i=A(t),s=e.createElement(i),r=t.attributes;for(const{name:t,value:e}of r){const n=this.sanitizerTable.getAttributePolicy(t,i);if(this.satisfiesAllConditions(n.conditions,r))switch(n.policyAction){case O.KEEP:z(s,t,e);break;case O.KEEP_AND_SANITIZE_URL:const r=b(e);r!==e&&this.recordChange(`Url in attribute ${t} was modified during sanitization. Original url:"${e}" was sanitized to: "${r}"`),z(s,t,r);break;case O.KEEP_AND_NORMALIZE:z(s,t,e.toLowerCase());break;case O.KEEP_AND_SANITIZE_STYLE:if(this.styleAttributeSanitizer){z(s,t,this.styleAttributeSanitizer(e))}else z(s,t,e);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY:if(this.resourceUrlPolicy){const r={type:T.HTML_ATTRIBUTE,attributeName:t,tagName:i},n=N(e),a=this.resourceUrlPolicy(n,r);a&&z(s,t,a.toString())}else z(s,t,e);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET:if(this.resourceUrlPolicy){const r={type:T.HTML_ATTRIBUTE,attributeName:t,tagName:i},n=$(e),a={parts:[]};for(const t of n.parts){const e=N(t.url),i=this.resourceUrlPolicy(e,r);i&&a.parts.push({url:i.toString(),descriptor:t.descriptor})}z(s,t,M(a))}else z(s,t,e);break;case O.DROP:this.recordChange(`Attribute: ${t} was dropped`)}else this.recordChange(`Not all conditions satisfied for attribute: ${t}.`)}return s}nodeFilter(t){if(y(t))return 1;if(!R(t))return 2;const e=A(t);return null===e?(this.recordChange(`Node name was null for node: ${t}`),2):this.sanitizerTable.isAllowedElement(e)?1:(this.recordChange(`Element: ${e} was dropped`),2)}recordChange(t){0}satisfiesAllConditions(t,e){var i;if(!t)return!0;for(const[s,r]of t){const t=null===(i=e.getNamedItem(s))||void 0===i?void 0:i.value;if(t&&!r.has(t))return!1}return!0}}function z(t,e,i){t.setAttribute(e,i)}function $(t){const e=[];for(const i of t.split(",")){const[t,s]=i.trim().split(/\s+/,2);e.push({url:t,descriptor:s})}return{parts:e}}function M(t){return t.parts.map((t=>{const{url:e,descriptor:i}=t;return`${e}${i?` ${i}`:""}`})).join(" , ")}class F{constructor(){this.calledBuild=!1,this.sanitizerTable=D}onlyAllowElements(t){const e=new Set,i=new Map;for(let s of t){if(s=s.toUpperCase(),!this.sanitizerTable.isAllowedElement(s))throw new Error(`Element: ${s}, is not allowed by html5_contract.textpb`);const t=this.sanitizerTable.elementPolicies.get(s);void 0!==t?i.set(s,t):e.add(s)}return this.sanitizerTable=new P(e,i,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}allowCustomElement(t,e){const i=new Set(this.sanitizerTable.allowedElements),s=new Map(this.sanitizerTable.elementPolicies);if(t=t.toUpperCase(),r=t,S.has(r.toUpperCase())||!/^[a-z][-_.a-z0-9]*-[-_.a-z0-9]*$/i.test(r))throw new Error(`Element: ${t} is not a custom element`);var r;if(e){const i=new Map;for(const t of e)i.set(t,{policyAction:O.KEEP});s.set(t,i)}else i.add(t);return this.sanitizerTable=new P(i,s,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}onlyAllowAttributes(t){const e=new Set,i=new Map,s=new Map;for(const s of t)this.sanitizerTable.allowedGlobalAttributes.has(s)&&e.add(s),this.sanitizerTable.globalAttributePolicies.has(s)&&i.set(s,this.sanitizerTable.globalAttributePolicies.get(s));for(const[e,i]of this.sanitizerTable.elementPolicies.entries()){const r=new Map;for(const[e,s]of i.entries())t.has(e)&&r.set(e,s);s.set(e,r)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,s,e,i),this}allowDataAttributes(t){const e=new Set(this.sanitizerTable.allowedGlobalAttributes);for(const i of t){if(0!==i.indexOf("data-"))throw new Error(`data attribute: ${i} does not begin with the prefix "data-"`);e.add(i)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,e,this.sanitizerTable.globalAttributePolicies),this}allowStyleAttributes(){const t=new Map(this.sanitizerTable.globalAttributePolicies);return t.set("style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,this.sanitizerTable.allowedGlobalAttributes,t),this}allowClassAttributes(){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);return t.add("class"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}allowIdAttributes(){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);return t.add("id"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}allowIdReferenceAttributes(){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);return t.add("aria-activedescendant").add("aria-controls").add("aria-labelledby").add("aria-owns").add("for").add("list"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}withResourceUrlPolicy(t){return this.resourceUrlPolicy=t,this}build(){if(this.calledBuild)throw new Error("this sanitizer has already called build");return this.calledBuild=!0,new U(this.sanitizerTable,t,void 0,void 0,this.resourceUrlPolicy)}}function G(t,e,i,s){if(0===t.length){throw new Error("")}const n=t.map((t=>r(t))),a=i.toLowerCase();if(n.every((t=>0!==a.indexOf(t))))throw new Error(`Attribute "${i}" does not match any of the allowed prefixes.`);e.setAttribute(i,s)}function K(t,e,i){return t.parseFromString(f(e),i)}Error;const H=[o`:`,o`style`,o`class`];function*W(t,e=new Set){const i=new Set,s=Array.from(t.childNodes).filter((t=>!e.has(t)));for(yield t;s.length;){const t=s.shift();i.has(t)||(i.add(t),yield t),t.childNodes&&Array.from(t.childNodes).filter((t=>!e.has(t))).forEach((t=>s.push(t)))}}function Y(t,e){return void 0!==t?.[e]}function B(t,e){return"function"==typeof t?.[e]}function V(t){return t.replace(/-./g,(t=>t[1].toUpperCase()))}function Z(t,e){return Y(t,"attribs")?t.attribs?.[e]??null:t.getAttribute?.(e)??null}function j(t,e,i=""){return Z(t,i+e)||(t.dataset?.[V(e)]??null)}function q(t,e,i=""){return function(t,e){return Y(t,"attribs")?e in(t.attribs||{}):t.hasAttribute?.(e)??!1}(t,i+e)||Y(t.dataset,V(e))}function X(t,e,i){Y(t,"attribs")?t.attribs[e]=i:t.setAttribute?.(e,i)}function Q(t,e,i){Y(t,"attribs")?t.attribs[e]=i:G(H,t,e,i)}function J(t,e,i){switch(e){case"disabled":return void(t.disabled=i);case"selected":return void(t.selected=i);case"checked":return void(t.checked=i);default:t[e]=i}}function tt(t,e){Y(t,"attribs")?delete t.attribs[e]:t.removeAttribute?.(e)}function et(t,e,i=""){tt(t,`${i}${e}`),tt(t,`data-${e}`)}function it(t,e,i){if(Y(t,"attribs")&&Y(e,"attribs"))e.attribs[i]=t.attribs[i];else if(i.startsWith("data-")){const s=V(i.slice(5));e.dataset[s]=t.dataset?.[s]}else{const s=t?.getAttribute?.(i);Q(e,i,s||"")}}function st(t){if(Y(t,"firstElementChild"))return t.firstElementChild;return Array.from(t.children).find((t=>1===t.nodeType))}function rt(t,...e){if(B(t,"replaceWith"))return t.replaceWith(...e);{const i=t,s=i.parentNode,r=Array.from(s.childNodes).indexOf(i);e.forEach((t=>t.parentNode=s)),s.childNodes=[].concat(Array.from(s.childNodes).slice(0,r)).concat(e).concat(Array.from(s.childNodes).slice(r+1))}}function nt(t,...e){B(t,"replaceChildren")?t.replaceChildren(...e):(t.childNodes=e,e.forEach((e=>e.parentNode=t)))}function at(t,e){return B(e,"appendChild")?t.appendChild(e):(t.childNodes.push(e),e.parentNode=t,e)}function ot(t,e){return B(e,"removeChild")?t.removeChild(e):(nt(t,...Array.from(t.childNodes).filter((t=>t!==e))),e)}function lt(t,e,i){return i?B(t,"insertBefore")?t.insertBefore(e,i):(rt(i,e,i),e):at(t,e)}function ct(t,e=0){return t?t.length<=e?t:t.slice(0,e-1)+"…":""}function ht(t,e=0){return globalThis.DocumentFragment&&t instanceof DocumentFragment?Array.from(t.childNodes).map((t=>ht(t,e))).join(""):ct(t.outerHTML||t.nodeValue||String(t),e)}function ut(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):""}class dt{iterable;constructor(t){this.iterable=t}filter(t){return new dt(dt.filterGenerator(t,this.iterable))}map(t){return new dt(dt.mapGenerator(t,this.iterable))}find(t){for(const e of this.iterable)if(t(e))return e}array(){return Array.from(this.iterable)}*generator(){for(const t of this.iterable)yield t}static*filterGenerator(t,e){for(const i of e)t(i)&&(yield i)}static*mapGenerator(t,e){for(const i of e)yield t(i)}static equals(t,e){const i=t[Symbol.iterator](),s=e[Symbol.iterator]();let r=i.next(),n=s.next();for(;!r.done&&!n.done;){if(r.value!==n.value)return!1;r=i.next(),n=s.next()}return r.done===n.done}}var pt;!function(t){t.resolveIncludes=async function(t,e){const i=t,s=i.tagName?.toLowerCase();if(!["include","link"].includes(s))return;if("link"===s&&"subresource"!==Z(i,"rel"))return;this.log("include directive found in:\n",ht(t,128)),this.log("include params:",e);const r="link"===i.tagName.toLocaleLowerCase()?"href":"src",n=Z(i,r);if(!n)throw new Error(`"${r}" attribute missing from ${ht(t,128)}.`);const a=[];"include"===s&&a.push("src"),"link"===s&&a.push("rel","href");const o=e=>{const s=st(e);for(const t of Array.from(i.attributes))s&&!a.includes(t.name)&&it(i,s,t.name);rt(t,...e.childNodes)},l={...e,rootDocument:!1,maxdepth:e?.maxdepth-1};if(0===l.maxdepth)throw new Error("Maximum recursion depth reached.");if(n.includes("://")||n.startsWith("//"))this.log("Including remote file from absolute path:",n),await this.preprocessRemote(n,l).then(o);else if(e?.dirpath?.includes("://")||e?.dirpath?.startsWith("//")){const t=n.startsWith("/")?n:`${e.dirpath}/${n}`;this.log("Including remote file from relative path:",t),await this.preprocessRemote(t,l).then(o)}else if("/"===n.charAt(0))this.log("Including local file from absolute path:",n),await this.preprocessLocal(n,l).then(o);else{const t=e?.dirpath&&"."!==e?.dirpath?`${e?.dirpath}/${n}`:n;this.log("Including local file from relative path:",t),await this.preprocessLocal(t,l).then(o)}},t.rebaseRelativePaths=async function(t,e){const i=t,s=i.tagName?.toLowerCase();if(!e?.dirpath)return;const r=Z(i,"src"),n=Z(i,"href"),a=r||n;if(!a||((o=a).includes("://")||o.startsWith("/")||o.startsWith("#")||o.startsWith("data:")))return;var o;const l=`${e.dirpath}/${a}`;this.log("Rebasing relative path as:",l),Y(i,"attribs")?Q(i,r?"src":"href",l):"img"===s?i.src=l:"a"===s?function(t,e){const i=v(e);void 0!==i&&(t.href=i)}(i,l):"source"===s||"audio"===s||"video"===s||"track"===s||"input"===s?i.src=l:"area"===s?function(t,e){const i=v(e);void 0!==i&&(t.href=i)}(i,l):this.log("Unable to rebase relative path for element:",s)},t.registerCustomElements=async function(t,e){const i=t,s=i.tagName?.toLowerCase(),r=(Z(i,"is")||Z(i,"alt"))?.toLowerCase();if(["template","div"].includes(s)&&r){if("div"===s&&"template"!==Z(i,"role"))return;this._customElements.has(r)||(this.log(`Registering custom element: ${r}\n`,ht(i,128)),this._customElements.set(r,i),ot(i.parentNode,i))}},t.resolveCustomElements=async function(t,e){const i=t,s=i.tagName?.toLowerCase();let r=s;if("div"===r&&(r=Z(i,"role")?.toLowerCase()||r),r&&this._customElements.has(r)){this.log(`Processing custom element: ${r}\n`,ht(i,128));const e=this._customElements.get(r),n=(e.content||e).cloneNode(!0),a=st(n);if(a)for(const t of Array.from(i.attributes))"div"===s&&"role"===t.name||it(i,a,t.name);const o=new dt(W(n)).find((t=>"slot"===t.tagName?.toLowerCase()));o&&rt(o,...i.childNodes),rt(t,...n.childNodes)}},t.resolveTextNodeExpressions=async function(t,e){const i=t.nodeValue||"";if(3!==t.nodeType||!i?.trim())return;this.log("Processing node content value:\n",ct(i,128));const s=new RegExp(/{{ ([^}]+) }}/gm),r=Array.from(i.matchAll(s)).map((t=>t[1]));return this.effect((function(){let e=i;for(const i of r){const s=this.eval(i,{$elem:t});e=e.replace(`{{ ${i} }}`,String(s))}t.nodeValue=e}))},t.resolveDataAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"data",":");if(s){this.log(":data attribute found in:\n",ht(t,128)),et(i,"data",":");const r=e?.rootNode===t?this:this.subrenderer();t.renderer=r;const n=r.eval(s,{$elem:t});if(await Promise.all(Object.entries(n).map((([t,e])=>r._store.set(t,e)))),r!==this)for(const e of W(t,this._skipNodes))this._skipNodes.add(e);await r.mount(t,e)}},t.resolveClassAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"class",":");if(s){this.log(":class attribute found in:\n",ht(t,128)),et(i,"class",":");const e=Z(i,"class")||"";return this.effect((function(){const r=this.eval(s,{$elem:t});Q(i,"class",(r?`${e} ${r}`:e).trim())}))}},t.resolveTextAttributes=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"text",":");if(s){this.log(":text attribute found in:\n",ht(t,128)),et(i,"text",":");const e=e=>this.textContent(t,e);return this.effect((function(){e(this.eval(s,{$elem:t}))}))}},t.resolveHtmlAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"html",":");return s?(this.log(":html attribute found in:\n",ht(t,128)),et(i,"html",":"),this.effect((function(){const r=this.eval(s,{$elem:t});return new Promise((async t=>{const s=await this.preprocessString(r,e);await this.renderNode(s),nt(i,s),t()}))}))):void 0},t.resolveEventAttributes=async function(t,e){if(this._skipNodes.has(t))return;const i=t;for(const e of Array.from(i.attributes||[]))if(e.name.startsWith(":on:")||e.name.startsWith("data-on-")){const s=e.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!s)throw new Error(`Invalid event attribute: ${e.name}`);this.log(e.name,"attribute found in:\n",ht(t,128));const r=q(i,"prevent",":");et(i,e.name),et(i,"prevent",":");const n="submit"===s&&"FORM"===i.tagName.toUpperCase();t.addEventListener?.(s,(i=>((r||n)&&i.preventDefault(),this.eval(e.value,{$elem:t,$event:i}))))}},t.resolveForAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"for",":")?.trim();if(s){this.log(":for attribute found in:\n",ht(t,128)),et(i,"for",":");for(const e of W(t,this._skipNodes))this._skipNodes.add(e);const r=Z(i,"style")||"";X(i,"style","display: none;");const n=t.parentNode,a=this.createElement("template",t.ownerDocument);lt(n,a,t),ot(n,t),at(a,t),this.log(":for template:\n",ht(a,128));const o=s.split(" in ",2);if(2!==o.length)throw new Error(`Invalid :for format: \`${s}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=o;await this.effect((function(){const i=this.eval(h,{$elem:t});if(this.log(":for list items:",i),l.splice(0,l.length).forEach((t=>{ot(n,t),this._skipNodes.delete(t)})),!Array.isArray(i))return console.error(`Expression did not yield a list: \`${h}\` => \`${i}\``),Promise.resolve();const s=[];for(const n of i){const i=this.subrenderer();i._store.set(c,n);const a=t.cloneNode(!0);X(a,"style",r),l.push(a),this._skipNodes.add(a),s.push(i.mount(a,e)),this.log("Rendered list child:\n",ht(a,128))}const o=a.nextSibling;for(const t of l)lt(n,t,o);return Promise.all(s)}))}},t.resolveBindAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"bind",":");if(s){this.log(":bind attribute found in:\n",ht(t,128));const e=["change","input"],r=Z(i,":bind:on")?.split(",")||i.dataset?.bindOn?.split(",")||e;et(i,"bind",":"),tt(i,":bind:on"),tt(i,"data-bind-on");const n="checkbox"===Z(i,"type")?"checked":"value";s.includes(".")||this.has(s)||this.set(s,""),this.effect((function(){const e=this.eval(s,{$elem:t});"checked"===n?i.checked=!!e:i.value=e}));const a=`${s} = $elem.${n}`;for(const e of r)t.addEventListener(e,(()=>this.eval(a,{$elem:t})))}},t.resolveShowAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"show",":");if(s){this.log(":show attribute found in:\n",ht(t,128)),et(i,"show",":");const e="none"===i.style?.display?"":i.style?.display??Z(i,"style")?.split(";")?.find((t=>"display"===t.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const r=this.eval(s,{$elem:t});i.style?i.style.display=r?e:"none":Q(i,"style",`display: ${r?e:"none"};`)}))}},t.resolveCustomAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t;for(const e of Array.from(i.attributes||[])){const s=":attr:",r="data-attr-";if(e.name.startsWith(s)||e.name.startsWith(r)){this.log(e.name,"attribute found in:\n",ht(t,128)),tt(i,e.name);const n=e.name.split(s,2).at(-1)?.split(r,2).at(-1);this.effect((function(){const s=this.eval(e.value,{$elem:t});X(i,n,s)}))}}},t.resolveCustomProperty=async function(t,e){if(this._skipNodes.has(t))return;const i=t;for(const e of Array.from(i.attributes||[])){const s=":prop:",r="data-prop-";if(e.name.startsWith(s)||e.name.startsWith(r)){this.log(e.name,"property found in:\n",ht(t,128)),tt(i,e.name);const n=e.name.split(s,2).at(-1)?.split(r,2).at(-1),a=V(n);this.effect((function(){const s=this.eval(e.value,{$elem:t});J(i,a,s)}))}}}}(pt||(pt={}));const ft=["this"],_t=["+","-","!"],mt=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],Et={"!":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},wt=["==","!=","<=",">=","||","&&","??","|>"],vt=["===","!=="];var bt;!function(t){t[t.STRING=1]="STRING",t[t.IDENTIFIER=2]="IDENTIFIER",t[t.DOT=3]="DOT",t[t.COMMA=4]="COMMA",t[t.COLON=5]="COLON",t[t.INTEGER=6]="INTEGER",t[t.DECIMAL=7]="DECIMAL",t[t.OPERATOR=8]="OPERATOR",t[t.GROUPER=9]="GROUPER",t[t.KEYWORD=10]="KEYWORD",t[t.ARROW=11]="ARROW"}(bt||(bt={}));const gt=(t,e,i=0)=>({kind:t,value:e,precedence:i}),At=t=>95===t||36===t||65<=(t&=-33)&&t<=90,yt=t=>48<=t&&t<=57;class Rt{_input;_index=-1;_tokenStart=0;_next;constructor(t){this._input=t,this._advance()}nextToken(){for(;9===(t=this._next)||10===t||13===t||32===t;)this._advance(!0);var t;if((t=>34===t||39===t)(this._next))return this._tokenizeString();if(At(this._next))return this._tokenizeIdentOrKeyword();if(yt(this._next))return this._tokenizeNumber();if(46===this._next)return this._tokenizeDot();if(44===this._next)return this._tokenizeComma();if(58===this._next)return this._tokenizeColon();if((t=>43===t||45===t||42===t||47===t||33===t||38===t||37===t||60===t||61===t||62===t||63===t||94===t||124===t)(this._next))return this._tokenizeOperator();if((t=>40===t||41===t||91===t||93===t||123===t||125===t)(this._next))return this._tokenizeGrouper();if(this._advance(),void 0!==this._next)throw new Error(`Expected end of input, got ${this._next}`)}_advance(t){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),!0===t&&(this._tokenStart=this._index)):this._next=void 0}_getValue(t=0){const e=this._input.substring(this._tokenStart,this._index+t);return 0===t&&this._clearValue(),e}_clearValue(){this._tokenStart=this._index}_tokenizeString(){const t="unterminated string",e=this._next;for(this._advance(!0);this._next!==e;){if(void 0===this._next)throw new Error(t);if(92===this._next&&(this._advance(),void 0===this._next))throw new Error(t);this._advance()}const i=gt(bt.STRING,this._getValue().replace(/\\(.)/g,((t,e)=>{switch(e){case"n":return"\n";case"r":return"\r";case"t":return"\t";case"b":return"\b";case"f":return"\f";default:return e}})));return this._advance(),i}_tokenizeIdentOrKeyword(){do{this._advance()}while(t=this._next,At(t)||yt(t));var t;const e=this._getValue(),i=(s=e,-1!==ft.indexOf(s)?bt.KEYWORD:bt.IDENTIFIER);var s;return gt(i,e)}_tokenizeNumber(){do{this._advance()}while(yt(this._next));return 46===this._next?this._tokenizeDot():gt(bt.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),yt(this._next)?this._tokenizeFraction():(this._clearValue(),gt(bt.DOT,".",13))}_tokenizeComma(){return this._advance(!0),gt(bt.COMMA,",")}_tokenizeColon(){return this._advance(!0),gt(bt.COLON,":")}_tokenizeFraction(){do{this._advance()}while(yt(this._next));return gt(bt.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let t=this._getValue(2);if(-1!==vt.indexOf(t))this._advance(),this._advance();else{if(t=this._getValue(1),"=>"===t)return this._advance(),gt(bt.ARROW,t);-1!==wt.indexOf(t)&&this._advance()}return t=this._getValue(),gt(bt.OPERATOR,t,Et[t])}_tokenizeGrouper(){const t=String.fromCharCode(this._next),e=gt(bt.GROUPER,t,Et[t]);return this._advance(!0),e}}class Tt{_kind;_tokenizer;_ast;_token;_value;constructor(t,e){this._tokenizer=new Rt(t),this._ast=e}parse(){return this._advance(),this._parseExpression()}_advance(t,e){if(!this._matches(t,e))throw new Error(`Expected kind ${t} (${e}), was ${this._token?.kind} (${this._token?.value})`);const i=this._tokenizer.nextToken();this._token=i,this._kind=i?.kind,this._value=i?.value}_matches(t,e){return!(t&&this._kind!==t||e&&this._value!==e)}_parseExpression(){if(!this._token)return this._ast.empty();const t=this._parseUnary();return void 0===t?void 0:this._parsePrecedence(t,0)}_parsePrecedence(t,e){if(void 0===t)throw new Error("Expected left to be defined.");for(;this._token;)if(this._matches(bt.GROUPER,"(")){const e=this._parseArguments();t=this._ast.invoke(t,void 0,e)}else if(this._matches(bt.GROUPER,"[")){const e=this._parseIndex();t=this._ast.index(t,e)}else if(this._matches(bt.DOT)){this._advance();const e=this._parseUnary();t=this._makeInvokeOrGetter(t,e)}else{if(this._matches(bt.KEYWORD))break;if(!(this._matches(bt.OPERATOR)&&this._token.precedence>=e))break;t="?"===this._value?this._parseTernary(t):this._parseBinary(t,this._token)}return t}_makeInvokeOrGetter(t,e){if(void 0===e)throw new Error("expected identifier");if("ID"===e.type)return this._ast.getter(t,e.value);if("Invoke"===e.type&&"ID"===e.receiver.type){const i=e.receiver;return this._ast.invoke(t,i.value,e.arguments)}throw new Error(`expected identifier: ${e}`)}_parseBinary(t,e){if(-1===mt.indexOf(e.value))throw new Error(`unknown operator: ${e.value}`);this._advance();let i=this._parseUnary();for(;(this._kind===bt.OPERATOR||this._kind===bt.DOT||this._kind===bt.GROUPER)&&this._token.precedence>e.precedence;)i=this._parsePrecedence(i,this._token.precedence);return this._ast.binary(t,e.value,i)}_parseUnary(){if(this._matches(bt.OPERATOR)){const t=this._value;if(this._advance(),"+"===t||"-"===t){if(this._matches(bt.INTEGER))return this._parseInteger(t);if(this._matches(bt.DECIMAL))return this._parseDecimal(t)}if(-1===_t.indexOf(t))throw new Error(`unexpected token: ${t}`);const e=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(t,e)}return this._parsePrimary()}_parseTernary(t){this._advance(bt.OPERATOR,"?");const e=this._parseExpression();this._advance(bt.COLON);const i=this._parseExpression();return this._ast.ternary(t,e,i)}_parsePrimary(){switch(this._kind){case bt.KEYWORD:const t=this._value;if("this"===t)return this._advance(),this._ast.id(t);if(-1!==ft.indexOf(t))throw new Error(`unexpected keyword: ${t}`);throw new Error(`unrecognized keyword: ${t}`);case bt.IDENTIFIER:return this._parseInvokeOrIdentifier();case bt.STRING:return this._parseString();case bt.INTEGER:return this._parseInteger();case bt.DECIMAL:return this._parseDecimal();case bt.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case bt.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const t=[];do{if(this._advance(),this._matches(bt.GROUPER,"]"))break;t.push(this._parseExpression())}while(this._matches(bt.COMMA));return this._advance(bt.GROUPER,"]"),this._ast.list(t)}_parseMap(){const t={};do{if(this._advance(),this._matches(bt.GROUPER,"}"))break;const e=this._value;(this._matches(bt.STRING)||this._matches(bt.IDENTIFIER))&&this._advance(),this._advance(bt.COLON),t[e]=this._parseExpression()}while(this._matches(bt.COMMA));return this._advance(bt.GROUPER,"}"),this._ast.map(t)}_parseInvokeOrIdentifier(){const t=this._value;if("true"===t)return this._advance(),this._ast.literal(!0);if("false"===t)return this._advance(),this._ast.literal(!1);if("null"===t)return this._advance(),this._ast.literal(null);if("undefined"===t)return this._advance(),this._ast.literal(void 0);const e=this._parseIdentifier(),i=this._parseArguments();return i?this._ast.invoke(e,void 0,i):e}_parseIdentifier(){if(!this._matches(bt.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const t=this._value;return this._advance(),this._ast.id(t)}_parseArguments(){if(!this._matches(bt.GROUPER,"("))return;const t=[];do{if(this._advance(),this._matches(bt.GROUPER,")"))break;const e=this._parseExpression();t.push(e)}while(this._matches(bt.COMMA));return this._advance(bt.GROUPER,")"),t}_parseIndex(){this._advance();const t=this._parseExpression();return this._advance(bt.GROUPER,"]"),t}_parseParenOrFunction(){const t=this._parseArguments();if(this._matches(bt.ARROW)){this._advance();const e=this._parseExpression(),i=t?.map((t=>t.value))??[];return this._ast.arrowFunction(i,e)}return this._ast.paren(t[0])}_parseString(){const t=this._ast.literal(this._value);return this._advance(),t}_parseInteger(t=""){const e=this._ast.literal(parseInt(`${t}${this._value}`,10));return this._advance(),e}_parseDecimal(t=""){const e=this._ast.literal(parseFloat(`${t}${this._value}`));return this._advance(),e}}const Ot={"+":(t,e)=>t+e,"-":(t,e)=>t-e,"*":(t,e)=>t*e,"/":(t,e)=>t/e,"%":(t,e)=>t%e,"==":(t,e)=>t==e,"!=":(t,e)=>t!=e,"===":(t,e)=>t===e,"!==":(t,e)=>t!==e,">":(t,e)=>t>e,">=":(t,e)=>t>=e,"<":(t,e)=>t<e,"<=":(t,e)=>t<=e,"||":(t,e)=>t||e,"&&":(t,e)=>t&&e,"??":(t,e)=>t??e,"|":(t,e)=>e(t),"|>":(t,e)=>e(t)},Nt={"+":t=>t,"-":t=>-t,"!":t=>!t};class It{timeouts=new Map;debounce(t,e){return new Promise(((i,s)=>{const r=this.timeouts.get(e);r&&clearTimeout(r),this.timeouts.set(e,setTimeout((()=>{try{i(e()),this.timeouts.delete(e)}catch(t){s(t)}}),t))}))}}const Pt=new class{empty(){return{type:"Empty",evaluate:t=>t,getIds:t=>t}}literal(t){return{type:"Literal",value:t,evaluate(t){return this.value},getIds:t=>t}}id(t){return{type:"ID",value:t,evaluate(t){return"this"===this.value?t:t?.[this.value]},getIds(t){return t.push(this.value),t}}}unary(t,e){const i=Nt[t];return{type:"Unary",operator:t,child:e,evaluate(t){return i(this.child.evaluate(t))},getIds(t){return this.child.getIds(t)}}}binary(t,e,i){const s=Ot[e];return{type:"Binary",operator:e,left:t,right:i,evaluate(t){if("="===this.operator){if("ID"!==this.left.type&&"Getter"!==this.left.type&&"Index"!==this.left.type)throw new Error(`Invalid assignment target: ${this.left}`);const e=this.right.evaluate(t);let i,s;return"Getter"===this.left.type?(i=this.left.receiver.evaluate(t),s=this.left.name):"Index"===this.left.type?(i=this.left.receiver.evaluate(t),s=this.left.argument.evaluate(t)):"ID"===this.left.type&&(i=t,s=this.left.value),void 0===i?void 0:i[s]=e}return s(this.left.evaluate(t),this.right.evaluate(t))},getIds(t){return this.left.getIds(t),this.right.getIds(t),t}}}getter(t,e){return{type:"Getter",receiver:t,name:e,evaluate(t){return this.receiver.evaluate(t)?.[this.name]},getIds(t){return this.receiver.getIds(t),t}}}invoke(t,e,i){if(null!=e&&"string"!=typeof e)throw new Error("method not a string");return{type:"Invoke",receiver:t,method:e,arguments:i,evaluate(t){const i=this.receiver.evaluate(t),s=this.method?i:t?.this??t,r=this.method?i?.[e]:i,n=(this.arguments??[]).map((e=>e?.evaluate(t)));return r?.apply?.(s,n)},getIds(t){return this.receiver.getIds(t),this.arguments?.forEach((e=>e?.getIds(t))),t}}}paren(t){return t}index(t,e){return{type:"Index",receiver:t,argument:e,evaluate(t){return this.receiver.evaluate(t)?.[this.argument.evaluate(t)]},getIds(t){return this.receiver.getIds(t),t}}}ternary(t,e,i){return{type:"Ternary",condition:t,trueExpr:e,falseExpr:i,evaluate(t){return this.condition.evaluate(t)?this.trueExpr.evaluate(t):this.falseExpr.evaluate(t)},getIds(t){return this.condition.getIds(t),this.trueExpr.getIds(t),this.falseExpr.getIds(t),t}}}map(t){return{type:"Map",entries:t,evaluate(e){const i={};if(t&&this.entries)for(const s in t){const t=this.entries[s];t&&(i[s]=t.evaluate(e))}return i},getIds(e){if(t&&this.entries)for(const i in t){const t=this.entries[i];t&&t.getIds(e)}return e}}}list(t){return{type:"List",items:t,evaluate(t){return this.items?.map((e=>e?.evaluate(t)))},getIds(t){return this.items?.forEach((e=>e?.getIds(t))),t}}}arrowFunction(t,e){return{type:"ArrowFunction",params:t,body:e,evaluate(t){const e=this.params,i=this.body;return function(...s){const r=Object.fromEntries(e.map(((t,e)=>[t,s[e]]))),n=new Proxy(t??{},{set:(t,e,i)=>(r.hasOwnProperty(e)&&(r[e]=i),t[e]=i),get:(t,e)=>r.hasOwnProperty(e)?r[e]:t[e]});return i.evaluate(n)}},getIds(t){return this.body.getIds(t).filter((t=>!this.params.includes(t)))}}}};function St(t,e){const i=t?._store;return i?.has(e)?i.get(e):i?.has("$parent")?St(i.get("$parent"),e):null}function xt(t,e){const i=t?._store;return i?.has(e)?t:i?.has("$parent")?xt(i.get("$parent"),e):null}class Ct extends It{evalkeys=["$elem","$event"];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_observer=null;_store=new Map;_lock=Promise.resolve();constructor(t){super();for(let[e,i]of Object.entries(t||{}))this.set(e,i)}wrapFunction(t){return(...e)=>t.call(this.$,...e)}wrapObject(t,e){return null==t||((i=t)instanceof Ct||i.__is_proxy__)||t.constructor!==Object&&!Array.isArray(t)?t:new Proxy(t,{deleteProperty:(t,i)=>i in t&&(delete t[i],e(),!0),set:(i,s,r,n)=>{"object"==typeof r&&null!=t&&(r=this.wrapObject(r,e));const a=Reflect.set(i,s,r,n);return e(),a},get:(t,e,i)=>"__is_proxy__"===e||Reflect.get(t,e,i)});var i}watch(t,e){const i=xt(this,t);if(!i)throw new Error(`Cannot watch key "${t}" as it does not exist in the store.`);i.observers.has(t)||i.observers.set(t,new Set),i.observers.get(t)?.has(e)||i.observers.get(t)?.add(e)}addKeyHandler(t,e){this.keyHandlers.has(t)||this.keyHandlers.set(t,new Set),this.keyHandlers.get(t).add(e)}async notify(t,e=10){const i=xt(this,t),s=Array.from(i?.observers.get(t)||[]);await this.debounce(e,(()=>Promise.all(s.map((t=>t.call(this.proxify(t)))))))}get(t,e){return e&&this.watch(t,e),St(this,t)}async set(t,e){if(e===this._store.get(t))return;const i=()=>this.notify(t);e&&"function"==typeof e&&(e=this.wrapFunction(e)),e&&"object"==typeof e&&(e=this.wrapObject(e,i)),function(t,e,i){const s=xt(t,e);s?s._store.set(e,i):t._store.set(e,i)}(this,t,e);for(const[i,s]of this.keyHandlers.entries())if(i.test(t))for(const i of s)await Promise.resolve(i.call(this.$,t,e));await i()}async del(t){await this.set(t,null),this._store.delete(t),this.observers.delete(t)}keys(){return Array.from(this._store.keys())}has(t){return this._store.has(t)}effect(t){return t.call(this.proxify(t))}proxify(t){const e=Array.from(this._store.entries()).map((([t])=>t)),i=Object.fromEntries(e.map((t=>[t,null])));return new Proxy(i,{get:(e,i,s)=>"string"==typeof i&&xt(this,i)?this.get(i,t):"$"===i?this.proxify(t):Reflect.get(this,i,s),set:(t,e,i,s)=>("string"!=typeof e||e in this?Reflect.set(this,e,i,s):this.set(e,i),!0)})}get $(){return this.proxify()}makeEvalFunction(t){if(t.includes(";"))throw new Error("Complex expressions are not supported.");let e=null;if(t.includes(" = ")){const[i,s]=t.split(" = ");e=i.trim(),t=s.trim()}return(i,s)=>{const r=((t,e)=>new Tt(t,e).parse())(t,Pt),n=r?.getIds([])?.map((t=>[t,s[t]??i[t]??globalThis[t]])),a=r?.evaluate(Object.fromEntries(n||[]));if(!e)return a;!function(t,e,i){const s=e.split(".");for(let e=0;e<s.length-1;e++)s[e]in t||(t[s[e]]={}),t=t[s[e]];t[s[s.length-1]]=i}(i,e,a)}}cachedExpressionFunction(t){return t=t.trim(),this.expressionCache.has(t)||this.expressionCache.set(t,this.makeEvalFunction(t)),this.expressionCache.get(t)}eval(t,e={}){const i=this._observer?this:this.$;if(this._store.has(t))return i[t];{const s=this.cachedExpressionFunction(t);try{return s(i,e)}catch(e){return console.error(`Failed to evaluate expression: ${t}`),console.error(e),null}}}}const Lt="$$";function kt(t){return`${Lt}${t}`}function Dt(t){return t.keys().filter((t=>t.startsWith(Lt)))}function Ut(t,e,i){const s=function(t){return t.substring(Lt.length)}(e);let r=!1;if(i){const e=String(i);t.searchParams.get(s)!==e&&(t.searchParams.set(s,e),r=!0)}else t.searchParams.has(s)&&(t.searchParams.delete(s),r=!0);return r}async function zt(t){const e=new URL(window.location.href);await async function(t,e){for(const[i,s]of e.searchParams.entries()){const e=kt(i);t.get(e)!==s&&await t.set(e,s)}}(t,e),function(t,e){let i=!1;for(const s of Dt(e))Ut(t,s,e.get(s))&&(i=!0);i&&window.history.replaceState({},"",t.toString())}(e,t),t.addKeyHandler(new RegExp("^\\$\\$"),((t,e)=>{const i=new URL(window.location.href);Ut(i,t,e)&&window.history.replaceState({},"",i.toString())})),window.addEventListener("popstate",function(t){return async()=>{const e=new URL(window.location.href),i=new Set;for(const[s,r]of e.searchParams.entries()){const e=kt(s);i.add(e),t.get(e)!==r&&t.set(e,r)}const s=Dt(t);for(const e of s)i.has(e)||t.del(e)}}(t))}class $t extends Ct{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(t){return this.debugging=t,this}async fetchRemote(t,e){return fetch(t,{cache:e?.cache??"default"}).then((t=>t.text()))}async fetchLocal(t,e){return this.fetchRemote(t,e)}async preprocessString(t,e){this.log("Preprocessing string content with params:\n",e);const i=this.parseHTML(t,e);return await this.preprocessNode(i,e),i}async preprocessRemote(t,e){const i={};e?.cache&&(i.cache=e.cache);const s=await fetch(t,i).then((t=>t.text()));return this.preprocessString(s,{...e,dirpath:ut(t),rootDocument:e?.rootDocument??!t.endsWith(".tpl.html")})}async preprocessLocal(t,e){const i=await this.fetchLocal(t,e);return this.preprocessString(i,{...e,dirpath:ut(t),rootDocument:e?.rootDocument??!t.endsWith(".tpl.html")})}subrenderer(){const t=(new this.constructor).debug(this.debugging);return t._store.set("$parent",this),t._store.set("$rootRenderer",this.get("$rootRenderer")??this),t._customElements=this._customElements,t}log(...t){this.debugging&&console.debug(...t)}async preprocessNode(t,e){e={dirpath:this.dirpath,maxdepth:10,...e};const i=new dt(W(t,this._skipNodes)).map((async t=>{this.log("Preprocessing node:\n",ht(t,128)),await pt.resolveIncludes.call(this,t,e),await pt.rebaseRelativePaths.call(this,t,e),await pt.registerCustomElements.call(this,t,e),await pt.resolveCustomElements.call(this,t,e)}));return await Promise.all(i.generator()),t}async renderNode(t,e){for(const i of W(t,this._skipNodes))this.log("Rendering node:\n",ht(i,128)),await pt.resolveForAttribute.call(this,i,e),await pt.resolveDataAttribute.call(this,i,e),await pt.resolveTextAttributes.call(this,i,e),await pt.resolveHtmlAttribute.call(this,i,e),await pt.resolveShowAttribute.call(this,i,e),await pt.resolveClassAttribute.call(this,i,e),await pt.resolveBindAttribute.call(this,i,e),await pt.resolveEventAttributes.call(this,i,e),await pt.resolveTextNodeExpressions.call(this,i,e),await pt.resolveCustomAttribute.call(this,i,e),await pt.resolveCustomProperty.call(this,i,e);return t}async mount(t,e){e={...e,rootNode:t},J(t,"renderer",this),this._store.set("$rootNode",t),this.has("$rootRenderer")||this._store.set("$rootRenderer",this),this.get("$rootRenderer")===this&&await zt(this),await this.preprocessNode(t,e),await this.renderNode(t,e)}}const Mt=[":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 Ft extends $t{impl="safe_browser";dirpath=ut(globalThis.location?.href??"http://localhost/");parseHTML(t,e={rootDocument:!1}){for(const e of Mt)t=t.replace(new RegExp(`\\s:${e.slice(1)}=`,"g"),` data-${e.slice(1).replace(":","-")}=`);t=(t=(t=t.replace(/<include(.*) src="([^"]+)"(.*)><\/include>/g,'<link $1 rel="subresource" href="$2" $3>')).replace(/<template is="([^"]+)">([\s\S]*)<\/template>/g,'<div role="template" alt="$1">$2</div>')).replace(/<(\w+)-(\w+)(.*)>([\s\S]*)<\/(\w+)-(\w+)>/g,'<div role="$1-$2" $3>$4</div>');const i=Mt.map((t=>`data-${t.slice(1).replace(":","-")}`));i.push("data-testid");const s=(new F).allowDataAttributes(i).allowClassAttributes().allowStyleAttributes().build();if(this.log("parseHTML",t),this.log("sanitized",String(s.sanitize(t))),e.rootDocument){return K(new DOMParser,s.sanitize(t),"text/html")}return s.sanitizeToFragment(t)}serializeHTML(t){return(new XMLSerializer).serializeToString(t).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(t,e){return this.preprocessRemote(t,e)}createElement(t,e){return(e||document).createElement(t)}textContent(t,e){t.textContent=e}}const Gt=new Ft;export{Gt as Mancha,Ft as Renderer};
|
|
1
|
+
const t={};function e(t){0}class i{constructor(t,e){this.privateDoNotAccessOrElseWrappedAttributePrefix=e}toString(){return this.privateDoNotAccessOrElseWrappedAttributePrefix}}const s=i;function r(t){if(function(t){return t instanceof i}(t))return t.privateDoNotAccessOrElseWrappedAttributePrefix;throw new Error("")}function n(t){return Object.isFrozen(t)&&Object.isFrozen(t.raw)}function a(t){return-1===t.toString().indexOf("`")}a((t=>t``))||a((t=>t`\0`))||a((t=>t`\n`))||a((t=>t`\u0000`)),n``&&n`\0`&&n`\n`&&n`\u0000`;function o(e){const i=e[0].toLowerCase();return new s(t,i)}let l,c="google#safe";function h(){var t;return""!==c&&null!==(t=function(){if("undefined"!=typeof window)return window.trustedTypes}())&&void 0!==t?t:null}class u{constructor(t,i){e(),this.privateDoNotAccessOrElseWrappedHtml=t}toString(){return this.privateDoNotAccessOrElseWrappedHtml.toString()}}function d(e,i){return null!=i?i:new u(e,t)}"undefined"!=typeof window&&window.TrustedHTML;function p(t){var e;const i=t;return d(i,null===(e=function(){var t,e;if(void 0===l)try{l=null!==(e=null===(t=h())||void 0===t?void 0:t.createPolicy(c,{createHTML:t=>t,createScript:t=>t,createScriptURL:t=>t}))&&void 0!==e?e:null}catch(t){l=null}return l}())||void 0===e?void 0:e.createHTML(i))}function f(t){var e;if(null===(e=h())||void 0===e?void 0:e.isHTML(t))return t;if(t instanceof u)return t.privateDoNotAccessOrElseWrappedHtml;throw new Error("")}"undefined"!=typeof window&&window.TrustedScriptURL;"undefined"!=typeof window&&window.TrustedScript;function _(t,e){e.appendChild(t);let i=(new XMLSerializer).serializeToString(e);return i=i.slice(i.indexOf(">")+1,i.lastIndexOf("</")),p(i)}const m=["data:","http:","https:","mailto:","ftp:"],E=/^\s*(?!javascript:)(?:[\w+.-]+:|[^:/?#]*(?:[/?#]|$))/i;function w(t){if(!function(t){const e=!E.test(t);return e}(t))return t}function v(t){return w(t)}function b(t){const e=function(t){let e;try{e=new URL(t)}catch(t){return"https:"}return e.protocol}(t);return void 0!==e&&-1!==m.indexOf(e.toLowerCase())?t:"about:invalid#zClosurez"}function g(t,e){const i=e.createRange();i.selectNode(e.body);return function(t,e){return t.createContextualFragment(f(e))}(i,p(t))}function A(t){const e=t.nodeName;return"string"==typeof e?e:"FORM"}function y(t){return 3===t.nodeType}function T(t){const e=t.nodeType;return 1===e||"number"!=typeof e}var R,O;function N(t){try{return new URL(t,window.document.baseURI)}catch(t){return new URL("about:invalid")}}function I(t){return{valueOf:t}.valueOf()}!function(t){t[t.STYLE_TAG=0]="STYLE_TAG",t[t.STYLE_ATTRIBUTE=1]="STYLE_ATTRIBUTE",t[t.HTML_ATTRIBUTE=2]="HTML_ATTRIBUTE"}(R||(R={}));class P{constructor(t,e,i,s,r){this.allowedElements=t,this.elementPolicies=e,this.allowedGlobalAttributes=i,this.globalAttributePolicies=s,this.globallyAllowedAttributePrefixes=r}isAllowedElement(t){return"FORM"!==t&&(this.allowedElements.has(t)||this.elementPolicies.has(t))}getAttributePolicy(t,e){const i=this.elementPolicies.get(e);if(null==i?void 0:i.has(t))return i.get(t);if(this.allowedGlobalAttributes.has(t))return{policyAction:O.KEEP};const s=this.globalAttributePolicies.get(t);return s||(this.globallyAllowedAttributePrefixes&&[...this.globallyAllowedAttributePrefixes].some((e=>0===t.indexOf(e)))?{policyAction:O.KEEP}:{policyAction:O.DROP})}}!function(t){t[t.DROP=0]="DROP",t[t.KEEP=1]="KEEP",t[t.KEEP_AND_SANITIZE_URL=2]="KEEP_AND_SANITIZE_URL",t[t.KEEP_AND_NORMALIZE=3]="KEEP_AND_NORMALIZE",t[t.KEEP_AND_SANITIZE_STYLE=4]="KEEP_AND_SANITIZE_STYLE",t[t.KEEP_AND_USE_RESOURCE_URL_POLICY=5]="KEEP_AND_USE_RESOURCE_URL_POLICY",t[t.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET=6]="KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET"}(O||(O={}));const S=new Set(["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"]);const x=["ARTICLE","SECTION","NAV","ASIDE","H1","H2","H3","H4","H5","H6","HEADER","FOOTER","ADDRESS","P","HR","PRE","BLOCKQUOTE","OL","UL","LH","LI","DL","DT","DD","FIGURE","FIGCAPTION","MAIN","DIV","EM","STRONG","SMALL","S","CITE","Q","DFN","ABBR","RUBY","RB","RT","RTC","RP","DATA","TIME","CODE","VAR","SAMP","KBD","SUB","SUP","I","B","U","MARK","BDI","BDO","SPAN","BR","WBR","INS","DEL","PICTURE","PARAM","TRACK","MAP","TABLE","CAPTION","COLGROUP","COL","TBODY","THEAD","TFOOT","TR","TD","TH","SELECT","DATALIST","OPTGROUP","OPTION","OUTPUT","PROGRESS","METER","FIELDSET","LEGEND","DETAILS","SUMMARY","MENU","DIALOG","SLOT","CANVAS","FONT","CENTER","ACRONYM","BASEFONT","BIG","DIR","HGROUP","STRIKE","TT"],C=[["A",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["AREA",new Map([["href",{policyAction:O.KEEP_AND_SANITIZE_URL}]])],["LINK",new Map([["href",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY,conditions:new Map([["rel",new Set(["alternate","author","bookmark","canonical","cite","help","icon","license","next","prefetch","dns-prefetch","prerender","preconnect","preload","prev","search","subresource"])]])}]])],["SOURCE",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["IMG",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}],["srcset",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET}]])],["VIDEO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])],["AUDIO",new Map([["src",{policyAction:O.KEEP_AND_USE_RESOURCE_URL_POLICY}]])]],L=["title","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-current","aria-disabled","aria-dropeffect","aria-expanded","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-level","aria-live","aria-multiline","aria-multiselectable","aria-orientation","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","alt","align","autocapitalize","autocomplete","autocorrect","autofocus","autoplay","bgcolor","border","cellpadding","cellspacing","checked","color","cols","colspan","controls","datetime","disabled","download","draggable","enctype","face","formenctype","frameborder","height","hreflang","hidden","ismap","label","lang","loop","max","maxlength","media","minlength","min","multiple","muted","nonce","open","placeholder","preload","rel","required","reversed","role","rows","rowspan","selected","shape","size","sizes","slot","span","spellcheck","start","step","summary","translate","type","valign","value","width","wrap","itemscope","itemtype","itemid","itemprop","itemref"],k=[["dir",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["dir",new Set(["auto","ltr","rtl"])]])))}],["async",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["async",new Set(["async"])]])))}],["cite",{policyAction:O.KEEP_AND_SANITIZE_URL}],["loading",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["loading",new Set(["eager","lazy"])]])))}],["poster",{policyAction:O.KEEP_AND_SANITIZE_URL}],["target",{policyAction:O.KEEP_AND_NORMALIZE,conditions:I((()=>new Map([["target",new Set(["_self","_blank"])]])))}]],D=new P(new Set(x),new Map(C),new Set(L),new Map(k));new P(new Set(I((()=>x.concat(["STYLE"])))),new Map(C),new Set(I((()=>L.concat(["id","name","class"])))),new Map(I((()=>k.concat([["style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}]])))));class U{constructor(t,i,s,r,n){this.sanitizerTable=t,this.styleElementSanitizer=s,this.styleAttributeSanitizer=r,this.resourceUrlPolicy=n,this.changes=[],e()}sanitizeAssertUnchanged(t){return this.sanitize(t)}sanitize(t){const e=document.implementation.createHTMLDocument("");return _(this.sanitizeToFragmentInternal(t,e),e.body)}sanitizeToFragment(t){const e=document.implementation.createHTMLDocument("");return this.sanitizeToFragmentInternal(t,e)}sanitizeToFragmentInternal(t,e){const i=g(t,e),s=document.createTreeWalker(i,5,(t=>this.nodeFilter(t)));let r=s.nextNode();const n=e.createDocumentFragment();let a=n;for(;null!==r;){let t;if(y(r))if(this.styleElementSanitizer&&"STYLE"===a.nodeName){const e=this.styleElementSanitizer(r.data);t=this.createTextNode(e)}else t=this.sanitizeTextNode(r);else{if(!T(r)){throw new Error("")}t=this.sanitizeElementNode(r,e)}if(a.appendChild(t),r=s.firstChild(),r)a=t;else for(;!(r=s.nextSibling())&&(r=s.parentNode());)a=a.parentNode}return n}createTextNode(t){return document.createTextNode(t)}sanitizeTextNode(t){return this.createTextNode(t.data)}sanitizeElementNode(t,e){const i=A(t),s=e.createElement(i),r=t.attributes;for(const{name:t,value:e}of r){const n=this.sanitizerTable.getAttributePolicy(t,i);if(this.satisfiesAllConditions(n.conditions,r))switch(n.policyAction){case O.KEEP:z(s,t,e);break;case O.KEEP_AND_SANITIZE_URL:const r=b(e);r!==e&&this.recordChange(`Url in attribute ${t} was modified during sanitization. Original url:"${e}" was sanitized to: "${r}"`),z(s,t,r);break;case O.KEEP_AND_NORMALIZE:z(s,t,e.toLowerCase());break;case O.KEEP_AND_SANITIZE_STYLE:if(this.styleAttributeSanitizer){z(s,t,this.styleAttributeSanitizer(e))}else z(s,t,e);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY:if(this.resourceUrlPolicy){const r={type:R.HTML_ATTRIBUTE,attributeName:t,tagName:i},n=N(e),a=this.resourceUrlPolicy(n,r);a&&z(s,t,a.toString())}else z(s,t,e);break;case O.KEEP_AND_USE_RESOURCE_URL_POLICY_FOR_SRCSET:if(this.resourceUrlPolicy){const r={type:R.HTML_ATTRIBUTE,attributeName:t,tagName:i},n=$(e),a={parts:[]};for(const t of n.parts){const e=N(t.url),i=this.resourceUrlPolicy(e,r);i&&a.parts.push({url:i.toString(),descriptor:t.descriptor})}z(s,t,M(a))}else z(s,t,e);break;case O.DROP:this.recordChange(`Attribute: ${t} was dropped`)}else this.recordChange(`Not all conditions satisfied for attribute: ${t}.`)}return s}nodeFilter(t){if(y(t))return 1;if(!T(t))return 2;const e=A(t);return null===e?(this.recordChange(`Node name was null for node: ${t}`),2):this.sanitizerTable.isAllowedElement(e)?1:(this.recordChange(`Element: ${e} was dropped`),2)}recordChange(t){0}satisfiesAllConditions(t,e){var i;if(!t)return!0;for(const[s,r]of t){const t=null===(i=e.getNamedItem(s))||void 0===i?void 0:i.value;if(t&&!r.has(t))return!1}return!0}}function z(t,e,i){t.setAttribute(e,i)}function $(t){const e=[];for(const i of t.split(",")){const[t,s]=i.trim().split(/\s+/,2);e.push({url:t,descriptor:s})}return{parts:e}}function M(t){return t.parts.map((t=>{const{url:e,descriptor:i}=t;return`${e}${i?` ${i}`:""}`})).join(" , ")}class F{constructor(){this.calledBuild=!1,this.sanitizerTable=D}onlyAllowElements(t){const e=new Set,i=new Map;for(let s of t){if(s=s.toUpperCase(),!this.sanitizerTable.isAllowedElement(s))throw new Error(`Element: ${s}, is not allowed by html5_contract.textpb`);const t=this.sanitizerTable.elementPolicies.get(s);void 0!==t?i.set(s,t):e.add(s)}return this.sanitizerTable=new P(e,i,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}allowCustomElement(t,e){const i=new Set(this.sanitizerTable.allowedElements),s=new Map(this.sanitizerTable.elementPolicies);if(t=t.toUpperCase(),r=t,S.has(r.toUpperCase())||!/^[a-z][-_.a-z0-9]*-[-_.a-z0-9]*$/i.test(r))throw new Error(`Element: ${t} is not a custom element`);var r;if(e){const i=new Map;for(const t of e)i.set(t,{policyAction:O.KEEP});s.set(t,i)}else i.add(t);return this.sanitizerTable=new P(i,s,this.sanitizerTable.allowedGlobalAttributes,this.sanitizerTable.globalAttributePolicies),this}onlyAllowAttributes(t){const e=new Set,i=new Map,s=new Map;for(const s of t)this.sanitizerTable.allowedGlobalAttributes.has(s)&&e.add(s),this.sanitizerTable.globalAttributePolicies.has(s)&&i.set(s,this.sanitizerTable.globalAttributePolicies.get(s));for(const[e,i]of this.sanitizerTable.elementPolicies.entries()){const r=new Map;for(const[e,s]of i.entries())t.has(e)&&r.set(e,s);s.set(e,r)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,s,e,i),this}allowDataAttributes(t){const e=new Set(this.sanitizerTable.allowedGlobalAttributes);for(const i of t){if(0!==i.indexOf("data-"))throw new Error(`data attribute: ${i} does not begin with the prefix "data-"`);e.add(i)}return this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,e,this.sanitizerTable.globalAttributePolicies),this}allowStyleAttributes(){const t=new Map(this.sanitizerTable.globalAttributePolicies);return t.set("style",{policyAction:O.KEEP_AND_SANITIZE_STYLE}),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,this.sanitizerTable.allowedGlobalAttributes,t),this}allowClassAttributes(){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);return t.add("class"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}allowIdAttributes(){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);return t.add("id"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}allowIdReferenceAttributes(){const t=new Set(this.sanitizerTable.allowedGlobalAttributes);return t.add("aria-activedescendant").add("aria-controls").add("aria-labelledby").add("aria-owns").add("for").add("list"),this.sanitizerTable=new P(this.sanitizerTable.allowedElements,this.sanitizerTable.elementPolicies,t,this.sanitizerTable.globalAttributePolicies),this}withResourceUrlPolicy(t){return this.resourceUrlPolicy=t,this}build(){if(this.calledBuild)throw new Error("this sanitizer has already called build");return this.calledBuild=!0,new U(this.sanitizerTable,t,void 0,void 0,this.resourceUrlPolicy)}}function G(t,e,i,s){if(0===t.length){throw new Error("")}const n=t.map((t=>r(t))),a=i.toLowerCase();if(n.every((t=>0!==a.indexOf(t))))throw new Error(`Attribute "${i}" does not match any of the allowed prefixes.`);e.setAttribute(i,s)}function K(t,e,i){return t.parseFromString(f(e),i)}Error;const H=[o`:`,o`style`,o`class`];function*W(t,e=new Set){const i=new Set,s=Array.from(t.childNodes).filter((t=>!e.has(t)));for(yield t;s.length;){const t=s.shift();i.has(t)||(i.add(t),yield t),t.childNodes&&Array.from(t.childNodes).filter((t=>!e.has(t))).forEach((t=>s.push(t)))}}function Y(t,e){return void 0!==t?.[e]}function B(t,e){return"function"==typeof t?.[e]}function V(t){return t.replace(/-./g,(t=>t[1].toUpperCase()))}function Z(t,e){return Y(t,"attribs")?t.attribs?.[e]??null:t.getAttribute?.(e)??null}function j(t,e,i=""){return Z(t,i+e)||(t.dataset?.[V(e)]??null)}function q(t,e,i=""){return function(t,e){return Y(t,"attribs")?e in(t.attribs||{}):t.hasAttribute?.(e)??!1}(t,i+e)||Y(t.dataset,V(e))}function X(t,e,i){Y(t,"attribs")?t.attribs[e]=i:t.setAttribute?.(e,i)}function Q(t,e,i){Y(t,"attribs")?t.attribs[e]=i:G(H,t,e,i)}function J(t,e,i){switch(e){case"disabled":return void(t.disabled=i);case"selected":return void(t.selected=i);case"checked":return void(t.checked=i);default:t[e]=i}}function tt(t,e){Y(t,"attribs")?delete t.attribs[e]:t.removeAttribute?.(e)}function et(t,e,i=""){tt(t,`${i}${e}`),tt(t,`data-${e}`)}function it(t,e,i){if(Y(t,"attribs")&&Y(e,"attribs"))e.attribs[i]=t.attribs[i];else if(i.startsWith("data-")){const s=V(i.slice(5));e.dataset[s]=t.dataset?.[s]}else{const s=t?.getAttribute?.(i);Q(e,i,s||"")}}function st(t){if(Y(t,"firstElementChild"))return t.firstElementChild;return Array.from(t.children).find((t=>1===t.nodeType))}function rt(t,...e){if(B(t,"replaceWith"))return t.replaceWith(...e);{const i=t,s=i.parentNode,r=Array.from(s.childNodes).indexOf(i);e.forEach((t=>t.parentNode=s)),s.childNodes=[].concat(Array.from(s.childNodes).slice(0,r)).concat(e).concat(Array.from(s.childNodes).slice(r+1))}}function nt(t,...e){B(t,"replaceChildren")?t.replaceChildren(...e):(t.childNodes=e,e.forEach((e=>e.parentNode=t)))}function at(t,e){return B(e,"appendChild")?t.appendChild(e):(t.childNodes.push(e),e.parentNode=t,e)}function ot(t,e){return B(e,"removeChild")?t.removeChild(e):(nt(t,...Array.from(t.childNodes).filter((t=>t!==e))),e)}function lt(t,e,i){return i?B(t,"insertBefore")?t.insertBefore(e,i):(rt(i,e,i),e):at(t,e)}function ct(t,e=0){return t?t.length<=e?t:t.slice(0,e-1)+"…":""}function ht(t,e=0){return globalThis.DocumentFragment&&t instanceof DocumentFragment?Array.from(t.childNodes).map((t=>ht(t,e))).join(""):ct(t.outerHTML||t.nodeValue||String(t),e)}function ut(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):""}class dt{iterable;constructor(t){this.iterable=t}filter(t){return new dt(dt.filterGenerator(t,this.iterable))}map(t){return new dt(dt.mapGenerator(t,this.iterable))}find(t){for(const e of this.iterable)if(t(e))return e}array(){return Array.from(this.iterable)}*generator(){for(const t of this.iterable)yield t}static*filterGenerator(t,e){for(const i of e)t(i)&&(yield i)}static*mapGenerator(t,e){for(const i of e)yield t(i)}static equals(t,e){const i=t[Symbol.iterator](),s=e[Symbol.iterator]();let r=i.next(),n=s.next();for(;!r.done&&!n.done;){if(r.value!==n.value)return!1;r=i.next(),n=s.next()}return r.done===n.done}}var pt;!function(t){t.resolveIncludes=async function(t,e){const i=t,s=i.tagName?.toLowerCase();if(!["include","link"].includes(s))return;if("link"===s&&"subresource"!==Z(i,"rel"))return;this.log("include directive found in:\n",ht(t,128)),this.log("include params:",e);const r="link"===i.tagName.toLocaleLowerCase()?"href":"src",n=Z(i,r);if(!n)throw new Error(`"${r}" attribute missing from ${ht(t,128)}.`);const a=[];"include"===s&&a.push("src"),"link"===s&&a.push("rel","href");const o=e=>{const s=st(e);for(const t of Array.from(i.attributes))s&&!a.includes(t.name)&&it(i,s,t.name);rt(t,...e.childNodes)},l={...e,rootDocument:!1,maxdepth:e?.maxdepth-1};if(0===l.maxdepth)throw new Error("Maximum recursion depth reached.");if(n.includes("://")||n.startsWith("//"))this.log("Including remote file from absolute path:",n),await this.preprocessRemote(n,l).then(o);else if(e?.dirpath?.includes("://")||e?.dirpath?.startsWith("//")){const t=n.startsWith("/")?n:`${e.dirpath}/${n}`;this.log("Including remote file from relative path:",t),await this.preprocessRemote(t,l).then(o)}else if("/"===n.charAt(0))this.log("Including local file from absolute path:",n),await this.preprocessLocal(n,l).then(o);else{const t=e?.dirpath&&"."!==e?.dirpath?`${e?.dirpath}/${n}`:n;this.log("Including local file from relative path:",t),await this.preprocessLocal(t,l).then(o)}},t.rebaseRelativePaths=async function(t,e){const i=t,s=i.tagName?.toLowerCase();if(!e?.dirpath)return;const r=Z(i,"src"),n=Z(i,"href"),a=r||n;if(!a||((o=a).includes("://")||o.startsWith("/")||o.startsWith("#")||o.startsWith("data:")))return;var o;const l=`${e.dirpath}/${a}`;this.log("Rebasing relative path as:",l),Y(i,"attribs")?Q(i,r?"src":"href",l):"img"===s?i.src=l:"a"===s?function(t,e){const i=v(e);void 0!==i&&(t.href=i)}(i,l):"source"===s||"audio"===s||"video"===s||"track"===s||"input"===s?i.src=l:"area"===s?function(t,e){const i=v(e);void 0!==i&&(t.href=i)}(i,l):this.log("Unable to rebase relative path for element:",s)},t.registerCustomElements=async function(t,e){const i=t,s=i.tagName?.toLowerCase(),r=(Z(i,"is")||Z(i,"alt"))?.toLowerCase();if(["template","div"].includes(s)&&r){if("div"===s&&"template"!==Z(i,"role"))return;this._customElements.has(r)||(this.log(`Registering custom element: ${r}\n`,ht(i,128)),this._customElements.set(r,i),ot(i.parentNode,i))}},t.resolveCustomElements=async function(t,e){const i=t,s=i.tagName?.toLowerCase();let r=s;if("div"===r&&(r=Z(i,"role")?.toLowerCase()||r),r&&this._customElements.has(r)){this.log(`Processing custom element: ${r}\n`,ht(i,128));const e=this._customElements.get(r),n=(e.content||e).cloneNode(!0),a=st(n);if(a)for(const t of Array.from(i.attributes))"div"===s&&"role"===t.name||it(i,a,t.name);const o=new dt(W(n)).find((t=>"slot"===t.tagName?.toLowerCase()));o&&rt(o,...i.childNodes),rt(t,...n.childNodes)}},t.resolveTextNodeExpressions=async function(t,e){const i=t.nodeValue||"";if(3!==t.nodeType||!i?.trim())return;this.log("Processing node content value:\n",ct(i,128));const s=new RegExp(/{{ ([^}]+) }}/gm),r=Array.from(i.matchAll(s)).map((t=>t[1]));return this.effect((function(){let e=i;for(const i of r){const s=this.eval(i,{$elem:t});e=e.replace(`{{ ${i} }}`,String(s))}t.nodeValue=e}))},t.resolveDataAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"data",":");if(s){this.log(":data attribute found in:\n",ht(t,128)),et(i,"data",":");const r=e?.rootNode===t?this:this.subrenderer();t.renderer=r;const n=r.eval(s,{$elem:t});if(await Promise.all(Object.entries(n).map((([t,e])=>r._store.set(t,e)))),r!==this)for(const e of W(t,this._skipNodes))this._skipNodes.add(e);await r.mount(t,e)}},t.resolveClassAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"class",":");if(s){this.log(":class attribute found in:\n",ht(t,128)),et(i,"class",":");const e=Z(i,"class")||"";return this.effect((function(){const r=this.eval(s,{$elem:t});Q(i,"class",(r?`${e} ${r}`:e).trim())}))}},t.resolveTextAttributes=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"text",":");if(s){this.log(":text attribute found in:\n",ht(t,128)),et(i,"text",":");const e=e=>this.textContent(t,e);return this.effect((function(){e(this.eval(s,{$elem:t}))}))}},t.resolveHtmlAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"html",":");return s?(this.log(":html attribute found in:\n",ht(t,128)),et(i,"html",":"),this.effect((function(){const r=this.eval(s,{$elem:t});return new Promise((async t=>{const s=await this.preprocessString(r,e);await this.renderNode(s),nt(i,s),t()}))}))):void 0},t.resolveEventAttributes=async function(t,e){if(this._skipNodes.has(t))return;const i=t;for(const e of Array.from(i.attributes||[]))if(e.name.startsWith(":on:")||e.name.startsWith("data-on-")){const s=e.name.split(":on:",2).at(-1)?.split("data-on-",2).at(-1)||"";if(!s)throw new Error(`Invalid event attribute: ${e.name}`);this.log(e.name,"attribute found in:\n",ht(t,128));const r=q(i,"prevent",":");et(i,e.name),et(i,"prevent",":");const n="submit"===s&&"FORM"===i.tagName.toUpperCase();t.addEventListener?.(s,(i=>((r||n)&&i.preventDefault(),this.eval(e.value,{$elem:t,$event:i}))))}},t.resolveForAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"for",":")?.trim();if(s){this.log(":for attribute found in:\n",ht(t,128)),et(i,"for",":");for(const e of W(t,this._skipNodes))this._skipNodes.add(e);const r=Z(i,"style")||"";X(i,"style","display: none;");const n=t.parentNode,a=this.createElement("template",t.ownerDocument);lt(n,a,t),ot(n,t),at(a,t),this.log(":for template:\n",ht(a,128));const o=s.split(" in ",2);if(2!==o.length)throw new Error(`Invalid :for format: \`${s}\`. Expected "{key} in {expression}".`);const l=[],[c,h]=o;await this.effect((function(){const i=this.eval(h,{$elem:t});if(this.log(":for list items:",i),l.splice(0,l.length).forEach((t=>{ot(n,t),this._skipNodes.delete(t)})),!Array.isArray(i))return console.error(`Expression did not yield a list: \`${h}\` => \`${i}\``),Promise.resolve();const s=[];for(const n of i){const i=this.subrenderer();i._store.set(c,n);const a=t.cloneNode(!0);X(a,"style",r),l.push(a),this._skipNodes.add(a),s.push(i.mount(a,e)),this.log("Rendered list child:\n",ht(a,128))}const o=a.nextSibling;for(const t of l)lt(n,t,o);return Promise.all(s)}))}},t.resolveBindAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"bind",":");if(s){this.log(":bind attribute found in:\n",ht(t,128));const e=["change","input"],r=Z(i,":bind:on")?.split(",")||i.dataset?.bindOn?.split(",")||e;et(i,"bind",":"),tt(i,":bind:on"),tt(i,"data-bind-on");const n="checkbox"===Z(i,"type")?"checked":"value";s.includes(".")||this.has(s)||this.set(s,""),this.effect((function(){const e=this.eval(s,{$elem:t});"checked"===n?i.checked=!!e:i.value=e}));const a=`${s} = $elem.${n}`;for(const e of r)t.addEventListener(e,(()=>this.eval(a,{$elem:t})))}},t.resolveShowAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t,s=j(i,"show",":");if(s){this.log(":show attribute found in:\n",ht(t,128)),et(i,"show",":");const e="none"===i.style?.display?"":i.style?.display??Z(i,"style")?.split(";")?.find((t=>"display"===t.split(":")[0]))?.split(":")?.at(1)?.trim();this.effect((function(){const r=this.eval(s,{$elem:t});i.style?i.style.display=r?e:"none":Q(i,"style",`display: ${r?e:"none"};`)}))}},t.resolveCustomAttribute=async function(t,e){if(this._skipNodes.has(t))return;const i=t;for(const e of Array.from(i.attributes||[])){const s=":attr:",r="data-attr-";if(e.name.startsWith(s)||e.name.startsWith(r)){this.log(e.name,"attribute found in:\n",ht(t,128)),tt(i,e.name);const n=e.name.split(s,2).at(-1)?.split(r,2).at(-1);this.effect((function(){const s=this.eval(e.value,{$elem:t});X(i,n,s)}))}}},t.resolveCustomProperty=async function(t,e){if(this._skipNodes.has(t))return;const i=t;for(const e of Array.from(i.attributes||[])){const s=":prop:",r="data-prop-";if(e.name.startsWith(s)||e.name.startsWith(r)){this.log(e.name,"property found in:\n",ht(t,128)),tt(i,e.name);const n=e.name.split(s,2).at(-1)?.split(r,2).at(-1),a=V(n);this.effect((function(){const s=this.eval(e.value,{$elem:t});J(i,a,s)}))}}}}(pt||(pt={}));const ft=["this"],_t=["+","-","!"],mt=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],Et={"!":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},wt=["==","!=","<=",">=","||","&&","??","|>"],vt=["===","!=="];var bt;!function(t){t[t.STRING=1]="STRING",t[t.IDENTIFIER=2]="IDENTIFIER",t[t.DOT=3]="DOT",t[t.COMMA=4]="COMMA",t[t.COLON=5]="COLON",t[t.INTEGER=6]="INTEGER",t[t.DECIMAL=7]="DECIMAL",t[t.OPERATOR=8]="OPERATOR",t[t.GROUPER=9]="GROUPER",t[t.KEYWORD=10]="KEYWORD",t[t.ARROW=11]="ARROW"}(bt||(bt={}));const gt=(t,e,i=0)=>({kind:t,value:e,precedence:i}),At=t=>95===t||36===t||65<=(t&=-33)&&t<=90,yt=t=>48<=t&&t<=57;class Tt{_input;_index=-1;_tokenStart=0;_next;constructor(t){this._input=t,this._advance()}nextToken(){for(;9===(t=this._next)||10===t||13===t||32===t;)this._advance(!0);var t;if((t=>34===t||39===t)(this._next))return this._tokenizeString();if(At(this._next))return this._tokenizeIdentOrKeyword();if(yt(this._next))return this._tokenizeNumber();if(46===this._next)return this._tokenizeDot();if(44===this._next)return this._tokenizeComma();if(58===this._next)return this._tokenizeColon();if((t=>43===t||45===t||42===t||47===t||33===t||38===t||37===t||60===t||61===t||62===t||63===t||94===t||124===t)(this._next))return this._tokenizeOperator();if((t=>40===t||41===t||91===t||93===t||123===t||125===t)(this._next))return this._tokenizeGrouper();if(this._advance(),void 0!==this._next)throw new Error(`Expected end of input, got ${this._next}`)}_advance(t){this._index++,this._index<this._input.length?(this._next=this._input.charCodeAt(this._index),!0===t&&(this._tokenStart=this._index)):this._next=void 0}_getValue(t=0){const e=this._input.substring(this._tokenStart,this._index+t);return 0===t&&this._clearValue(),e}_clearValue(){this._tokenStart=this._index}_tokenizeString(){const t="unterminated string",e=this._next;for(this._advance(!0);this._next!==e;){if(void 0===this._next)throw new Error(t);if(92===this._next&&(this._advance(),void 0===this._next))throw new Error(t);this._advance()}const i=gt(bt.STRING,this._getValue().replace(/\\(.)/g,((t,e)=>{switch(e){case"n":return"\n";case"r":return"\r";case"t":return"\t";case"b":return"\b";case"f":return"\f";default:return e}})));return this._advance(),i}_tokenizeIdentOrKeyword(){do{this._advance()}while(t=this._next,At(t)||yt(t));var t;const e=this._getValue(),i=(s=e,-1!==ft.indexOf(s)?bt.KEYWORD:bt.IDENTIFIER);var s;return gt(i,e)}_tokenizeNumber(){do{this._advance()}while(yt(this._next));return 46===this._next?this._tokenizeDot():gt(bt.INTEGER,this._getValue())}_tokenizeDot(){return this._advance(),yt(this._next)?this._tokenizeFraction():(this._clearValue(),gt(bt.DOT,".",13))}_tokenizeComma(){return this._advance(!0),gt(bt.COMMA,",")}_tokenizeColon(){return this._advance(!0),gt(bt.COLON,":")}_tokenizeFraction(){do{this._advance()}while(yt(this._next));return gt(bt.DECIMAL,this._getValue())}_tokenizeOperator(){this._advance();let t=this._getValue(2);if(-1!==vt.indexOf(t))this._advance(),this._advance();else{if(t=this._getValue(1),"=>"===t)return this._advance(),gt(bt.ARROW,t);-1!==wt.indexOf(t)&&this._advance()}return t=this._getValue(),gt(bt.OPERATOR,t,Et[t])}_tokenizeGrouper(){const t=String.fromCharCode(this._next),e=gt(bt.GROUPER,t,Et[t]);return this._advance(!0),e}}class Rt{_kind;_tokenizer;_ast;_token;_value;constructor(t,e){this._tokenizer=new Tt(t),this._ast=e}parse(){return this._advance(),this._parseExpression()}_advance(t,e){if(!this._matches(t,e))throw new Error(`Expected kind ${t} (${e}), was ${this._token?.kind} (${this._token?.value})`);const i=this._tokenizer.nextToken();this._token=i,this._kind=i?.kind,this._value=i?.value}_matches(t,e){return!(t&&this._kind!==t||e&&this._value!==e)}_parseExpression(){if(!this._token)return this._ast.empty();const t=this._parseUnary();return void 0===t?void 0:this._parsePrecedence(t,0)}_parsePrecedence(t,e){if(void 0===t)throw new Error("Expected left to be defined.");for(;this._token;)if(this._matches(bt.GROUPER,"(")){const e=this._parseArguments();t=this._ast.invoke(t,void 0,e)}else if(this._matches(bt.GROUPER,"[")){const e=this._parseIndex();t=this._ast.index(t,e)}else if(this._matches(bt.DOT)){this._advance();const e=this._parseUnary();t=this._makeInvokeOrGetter(t,e)}else{if(this._matches(bt.KEYWORD))break;if(!(this._matches(bt.OPERATOR)&&this._token.precedence>=e))break;t="?"===this._value?this._parseTernary(t):this._parseBinary(t,this._token)}return t}_makeInvokeOrGetter(t,e){if(void 0===e)throw new Error("expected identifier");if("ID"===e.type)return this._ast.getter(t,e.value);if("Invoke"===e.type&&"ID"===e.receiver.type){const i=e.receiver;return this._ast.invoke(t,i.value,e.arguments)}throw new Error(`expected identifier: ${e}`)}_parseBinary(t,e){if(-1===mt.indexOf(e.value))throw new Error(`unknown operator: ${e.value}`);this._advance();let i=this._parseUnary();for(;(this._kind===bt.OPERATOR||this._kind===bt.DOT||this._kind===bt.GROUPER)&&this._token.precedence>e.precedence;)i=this._parsePrecedence(i,this._token.precedence);return this._ast.binary(t,e.value,i)}_parseUnary(){if(this._matches(bt.OPERATOR)){const t=this._value;if(this._advance(),"+"===t||"-"===t){if(this._matches(bt.INTEGER))return this._parseInteger(t);if(this._matches(bt.DECIMAL))return this._parseDecimal(t)}if(-1===_t.indexOf(t))throw new Error(`unexpected token: ${t}`);const e=this._parsePrecedence(this._parsePrimary(),13);return this._ast.unary(t,e)}return this._parsePrimary()}_parseTernary(t){this._advance(bt.OPERATOR,"?");const e=this._parseExpression();this._advance(bt.COLON);const i=this._parseExpression();return this._ast.ternary(t,e,i)}_parsePrimary(){switch(this._kind){case bt.KEYWORD:const t=this._value;if("this"===t)return this._advance(),this._ast.id(t);if(-1!==ft.indexOf(t))throw new Error(`unexpected keyword: ${t}`);throw new Error(`unrecognized keyword: ${t}`);case bt.IDENTIFIER:return this._parseInvokeOrIdentifier();case bt.STRING:return this._parseString();case bt.INTEGER:return this._parseInteger();case bt.DECIMAL:return this._parseDecimal();case bt.GROUPER:return"("===this._value?this._parseParenOrFunction():"{"===this._value?this._parseMap():"["===this._value?this._parseList():void 0;case bt.COLON:throw new Error('unexpected token ":"');default:return}}_parseList(){const t=[];do{if(this._advance(),this._matches(bt.GROUPER,"]"))break;t.push(this._parseExpression())}while(this._matches(bt.COMMA));return this._advance(bt.GROUPER,"]"),this._ast.list(t)}_parseMap(){const t={};do{if(this._advance(),this._matches(bt.GROUPER,"}"))break;const e=this._value;(this._matches(bt.STRING)||this._matches(bt.IDENTIFIER))&&this._advance(),this._advance(bt.COLON),t[e]=this._parseExpression()}while(this._matches(bt.COMMA));return this._advance(bt.GROUPER,"}"),this._ast.map(t)}_parseInvokeOrIdentifier(){const t=this._value;if("true"===t)return this._advance(),this._ast.literal(!0);if("false"===t)return this._advance(),this._ast.literal(!1);if("null"===t)return this._advance(),this._ast.literal(null);if("undefined"===t)return this._advance(),this._ast.literal(void 0);const e=this._parseIdentifier(),i=this._parseArguments();return i?this._ast.invoke(e,void 0,i):e}_parseIdentifier(){if(!this._matches(bt.IDENTIFIER))throw new Error(`expected identifier: ${this._value}`);const t=this._value;return this._advance(),this._ast.id(t)}_parseArguments(){if(!this._matches(bt.GROUPER,"("))return;const t=[];do{if(this._advance(),this._matches(bt.GROUPER,")"))break;const e=this._parseExpression();t.push(e)}while(this._matches(bt.COMMA));return this._advance(bt.GROUPER,")"),t}_parseIndex(){this._advance();const t=this._parseExpression();return this._advance(bt.GROUPER,"]"),t}_parseParenOrFunction(){const t=this._parseArguments();if(this._matches(bt.ARROW)){this._advance();const e=this._parseExpression(),i=t?.map((t=>t.value))??[];return this._ast.arrowFunction(i,e)}return this._ast.paren(t[0])}_parseString(){const t=this._ast.literal(this._value);return this._advance(),t}_parseInteger(t=""){const e=this._ast.literal(parseInt(`${t}${this._value}`,10));return this._advance(),e}_parseDecimal(t=""){const e=this._ast.literal(parseFloat(`${t}${this._value}`));return this._advance(),e}}const Ot={"+":(t,e)=>t+e,"-":(t,e)=>t-e,"*":(t,e)=>t*e,"/":(t,e)=>t/e,"%":(t,e)=>t%e,"==":(t,e)=>t==e,"!=":(t,e)=>t!=e,"===":(t,e)=>t===e,"!==":(t,e)=>t!==e,">":(t,e)=>t>e,">=":(t,e)=>t>=e,"<":(t,e)=>t<e,"<=":(t,e)=>t<=e,"||":(t,e)=>t||e,"&&":(t,e)=>t&&e,"??":(t,e)=>t??e,"|":(t,e)=>e(t),"|>":(t,e)=>e(t)},Nt={"+":t=>t,"-":t=>-t,"!":t=>!t};class It{timeouts=new Map;debounce(t,e){return new Promise(((i,s)=>{const r=this.timeouts.get(e);r&&clearTimeout(r),this.timeouts.set(e,setTimeout((()=>{try{i(e()),this.timeouts.delete(e)}catch(t){s(t)}}),t))}))}}const Pt=new class{empty(){return{type:"Empty",evaluate:t=>t,getIds:t=>t}}literal(t){return{type:"Literal",value:t,evaluate(t){return this.value},getIds:t=>t}}id(t){return{type:"ID",value:t,evaluate(t){return"this"===this.value?t:t?.[this.value]},getIds(t){return t.push(this.value),t}}}unary(t,e){const i=Nt[t];return{type:"Unary",operator:t,child:e,evaluate(t){return i(this.child.evaluate(t))},getIds(t){return this.child.getIds(t)}}}binary(t,e,i){const s=Ot[e];return{type:"Binary",operator:e,left:t,right:i,evaluate(t){if("="===this.operator){if("ID"!==this.left.type&&"Getter"!==this.left.type&&"Index"!==this.left.type)throw new Error(`Invalid assignment target: ${this.left}`);const e=this.right.evaluate(t);let i,s;return"Getter"===this.left.type?(i=this.left.receiver.evaluate(t),s=this.left.name):"Index"===this.left.type?(i=this.left.receiver.evaluate(t),s=this.left.argument.evaluate(t)):"ID"===this.left.type&&(i=t,s=this.left.value),void 0===i?void 0:i[s]=e}return s(this.left.evaluate(t),this.right.evaluate(t))},getIds(t){return this.left.getIds(t),this.right.getIds(t),t}}}getter(t,e){return{type:"Getter",receiver:t,name:e,evaluate(t){return this.receiver.evaluate(t)?.[this.name]},getIds(t){return this.receiver.getIds(t),t}}}invoke(t,e,i){if(null!=e&&"string"!=typeof e)throw new Error("method not a string");return{type:"Invoke",receiver:t,method:e,arguments:i,evaluate(t){const i=this.receiver.evaluate(t),s=this.method?i:t?.this??t,r=this.method?i?.[e]:i,n=(this.arguments??[]).map((e=>e?.evaluate(t)));return r?.apply?.(s,n)},getIds(t){return this.receiver.getIds(t),this.arguments?.forEach((e=>e?.getIds(t))),t}}}paren(t){return t}index(t,e){return{type:"Index",receiver:t,argument:e,evaluate(t){return this.receiver.evaluate(t)?.[this.argument.evaluate(t)]},getIds(t){return this.receiver.getIds(t),t}}}ternary(t,e,i){return{type:"Ternary",condition:t,trueExpr:e,falseExpr:i,evaluate(t){return this.condition.evaluate(t)?this.trueExpr.evaluate(t):this.falseExpr.evaluate(t)},getIds(t){return this.condition.getIds(t),this.trueExpr.getIds(t),this.falseExpr.getIds(t),t}}}map(t){return{type:"Map",entries:t,evaluate(e){const i={};if(t&&this.entries)for(const s in t){const t=this.entries[s];t&&(i[s]=t.evaluate(e))}return i},getIds(e){if(t&&this.entries)for(const i in t){const t=this.entries[i];t&&t.getIds(e)}return e}}}list(t){return{type:"List",items:t,evaluate(t){return this.items?.map((e=>e?.evaluate(t)))},getIds(t){return this.items?.forEach((e=>e?.getIds(t))),t}}}arrowFunction(t,e){return{type:"ArrowFunction",params:t,body:e,evaluate(t){const e=this.params,i=this.body;return function(...s){const r=Object.fromEntries(e.map(((t,e)=>[t,s[e]]))),n=new Proxy(t??{},{set:(t,e,i)=>(r.hasOwnProperty(e)&&(r[e]=i),t[e]=i),get:(t,e)=>r.hasOwnProperty(e)?r[e]:t[e]});return i.evaluate(n)}},getIds(t){return this.body.getIds(t).filter((t=>!this.params.includes(t)))}}}};function St(t,e){const i=t?._store;return i?.has(e)?i.get(e):i?.has("$parent")?St(i.get("$parent"),e):null}function xt(t,e){const i=t?._store;return i?.has(e)?t:i?.has("$parent")?xt(i.get("$parent"),e):null}class Ct extends It{evalkeys=["$elem","$event"];expressionCache=new Map;observers=new Map;keyHandlers=new Map;_observer=null;_store=new Map;_lock=Promise.resolve();constructor(t){super();for(let[e,i]of Object.entries(t||{}))this.set(e,i)}wrapFunction(t){return(...e)=>t.call(this.$,...e)}wrapObject(t,e){return null==t||((i=t)instanceof Ct||i.__is_proxy__)||t.constructor!==Object&&!Array.isArray(t)?t:new Proxy(t,{deleteProperty:(t,i)=>i in t&&(delete t[i],e(),!0),set:(i,s,r,n)=>{"object"==typeof r&&null!=t&&(r=this.wrapObject(r,e));const a=Reflect.set(i,s,r,n);return e(),a},get:(t,e,i)=>"__is_proxy__"===e||Reflect.get(t,e,i)});var i}watch(t,e){const i=xt(this,t);if(!i)throw new Error(`Cannot watch key "${t}" as it does not exist in the store.`);i.observers.has(t)||i.observers.set(t,new Set),i.observers.get(t)?.has(e)||i.observers.get(t)?.add(e)}addKeyHandler(t,e){this.keyHandlers.has(t)||this.keyHandlers.set(t,new Set),this.keyHandlers.get(t).add(e)}async notify(t,e=10){const i=xt(this,t),s=Array.from(i?.observers.get(t)||[]);await this.debounce(e,(()=>Promise.all(s.map((t=>t.call(this.proxify(t)))))))}get(t,e){return e&&this.watch(t,e),St(this,t)}async set(t,e){if(e===this._store.get(t))return;const i=()=>this.notify(t);e&&"function"==typeof e&&(e=this.wrapFunction(e)),e&&"object"==typeof e&&(e=this.wrapObject(e,i)),function(t,e,i){const s=xt(t,e);s?s._store.set(e,i):t._store.set(e,i)}(this,t,e);for(const[i,s]of this.keyHandlers.entries())if(i.test(t))for(const i of s)await Promise.resolve(i.call(this.$,t,e));await i()}async del(t){await this.set(t,null),this._store.delete(t),this.observers.delete(t)}keys(){return Array.from(this._store.keys())}has(t){return this._store.has(t)}effect(t){return t.call(this.proxify(t))}proxify(t){const e=Array.from(this._store.entries()).map((([t])=>t)),i=Object.fromEntries(e.map((t=>[t,null])));return new Proxy(i,{get:(e,i,s)=>"string"==typeof i&&xt(this,i)?this.get(i,t):"$"===i?this.proxify(t):Reflect.get(this,i,s),set:(t,e,i,s)=>("string"!=typeof e||e in this?Reflect.set(this,e,i,s):this.set(e,i),!0)})}get $(){return this.proxify()}makeEvalFunction(t){if(t.includes(";"))throw new Error("Complex expressions are not supported.");let e=null;if(t.includes(" = ")){const[i,s]=t.split(" = ");e=i.trim(),t=s.trim()}return(i,s)=>{const r=((t,e)=>new Rt(t,e).parse())(t,Pt),n=r?.getIds([])?.map((t=>[t,s[t]??i[t]??globalThis[t]])),a=r?.evaluate(Object.fromEntries(n||[]));if(!e)return a;!function(t,e,i){const s=e.split(".");for(let e=0;e<s.length-1;e++)s[e]in t||(t[s[e]]={}),t=t[s[e]];t[s[s.length-1]]=i}(i,e,a)}}cachedExpressionFunction(t){return t=t.trim(),this.expressionCache.has(t)||this.expressionCache.set(t,this.makeEvalFunction(t)),this.expressionCache.get(t)}eval(t,e={}){const i=this._observer?this:this.$;if(this._store.has(t))return i[t];{const s=this.cachedExpressionFunction(t);try{return s(i,e)}catch(e){return console.error(`Failed to evaluate expression: ${t}`),console.error(e),null}}}}const Lt="$$",kt="http://localhost/";function Dt(){return new URL(globalThis.window?.location?.href||kt)}function Ut(t){return`${Lt}${t}`}function zt(t){return t.keys().filter((t=>t.startsWith(Lt)))}function $t(t,e,i){const s=function(t){return t.substring(Lt.length)}(e);let r=!1;if(i){const e=String(i);t.searchParams.get(s)!==e&&(t.searchParams.set(s,e),r=!0)}else t.searchParams.has(s)&&(t.searchParams.delete(s),r=!0);return r}async function Mt(t){const e=Dt();await async function(t,e){for(const[i,s]of e.searchParams.entries()){const e=Ut(i);t.get(e)!==s&&await t.set(e,s)}}(t,e),function(t,e){let i=!1;for(const s of zt(e))$t(t,s,e.get(s))&&(i=!0);i&&globalThis.window?.history?.replaceState({},"",t.toString())}(e,t),t.addKeyHandler(new RegExp("^\\$\\$"),((t,e)=>{const i=Dt();$t(i,t,e)&&globalThis.window?.history?.replaceState({},"",i.toString())})),globalThis.window?.addEventListener("popstate",function(t){return async()=>{const e=Dt(),i=new Set;for(const[s,r]of e.searchParams.entries()){const e=Ut(s);i.add(e),t.get(e)!==r&&t.set(e,r)}const s=zt(t);for(const e of s)i.has(e)||t.del(e)}}(t))}class Ft extends Ct{debugging=!1;dirpath="";_skipNodes=new Set;_customElements=new Map;debug(t){return this.debugging=t,this}async fetchRemote(t,e){return fetch(t,{cache:e?.cache??"default"}).then((t=>t.text()))}async fetchLocal(t,e){return this.fetchRemote(t,e)}async preprocessString(t,e){this.log("Preprocessing string content with params:\n",e);const i=this.parseHTML(t,e);return await this.preprocessNode(i,e),i}async preprocessRemote(t,e){const i={};e?.cache&&(i.cache=e.cache);const s=await fetch(t,i).then((t=>t.text()));return this.preprocessString(s,{...e,dirpath:ut(t),rootDocument:e?.rootDocument??!t.endsWith(".tpl.html")})}async preprocessLocal(t,e){const i=await this.fetchLocal(t,e);return this.preprocessString(i,{...e,dirpath:ut(t),rootDocument:e?.rootDocument??!t.endsWith(".tpl.html")})}subrenderer(){const t=(new this.constructor).debug(this.debugging);return t._store.set("$parent",this),t._store.set("$rootRenderer",this.get("$rootRenderer")??this),t._customElements=this._customElements,t}log(...t){this.debugging&&console.debug(...t)}async preprocessNode(t,e){e={dirpath:this.dirpath,maxdepth:10,...e};const i=new dt(W(t,this._skipNodes)).map((async t=>{this.log("Preprocessing node:\n",ht(t,128)),await pt.resolveIncludes.call(this,t,e),await pt.rebaseRelativePaths.call(this,t,e),await pt.registerCustomElements.call(this,t,e),await pt.resolveCustomElements.call(this,t,e)}));return await Promise.all(i.generator()),t}async renderNode(t,e){for(const i of W(t,this._skipNodes))this.log("Rendering node:\n",ht(i,128)),await pt.resolveForAttribute.call(this,i,e),await pt.resolveDataAttribute.call(this,i,e),await pt.resolveTextAttributes.call(this,i,e),await pt.resolveHtmlAttribute.call(this,i,e),await pt.resolveShowAttribute.call(this,i,e),await pt.resolveClassAttribute.call(this,i,e),await pt.resolveBindAttribute.call(this,i,e),await pt.resolveEventAttributes.call(this,i,e),await pt.resolveTextNodeExpressions.call(this,i,e),await pt.resolveCustomAttribute.call(this,i,e),await pt.resolveCustomProperty.call(this,i,e);return t}async mount(t,e){e={...e,rootNode:t},J(t,"renderer",this),this._store.set("$rootNode",t),this.has("$rootRenderer")||this._store.set("$rootRenderer",this),this.get("$rootRenderer")===this&&await Mt(this),await this.preprocessNode(t,e),await this.renderNode(t,e)}}const Gt=[":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 Kt extends Ft{impl="safe_browser";dirpath=ut(globalThis.location?.href??"http://localhost/");parseHTML(t,e={rootDocument:!1}){for(const e of Gt)t=t.replace(new RegExp(`\\s:${e.slice(1)}=`,"g"),` data-${e.slice(1).replace(":","-")}=`);t=(t=(t=t.replace(/<include(.*) src="([^"]+)"(.*)><\/include>/g,'<link $1 rel="subresource" href="$2" $3>')).replace(/<template is="([^"]+)">([\s\S]*)<\/template>/g,'<div role="template" alt="$1">$2</div>')).replace(/<(\w+)-(\w+)(.*)>([\s\S]*)<\/(\w+)-(\w+)>/g,'<div role="$1-$2" $3>$4</div>');const i=Gt.map((t=>`data-${t.slice(1).replace(":","-")}`));i.push("data-testid");const s=(new F).allowDataAttributes(i).allowClassAttributes().allowStyleAttributes().build();if(this.log("parseHTML",t),this.log("sanitized",String(s.sanitize(t))),e.rootDocument){return K(new DOMParser,s.sanitize(t),"text/html")}return s.sanitizeToFragment(t)}serializeHTML(t){return(new XMLSerializer).serializeToString(t).replace(/\s?xmlns="[^"]+"/gm,"")}preprocessLocal(t,e){return this.preprocessRemote(t,e)}createElement(t,e){return(e||document).createElement(t)}textContent(t,e){t.textContent=e}}const Ht=new Kt;export{Ht as Mancha,Kt as Renderer};
|
package/dist/test_utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare function innerHTML(elem: Element): string;
|
|
2
2
|
export declare function getTextContent(elem: Element): string | null;
|
|
3
|
+
export declare function setupGlobalTestEnvironment(): Promise<void>;
|
|
3
4
|
export declare const assert: {
|
|
4
5
|
equal: (actual: any, expected: any, message?: string) => void;
|
|
5
6
|
deepEqual: (actual: any, expected: any, message?: string) => void;
|
package/dist/test_utils.js
CHANGED
|
@@ -14,6 +14,24 @@ export function getTextContent(elem) {
|
|
|
14
14
|
else
|
|
15
15
|
return DomUtils.textContent(elem);
|
|
16
16
|
}
|
|
17
|
+
export async function setupGlobalTestEnvironment() {
|
|
18
|
+
// Set up global test environment for DOM manipulation.
|
|
19
|
+
// Fall back to JSDOM for DOM manipulation during testing.
|
|
20
|
+
if (!globalThis.window) {
|
|
21
|
+
// Import JSDOM dynamically, because it's not available in browser context.
|
|
22
|
+
const { JSDOM } = await import("jsdom");
|
|
23
|
+
const dom = new JSDOM(``, { url: "http://localhost/" });
|
|
24
|
+
// Types.
|
|
25
|
+
globalThis.Document = globalThis.Document || dom.window.Document;
|
|
26
|
+
globalThis.DocumentFragment = globalThis.DocumentFragment || dom.window.DocumentFragment;
|
|
27
|
+
// Objects and Classes.
|
|
28
|
+
globalThis.window = globalThis.window || dom.window;
|
|
29
|
+
globalThis.document = globalThis.document || dom.window.document;
|
|
30
|
+
globalThis.DOMParser = globalThis.DOMParser || dom.window.DOMParser;
|
|
31
|
+
globalThis.XMLSerializer = globalThis.XMLSerializer || dom.window.XMLSerializer;
|
|
32
|
+
globalThis.PopStateEvent = globalThis.PopStateEvent || dom.window.PopStateEvent;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
17
35
|
// Map the assert methods using Chai.
|
|
18
36
|
chai.use(chaiAsPromised);
|
|
19
37
|
export const assert = {
|
|
@@ -42,19 +60,4 @@ export const assert = {
|
|
|
42
60
|
await chai.expect(p, message).to.eventually.be.rejected;
|
|
43
61
|
},
|
|
44
62
|
};
|
|
45
|
-
// Fall back to JSDOM for DOM manipulation during testing.
|
|
46
|
-
if (!globalThis.window) {
|
|
47
|
-
// Import JSDOM dynamically, because it's not available in browser context.
|
|
48
|
-
const { JSDOM } = await import("jsdom");
|
|
49
|
-
const dom = new JSDOM(``, { url: "http://localhost/" });
|
|
50
|
-
// Types.
|
|
51
|
-
globalThis.Document = globalThis.Document || dom.window.Document;
|
|
52
|
-
globalThis.DocumentFragment = globalThis.DocumentFragment || dom.window.DocumentFragment;
|
|
53
|
-
// Objects and Classes.
|
|
54
|
-
globalThis.window = globalThis.window || dom.window;
|
|
55
|
-
globalThis.document = globalThis.document || dom.window.document;
|
|
56
|
-
globalThis.DOMParser = globalThis.DOMParser || dom.window.DOMParser;
|
|
57
|
-
globalThis.XMLSerializer = globalThis.XMLSerializer || dom.window.XMLSerializer;
|
|
58
|
-
globalThis.PopStateEvent = globalThis.PopStateEvent || dom.window.PopStateEvent;
|
|
59
|
-
}
|
|
60
63
|
//# sourceMappingURL=test_utils.js.map
|
package/dist/test_utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_utils.js","sourceRoot":"","sources":["../src/test_utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,IAAI,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC;;QACrD,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAW,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAa;IAC1C,IAAI,WAAW,CAAC,IAAI,EAAE,aAAa,CAAC;QAAE,OAAO,IAAI,CAAC,WAAW,CAAC;;QACzD,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAW,CAAC,CAAC;AAChD,CAAC;AAED,
|
|
1
|
+
{"version":3,"file":"test_utils.js","sourceRoot":"","sources":["../src/test_utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,IAAI,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC;;QACrD,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAW,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAa;IAC1C,IAAI,WAAW,CAAC,IAAI,EAAE,aAAa,CAAC;QAAE,OAAO,IAAI,CAAC,WAAW,CAAC;;QACzD,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAW,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,0BAA0B;IAC9C,uDAAuD;IAEvD,0DAA0D;IAC1D,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QACvB,2EAA2E;QAC3E,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,mBAAmB,EAAE,CAAC,CAAC;QAExD,SAAS;QACT,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjE,UAAU,CAAC,gBAAgB,GAAG,UAAU,CAAC,gBAAgB,IAAI,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC;QAEzF,uBAAuB;QACvB,UAAU,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,IAAK,GAAG,CAAC,MAAgD,CAAC;QAC/F,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjE,UAAU,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;QACpE,UAAU,CAAC,aAAa,GAAG,UAAU,CAAC,aAAa,IAAI,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC;QAChF,UAAU,CAAC,aAAa,GAAG,UAAU,CAAC,aAAa,IAAI,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC;IAClF,CAAC;AACH,CAAC;AAED,qCAAqC;AACrC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AACzB,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,CAAC,MAAW,EAAE,QAAa,EAAE,OAAgB,EAAE,EAAE;QACtD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;IACD,SAAS,EAAE,CAAC,MAAW,EAAE,QAAa,EAAE,OAAgB,EAAE,EAAE;QAC1D,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACvD,CAAC;IACD,QAAQ,EAAE,CAAC,MAAW,EAAE,QAAa,EAAE,OAAgB,EAAE,EAAE;QACzD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACtD,CAAC;IACD,YAAY,EAAE,CAAC,MAAW,EAAE,QAAa,EAAE,OAAgB,EAAE,EAAE;QAC7D,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC;IACD,EAAE,EAAE,CAAC,KAAU,EAAE,OAAgB,EAAE,EAAE;QACnC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACvC,CAAC;IACD,IAAI,EAAE,CAAC,OAAgB,EAAE,EAAE;QACzB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IACD,MAAM,EAAE,CAAC,EAAc,EAAE,OAAgB,EAAE,EAAE;QAC3C,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IACtC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,CAAe,EAAE,OAAgB,EAAE,EAAE;QACnD,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,QAAQ,CAAC;IAC1D,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mancha",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.4",
|
|
4
4
|
"description": "Javscript HTML rendering engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"@types/yargs": "^17.0.29",
|
|
49
49
|
"@web/test-runner": "^0.19.0",
|
|
50
50
|
"@web/test-runner-playwright": "^0.11.1",
|
|
51
|
-
"@web/test-runner-puppeteer": "^0.17.0",
|
|
52
51
|
"chai": "^5.1.2",
|
|
53
52
|
"chai-as-promised": "^8.0.1",
|
|
54
53
|
"css-loader": "^7.1.2",
|