@dinoreic/fez 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/fez.js +18 -15
- package/dist/fez.js.map +4 -4
- package/package.json +1 -1
- package/src/fez/defaults.js +36 -1
- package/src/fez/instance.js +43 -13
- package/src/fez/root.js +2 -13
- package/src/fez/utility.js +13 -0
- package/src/{log.js → fez/utils/dump.js} +99 -42
- package/dist/log.js +0 -5
- package/dist/log.js.map +0 -7
package/README.md
CHANGED
|
@@ -144,6 +144,7 @@ This example showcases:
|
|
|
144
144
|
* **Reactive State Management** - Built-in reactive `state` object automatically triggers re-renders on property changes
|
|
145
145
|
* **DOM Morphing** - Uses [Idiomorph](https://github.com/bigskysoftware/idiomorph) for intelligent DOM updates that preserve element state and animations
|
|
146
146
|
* **Preserve DOM Elements** - Use `fez-keep="unique-key"` attribute to preserve DOM elements across re-renders (useful for animations, form inputs, or stateful elements)
|
|
147
|
+
* **DOM Memoization** - Use `fez-memoize="key"` attribute to memoize and restore DOM content by key (component-scoped) or `<fez-memoize key="unique-key">` component for global memoization
|
|
147
148
|
* **Style Macros** - Define custom CSS shortcuts like `Fez.styleMacro('mobile', '@media (max-width: 768px)')` and use as `:mobile { ... }`
|
|
148
149
|
* **Scoped & Global Styles** - Components can define both scoped CSS (`:fez { ... }`) and global styles in the same component
|
|
149
150
|
|
|
@@ -473,6 +474,10 @@ All parts are optional
|
|
|
473
474
|
<!-- preserve state by key, not affected by state changes-->>
|
|
474
475
|
<p fez-keep="key">...</p>
|
|
475
476
|
|
|
477
|
+
<!-- memoize DOM content by key (component-scoped) -->
|
|
478
|
+
<!-- stores DOM on first render, restores on subsequent renders with same key -->
|
|
479
|
+
<div fez-memoize="unique-key">expensive content</div>
|
|
480
|
+
|
|
476
481
|
<!-- :attribute for evaluated attributes (converts to JSON) -->
|
|
477
482
|
<div :data-config="state.config"></div>
|
|
478
483
|
</div>
|
|
@@ -547,6 +552,45 @@ Fez.onError = (kind, error) => {
|
|
|
547
552
|
}
|
|
548
553
|
```
|
|
549
554
|
|
|
555
|
+
## Default Components
|
|
556
|
+
|
|
557
|
+
Fez includes several built-in components available when you include `defaults.js`:
|
|
558
|
+
|
|
559
|
+
### fez-component
|
|
560
|
+
Dynamically includes a Fez component by name:
|
|
561
|
+
```html
|
|
562
|
+
<fez-component name="some-node" :props="fez.props"></fez-component>
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
### fez-include
|
|
566
|
+
Loads remote HTML content via URL:
|
|
567
|
+
```html
|
|
568
|
+
<fez-include src="./demo/fez/ui-slider.html"></fez-include>
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
### fez-inline
|
|
572
|
+
Creates inline components with reactive state:
|
|
573
|
+
```html
|
|
574
|
+
<fez-inline :state="{count: 0}">
|
|
575
|
+
<button onclick="fez.state.count += 1">+</button>
|
|
576
|
+
{{ state.count }} * {{ state.count }} = {{ state.count * state.count }}
|
|
577
|
+
</fez-inline>
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
### fez-memoize
|
|
581
|
+
Memoizes DOM content by key (global scope):
|
|
582
|
+
```html
|
|
583
|
+
<!-- First render: stores the content -->
|
|
584
|
+
<fez-memoize key="unique-key">
|
|
585
|
+
<expensive-component></expensive-component>
|
|
586
|
+
</fez-memoize>
|
|
587
|
+
|
|
588
|
+
<!-- Subsequent renders: restores stored content instantly -->
|
|
589
|
+
<fez-memoize key="unique-key">
|
|
590
|
+
<!-- Content here is ignored, stored version is used -->
|
|
591
|
+
</fez-memoize>
|
|
592
|
+
```
|
|
593
|
+
|
|
550
594
|
## Global State Management
|
|
551
595
|
|
|
552
596
|
Fez includes a built-in global state manager that automatically tracks component subscriptions. It automatically tracks which components use which state variables and only updates exactly what's needed.
|
package/dist/fez.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
(()=>{var
|
|
1
|
+
(()=>{var Ae=Object.defineProperty;var Ce=(r,e)=>()=>(r&&(e=r(r=0)),e);var we=(r,e)=>{for(var t in e)Ae(r,t,{get:e[t],enumerable:!0})};var ce={};we(ce,{loadDefaults:()=>le});var le,ae=Ce(()=>{le=()=>{Fez("fez-component",class{init(e){let t=document.createElement(e.name);for(t.props=e.props||e["data-props"]||e;this.root.firstChild;)this.root.parentNode.insertBefore(this.root.lastChild,t.nextSibling);this.root.innerHTML="",this.root.appendChild(t)}}),Fez("fez-include",class{init(e){Fez.fetch(e.src,t=>{let n=Fez.domRoot(t);Fez.head(n),this.root.innerHTML=n.innerHTML})}}),Fez("fez-inline",class{init(e){let t=this.root.innerHTML;if(this.root.innerHTML.includes("<")){let o=`inline-${Fez.fnv1(this.root.outerHTML)}`;Fez(o,class{HTML=t;init(){Object.assign(this.state,e.state||{})}});let s=document.createElement(o);this.root.after(this.root.lastChild,s),this.root.remove()}}});let r=new Map;Fez("fez-memoize",class{init(e){if(!e.key){Fez.error("fez-memoize: key prop is required");return}if(r.has(e.key)){let t=r.get(e.key);Fez.log(`Memoize - key: "${e.key}" - restore`),this.root.innerHTML="",this.root.appendChild(t.cloneNode(!0))}}onMount(e){r.has(e.key)||requestAnimationFrame(()=>{let t=document.createElement("div");t.innerHTML=this.root.innerHTML,Fez.log(`Memoize - key: "${e.key}" - set`),r.set(e.key,t)})}})};typeof Fez<"u"&&Fez&&le()});function D(r,e={},t){if(typeof e=="string"&&([e,t]=[t,e],e||={}),e instanceof Node&&(t=e,e={}),Array.isArray(r)&&(t=r,r="div"),(typeof e!="object"||Array.isArray(e))&&(t=e,e={}),r.includes(".")){let o=r.split(".");r=o.shift()||"div";let s=o.join(" ");e.class?e.class+=` ${s}`:e.class=s}let n=document.createElement(r);for(let[o,s]of Object.entries(e))if(typeof s=="function")n[o]=s.bind(this);else{let i=String(s).replaceAll("fez.",this.fezHtmlRoot);n.setAttribute(o,i)}if(t)if(Array.isArray(t))for(let o of t)n.appendChild(o);else t instanceof Node?n.appendChild(t):n.innerHTML=String(t);return n}function Te(r,e){if(r=r.replace(/^#?raw/,"@html").replace(/^#?html/,"@html"),r.startsWith("#if")||r.startsWith("if"))return e.push(!1),r=r.replace(/^#?if/,""),`\${ ${r} ? \``;if(r.startsWith("#unless")||r.startsWith("unless"))return e.push(!1),r=r.replace(/^#?unless/,""),`\${ !(${r}) ? \``;if(r=="/block")return"`) && ''}";if(r.startsWith("#for")||r.startsWith("for")){r=r.replace(/^#?for/,"");let t=r.split(" in ",2);return"${"+t[1]+".map(("+t[0]+")=>`"}else if(r.startsWith("#each")||r.startsWith("each")){r=r.replace(/^#?each/,"");let t=r.split(" as ",2);return"${"+t[0]+".map(("+t[1]+")=>`"}else{if(r==":else"||r=="else")return e[e.length-1]=!0,"` : `";if(r=="/if"||r=="/unless")return e.pop()?"`}":"` : ``}";if(r=="/for"||r=="/each")return'`).join("")}';{let t="@html ";return r.startsWith("json ")&&(r=r.replace("json ","@html '<pre class=json>'+JSON.stringify("),r+=", null, 2) + '</pre>'"),r.startsWith(t)?r=r.replace(t,""):r=`Fez.htmlEscape(${r})`,"${"+r+"}"}}}function N(r,e={}){let t=[];r=r.replaceAll("[[","{{").replaceAll("]]","}}"),r=r.replace(/(\w+)=\{\{\s*(.*?)\s*\}\}([\s>])/g,(s,i,u,f)=>`${i}="{{ ${u} }}"${f}`);let n={};r=r.replace(/\{\{block\s+(\w+)\s*\}\}([^§]+)\{\{\/block\}\}/g,(s,i,u)=>(n[i]=u,"")),r=r.replace(/\{\{block:([\w\-]+)\s*\}\}/g,(s,i)=>n[i]||`block:${i}?`),r=r.replace(/:(\w+)="([\w\.\[\]]+)"/,(s,i,u)=>`:${i}=Fez.store.delete({{ Fez.store.set(${u}) }})`);let o=r.replace(/{{(.*?)}}/g,(s,i)=>(i=i.replaceAll("`","`"),i=i.replaceAll("<","<").replaceAll(">",">").replaceAll("&","&"),Te(i,t)));o=o.replace(/<!\-\-.*?\-\->/g,"").replace(/>\s+</g,"><"),o="`"+o.trim()+"`";try{let s=`const fez = this;
|
|
2
2
|
with (this) {
|
|
3
|
-
return ${
|
|
3
|
+
return ${o}
|
|
4
4
|
}
|
|
5
|
-
`,i=new Function(
|
|
5
|
+
`,i=new Function(s);return f=>{try{return i.bind(f)()}catch(m){m.message=`FEZ template runtime error: ${m.message}
|
|
6
6
|
|
|
7
|
-
Template source: ${
|
|
8
|
-
${n}`,console.error(o),()=>Fez.error("Template Compile Error",!0)}}var _=class{static getProps(e,t){let s={};if(e.props)return e.props;for(let n of e.attributes)s[n.name]=n.value;for(let[n,o]of Object.entries(s))if([":"].includes(n[0])){delete s[n];try{let i=new Function(`return (${o})`).bind(t)();s[n.replace(/[\:_]/,"")]=i}catch(i){console.error(`Fez: Error evaluating attribute ${n}="${o}" for ${e.tagName}: ${i.message}`)}}if(s["data-props"]){let n=s["data-props"];if(typeof n=="object")return n;n[0]!="{"&&(n=decodeURIComponent(n));try{s=JSON.parse(n)}catch(o){console.error(`Fez: Invalid JSON in data-props for ${e.tagName}: ${o.message}`)}}else if(s["data-json-template"]){let n=t.previousSibling?.textContent;if(n)try{s=JSON.parse(n),t.previousSibling.remove()}catch(o){console.error(`Fez: Invalid JSON in template for ${e.tagName}: ${o.message}`)}}return s}static formData(e){let t=e.closest("form")||e.querySelector("form");if(!t)return Fez.log("No form found for formData()"),{};let s=new FormData(t),n={};return s.forEach((o,i)=>{n[i]=o}),n}static nodeName="div";constructor(){}n=k;get fezHtmlRoot(){return`Fez(${this.UID}).`}get isConnected(){return this.root?.isConnected?!0:(this.fezOnDestroy(),!1)}prop(e){let t=this.oldRoot[e]||this.props[e];return typeof t=="function"&&(t=t.bind(this.root)),t}copy(){for(let e of Array.from(arguments)){let t=this.props[e];if(t!==void 0){if(e=="class"){let s=this.root.getAttribute(e,t);s&&(t=[s,t].join(" "))}(e=="style"||!this.root[e])&&(typeof t=="string"?this.root.setAttribute(e,t):this.root[e]=t)}}}fezOnDestroy(){this._onDestroyCallbacks&&(this._onDestroyCallbacks.forEach(e=>{try{e()}catch(t){console.error("Fez: Error in cleanup callback:",t)}}),this._onDestroyCallbacks=[]),this.onDestroy(),this.onDestroy=()=>{},this.root&&(this.root.fez=void 0),this.root=void 0}addOnDestroy(e){this._onDestroyCallbacks=this._onDestroyCallbacks||[],this._onDestroyCallbacks.push(e)}on(e,t,s=200){this._eventHandlers=this._eventHandlers||{},this._eventHandlers[e]&&window.removeEventListener(e,this._eventHandlers[e]);let n=Fez.throttle(()=>{this.isConnected&&t.call(this)},s);this._eventHandlers[e]=n,window.addEventListener(e,n),this.addOnDestroy(()=>{window.removeEventListener(e,n),delete this._eventHandlers[e]})}onWindowResize(e,t){this.on("resize",e,t),e()}onWindowScroll(e,t){this.on("scroll",e,t),e()}onElementResize(e,t,s=200){let n=Fez.throttle(()=>{this.isConnected&&t.call(this,e.getBoundingClientRect(),e)},s),o=new ResizeObserver(n);o.observe(e),t.call(this,e.getBoundingClientRect(),e),this.addOnDestroy(()=>{o.disconnect()})}slot(e,t){t||=document.createElement("template");let s=t.nodeName=="SLOT";for(;e.firstChild;)s?t.parentNode.insertBefore(e.lastChild,t.nextSibling):t.appendChild(e.firstChild);return s?t.parentNode.removeChild(t):e.innerHTML="",t}setStyle(e,t){this.root.style.setProperty(e,t)}connect(){}onMount(){}beforeRender(){}afterRender(){}onDestroy(){}onStateChange(){}onGlobalStateChange(){}publish(e,...t){let s=o=>{if(Fez._subs&&Fez._subs[e]){let i=Fez._subs[e].find(([u])=>u===o);if(i)return i[1].bind(o)(...t),!0}return!1};if(s(this))return!0;let n=this.root.parentElement;for(;n;){if(n.fez&&s(n.fez))return!0;n=n.parentElement}return!1}fezBlocks={};parseHtml(e){let t=this.fezHtmlRoot.replaceAll('"',""");return e=e.replace(/([!'"\s;])fez\.(\w)/g,`$1${t}$2`).replace(/>\s+</g,"><"),e.trim()}nextTick(e,t){t?(this._nextTicks||={},this._nextTicks[t]||=window.requestAnimationFrame(()=>{e.bind(this)(),this._nextTicks[t]=null},t)):window.requestAnimationFrame(e.bind(this))}render(e){if(e||=this?.class?.fezHtmlFunc,!e||!this.root)return;this.beforeRender();let t=typeof this.class.nodeName=="function"?this.class.nodeName(this.root):this.class.nodeName,s=document.createElement(t||"div"),n;Array.isArray(e)?e[0]instanceof Node?e.forEach(o=>s.appendChild(o)):n=e.join(""):typeof e=="string"?n=H(e)(this):typeof e=="function"&&(n=e(this)),n&&(n=n.replace(/\s\w+="undefined"/g,""),s.innerHTML=this.parseHtml(n)),s.querySelectorAll("[fez-keep]").forEach(o=>{let i=o.getAttribute("fez-keep"),u=this.root.querySelector(`[fez-keep="${i}"]`);u?o.parentNode.replaceChild(u,o):i==="default-slot"&&Array.from(this.root.childNodes).forEach(f=>o.appendChild(f))}),Fez.morphdom(this.root,s),this.renderFezPostProcess(),this.afterRender()}renderFezPostProcess(){let e=(t,s)=>{this.root.querySelectorAll(`*[${t}]`).forEach(n=>{let o=n.getAttribute(t);n.removeAttribute(t),o&&s.bind(this)(o,n)})};e("fez-this",(t,s)=>{new Function("n",`this.${t} = n`).bind(this)(s)}),e("fez-use",(t,s)=>{let n=this[t];typeof n=="function"?n(s):console.error(`Fez error: "${t}" is not a function in ${this.fezName}`)}),e("fez-class",(t,s)=>{let n=t.split(/\s+/),o=n.pop();n.forEach(i=>s.classList.add(i)),o&&setTimeout(()=>{s.classList.add(o)},300)}),e("fez-bind",(t,s)=>{if(["INPUT","SELECT","TEXTAREA"].includes(s.nodeName)){let n=new Function(`return this.${t}`).bind(this)(),o=s.type.toLowerCase()=="checkbox",i=["SELECT"].includes(s.nodeName)||o?"onchange":"onkeyup";s.setAttribute(i,`${this.fezHtmlRoot}${t} = this.${o?"checked":"value"}`),this.val(s,n)}else console.error(`Cant fez-bind="${t}" to ${s.nodeName} (needs INPUT, SELECT or TEXTAREA. Want to use fez-this?).`)}),this.root.querySelectorAll("*[disabled]").forEach(t=>{let s=t.getAttribute("disabled");["false"].includes(s)?t.removeAttribute("disabled"):t.setAttribute("disabled","true")})}refresh(e){if(alert("NEEDS FIX and remove htmlTemplate"),e){let s=Fez.domRoot(this.class.htmlTemplate).querySelector(e).innerHTML;this.render(e,s)}else this.render()}setInterval(e,t,s){typeof e=="number"&&([t,e]=[e,t]),s||=Fez.fnv1(String(e)),this._setIntervalCache||={},clearInterval(this._setIntervalCache[s]);let n=setInterval(()=>{this.isConnected&&e()},t);return this._setIntervalCache[s]=n,this.addOnDestroy(()=>{clearInterval(n),delete this._setIntervalCache[s]}),n}find(e){return typeof e=="string"?this.root.querySelector(e):e}val(e,t){let s=this.find(e);if(s)if(["INPUT","TEXTAREA","SELECT"].includes(s.nodeName))if(typeof t<"u")s.type=="checkbox"?s.checked=!!t:s.value=t;else return s.value;else if(typeof t<"u")s.innerHTML=t;else return s.innerHTML}formData(e){return this.class.formData(e||this.root)}attr(e,t){return typeof t>"u"?this.root.getAttribute(e):(this.root.setAttribute(e,t),t)}childNodes(e){let t=Array.from(this.root.children);if(e){let s=document.createElement("div");s.style.display="none",document.body.appendChild(s),t.forEach(n=>s.appendChild(n)),t=Array.from(s.children).map(e),document.body.removeChild(s)}return t}subscribe(e,t){Fez._subs||={},Fez._subs[e]||=[],Fez._subs[e]=Fez._subs[e].filter(s=>s[0].isConnected),Fez._subs[e].push([this,t])}rootId(){return this.root.id||=`fez_${this.UID}`,this.root.id}fezRegister(){this.css&&(this.css=Fez.globalCss(this.css,{name:this.fezName,wrap:!0})),this.class.css&&(this.class.css=Fez.globalCss(this.class.css,{name:this.fezName})),this.state||=this.reactiveStore(),this.globalState=Fez.state.createProxy(this),this.fezRegisterBindMethods()}fezRegisterBindMethods(){Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(t=>t!=="constructor"&&typeof this[t]=="function").forEach(t=>this[t]=this[t].bind(this))}fezHide(){let e=this.root,t=this.childNodes(),s=this.root.parentNode;return t.reverse().forEach(n=>s.insertBefore(n,e.nextSibling)),this.root.remove(),this.root=s,t}reactiveStore(e,t){e||={},t||=(n,o,i,u)=>{this.onStateChange(o,i,u),this.nextTick(this.render,"render")},t.bind(this);function s(n,o){return typeof n!="object"||n===null?n:new Proxy(n,{set(i,u,f,b){let g=Reflect.get(i,u,b);if(g!==f){typeof f=="object"&&f!==null&&(f=s(f,o));let S=Reflect.set(i,u,f,b);return o(i,u,f,g),S}return!0},get(i,u,f){let b=Reflect.get(i,u,f);return typeof b=="object"&&b!==null?s(b,o):b}})}return s(e,t)}};var $e={data:""},Z=r=>typeof window=="object"?((r?r.querySelector("#_goober"):window._goober)||Object.assign((r||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:r||$e,Fe=r=>{let e=Z(r),t=e.data;return e.data="",t},Te=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,we=/\/\*[^]*?\*\/| +/g,X=/\n+/g,F=(r,e)=>{let t="",s="",n="";for(let o in r){let i=r[o];o[0]=="@"?o[1]=="i"?t=o+" "+i+";":s+=o[1]=="f"?F(i,o):o+"{"+F(i,o[1]=="k"?"":e)+"}":typeof i=="object"?s+=F(i,e?e.replace(/([^,])+/g,u=>o.replace(/(^:.*)|([^,])+/g,f=>/&/.test(f)?f.replace(/&/g,u):u?u+" "+f:f)):o):i!=null&&(o=/^--/.test(o)?o:o.replace(/[A-Z]/g,"-$&").toLowerCase(),n+=F.p?F.p(o,i):o+":"+i+";")}return t+(e&&n?e+"{"+n+"}":n)+s},C={},Y=r=>{if(typeof r=="object"){let e="";for(let t in r)e+=t+Y(r[t]);return e}return r},Me=(r,e,t,s,n)=>{let o=Y(r),i=C[o]||(C[o]=(f=>{let b=0,g=11;for(;b<f.length;)g=101*g+f.charCodeAt(b++)>>>0;return"go"+g})(o));if(!C[i]){let f=o!==r?r:(b=>{let g,S,w=[{}];for(;g=Te.exec(b.replace(we,""));)g[4]?w.shift():g[3]?(S=g[3].replace(X," ").trim(),w.unshift(w[0][S]=w[0][S]||{})):w[0][g[1]]=g[2].replace(X," ").trim();return w[0]})(r);C[i]=F(n?{["@keyframes "+i]:f}:f,t?"":"."+i)}let u=t&&C.g?C.g:null;return t&&(C.g=C[i]),((f,b,g,S)=>{S?b.data=b.data.replace(S,f):b.data.indexOf(f)===-1&&(b.data=g?f+b.data:b.data+f)})(C[i],e,s,u),i},Le=(r,e,t)=>r.reduce((s,n,o)=>{let i=e[o];if(i&&i.call){let u=i(t),f=u&&u.props&&u.props.className||/^go/.test(u)&&u;i=f?"."+f:u&&typeof u=="object"?u.props?"":F(u,""):u===!1?"":u}return s+n+(i??"")},"");function I(r){let e=this||{},t=r.call?r(e.p):r;return Me(t.unshift?t.raw?Le(t,[].slice.call(arguments,1),e.p):t.reduce((s,n)=>Object.assign(s,n&&n.call?n(e.p):n),{}):t,Z(e.target),e.g,e.o,e.k)}var x,P,q,_e=I.bind({g:1}),Oe=I.bind({k:1});function je(r,e,t,s){F.p=e,x=r,P=t,q=s}function He(r,e){let t=this||{};return function(){let s=arguments;function n(o,i){let u=Object.assign({},o),f=u.className||n.className;t.p=Object.assign({theme:P&&P()},u),t.o=/ *go\d+/.test(f),u.className=I.apply(t,s)+(f?" "+f:""),e&&(u.ref=i);let b=r;return r[0]&&(b=u.as||r,delete u.as),q&&b[0]&&q(u),x(b,u)}return e?e(n):n}}var Q={css:I,extractCss:Fe,glob:_e,keyframes:Oe,setup:je,styled:He};var ee=function(){"use strict";let r=new Set,e={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:A,afterNodeAdded:A,beforeNodeMorphed:A,afterNodeMorphed:A,beforeNodeRemoved:A,afterNodeRemoved:A,beforeAttributeUpdated:A},head:{style:"merge",shouldPreserve:function(l){return l.getAttribute("im-preserve")==="true"},shouldReAppend:function(l){return l.getAttribute("im-re-append")==="true"},shouldRemove:A,afterHeadMorphed:A}};function t(l,c,a={}){l instanceof Document&&(l=l.documentElement),typeof c=="string"&&(c=de(c));let d=he(c),h=ae(l,d,a);return s(l,d,h)}function s(l,c,a){if(a.head.block){let d=l.querySelector("head"),h=c.querySelector("head");if(d&&h){let p=S(h,d,a);Promise.all(p).then(function(){s(l,c,Object.assign(a,{head:{block:!1,ignore:!0}}))});return}}if(a.morphStyle==="innerHTML")return i(c,l,a),l.children;if(a.morphStyle==="outerHTML"||a.morphStyle==null){let d=me(c,l,a),h=d?.previousSibling,p=d?.nextSibling,y=o(l,d,a);return d?pe(h,y,p):[]}else throw"Do not understand how to morph style "+a.morphStyle}function n(l,c){return c.ignoreActiveValue&&l===document.activeElement&&l!==document.body}function o(l,c,a){if(!(a.ignoreActive&&l===document.activeElement))return c==null?a.callbacks.beforeNodeRemoved(l)===!1?l:(l.remove(),a.callbacks.afterNodeRemoved(l),null):R(l,c)?(a.callbacks.beforeNodeMorphed(l,c)===!1||(l instanceof HTMLHeadElement&&a.head.ignore||(l instanceof HTMLHeadElement&&a.head.style!=="morph"?S(c,l,a):(f(c,l,a),n(l,a)||i(c,l,a))),a.callbacks.afterNodeMorphed(l,c)),l):a.callbacks.beforeNodeRemoved(l)===!1||a.callbacks.beforeNodeAdded(c)===!1?l:(l.parentElement.replaceChild(c,l),a.callbacks.afterNodeAdded(c),a.callbacks.afterNodeRemoved(l),c)}function i(l,c,a){let d=l.firstChild,h=c.firstChild,p;for(;d;){if(p=d,d=p.nextSibling,h==null){if(a.callbacks.beforeNodeAdded(p)===!1)return;c.appendChild(p),a.callbacks.afterNodeAdded(p),M(a,p);continue}if(G(p,h,a)){o(h,p,a),h=h.nextSibling,M(a,p);continue}let y=fe(l,c,p,h,a);if(y){h=V(h,y,a),o(y,p,a),M(a,p);continue}let z=ue(l,c,p,h,a);if(z){h=V(h,z,a),o(z,p,a),M(a,p);continue}if(a.callbacks.beforeNodeAdded(p)===!1)return;c.insertBefore(p,h),a.callbacks.afterNodeAdded(p),M(a,p)}for(;h!==null;){let y=h;h=h.nextSibling,U(y,a)}}function u(l,c,a,d){return l==="value"&&d.ignoreActiveValue&&c===document.activeElement?!0:d.callbacks.beforeAttributeUpdated(l,c,a)===!1}function f(l,c,a){let d=l.nodeType;if(d===1){let h=l.attributes,p=c.attributes;for(let y of h)if(!u(y.name,c,"update",a))try{c.getAttribute(y.name)!==y.value&&c.setAttribute(y.name,y.value)}catch(z){console.error("Error setting attribute:",{badNode:c,badAttribute:y,error:z.message})}for(let y=p.length-1;0<=y;y--){let z=p[y];u(z.name,c,"remove",a)||l.hasAttribute(z.name)||c.removeAttribute(z.name)}}(d===8||d===3)&&c.nodeValue!==l.nodeValue&&(c.nodeValue=l.nodeValue),n(c,a)||g(l,c,a)}function b(l,c,a,d){if(l[a]!==c[a]){let h=u(a,c,"update",d);h||(c[a]=l[a]),l[a]?h||c.setAttribute(a,l[a]):u(a,c,"remove",d)||c.removeAttribute(a)}}function g(l,c,a){if(l instanceof HTMLInputElement&&c instanceof HTMLInputElement&&l.type!=="file"){let d=l.value,h=c.value;b(l,c,"checked",a),b(l,c,"disabled",a),l.hasAttribute("value")?d!==h&&(u("value",c,"update",a)||(c.setAttribute("value",d),c.value=d)):u("value",c,"remove",a)||(c.value="",c.removeAttribute("value"))}else if(l instanceof HTMLOptionElement)b(l,c,"selected",a);else if(l instanceof HTMLTextAreaElement&&c instanceof HTMLTextAreaElement){let d=l.value,h=c.value;if(u("value",c,"update",a))return;d!==h&&(c.value=d),c.firstChild&&c.firstChild.nodeValue!==d&&(c.firstChild.nodeValue=d)}}function S(l,c,a){let d=[],h=[],p=[],y=[],z=a.head.style,L=new Map;for(let v of l.children)L.set(v.outerHTML,v);for(let v of c.children){let E=L.has(v.outerHTML),j=a.head.shouldReAppend(v),D=a.head.shouldPreserve(v);E||D?j?h.push(v):(L.delete(v.outerHTML),p.push(v)):z==="append"?j&&(h.push(v),y.push(v)):a.head.shouldRemove(v)!==!1&&h.push(v)}y.push(...L.values());let K=[];for(let v of y){let E=document.createRange().createContextualFragment(v.outerHTML).firstChild;if(a.callbacks.beforeNodeAdded(E)!==!1){if(E.href||E.src){let j=null,D=new Promise(function(ve){j=ve});E.addEventListener("load",function(){j()}),K.push(D)}c.appendChild(E),a.callbacks.afterNodeAdded(E),d.push(E)}}for(let v of h)a.callbacks.beforeNodeRemoved(v)!==!1&&(c.removeChild(v),a.callbacks.afterNodeRemoved(v));return a.head.afterHeadMorphed(c,{added:d,kept:p,removed:h}),K}function w(){}function A(){}function ce(l){let c={};return Object.assign(c,e),Object.assign(c,l),c.callbacks={},Object.assign(c.callbacks,e.callbacks),Object.assign(c.callbacks,l.callbacks),c.head={},Object.assign(c.head,e.head),Object.assign(c.head,l.head),c}function ae(l,c,a){return a=ce(a),{target:l,newContent:c,config:a,morphStyle:a.morphStyle,ignoreActive:a.ignoreActive,ignoreActiveValue:a.ignoreActiveValue,idMap:ze(l,c),deadIds:new Set,callbacks:a.callbacks,head:a.head}}function G(l,c,a){return l==null||c==null?!1:l.nodeType===c.nodeType&&l.tagName===c.tagName?l.id!==""&&l.id===c.id?!0:O(a,l,c)>0:!1}function R(l,c){return l==null||c==null?!1:l.nodeType===c.nodeType&&l.tagName===c.tagName}function V(l,c,a){for(;l!==c;){let d=l;l=l.nextSibling,U(d,a)}return M(a,c),c.nextSibling}function fe(l,c,a,d,h){let p=O(h,a,c),y=null;if(p>0){let z=d,L=0;for(;z!=null;){if(G(a,z,h))return z;if(L+=O(h,z,l),L>p)return null;z=z.nextSibling}}return y}function ue(l,c,a,d,h){let p=d,y=a.nextSibling,z=0;for(;p!=null;){if(O(h,p,l)>0)return null;if(R(a,p))return p;if(R(y,p)&&(z++,y=y.nextSibling,z>=2))return null;p=p.nextSibling}return p}function de(l){let c=new DOMParser,a=l.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(a.match(/<\/html>/)||a.match(/<\/head>/)||a.match(/<\/body>/)){let d=c.parseFromString(l,"text/html");if(a.match(/<\/html>/))return d.generatedByIdiomorph=!0,d;{let h=d.firstChild;return h?(h.generatedByIdiomorph=!0,h):null}}else{let h=c.parseFromString("<body><template>"+l+"</template></body>","text/html").body.querySelector("template").content;return h.generatedByIdiomorph=!0,h}}function he(l){if(l==null)return document.createElement("div");if(l.generatedByIdiomorph)return l;if(l instanceof Node){let c=document.createElement("div");return c.append(l),c}else{let c=document.createElement("div");for(let a of[...l])c.append(a);return c}}function pe(l,c,a){let d=[],h=[];for(;l!=null;)d.push(l),l=l.previousSibling;for(;d.length>0;){let p=d.pop();h.push(p),c.parentElement.insertBefore(p,c)}for(h.push(c);a!=null;)d.push(a),h.push(a),a=a.nextSibling;for(;d.length>0;)c.parentElement.insertBefore(d.pop(),c.nextSibling);return h}function me(l,c,a){let d;d=l.firstChild;let h=d,p=0;for(;d;){let y=be(d,c,a);y>p&&(h=d,p=y),d=d.nextSibling}return h}function be(l,c,a){return R(l,c)?.5+O(a,l,c):0}function U(l,c){M(c,l),c.callbacks.beforeNodeRemoved(l)!==!1&&(l.remove(),c.callbacks.afterNodeRemoved(l))}function ye(l,c){return!l.deadIds.has(c)}function ge(l,c,a){return(l.idMap.get(a)||r).has(c)}function M(l,c){let a=l.idMap.get(c)||r;for(let d of a)l.deadIds.add(d)}function O(l,c,a){let d=l.idMap.get(c)||r,h=0;for(let p of d)ye(l,p)&&ge(l,p,a)&&++h;return h}function J(l,c){let a=l.parentElement,d=l.querySelectorAll("[id]");for(let h of d){let p=h;for(;p!==a&&p!=null;){let y=c.get(p);y==null&&(y=new Set,c.set(p,y)),y.add(h.id),p=p.parentElement}}}function ze(l,c){let a=new Map;return J(l,a),J(c,a),a}return{morph:t,defaults:e}}();function B(r,e){let t=globalThis.window?.Fez||globalThis.Fez;if(r.includes("-")||console.error(`Fez: Invalid custom element name "${r}". Custom element names must contain a dash (e.g., 'my-element', 'ui-button').`),e.fezHtmlRoot)e.html&&(e.html=te(e.html));else{let s=new e,n=class extends _{};if(Object.getOwnPropertyNames(s).concat(Object.getOwnPropertyNames(e.prototype)).filter(i=>!["constructor","prototype"].includes(i)).forEach(i=>n.prototype[i]=s[i]),s.GLOBAL&&(n.fezGlobal=s.GLOBAL),s.CSS&&(n.css=s.CSS),s.HTML&&(n.html=te(s.HTML)),s.NAME&&(n.nodeName=s.NAME),s.GLOBAL){let i=()=>document.body.appendChild(document.createElement(r));document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}e=n,t.log(`${r} compiled`)}e.html&&(e.html=e.html.replace(/<slot\s*\/>|<slot\s*>\s*<\/slot>/g,()=>{let s=e.SLOT||"div";return`<${s} class="fez-slot" fez-keep="default-slot"></${s}>`}),e.fezHtmlFunc=H(e.html)),e.css&&(e.css=t.globalCss(e.css,{name:r})),t.classes[r]=e,Re(r,e)}function Re(r,e){let t=globalThis.window?.Fez||globalThis.Fez;customElements.get(r)||customElements.define(r,class extends HTMLElement{connectedCallback(){t._pendingConnections||(t._pendingConnections=[],t._batchScheduled=!1),t._pendingConnections.push({name:r,node:this}),t._batchScheduled||(t._batchScheduled=!0,Promise.resolve().then(()=>{let s=t._pendingConnections.slice();t._pendingConnections=[],t._batchScheduled=!1,s.sort((n,o)=>n.node.contains(o.node)?-1:o.node.contains(n.node)?1:0),s.forEach(({name:n,node:o})=>{o.isConnected&&o.parentNode&&Ie(n,o)})}))}})}function te(r){let e=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);return r.replace(/<([a-z-]+)\b([^>]*)\/>/g,(t,s,n)=>e.has(s)?t:`<${s}${n}></${s}>`)}function Ie(r,e){let t=Fez.classes[r],s=e.parentNode;if(e.isConnected){let n=typeof t.nodeName=="function"?t.nodeName(e):t.nodeName,o=document.createElement(n||"div");o.classList.add("fez"),o.classList.add(`fez-${r}`),s.replaceChild(o,e);let i=new t;if(i.UID=++Fez.instanceCount,Fez.instances.set(i.UID,i),i.oldRoot=e,i.fezName=r,i.root=o,i.props=t.getProps(e,o),i.class=t,i.slot(e,o),o.fez=i,t.fezGlobal&&t.fezGlobal!=!0&&(window[t.fezGlobal]=i),window.$&&(i.$root=$(o)),i.props.id&&o.setAttribute("id",i.props.id),i.fezRegister(),(i.init||i.created||i.connect).bind(i)(i.props),i.render(),i.firstRender=!0,i.onMount(i.props),i.onSubmit){let u=i.root.nodeName=="FORM"?i.root:i.find("form");u.onsubmit=f=>{f.preventDefault(),i.onSubmit(i.formData())}}if(i.onPropsChange){Ne.observe(o,{attributes:!0});for(let[u,f]of Object.entries(i.props))i.onPropsChange(u,f)}}}var Ne=new MutationObserver((r,e)=>{for(let t of r)if(t.type==="attributes"){let s=t.target.fez,n=t.attributeName,o=t.target.getAttribute(n);s&&(s.props[n]=o,s.onPropsChange(n,o))}});var De=r=>{let e={script:"",style:"",html:"",head:""},t=r.split(`
|
|
9
|
-
`),
|
|
10
|
-
|
|
11
|
-
`),
|
|
12
|
-
`),
|
|
13
|
-
|
|
7
|
+
Template source: ${o}`,console.error(m)}}}catch(s){return s.message=`FEZ template compile error: ${s.message}Template source:
|
|
8
|
+
${o}`,console.error(s),()=>Fez.error("Template Compile Error",!0)}}var _=class{static getProps(e,t){let n={};if(e.props)return e.props;for(let o of e.attributes)n[o.name]=o.value;for(let[o,s]of Object.entries(n))if([":"].includes(o[0])){delete n[o];try{let i=new Function(`return (${s})`).bind(t)();n[o.replace(/[\:_]/,"")]=i}catch(i){console.error(`Fez: Error evaluating attribute ${o}="${s}" for ${e.tagName}: ${i.message}`)}}if(n["data-props"]){let o=n["data-props"];if(typeof o=="object")return o;o[0]!="{"&&(o=decodeURIComponent(o));try{n=JSON.parse(o)}catch(s){console.error(`Fez: Invalid JSON in data-props for ${e.tagName}: ${s.message}`)}}else if(n["data-json-template"]){let o=t.previousSibling?.textContent;if(o)try{n=JSON.parse(o),t.previousSibling.remove()}catch(s){console.error(`Fez: Invalid JSON in template for ${e.tagName}: ${s.message}`)}}return n}static formData(e){let t=e.closest("form")||e.querySelector("form");if(!t)return Fez.log("No form found for formData()"),{};let n=new FormData(t),o={};return n.forEach((s,i)=>{o[i]=s}),o}static nodeName="div";constructor(){}n=D;get fezHtmlRoot(){return`Fez(${this.UID}).`}get isConnected(){return this.root?.isConnected?!0:(this.fezOnDestroy(),!1)}prop(e){let t=this.oldRoot[e]||this.props[e];return typeof t=="function"&&(t=t.bind(this.root)),t}copy(){for(let e of Array.from(arguments)){let t=this.props[e];if(t!==void 0){if(e=="class"){let n=this.root.getAttribute(e,t);n&&(t=[n,t].join(" "))}(e=="style"||!this.root[e])&&(typeof t=="string"?this.root.setAttribute(e,t):this.root[e]=t)}}}fezOnDestroy(){this._onDestroyCallbacks&&(this._onDestroyCallbacks.forEach(e=>{try{e()}catch(t){console.error("Fez: Error in cleanup callback:",t)}}),this._onDestroyCallbacks=[]),this.onDestroy(),this.onDestroy=()=>{},this.root&&(this.root.fez=void 0),this.root=void 0}addOnDestroy(e){this._onDestroyCallbacks=this._onDestroyCallbacks||[],this._onDestroyCallbacks.push(e)}on(e,t,n=200){this._eventHandlers=this._eventHandlers||{},this._eventHandlers[e]&&window.removeEventListener(e,this._eventHandlers[e]);let o=Fez.throttle(()=>{this.isConnected&&t.call(this)},n);this._eventHandlers[e]=o,window.addEventListener(e,o),this.addOnDestroy(()=>{window.removeEventListener(e,o),delete this._eventHandlers[e]})}onWindowResize(e,t){this.on("resize",e,t),e()}onWindowScroll(e,t){this.on("scroll",e,t),e()}onElementResize(e,t,n=200){let o=Fez.throttle(()=>{this.isConnected&&t.call(this,e.getBoundingClientRect(),e)},n),s=new ResizeObserver(o);s.observe(e),t.call(this,e.getBoundingClientRect(),e),this.addOnDestroy(()=>{s.disconnect()})}slot(e,t){t||=document.createElement("template");let n=t.nodeName=="SLOT";for(;e.firstChild;)n?t.parentNode.insertBefore(e.lastChild,t.nextSibling):t.appendChild(e.firstChild);return n?t.parentNode.removeChild(t):e.innerHTML="",t}setStyle(e,t){this.root.style.setProperty(e,t)}connect(){}onMount(){}beforeRender(){}afterRender(){}onDestroy(){}onStateChange(){}onGlobalStateChange(){}publish(e,...t){let n=s=>{if(Fez._subs&&Fez._subs[e]){let i=Fez._subs[e].find(([u])=>u===s);if(i)return i[1].bind(s)(...t),!0}return!1};if(n(this))return!0;let o=this.root.parentElement;for(;o;){if(o.fez&&n(o.fez))return!0;o=o.parentElement}return!1}fezBlocks={};parseHtml(e){let t=this.fezHtmlRoot.replaceAll('"',""");return e=e.replace(/([!'"\s;])fez\.(\w)/g,`$1${t}$2`).replace(/>\s+</g,"><"),e.trim()}nextTick(e,t){t?(this._nextTicks||={},this._nextTicks[t]||=window.requestAnimationFrame(()=>{e.bind(this)(),this._nextTicks[t]=null},t)):window.requestAnimationFrame(e.bind(this))}render(e){if(e||=this?.class?.fezHtmlFunc,!e||!this.root)return;this.beforeRender();let t=typeof this.class.nodeName=="function"?this.class.nodeName(this.root):this.class.nodeName,n=document.createElement(t||"div"),o;Array.isArray(e)?e[0]instanceof Node?e.forEach(s=>n.appendChild(s)):o=e.join(""):typeof e=="string"?o=N(e)(this):typeof e=="function"&&(o=e(this)),o&&(o=o.replace(/\s\w+="undefined"/g,""),n.innerHTML=this.parseHtml(o)),this.fezKeepNode(n),this.fezMemoization(n),Fez.morphdom(this.root,n),this.fezRenderPostProcess(),this.afterRender()}fezRenderPostProcess(){let e=(t,n)=>{this.root.querySelectorAll(`*[${t}]`).forEach(o=>{let s=o.getAttribute(t);o.removeAttribute(t),s&&n.bind(this)(s,o)})};e("fez-this",(t,n)=>{new Function("n",`this.${t} = n`).bind(this)(n)}),e("fez-use",(t,n)=>{let o=this[t];typeof o=="function"?o(n):console.error(`Fez error: "${t}" is not a function in ${this.fezName}`)}),e("fez-class",(t,n)=>{let o=t.split(/\s+/),s=o.pop();o.forEach(i=>n.classList.add(i)),s&&setTimeout(()=>{n.classList.add(s)},300)}),e("fez-bind",(t,n)=>{if(["INPUT","SELECT","TEXTAREA"].includes(n.nodeName)){let o=new Function(`return this.${t}`).bind(this)(),s=n.type.toLowerCase()=="checkbox",i=["SELECT"].includes(n.nodeName)||s?"onchange":"onkeyup";n.setAttribute(i,`${this.fezHtmlRoot}${t} = this.${s?"checked":"value"}`),this.val(n,o)}else console.error(`Cant fez-bind="${t}" to ${n.nodeName} (needs INPUT, SELECT or TEXTAREA. Want to use fez-this?).`)}),this.root.querySelectorAll("*[disabled]").forEach(t=>{let n=t.getAttribute("disabled");["false"].includes(n)?t.removeAttribute("disabled"):t.setAttribute("disabled","true")})}fezKeepNode(e){e.querySelectorAll("[fez-keep]").forEach(t=>{let n=t.getAttribute("fez-keep"),o=this.root.querySelector(`[fez-keep="${n}"]`);o?t.parentNode.replaceChild(o,t):n==="default-slot"&&Array.from(this.root.childNodes).forEach(s=>t.appendChild(s))})}fezMemoization(e){let t=e.querySelector("[fez-memoize]:not(.fez)");if(!t)return;this.fezMemoStore||=new Map;let n=t.getAttribute("fez-memoize"),o=this.fezMemoStore.get(n);if(o)Fez.log(`Memoize restore ${this.fezName}: ${n}`),t.parentNode.replaceChild(o.cloneNode(!0),t);else{let s=this.root.querySelector("[fez-memoize]:not(.fez)");if(s){let i=s.getAttribute("fez-memoize");this.fezMemoStore.set(i,s.cloneNode(!0))}}}refresh(e){if(alert("NEEDS FIX and remove htmlTemplate"),e){let n=Fez.domRoot(this.class.htmlTemplate).querySelector(e).innerHTML;this.render(e,n)}else this.render()}setInterval(e,t,n){typeof e=="number"&&([t,e]=[e,t]),n||=Fez.fnv1(String(e)),this._setIntervalCache||={},clearInterval(this._setIntervalCache[n]);let o=setInterval(()=>{this.isConnected&&e()},t);return this._setIntervalCache[n]=o,this.addOnDestroy(()=>{clearInterval(o),delete this._setIntervalCache[n]}),o}find(e){return typeof e=="string"?this.root.querySelector(e):e}val(e,t){let n=this.find(e);if(n)if(["INPUT","TEXTAREA","SELECT"].includes(n.nodeName))if(typeof t<"u")n.type=="checkbox"?n.checked=!!t:n.value=t;else return n.value;else if(typeof t<"u")n.innerHTML=t;else return n.innerHTML}formData(e){return this.class.formData(e||this.root)}attr(e,t){return typeof t>"u"?this.root.getAttribute(e):(this.root.setAttribute(e,t),t)}childNodes(e){let t=Array.from(this.root.children);if(e){let n=document.createElement("div");n.style.display="none",document.body.appendChild(n),t.forEach(o=>n.appendChild(o)),t=Array.from(n.children).map(e),document.body.removeChild(n)}return t}subscribe(e,t){Fez._subs||={},Fez._subs[e]||=[],Fez._subs[e]=Fez._subs[e].filter(n=>n[0].isConnected),Fez._subs[e].push([this,t])}rootId(){return this.root.id||=`fez_${this.UID}`,this.root.id}fezRegister(){this.css&&(this.css=Fez.globalCss(this.css,{name:this.fezName,wrap:!0})),this.class.css&&(this.class.css=Fez.globalCss(this.class.css,{name:this.fezName})),this.state||=this.reactiveStore(),this.globalState=Fez.state.createProxy(this),this.fezRegisterBindMethods()}fezRegisterBindMethods(){Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(t=>t!=="constructor"&&typeof this[t]=="function").forEach(t=>this[t]=this[t].bind(this))}fezHide(){let e=this.root,t=this.childNodes(),n=this.root.parentNode;return t.reverse().forEach(o=>n.insertBefore(o,e.nextSibling)),this.root.remove(),this.root=n,t}reactiveStore(e,t){e||={},t||=(o,s,i,u)=>{this.onStateChange(s,i,u),this.nextTick(this.render,"render")},t.bind(this);function n(o,s){return typeof o!="object"||o===null?o:new Proxy(o,{set(i,u,f,m){let g=Reflect.get(i,u,m);if(g!==f){typeof f=="object"&&f!==null&&(f=n(f,s));let S=Reflect.set(i,u,f,m);return s(i,u,f,g),S}return!0},get(i,u,f){let m=Reflect.get(i,u,f);return typeof m=="object"&&m!==null?n(m,s):m}})}return n(e,t)}};var $e={data:""},Z=r=>typeof window=="object"?((r?r.querySelector("#_goober"):window._goober)||Object.assign((r||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:r||$e,Me=r=>{let e=Z(r),t=e.data;return e.data="",t},Fe=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,Le=/\/\*[^]*?\*\/| +/g,X=/\n+/g,w=(r,e)=>{let t="",n="",o="";for(let s in r){let i=r[s];s[0]=="@"?s[1]=="i"?t=s+" "+i+";":n+=s[1]=="f"?w(i,s):s+"{"+w(i,s[1]=="k"?"":e)+"}":typeof i=="object"?n+=w(i,e?e.replace(/([^,])+/g,u=>s.replace(/(^:.*)|([^,])+/g,f=>/&/.test(f)?f.replace(/&/g,u):u?u+" "+f:f)):s):i!=null&&(s=/^--/.test(s)?s:s.replace(/[A-Z]/g,"-$&").toLowerCase(),o+=w.p?w.p(s,i):s+":"+i+";")}return t+(e&&o?e+"{"+o+"}":o)+n},C={},Y=r=>{if(typeof r=="object"){let e="";for(let t in r)e+=t+Y(r[t]);return e}return r},_e=(r,e,t,n,o)=>{let s=Y(r),i=C[s]||(C[s]=(f=>{let m=0,g=11;for(;m<f.length;)g=101*g+f.charCodeAt(m++)>>>0;return"go"+g})(s));if(!C[i]){let f=s!==r?r:(m=>{let g,S,M=[{}];for(;g=Fe.exec(m.replace(Le,""));)g[4]?M.shift():g[3]?(S=g[3].replace(X," ").trim(),M.unshift(M[0][S]=M[0][S]||{})):M[0][g[1]]=g[2].replace(X," ").trim();return M[0]})(r);C[i]=w(o?{["@keyframes "+i]:f}:f,t?"":"."+i)}let u=t&&C.g?C.g:null;return t&&(C.g=C[i]),((f,m,g,S)=>{S?m.data=m.data.replace(S,f):m.data.indexOf(f)===-1&&(m.data=g?f+m.data:m.data+f)})(C[i],e,n,u),i},Oe=(r,e,t)=>r.reduce((n,o,s)=>{let i=e[s];if(i&&i.call){let u=i(t),f=u&&u.props&&u.props.className||/^go/.test(u)&&u;i=f?"."+f:u&&typeof u=="object"?u.props?"":w(u,""):u===!1?"":u}return n+o+(i??"")},"");function j(r){let e=this||{},t=r.call?r(e.p):r;return _e(t.unshift?t.raw?Oe(t,[].slice.call(arguments,1),e.p):t.reduce((n,o)=>Object.assign(n,o&&o.call?o(e.p):o),{}):t,Z(e.target),e.g,e.o,e.k)}var Q,R,P,Ie=j.bind({g:1}),Ne=j.bind({k:1});function ke(r,e,t,n){w.p=e,Q=r,R=t,P=n}function je(r,e){let t=this||{};return function(){let n=arguments;function o(s,i){let u=Object.assign({},s),f=u.className||o.className;t.p=Object.assign({theme:R&&R()},u),t.o=/ *go\d+/.test(f),u.className=j.apply(t,n)+(f?" "+f:""),e&&(u.ref=i);let m=r;return r[0]&&(m=u.as||r,delete u.as),P&&m[0]&&P(u),Q(m,u)}return e?e(o):o}}var ee={css:j,extractCss:Me,glob:Ie,keyframes:Ne,setup:ke,styled:je};var te=function(){"use strict";let r=new Set,e={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:A,afterNodeAdded:A,beforeNodeMorphed:A,afterNodeMorphed:A,beforeNodeRemoved:A,afterNodeRemoved:A,beforeAttributeUpdated:A},head:{style:"merge",shouldPreserve:function(l){return l.getAttribute("im-preserve")==="true"},shouldReAppend:function(l){return l.getAttribute("im-re-append")==="true"},shouldRemove:A,afterHeadMorphed:A}};function t(l,c,a={}){l instanceof Document&&(l=l.documentElement),typeof c=="string"&&(c=pe(c));let d=me(c),h=ue(l,d,a);return n(l,d,h)}function n(l,c,a){if(a.head.block){let d=l.querySelector("head"),h=c.querySelector("head");if(d&&h){let p=S(h,d,a);Promise.all(p).then(function(){n(l,c,Object.assign(a,{head:{block:!1,ignore:!0}}))});return}}if(a.morphStyle==="innerHTML")return i(c,l,a),l.children;if(a.morphStyle==="outerHTML"||a.morphStyle==null){let d=ye(c,l,a),h=d?.previousSibling,p=d?.nextSibling,y=s(l,d,a);return d?be(h,y,p):[]}else throw"Do not understand how to morph style "+a.morphStyle}function o(l,c){return c.ignoreActiveValue&&l===document.activeElement&&l!==document.body}function s(l,c,a){if(!(a.ignoreActive&&l===document.activeElement))return c==null?a.callbacks.beforeNodeRemoved(l)===!1?l:(l.remove(),a.callbacks.afterNodeRemoved(l),null):k(l,c)?(a.callbacks.beforeNodeMorphed(l,c)===!1||(l instanceof HTMLHeadElement&&a.head.ignore||(l instanceof HTMLHeadElement&&a.head.style!=="morph"?S(c,l,a):(f(c,l,a),o(l,a)||i(c,l,a))),a.callbacks.afterNodeMorphed(l,c)),l):a.callbacks.beforeNodeRemoved(l)===!1||a.callbacks.beforeNodeAdded(c)===!1?l:(l.parentElement.replaceChild(c,l),a.callbacks.afterNodeAdded(c),a.callbacks.afterNodeRemoved(l),c)}function i(l,c,a){let d=l.firstChild,h=c.firstChild,p;for(;d;){if(p=d,d=p.nextSibling,h==null){if(a.callbacks.beforeNodeAdded(p)===!1)return;c.appendChild(p),a.callbacks.afterNodeAdded(p),F(a,p);continue}if(W(p,h,a)){s(h,p,a),h=h.nextSibling,F(a,p);continue}let y=de(l,c,p,h,a);if(y){h=V(h,y,a),s(y,p,a),F(a,p);continue}let z=he(l,c,p,h,a);if(z){h=V(h,z,a),s(z,p,a),F(a,p);continue}if(a.callbacks.beforeNodeAdded(p)===!1)return;c.insertBefore(p,h),a.callbacks.afterNodeAdded(p),F(a,p)}for(;h!==null;){let y=h;h=h.nextSibling,U(y,a)}}function u(l,c,a,d){return l==="value"&&d.ignoreActiveValue&&c===document.activeElement?!0:d.callbacks.beforeAttributeUpdated(l,c,a)===!1}function f(l,c,a){let d=l.nodeType;if(d===1){let h=l.attributes,p=c.attributes;for(let y of h)if(!u(y.name,c,"update",a))try{c.getAttribute(y.name)!==y.value&&c.setAttribute(y.name,y.value)}catch(z){console.error("Error setting attribute:",{badNode:c,badAttribute:y,error:z.message})}for(let y=p.length-1;0<=y;y--){let z=p[y];u(z.name,c,"remove",a)||l.hasAttribute(z.name)||c.removeAttribute(z.name)}}(d===8||d===3)&&c.nodeValue!==l.nodeValue&&(c.nodeValue=l.nodeValue),o(c,a)||g(l,c,a)}function m(l,c,a,d){if(l[a]!==c[a]){let h=u(a,c,"update",d);h||(c[a]=l[a]),l[a]?h||c.setAttribute(a,l[a]):u(a,c,"remove",d)||c.removeAttribute(a)}}function g(l,c,a){if(l instanceof HTMLInputElement&&c instanceof HTMLInputElement&&l.type!=="file"){let d=l.value,h=c.value;m(l,c,"checked",a),m(l,c,"disabled",a),l.hasAttribute("value")?d!==h&&(u("value",c,"update",a)||(c.setAttribute("value",d),c.value=d)):u("value",c,"remove",a)||(c.value="",c.removeAttribute("value"))}else if(l instanceof HTMLOptionElement)m(l,c,"selected",a);else if(l instanceof HTMLTextAreaElement&&c instanceof HTMLTextAreaElement){let d=l.value,h=c.value;if(u("value",c,"update",a))return;d!==h&&(c.value=d),c.firstChild&&c.firstChild.nodeValue!==d&&(c.firstChild.nodeValue=d)}}function S(l,c,a){let d=[],h=[],p=[],y=[],z=a.head.style,L=new Map;for(let v of l.children)L.set(v.outerHTML,v);for(let v of c.children){let E=L.has(v.outerHTML),I=a.head.shouldReAppend(v),H=a.head.shouldPreserve(v);E||H?I?h.push(v):(L.delete(v.outerHTML),p.push(v)):z==="append"?I&&(h.push(v),y.push(v)):a.head.shouldRemove(v)!==!1&&h.push(v)}y.push(...L.values());let J=[];for(let v of y){let E=document.createRange().createContextualFragment(v.outerHTML).firstChild;if(a.callbacks.beforeNodeAdded(E)!==!1){if(E.href||E.src){let I=null,H=new Promise(function(Ee){I=Ee});E.addEventListener("load",function(){I()}),J.push(H)}c.appendChild(E),a.callbacks.afterNodeAdded(E),d.push(E)}}for(let v of h)a.callbacks.beforeNodeRemoved(v)!==!1&&(c.removeChild(v),a.callbacks.afterNodeRemoved(v));return a.head.afterHeadMorphed(c,{added:d,kept:p,removed:h}),J}function M(){}function A(){}function fe(l){let c={};return Object.assign(c,e),Object.assign(c,l),c.callbacks={},Object.assign(c.callbacks,e.callbacks),Object.assign(c.callbacks,l.callbacks),c.head={},Object.assign(c.head,e.head),Object.assign(c.head,l.head),c}function ue(l,c,a){return a=fe(a),{target:l,newContent:c,config:a,morphStyle:a.morphStyle,ignoreActive:a.ignoreActive,ignoreActiveValue:a.ignoreActiveValue,idMap:Se(l,c),deadIds:new Set,callbacks:a.callbacks,head:a.head}}function W(l,c,a){return l==null||c==null?!1:l.nodeType===c.nodeType&&l.tagName===c.tagName?l.id!==""&&l.id===c.id?!0:O(a,l,c)>0:!1}function k(l,c){return l==null||c==null?!1:l.nodeType===c.nodeType&&l.tagName===c.tagName}function V(l,c,a){for(;l!==c;){let d=l;l=l.nextSibling,U(d,a)}return F(a,c),c.nextSibling}function de(l,c,a,d,h){let p=O(h,a,c),y=null;if(p>0){let z=d,L=0;for(;z!=null;){if(W(a,z,h))return z;if(L+=O(h,z,l),L>p)return null;z=z.nextSibling}}return y}function he(l,c,a,d,h){let p=d,y=a.nextSibling,z=0;for(;p!=null;){if(O(h,p,l)>0)return null;if(k(a,p))return p;if(k(y,p)&&(z++,y=y.nextSibling,z>=2))return null;p=p.nextSibling}return p}function pe(l){let c=new DOMParser,a=l.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(a.match(/<\/html>/)||a.match(/<\/head>/)||a.match(/<\/body>/)){let d=c.parseFromString(l,"text/html");if(a.match(/<\/html>/))return d.generatedByIdiomorph=!0,d;{let h=d.firstChild;return h?(h.generatedByIdiomorph=!0,h):null}}else{let h=c.parseFromString("<body><template>"+l+"</template></body>","text/html").body.querySelector("template").content;return h.generatedByIdiomorph=!0,h}}function me(l){if(l==null)return document.createElement("div");if(l.generatedByIdiomorph)return l;if(l instanceof Node){let c=document.createElement("div");return c.append(l),c}else{let c=document.createElement("div");for(let a of[...l])c.append(a);return c}}function be(l,c,a){let d=[],h=[];for(;l!=null;)d.push(l),l=l.previousSibling;for(;d.length>0;){let p=d.pop();h.push(p),c.parentElement.insertBefore(p,c)}for(h.push(c);a!=null;)d.push(a),h.push(a),a=a.nextSibling;for(;d.length>0;)c.parentElement.insertBefore(d.pop(),c.nextSibling);return h}function ye(l,c,a){let d;d=l.firstChild;let h=d,p=0;for(;d;){let y=ge(d,c,a);y>p&&(h=d,p=y),d=d.nextSibling}return h}function ge(l,c,a){return k(l,c)?.5+O(a,l,c):0}function U(l,c){F(c,l),c.callbacks.beforeNodeRemoved(l)!==!1&&(l.remove(),c.callbacks.afterNodeRemoved(l))}function ze(l,c){return!l.deadIds.has(c)}function ve(l,c,a){return(l.idMap.get(a)||r).has(c)}function F(l,c){let a=l.idMap.get(c)||r;for(let d of a)l.deadIds.add(d)}function O(l,c,a){let d=l.idMap.get(c)||r,h=0;for(let p of d)ze(l,p)&&ve(l,p,a)&&++h;return h}function K(l,c){let a=l.parentElement,d=l.querySelectorAll("[id]");for(let h of d){let p=h;for(;p!==a&&p!=null;){let y=c.get(p);y==null&&(y=new Set,c.set(p,y)),y.add(h.id),p=p.parentElement}}}function Se(l,c){let a=new Map;return K(l,a),K(c,a),a}return{morph:t,defaults:e}}();var xe=r=>{let e=r.split(/(<\/?[^>]+>)/g).map(o=>o.trim()).filter(o=>o),t=0,n=[];for(let o=0;o<e.length;o++){let s=e[o],i=e[o+1],u=e[o+2];if(s.startsWith("<"))if(!s.startsWith("</")&&!s.endsWith("/>")&&i&&!i.startsWith("<")&&u&&u.startsWith("</")){let f=Math.max(0,t);n.push(" ".repeat(f)+s+i+u),o+=2}else if(s.startsWith("</")){t--;let f=Math.max(0,t);n.push(" ".repeat(f)+s)}else if(s.endsWith("/>")||s.includes(" />")){let f=Math.max(0,t);n.push(" ".repeat(f)+s)}else{let f=Math.max(0,t);n.push(" ".repeat(f)+s),t++}else if(s){let f=Math.max(0,t);n.push(" ".repeat(f)+s)}}return n.join(`
|
|
9
|
+
`)},q=(()=>{let r=[],e=[],t=0;document.addEventListener("keydown",s=>{if(s.key==="Escape"){s.preventDefault();let i=document.getElementById("dump-dialog"),u=document.getElementById("log-reopen-button");i?(i.remove(),localStorage.setItem("_LOG_CLOSED","true"),n()):u&&(u.remove(),localStorage.setItem("_LOG_CLOSED","false"),o())}});let n=()=>{let s=document.getElementById("log-reopen-button");s||(s=document.body.appendChild(document.createElement("button")),s.id="log-reopen-button",s.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:middle;margin-right:4px"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>LOG',s.style.cssText="position:fixed; top: 10px; right: 10px;padding:10px 20px;background:#ff3333;color:#fff;border:none;cursor:pointer;font:14px/1.4 monospace;z-index:2147483647;border-radius:8px;display:flex;align-items:center;opacity:1;visibility:visible;box-shadow:0 4px 12px rgba(255,51,51,0.3)",s.onclick=()=>{s.remove(),localStorage.setItem("_LOG_CLOSED","false"),o()})},o=()=>{let s=document.getElementById("dump-dialog");if(!s){s=document.body.appendChild(document.createElement("div")),s.id="dump-dialog";let f=window.pageYOffset||document.documentElement.scrollTop;s.style.cssText="position:absolute; top:"+(f+20)+"px; left: 20px; right:20px;background:#fff; border:1px solid #333; box-shadow:0 0 10px rgba(0,0,0,0.5);padding:20px; overflow:auto; z-index:2147483646; font:13px/1.4 monospace;white-space:pre; display:block; opacity:1; visibility:visible"}let i=parseInt(localStorage.getItem("_LOG_INDEX"));!isNaN(i)&&i>=0&&i<r.length?t=i:t=r.length-1;let u=()=>{let f=r.map((m,g)=>{let S="#f0f0f0";return g!==t&&(e[g]==="object"?S="#d6e3ef":e[g]==="array"&&(S="#d8d5ef")),`<button style="font-size: 14px; font-weight: 400; padding:2px 6px; margin: 0 2px 2px 0;cursor:pointer;background:${g===t?"#333":S};color:${g===t?"#fff":"#000"}" data-index="${g}">${g+1}</button>`}).join("");s.innerHTML='<div style="display:flex;flex-direction:column;height:100%"><div style="display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:10px"><div style="display:flex;flex-wrap:wrap;gap:4px;flex:1;margin-right:10px">'+f+'</div><button style="padding:4px 8px;cursor:pointer;flex-shrink:0">×</button></div><xmp style="font-family:monospace;flex:1;overflow:auto;margin:0;padding:0;color:#000;background:#fff;font-size:14px;line-height:22px">'+r[t]+"</xmp></div>",s.querySelector('button[style*="flex-shrink:0"]').onclick=()=>{s.remove(),localStorage.setItem("_LOG_CLOSED","true"),n()},s.querySelectorAll("button[data-index]").forEach(m=>{m.onclick=()=>{t=parseInt(m.dataset.index),localStorage.setItem("_LOG_INDEX",t),u()}})};u()};return s=>{if(!document.body){window.requestAnimationFrame(()=>q(s));return}s instanceof Node&&(s=xe(s.outerHTML));let i=typeof s;s===void 0&&(s="undefined"),s===null&&(s="null"),Array.isArray(s)?i="array":typeof s=="object"&&s!==null&&(i="object"),typeof s!="string"&&(s=JSON.stringify(s,(f,m)=>typeof m=="function"?String(m):m,2).replaceAll("<","<")),s=s.trim(),r.push(s+`
|
|
10
|
+
|
|
11
|
+
type: ${i}`),e.push(i),localStorage.getItem("_LOG_CLOSED")==="true"?n():o()}})();typeof window<"u"&&!window.LOG&&(window.LOG=q);var re=q;function B(r,e){let t=globalThis.window?.Fez||globalThis.Fez;if(r.includes("-")||console.error(`Fez: Invalid custom element name "${r}". Custom element names must contain a dash (e.g., 'my-element', 'ui-button').`),e.fezHtmlRoot)e.html&&(e.html=ne(e.html));else{let n=new e,o=class extends _{};if(Object.getOwnPropertyNames(n).concat(Object.getOwnPropertyNames(e.prototype)).filter(i=>!["constructor","prototype"].includes(i)).forEach(i=>o.prototype[i]=n[i]),n.GLOBAL&&(o.fezGlobal=n.GLOBAL),n.CSS&&(o.css=n.CSS),n.HTML&&(o.html=ne(n.HTML)),n.NAME&&(o.nodeName=n.NAME),n.GLOBAL){let i=()=>document.body.appendChild(document.createElement(r));document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}e=o,t.log(`${r} compiled`)}e.html&&(e.html=e.html.replace(/<slot\s*\/>|<slot\s*>\s*<\/slot>/g,()=>{let n=e.SLOT||"div";return`<${n} class="fez-slot" fez-keep="default-slot"></${n}>`}),e.fezHtmlFunc=N(e.html)),e.css&&(e.css=t.globalCss(e.css,{name:r})),t.classes[r]=e,He(r,e)}function He(r,e){let t=globalThis.window?.Fez||globalThis.Fez;customElements.get(r)||customElements.define(r,class extends HTMLElement{connectedCallback(){t._pendingConnections||(t._pendingConnections=[],t._batchScheduled=!1),t._pendingConnections.push({name:r,node:this}),t._batchScheduled||(t._batchScheduled=!0,Promise.resolve().then(()=>{let n=t._pendingConnections.slice();t._pendingConnections=[],t._batchScheduled=!1,n.sort((o,s)=>o.node.contains(s.node)?-1:s.node.contains(o.node)?1:0),n.forEach(({name:o,node:s})=>{s.isConnected&&s.parentNode&&De(o,s)})}))}})}function ne(r){let e=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);return r.replace(/<([a-z-]+)\b([^>]*)\/>/g,(t,n,o)=>e.has(n)?t:`<${n}${o}></${n}>`)}function De(r,e){let t=Fez.classes[r],n=e.parentNode;if(e.isConnected){let o=typeof t.nodeName=="function"?t.nodeName(e):t.nodeName,s=document.createElement(o||"div");s.classList.add("fez"),s.classList.add(`fez-${r}`),n.replaceChild(s,e);let i=new t;if(i.UID=++Fez.instanceCount,Fez.instances.set(i.UID,i),i.oldRoot=e,i.fezName=r,i.root=s,i.props=t.getProps(e,s),i.class=t,i.slot(e,s),s.fez=i,t.fezGlobal&&t.fezGlobal!=!0&&(window[t.fezGlobal]=i),window.$&&(i.$root=$(s)),i.props.id&&s.setAttribute("id",i.props.id),i.fezRegister(),(i.init||i.created||i.connect).bind(i)(i.props),i.render(),i.firstRender=!0,i.onMount(i.props),i.onSubmit){let u=i.root.nodeName=="FORM"?i.root:i.find("form");u.onsubmit=f=>{f.preventDefault(),i.onSubmit(i.formData())}}if(i.onPropsChange){Re.observe(s,{attributes:!0});for(let[u,f]of Object.entries(i.props))i.onPropsChange(u,f)}}}var Re=new MutationObserver((r,e)=>{for(let t of r)if(t.type==="attributes"){let n=t.target.fez,o=t.attributeName,s=t.target.getAttribute(o);n&&(n.props[o]=s,n.onPropsChange(o,s))}});var Pe=r=>{let e={script:"",style:"",html:"",head:""},t=r.split(`
|
|
12
|
+
`),n=[],o="";for(var s of t)s=s.trim(),s.startsWith("<script")&&!e.script&&o!="head"?o="script":s.startsWith("<head")&&!e.script?o="head":s.startsWith("<style")?o="style":s.endsWith("<\/script>")&&o==="script"&&!e.script?(e.script=n.join(`
|
|
13
|
+
`),n=[],o=null):s.endsWith("</style>")&&o==="style"?(e.style=n.join(`
|
|
14
|
+
`),n=[],o=null):(s.endsWith("</head>")||s.endsWith("</header>"))&&o==="head"?(e.head=n.join(`
|
|
15
|
+
`),n=[],o=null):o?n.push(s):e.html+=s+`
|
|
16
|
+
`;if(e.head){let u=Fez.domRoot(e.head);Array.from(u.children).forEach(f=>{if(f.tagName==="SCRIPT"){let m=document.createElement("script");Array.from(f.attributes).forEach(g=>{m.setAttribute(g.name,g.value)}),m.type||="text/javascript",f.src?document.head.appendChild(m):(m.type.includes("javascript")||m.type=="module")&&(m.textContent=f.textContent,document.head.appendChild(m))}else document.head.appendChild(f.cloneNode(!0))})}let i=e.script;return/class\s+\{/.test(i)||(i=`class {
|
|
14
17
|
${i}
|
|
15
18
|
}`),String(e.style).includes(":")&&(Object.entries(Fez._styleMacros).forEach(([u,f])=>{e.style=e.style.replaceAll(`:${u} `,`${f} `)}),e.style=e.style.includes(":fez")||/(?:^|\s)body\s*\{/.test(e.style)?e.style:`:fez {
|
|
16
19
|
${e.style}
|
|
@@ -18,11 +21,11 @@ ${e.style}
|
|
|
18
21
|
CSS = \`${e.style}\`
|
|
19
22
|
}`)),/\w/.test(String(e.html))&&(e.html=e.html.replaceAll("`","`"),e.html=e.html.replaceAll("$","\\$"),i=i.replace(/\}\s*$/,`
|
|
20
23
|
HTML = \`${e.html}\`
|
|
21
|
-
}`)),i};function
|
|
24
|
+
}`)),i};function G(r){if(r instanceof Node){let e=r;e.remove();let t=e.getAttribute("fez");if(t&&(t.includes(".")||t.includes("/"))){qe(t);return}else return t&&!t.includes("-")&&console.error(`Fez: Invalid custom element name "${t}". Custom element names must contain a dash (e.g., 'my-element', 'ui-button').`),x(t,e.innerHTML)}else{(r?Fez.domRoot(r):document.body).querySelectorAll("template[fez], xmp[fez]").forEach(t=>{G(t)});return}}function qe(r){Fez.log(`Loading from ${r}`),Fez.fetch(r).then(e=>{let o=new DOMParser().parseFromString(e,"text/html").querySelectorAll("template[fez], xmp[fez]");if(o.length>0)o.forEach(s=>{let i=s.getAttribute("fez");i&&!i.includes("-")&&!i.includes(".")&&!i.includes("/")&&console.error(`Fez: Invalid custom element name "${i}". Custom element names must contain a dash (e.g., 'my-element', 'ui-button').`);let u=s.innerHTML;x(i,u)});else{let s=r.split("/").pop().split(".")[0];x(s,e)}}).catch(e=>{console.error(`FEZ template load error for "${r}": ${e.message}`)})}function x(r,e){if(arguments.length===1)return G(r);if(e&&e.includes("</xmp>"))return G(e);r&&!r.includes("-")&&!r.includes(".")&&!r.includes("/")&&console.error(`Fez: Invalid custom element name "${r}". Custom element names must contain a dash (e.g., 'my-element', 'ui-button').`);let t=Pe(e),n=t.split(/class\s+\{/,2);if(t=`${n[0]};
|
|
22
25
|
|
|
23
26
|
window.Fez('${r}', class {
|
|
24
|
-
${
|
|
25
|
-
`}if(t.includes("import "))Fez.head({script:t}),setTimeout(()=>{Fez.classes[r]||Fez.error(`Template "${r}" possible compile error. (can be a false positive, it imports are not loaded)`)},2e3);else try{new Function(t)()}catch(
|
|
26
|
-
`).filter(
|
|
27
|
-
`);e.wrap&&(t=`:fez { ${t} }`),t=t.replace(/\:fez|\:host/,`.fez.fez-${e.name}`),r=
|
|
27
|
+
${n[1]})`,r){let o=document.getElementById("fez-hidden-styles");o||(o=document.createElement("style"),o.id="fez-hidden-styles",document.head.appendChild(o));let s=[...Object.keys(Fez.classes),r].sort().join(", ");o.textContent=`${s} { display: none; }
|
|
28
|
+
`}if(t.includes("import "))Fez.head({script:t}),setTimeout(()=>{Fez.classes[r]||Fez.error(`Template "${r}" possible compile error. (can be a false positive, it imports are not loaded)`)},2e3);else try{new Function(t)()}catch(o){Fez.error(`Template "${r}" compile error: ${o.message}`),console.log(t)}}var se=x;var Be={data:{},listeners:new Map,subscribers:new Map,globalSubscribers:new Set,notify(r,e,t){Fez.log(`Global state change for ${r}: ${e} (from ${t})`);let n=this.listeners.get(r);n&&n.forEach(s=>{s.isConnected?(s.onGlobalStateChange(r,e,t),s.render()):n.delete(s)});let o=this.subscribers.get(r);o&&o.forEach(s=>{try{s(e,t,r)}catch(i){console.error(`Error in subscriber for key ${r}:`,i)}}),this.globalSubscribers.forEach(s=>{try{s(r,e,t)}catch(i){console.error("Error in global subscriber:",i)}})},createProxy(r){return new Proxy({},{get:(e,t)=>(r._globalStateKeys||=new Set,r._globalStateKeys.has(t)||(r._globalStateKeys.add(t),this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(r)),this.data[t]),set:(e,t,n)=>{let o=this.data[t];return o!==n&&(this.data[t]=n,this.notify(t,n,o)),!0}})},set(r,e){let t=this.data[r];t!==e&&(this.data[r]=e,this.notify(r,e,t))},get(r){return this.data[r]},forEach(r,e){let t=this.listeners.get(r);t&&t.forEach(n=>{n.isConnected?e(n):t.delete(n)})},subscribe(r,e){if(typeof r=="function")return this.globalSubscribers.add(r),()=>this.globalSubscribers.delete(r);{let t=r;return this.subscribers.has(t)||this.subscribers.set(t,new Set),this.subscribers.get(t).add(e),()=>{let n=this.subscribers.get(t);n&&(n.delete(e),n.size===0&&this.subscribers.delete(t))}}}},oe=Be;var ie=r=>{r.head=(e,t)=>{if(e.nodeName){e.nodeName=="SCRIPT"?(r.head({script:e.innerText}),e.remove()):(e.querySelectorAll("script").forEach(f=>r.head(f)),e.querySelectorAll("template[fez], xmp[fez], script[fez]").forEach(f=>r.compile(f)));return}if(typeof e!="object"||e===null)throw new Error("head requires an object parameter");let n,o={},s;if(e.script){if(e.script.includes("import ")){t&&r.error("Fez.head callback is not supported when script with import is passed (module context).");let f=document.createElement("script");f.type="module",f.textContent=e.script,document.head.appendChild(f),setTimeout(()=>f.remove(),100)}else try{new Function(e.script)(),t&&t()}catch(f){r.error("Error executing script:",f),console.log(e.script)}return}else if(e.js){n=e.js,s="script";for(let[f,m]of Object.entries(e))f!=="js"&&f!=="module"&&(o[f]=m);e.module&&(o.type="module")}else if(e.css){n=e.css,s="link",o.rel="stylesheet";for(let[f,m]of Object.entries(e))f!=="css"&&(o[f]=m)}else throw new Error('head requires either "script", "js" or "css" property');let i=document.querySelector(`${s}[src="${n}"], ${s}[href="${n}"]`);if(i)return t&&t(),i;let u=document.createElement(s);s==="link"?u.href=n:u.src=n;for(let[f,m]of Object.entries(o))u.setAttribute(f,m);return(t||e.module)&&(u.onload=()=>{e.module&&s==="script"&&import(n).then(f=>{window[e.module]=f.default||f[e.module]||f}).catch(f=>{console.error(`Error importing module ${e.module}:`,f)}),t&&t()}),document.head.appendChild(u),u},r.darkenColor=(e,t=20)=>{let n=parseInt(e.replace("#",""),16),o=Math.round(2.55*t),s=(n>>16)-o,i=(n>>8&255)-o,u=(n&255)-o;return"#"+(16777216+(s<255?s<1?0:s:255)*65536+(i<255?i<1?0:i:255)*256+(u<255?u<1?0:u:255)).toString(16).slice(1)},r.lightenColor=(e,t=20)=>{let n=parseInt(e.replace("#",""),16),o=Math.round(2.55*t),s=(n>>16)+o,i=(n>>8&255)+o,u=(n&255)+o;return"#"+(16777216+(s<255?s<1?0:s:255)*65536+(i<255?i<1?0:i:255)*256+(u<255?u<1?0:u:255)).toString(16).slice(1)},r.htmlEscape=e=>typeof e=="string"?(e=e.replace(/font-family\s*:\s*(?:&[^;]+;|[^;])*?;/gi,"").replaceAll("&","&").replaceAll("'","'").replaceAll('"',""").replaceAll("<","<").replaceAll(">",">"),e):e===void 0?"":e,r.domRoot=(e,t="div")=>{if(e instanceof Node)return e;{let n=document.createElement(t);return n.innerHTML=e,n}},r.activateNode=(e,t="active")=>{Array.from(e.parentElement.children).forEach(n=>{n.classList.remove(t)}),e.classList.add(t)},r.isTrue=e=>["1","true","on"].includes(String(e).toLowerCase()),r.getFunction=e=>{if(e){if(typeof e=="function")return e;if(typeof e=="string")return new Function(e)}else return()=>{}}};var b=(r,e)=>{if(typeof r=="number"){let t=b.instances.get(r);if(t)return t;b.error(`Instance with UID "${r}" not found.`)}else if(r)if(e)if(typeof e=="function"&&!/^\s*class/.test(e.toString())&&!/\b(this|new)\b/.test(e.toString())){let n=Array.from(document.querySelectorAll(`.fez.fez-${r}`)).filter(o=>o.fez);return n.forEach(o=>e(o.fez)),n}else return typeof e!="function"?b.find(r,e):B(r,e);else{let t=r.nodeName?r.closest(".fez"):document.querySelector(r.includes("#")?r:`.fez.fez-${r}`);if(t){if(t.fez)return t.fez;b.error(`node "${r}" has no Fez attached.`)}else b.error(`node "${r}" not found.`)}else b.error("Fez() ?")};b.classes={};b.instanceCount=0;b.instances=new Map;b.find=(r,e)=>{let t=r;typeof t=="string"&&(t=document.body.querySelector(t)),typeof t.val=="function"&&(t=t[0]);let n=e?`.fez.fez-${e}`:".fez",o=t.closest(n);if(o&&o.fez)return o.fez;console.error("Fez node connector not found",r,t)};b.cssClass=r=>ee.css(r);b.globalCss=(r,e={})=>{if(typeof r=="function"&&(r=r()),r.includes(":")){let t=r.split(`
|
|
29
|
+
`).filter(n=>!/^\s*\/\//.test(n)).join(`
|
|
30
|
+
`);e.wrap&&(t=`:fez { ${t} }`),t=t.replace(/\:fez|\:host/,`.fez.fez-${e.name}`),r=b.cssClass(t)}return document.body?document.body.parentElement.classList.add(r):document.addEventListener("DOMContentLoaded",()=>{document.body.parentElement.classList.add(r)}),r};b.info=()=>{console.log("Fez components:",Object.keys(b.classes||{}))};b.morphdom=(r,e,t={})=>{Array.from(r.attributes).forEach(o=>{e.setAttribute(o.name,o.value)}),te.morph(r,e,{morphStyle:"outerHTML"});let n=r.nextSibling;n?.nodeType===Node.TEXT_NODE&&n.textContent.trim()===""&&n.remove()};b.publish=(r,...e)=>{b._subs||={},b._subs[r]||=[],b._subs[r].forEach(t=>{t[1].bind(t[0])(...e)})};b.fnv1=r=>{var e,t,n,o,s,i;for(e=2166136261,t=16777619,n=e,o=s=0,i=r.length-1;0<=i?s<=i:s>=i;o=0<=i?++s:--s)n^=r.charCodeAt(o),n*=t;return n.toString(36).replaceAll("-","")};b.tag=(r,e={},t="")=>{let n=encodeURIComponent(JSON.stringify(e));return`<${r} data-props="${n}">${t}</${r}>`};b.error=(r,e)=>{if(r=`Fez: ${r}`,console.error(r),e)return`<span style="border: 1px solid red; font-size: 14px; padding: 3px 7px; background: #fee; border-radius: 4px;">${r}</span>`};b.log=r=>{b.LOG===!0&&(r=String(r).substring(0,180),console.log(`Fez: ${r}`))};document.addEventListener("DOMContentLoaded",()=>{b.log("Fez.LOG === true, logging enabled.")});b.untilTrue=(r,e)=>{e||=200,r()||setTimeout(()=>{b.untilTrue(r,e)},e)};b.throttle=(r,e=200)=>{let t=0,n;return function(...o){let s=Date.now();s-t>=e?(r.apply(this,o),t=s):(clearTimeout(n),n=setTimeout(()=>{r.apply(this,o),t=Date.now()},e-(s-t)))}};b.fetch=function(...r){b._fetchCache||={};let e="GET",t,n;typeof r[0]=="string"&&/^[A-Z]+$/.test(r[0])&&(e=r.shift()),t=r.shift();let o={},s=null;if(typeof r[0]=="object"&&(s=r.shift()),typeof r[0]=="function"&&(n=r.shift()),s){if(e==="GET"){let f=new URLSearchParams(s);t+=(t.includes("?")?"&":"?")+f.toString()}else if(e==="POST"){let f=new FormData;for(let[m,g]of Object.entries(s))f.append(m,g);o.body=f}}o.method=e;let i=`${e}:${t}:${JSON.stringify(o)}`;if(b._fetchCache[i]){let f=b._fetchCache[i];if(b.log(`fetch cache hit: ${e} ${t}`),n){n(f);return}return Promise.resolve(f)}b.log(`fetch live: ${e} ${t}`);let u=f=>f.headers.get("content-type")?.includes("application/json")?f.json():f.text();if(n){fetch(t,o).then(u).then(f=>{b._fetchCache[i]=f,n(f)}).catch(f=>b.onError("fetch",f));return}return fetch(t,o).then(u).then(f=>(b._fetchCache[i]=f,f))};b.onError=(r,e)=>{if(typeof r!="string")throw new Error("Fez.onError: kind must be a string");console.error(`${r}: ${e.toString()}`)};b._styleMacros={};b.styleMacro=(r,e)=>{b._styleMacros[r]=e};b.store={store:new Map,counter:0,set(r){let e=this.counter++;return this.store.set(e,r),e},get(r){return this.store.get(r)},delete(r){let e=this.store.get(r);return this.store.delete(r),e}};ie(b);b.compile=se;b.state=oe;b.dump=re;var T=b;typeof window<"u"&&(window.FezBase=_);typeof window<"u"&&(window.Fez=T);Promise.resolve().then(()=>ae());setInterval(()=>{for(let[r,e]of T.instances)e?.isConnected||(e.fez?.fezOnDestroy(),T.instances.delete(r))},5e3);var Ge=new MutationObserver(r=>{for(let{addedNodes:e,removedNodes:t}of r)e.forEach(n=>{n.nodeType===1&&(n.matches("template[fez], xmp[fez], script[fez]")&&(T.compile(n),n.remove()),n.querySelectorAll&&n.querySelectorAll("template[fez], xmp[fez], script[fez]").forEach(s=>{T.compile(s),s.remove()}))}),t.forEach(n=>{n.nodeType===1&&n.querySelectorAll&&n.querySelectorAll(".fez, :scope.fez").forEach(s=>{s.fez&&s.root&&(T.instances.delete(s.fez.UID),s.fez.fezOnDestroy())})})});Ge.observe(document.documentElement,{childList:!0,subtree:!0});var At=T;})();
|
|
28
31
|
//# sourceMappingURL=fez.js.map
|