jq79 0.3.25 → 0.3.26

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/jq79.js CHANGED
@@ -1,10 +1,10 @@
1
- var St=Object.defineProperty;var bt=(t,e,n)=>e in t?St(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var w=(t,e,n)=>bt(t,typeof e!="symbol"?e+"":e,n);function A(t,e){return typeof t=="string"?document.querySelector(t):t.querySelector(e)}function P(t,e){return Array.from(typeof t=="string"?document.querySelectorAll(t):t.querySelectorAll(e))}var F=(t,e={})=>{let n=document.createElement(t);for(let[s,r]of Object.entries(e))if(s==="className")n.className=Array.isArray(r)?r.join(" "):r;else if(s==="textContent")n.textContent=r;else if(s==="children")for(let o of r)n.appendChild(o);else n.setAttribute(s,r);return n},$t=new Set(["a","b","i","em","strong","p","br","ul","ol","li","blockquote","code","pre","span","div","h1","h2","h3","h4","h5","h6","img"]),V={a:new Set(["href","title"]),img:new Set(["src","alt"]),"*":new Set(["class"])},wt=new Set(["http:","https:","mailto:"]);function Rt(t){try{let e=new URL(t,"https://example.com");return wt.has(e.protocol)}catch{return!1}}function Z(t,e){for(let n of Array.from(t.childNodes))if(n.nodeType===Node.ELEMENT_NODE){let s=xt(n);s&&e.appendChild(s)}else n.nodeType===Node.TEXT_NODE&&e.appendChild(n.cloneNode())}function xt(t){let e=t.tagName.toLowerCase();if(!$t.has(e))return null;let n=document.createElement(e);for(let s of Array.from(t.attributes)){let r=s.name.toLowerCase(),o=V[e]?.has(r),i=V["*"]?.has(r);!o&&!i||(r==="href"||r==="src")&&!Rt(s.value)||n.setAttribute(r,s.value)}return e==="a"&&n.setAttribute("rel","noopener noreferrer"),Z(t,n),n}function X(t){let e=new DOMParser().parseFromString(t,"text/html"),n=document.createElement("div");return Z(e.body,n),n.innerHTML}var Tt=(t,e)=>e.split(".").reduce((n,s)=>n?.[s],t),J=t=>{if(Array.isArray(t))return!0;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null},Y=(t,e,n)=>{Object.entries(t).forEach(([s,r])=>{let o=e?`${e}.${s}`:s;r&&typeof r=="object"&&J(r)?Y(r,o,n):n(o,r)})},Ct=(t,e)=>t===e||t.startsWith(`${e}.`)||e.startsWith(`${t}.`),W=Symbol("jq79.raw"),B=t=>{let e=t;for(;e!==null&&typeof e=="object"&&e[W];)e=e[W];return e},Q=Symbol("jq79.store"),I=t=>t!==null&&typeof t=="object"&&t[Q]===!0,v=[],tt=t=>{v.push(new Set);try{return t()}finally{v.pop()}},O=t=>{let e=new Map,n=new Set,s=new Set,r=new WeakMap,o=Object.create(null),i=(f,h,b=!1)=>{e.get(f)?.forEach(S=>S(h,f)),n.forEach(S=>S(f,h)),s.forEach(S=>{(b||Array.from(S.deps).some(d=>Ct(d,f)))&&S.run()})},c=f=>f!==null&&typeof f=="object"&&J(f),l=(f,h)=>{let b=r.get(f);if(b)return b;let S=new Proxy(f,{get(d,m,E){if(m===W)return d;if(m===Q)return h==="";if(typeof m!="string")return Reflect.get(d,m,E);if(h===""&&m in o)return o[m];let g=h?`${h}.${m}`:m;v[v.length-1]?.add(g);let R=Reflect.get(d,m,E);if(I(R))return R;let $=B(R);return c($)?l($,g):$},set(d,m,E,g){if(g!==S&&!Object.prototype.hasOwnProperty.call(d,m))return Reflect.set(d,m,E,g);let R=h?`${h}.${m}`:m,$=I(E)?E:B(E),C=!Object.prototype.hasOwnProperty.call(d,m);d[m]=$;let T=I($)||!c($)?$:l($,R);return i(R,T,C),!0}});return r.set(f,S),S},p=l(B(t),""),a=(f,h,{immediate:b=!1}={})=>(e.has(f)||e.set(f,new Set),e.get(f).add(h),b&&h(Tt(p,f),f),()=>e.get(f)?.delete(h)),u=(f,{immediate:h=!1}={})=>(n.add(f),h&&Y(p,"",(b,S)=>f(b,S)),()=>n.delete(f)),y=f=>{let h={deps:new Set,run:()=>{let b=new Set;v.push(b);try{f()}finally{v.pop(),h.deps=b}}};return s.add(h),h.run(),()=>{s.delete(h)}};return o.$on=a,o.$onAny=u,o.$effect=y,p},N=t=>{let e=[];return{effect:n=>{e.push(t.$effect(n))},onDispose:n=>{e.push(n)},dispose:()=>{e.splice(0).forEach(n=>n())}}};var et=/(?:let|var|const)\s+([A-Za-z_$][\w$]*)/y,nt=/\$:\s*/y,j=/import(?=\s*\()/y,st=/\$:\s*([A-Za-z_$][\w$]*)\s*=(?!=)/y,q=(t,e)=>{let n=t[e],s=e+1;for(;s<t.length;){if(t[s]==="\\"){s+=2;continue}if(t[s]===n)return s+1;s++}return t.length},M=(t,e)=>{let n=t.indexOf(`
2
- `,e);return n===-1?t.length:n},D=(t,e)=>{let n=t.indexOf("*/",e+2);return n===-1?t.length:n+2},Lt=(t,e)=>{let n=e;for(;n<t.length;){if(/\s/.test(t[n])){n++;continue}if(t[n]==="/"&&t[n+1]==="/"){n=M(t,n);continue}if(t[n]==="/"&&t[n+1]==="*"){n=D(t,n);continue}break}return n},vt=/^(\?\.|\?\?|&&|\|\||\*\*|[.,+\-*/%&|^<>=?:([])/,Nt=(t,e)=>{let n=0,s=e;for(;s<t.length;){let r=t[s];if(r==="'"||r==='"'||r==="`"){s=q(t,s);continue}if(r==="/"&&t[s+1]==="/"){s=M(t,s);continue}if(r==="/"&&t[s+1]==="*"){s=D(t,s);continue}if("([{".includes(r))n++;else if(")]}".includes(r))n--;else{if(n<=0&&r===";")return s;if(n<=0&&r===`
3
- `){let o=Lt(t,s+1);if(o>=t.length||!vt.test(t.slice(o,o+2)))return s;s=o;continue}}s++}return t.length},it=t=>{let e=[],n="",s=0,r=0,o=!0;for(;s<t.length;){let i=t[s],c=t[s+1];if(i==="'"||i==='"'||i==="`"){let l=q(t,s);n+=t.slice(s,l),s=l,o=!1;continue}if(i==="/"&&(c==="/"||c==="*")){let l=c==="/"?M(t,s):D(t,s);n+=t.slice(s,l),s=l;continue}if(i==="i"&&(s===0||!/[\w$.]/.test(t[s-1]))&&(j.lastIndex=s,j.test(t))){n+="$__import",s+=6,o=!1;continue}if(r===0&&o){et.lastIndex=s;let l=et.exec(t);if(l){e.push(l[1]),n+=l[1],s+=l[0].length,o=!1;continue}nt.lastIndex=s;let p=nt.exec(t);if(p){st.lastIndex=s;let a=st.exec(t);a&&e.push(a[1]);let u=s+p[0].length,y=Nt(t,u);n+=`$__effect(() => { ${t.slice(u,y)} });`,s=y;continue}}"([{".includes(i)?r++:")]}".includes(i)&&(r=Math.max(0,r-1)),i===`
4
- `||i===";"||i==="}"?o=!0:/\s/.test(i)||(o=!1),n+=i,s++}return{vars:e,code:n}},rt=/export\s+default(?![\w$])/y,ot=/import\s*(?:([\w$\s,{}*]+?)\s*from\s*)?(["'])([^"'\n]+)\2/y,_t=t=>{let e=[],n=0,s=0;for(let r=0;r<=t.length;r++){let o=t[r];if(o==="{")n++;else if(o==="}")n--;else if(r===t.length||o===","&&n===0){let i=t.slice(s,r).trim();i&&e.push(i),s=r+1}}return e},At=(t,e,n)=>{let s=`await $__import(${JSON.stringify(e)})`;if(t===void 0)return s;let r=_t(t),o=[],i=s;if(r.length>1){let c=`$__mod${n}`;o.push(`${c} = ${s}`),i=c}for(let c of r)c.startsWith("{")?o.push(`${c.replace(/\s+as\s+/g,": ")} = ${i}`):c.startsWith("*")?o.push(`${c.replace(/^\*\s*as\s+/,"")} = ${i}`):o.push(`${c} = $__default(${i})`);return`const ${o.join(", ")}`},ct=t=>{let e="",n=0,s=0,r=!0,o=!1,i=0;for(;n<t.length;){let c=t[n],l=t[n+1],p=n===0||!/[\w$.]/.test(t[n-1]);if(c==="'"||c==='"'||c==="`"){let a=q(t,n);e+=t.slice(n,a),n=a,r=!1;continue}if(c==="/"&&(l==="/"||l==="*")){let a=l==="/"?M(t,n):D(t,n);e+=t.slice(n,a),n=a;continue}if(c==="i"&&p){if(j.lastIndex=n,j.test(t)){e+="$__import",n+=6,r=!1;continue}if(s===0&&r){ot.lastIndex=n;let a=ot.exec(t);if(a){e+=At(a[1],a[3],i++),n+=a[0].length,r=!1;continue}}}if(c==="e"&&p&&s===0&&r){rt.lastIndex=n;let a=rt.exec(t);if(a){o=!0,e+="$__exports.default =",n+=a[0].length,r=!1;continue}}"([{".includes(c)?s++:")]}".includes(c)&&(s=Math.max(0,s-1)),c===`
5
- `||c===";"||c==="}"?r=!0:/\s/.test(c)||(r=!1),e+=c,n++}return o?e:null};var ut=t=>Object.fromEntries(Array.from(t.attributes).map(e=>[e.name,e.value])),pt=t=>({tag:t.tagName.toLowerCase(),attrs:ut(t),children:Array.from(t.childNodes).flatMap(e=>{if(e.nodeType===Node.TEXT_NODE){let n=e.textContent??"";return n?[n]:[]}return e.nodeType===Node.ELEMENT_NODE?[pt(e)]:[]})}),x=(t,e,n)=>{try{return new Function("$scope",...Object.keys(n??{}),`with ($scope) { return (${t}); }`)(e,...Object.values(n??{}))}catch{return}},Ot=(t,e)=>t.replace(/{{\s*([\s\S]+?)\s*}}/g,(n,s)=>x(s,e)??""),ht=new Set([":attrs",":if",":elseif",":else",":each",":key",":with",":text",":html"]),jt=/^\s*(\w+)\s+in\s+([\s\S]+)$/,Mt=(t,e,n,s)=>{let[r,...o]=e.slice(1).split("."),i=new Set(o);t.addEventListener(r,c=>{if(i.has("self")&&c.target!==t)return;i.has("prevent")&&c.preventDefault(),i.has("stop")&&c.stopPropagation();let l=x(n,s,{$event:c});typeof l=="function"&&l.call(t,c)},{once:i.has("once"),capture:i.has("capture")})},at=t=>t.replace(/-(\w)/g,(e,n)=>n.toUpperCase()),lt=(t,e)=>{let n=e.replace(/-/g,"").toLowerCase();for(let s=t;s&&s!==Object.prototype;s=Object.getPrototypeOf(s))for(let r of Object.keys(s))if(/^[A-Z]/.test(r)&&r.replace(/-/g,"").toLowerCase()===n)return r;return null},dt=(t,e,n,s)=>{let r=document.createComment(t),o=document.createDocumentFragment();o.appendChild(r);let i={};Object.entries(e.attrs).forEach(([a,u])=>{if(!(a===G||ht.has(a)||a.startsWith("@")))if(a.startsWith(":")){let y=at(a.slice(1));i[y]=u||y}else i[at(a)]=JSON.stringify(u)});let c=null,l=null,p=null;return s.effect(()=>{let a=x(t,n),u=a instanceof _?a:null;if(u===l||(p?.dispose(),p=null,c?.destroy(),c=null,l=u,!u))return;let y=new _({template:u.template,scripts:u.scripts,styles:u.styles,modules:u.modules,filename:u.filename}),f=tt(()=>Object.fromEntries(Object.entries(i).map(([S,d])=>[S,x(d,n)]))),h=document.createDocumentFragment();y.render(f).mount(h),r.parentNode.insertBefore(h,r.nextSibling);let b=N(n);Object.entries(i).forEach(([S,d])=>{b.effect(()=>{y.data[S]=x(d,n)})}),p=b,c=y}),s.onDispose(()=>{p?.dispose(),c?.destroy()}),o},Dt=(t,e)=>{let n=()=>{let s=x(t,e);return s!==null&&typeof s=="object"?s:null};return new Proxy(e,{has(s,r){let o=n();return o!==null&&Reflect.has(o,r)||Reflect.has(s,r)},get(s,r){let o=n();return o!==null&&Reflect.has(o,r)?o[r]:Reflect.get(s,r)},set(s,r,o){let i=n();return i!==null&&Reflect.has(i,r)?(i[r]=o,!0):Reflect.set(s,r,o)}})},H=(t,e,n)=>{let s=t.attrs[":with"],r=s!==void 0?Dt(s,e):e,o=lt(r,t.tag);if(o)return dt(o,t,r,n);let i=document.createElement(t.tag);if(i instanceof HTMLUnknownElement||t.tag.includes("-")){let a=!1;n.effect(()=>{if(a)return;let u=lt(r,t.tag);u&&(a=!0,i.replaceWith(dt(u,t,r,n)))})}Object.entries(t.attrs).forEach(([a,u])=>{a.startsWith("@")?Mt(i,a,u,r):ht.has(a)||i.setAttribute(a,u)});let c=t.attrs[":attrs"];if(c!==void 0){let a=[];n.effect(()=>{a.forEach(y=>i.removeAttribute(y));let u=x(c,r);a=u&&typeof u=="object"?Object.keys(u):[],a.forEach(y=>{let f=u[y];f!=null&&f!==!1&&i.setAttribute(y,String(f))})})}let l=t.attrs[":text"],p=t.attrs[":html"];return l!==void 0?n.effect(()=>{i.textContent=String(x(l,r)??"")}):p!==void 0?n.effect(()=>{i.innerHTML=X(String(x(p,r)??""))}):i.appendChild(z(t.children,r,n)),i},kt=(t,e,n)=>{let s=document.createComment("if"),r=document.createDocumentFragment();r.appendChild(s);let o=null,i=null,c=null;return n.effect(()=>{let l=t.find(p=>p.expr===void 0||x(p.expr,e))??null;l!==i&&(c?.dispose(),o&&o.parentNode?.removeChild(o),o=null,i=l,l&&(c=N(e),o=H(l.node,e,c),s.parentNode.insertBefore(o,s.nextSibling)))}),r},U=(t,e,n)=>{Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})},Pt=(t,e,n)=>{let s=t.attrs[":each"].match(jt);if(!s)return document.createComment(`invalid :each expression "${t.attrs[":each"]}"`);let[,r,o]=s,i=t.attrs[":key"],{[":each"]:c,[":key"]:l,...p}=t.attrs,a={...t,attrs:p},u=document.createComment("each"),y=document.createDocumentFragment();y.appendChild(u);let f=[];return n.effect(()=>{let h=x(o,e),b=Array.isArray(h)?h:[],S=new Map(f.map(g=>[g.key,g])),d=b.map((g,R)=>{let $=Object.create(e);U($,r,g),U($,"$index",R);let C=i!==void 0?x(i,$):R,T=S.get(C);if(T&&Object.is(T.item,g))return U(T.scope,"$index",R),T;T?.fx.dispose(),T?.node.parentNode?.removeChild(T.node);let L=N(e);return{key:C,item:g,scope:$,fx:L,node:H(a,$,L)}}),m=new Set(d.map(g=>g.key));f.forEach(g=>{m.has(g.key)||(g.fx.dispose(),g.node.parentNode?.removeChild(g.node))});let E=u;d.forEach(g=>{E.nextSibling!==g.node&&u.parentNode.insertBefore(g.node,E.nextSibling),E=g.node}),f=d}),y},z=(t,e,n)=>{let s=document.createDocumentFragment(),r=0;for(;r<t.length;){let o=t[r];if(typeof o=="string"){let i=document.createTextNode(o);o.includes("{{")&&n.effect(()=>{i.textContent=Ot(o,e)}),s.appendChild(i),r++;continue}if(":each"in o.attrs){s.appendChild(Pt(o,e,n)),r++;continue}if(":if"in o.attrs){let i=[{expr:o.attrs[":if"],node:o}];r++;let c=p=>{let a=r;for(;a<t.length&&typeof t[a]=="string"&&!t[a].trim();)a++;let u=t[a];if(typeof u=="object"&&p in u.attrs)return r=a+1,u};for(let p=c(":elseif");p;p=c(":elseif"))i.push({expr:p.attrs[":elseif"],node:p});let l=c(":else");l&&i.push({node:l}),s.appendChild(kt(i,e,n));continue}s.appendChild(H(o,e,n)),r++}return s},re=(t,e)=>z(t.template,e,N(e)),Ft=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Bt=/<([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)\/>/g,It=/(<script[\s\S]*?<\/script\s*>|<style[\s\S]*?<\/style\s*>)/gi,Wt=t=>t.split(It).map((e,n)=>n%2===1?e:e.replace(Bt,(s,r,o)=>Ft.has(r.toLowerCase())?s:`<${r}${o}></${r}>`)).join(""),G="data-jq79",qt=t=>{let e=2166136261;for(let n=0;n<t.length;n++)e=Math.imul(e^t.charCodeAt(n),16777619);return(e>>>0).toString(36)},mt=(t,e)=>{t.forEach(n=>{typeof n!="string"&&(n.attrs[G]=e,mt(n.children,e))})},Ut=(t,e)=>t.split(",").map(n=>{let s=n.trim(),r=s.indexOf("::"),o=r===-1?s:s.slice(0,r),i=r===-1?"":s.slice(r);return`${o}[${G}="${e}"]${i}`}).join(", "),gt=(t,e)=>{Array.from(t).forEach(n=>{n instanceof CSSStyleRule?n.selectorText=Ut(n.selectorText,e):n instanceof CSSGroupingRule&&gt(n.cssRules,e)})},Ht=(t,e)=>{/:deep\(|::v-deep|>>>/.test(t)&&console.warn("jq79: :deep()/::v-deep/>>> are not supported in <style scoped>; the rule will be dropped by the browser");let n=new CSSStyleSheet;return n.replaceSync(t),gt(n.cssRules,e),Array.from(n.cssRules).map(s=>s.cssText).join(`
6
- `)},zt=t=>{let n=new DOMParser().parseFromString(`<template>${Wt(t)}</template>`,"text/html").querySelector("template"),s=[],r=[],o=[];Array.from(n.content.children).forEach(c=>{let l={attrs:ut(c),content:c.textContent??""};c.tagName==="SCRIPT"?s.push(l):c.tagName==="STYLE"?r.push(l):o.push(pt(c))}),r.forEach(c=>{"lang"in c.attrs&&console.warn(`jq79: <style lang="${c.attrs.lang}"> needs the jq79/vite plugin to compile it. This component didn't go through the bundler, so its styles were left uncompiled and the browser will ignore them.`)});let i=c=>"scoped"in c.attrs&&!("lang"in c.attrs);if(r.some(i)){let c=qt(t);mt(o,c),r.forEach(l=>{i(l)&&(l.scoped=Ht(l.content,c))})}return{template:o,scripts:s,styles:r}},K=t=>/\.html?([?#]|$)/.test(t)?_.fetch(t):import(t),yt=(t,e)=>t?`
7
- //# sourceURL=${t}?jq79-script=${e}`:"",ft=t=>t.scoped??t.content,k=new Map,Gt=t=>{let e=k.get(t);if(!e){let n=document.createElement("style");n.textContent=t,document.head.appendChild(n),e={el:n,count:0},k.set(t,e)}e.count++},Kt=t=>{let e=k.get(t);e&&--e.count<=0&&(e.el.remove(),k.delete(t))},Et={$:A,$$:P,$create:F,$reactive:O},Vt=(t,e,n,s={},r=K,o={})=>{let i={...Et,...s},c=new Proxy(e,{has:(p,a)=>a!=="$__effect"&&a!=="$__import"&&(Reflect.has(p,a)||!(a in globalThis)&&!(a in i))});new Function("$scope","$__effect","$__import",...Object.keys(i),`return (async () => { with ($scope) { ${t} } })()${yt(o.filename,o.index??0)}`)(c,n,r,...Object.values(i)).catch(p=>console.error("jq79: error in :setup script",p))},Zt=t=>t&&t.default!==void 0?t.default:t,Xt=(t,e,n,s={},r=K,o={})=>{let i={...Et,...s},c={},l=new Function("$__exports","$__default","$__import",...Object.keys(i),`return (async () => { "use strict";
8
- ${t}
9
- ;$__exports.done = true })()${yt(o.filename,o.index??0)}`)(c,Zt,r,...Object.values(i)),p=y=>console.error("jq79: error in factory script",y),a=!1,u=()=>{if(a)return;a=!0;let y=c.default;if(typeof y!="function")return;let f=h=>{h&&typeof h=="object"&&Object.assign(e,h)};try{let h=y({$data:e,$effect:n,...s});h instanceof Promise?h.then(f).catch(p):f(h)}catch(h){p(h)}};l.then(u,p),c.done&&u()},_=class t{constructor(e,n={}){w(this,"template");w(this,"scripts");w(this,"styles");w(this,"modules");w(this,"filename");w(this,"data",null);w(this,"fx",null);w(this,"content",null);w(this,"startMarker",null);w(this,"endMarker",null);w(this,"styleEls",[]);w(this,"ownsSharedStyles",!1);w(this,"useShadow",!1);w(this,"mountRoot",null);w(this,"resolveMounted",null);w(this,"emitListeners",new Map);let s=typeof e=="string"?zt(e):e;this.template=s.template,this.scripts=s.scripts,this.styles=s.styles,this.modules=n.modules??(typeof e=="string"?void 0:e.modules),this.filename=n.filename??(typeof e=="string"?void 0:e.filename)}static async fetch(e){let n=await fetch(e);if(!n.ok)throw new Error(`failed to fetch component from ${e}: ${n.status}`);return new t(await n.text(),{filename:e})}on(e,n){return this.emitListeners.has(e)||this.emitListeners.set(e,new Set),this.emitListeners.get(e).add(n),this}off(e,n){return this.emitListeners.get(e)?.delete(n),this}render(e={}){return this.renderWith(e,!1)}renderShadow(e={}){return this.renderWith(e,!0)}renderWith(e,n){this.destroy();let s=O({...e}),r=N(s);this.data=s,this.fx=r,this.useShadow=n,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let o=this.startMarker,i=(d,m)=>{let E=new CustomEvent(d,{detail:m,bubbles:!0,composed:!0}),g=o.dispatchEvent(E);return o===this.startMarker&&this.emitListeners.get(d)?.forEach(R=>R(E,m)),g},c,l=new Promise(d=>{c=d});this.resolveMounted=c;let p=()=>l,a=this.endMarker,u=d=>{let m=[];for(let E=o.nextSibling;E&&E!==a;E=E.nextSibling)E instanceof Element&&(E.matches(d)&&m.push(E),m.push(...Array.from(E.querySelectorAll(d))));return m},y=d=>u(d)[0]??null,f=this.modules,h=d=>f&&d in f?Promise.resolve(f[d]):K(d),b=d=>`await $mounted();${d}`;this.scripts.forEach((d,m)=>{let E={$emit:i,$mounted:p,$self:y,$$self:u},g={filename:this.filename,index:m},R=ct(d.content);if(R!==null){let L=":mounted"in d.attrs?b(R):R;Xt(L,s,r.effect,E,h,g);return}let{vars:$,code:C}=it(d.content);$.forEach(L=>{L in s||(s[L]=void 0)});let T=":mounted"in d.attrs?b(C):C;Vt(T,s,r.effect,E,h,g)});let S=document.createDocumentFragment();return S.append(this.startMarker,z(this.template,s,r),this.endMarker),this.content=S,n?this.styleEls=this.styles.map(d=>{let m=document.createElement("style");return m.textContent=d.content,m}):(this.styles.forEach(d=>Gt(ft(d))),this.ownsSharedStyles=!0),this}mount(e,n){let s=typeof e=="string"?A(e):e;if(!s)throw new Error(`mount target not found: ${e}`);return(!this.content||n!==void 0)&&this.renderWith(n??{},this.useShadow),this.attach(s)}mountShadow(e,n){let s=typeof e=="string"?A(e):e;if(!s)throw new Error(`mount target not found: ${e}`);return(!this.content||n!==void 0||!this.useShadow)&&this.renderWith(n??{},!0),this.attach(s)}attach(e){this.mountRoot&&this.detach();let n=this.useShadow&&e instanceof Element?e.shadowRoot??e.attachShadow({mode:"open"}):e;return this.useShadow&&this.styleEls.forEach(s=>n.appendChild(s)),n.appendChild(this.content),this.mountRoot=n,this.resolveMounted?.(),this}detach(){if(!this.mountRoot||!this.content||!this.startMarker||!this.endMarker)return this;let e=this.startMarker;for(;e;){let n=e.nextSibling;if(this.content.appendChild(e),e===this.endMarker)break;e=n}return this.mountRoot=null,this}destroy(){return this.detach(),this.fx?.dispose(),this.fx=null,this.styleEls.forEach(e=>e.parentNode?.removeChild(e)),this.styleEls=[],this.ownsSharedStyles&&(this.styles.forEach(e=>Kt(ft(e))),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.data=null,this.resolveMounted=null,this}},oe=t=>new _(t);export{A as $,P as $$,F as $create,O as $reactive,_ as Component79,oe as parseComponent,re as renderComponent};
1
+ var be=Object.defineProperty;var $e=(e,t,n)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var $=(e,t,n)=>$e(e,typeof t!="symbol"?t+"":t,n);function A(e,t){return typeof e=="string"?document.querySelector(e):e.querySelector(t)}function P(e,t){return Array.from(typeof e=="string"?document.querySelectorAll(e):e.querySelectorAll(t))}var F=(e,t={})=>{let n=document.createElement(e);for(let[s,r]of Object.entries(t))if(s==="className")n.className=Array.isArray(r)?r.join(" "):r;else if(s==="textContent")n.textContent=r;else if(s==="children")for(let o of r)n.appendChild(o);else n.setAttribute(s,r);return n},Re=new Set(["a","b","i","em","strong","p","br","ul","ol","li","blockquote","code","pre","span","div","h1","h2","h3","h4","h5","h6","img"]),Z={a:new Set(["href","title"]),img:new Set(["src","alt"]),"*":new Set(["class"])},we=new Set(["http:","https:","mailto:"]);function xe(e){try{let t=new URL(e,"https://example.com");return we.has(t.protocol)}catch{return!1}}function X(e,t){for(let n of Array.from(e.childNodes))if(n.nodeType===Node.ELEMENT_NODE){let s=Te(n);s&&t.appendChild(s)}else n.nodeType===Node.TEXT_NODE&&t.appendChild(n.cloneNode())}function Te(e){let t=e.tagName.toLowerCase();if(!Re.has(t))return null;let n=document.createElement(t);for(let s of Array.from(e.attributes)){let r=s.name.toLowerCase(),o=Z[t]?.has(r),c=Z["*"]?.has(r);!o&&!c||(r==="href"||r==="src")&&!xe(s.value)||n.setAttribute(r,s.value)}return t==="a"&&n.setAttribute("rel","noopener noreferrer"),X(e,n),n}function J(e){let t=new DOMParser().parseFromString(e,"text/html"),n=document.createElement("div");return X(t.body,n),n.innerHTML}var Ce=(e,t)=>t.split(".").reduce((n,s)=>n?.[s],e),Y=e=>{if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Q=(e,t,n)=>{Object.entries(e).forEach(([s,r])=>{let o=t?`${t}.${s}`:s;r&&typeof r=="object"&&Y(r)?Q(r,o,n):n(o,r)})},Le=(e,t)=>e===t||e.startsWith(`${t}.`)||t.startsWith(`${e}.`),W=Symbol("jq79.raw"),B=e=>{let t=e;for(;t!==null&&typeof t=="object"&&t[W];)t=t[W];return t},ee=Symbol("jq79.store"),I=e=>e!==null&&typeof e=="object"&&e[ee]===!0,v=[],te=e=>{v.push(new Set);try{return e()}finally{v.pop()}},O=e=>{let t=new Map,n=new Set,s=new Set,r=new WeakMap,o=Object.create(null),c=(f,u,S=!1)=>{t.get(f)?.forEach(b=>b(u,f)),n.forEach(b=>b(f,u)),s.forEach(b=>{(S||Array.from(b.deps).some(m=>Le(m,f)))&&b.run()})},i=f=>f!==null&&typeof f=="object"&&Y(f),a=(f,u)=>{let S=r.get(f);if(S)return S;let b=new Proxy(f,{get(m,h,E){if(h===W)return m;if(h===ee)return u==="";if(typeof h!="string")return Reflect.get(m,h,E);if(u===""&&h in o)return o[h];let w=u?`${u}.${h}`:h;v[v.length-1]?.add(w);let y=Reflect.get(m,h,E);if(I(y))return y;let R=B(y);return i(R)?a(R,w):R},set(m,h,E,w){if(w!==b&&!Object.prototype.hasOwnProperty.call(m,h))return Reflect.set(m,h,E,w);let y=u?`${u}.${h}`:h,R=I(E)?E:B(E),C=!Object.prototype.hasOwnProperty.call(m,h);m[h]=R;let L=I(R)||!i(R)?R:a(R,y);return c(y,L,C),!0}});return r.set(f,b),b},g=a(B(e),""),l=(f,u,{immediate:S=!1}={})=>(t.has(f)||t.set(f,new Set),t.get(f).add(u),S&&u(Ce(g,f),f),()=>t.get(f)?.delete(u)),p=(f,{immediate:u=!1}={})=>(n.add(f),u&&Q(g,"",(S,b)=>f(S,b)),()=>n.delete(f)),d=f=>{let u={deps:new Set,run:()=>{let S=new Set;v.push(S);try{f()}finally{v.pop(),u.deps=S}}};return s.add(u),u.run(),()=>{s.delete(u)}};return o.$on=l,o.$onAny=p,o.$effect=d,g},N=e=>{let t=[];return{effect:n=>{t.push(e.$effect(n))},onDispose:n=>{t.push(n)},dispose:()=>{t.splice(0).forEach(n=>n())}}};var ne=/(?:let|var|const)\s+([A-Za-z_$][\w$]*)/y,se=/\$:\s*/y,j=/import(?=\s*\()/y,re=/\$:\s*([A-Za-z_$][\w$]*)\s*=(?!=)/y,q=(e,t)=>{let n=e[t],s=t+1;for(;s<e.length;){if(e[s]==="\\"){s+=2;continue}if(e[s]===n)return s+1;s++}return e.length},M=(e,t)=>{let n=e.indexOf(`
2
+ `,t);return n===-1?e.length:n},D=(e,t)=>{let n=e.indexOf("*/",t+2);return n===-1?e.length:n+2},ve=(e,t)=>{let n=t;for(;n<e.length;){if(/\s/.test(e[n])){n++;continue}if(e[n]==="/"&&e[n+1]==="/"){n=M(e,n);continue}if(e[n]==="/"&&e[n+1]==="*"){n=D(e,n);continue}break}return n},Ne=/^(\?\.|\?\?|&&|\|\||\*\*|[.,+\-*/%&|^<>=?:([])/,_e=(e,t)=>{let n=0,s=t;for(;s<e.length;){let r=e[s];if(r==="'"||r==='"'||r==="`"){s=q(e,s);continue}if(r==="/"&&e[s+1]==="/"){s=M(e,s);continue}if(r==="/"&&e[s+1]==="*"){s=D(e,s);continue}if("([{".includes(r))n++;else if(")]}".includes(r))n--;else{if(n<=0&&r===";")return s;if(n<=0&&r===`
3
+ `){let o=ve(e,s+1);if(o>=e.length||!Ne.test(e.slice(o,o+2)))return s;s=o;continue}}s++}return e.length},ce=e=>{let t=[],n="",s=0,r=0,o=!0;for(;s<e.length;){let c=e[s],i=e[s+1];if(c==="'"||c==='"'||c==="`"){let a=q(e,s);n+=e.slice(s,a),s=a,o=!1;continue}if(c==="/"&&(i==="/"||i==="*")){let a=i==="/"?M(e,s):D(e,s);n+=e.slice(s,a),s=a;continue}if(c==="i"&&(s===0||!/[\w$.]/.test(e[s-1]))&&(j.lastIndex=s,j.test(e))){n+="$__import",s+=6,o=!1;continue}if(r===0&&o){ne.lastIndex=s;let a=ne.exec(e);if(a){t.push(a[1]),n+=a[1],s+=a[0].length,o=!1;continue}se.lastIndex=s;let g=se.exec(e);if(g){re.lastIndex=s;let l=re.exec(e);l&&t.push(l[1]);let p=s+g[0].length,d=_e(e,p);n+=`$__effect(() => { ${e.slice(p,d)} });`,s=d;continue}}"([{".includes(c)?r++:")]}".includes(c)&&(r=Math.max(0,r-1)),c===`
4
+ `||c===";"||c==="}"?o=!0:/\s/.test(c)||(o=!1),n+=c,s++}return{vars:t,code:n}},oe=/export\s+default(?![\w$])/y,ie=/import\s*(?:([\w$\s,{}*]+?)\s*from\s*)?(["'])([^"'\n]+)\2/y,Ae=e=>{let t=[],n=0,s=0;for(let r=0;r<=e.length;r++){let o=e[r];if(o==="{")n++;else if(o==="}")n--;else if(r===e.length||o===","&&n===0){let c=e.slice(s,r).trim();c&&t.push(c),s=r+1}}return t},Oe=(e,t,n)=>{let s=`await $__import(${JSON.stringify(t)})`;if(e===void 0)return s;let r=Ae(e),o=[],c=s;if(r.length>1){let i=`$__mod${n}`;o.push(`${i} = ${s}`),c=i}for(let i of r)i.startsWith("{")?o.push(`${i.replace(/\s+as\s+/g,": ")} = ${c}`):i.startsWith("*")?o.push(`${i.replace(/^\*\s*as\s+/,"")} = ${c}`):o.push(`${i} = $__default(${c})`);return`const ${o.join(", ")}`},ae=e=>{let t="",n=0,s=0,r=!0,o=!1,c=0;for(;n<e.length;){let i=e[n],a=e[n+1],g=n===0||!/[\w$.]/.test(e[n-1]);if(i==="'"||i==='"'||i==="`"){let l=q(e,n);t+=e.slice(n,l),n=l,r=!1;continue}if(i==="/"&&(a==="/"||a==="*")){let l=a==="/"?M(e,n):D(e,n);t+=e.slice(n,l),n=l;continue}if(i==="i"&&g){if(j.lastIndex=n,j.test(e)){t+="$__import",n+=6,r=!1;continue}if(s===0&&r){ie.lastIndex=n;let l=ie.exec(e);if(l){t+=Oe(l[1],l[3],c++),n+=l[0].length,r=!1;continue}}}if(i==="e"&&g&&s===0&&r){oe.lastIndex=n;let l=oe.exec(e);if(l){o=!0,t+="$__exports.default =",n+=l[0].length,r=!1;continue}}"([{".includes(i)?s++:")]}".includes(i)&&(s=Math.max(0,s-1)),i===`
5
+ `||i===";"||i==="}"?r=!0:/\s/.test(i)||(r=!1),t+=i,n++}return o?t:null};var pe=e=>Object.fromEntries(Array.from(e.attributes).map(t=>[t.name,t.value])),me=e=>({tag:e.tagName.toLowerCase(),attrs:pe(e),children:Array.from(e.childNodes).flatMap(t=>{if(t.nodeType===Node.TEXT_NODE){let n=t.textContent??"";return n?[n]:[]}return t.nodeType===Node.ELEMENT_NODE?[me(t)]:[]})}),T=(e,t,n)=>{try{return new Function("$scope",...Object.keys(n??{}),`with ($scope) { return (${e}); }`)(t,...Object.values(n??{}))}catch{return}},je=(e,t)=>e.replace(/{{\s*([\s\S]+?)\s*}}/g,(n,s)=>T(s,t)??""),he=new Set([":attrs",":if",":elseif",":else",":each",":key",":with",":text",":html"]),Me=/^\s*(\w+)\s+in\s+([\s\S]+)$/,De=(e,t,n,s)=>{let[r,...o]=t.slice(1).split("."),c=new Set(o);e.addEventListener(r,i=>{if(c.has("self")&&i.target!==e)return;c.has("prevent")&&i.preventDefault(),c.has("stop")&&i.stopPropagation();let a=T(n,s,{$event:i});typeof a=="function"&&a.call(e,i)},{once:c.has("once"),capture:c.has("capture")})},le=e=>e.replace(/-(\w)/g,(t,n)=>n.toUpperCase()),fe=(e,t)=>{let n=t.replace(/-/g,"").toLowerCase();for(let s=e;s&&s!==Object.prototype;s=Object.getPrototypeOf(s))for(let r of Object.keys(s))if(/^[A-Z]/.test(r)&&r.replace(/-/g,"").toLowerCase()===n)return r;return null},ue=(e,t,n,s,r)=>{let o=document.createComment(e),c=document.createDocumentFragment();c.appendChild(o);let i={};Object.entries(t.attrs).forEach(([p,d])=>{if(!(p===G||he.has(p)||p.startsWith("@")))if(p.startsWith(":")){let f=le(p.slice(1));i[f]=d||f}else i[le(p)]=JSON.stringify(d)});let a=null,g=null,l=null;return s.effect(()=>{let p=T(e,n),d=p instanceof _?p:null;if(d===g||(l?.dispose(),l=null,a?.destroy(),a=null,g=d,!d))return;let f=new _({template:d.template,scripts:d.scripts,styles:d.styles,modules:d.modules,filename:d.filename}),u=te(()=>Object.fromEntries(Object.entries(i).map(([m,h])=>[m,T(h,n)]))),S=document.createDocumentFragment();(r?f.renderShadow(u):f.render(u)).mount(S),o.parentNode.insertBefore(S,o.nextSibling);let b=N(n);Object.entries(i).forEach(([m,h])=>{b.effect(()=>{f.data[m]=T(h,n)})}),l=b,a=f}),s.onDispose(()=>{l?.dispose(),a?.destroy()}),c},ke=(e,t)=>{let n=()=>{let s=T(e,t);return s!==null&&typeof s=="object"?s:null};return new Proxy(t,{has(s,r){let o=n();return o!==null&&Reflect.has(o,r)||Reflect.has(s,r)},get(s,r){let o=n();return o!==null&&Reflect.has(o,r)?o[r]:Reflect.get(s,r)},set(s,r,o){let c=n();return c!==null&&Reflect.has(c,r)?(c[r]=o,!0):Reflect.set(s,r,o)}})},H=(e,t,n,s)=>{let r=e.attrs[":with"],o=r!==void 0?ke(r,t):t,c=fe(o,e.tag);if(c)return ue(c,e,o,n,s);let i=document.createElement(e.tag);if(i instanceof HTMLUnknownElement||e.tag.includes("-")){let p=!1;n.effect(()=>{if(p)return;let d=fe(o,e.tag);d&&(p=!0,i.replaceWith(ue(d,e,o,n,s)))})}Object.entries(e.attrs).forEach(([p,d])=>{p.startsWith("@")?De(i,p,d,o):he.has(p)||i.setAttribute(p,d)});let a=e.attrs[":attrs"];if(a!==void 0){let p=[];n.effect(()=>{p.forEach(f=>i.removeAttribute(f));let d=T(a,o);p=d&&typeof d=="object"?Object.keys(d):[],p.forEach(f=>{let u=d[f];u!=null&&u!==!1&&i.setAttribute(f,String(u))})})}let g=e.attrs[":text"],l=e.attrs[":html"];return g!==void 0?n.effect(()=>{i.textContent=String(T(g,o)??"")}):l!==void 0?n.effect(()=>{i.innerHTML=J(String(T(l,o)??""))}):i.appendChild(z(e.children,o,n,s)),i},Pe=(e,t,n,s)=>{let r=document.createComment("if"),o=document.createDocumentFragment();o.appendChild(r);let c=null,i=null,a=null;return n.effect(()=>{let g=e.find(l=>l.expr===void 0||T(l.expr,t))??null;g!==i&&(a?.dispose(),c&&c.parentNode?.removeChild(c),c=null,i=g,g&&(a=N(t),c=H(g.node,t,a,s),r.parentNode.insertBefore(c,r.nextSibling)))}),o},U=(e,t,n)=>{Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})},Fe=(e,t,n,s)=>{let r=e.attrs[":each"].match(Me);if(!r)return document.createComment(`invalid :each expression "${e.attrs[":each"]}"`);let[,o,c]=r,i=e.attrs[":key"],{[":each"]:a,[":key"]:g,...l}=e.attrs,p={...e,attrs:l},d=document.createComment("each"),f=document.createDocumentFragment();f.appendChild(d);let u=[];return n.effect(()=>{let S=T(c,t),b=Array.isArray(S)?S:[],m=new Map(u.map(y=>[y.key,y])),h=b.map((y,R)=>{let C=Object.create(t);U(C,o,y),U(C,"$index",R);let L=i!==void 0?T(i,C):R,x=m.get(L);if(x&&Object.is(x.item,y))return U(x.scope,"$index",R),x;x?.fx.dispose(),x?.node.parentNode?.removeChild(x.node);let V=N(t);return{key:L,item:y,scope:C,fx:V,node:H(p,C,V,s)}}),E=new Set(h.map(y=>y.key));u.forEach(y=>{E.has(y.key)||(y.fx.dispose(),y.node.parentNode?.removeChild(y.node))});let w=d;h.forEach(y=>{w.nextSibling!==y.node&&d.parentNode.insertBefore(y.node,w.nextSibling),w=y.node}),u=h}),f},z=(e,t,n,s=!1)=>{let r=document.createDocumentFragment(),o=0;for(;o<e.length;){let c=e[o];if(typeof c=="string"){let i=document.createTextNode(c);c.includes("{{")&&n.effect(()=>{i.textContent=je(c,t)}),r.appendChild(i),o++;continue}if(":each"in c.attrs){r.appendChild(Fe(c,t,n,s)),o++;continue}if(":if"in c.attrs){let i=[{expr:c.attrs[":if"],node:c}];o++;let a=l=>{let p=o;for(;p<e.length&&typeof e[p]=="string"&&!e[p].trim();)p++;let d=e[p];if(typeof d=="object"&&l in d.attrs)return o=p+1,d};for(let l=a(":elseif");l;l=a(":elseif"))i.push({expr:l.attrs[":elseif"],node:l});let g=a(":else");g&&i.push({node:g}),r.appendChild(Pe(i,t,n,s));continue}r.appendChild(H(c,t,n,s)),o++}return r},ot=(e,t,n=!1)=>z(e.template,t,N(t),n),Be=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ie=/<([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)\/>/g,We=/(<script[\s\S]*?<\/script\s*>|<style[\s\S]*?<\/style\s*>)/gi,qe=e=>e.split(We).map((t,n)=>n%2===1?t:t.replace(Ie,(s,r,o)=>Be.has(r.toLowerCase())?s:`<${r}${o}></${r}>`)).join(""),G="data-jq79",Ue=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0).toString(36)},ge=(e,t)=>{e.forEach(n=>{typeof n!="string"&&(n.attrs[G]=t,ge(n.children,t))})},He=(e,t)=>e.split(",").map(n=>{let s=n.trim(),r=s.indexOf("::"),o=r===-1?s:s.slice(0,r),c=r===-1?"":s.slice(r);return`${o}[${G}="${t}"]${c}`}).join(", "),ye=(e,t)=>{Array.from(e).forEach(n=>{n instanceof CSSStyleRule?n.selectorText=He(n.selectorText,t):n instanceof CSSGroupingRule&&ye(n.cssRules,t)})},ze=(e,t)=>{/:deep\(|::v-deep|>>>/.test(e)&&console.warn("jq79: :deep()/::v-deep/>>> are not supported in <style scoped>; the rule will be dropped by the browser");let n=new CSSStyleSheet;return n.replaceSync(e),ye(n.cssRules,t),Array.from(n.cssRules).map(s=>s.cssText).join(`
6
+ `)},Ge=e=>{let n=new DOMParser().parseFromString(`<template>${qe(e)}</template>`,"text/html").querySelector("template"),s=[],r=[],o=[];Array.from(n.content.children).forEach(i=>{let a={attrs:pe(i),content:i.textContent??""};i.tagName==="SCRIPT"?s.push(a):i.tagName==="STYLE"?r.push(a):o.push(me(i))}),r.forEach(i=>{"lang"in i.attrs&&console.warn(`jq79: <style lang="${i.attrs.lang}"> needs the jq79/vite plugin to compile it. This component didn't go through the bundler, so its styles were left uncompiled and the browser will ignore them.`)});let c=i=>"scoped"in i.attrs&&!("lang"in i.attrs);if(r.some(c)){let i=Ue(e);ge(o,i),r.forEach(a=>{c(a)&&(a.scoped=ze(a.content,i))})}return{template:o,scripts:s,styles:r}},K=e=>/\.html?([?#]|$)/.test(e)?_.fetch(e):import(e),Ee=(e,t)=>e?`
7
+ //# sourceURL=${e}?jq79-script=${t}`:"",de=e=>e.scoped??e.content,k=new Map,Ke=e=>{let t=k.get(e);if(!t){let n=document.createElement("style");n.textContent=e,document.head.appendChild(n),t={el:n,count:0},k.set(e,t)}t.count++},Ve=e=>{let t=k.get(e);t&&--t.count<=0&&(t.el.remove(),k.delete(e))},Se={$:A,$$:P,$create:F,$reactive:O},Ze=(e,t,n,s={},r=K,o={})=>{let c={...Se,...s},i=new Proxy(t,{has:(g,l)=>l!=="$__effect"&&l!=="$__import"&&(Reflect.has(g,l)||!(l in globalThis)&&!(l in c))});new Function("$scope","$__effect","$__import",...Object.keys(c),`return (async () => { with ($scope) { ${e} } })()${Ee(o.filename,o.index??0)}`)(i,n,r,...Object.values(c)).catch(g=>console.error("jq79: error in :setup script",g))},Xe=e=>e&&e.default!==void 0?e.default:e,Je=(e,t,n,s={},r=K,o={})=>{let c={...Se,...s},i={},a=new Function("$__exports","$__default","$__import",...Object.keys(c),`return (async () => { "use strict";
8
+ ${e}
9
+ ;$__exports.done = true })()${Ee(o.filename,o.index??0)}`)(i,Xe,r,...Object.values(c)),g=d=>console.error("jq79: error in factory script",d),l=!1,p=()=>{if(l)return;l=!0;let d=i.default;if(typeof d!="function")return;let f=u=>{u&&typeof u=="object"&&Object.assign(t,u)};try{let u=d({$data:t,$effect:n,...s});u instanceof Promise?u.then(f).catch(g):f(u)}catch(u){g(u)}};a.then(p,g),i.done&&p()},_=class e{constructor(t,n={}){$(this,"template");$(this,"scripts");$(this,"styles");$(this,"modules");$(this,"filename");$(this,"data",null);$(this,"fx",null);$(this,"content",null);$(this,"startMarker",null);$(this,"endMarker",null);$(this,"styleEls",[]);$(this,"ownsSharedStyles",!1);$(this,"useShadow",!1);$(this,"mountRoot",null);$(this,"resolveMounted",null);$(this,"emitListeners",new Map);let s=typeof t=="string"?Ge(t):t;this.template=s.template,this.scripts=s.scripts,this.styles=s.styles,this.modules=n.modules??(typeof t=="string"?void 0:t.modules),this.filename=n.filename??(typeof t=="string"?void 0:t.filename)}static async fetch(t){let n=await fetch(t);if(!n.ok)throw new Error(`failed to fetch component from ${t}: ${n.status}`);return new e(await n.text(),{filename:t})}on(t,n){return this.emitListeners.has(t)||this.emitListeners.set(t,new Set),this.emitListeners.get(t).add(n),this}off(t,n){return this.emitListeners.get(t)?.delete(n),this}render(t={}){return this.renderWith(t,!1)}renderShadow(t={}){return this.renderWith(t,!0)}renderWith(t,n){this.destroy();let s=O({...t}),r=N(s);this.data=s,this.fx=r,this.useShadow=n,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let o=this.startMarker,c=(m,h)=>{let E=new CustomEvent(m,{detail:h,bubbles:!0,composed:!0}),w=o.dispatchEvent(E);return o===this.startMarker&&this.emitListeners.get(m)?.forEach(y=>y(E,h)),w},i,a=new Promise(m=>{i=m});this.resolveMounted=i;let g=()=>a,l=this.endMarker,p=m=>{let h=[];for(let E=o.nextSibling;E&&E!==l;E=E.nextSibling)E instanceof Element&&(E.matches(m)&&h.push(E),h.push(...Array.from(E.querySelectorAll(m))));return h},d=m=>p(m)[0]??null,f=this.modules,u=m=>f&&m in f?Promise.resolve(f[m]):K(m),S=m=>`await $mounted();${m}`;this.scripts.forEach((m,h)=>{let E={$emit:c,$mounted:g,$self:d,$$self:p},w={filename:this.filename,index:h},y=ae(m.content);if(y!==null){let x=":mounted"in m.attrs?S(y):y;Je(x,s,r.effect,E,u,w);return}let{vars:R,code:C}=ce(m.content);R.forEach(x=>{x in s||(s[x]=void 0)});let L=":mounted"in m.attrs?S(C):C;Ze(L,s,r.effect,E,u,w)});let b=document.createDocumentFragment();return b.append(this.startMarker,z(this.template,s,r,n),this.endMarker),this.content=b,n?this.styleEls=this.styles.map(m=>{let h=document.createElement("style");return h.textContent=m.content,h}):(this.styles.forEach(m=>Ke(de(m))),this.ownsSharedStyles=!0),this}mount(t,n){let s=typeof t=="string"?A(t):t;if(!s)throw new Error(`mount target not found: ${t}`);return(!this.content||n!==void 0)&&this.renderWith(n??{},this.useShadow),this.attach(s)}mountShadow(t,n){let s=typeof t=="string"?A(t):t;if(!s)throw new Error(`mount target not found: ${t}`);return(!this.content||n!==void 0||!this.useShadow)&&this.renderWith(n??{},!0),this.attach(s)}attach(t){this.mountRoot&&this.detach();let n=this.useShadow&&t instanceof Element?t.shadowRoot??t.attachShadow({mode:"open"}):t;return this.useShadow&&this.styleEls.forEach(s=>n.appendChild(s)),n.appendChild(this.content),this.mountRoot=n,this.resolveMounted?.(),this}detach(){if(!this.mountRoot||!this.content||!this.startMarker||!this.endMarker)return this;let t=this.startMarker;for(;t;){let n=t.nextSibling;if(this.content.appendChild(t),t===this.endMarker)break;t=n}return this.mountRoot=null,this}destroy(){return this.detach(),this.fx?.dispose(),this.fx=null,this.styleEls.forEach(t=>t.parentNode?.removeChild(t)),this.styleEls=[],this.ownsSharedStyles&&(this.styles.forEach(t=>Ve(de(t))),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.data=null,this.resolveMounted=null,this}},it=e=>new _(e);export{A as $,P as $$,F as $create,O as $reactive,_ as Component79,it as parseComponent,ot as renderComponent};
10
10
  //# sourceMappingURL=jq79.js.map