jq79 0.4.16 → 0.4.18
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 +1 -1
- package/dist/jq79.cjs +12 -12
- package/dist/jq79.cjs.map +1 -1
- package/dist/jq79.d.ts +1 -0
- package/dist/jq79.global.js +12 -12
- package/dist/jq79.global.js.map +1 -1
- package/dist/jq79.js +12 -12
- package/dist/jq79.js.map +1 -1
- package/package.json +1 -1
- package/src/jq79.ts +117 -12
package/dist/jq79.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
`,n);return e===-1?t.length:e},D=(t,n)=>{let e=t.indexOf("*/",n+2);return e===-1?t.length:e+2},
|
|
3
|
-
`)return e;if(
|
|
4
|
-
`){let
|
|
5
|
-
`||
|
|
6
|
-
`||
|
|
7
|
-
`||
|
|
8
|
-
); }`)}catch{s=null}
|
|
9
|
-
= $value`;Object.entries(d).forEach(([c,f])=>{let
|
|
10
|
-
`)},
|
|
11
|
-
//# sourceURL=${t}?jq79-script=${n}`:"",
|
|
1
|
+
var pe=Object.defineProperty;var he=(t,n,e)=>n in t?pe(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var N=(t,n,e)=>he(t,typeof n!="symbol"?n+"":n,e);function K(t,n){return typeof t=="string"?document.querySelector(t):t.querySelector(n)}function dt(t,n){return Array.from(typeof t=="string"?document.querySelectorAll(t):t.querySelectorAll(n))}var pt=(t,n={})=>{let e=document.createElement(t);for(let[s,r]of Object.entries(n))if(s==="className")e.className=Array.isArray(r)?r.join(" "):r;else if(s==="textContent")e.textContent=r;else if(s==="children")for(let o of r)e.appendChild(o);else e.setAttribute(s,r);return e},ge=new Set(["a","b","i","em","strong","p","br","ul","ol","li","blockquote","code","pre","span","div","h1","h2","h3","h4","h5","h6","img"]),Ot={a:new Set(["href","title"]),img:new Set(["src","alt"]),"*":new Set(["class"])},me=new Set(["http:","https:","mailto:"]);function ye(t){try{let n=new URL(t,"https://example.com");return me.has(n.protocol)}catch{return!1}}var be={"https:":"443","http:":"80"};function Ee(t){let n=t.trim().toLowerCase().match(/^([a-z\d*][a-z\d.*-]*?)(?::(\d{1,5}|\*))?$/);if(!n)return null;let[,e,s]=n,r=e.split(".");return r.some(i=>i!=="*"&&!/^[a-z\d-]+$/.test(i))?null:{host:new RegExp(`^${r.map(i=>i==="*"?"[^.]+":i).join("\\.")}$`),port:!s||s==="*"?null:s}}var vt=t=>{let n=(Array.isArray(t)?t:t.split(",")).map(Ee).filter(e=>e!==null);return e=>{let s=e.hostname.toLowerCase(),r=e.port||be[e.protocol]||"";return n.some(o=>o.host.test(s)&&(o.port===null||o.port===r))}};function Se(t,n,e,s){try{return!!t(new URL(n,document.baseURI),e,s)}catch{return!1}}var Lt=512;function Pt(t,n,e,s){if(e>Lt)throw new RangeError(`jq79: sanitizeHTML input nests deeper than ${Lt} elements`);for(let r of Array.from(t.childNodes))if(r.nodeType===Node.ELEMENT_NODE){let o=we(r,e,s);o&&n.appendChild(o)}else r.nodeType===Node.TEXT_NODE&&n.appendChild(r.cloneNode())}function we(t,n,e){let s=t.tagName.toLowerCase();if(!ge.has(s))return null;let r=document.createElement(s);for(let o of Array.from(t.attributes)){let i=o.name.toLowerCase(),l=Ot[s]?.has(i),u=Ot["*"]?.has(i);!l&&!u||(i==="href"||i==="src")&&(!ye(o.value)||e&&!Se(e,o.value,s,i))||r.setAttribute(i,o.value)}return s==="a"&&r.setAttribute("rel","noopener noreferrer"),Pt(t,r,n+1,e),r}function Mt(t,n){let e=document.createElement("template");e.innerHTML=t;let s=document.createElement("div");return Pt(e.content,s,0,n?.allowUrl),s.innerHTML}var Re=(t,n)=>n.split(".").reduce((e,s)=>e?.[s],t),qt=t=>{if(Array.isArray(t))return!0;let n=Object.getPrototypeOf(t);return n===Object.prototype||n===null},Wt=(t,n,e)=>{Object.entries(t).forEach(([s,r])=>{let o=n?`${n}.${s}`:s;r&&typeof r=="object"&&qt(r)?Wt(r,o,e):e(o,r)})},$e=(t,n)=>t===n||t.startsWith(`${n}.`)||n.startsWith(`${t}.`),ht=Symbol("jq79.raw"),Y=t=>{let n=t;for(;n!==null&&typeof n=="object"&&n[ht];)n=n[ht];return n},Ut=Symbol("jq79.store"),V=t=>t!==null&&typeof t=="object"&&t[Ut]===!0,z=[],J=t=>{z.push(new Set);try{return t()}finally{z.pop()}},Dt="$__attach",tt=Symbol("jq79.alsoWakenBy"),et=t=>{let n=new Map,e=new Set,s=new Set,r=new WeakMap,o=Object.create(null),i=(h,m,T=!1)=>{n.get(h)?.forEach(S=>S(m,h)),e.forEach(S=>S(h,m)),s.forEach(S=>{(T||Array.from(S.deps).some(c=>$e(c,h)))&&S.run()})},l=h=>h!==null&&typeof h=="object"&&qt(h),u=new Map,p=(h,m)=>{let T=u.get(m);T?.store!==h&&(T?.unsubscribe(),u.set(m,{store:h,unsubscribe:h.$onAny((S,c)=>i(`${m}.${S}`,c))}))},d=h=>{u.get(h)?.unsubscribe(),u.delete(h)},g=(h,m)=>{let T=r.get(h);if(T)return T;let S=null,c=new Proxy(h,{has(f,a){return Reflect.has(f,a)||typeof a=="string"&&S?.has(a)===!0},get(f,a,w){if(a===ht)return f;if(a===Ut)return m==="";if(typeof a!="string")return Reflect.get(f,a,w);if(m===""&&a in o)return o[a];let A=m?`${m}.${a}`:a;z[z.length-1]?.add(A);let j=Reflect.get(f,a,w);if(V(j))return p(j,A),j;let E=Y(j);return l(E)?g(E,A):E},set(f,a,w,A){if(A!==c&&!Object.prototype.hasOwnProperty.call(f,a))return Reflect.set(f,a,w,A);let j=m?`${m}.${a}`:a,E=V(w)?w:Y(w),v=!Object.prototype.hasOwnProperty.call(f,a);if(!v&&Object.is(f[a],E)&&(E===null||typeof E!="object"))return!0;f[a]=E,S?.delete(a),V(E)?p(E,j):d(j);let L=V(E)||!l(E)?E:g(E,j);return i(j,L,v),!0},deleteProperty(f,a){if(typeof a!="string")return Reflect.deleteProperty(f,a);let w=Object.prototype.hasOwnProperty.call(f,a),A=Reflect.deleteProperty(f,a);if(A&&w){let j=m?`${m}.${a}`:a;(S??(S=new Set)).add(a),d(j),i(j,void 0)}return A}});return r.set(h,c),c},b=g(Y(t),"");Object.entries(Y(t)).forEach(([h,m])=>{V(m)&&p(m,h)});let O=(h,m,{immediate:T=!1}={})=>(n.has(h)||n.set(h,new Set),n.get(h).add(m),T&&m(Re(b,h),h),()=>n.get(h)?.delete(m)),x=(h,{immediate:m=!1}={})=>(e.add(h),m&&Wt(b,"",(T,S)=>h(T,S)),()=>e.delete(h)),y=(h,m)=>{let T=!1,S=!1,c={deps:new Set,run:()=>{if(T){S=!0;return}T=!0;try{let f=0;do{S=!1;let a=new Set;z.push(a);try{h()}finally{z.pop(),c.deps=a}}while(S&&++f<100);S&&console.error("jq79: an effect re-woke itself 100 times in a row (it writes what it reads); giving up on it settling")}finally{T=!1}}};return s.add(c),m?.length?R(c,m):(c.run(),()=>{s.delete(c)})},R=(h,m)=>{let T=m.map(S=>S?.[Dt]?.(h)).filter(Boolean);return h.run(),()=>{s.delete(h),T.forEach(S=>S())}},$=h=>(s.add(h),()=>{s.delete(h)}),_=()=>{u.forEach(({unsubscribe:h})=>h()),u.clear()};return o.$on=O,o.$onAny=x,o.$effect=y,o.$dispose=_,o[Dt]=$,b},I=t=>{let n=[],e=[],s=t[tt];return{effect:r=>{n.push(t.$effect(r,s)),e.push(r)},onDispose:r=>{n.push(r)},refresh:()=>{e.forEach(r=>r())},dispose:()=>{n.splice(0).forEach(r=>r()),e.length=0}}};var Ft=/(?:let|var|const)(?:\s+(?=[A-Za-z_$])|\s*(?=[{[]))/y,It=/\$:\s*/y,st=/import(?=\s*\()/y,kt=/\$:\s*([A-Za-z_$][\w$]*)\s*=(?!=)/y,q=(t,n)=>{let e=t[n],s=n+1;for(;s<t.length;){if(t[s]==="\\"){s+=2;continue}if(t[s]===e)return s+1;s++}return t.length},M=(t,n)=>{let e=t.indexOf(`
|
|
2
|
+
`,n);return e===-1?t.length:e},D=(t,n)=>{let e=t.indexOf("*/",n+2);return e===-1?t.length:e+2},nt=(t,n)=>{let e=n;for(;e<t.length;){if(/\s/.test(t[e])){e++;continue}if(t[e]==="/"&&t[e+1]==="/"){e=M(t,e);continue}if(t[e]==="/"&&t[e+1]==="*"){e=D(t,e);continue}break}return e},Te=new Set(["return","typeof","case","in","instanceof","new","delete","void","do","else","yield","await"]),W=(t,n)=>{let e=n-1;for(;e>=0;){let r=t[e];if(/\s/.test(r)){e--;continue}if(r==="/"&&t[e-1]==="*"){let o=t.lastIndexOf("/*",e-2);if(o===-1)return!0;e=o-1;continue}break}if(e<0)return!0;let s=t[e];if(/[\w$]/.test(s)){let r=e;for(;r>0&&/[\w$]/.test(t[r-1]);)r--;return Te.has(t.slice(r,e+1))}return(s==="+"||s==="-")&&t[e-1]===s?!1:!")]}\"'`.".includes(s)},U=(t,n)=>{let e=n+1,s=!1;for(;e<t.length;){let r=t[e];if(r==="\\"){e+=2;continue}if(r===`
|
|
3
|
+
`)return e;if(r==="[")s=!0;else if(r==="]")s=!1;else if(r==="/"&&!s){for(e++;e<t.length&&/[a-z]/i.test(t[e]);)e++;return e}e++}return t.length},xe=/^(\?\.|\?\?|&&|\|\||\*\*|[.,+\-*/%&|^<>=?:([])/,Ce=(t,n)=>{let e=n-1;for(;e>=0;){let s=t[e];if(/\s/.test(s)){e--;continue}if(s==="/"&&t[e-1]==="*"){let r=t.lastIndexOf("/*",e-2);if(r===-1)return"";e=r-1;continue}return s}return""},Bt=(t,n)=>{let e=0,s=n;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(r==="/"&&W(t,s)){s=U(t,s);continue}if("([{".includes(r))e++;else if(")]}".includes(r))e--;else{if(e<=0&&r===";")return s;if(e<=0&&r===`
|
|
4
|
+
`){let o=nt(t,s+1);if(!(o<t.length&&(xe.test(t.slice(o,o+2))||[",","="].includes(Ce(t,s)))))return s;s=o;continue}}s++}return t.length},_e=t=>{let n=[],e=0,s=0,r=0,o=l=>{n.push({raw:t.slice(s,l),codeEnd:Math.max(0,r-s)}),s=l+1,r=s},i=0;for(;i<t.length;){let l=t[i];if(l==="'"||l==='"'||l==="`"){i=q(t,i),r=i;continue}if(l==="/"&&t[i+1]==="/"){i=M(t,i);continue}if(l==="/"&&t[i+1]==="*"){i=D(t,i);continue}if(l==="/"&&W(t,i)){i=U(t,i),r=i;continue}if("([{".includes(l))e++;else if(")]}".includes(l))e--;else if(l===","&&e<=0){o(i),i++;continue}/\s/.test(l)||(r=i+1),i++}return o(t.length),n},gt=t=>{let n=t.trim();if(!n.startsWith("{")&&!n.startsWith("["))return ot.test(n)?[n]:[];let e=[];for(let s of yt(n.slice(1,zt(n)))){s.startsWith("...")&&(s=s.slice(3).trim());let r=bt(s);if(r!==-1&&(s=s.slice(0,r).trim()),n.startsWith("{")){let o=mt(s,":");if(o!==-1){e.push(...gt(s.slice(o+1)));continue}}e.push(...gt(s))}return e},Ae=t=>{let n=[],e=_e(t).map(({raw:o,codeEnd:i})=>{let l=o.match(/^\s*/)[0];if(i<=l.length)return{text:o,empty:!0};let u=o.slice(l.length,i),p=o.slice(i),d=bt(u),g=(d===-1?u:u.slice(0,d)).trim(),b=u[0]==="{"||u[0]==="[";b?n.push(...gt(g)):ot.test(g)&&n.push(g);let O=it(u).code;return{text:`${l}${b?`(${O})`:O}${p}`,empty:!1}}),s=[];for(;e.length&&e[e.length-1].empty;)s.unshift(e.pop().text);let r=e.map(o=>o.text).join(",")+s.join("");return r.trimStart().startsWith("(")&&(r=`;${r}`),{vars:n,code:r}},it=t=>{let n=[],e="",s=0,r=0,o=!0;for(;s<t.length;){let i=t[s],l=t[s+1];if(i==="'"||i==='"'||i==="`"){let u=q(t,s);e+=t.slice(s,u),s=u,o=!1;continue}if(i==="/"&&(l==="/"||l==="*")){let u=l==="/"?M(t,s):D(t,s);e+=t.slice(s,u),s=u;continue}if(i==="/"&&W(t,s)){let u=U(t,s);e+=t.slice(s,u),s=u,o=!1;continue}if(i==="i"&&(s===0||!/[\w$.]/.test(t[s-1]))&&(st.lastIndex=s,st.test(t))){e+="$__import",s+=6,o=!1;continue}if(r===0&&o){Ft.lastIndex=s;let u=Ft.exec(t);if(u){let d=s+u[0].length,g=Bt(t,d),{vars:b,code:O}=Ae(t.slice(d,g));n.push(...b),e+=O,s=g,o=!1;continue}It.lastIndex=s;let p=It.exec(t);if(p){kt.lastIndex=s;let d=kt.exec(t);d&&n.push(d[1]);let g=s+p[0].length,b=Bt(t,g);e+=`$__effect(() => { ${it(t.slice(g,b)).code} });`,s=b;continue}}"([{".includes(i)?r++:")]}".includes(i)&&(r=Math.max(0,r-1)),i===`
|
|
5
|
+
`||i===";"||i==="}"?o=!0:/\s/.test(i)||(o=!1),e+=i,s++}return{vars:n,code:e}},rt=/export\s+default(?![\w$])/y,Ht=/import\s*(?:([\w$\s,{}*]+?)\s*from\s*)?(["'])([^"'\n]+)\2/y,je=t=>{let n=[],e=0,s=0;for(let r=0;r<=t.length;r++){let o=t[r];if(o==="{")e++;else if(o==="}")e--;else if(r===t.length||o===","&&e===0){let i=t.slice(s,r).trim();i&&n.push(i),s=r+1}}return n},Ne=(t,n,e)=>{let s=`await $__import(${JSON.stringify(n)})`;if(t===void 0)return s;let r=je(t),o=[],i=s;if(r.length>1){let l=`$__mod${e}`;o.push(`${l} = ${s}`),i=l}for(let l of r)l.startsWith("{")?o.push(`${l.replace(/\s+as\s+/g,": ")} = ${i}`):l.startsWith("*")?o.push(`${l.replace(/^\*\s*as\s+/,"")} = ${i}`):o.push(`${l} = $__default(${i})`);return`const ${o.join(", ")}`},ot=/^[A-Za-z_$][\w$]*$/,zt=t=>{let n=0,e=0;for(;e<t.length;){let s=t[e];if(s==="'"||s==='"'||s==="`"){e=q(t,e);continue}if(s==="/"&&t[e+1]==="/"){e=M(t,e);continue}if(s==="/"&&t[e+1]==="*"){e=D(t,e);continue}if(s==="/"&&W(t,e)){e=U(t,e);continue}if("([{".includes(s))n++;else if(")]}".includes(s)&&--n===0)return e;e++}return t.length},mt=(t,n)=>{let e=0,s=0;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(r==="/"&&r!==n&&W(t,s)){s=U(t,s);continue}if("([{".includes(r))e++;else if(")]}".includes(r))e--;else if(e===0&&r===n)return s;s++}return-1},yt=t=>{let n=[],e=0,s=0,r=0;for(;r<=t.length;){let o=t[r];if(o==="'"||o==='"'||o==="`"){r=q(t,r);continue}if(o==="/"&&t[r+1]==="/"){r=M(t,r);continue}if(o==="/"&&t[r+1]==="*"){r=D(t,r);continue}if(o==="/"&&W(t,r)){r=U(t,r);continue}if(o!==void 0&&"([{".includes(o))e++;else if(o!==void 0&&")]}".includes(o))e--;else if(r===t.length||o===","&&e===0){let i=t.slice(s,r).trim();i&&n.push(i),s=r+1}r++}return n},bt=t=>{let n=0;for(;n<t.length;){let e=mt(t.slice(n),"=");if(e===-1)return-1;let s=n+e;if(t[s+1]!=="="&&t[s+1]!==">"&&t[s-1]!=="="&&t[s-1]!=="!")return s;n=s+1}return-1},Z=t=>{let n=(t??"").trim();if(!n.startsWith("{"))return null;let e=zt(n);if(e>=n.length)return null;let s=[];for(let r of yt(n.slice(1,e))){if(r.startsWith("..."))continue;let o=bt(r),i=o===-1?r:r.slice(0,o),l=o===-1?void 0:r.slice(o+1).trim(),u=mt(i,":"),p=(u===-1?i:i.slice(0,u)).trim();if(!ot.test(p))continue;let d={name:p};l!==void 0&&(d.default=l);let g=u===-1?"":i.slice(u+1).trim();ot.test(g)&&(d.as=g),s.push(d)}return s},Oe=t=>{let n=0,e=0,s=!0;for(;n<t.length;){let r=t[n];if(r==="'"||r==='"'||r==="`"){n=q(t,n),s=!1;continue}if(r==="/"&&t[n+1]==="/"){n=M(t,n);continue}if(r==="/"&&t[n+1]==="*"){n=D(t,n);continue}if(r==="/"&&W(t,n)){n=U(t,n),s=!1;continue}if(r==="e"&&e===0&&s&&(n===0||!/[\w$.]/.test(t[n-1]))){rt.lastIndex=n;let o=rt.exec(t);if(o)return n+o[0].length}"([{".includes(r)?e++:")]}".includes(r)&&(e=Math.max(0,e-1)),r===`
|
|
6
|
+
`||r===";"||r==="}"?s=!0:/\s/.test(r)||(s=!1),n++}return-1},Le=/^async(?![\w$])/,ve=/^function(?![\w$])\s*\*?\s*[A-Za-z_$][\w$]*|^function(?![\w$])\s*\*?/,Pe=t=>{let n=Oe(t);if(n===-1)return null;let e=nt(t,n),s=t.slice(e);Le.test(s)&&(e=nt(t,e+5));let r=ve.exec(t.slice(e));if(r&&(e=nt(t,e+r[0].length)),t[e]!=="(")return null;let o=0,i=e;for(;i<t.length;){let l=t[i];if(l==="'"||l==='"'||l==="`"){i=q(t,i);continue}if(l==="/"&&t[i+1]==="/"){i=M(t,i);continue}if(l==="/"&&t[i+1]==="*"){i=D(t,i);continue}if(l==="/"&&W(t,i)){i=U(t,i);continue}if("([{".includes(l))o++;else if(")]}".includes(l)&&--o===0)break;i++}return yt(t.slice(e+1,i))[0]??""},lt=t=>{let n=Pe(t);if(n===null)return null;let e=Z(n),s=e?.find(r=>r.name.startsWith("$"))?.name;if(s)throw new Error(`jq79: the factory signature is (props, ctx), so \`${s}\` can't be destructured from the first parameter. Write \`export default (props, { ${s} }) => \u2026\`, or \`_\` in place of props if the component takes none.`);return e},Zt=t=>{let n="",e=0,s=0,r=!0,o=!1,i=0;for(;e<t.length;){let l=t[e],u=t[e+1],p=e===0||!/[\w$.]/.test(t[e-1]);if(l==="'"||l==='"'||l==="`"){let d=q(t,e);n+=t.slice(e,d),e=d,r=!1;continue}if(l==="/"&&(u==="/"||u==="*")){let d=u==="/"?M(t,e):D(t,e);n+=t.slice(e,d),e=d;continue}if(l==="/"&&W(t,e)){let d=U(t,e);n+=t.slice(e,d),e=d,r=!1;continue}if(l==="i"&&p){if(st.lastIndex=e,st.test(t)){n+="$__import",e+=6,r=!1;continue}if(s===0&&r){Ht.lastIndex=e;let d=Ht.exec(t);if(d){n+=Ne(d[1],d[3],i++),e+=d[0].length,r=!1;continue}}}if(l==="e"&&p&&s===0&&r){rt.lastIndex=e;let d=rt.exec(t);if(d){o=!0,n+="$__exports.default =",e+=d[0].length,r=!1;continue}}"([{".includes(l)?s++:")]}".includes(l)&&(s=Math.max(0,s-1)),l===`
|
|
7
|
+
`||l===";"||l==="}"?r=!0:/\s/.test(l)||(r=!1),n+=l,e++}return o?n:null};var Me="0.4.18",ne=t=>Object.fromEntries(Array.from(t.attributes).map(n=>[n.name,n.value])),se=t=>({tag:t.tagName.toLowerCase(),attrs:ne(t),children:Array.from((t instanceof HTMLTemplateElement?t.content:t).childNodes).flatMap(n=>{if(n.nodeType===Node.TEXT_NODE){let e=n.textContent??"";return e?[e]:[]}return n.nodeType===Node.ELEMENT_NODE?[se(n)]:[]})}),Gt=new Map,re=(t,n)=>{let e=`${n.join(",")}|${t}`,s=Gt.get(e);if(s===void 0){try{s=new Function("$scope",...n,`with ($scope) { return (${t}
|
|
8
|
+
); }`)}catch{s=null}Gt.set(e,s)}return s},C=(t,n,e)=>{let s=re(t,e?Object.keys(e):[]);if(s)try{return s(n,...e?Object.values(e):[])}catch{return}},De=(t,n)=>t.replace(/{{\s*([\s\S]+?)\s*}}/g,(e,s)=>C(s,n)??""),qe=new Set([":attrs",":class",":value",":checked",":selected",":if",":elseif",":else",":each",":key",":with",":text",":html",":html.allowed",":props"]),Tt=t=>qe.has(t)||t.startsWith(":class.")||t.startsWith(":props.")||t===":slot"||t.startsWith(":slot."),We=/^\s*\(?\s*(\w+)\s*(?:,\s*(\w+))?\s*\)?\s+in\s+([\s\S]+)$/,Ue=(t,n,e,s)=>{let[r,...o]=n.slice(1).split("."),i=new Set(o);t.addEventListener(r,l=>{if(i.has("self")&&l.target!==t)return;i.has("prevent")&&l.preventDefault(),i.has("stop")&&l.stopPropagation();let u=C(e,s,{$event:l});typeof u=="function"&&u.call(t,l)},{once:i.has("once"),capture:i.has("capture")})},Fe=(t,n,e,s)=>{let[r,...o]=n.slice(1).split("."),i=new Set(o),l=u=>{i.has("prevent")&&u.preventDefault(),i.has("stop")&&u.stopPropagation(),i.has("once")&&t.off(r,l),J(()=>{let p=C(e,s,{$event:u});typeof p=="function"&&p(u)})};t.on(r,l)},k=t=>t.replace(/-(\w)/g,(n,e)=>e.toUpperCase()),St=t=>t.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`),xt=t=>t instanceof DocumentFragment?{first:t.firstChild,last:t.lastChild}:{first:t,last:t},at=({first:t,last:n})=>{for(let e=t;e;){let s=e===n?null:e.nextSibling;e.parentNode?.removeChild(e),e=s}},Ie=({first:t,last:n},e)=>{let s=e.nextSibling;for(let r=t;r;){let o=r===n?null:r.nextSibling;e.parentNode.insertBefore(r,s),r=o}},Kt=(t,n)=>{let e=n.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()===e)return r;return null},Vt=200,Et=0,oe=Symbol("jq79.slots"),ke=t=>t==="slot"||t.startsWith("slot."),ie=t=>t?k(t):"default",Ct=t=>Object.keys(t.attrs).find(n=>n===":slot"||n.startsWith(":slot.")),Be=t=>t==="default"?":slot":`:slot.${t}`,He=t=>typeof t!="string"||t.trim()!=="",ze=t=>{let n={},e=[];t.children.forEach(r=>{let o=typeof r=="object"&&r.tag==="template"?Ct(r):void 0;if(typeof r=="string"||o===void 0){e.push(r);return}let i=ie(o.slice(6));if(i in n){console.warn(`jq79: two <template ${Be(i)}> in <${t.tag}>; the second was ignored`);return}n[i]={nodes:r.children,binder:r.attrs[o]||void 0}});let s=e.some(He);return s&&"default"in n?console.warn(`jq79: <${t.tag}> has both a <template :slot> and content outside it - the <template> is the default slot's content, and the rest was ignored`):s&&(n.default={nodes:e,binder:t.attrs[":slot"]||void 0}),n},Ze=(t,n,e)=>{Z(n)?.forEach(({name:s,as:r,default:o})=>{let i=r??s;Object.defineProperty(t,i,{enumerable:!0,configurable:!0,get:()=>{let l=e[s]?.();return l===void 0&&o!==void 0?C(o,t):l},set:()=>console.warn(`jq79: "${i}" is a slot prop - it comes from the component, so assigning to it does nothing`)})})},Ge=t=>{let n=Ct(t);return console.warn(`jq79: <template ${n}> fills a slot only as a direct child of a component tag; here it rendered nothing`),document.createComment(`misplaced ${n}`)},Ke=(t,n)=>{let e=Object.entries(ze(t));if(!e.length)return null;let s={};return e.forEach(([r,o])=>{s[r]=Ve(o,n)}),s},Ve=(t,n)=>(e,s,r,o)=>{let i=Object.create(n);Ze(i,t.binder,e);let l=i[tt]??[];Object.defineProperty(i,tt,{value:[...l,s]});let u=I(i);return r.onDispose(()=>u.dispose()),G(t.nodes,i,u,o)},Je=(t,n,e,s)=>{let r=ie(t.tag.slice(5)),o=document.createDocumentFragment(),i=document.createComment(t.tag),l=document.createComment(`/${t.tag}`);o.append(i,l);let u=n[oe]?.[r];if(!u)return o.insertBefore(G(t.children,n,e,s),l),o;let p={};return Object.entries(t.attrs).forEach(([d,g])=>{if(!(d===ut||Tt(d)||d.startsWith("@")))if(d.startsWith(":")){let b=g||d.slice(1);p[k(d.slice(1))]=()=>C(b,n)}else p[k(d)]=()=>g}),o.insertBefore(u(p,n,e,s),l),o},Jt=(t,n,e,s,r)=>{let o=document.createComment(t),i=document.createComment(`/${t}`),l=document.createDocumentFragment();l.append(o,i);let u=Ke(n,e),p={},d={},g=[],b=[],O=!1;Object.entries(n.attrs).forEach(([c,f])=>{if(c!==ut){if(c===":props"||c.startsWith(":props.")){O=!0,b.push({expr:f});return}if(!Tt(c))if(c.startsWith("@"))g.push([c,f]);else if(c===":model"||c.startsWith(":model.")){let a=c===":model"?"default":k(c.slice(7));d[a]=f||(c===":model"?"model":a)}else if(c.startsWith(":")){let a=k(c.slice(1));p[a]=f||a,b.push({name:a,expr:f||a})}else{let a=k(c),w=JSON.stringify(f);p[a]=w,b.push({name:a,expr:w})}}});let x=c=>c==="default"?":model":`:model.${c}`,y=c=>c==="default"?"model":c,R=c=>`${c}
|
|
9
|
+
= $value`;Object.entries(d).forEach(([c,f])=>{let a=y(c);p[a]!==void 0&&console.warn(`jq79: <${n.tag}> binds prop "${a}" through both :${a} and ${x(c)} - ${x(c)} wins`),p[a]=f,re(R(f),["$value"])===null&&console.warn(`jq79: ${x(c)}="${f}" is not assignable - updates from <${n.tag}> will be dropped`)});let $=()=>{let c={};return b.forEach(({name:f,expr:a})=>{if(f!==void 0)c[f]=C(a,e);else{let w=C(a,e);w!==null&&typeof w=="object"&&Object.assign(c,w)}}),Object.entries(d).forEach(([f,a])=>{c[y(f)]=C(a,e)}),c},_=null,h=null,m=null,T=new Set,S=c=>{if(c==null){if(!e[fe]?.has(t)||T.has("unfilled"))return;T.add("unfilled"),console.error(`jq79: <${n.tag}> is declared as a prop and the parent passed nothing - nothing renders here. Pass it (:${t}="\u2026"), or drop it from the signature to use the one declared in this file.`);return}T.has("type")||(T.add("type"),console.error(`jq79: <${n.tag}> is ${typeof c}, not a component - nothing renders here`))};return s.effect(()=>{let c=C(t,e),f=c instanceof F?c:null;if(f||S(c),f===h||(m?.dispose(),m=null,_?.destroy(),_=null,h=f,!f))return;let a=new F({template:f.template,scripts:f.scripts,styles:f.styles,modules:f.modules,filename:f.filename,siblings:f.siblings,name:f.name});if(u&&(a.slots=u),Object.keys(d).length){let v=new Set,L=(H,P)=>{v.has(H)||(v.add(H),console.warn(P))};a.on("model:update",(H,P)=>{if(P===null||typeof P!="object"){L("payload",`jq79: model:update expects a { name?, value } payload, got ${P===null?"null":typeof P}`);return}let ft=P.name==null?"default":k(String(P.name)),Nt=d[ft];if(Nt===void 0){L(ft,`jq79: <${n.tag}> has no ${x(ft)} - bound: ${Object.keys(d).map(x).join(", ")}`);return}J(()=>C(R(Nt),e,{$value:P.value}))})}g.forEach(([v,L])=>Fe(a,v,L,e));let w=wn(a.scripts),A=te(J($),w),j=document.createDocumentFragment();if(Et>=Vt){console.error(`jq79: <${n.tag}> is ${Vt} levels deep inside itself; giving up here. A component that renders itself stops when its data stops - is there a cycle in it?`);return}Et++;try{(r?a.renderShadow(A):a.render(A)).mount(j)}finally{Et--}i.parentNode.insertBefore(j,i);let E=I(e);if(O){let v=[];E.effect(()=>{let L=te($(),w),H=Object.keys(L);v.forEach(P=>{P in L||(a.data[P]=void 0)}),H.forEach(P=>{a.data[P]=L[P]}),v=H})}else Object.entries(p).forEach(([v,L])=>{w!==null&&!w.has(v)||E.effect(()=>{a.data[v]=C(L,e)})});m=E,_=a}),s.onDispose(()=>{m?.dispose(),_?.destroy()}),l},Xe=(t,n)=>{let e=()=>{let s=C(t,n);return s!==null&&typeof s=="object"?s:null};return new Proxy(n,{has(s,r){let o=e();return o!==null&&Reflect.has(o,r)||Reflect.has(s,r)},get(s,r){let o=e();return o!==null&&Reflect.has(o,r)?o[r]:Reflect.get(s,r)},set(s,r,o){let i=e();return i!==null&&Reflect.has(i,r)?(i[r]=o,!0):Reflect.set(s,r,o)}})},Q=t=>typeof t=="string"?t.split(/\s+/).filter(Boolean):Array.isArray(t)?t.flatMap(Q):t!==null&&typeof t=="object"?Object.entries(t).flatMap(([n,e])=>e?Q(n):[]):[],Qe=t=>typeof t=="function"?(n,e,s)=>{try{return!!t(n,e,s)}catch{return!1}}:typeof t=="string"||Array.isArray(t)?vt(t):()=>!1,_t=(t,n,e,s)=>{let r=t.attrs[":with"],o=r!==void 0?Xe(r,n):n;if(ke(t.tag))return Je(t,o,e,s);if(t.tag==="template"&&Ct(t)!==void 0)return Ge(t);let i=Kt(o,t.tag);if(i)return Jt(i,t,o,e,s);let l=document.createElement(t.tag);if(l instanceof HTMLUnknownElement||t.tag.includes("-")){let y=!1;e.effect(()=>{if(y)return;let R=Kt(o,t.tag);if(!R)return;y=!0;let $=Jt(R,t,o,e,s),_=xt($);e.onDispose(()=>at(_)),l.replaceWith($)})}Object.entries(t.attrs).forEach(([y,R])=>{y.startsWith("@")?Ue(l,y,R,o):y===":model"||y.startsWith(":model.")?l instanceof HTMLUnknownElement||t.tag.includes("-")||console.warn(`jq79: ${y} on <${t.tag}> does nothing - :model binds component tags only (for now)`):Tt(y)||l.setAttribute(y,R)});let u=t.attrs[":attrs"];if(u!==void 0){let y=[];e.effect(()=>{y.forEach($=>l.removeAttribute($));let R=C(u,o);y=R&&typeof R=="object"?Object.keys(R):[],y.forEach($=>{let _=R[$];_!=null&&_!==!1&&l.setAttribute($,String(_))})})}let p=t.attrs[":class"],d=Object.entries(t.attrs).filter(([y])=>y.startsWith(":class.")).map(([y,R])=>[y.slice(7),R]);if(p!==void 0||d.length){let y=new Set(Q(t.attrs.class??"")),R=[];e.effect(()=>{let $=p!==void 0?Q(C(p,o)):[];d.forEach(([_,h])=>{C(h,o)&&$.push(...Q(_))}),R.forEach(_=>{!$.includes(_)&&!y.has(_)&&l.classList.remove(_)}),l.classList.add(...$),R=$})}let g=t.attrs[":text"],b=t.attrs[":html"],O=t.attrs[":html.allowed"];O!==void 0&&b===void 0&&console.warn("jq79: :html.allowed without :html on the same element does nothing"),g!==void 0?e.effect(()=>{l.textContent=String(C(g,o)??"")}):b!==void 0?e.effect(()=>{let y=O!==void 0?{allowUrl:Qe(C(O,o))}:void 0;l.innerHTML=Mt(String(C(b,o)??""),y)}):l instanceof HTMLTemplateElement?l.content.appendChild(G(t.children,o,e,s)):l.appendChild(G(t.children,o,e,s));let x=t.attrs[":value"];return x!==void 0&&e.effect(()=>{let y=String(C(x,o)??"");l.value!==y&&(l.value=y)}),[":checked",":selected"].forEach(y=>{let R=t.attrs[y];if(R===void 0)return;let $=y.slice(1);e.effect(()=>{l[$]=!!C(R,o)})}),l},Ye=(t,n,e,s)=>{let r=document.createComment("if"),o=document.createDocumentFragment();o.appendChild(r);let i=null,l=null,u=null;return e.effect(()=>{let p=t.find(g=>g.expr===void 0||C(g.expr,n))??null;if(p===l||(u?.dispose(),i&&at(i),i=null,l=p,!p))return;u=I(n);let d=_t(p.node,n,u,s);i=xt(d),r.parentNode.insertBefore(d,r.nextSibling)}),o},X=(t,n,e)=>{Object.defineProperty(t,n,{value:e,writable:!0,enumerable:!0,configurable:!0})},tn=t=>{if(t===null||typeof t!="object"||Array.isArray(t))return!1;let n=Object.getPrototypeOf(t);return n===Object.prototype||n===null},en=(t,n,e,s)=>{let r=t.attrs[":each"].match(We);if(!r)return document.createComment(`invalid :each expression "${t.attrs[":each"]}"`);let[,o,i,l]=r,u=t.attrs[":key"],{[":each"]:p,[":key"]:d,...g}=t.attrs,b={...t,attrs:g},O=document.createComment("each"),x=document.createDocumentFragment();x.appendChild(O),(":if"in t.attrs||":elseif"in t.attrs||":else"in t.attrs)&&console.warn("jq79: :if/:elseif/:else on a :each element is ignored; filter the list expression instead");let y=[],R=!1;return e.effect(()=>{let $=C(l,n),_=Array.isArray($)?$.map((f,a)=>[a,f]):tn($)?Object.entries($):[],h=new Map;y.forEach(f=>{let a=h.get(f.key);a?a.push(f):h.set(f.key,[f])});let m=new Set,T=[],S=_.map(([f,a],w)=>{let A=Object.create(n);X(A,o,a),i&&X(A,i,f),X(A,"$index",w);let j=u!==void 0?C(u,A):f;m.has(j)&&!R&&(R=!0,console.warn(`jq79: duplicate :key in :each "${t.attrs[":each"]}"; duplicates pair up by position`)),m.add(j);let E=h.get(j)?.shift();if(E&&Object.is(E.item,a))return E.scope.$index!==w&&T.push(E),X(E.scope,"$index",w),i&&X(E.scope,i,f),E;E&&(E.fx.dispose(),at(E.range));let v=I(n),L=xt(_t(b,A,v,s));return{key:j,item:a,scope:A,fx:v,range:L}});h.forEach(f=>f.forEach(a=>{a.fx.dispose(),at(a.range)}));let c=O;S.forEach(f=>{c.nextSibling!==f.range.first&&Ie(f.range,c),c=f.range.last}),T.forEach(f=>J(()=>f.fx.refresh())),y=S}),x},G=(t,n,e,s=!1)=>{let r=document.createDocumentFragment(),o=0;for(;o<t.length;){let i=t[o];if(typeof i=="string"){let l=document.createTextNode(i);i.includes("{{")&&e.effect(()=>{l.textContent=De(i,n)}),r.appendChild(l),o++;continue}if(":each"in i.attrs){r.appendChild(en(i,n,e,s)),o++;continue}if(":if"in i.attrs){let l=[{expr:i.attrs[":if"],node:i}];o++;let u=d=>{let g=o;for(;g<t.length&&typeof t[g]=="string"&&!t[g].trim();)g++;let b=t[g];if(typeof b=="object"&&d in b.attrs)return o=g+1,b};for(let d=u(":elseif");d;d=u(":elseif"))l.push({expr:d.attrs[":elseif"],node:d});let p=u(":else");p&&l.push({node:p}),r.appendChild(Ye(l,n,e,s));continue}r.appendChild(_t(i,n,e,s)),o++}return r},qn=(t,n,e=!1)=>G(t.template,n,I(n),e),nn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),sn=/<([A-Za-z][\w.-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)\/>/g,At=/(<script[\s\S]*?<\/script\s*>|<style[\s\S]*?<\/style\s*>)/gi,rn=t=>t.split(At).map((n,e)=>e%2===1?n:n.replace(sn,(s,r,o)=>nn.has(r.toLowerCase())?s:`<${r}${o}></${r}>`)).join(""),le=/<([A-Za-z][\w.-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g,on=/"[^"]*"|'[^']*'|(^|\s)\.\.\.([A-Za-z_$][\w$.]*)/g,ln=t=>t.split(At).map((n,e)=>e%2===1?n:n.replace(le,(s,r,o)=>{let i=0,l=o.replace(on,(u,p,d)=>d===void 0?u:`${p}:props.${i++}="${d}"`);return`<${r}${l}>`})).join(""),an=/"[^"]*"|'[^']*'|(^|\s)(:[\w.$-]+)/g,cn=/<\/slot\.([\w.$-]+)(\s*)>/gi,un=/^slot\./i,fn=t=>un.test(t)?`slot.${St(t.slice(5))}`:t,dn=t=>t.split(At).map((n,e)=>e%2===1?n:n.replace(le,(s,r,o)=>{let i=o.replace(an,(l,u,p)=>p===void 0?l:`${u}${St(p)}`);return`<${fn(r)}${i}>`}).replace(cn,(s,r,o)=>`</slot.${St(r)}${o}>`)).join(""),ut="data-jq79",pn=t=>{let n=2166136261;for(let e=0;e<t.length;e++)n=Math.imul(n^t.charCodeAt(e),16777619);return(n>>>0).toString(36)},ae=(t,n)=>{t.forEach(e=>{typeof e!="string"&&(e.attrs[ut]=n,ae(e.children,n))})},hn=(t,n)=>t.split(",").map(e=>{let s=e.trim(),r=s.indexOf("::"),o=r===-1?s:s.slice(0,r),i=r===-1?"":s.slice(r);return`${o}[${ut}="${n}"]${i}`}).join(", "),ce=(t,n)=>{Array.from(t).forEach(e=>{e instanceof CSSStyleRule?e.selectorText=hn(e.selectorText,n):e instanceof CSSGroupingRule&&ce(e.cssRules,n)})},gn=(t,n)=>{/: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 e=new CSSStyleSheet;return e.replaceSync(t),ce(e.cssRules,n),Array.from(e.cssRules).map(s=>s.cssText).join(`
|
|
10
|
+
`)},mn=/^[A-Z][A-Za-z0-9]*$/,wt=t=>{let n=rn(ln(dn(t))),s=new DOMParser().parseFromString(`<template>${n}</template>`,"text/html").querySelector("template"),r=[],o=[];Array.from(s.content.children).forEach(u=>{u.tagName==="TEMPLATE"?o.push(u):r.push(u)});let i=Xt(r,t),l={};return o.forEach(u=>{let p=u.getAttribute("name");if(p===null){console.warn("jq79: a top-level <template> without a name declares nothing and was ignored");return}if(!mn.test(p)){console.warn(`jq79: <template name="${p}"> was ignored - a component name has to be PascalCase, or no tag could ever reference it (only capitalized names resolve as components)`);return}if(p in l){console.warn(`jq79: two <template name="${p}"> in one file; the second was ignored`);return}l[p]=new F({...Xt(Array.from(u.content.children),u.innerHTML),siblings:l,name:p})}),Object.keys(l).length&&(i.siblings=l),i},Xt=(t,n)=>{let e=[],s=[],r=[];t.forEach(i=>{let l={attrs:ne(i),content:i.textContent??""};i.tagName==="SCRIPT"?e.push(l):i.tagName==="STYLE"?s.push(l):r.push(se(i))}),s.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 o=i=>"scoped"in i.attrs&&!("lang"in i.attrs);if(s.some(o)){let i=pn(n);ae(r,i),s.forEach(l=>{o(l)&&(l.scoped=gn(l.content,i))})}return{template:r,scripts:e,styles:s}},jt=t=>/\.html?([?#]|$)/.test(t)?Rt(t):import(t),ue=(t,n)=>t?`
|
|
11
|
+
//# sourceURL=${t}?jq79-script=${n}`:"",Qt=t=>t.scoped??t.content,ct=new Map,yn=t=>{let n=ct.get(t);if(!n){let e=document.createElement("style");e.textContent=t,document.head.appendChild(e),n={el:e,count:0},ct.set(t,n)}n.count++},bn=t=>{let n=ct.get(t);n&&--n.count<=0&&(n.el.remove(),ct.delete(t))},En=(t,n,e,s={},r=jt,o={})=>{let i={...de,...s},l=new Proxy(n,{has:(p,d)=>d!=="$__effect"&&d!=="$__import"&&(Reflect.has(p,d)||!(d in globalThis)&&!(d in i))});new Function("$scope","$__effect","$__import",...Object.keys(i),`return (async () => { with ($scope) { ${t} } })()${ue(o.filename,o.index??0)}`)(l,e,r,...Object.values(i)).catch(p=>console.error("jq79: error in :setup script",p))},Yt=(t,n)=>{n?.forEach(({name:e,default:s})=>{t[e]===void 0&&(t[e]=s===void 0?void 0:C(s,t))})},Sn=t=>{let n=new Set;return t.forEach(e=>{(lt(e.content)??Z(e.attrs[":setup"]))?.forEach(({name:r})=>n.add(r))}),n},wn=t=>{let n=null;return t.forEach(e=>{let s=lt(e.content)??Z(e.attrs[":setup"]);if(!s)return;let r=n??(n=new Set);s.forEach(({name:o})=>r.add(o))}),n},te=(t,n)=>{if(n===null)return t;let e={};return Object.keys(t).forEach(s=>{n.has(s)&&(e[s]=t[s])}),e},Rn=(t,n)=>{if(!t)return null;let e=Object.create(null),s=!1;return Object.entries(t).forEach(([r,o])=>{n.has(r)||(e[r]=o,s=!0)}),s?e:null},fe=Symbol("jq79.unfilledProps"),$n=t=>t&&t.default!==void 0?t.default:t,Tn=(t,n,e,s={},r=jt,o={})=>{let i={...de,...s},l={},u=new Function("$__exports","$__default","$__import",...Object.keys(i),`return (async () => { "use strict";
|
|
12
12
|
${t}
|
|
13
|
-
;$__exports.done = true })()${
|
|
13
|
+
;$__exports.done = true })()${ue(o.filename,o.index??0)}`)(l,$n,r,...Object.values(i)),p=b=>console.error("jq79: error in factory script",b),d=!1,g=()=>{if(d)return;d=!0;let b=l.default;if(typeof b!="function")return;let O=x=>{x&&typeof x=="object"&&Object.assign(n,x)};try{let x=b(n,{$data:n,$props:n,$effect:e,...s});x instanceof Promise?x.then(O).catch(p):O(x)}catch(x){p(x)}};u.then(g,p),l.done&&g()},xn="__JQ79_HMR_ENABLED__",Cn="__JQ79_HMR__",B=null,_n=t=>{if(!B||!t.filename)return;let n=B.get(t.filename);n||B.set(t.filename,n=new Set),n.add(new WeakRef(t))},ee=t=>{try{return new URL(t,document.baseURI).pathname}catch{return t}},An=(t,n)=>{if(!B)return 0;let e=ee(t),s=wt(n),r=!1,o=l=>l.name===void 0?s:s.siblings?.[l.name]??null,i=0;for(let[l,u]of B)if(ee(l)===e){for(let p of u){let d=p.deref();if(!d){u.delete(p);continue}let g=o(d);if(!g){r=!0;continue}d.hotReplace(g)&&i++}u.size||B.delete(l)}return r?0:i},jn=()=>{B??(B=new Map),globalThis[Cn]={update:An}},Rt=async t=>{let n=await fetch(t);if(!n.ok)throw new Error(`failed to fetch component from ${t}: ${n.status}`);return new F(await n.text(),{filename:t})},F=class{constructor(n,e={}){N(this,"template");N(this,"scripts");N(this,"styles");N(this,"modules");N(this,"filename");N(this,"siblings");N(this,"name");N(this,"slots");N(this,"data",null);N(this,"fx",null);N(this,"content",null);N(this,"startMarker",null);N(this,"endMarker",null);N(this,"styleEls",[]);N(this,"ownsSharedStyles",!1);N(this,"useShadow",!1);N(this,"mountRoot",null);N(this,"resolveMounted",null);N(this,"emitListeners",new Map);let s=typeof n=="string"?wt(n):n;this.template=s.template,this.scripts=s.scripts,this.styles=s.styles,this.modules=e.modules??(typeof n=="string"?void 0:n.modules),this.filename=e.filename??(typeof n=="string"?void 0:n.filename),this.siblings=s.siblings,this.name=s.name,this.adoptSiblings(),_n(this)}adoptSiblings(){this.siblings&&Object.entries(this.siblings).forEach(([n,e])=>{e.filename??(e.filename=this.filename),e.modules??(e.modules=this.modules),this.name||(this[n]=e)})}hotReplace(n){let e=typeof n=="string"?wt(n):n,s=this.startMarker,r=!!(s&&this.content),o=r&&s.isConnected,i=o?s.parentNode:null,l=o?this.endMarker.nextSibling:null,u={...this.data},p=this.useShadow;return r&&this.destroy(),this.template=e.template,this.scripts=e.scripts,this.styles=e.styles,this.siblings=e.siblings,this.adoptSiblings(),!r||(this.renderWith(u,p),!i)?!1:(p&&this.styleEls.forEach(d=>i.insertBefore(d,l)),i.insertBefore(this.content,l),this.mountRoot=i,this.resolveMounted?.(),!0)}static fetch(n){if(Array.isArray(n))throw new TypeError("Component79.fetch takes one URL; use fetchAll for an array");return new $t(Rt(n))}static fetchAll(n){return Promise.all(n.map(Rt))}on(n,e){return this.emitListeners.has(n)||this.emitListeners.set(n,new Set),this.emitListeners.get(n).add(e),this}off(n,e){return this.emitListeners.get(n)?.delete(e),this}render(n={}){return this.renderWith(n,!1)}renderShadow(n={}){return this.renderWith(n,!0)}renderWith(n,e){this.destroy();let s=Sn(this.scripts),r=Rn(this.siblings,s),o=r?Object.assign(Object.create(r),n):{...n},i=new Set([...s].filter(c=>!(c in n)));i.size&&Object.defineProperty(o,fe,{value:i}),this.slots&&Object.defineProperty(o,oe,{value:this.slots});let l=et(o),u=I(l);this.data=l,this.fx=u,this.useShadow=e,this.startMarker=document.createComment("jq79"),this.endMarker=document.createComment("/jq79");let p=this.startMarker,d=(c,f)=>{let a=new CustomEvent(c,{detail:f,bubbles:!0,composed:!0,cancelable:!0});return p===this.startMarker&&this.emitListeners.get(c)?.forEach(w=>w(a,f)),a.cancelBubble||p.dispatchEvent(a),!a.defaultPrevented},g,b=new Promise(c=>{g=c});this.resolveMounted=g;let O=()=>b,x=this.endMarker,y=c=>{let f=[];for(let a=p.nextSibling;a&&a!==x;a=a.nextSibling)a instanceof Element&&(a.matches(c)&&f.push(a),f.push(...Array.from(a.querySelectorAll(c))));return f},R=c=>y(c)[0]??null,$=this.modules,_=c=>$&&c in $?Promise.resolve($[c]):jt(c),h=Object.assign(Object.create(null),{$emit:d,$slots:Object.fromEntries(Object.keys(this.slots??{}).map(c=>[c,!0]))}),m=c=>`await $mounted();${c}`;this.scripts.forEach((c,f)=>{let a={$mounted:O,$self:R,$$self:y,...h,...r},w={filename:this.filename,index:f},A=Zt(c.content);if(A!==null){Yt(l,lt(c.content));let L=":mounted"in c.attrs?m(A):A;Tn(L,l,u.effect,a,_,w);return}let{vars:j,code:E}=it(c.content);Yt(l,Z(c.attrs[":setup"])),j.forEach(L=>{L in l||(l[L]=void 0)});let v=":mounted"in c.attrs?m(E):E;En(v,l,u.effect,a,_,w)});let T=document.createDocumentFragment(),S=new Proxy(l,{has:(c,f)=>typeof f=="string"&&f in h||Reflect.has(c,f),get:(c,f,a)=>typeof f=="string"&&f in h&&!Reflect.has(c,f)?h[f]:Reflect.get(c,f,a)});return T.append(this.startMarker,G(this.template,S,u,e),this.endMarker),this.content=T,e?this.styleEls=this.styles.map(c=>{let f=document.createElement("style");return f.textContent=c.content,f}):(this.styles.forEach(c=>yn(Qt(c))),this.ownsSharedStyles=!0),this}mount(n,e){let s=typeof n=="string"?K(n):n;if(!s)throw new Error(`mount target not found: ${n}`);return(!this.content||e!==void 0)&&this.renderWith(e??{},this.useShadow),this.attach(s)}mountShadow(n,e){let s=typeof n=="string"?K(n):n;if(!s)throw new Error(`mount target not found: ${n}`);return(!this.content||e!==void 0||!this.useShadow)&&this.renderWith(e??{},!0),this.attach(s)}attach(n){this.mountRoot&&this.detach();let e=this.useShadow&&n instanceof Element?n.shadowRoot??n.attachShadow({mode:"open"}):n;return this.useShadow&&this.styleEls.forEach(s=>e.appendChild(s)),e.appendChild(this.content),this.mountRoot=e,this.resolveMounted?.(),this}detach(){if(!this.mountRoot||!this.content||!this.startMarker||!this.endMarker)return this;let n=this.startMarker;for(;n;){let e=n.nextSibling;if(this.content.appendChild(n),n===this.endMarker)break;n=e}return this.mountRoot=null,this}destroy(){return this.detach(),this.fx?.dispose(),this.fx=null,this.data?.$dispose(),this.styleEls.forEach(n=>n.parentNode?.removeChild(n)),this.styleEls=[],this.ownsSharedStyles&&(this.styles.forEach(n=>bn(Qt(n))),this.ownsSharedStyles=!1),this.content=null,this.startMarker=null,this.endMarker=null,this.data=null,this.resolveMounted=null,this}};N(F,"version",Me);var $t=class{constructor(n){N(this,"chain");this.chain=n}queue(n){return this.chain=this.chain.then(e=>(n(e),e)),this}then(n,e){return this.chain.then(n,e)}catch(n){return this.chain.catch(n)}finally(n){return this.chain.finally(n)}mount(n,e){return this.queue(s=>s.mount(n,e))}mountShadow(n,e){return this.queue(s=>s.mountShadow(n,e))}render(n={}){return this.queue(e=>e.render(n))}renderShadow(n={}){return this.queue(e=>e.renderShadow(n))}on(n,e){return this.queue(s=>s.on(n,e))}off(n,e){return this.queue(s=>s.off(n,e))}detach(){return this.queue(n=>n.detach())}destroy(){return this.queue(n=>n.destroy())}};var Wn=t=>new F(t),de={$:K,$$:dt,$create:pt,$reactive:et,Component79:F};typeof globalThis<"u"&&globalThis[xn]&&jn();export{K as $,dt as $$,pt as $create,et as $reactive,F as C79,F as Component79,$t as PendingComponent79,jn as enableHotReload,An as hotUpdate,Wn as parseComponent,qn as renderComponent};
|
|
14
14
|
//# sourceMappingURL=jq79.js.map
|