@stacksjs/stx-vscode 0.2.888 → 0.2.890

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stacksjs/stx-typescript-plugin",
3
- "version": "0.2.888",
3
+ "version": "0.2.890",
4
4
  "private": true,
5
5
  "main": "index.js"
6
6
  }
@@ -1,16 +1,16 @@
1
- var ln=Object.create;var{getPrototypeOf:un,defineProperty:et,getOwnPropertyNames:pn}=Object;var tt=Object.prototype.hasOwnProperty;function dn(e){return this[e]}var fn,mn,Q=(e,n,s)=>{var t=e!=null&&typeof e==="object";if(t){var i=n?fn??=new WeakMap:mn??=new WeakMap,r=i.get(e);if(r)return r}s=e!=null?ln(un(e)):{};let a=n||!e||!e.__esModule||!tt.call(e,"default")?et(s,"default",{value:e,enumerable:!0}):s;if(e&&typeof e==="object"||typeof e==="function"){for(let c of pn(e))if(!tt.call(a,c))et(a,c,{get:dn.bind(e,c),enumerable:!0})}if(t)i.set(e,a);return a};var tn=require("node:crypto"),X=require("node:fs"),nn=require("node:os"),K=Q(require("node:path"));var je=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b/y,gn=new Map(["textarea","title","xmp","iframe","noembed","noframes"].map((e)=>[e,new RegExp(`</${e}\\s*>`,"ig")]));function hn(e){let n=[],s=0;while(s<e.length){let t=e.indexOf("<",s);if(t===-1)break;if(e.startsWith("<!--",t)){let b=e.indexOf("-->",t+4);if(b===-1)break;s=b+3;continue}je.lastIndex=t;let i=je.exec(e);if(!i){s=t+1;continue}let r=je.lastIndex,a=r,c=null;for(;a<e.length;a++){let b=e[a];if(c){if(b===c)c=null}else if(b==='"'||b==="'")c=b;else if(b===">")break}if(a===e.length)break;let o=i[1]==="/",l=e[a-1]==="/";n.push({start:t,end:a+1,name:i[2],attributes:e.slice(r,l?a-1:a),closing:o,selfClosing:l}),s=a+1;let d=i[2].toLowerCase();if(!o&&d==="plaintext")break;let x=gn.get(d);if(!o&&(d==="script"||d==="style"||x)){let b=x??(d==="script"?xn:bn);b.lastIndex=s;let _=b.exec(e);if(!_)break;s=_.index}}return n}var xn=/<\/script\s*>/ig;var bn=/<\/style\s*>/ig;function ue(e){let n=hn(e),s=[];for(let t=0;t<n.length;t++){let i=n[t],r=n[t+1];if(i.name.toLowerCase()!=="script"||i.closing||r?.name.toLowerCase()!=="script"||!r.closing)continue;s.push({start:i.start,end:r.end,bodyStart:i.end,bodyEnd:r.start,attrs:i.attributes})}return s}function pe(e){let n=new Map;for(let s of e.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))n.set(s[1].toLowerCase(),s[2]??s[3]??s[4]??!0);return n}function ye(e){let n=e.get("type");return typeof n!=="string"||!n.trim()||/^(?:module|(?:text|application)\/(?:javascript|typescript|ecmascript))$/i.test(n.trim())}var Ne=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useIntervalFn","useObjectUrl"];var Qe=Q(require("node:path"),1);function yn(e,n){let s=e[n],t=n+1;while(t<e.length){if(e[t]==="\\"){t+=2;continue}if(e[t]===s)return t+1;t++}return e.length}function Sn(e,n){let s=n+1;while(s<e.length){if(e[s]==="\\"){s+=2;continue}if(e[s]==="`")return s+1;if(e[s]==="$"&&e[s+1]==="{"){if(s=nt(e,s+2),s<e.length)s++;continue}s++}return e.length}function nt(e,n){let s=1,t=n,i="{",r="";while(t<e.length){let a=e[t];if(a==="\\"){t+=2;continue}if(a==='"'||a==="'"){t=yn(e,t),i=ie,r="";continue}if(a==="`"){t=Sn(e,t),i=ie,r="";continue}if(a==="/"&&e[t+1]==="/"){while(t<e.length&&e[t]!==`
2
- `)t++;continue}if(a==="/"&&e[t+1]==="*"){t+=2;while(t<e.length&&e.slice(t,t+2)!=="*/")t++;t+=2;continue}if(a==="/"&&st(i,r)){let c=it(e,t);if(c!==-1){t=c,i=ie,r="";continue}}if(a==="{")s++;else if(a==="}"){if(s--,s===0)return t}if(/[\w$]/.test(a))r=/[\w$]/.test(i)?r+a:a,i=a;else if(!/\s/.test(a))i=a,r="";t++}return e.length}var vn=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function st(e,n){if(n)return vn.has(n);return!(e===")"||e==="]"||e===ie)}var ie="\x00";function it(e,n){let s=n+1,t=!1;while(s<e.length){let i=e[s];if(i===`
3
- `)return-1;if(i==="\\"){s+=2;continue}if(i==="[")t=!0;else if(i==="]")t=!1;else if(i==="/"&&!t){s++;while(s<e.length&&/[a-z]/i.test(e[s]))s++;return s}s++}return-1}function L(e){return Le(e,!1)}function rt(e){return Le(e,!0)}function Le(e,n){let s="",t=0,i="",r="";while(t<e.length){let a=e.slice(t,t+2);if(a==="//"){while(t<e.length&&e[t]!==`
4
- `)s+=" ",t++;continue}if(a==="/*"){while(t<e.length&&e.slice(t,t+2)!=="*/")s+=e[t]===`
1
+ var gn=Object.create;var{getPrototypeOf:hn,defineProperty:nt,getOwnPropertyNames:xn}=Object;var rt=Object.prototype.hasOwnProperty;function bn(e){return this[e]}var yn,Sn,Q=(e,n,r)=>{var t=e!=null&&typeof e==="object";if(t){var s=n?yn??=new WeakMap:Sn??=new WeakMap,i=s.get(e);if(i)return i}r=e!=null?gn(hn(e)):{};let o=n||!e||!e.__esModule||!rt.call(e,"default")?nt(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let a of xn(e))if(!rt.call(o,a))nt(o,a,{get:bn.bind(e,a),enumerable:!0})}if(t)s.set(e,o);return o};var cn=require("node:crypto"),Z=require("node:fs"),ln=require("node:os"),H=Q(require("node:path"));var Be=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b/y,vn=new Map(["textarea","title","xmp","iframe","noembed","noframes"].map((e)=>[e,new RegExp(`</${e}\\s*>`,"ig")]));function En(e){let n=[],r=0;while(r<e.length){let t=e.indexOf("<",r);if(t===-1)break;if(e.startsWith("<!--",t)){let b=e.indexOf("-->",t+4);if(b===-1)break;r=b+3;continue}Be.lastIndex=t;let s=Be.exec(e);if(!s){r=t+1;continue}let i=Be.lastIndex,o=i,a=null;for(;o<e.length;o++){let b=e[o];if(a){if(b===a)a=null}else if(b==='"'||b==="'")a=b;else if(b===">")break}if(o===e.length)break;let c=s[1]==="/",l=e[o-1]==="/";n.push({start:t,end:o+1,name:s[2],attributes:e.slice(i,l?o-1:o),closing:c,selfClosing:l}),r=o+1;let p=s[2].toLowerCase();if(!c&&p==="plaintext")break;let x=vn.get(p);if(!c&&(p==="script"||p==="style"||x)){let b=x??(p==="script"?wn:$n);b.lastIndex=r;let _=b.exec(e);if(!_)break;r=_.index}}return n}var wn=/<\/script\s*>/ig;var $n=/<\/style\s*>/ig;function ue(e){let n=En(e),r=[];for(let t=0;t<n.length;t++){let s=n[t],i=n[t+1];if(s.name.toLowerCase()!=="script"||s.closing||i?.name.toLowerCase()!=="script"||!i.closing)continue;r.push({start:s.start,end:i.end,bodyStart:s.end,bodyEnd:i.start,attrs:s.attributes})}return r}function pe(e){let n=new Map;for(let r of e.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))n.set(r[1].toLowerCase(),r[2]??r[3]??r[4]??!0);return n}function ye(e){let n=e.get("type");return typeof n!=="string"||!n.trim()||/^(?:module|(?:text|application)\/(?:javascript|typescript|ecmascript))$/i.test(n.trim())}var ze=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useIntervalFn","useObjectUrl"];var tt=Q(require("node:path"),1);function _n(e,n){let r=e[n],t=n+1;while(t<e.length){if(e[t]==="\\"){t+=2;continue}if(e[t]===r)return t+1;t++}return e.length}function kn(e,n){let r=n+1;while(r<e.length){if(e[r]==="\\"){r+=2;continue}if(e[r]==="`")return r+1;if(e[r]==="$"&&e[r+1]==="{"){if(r=st(e,r+2),r<e.length)r++;continue}r++}return e.length}function st(e,n){let r=1,t=n,s="{",i="";while(t<e.length){let o=e[t];if(o==="\\"){t+=2;continue}if(o==='"'||o==="'"){t=_n(e,t),s=se,i="";continue}if(o==="`"){t=kn(e,t),s=se,i="";continue}if(o==="/"&&e[t+1]==="/"){while(t<e.length&&e[t]!==`
2
+ `)t++;continue}if(o==="/"&&e[t+1]==="*"){t+=2;while(t<e.length&&e.slice(t,t+2)!=="*/")t++;t+=2;continue}if(o==="/"&&it(s,i)){let a=ot(e,t);if(a!==-1){t=a,s=se,i="";continue}}if(o==="{")r++;else if(o==="}"){if(r--,r===0)return t}if(/[\w$]/.test(o))i=/[\w$]/.test(s)?i+o:o,s=o;else if(!/\s/.test(o))s=o,i="";t++}return e.length}var Cn=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function it(e,n){if(n)return Cn.has(n);return!(e===")"||e==="]"||e===se)}var se="\x00";function ot(e,n){let r=n+1,t=!1;while(r<e.length){let s=e[r];if(s===`
3
+ `)return-1;if(s==="\\"){r+=2;continue}if(s==="[")t=!0;else if(s==="]")t=!1;else if(s==="/"&&!t){r++;while(r<e.length&&/[a-z]/i.test(e[r]))r++;return r}r++}return-1}function j(e){return Ve(e,!1)}function at(e){return Ve(e,!0)}function Ve(e,n){let r="",t=0,s="",i="";while(t<e.length){let o=e.slice(t,t+2);if(o==="//"){while(t<e.length&&e[t]!==`
4
+ `)r+=" ",t++;continue}if(o==="/*"){while(t<e.length&&e.slice(t,t+2)!=="*/")r+=e[t]===`
5
5
  `?`
6
- `:" ",t++;s+=" ",t+=2;continue}let c=e[t];if(c==='"'||c==="'"){let o=c;s+=" ",t++;while(t<e.length&&e[t]!==o){if(e[t]==="\\"){s+=" ",t+=2;continue}s+=e[t]===`
6
+ `:" ",t++;r+=" ",t+=2;continue}let a=e[t];if(a==='"'||a==="'"){let c=a;r+=" ",t++;while(t<e.length&&e[t]!==c){if(e[t]==="\\"){r+=" ",t+=2;continue}r+=e[t]===`
7
7
  `?`
8
- `:" ",t++}s+=n?"$":" ",t++,i=ie,r="";continue}if(c==="/"&&st(i,r)){let o=it(e,t);if(o!==-1){s+=`/${" ".repeat(o-t-2)}/`,t=o,i=ie,r="";continue}}if(c==="`"){s+=n?"(":" ",t++;while(t<e.length&&e[t]!=="`"){if(e[t]==="\\"){s+=" ",t+=2;continue}if(e[t]==="$"&&e[t+1]==="{"){let o=t+2,l=nt(e,o);if(s+=n?" {":" ",s+=Le(e.slice(o,l),n),l<e.length)s+=n?"}":" ";t=l+1;continue}s+=e[t]===`
8
+ `:" ",t++}r+=n?"$":" ",t++,s=se,i="";continue}if(a==="/"&&it(s,i)){let c=ot(e,t);if(c!==-1){r+=`/${" ".repeat(c-t-2)}/`,t=c,s=se,i="";continue}}if(a==="`"){r+=n?"(":" ",t++;while(t<e.length&&e[t]!=="`"){if(e[t]==="\\"){r+=" ",t+=2;continue}if(e[t]==="$"&&e[t+1]==="{"){let c=t+2,l=st(e,c);if(r+=n?" {":" ",r+=Ve(e.slice(c,l),n),l<e.length)r+=n?"}":" ";t=l+1;continue}r+=e[t]===`
9
9
  `?`
10
- `:" ",t++}s+=n?")":" ",t++,i=ie,r="";continue}if(s+=c,t++,/[\w$]/.test(c))r=/[\w$]/.test(i)?r+c:c,i=c;else if(!/\s/.test(c))i=c,r=""}return s}function q(e){let n=new Uint16Array(e.length),s=0,t=!0;for(let i=0;i<e.length;i++){let r=e[i];if(r===")"||r==="]"||r==="}")if(s===0)t=!1;else s--;if(n[i]=s,r==="("||r==="["||r==="{")s++}return{depths:n,balanced:t&&s===0}}class ze{cache=new Map;maxSize;options;sizes;bytes=0;constructor(e=100,n){this.maxSize=e,this.options=n??null,this.sizes=n?new Map:null}get byteSize(){return this.bytes}setMaxBytes(e){if(!this.options)return;this.options={...this.options,maxBytes:e};while(this.bytes>e&&this.cache.size>0){let n=this.cache.keys().next().value;if(n===void 0)break;this.delete(n)}}get(e){if(!this.cache.has(e))return;let n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}set(e,n){if(this.cache.has(e))this.delete(e);let s=this.options?this.options.sizeOf(n):0;if(this.options&&s>this.options.maxBytes)return;while(this.cache.size>0&&(this.cache.size>=this.maxSize||this.options!==null&&this.bytes+s>this.options.maxBytes)){let t=this.cache.keys().next().value;if(t===void 0)break;this.delete(t)}if(this.cache.set(e,n),this.sizes)this.sizes.set(e,s),this.bytes+=s}has(e){return this.cache.has(e)}delete(e){if(this.sizes){let n=this.sizes.get(e);if(n!==void 0)this.bytes-=n,this.sizes.delete(e)}return this.cache.delete(e)}clear(){this.cache.clear(),this.sizes?.clear(),this.bytes=0}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}class ot{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator(e){let n=Array.from(new Set(e)),s=n.sort().join(","),t=this.pool.find((c)=>c.context.join(",")===s);if(t)return t.func;let i=this.fnCache,r=this.fnCacheMaxSize,a=(...c)=>(o)=>{try{let l=`${s}:${o}`,d=i.get(l);if(!d){if(i.size>=r){let x=i.keys().next().value;if(x)i.delete(x)}d=Function(...n,`
10
+ `:" ",t++}r+=n?")":" ",t++,s=se,i="";continue}if(r+=a,t++,/[\w$]/.test(a))i=/[\w$]/.test(s)?i+a:a,s=a;else if(!/\s/.test(a))s=a,i=""}return r}function U(e){let n=new Uint16Array(e.length),r=0,t=!0;for(let s=0;s<e.length;s++){let i=e[s];if(i===")"||i==="]"||i==="}")if(r===0)t=!1;else r--;if(n[s]=r,i==="("||i==="["||i==="{")r++}return{depths:n,balanced:t&&r===0}}class Se{cache=new Map;maxSize;options;sizes;bytes=0;constructor(e=100,n){this.maxSize=e,this.options=n??null,this.sizes=n?new Map:null}get byteSize(){return this.bytes}setMaxBytes(e){if(!this.options)return;this.options={...this.options,maxBytes:e};while(this.bytes>e&&this.cache.size>0){let n=this.cache.keys().next().value;if(n===void 0)break;this.delete(n)}}get(e){if(!this.cache.has(e))return;let n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}set(e,n){if(this.cache.has(e))this.delete(e);let r=this.options?this.options.sizeOf(n):0;if(this.options&&r>this.options.maxBytes)return;while(this.cache.size>0&&(this.cache.size>=this.maxSize||this.options!==null&&this.bytes+r>this.options.maxBytes)){let t=this.cache.keys().next().value;if(t===void 0)break;this.delete(t)}if(this.cache.set(e,n),this.sizes)this.sizes.set(e,r),this.bytes+=r}has(e){return this.cache.has(e)}delete(e){if(this.sizes){let n=this.sizes.get(e);if(n!==void 0)this.bytes-=n,this.sizes.delete(e)}return this.cache.delete(e)}clear(){this.cache.clear(),this.sizes?.clear(),this.bytes=0}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}class ct{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator(e){let n=Array.from(new Set(e)),r=n.sort().join(","),t=this.pool.find((a)=>a.context.join(",")===r);if(t)return t.func;let s=this.fnCache,i=this.fnCacheMaxSize,o=(...a)=>(c)=>{try{let l=`${r}:${c}`,p=s.get(l);if(!p){if(s.size>=i){let x=s.keys().next().value;if(x)s.delete(x)}p=Function(...n,`
11
11
  'use strict';
12
12
  try {
13
- return ${o};
13
+ return ${c};
14
14
  }
15
15
  catch (e) {
16
16
  if (e instanceof ReferenceError || e instanceof TypeError) {
@@ -18,7 +18,7 @@ catch (e) {
18
18
  }
19
19
  throw e;
20
20
  }
21
- `),i.set(l,d)}return d(...c)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:a,context:n.slice()});return a}clear(){this.pool.length=0,this.fnCache.clear()}}var As=new ot;class at{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(e){this.enabled=e}isEnabled(){return this.enabled}setBudget(e,n){this.budgets.set(e,{warnThreshold:0.8,action:"warn",...n})}setBudgets(e){for(let[n,s]of Object.entries(e))this.setBudget(n,s)}removeBudget(e){this.budgets.delete(e)}getBudgets(){let e={};for(let[n,s]of this.budgets.entries())e[n]=s;return e}onViolation(e){this.violationHandlers.push(e)}offViolation(e){let n=this.violationHandlers.indexOf(e);if(n!==-1)this.violationHandlers.splice(n,1)}time(e,n){if(!this.enabled)return n();let s=performance.now(),t=n(),i=performance.now()-s;return this.recordTime(e,i),this.checkBudget(e,i),t}async timeAsync(e,n){if(!this.enabled)return n();let s=performance.now(),t=await n(),i=performance.now()-s;return this.recordTime(e,i),this.checkBudget(e,i),t}checkBudget(e,n){let s=this.budgets.get(e);if(!s)return;let t=n/s.maxTime*100,i=s.warnThreshold!==void 0?n>=s.maxTime*s.warnThreshold&&n<s.maxTime:!1,r=n>=s.maxTime;if(!i&&!r)return;let a={label:e,actualTime:n,budgetTime:s.maxTime,exceedancePercent:t,timestamp:new Date,isWarning:i};this.violations.push(a);while(this.violations.length>this.maxViolations)this.violations.shift();for(let o of this.violationHandlers)try{o(a)}catch{}let c=i?`[Performance Warning] "${e}" took ${n.toFixed(2)}ms (${t.toFixed(1)}% of ${s.maxTime}ms budget)`:`[Performance Budget Exceeded] "${e}" took ${n.toFixed(2)}ms (exceeded ${s.maxTime}ms budget by ${(t-100).toFixed(1)}%)`;switch(s.action){case"log":console.log(c);break;case"warn":console.warn(c);break;case"error":console.error(c);break;case"throw":if(r)throw Error(c);else console.warn(c);break}}recordTime(e,n){let s=this.metrics.get(e);if(s)s.count++,s.totalTime+=n,s.maxTime=Math.max(s.maxTime,n),s.minTime=Math.min(s.minTime,n);else this.metrics.set(e,{count:1,totalTime:n,maxTime:n,minTime:n})}getStats(e){if(e){let s=this.metrics.get(e);if(!s)return{};let t=this.budgets.get(e);return{count:s.count,avgTime:s.totalTime/s.count,totalTime:s.totalTime,maxTime:s.maxTime,minTime:s.minTime,budget:t?.maxTime,budgetUtilization:t?s.totalTime/s.count/t.maxTime*100:void 0}}let n={};for(let[s,t]of this.metrics.entries()){let i=this.budgets.get(s);n[s]={count:t.count,avgTime:t.totalTime/t.count,totalTime:t.totalTime,maxTime:t.maxTime,minTime:t.minTime,budget:i?.maxTime,budgetUtilization:i?t.totalTime/t.count/i.maxTime*100:void 0}}return n}getViolations(e){if(e)return this.violations.filter((n)=>n.label===e);return[...this.violations]}getViolationStats(){let e={},n=0,s=0;for(let t of this.violations)if(e[t.label]=(e[t.label]||0)+1,t.isWarning)n++;else s++;return{total:this.violations.length,byLabel:e,warnings:n,errors:s}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var Be=null;function wn(){if(!Be)Be=new at;return Be}var Rs=new Proxy({},{get(e,n){return wn()[n]}});var ct=new ze(32,{maxBytes:2097152,sizeOf:(e)=>e.code.length*4}),re=/^[A-Za-z_$][\w$]*$/,$n=new Set(["if","for","while","switch","with"]),lt=["(","[","{"],ut=[")","]","}"],Tn=new Set(["const","let","var","return","if","for","while","do","switch","try","throw","export"]);function _n(e){let n=L(e),s=[];for(let t of n.matchAll(/[A-Za-z_$][\w$]*|=>|\.\.\.|[^\s]/g)){let i=t.index??0;s.push({text:t[0],start:i,end:i+t[0].length})}return{code:n,tokens:s}}function En(e){let n=ct.get(e);if(n)return n;let{code:s,tokens:t}=_n(e),i=new Map,r=[];for(let p=0;p<t.length;p++){let f=t[p].text;if(["(","[","{"].includes(f))r.push(p);else if([")","]","}"].includes(f)){let T=r.at(-1);if(T!==void 0&&["()","[]","{}"].includes(t[T].text+f))r.pop(),i.set(T,p),i.set(p,T)}}function a(p,f){let T=[],h=p;for(let u=p;u<f;u++){if(["(","[","{"].includes(t[u].text)&&(i.get(u)??f)<f){u=i.get(u);continue}if(t[u].text===",")T.push([h,u]),h=u+1}return T.push([h,f]),T}let c=[];function o(p,f,T,h=!1,u){if(t[p]?.text==="...")p++;if(p>=f)return;let m=t[p].text;if(re.test(m)){if(T.add(m),T===x)c.push({name:m,token:p,functionScoped:h,declarationToken:u});return}if(m!=="{"&&m!=="[")return;let w=i.get(p);if(w===void 0||w>=f)return;for(let[R,v]of a(p+1,w)){let P=R;if(m==="{")for(let O=R;O<v;O++){if(t[O].text===":"){P=O+1;break}if(t[O].text==="=")break;if(["(","[","{"].includes(t[O].text)&&i.has(O))O=i.get(O)}o(P,v,T,h,u)}}function l(p,f){let T=new Set;for(let[h,u]of a(p,f))o(h,u,T);return T}function d(p){let f=p;for(;f<t.length;f++){let T=t[f].text;if(["(","[","{"].includes(T)&&i.has(f)){f=i.get(f);continue}if([",",";",")","]","}"].includes(T))break}return t[Math.max(p,f-1)]?.end??s.length}let x=new Set,b=[];for(let p=0;p<t.length;p++)if(t[p].text==="=>"){let f=p-1,T=f,h;if(t[f]?.text===")"&&i.has(f))T=i.get(f),h=l(T+1,f);else if(t[f]&&re.test(t[f].text))h=new Set([t[f].text]);else continue;let u=p+1,m=t[u]?.text==="{"&&i.has(u)?t[i.get(u)].end:d(u);b.push({start:t[T].start,end:m,bodyStart:t[u]?.start??m,functionBody:!0,names:h})}else if(t[p].text==="("&&i.has(p)){let f=t[p-1]?.text;if(!f||$n.has(f)||!re.test(f)&&f!=="*"&&f!=="]")continue;let T=i.get(p),h=T+1;if(t[h]?.text===":"){h++;while(h<t.length&&!["{","=>",";","="].includes(t[h].text))h++}if(t[h]?.text!=="{"||!i.has(h))continue;b.push({start:t[p].start,end:t[i.get(h)].end,bodyStart:t[h].start,functionBody:f!=="catch",names:l(p+1,T)})}function _(p){let f=p;for(;f<t.length;f++){let T=t[f].text;if(lt.includes(T)&&i.has(f)){f=i.get(f);continue}if(T===";"||ut.includes(T))break;let h=t[f-1];if(f>p&&Tn.has(T)&&h.text!==".")break;if(f>p&&/[\n\r]/.test(s.slice(h.end,t[f].start))&&(/^[\w$]+$/.test(h.text)||ut.includes(h.text)||['"',"'","`"].includes(h.text))&&re.test(T)&&!["in","of","instanceof"].includes(T))break}return f}let A=[];for(let p=0;p<t.length;p++){if(t[p].text!=="for")continue;let f=t[p+1]?.text==="await"?p+2:p+1;if(t[f]?.text!=="("||!i.has(f))continue;let T=i.get(f),h=T+1,u=t[h]?.text==="{"&&i.has(h)?i.get(h):_(h),m=t[u]?.text===";"||t[u]?.text==="}"?t[u].end:t[Math.max(h,u-1)]?.end??s.length;A.push({headStart:f,headEnd:T,start:t[f].start,end:m})}for(let p=0;p<t.length;p++){let f=t[p].text,T=t[p-1]?.text;if(T==="."||t[p+1]?.text===":")continue;if(T==="as"||T==="<")continue;if(f==="const"||f==="let"||f==="var"){let h=_(p+1),u=p+1,m=!1,w=!1,R=0;for(let v=p+1;v<=h;v++){let P=t[v]?.text;if(v<h&&lt.includes(P)&&i.has(v)&&i.get(v)<h){v=i.get(v);continue}if(v<h&&P===":"&&!w)m=!0;else if(v<h&&P==="="&&R===0)m=!1,w=!0;else if(v<h&&m&&P==="<")R++;else if(v<h&&m&&P===">"&&R>0)R--;else if(v===h||P===","&&R===0)o(u,v,x,f==="var",p),u=v+1,m=!1,w=!1}}else if(f==="function"||f==="class"){let h=p+1;if(t[h]?.text==="*")h++;if(t[h]&&re.test(t[h].text)&&t[h].text!=="extends")x.add(t[h].text),c.push({name:t[h].text,token:h,declarationToken:p})}else if(f==="import"){let h=p+1;if(t[h]?.text==="*"&&t[h+1]?.text==="as")h+=2;let u=t[h]?.text;if(u&&re.test(u)&&u!=="type"&&t[h+1]?.text!=="("&&t[h+1]?.text!==".")x.add(u),c.push({name:u,token:h,file:!0});let m=t[h]?.text==="{"?h:t[h+1]?.text===","&&t[h+2]?.text==="{"?h+2:-1;if(m!==-1&&i.has(m)){let w=i.get(m);for(let[R,v]of a(m+1,w)){let P=v-1;while(P>=R&&!re.test(t[P].text))P--;if(P>=R&&t[P].text!=="type")c.push({name:t[P].text,token:P,file:!0})}}}}let C={code:s,scopes:b,loops:A,declarations:x,sites:c,tokens:t,pairs:i};return ct.set(e,C),C}function Ve(e){let n=En(e),s=rt(e),{depths:t}=q(s),i=[];for(let r of n.sites){if(r.file||r.declarationToken===void 0)continue;let a=n.tokens[r.declarationToken];if(t[a.start]!==0)continue;let c=s.slice(0,a.start),o=[...c.matchAll(/[A-Za-z_$][\w$]*|\d+(?:[.]\d+)?|[^\s]/g)],l=o.pop();if(l?.[0]==="declare")continue;if(a.text==="function"||a.text==="class"){while(l&&["async","export","default","abstract"].includes(l[0]))l=o.pop();if(l&&![";","}"].includes(l[0])){let d=c.slice(l.index+l[0].length);if(!/[\r\n]/.test(d)||!/^(?:[\w$]+|[)\]])$/.test(l[0])||["return","throw","yield","await","new"].includes(l[0]))continue}}i.push({name:r.name,start:a.start})}return i}function pt(e){return[...new Set(Ve(e).map((n)=>n.name))].sort()}function dt(e){let n=e.indexOf(" as ");if(n!==-1){let r=e.slice(0,n).trim(),a=e.slice(n+4).trim();return r&&a?{arrayExpr:r,itemVar:a}:null}let s=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!s)return null;let t=s[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),i=s[2].trim();return t&&i?{arrayExpr:i,itemVar:t}:null}var de=["batch","cachedQuery","clearServerData","computed","configureFetch","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","flushKeptState","forgetKeptState","goBack","goForward","inject","invalidateRoute","isDerived","isSignal","keptState","memo","navigate","nextTick","onBeforeMount","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","peek","provide","reactive","ref","refDebounced","refresh","registerStoresClient","setKeptScope","setRouteParams","sharedRequest","state","untrack","useAsync","useBroadcastStream","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebounceFn","useDebouncedValue","useDocumentVisibility","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useModel","useMutation","useNativeDesktop","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useRouteParam","useRouteParams","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useSlots","useStore","useThrottle","useThrottleFn","useTimeout","useTimeoutFn","useToggle","useWebSocket","watch","watchEffect","watchMultiple","withDefaults"];var Cn=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var Bs=de.filter((e)=>!Cn.includes(e));var kn=["x-text","x-html","x-model","x-show","x-if","x-for","x-cloak","x-ref","x-data","x-bind","x-class","x-style","x-tooltip","x-tooltip-position"],An=["x-init","x-transition","x-effect","x-on"],zs=[...kn,...An];var Ce=Q(require("node:fs"),1),fe=Q(require("node:path"),1);function ft(e,n,s,t){let i=0;for(let r=n;r<e.length;r++)if(e[r]===s)i++;else if(e[r]===t&&!(t===">"&&e[r-1]==="=")){if(--i===0)return r}return-1}function Rn(e){let n=L(e),s=0,t=0,i=[];for(let r=0;r<n.length;r++)if("([{".includes(n[r]))s++;else if(")]}".includes(n[r]))s--;else if(n[r]===","&&s===0)i.push(e.slice(t,r).trim()),t=r+1;return i.push(e.slice(t).trim()),i}function Fe(e,n){let s=L(e),t=new RegExp(`\\b(?:${n.map((i)=>i.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g");for(let i of s.matchAll(t)){let r=i.index+i[0].length,a="";if(s[r]==="<"){let o=ft(s,r,"<",">");if(o<0)continue;a=e.slice(r+1,o),r=o+1;while(/\s/.test(s[r]||"")&&r<s.length)r++}if(s[r]!=="(")continue;let c=ft(s,r,"(",")");if(c>=0)return{type:a,args:Rn(e.slice(r+1,c))}}return null}var _e=`
21
+ `),s.set(l,p)}return p(...a)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:o,context:n.slice()});return o}clear(){this.pool.length=0,this.fnCache.clear()}}var Jr=new ct;class lt{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(e){this.enabled=e}isEnabled(){return this.enabled}setBudget(e,n){this.budgets.set(e,{warnThreshold:0.8,action:"warn",...n})}setBudgets(e){for(let[n,r]of Object.entries(e))this.setBudget(n,r)}removeBudget(e){this.budgets.delete(e)}getBudgets(){let e={};for(let[n,r]of this.budgets.entries())e[n]=r;return e}onViolation(e){this.violationHandlers.push(e)}offViolation(e){let n=this.violationHandlers.indexOf(e);if(n!==-1)this.violationHandlers.splice(n,1)}time(e,n){if(!this.enabled)return n();let r=performance.now(),t=n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),t}async timeAsync(e,n){if(!this.enabled)return n();let r=performance.now(),t=await n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),t}checkBudget(e,n){let r=this.budgets.get(e);if(!r)return;let t=n/r.maxTime*100,s=r.warnThreshold!==void 0?n>=r.maxTime*r.warnThreshold&&n<r.maxTime:!1,i=n>=r.maxTime;if(!s&&!i)return;let o={label:e,actualTime:n,budgetTime:r.maxTime,exceedancePercent:t,timestamp:new Date,isWarning:s};this.violations.push(o);while(this.violations.length>this.maxViolations)this.violations.shift();for(let c of this.violationHandlers)try{c(o)}catch{}let a=s?`[Performance Warning] "${e}" took ${n.toFixed(2)}ms (${t.toFixed(1)}% of ${r.maxTime}ms budget)`:`[Performance Budget Exceeded] "${e}" took ${n.toFixed(2)}ms (exceeded ${r.maxTime}ms budget by ${(t-100).toFixed(1)}%)`;switch(r.action){case"log":console.log(a);break;case"warn":console.warn(a);break;case"error":console.error(a);break;case"throw":if(i)throw Error(a);else console.warn(a);break}}recordTime(e,n){let r=this.metrics.get(e);if(r)r.count++,r.totalTime+=n,r.maxTime=Math.max(r.maxTime,n),r.minTime=Math.min(r.minTime,n);else this.metrics.set(e,{count:1,totalTime:n,maxTime:n,minTime:n})}getStats(e){if(e){let r=this.metrics.get(e);if(!r)return{};let t=this.budgets.get(e);return{count:r.count,avgTime:r.totalTime/r.count,totalTime:r.totalTime,maxTime:r.maxTime,minTime:r.minTime,budget:t?.maxTime,budgetUtilization:t?r.totalTime/r.count/t.maxTime*100:void 0}}let n={};for(let[r,t]of this.metrics.entries()){let s=this.budgets.get(r);n[r]={count:t.count,avgTime:t.totalTime/t.count,totalTime:t.totalTime,maxTime:t.maxTime,minTime:t.minTime,budget:s?.maxTime,budgetUtilization:s?t.totalTime/t.count/s.maxTime*100:void 0}}return n}getViolations(e){if(e)return this.violations.filter((n)=>n.label===e);return[...this.violations]}getViolationStats(){let e={},n=0,r=0;for(let t of this.violations)if(e[t.label]=(e[t.label]||0)+1,t.isWarning)n++;else r++;return{total:this.violations.length,byLabel:e,warnings:n,errors:r}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var We=null;function Tn(){if(!We)We=new lt;return We}var qr=new Proxy({},{get(e,n){return Tn()[n]}});var ut=new Se(32,{maxBytes:2097152,sizeOf:(e)=>e.code.length*4}),ie=/^[A-Za-z_$][\w$]*$/,An=new Set(["if","for","while","switch","with"]),pt=["(","[","{"],dt=[")","]","}"],Rn=new Set(["const","let","var","return","if","for","while","do","switch","try","throw","export"]);function On(e){let n=j(e),r=[];for(let t of n.matchAll(/[A-Za-z_$][\w$]*|=>|\.\.\.|[^\s]/g)){let s=t.index??0;r.push({text:t[0],start:s,end:s+t[0].length})}return{code:n,tokens:r}}function Pn(e){let n=ut.get(e);if(n)return n;let{code:r,tokens:t}=On(e),s=new Map,i=[];for(let d=0;d<t.length;d++){let f=t[d].text;if(["(","[","{"].includes(f))i.push(d);else if([")","]","}"].includes(f)){let w=i.at(-1);if(w!==void 0&&["()","[]","{}"].includes(t[w].text+f))i.pop(),s.set(w,d),s.set(d,w)}}function o(d,f){let w=[],h=d;for(let u=d;u<f;u++){if(["(","[","{"].includes(t[u].text)&&(s.get(u)??f)<f){u=s.get(u);continue}if(t[u].text===",")w.push([h,u]),h=u+1}return w.push([h,f]),w}let a=[];function c(d,f,w,h=!1,u){if(t[d]?.text==="...")d++;if(d>=f)return;let m=t[d].text;if(ie.test(m)){if(w.add(m),w===x)a.push({name:m,token:d,functionScoped:h,declarationToken:u});return}if(m!=="{"&&m!=="[")return;let E=s.get(d);if(E===void 0||E>=f)return;for(let[R,v]of o(d+1,E)){let O=R;if(m==="{")for(let M=R;M<v;M++){if(t[M].text===":"){O=M+1;break}if(t[M].text==="=")break;if(["(","[","{"].includes(t[M].text)&&s.has(M))M=s.get(M)}c(O,v,w,h,u)}}function l(d,f){let w=new Set;for(let[h,u]of o(d,f))c(h,u,w);return w}function p(d){let f=d;for(;f<t.length;f++){let w=t[f].text;if(["(","[","{"].includes(w)&&s.has(f)){f=s.get(f);continue}if([",",";",")","]","}"].includes(w))break}return t[Math.max(d,f-1)]?.end??r.length}let x=new Set,b=[];for(let d=0;d<t.length;d++)if(t[d].text==="=>"){let f=d-1,w=f,h;if(t[f]?.text===")"&&s.has(f))w=s.get(f),h=l(w+1,f);else if(t[f]&&ie.test(t[f].text))h=new Set([t[f].text]);else continue;let u=d+1,m=t[u]?.text==="{"&&s.has(u)?t[s.get(u)].end:p(u);b.push({start:t[w].start,end:m,bodyStart:t[u]?.start??m,functionBody:!0,names:h})}else if(t[d].text==="("&&s.has(d)){let f=t[d-1]?.text;if(!f||An.has(f)||!ie.test(f)&&f!=="*"&&f!=="]")continue;let w=s.get(d),h=w+1;if(t[h]?.text===":"){h++;while(h<t.length&&!["{","=>",";","="].includes(t[h].text))h++}if(t[h]?.text!=="{"||!s.has(h))continue;b.push({start:t[d].start,end:t[s.get(h)].end,bodyStart:t[h].start,functionBody:f!=="catch",names:l(d+1,w)})}function _(d){let f=d;for(;f<t.length;f++){let w=t[f].text;if(pt.includes(w)&&s.has(f)){f=s.get(f);continue}if(w===";"||dt.includes(w))break;let h=t[f-1];if(f>d&&Rn.has(w)&&h.text!==".")break;if(f>d&&/[\n\r]/.test(r.slice(h.end,t[f].start))&&(/^[\w$]+$/.test(h.text)||dt.includes(h.text)||['"',"'","`"].includes(h.text))&&ie.test(w)&&!["in","of","instanceof"].includes(w))break}return f}let A=[];for(let d=0;d<t.length;d++){if(t[d].text!=="for")continue;let f=t[d+1]?.text==="await"?d+2:d+1;if(t[f]?.text!=="("||!s.has(f))continue;let w=s.get(f),h=w+1,u=t[h]?.text==="{"&&s.has(h)?s.get(h):_(h),m=t[u]?.text===";"||t[u]?.text==="}"?t[u].end:t[Math.max(h,u-1)]?.end??r.length;A.push({headStart:f,headEnd:w,start:t[f].start,end:m})}for(let d=0;d<t.length;d++){let f=t[d].text,w=t[d-1]?.text;if(w==="."||t[d+1]?.text===":")continue;if(w==="as"||w==="<")continue;if(f==="const"||f==="let"||f==="var"){let h=_(d+1),u=d+1,m=!1,E=!1,R=0;for(let v=d+1;v<=h;v++){let O=t[v]?.text;if(v<h&&pt.includes(O)&&s.has(v)&&s.get(v)<h){v=s.get(v);continue}if(v<h&&O===":"&&!E)m=!0;else if(v<h&&O==="="&&R===0)m=!1,E=!0;else if(v<h&&m&&O==="<")R++;else if(v<h&&m&&O===">"&&R>0)R--;else if(v===h||O===","&&R===0)c(u,v,x,f==="var",d),u=v+1,m=!1,E=!1}}else if(f==="function"||f==="class"){let h=d+1;if(t[h]?.text==="*")h++;if(t[h]&&ie.test(t[h].text)&&t[h].text!=="extends")x.add(t[h].text),a.push({name:t[h].text,token:h,declarationToken:d})}else if(f==="import"){let h=d+1;if(t[h]?.text==="*"&&t[h+1]?.text==="as")h+=2;let u=t[h]?.text;if(u&&ie.test(u)&&u!=="type"&&t[h+1]?.text!=="("&&t[h+1]?.text!==".")x.add(u),a.push({name:u,token:h,file:!0});let m=t[h]?.text==="{"?h:t[h+1]?.text===","&&t[h+2]?.text==="{"?h+2:-1;if(m!==-1&&s.has(m)){let E=s.get(m);for(let[R,v]of o(m+1,E)){let O=v-1;while(O>=R&&!ie.test(t[O].text))O--;if(O>=R&&t[O].text!=="type")a.push({name:t[O].text,token:O,file:!0})}}}}let C={code:r,scopes:b,loops:A,declarations:x,sites:a,tokens:t,pairs:s};return ut.set(e,C),C}function Ce(e){let n=Pn(e),r=at(e),{depths:t}=U(r),s=[];for(let i of n.sites){if(i.file||i.declarationToken===void 0)continue;let o=n.tokens[i.declarationToken];if(t[o.start]!==0)continue;let a=r.slice(0,o.start),c=[...a.matchAll(/[A-Za-z_$][\w$]*|\d+(?:[.]\d+)?|[^\s]/g)],l=c.pop();if(l?.[0]==="declare")continue;if(o.text==="function"||o.text==="class"){while(l&&["async","export","default","abstract"].includes(l[0]))l=c.pop();if(l&&![";","}"].includes(l[0])){let p=a.slice(l.index+l[0].length);if(!/[\r\n]/.test(p)||!/^(?:[\w$]+|[)\]])$/.test(l[0])||["return","throw","yield","await","new"].includes(l[0]))continue}}s.push({name:i.name,start:o.start})}return s}function ft(e){return[...new Set(Ce(e).map((n)=>n.name))].sort()}function mt(e){let n=e.indexOf(" as ");if(n!==-1){let i=e.slice(0,n).trim(),o=e.slice(n+4).trim();return i&&o?{arrayExpr:i,itemVar:o}:null}let r=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!r)return null;let t=r[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),s=r[2].trim();return t&&s?{arrayExpr:s,itemVar:t}:null}var de=["batch","cachedQuery","clearServerData","computed","configureFetch","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","flushKeptState","forgetKeptState","goBack","goForward","inject","invalidateRoute","isDerived","isSignal","keptState","memo","navigate","nextTick","onBeforeMount","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","peek","provide","reactive","ref","refDebounced","refresh","registerStoresClient","setKeptScope","setRouteParams","sharedRequest","state","untrack","useAsync","useBroadcastStream","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebounceFn","useDebouncedValue","useDocumentVisibility","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useModel","useMutation","useNativeDesktop","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useRouteParam","useRouteParams","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useSlots","useStore","useThrottle","useThrottleFn","useTimeout","useTimeoutFn","useToggle","useWebSocket","watch","watchEffect","watchMultiple","withDefaults"];var Mn=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var ss=de.filter((e)=>!Mn.includes(e));var In=["x-text","x-html","x-model","x-show","x-if","x-for","x-cloak","x-ref","x-data","x-bind","x-class","x-style","x-tooltip","x-tooltip-position"],Nn=["x-init","x-transition","x-effect","x-on"],is=[...In,...Nn];var Oe=Q(require("node:fs"),1),fe=Q(require("node:path"),1);function gt(e,n,r,t){let s=0;for(let i=n;i<e.length;i++)if(e[i]===r)s++;else if(e[i]===t&&!(t===">"&&e[i-1]==="=")){if(--s===0)return i}return-1}function Ln(e){let n=j(e),r=0,t=0,s=[];for(let i=0;i<n.length;i++)if("([{".includes(n[i]))r++;else if(")]}".includes(n[i]))r--;else if(n[i]===","&&r===0)s.push(e.slice(t,i).trim()),t=i+1;return s.push(e.slice(t).trim()),s}function Te(e,n,r=!1){let t=j(e),s=new RegExp(`\\b(?:${n.map((o)=>o.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g"),i=r?U(t).depths:void 0;for(let o of t.matchAll(s)){if(i&&i[o.index]!==0)continue;let a=o.index+o[0].length,c="";if(t[a]==="<"){let p=gt(t,a,"<",">");if(p<0)continue;c=e.slice(a+1,p),a=p+1;while(/\s/.test(t[a]||"")&&a<t.length)a++}if(t[a]!=="(")continue;let l=gt(t,a,"(",")");if(l>=0)return{type:c,args:Ln(e.slice(a+1,l)),start:o.index,end:l+1}}return null}var Ae=`
22
22
  type __StxCtor<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends readonly unknown[] ? __StxCtor<T[number]> : T extends abstract new (...args: any[]) => infer V ? V : unknown;
23
23
  type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
24
24
  type __StxOption<T> = T extends { type: infer C } ? __StxCtor<C> : T extends { default: infer D } ? D extends (...args: any[]) => infer V ? V : __StxWiden<D> : __StxCtor<T>;
@@ -26,75 +26,81 @@ type __StxRequired<O> = { [K in keyof O]-?: O[K] extends { required: true } ? K
26
26
  type __StxDefaulted<O> = { [K in keyof O]-?: O[K] extends { default: unknown } ? K : never }[keyof O];
27
27
  type __StxOptions<O> = { [K in Exclude<__StxRequired<O>, __StxDefaulted<O>>]: __StxOption<O[K]> } & { [K in Exclude<keyof O, Exclude<__StxRequired<O>, __StxDefaulted<O>>>]?: __StxOption<O[K]> };
28
28
  type __StxDefaults<P, K> = Omit<P, Extract<keyof P, K>> & Partial<Pick<P, Extract<keyof P, K>>>;
29
- `;function Ee(e,n){let s=[],t={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},i=L(e),r=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(b,_,A,C,p)=>{if(i.slice(p,p+6)!=="import")return b;if(C.endsWith(".stx"))return"";let f=`${n}Import${s.length}`;if(s.push(`import * as ${f} from ${JSON.stringify(C)};`),_.startsWith("*"))return`import ${_.replace(/^\*\s+as\s+/,"")} = ${f};`;if(!_.startsWith("{"))return`import ${_} = ${f}.default;`;return _.slice(1,-1).split(",").map((T)=>{let[h,u=h]=T.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!h)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(C)&&h in t)t[h].push(u);return`import ${u} = ${f}.${h};`}).join(`
30
- `)}),a=Fe(e,t.defineProps),c=Fe(e,t.defineEmits),o=Fe(e,t.withDefaults);if(!a&&!c)return{declarations:"",props:null,events:null};let l=[],d=null,x=null;if(a){l.push(`const __options = (${a.args[0]||"{}"}) as const;`),l.push(`const __defaults = (${o?.args[1]||"{}"});`);let b=a.type||"__StxOptions<typeof __options>";l.push(`export type __StxProps = __StxDefaults<${b}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),d=`${n}.__StxProps`}if(c)l.push(`const __events = (${c.args[0]||"[]"}) as const;`),l.push(`export type __StxEvents = ${c.type||"Record<(typeof __events)[number], any[]>"};`),x=`${n}.__StxEvents`;return{declarations:`${s.join(`
29
+ `;function Re(e,n){let r=[],t={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},s=j(e),i=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(b,_,A,C,d)=>{if(s.slice(d,d+6)!=="import")return b;if(C.endsWith(".stx"))return"";let f=`${n}Import${r.length}`;if(r.push(`import * as ${f} from ${JSON.stringify(C)};`),_.startsWith("*"))return`import ${_.replace(/^\*\s+as\s+/,"")} = ${f};`;if(!_.startsWith("{"))return`import ${_} = ${f}.default;`;return _.slice(1,-1).split(",").map((w)=>{let[h,u=h]=w.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!h)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(C)&&h in t)t[h].push(u);return`import ${u} = ${f}.${h};`}).join(`
30
+ `)}),o=Te(e,t.defineProps),a=Te(e,t.defineEmits),c=Te(e,t.withDefaults);if(!o&&!a)return{declarations:"",props:null,events:null};let l=[],p=null,x=null;if(o){l.push(`const __options = (${o.args[0]||"{}"}) as const;`),l.push(`const __defaults = (${c?.args[1]||"{}"});`);let b=o.type||"__StxOptions<typeof __options>";l.push(`export type __StxProps = __StxDefaults<${b}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),p=`${n}.__StxProps`}if(a)l.push(`const __events = (${a.args[0]||"[]"}) as const;`),l.push(`export type __StxEvents = ${a.type||"Record<(typeof __events)[number], any[]>"};`),x=`${n}.__StxEvents`;return{declarations:`${r.join(`
31
31
  `)}
32
32
  namespace ${n} {
33
- ${r}
33
+ ${i}
34
34
  ${l.join(`
35
35
  `)}
36
- }`,props:d,events:x}}var oe=Q(require("node:fs"),1),j=Q(require("node:path"),1);function gt(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var mt=new Map;function ht(e,n=!0){let s=mt.get(e);if(n&&s)return s;let t=new Map,i=[j.default.join(e,"src"),j.default.join(e,"dist"),e];function r(a,c){if(c>6)return;let o;try{o=oe.default.readdirSync(a,{withFileTypes:!0})}catch{return}for(let l of o){let d=j.default.join(a,l.name);if(l.isDirectory()){if(l.name==="node_modules"||l.name.startsWith("."))continue;r(d,c+1)}else if(l.isFile()&&l.name.endsWith(".stx")){let x=l.name.slice(0,-4);if(!t.has(x))t.set(x,d);let b=x.toLowerCase();if(!t.has(b))t.set(b,d);let _=gt(x);if(!t.has(_))t.set(_,d)}}}for(let a of i)if(r(a,0),t.size>0)break;if(n)mt.set(e,t);return t}function xt(e,n){if(e.startsWith(".")||e.startsWith("/"))return null;let s=n;while(!0){let t=j.default.join(s,"node_modules",e);try{if(oe.default.statSync(t).isDirectory())return t}catch{}let i=j.default.dirname(s);if(i===s)return null;s=i}}function bt(e,n,s={}){return[j.default.resolve(j.default.dirname(n),`${e}.stx`),j.default.resolve(j.default.dirname(n),e),j.default.resolve(s.componentsDir||"components",`${e}.stx`),j.default.resolve(s.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function yt(e){let n=e.endsWith(".stx")?e.slice(0,-4):e,s=n.split("-").map((i)=>i.charAt(0).toUpperCase()+i.slice(1)).join(""),t=gt(n);return[n,s,t]}function Pn(e,n){let[s,t,i]=yt(e);for(let r of[s,s.toLowerCase(),t,i]){let a=n?.__importedComponents?.get(r);if(a!==void 0)return a}}function Mn(e,n){let s=n?j.default.resolve(n):void 0,t=j.default.dirname(j.default.resolve(e));for(;;){if(oe.default.existsSync(j.default.join(t,"package.json")))return s&&t===s?void 0:t;let i=j.default.dirname(t);if(i===t)return;t=i}}var On=["src/ui","src/components","components","dist"];function In(e,n){let s=j.default.resolve(e);if(!n&&!s.split(j.default.sep).includes("node_modules"))return[];let t=Mn(s,n);if(!t)return[];let i=[];try{let c=JSON.parse(oe.default.readFileSync(j.default.join(t,"package.json"),"utf8")).stx?.components;if(Array.isArray(c))i=c.filter((o)=>typeof o==="string")}catch{}let r=i.length?i:On;return[j.default.dirname(j.default.resolve(e)),...r.map((a)=>j.default.resolve(t,a))]}function*Dn(e,n,s={},t){let i=yt(e);if(i[0].startsWith("./")||i[0].startsWith("../")){yield j.default.resolve(j.default.dirname(n),`${i[0]}.stx`);return}let r=[...new Set(i.map((o)=>`${o}.stx`))],a=s.projectRoot||process.cwd(),c=[...In(n,s.projectRoot),...t?.__originalFilePath?[j.default.join(j.default.dirname(t.__originalFilePath),"components")]:[],...s.componentsDir?[s.componentsDir]:[],j.default.join(j.default.dirname(n),"components"),j.default.resolve(a,"src/components"),j.default.resolve(a,"components"),j.default.resolve("/home/runner/work/stx/stx/packages/stx/src","components")];for(let o of new Set(c)){for(let l of r)yield j.default.join(o,l);try{for(let l of oe.default.readdirSync(o,{withFileTypes:!0}))if(l.isDirectory())for(let d of r)yield j.default.join(o,l.name,d)}catch{}}}function St(e,n,s={},t){let i=Pn(e,t);if(i!==void 0)return i;for(let r of Dn(e,n,s,t))try{if(oe.default.statSync(r,{throwIfNoEntry:!1})?.isFile())return r}catch{}return null}var vt=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function wt(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...vt].some((n)=>n.toLowerCase()===e.toLowerCase());return vt.has(e)||/[A-Z]/.test(e)}function*jn(e){let n=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,s;while(s=n.exec(e)){let t=n.lastIndex,i=[];while(t<e.length){while(/\s/.test(e[t]||""))t++;if(e[t]===">"||e.slice(t,t+2)==="/>"){t+=e[t]===">"?1:2;break}let r=/^[^\s=/>]+/.exec(e.slice(t))?.[0];if(!r){t++;continue}let a=t;t+=r.length;while(/\s/.test(e[t]||""))t++;if(e[t]!=="="){i.push({name:r,value:!0,offset:a,braced:!1});continue}t++;while(/\s/.test(e[t]||""))t++;let c=e[t],o=c==="{",l=c==='"'||c==="'";if(l||o)t++;let d=t;if(o){let x=L(e.slice(t)),b=1,_=0;for(;_<x.length;_++){if(x[_]==="{")b++;if(x[_]==="}"&&--b===0)break}t+=_}else if(l)while(t<e.length&&e[t]!==c)t++;else while(t<e.length&&!/[\s/>]/.test(e[t]))t++;if(i.push({name:r,value:e.slice(d,t),offset:d,braced:o}),l||o)t++}n.lastIndex=t,yield{name:s[1],offset:s.index,attributes:i}}}function $t(e,n,s){let t=[],i=[_e,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxStaticProp<P, K> = __StxProp<P, K> extends infer T ? boolean extends T ? T | "true" | "false" : T : never;','type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? number extends E[K]["length"] ? E[K][0] : Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],r=new Map,a=new Map,c=new Map,o=s.scriptCode(e,s.filePath),l=L(o);for(let A of o.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(l.slice(A.index,A.index+6)!=="import")continue;let C=A[2],p=fe.default.isAbsolute(C)||C.startsWith(".")?fe.default.resolve(fe.default.dirname(s.filePath),C):xt(C,fe.default.dirname(s.filePath));if(!p)continue;let f=p.endsWith(".stx")?p:Ce.default.existsSync(`${p}.stx`)?`${p}.stx`:void 0,T=f?null:ht(p,!1),h=A[1].startsWith("{")?A[1].slice(1,-1).split(","):[A[1]];for(let u of h){let[m,w=m]=u.trim().split(/\s+as\s+/),R=f||T?.get(m)||T?.get(m.toLowerCase());if(R)c.set(w,R),c.set(w.toLowerCase(),R),c.set(w.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),R)}}for(let A of n.matchAll(/@import\s*\(([^)]+)\)/g))for(let C of A[1].matchAll(/['"]([^'"]+)['"]/g)){let p=bt(C[1],s.filePath,s).find((f)=>Ce.default.statSync(f,{throwIfNoEntry:!1})?.isFile());if(p)c.set(fe.default.basename(C[1]).replace(/\.stx$/,""),p)}let d={__importedComponents:c},x=new Map,b=(A,C,p)=>{let f=e.slice(0,A);return{code:C,offset:A,attribute:p,anchor:!0,kind:"directive",line:f.split(`
36
+ }`,props:p,events:x}}var oe=Q(require("node:fs"),1),L=Q(require("node:path"),1);function xt(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var ht=new Map;function bt(e,n=!0){let r=ht.get(e);if(n&&r)return r;let t=new Map,s=[L.default.join(e,"src"),L.default.join(e,"dist"),e];function i(o,a){if(a>6)return;let c;try{c=oe.default.readdirSync(o,{withFileTypes:!0})}catch{return}for(let l of c){let p=L.default.join(o,l.name);if(l.isDirectory()){if(l.name==="node_modules"||l.name.startsWith("."))continue;i(p,a+1)}else if(l.isFile()&&l.name.endsWith(".stx")){let x=l.name.slice(0,-4);if(!t.has(x))t.set(x,p);let b=x.toLowerCase();if(!t.has(b))t.set(b,p);let _=xt(x);if(!t.has(_))t.set(_,p)}}}for(let o of s)if(i(o,0),t.size>0)break;if(n)ht.set(e,t);return t}function yt(e,n){if(e.startsWith(".")||e.startsWith("/"))return null;let r=n;while(!0){let t=L.default.join(r,"node_modules",e);try{if(oe.default.statSync(t).isDirectory())return t}catch{}let s=L.default.dirname(r);if(s===r)return null;r=s}}function St(e,n,r={}){return[L.default.resolve(L.default.dirname(n),`${e}.stx`),L.default.resolve(L.default.dirname(n),e),L.default.resolve(r.componentsDir||"components",`${e}.stx`),L.default.resolve(r.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function vt(e){let n=e.endsWith(".stx")?e.slice(0,-4):e,r=n.split("-").map((s)=>s.charAt(0).toUpperCase()+s.slice(1)).join(""),t=xt(n);return[n,r,t]}function Dn(e,n){let[r,t,s]=vt(e);for(let i of[r,r.toLowerCase(),t,s]){let o=n?.__importedComponents?.get(i);if(o!==void 0)return o}}function jn(e,n){let r=n?L.default.resolve(n):void 0,t=L.default.dirname(L.default.resolve(e));for(;;){if(oe.default.existsSync(L.default.join(t,"package.json")))return r&&t===r?void 0:t;let s=L.default.dirname(t);if(s===t)return;t=s}}var Fn=["src/ui","src/components","components","dist"];function Bn(e,n){let r=L.default.resolve(e);if(!n&&!r.split(L.default.sep).includes("node_modules"))return[];let t=jn(r,n);if(!t)return[];let s=[];try{let a=JSON.parse(oe.default.readFileSync(L.default.join(t,"package.json"),"utf8")).stx?.components;if(Array.isArray(a))s=a.filter((c)=>typeof c==="string")}catch{}let i=s.length?s:Fn;return[L.default.dirname(L.default.resolve(e)),...i.map((o)=>L.default.resolve(t,o))]}function*zn(e,n,r={},t){let s=vt(e);if(s[0].startsWith("./")||s[0].startsWith("../")){yield L.default.resolve(L.default.dirname(n),`${s[0]}.stx`);return}let i=[...new Set(s.map((c)=>`${c}.stx`))],o=r.projectRoot||process.cwd(),a=[...Bn(n,r.projectRoot),...t?.__originalFilePath?[L.default.join(L.default.dirname(t.__originalFilePath),"components")]:[],...r.componentsDir?[r.componentsDir]:[],L.default.join(L.default.dirname(n),"components"),L.default.resolve(o,"src/components"),L.default.resolve(o,"components"),L.default.resolve("/home/runner/work/stx/stx/packages/stx/src","components")];for(let c of new Set(a)){for(let l of i)yield L.default.join(c,l);try{for(let l of oe.default.readdirSync(c,{withFileTypes:!0}))if(l.isDirectory())for(let p of i)yield L.default.join(c,l.name,p)}catch{}}}function Et(e,n,r={},t){let s=Dn(e,t);if(s!==void 0)return s;for(let i of zn(e,n,r,t))try{if(oe.default.statSync(i,{throwIfNoEntry:!1})?.isFile())return i}catch{}return null}var wt=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function $t(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...wt].some((n)=>n.toLowerCase()===e.toLowerCase());return wt.has(e)||/[A-Z]/.test(e)}function*Vn(e){let n=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,r;while(r=n.exec(e)){let t=n.lastIndex,s=[];while(t<e.length){while(/\s/.test(e[t]||""))t++;if(e[t]===">"||e.slice(t,t+2)==="/>"){t+=e[t]===">"?1:2;break}let i=/^[^\s=/>]+/.exec(e.slice(t))?.[0];if(!i){t++;continue}let o=t;t+=i.length;while(/\s/.test(e[t]||""))t++;if(e[t]!=="="){s.push({name:i,value:!0,offset:o,braced:!1});continue}t++;while(/\s/.test(e[t]||""))t++;let a=e[t],c=a==="{",l=a==='"'||a==="'";if(l||c)t++;let p=t;if(c){let x=j(e.slice(t)),b=1,_=0;for(;_<x.length;_++){if(x[_]==="{")b++;if(x[_]==="}"&&--b===0)break}t+=_}else if(l)while(t<e.length&&e[t]!==a)t++;else while(t<e.length&&!/[\s/>]/.test(e[t]))t++;if(s.push({name:i,value:e.slice(p,t),offset:p,braced:c}),l||c)t++}n.lastIndex=t,yield{name:r[1],offset:r.index,attributes:s}}}function _t(e,n,r){let t=[],s=[Ae,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxStaticProp<P, K> = __StxProp<P, K> extends infer T ? boolean extends T ? T | "true" | "false" : T : never;','type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? number extends E[K]["length"] ? E[K][0] : Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],i=new Map,o=new Map,a=new Map,c=r.scriptCode(e,r.filePath),l=j(c);for(let A of c.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(l.slice(A.index,A.index+6)!=="import")continue;let C=A[2],d=fe.default.isAbsolute(C)||C.startsWith(".")?fe.default.resolve(fe.default.dirname(r.filePath),C):yt(C,fe.default.dirname(r.filePath));if(!d)continue;let f=d.endsWith(".stx")?d:Oe.default.existsSync(`${d}.stx`)?`${d}.stx`:void 0,w=f?null:bt(d,!1),h=A[1].startsWith("{")?A[1].slice(1,-1).split(","):[A[1]];for(let u of h){let[m,E=m]=u.trim().split(/\s+as\s+/),R=f||w?.get(m)||w?.get(m.toLowerCase());if(R)a.set(E,R),a.set(E.toLowerCase(),R),a.set(E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),R)}}for(let A of n.matchAll(/@import\s*\(([^)]+)\)/g))for(let C of A[1].matchAll(/['"]([^'"]+)['"]/g)){let d=St(C[1],r.filePath,r).find((f)=>Oe.default.statSync(f,{throwIfNoEntry:!1})?.isFile());if(d)a.set(fe.default.basename(C[1]).replace(/\.stx$/,""),d)}let p={__importedComponents:a},x=new Map,b=(A,C,d)=>{let f=e.slice(0,A);return{code:C,offset:A,attribute:d,anchor:!0,kind:"directive",line:f.split(`
37
37
  `).length,column:A-f.lastIndexOf(`
38
- `)}},_=(A,C,p)=>t.push({expression:A,statement:{text:C+A.code+p,prefixLength:C.length}});for(let A of jn(n)){if(wt(A.name)||A.name==="component")continue;let C=St(A.name,s.filePath,s,d);if(!C)continue;let p=x.get(C);if(!p){let T;try{T=s.readComponent?s.readComponent(C):Ce.default.readFileSync(C,"utf8")}catch{continue}if(T===void 0)continue;a.set(C,T),p=Ee(s.scriptCode(T,C),`__StxComponent${x.size}`),x.set(C,p),i.push(p.declarations)}let f=[];for(let T of A.attributes){let{name:h,offset:u}=T,m=T.value===!0?"true":T.value;if(h.startsWith("@")||h.startsWith("v-on:")){if(p.events&&T.value!==!0)r.set(u,`__StxEvent<${p.events}, ${JSON.stringify(h.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let w=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(h);if(h.startsWith("v-")&&!h.startsWith("v-bind:")&&!w)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(h))continue;let R=(w?w[1]||"modelValue":h.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(I,M)=>M.toUpperCase());if(f.push(R),!p.props)continue;let v=h.startsWith(":")||h.startsWith("v-bind:")||!!w||T.braced,P=v?m:T.value!==!0?JSON.stringify(m):"true",O=!v&&T.value!==!0&&(m==="true"||m==="false");_(b(u,P,h),";void ((",`) satisfies ${O?"__StxStaticProp":"__StxProp"}<${p.props}, ${JSON.stringify(R)}>);`)}if(p.props){let T=[...new Set(f)].map((u)=>`${JSON.stringify(u)}: undefined as any`).join(", "),h=b(A.offset,`<${A.name}>`);t.push({expression:h,statement:{text:`;void ({ ${T} } satisfies ${p.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:x.size?i.join(`
39
- `):"",checks:t,events:r,dependencies:a}}var Je=Q(require("node:fs"),1),U=Q(require("node:path"),1);var ke=["module","exports","require","props","$props","$bool","$num","defineProps","withDefaults","defineClientPayload","useServerData","useRuntimeConfig","useServerRuntimeConfig","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","setResponseStatus","setResponseHeader","notFound","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"];var Tt=require("node:module");var ri=new Set(Tt.builtinModules);function Ke(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function We(e){for(let n of ue(Ke(e))){let s=pe(n.attrs);if(!s.has("component")&&!s.has("stx:component"))continue;return{code:e.slice(n.bodyStart,n.bodyEnd),start:n.bodyStart,open:n.start}}}function _t(e,n){let s=We(e);if(!s)return{};let t=s.code.trim();if(!t)return{};try{let i=JSON.parse(t);if(!i||typeof i!=="object"||Array.isArray(i))throw Error("expected a JSON object");return i}catch(i){throw Error(`${n}: <script component> must contain JSON metadata (${i.message})`)}}function Ge(e,n){let s=L(e),t=new Set(Ve(e).map((o)=>o.start)),i=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,r=[],a=n?void 0:new Bun.Transpiler({loader:"ts"}),c;while(c=i.exec(s)){if(!t.has(c.index+c[0].indexOf("function")))continue;let o=i.lastIndex;while(/\s/.test(s[o]||""))o++;let l=o;if(s[o]==="<")o=He(s,o,"<",">");if(o<0)continue;let d=e.slice(l,o).trim();while(/\s/.test(s[o]||""))o++;if(s[o]!=="(")continue;let x=o,b=He(s,o,"(",")");if(b<0)continue;for(o=b;o<e.length;o++){let _=s[o];if(_!=="{"&&_!==";")continue;let A=e.slice(c.index,o).trim();if(n){if(!n(A,_,c[1]))continue}else{let p;try{p=a.transformSync(A+(_==="{"?"{}":";"))}catch{continue}if(_==="{"&&!p.includes(`function ${c[1]}(`))continue;if(_===";"&&p.trim())continue}let C=_==="{"?He(s,o,"{","}"):o+1;if(C<0)break;r.push({name:c[1],header:A,generic:d,parameterOffset:x+1,parameters:e.slice(x+1,b-1),returns:e.slice(b,o).trim().replace(/^:\s*/,""),async:/\basync\s+function/.test(c[0]),..._==="{"?{source:e.slice(c.index,C)}:{}}),i.lastIndex=C;break}}return r}function Ae(e,n){if(e[n]!=="(")return null;let s=0,t="";for(let i=n;i<e.length;i++){let r=e[i];if(t!==""){if(r==="\\")i++;else if(r===t)t="";continue}if(r==="'"||r==='"'||r==="`"){t=r;continue}if(r==="(")s++;else if(r===")"){if(s--,s===0)return{expression:e.slice(n+1,i),end:i+1}}}return null}function Et(e){let n=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec(e.trim());return n?{iterable:n[1],key:n[2],value:n[3]}:void 0}function He(e,n,s,t){if(e[n]!==s)return-1;let i=0,r=null;for(let a=n;a<e.length;a++){let c=e[a];if(r){if(c==="\\"){a++;continue}if(c===r)r=null;continue}if(c==="'"||c==='"'||c==="`"){r=c;continue}if(c===s)i++;else if(c===t){if(t===">"&&e[a-1]==="=")continue;if(i--,i===0)return a+1}}return-1}function Ue(e){if(!e||typeof e!=="object")return"unknown";switch(e.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}var Nn=new Set(ke);function Re(e){let n=he(e),s=n.find((x)=>x.name==="InheritedContext");if(!s)return;let t=/^(?:interface\s+InheritedContext|type\s+InheritedContext\s*=)\s*\{/.test(L(s.text).trim()),i=L(e),r=q(i).depths,a=[...i.matchAll(/\b(?:interface|type)\s+InheritedContext\b/g)].find((x)=>r[x.index]===0)?.index??0,c=s.text.slice(s.text.indexOf("{")+1,s.text.lastIndexOf("}")),o=L(c),l=q(o).depths,d=[...o.matchAll(/(?:^|[;,\n])\s*(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:/g)].filter((x)=>l[x.index]===0).map((x)=>x[1]);return{keys:t?d:[],types:n.map((x)=>x.text).join(`
40
- `),offset:Math.max(0,a),...!t?{unsupported:"InheritedContext requires a local non-generic object interface or object type alias with named properties"}:{}}}function Ln(e){let n=[],s=L(e);for(let t of e.matchAll(/\bimport\s+(type\s+)?([\w$*{}\s,]+?)\s+from\s*(['"])([^'"]+)\3/g)){if(t[1]||s.slice(t.index,t.index+6)!=="import")continue;let i=t[2].trim(),r=["stx","@stacksjs/stx"].includes(t[4]);if(/^[A-Za-z_$][\w$]*$/.test(i)){n.push(i);continue}if(!i.startsWith("{")||!i.endsWith("}"))continue;for(let a of i.slice(1,-1).split(",")){if(/^\s*type\s+/.test(a))continue;let[c,o=c]=a.trim().split(/\s+as\s+/);if(o&&!(r&&Nn.has(c)))n.push(o)}}return n}function Ct(e){let n=Re(e);if(!n||n.unsupported)return"";let s=new Set(ae(e));return n.keys.filter((t)=>!s.has(t)).map((t)=>`declare const ${t}: InheritedContext[${JSON.stringify(t)}];`).join(`
41
- `)}function kt(e,n){let s=[_e],t=[],i=new Map,r=U.default.resolve(n.filePath),a=r.split(U.default.sep).lastIndexOf("views"),c=a>=0?r.split(U.default.sep).slice(0,a).join(U.default.sep):U.default.dirname(r),o=U.default.resolve(n.partialsDir||U.default.join(c,"partials")),l=U.default.resolve(n.layoutsDir||U.default.join(c,"views/layouts"));if([o,l].some((p)=>r===p||r.startsWith(p+U.default.sep)))return{declarations:"",checks:t,dependencies:i};let d=(p)=>n.readTemplate?.(p)??(Je.default.existsSync(p)?Je.default.readFileSync(p,"utf8"):void 0),x=0,b=!1,_=[];function A(p,f){let T=e.slice(0,p).split(`
42
- `).length,h=p-e.lastIndexOf(`
43
- `,p-1),u={code:e.slice(p,e.indexOf(`
44
- `,p)<0?e.length:e.indexOf(`
45
- `,p)),line:T,column:h,kind:"directive",offset:p,anchor:!0};t.push({expression:u,statement:{text:`;${f}`,prefixLength:1}})}function C(p,f,T,h,u,m){let w=`__StxInherited${x++}`;while((e+p+[...i.values()].join("")).includes(w))w+="_";let R=me(p).filter((N)=>N.kind==="server").map((N)=>N.code).join(`
46
- `),v=`${w}ParentValue`,P=`${w}ParentType`;s.push(`type ${P} = ${T};`);let O=Ze(Me(R,U.default.dirname(f)),w);s.push(...O.imports);let I=Re(R);if(I&&u!==void 0){b=!0;let N=O.imports.length?O.aliases.join(`
47
- `):"",H=Ee(`${N}
38
+ `)}},_=(A,C,d)=>t.push({expression:A,statement:{text:C+A.code+d,prefixLength:C.length}});for(let A of Vn(n)){if($t(A.name)||A.name==="component")continue;let C=Et(A.name,r.filePath,r,p);if(!C)continue;let d=x.get(C);if(!d){let w;try{w=r.readComponent?r.readComponent(C):Oe.default.readFileSync(C,"utf8")}catch{continue}if(w===void 0)continue;o.set(C,w),d=Re(r.scriptCode(w,C),`__StxComponent${x.size}`),x.set(C,d),s.push(d.declarations)}let f=[];for(let w of A.attributes){let{name:h,offset:u}=w,m=w.value===!0?"true":w.value;if(h.startsWith("@")||h.startsWith("v-on:")){if(d.events&&w.value!==!0)i.set(u,`__StxEvent<${d.events}, ${JSON.stringify(h.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let E=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(h);if(h.startsWith("v-")&&!h.startsWith("v-bind:")&&!E)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(h))continue;let R=(E?E[1]||"modelValue":h.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(I,P)=>P.toUpperCase());if(f.push(R),!d.props)continue;let v=h.startsWith(":")||h.startsWith("v-bind:")||!!E||w.braced,O=v?m:w.value!==!0?JSON.stringify(m):"true",M=!v&&w.value!==!0&&(m==="true"||m==="false");_(b(u,O,h),";void ((",`) satisfies ${M?"__StxStaticProp":"__StxProp"}<${d.props}, ${JSON.stringify(R)}>);`)}if(d.props){let w=[...new Set(f)].map((u)=>`${JSON.stringify(u)}: undefined as any`).join(", "),h=b(A.offset,`<${A.name}>`);t.push({expression:h,statement:{text:`;void ({ ${w} } satisfies ${d.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:x.size?s.join(`
39
+ `):"",checks:t,events:i,dependencies:o}}var Xe=Q(require("node:fs"),1),J=Q(require("node:path"),1);var Pe=["module","exports","require","props","$props","$bool","$num","defineProps","withDefaults","defineClientPayload","useServerData","useRuntimeConfig","useServerRuntimeConfig","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","setResponseStatus","setResponseHeader","notFound","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"];function Wn(){let{NODE_ENV:e}=process.env;return e==="production"}function He(){let{STX_DEBUG:e}=process.env;return!Wn()||e==="true"}var Hn={showRelativePaths:!1,enableAutoRecovery:He(),logRecoveryWarnings:!0},vs={...Hn};class Ke{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor(e={}){this.maxErrors=e.maxErrors??1000,this.enableFileLogging=e.enableFileLogging??!1,this.logFilePath=e.logFilePath??".stx/errors.log",this.logFormat=e.logFormat??"json",this.maxFileSize=e.maxFileSize??10485760,this.maxLogFiles=e.maxLogFiles??5,this.minLevel=e.minLevel??"all"}configure(e){if(e.maxErrors!==void 0)this.maxErrors=e.maxErrors;if(e.enableFileLogging!==void 0)this.enableFileLogging=e.enableFileLogging;if(e.logFilePath!==void 0)this.logFilePath=e.logFilePath;if(e.logFormat!==void 0)this.logFormat=e.logFormat;if(e.maxFileSize!==void 0)this.maxFileSize=e.maxFileSize;if(e.maxLogFiles!==void 0)this.maxLogFiles=e.maxLogFiles;if(e.minLevel!==void 0)this.minLevel=e.minLevel}log(e,n,r="error"){let t={timestamp:new Date,error:e,context:n,level:r};if(this.errors.push(t),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(r))this.writeToFile(t)}shouldLog(e){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return e==="error"||e==="warning";if(this.minLevel==="error")return e==="error";return!0}formatEntry(e){if(this.logFormat==="json")return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level||"error",type:e.error.constructor.name,message:e.error.message,stack:e.error.stack,context:e.context});let n=[`[${e.timestamp.toISOString()}] [${(e.level||"error").toUpperCase()}] ${e.error.constructor.name}: ${e.error.message}`];if(e.error.stack)n.push(` Stack: ${e.error.stack.split(`
40
+ `).slice(1).join(`
41
+ `)}`);if(e.context)n.push(` Context: ${JSON.stringify(e.context)}`);return n.join(`
42
+ `)}writeToFile(e){this.writeQueue=this.writeQueue.then(async()=>{try{let n=await import("node:fs"),r=await import("node:path"),t=r.dirname(this.logFilePath);if(!n.existsSync(t))n.mkdirSync(t,{recursive:!0});await this.rotateIfNeeded(n);let s=`${this.formatEntry(e)}
43
+ `;n.appendFileSync(this.logFilePath,s,"utf-8")}catch(n){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",n)}})}async rotateIfNeeded(e){try{if(!e.existsSync(this.logFilePath))return;if(e.statSync(this.logFilePath).size<this.maxFileSize)return;for(let r=this.maxLogFiles-1;r>=1;r--){let t=`${this.logFilePath}.${r}`,s=`${this.logFilePath}.${r+1}`;if(e.existsSync(t))if(r>=this.maxLogFiles-1)e.unlinkSync(t);else e.renameSync(t,s)}if(this.maxLogFiles<=1)e.writeFileSync(this.logFilePath,"");else e.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(n){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",n)}}getRecentErrors(e=10){return this.errors.slice(-e)}getErrorsByType(e){return this.errors.filter((n)=>n.error.constructor.name===e)}getErrorsByLevel(e){return this.errors.filter((n)=>n.level===e)}clear(){this.errors.length=0}async clearLogFile(){try{let e=await import("node:fs");if(e.existsSync(this.logFilePath))e.writeFileSync(this.logFilePath,"","utf-8")}catch(e){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",e)}}getStats(){let e={},n={error:0,warning:0,info:0};for(let r of this.errors){let t=r.error.constructor.name;e[t]=(e[t]||0)+1;let s=r.level||"error";n[s]=(n[s]||0)+1}return{total:this.errors.length,byType:e,byLevel:n}}async exportToFile(e,n="json"){let r=await import("node:fs"),t=await import("node:path"),s=t.dirname(e);if(!r.existsSync(s))r.mkdirSync(s,{recursive:!0});if(n==="json"){let i=this.errors.map((o)=>({timestamp:o.timestamp.toISOString(),level:o.level||"error",type:o.error.constructor.name,message:o.error.message,stack:o.error.stack,context:o.context}));r.writeFileSync(e,JSON.stringify(i,null,2),"utf-8")}else{let i=this.errors.map((o)=>this.formatEntry(o));r.writeFileSync(e,i.join(`
44
+
45
+ `),"utf-8")}}async flush(){await this.writeQueue}}var Jn=new Ke;var Xn={maxSanitizeDepth:10,allowBracketNotation:!1},fi={...Xn};var Zn="__stx_safe_ctors",Ct=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],Yn=[...Ct,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],mi=Yn.map(()=>{return}),gi=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is}));var hi=new Set([...Ct,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",Zn]);var Tt=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],xi=(()=>{let e={Date,URL,URLSearchParams},n=Intl;for(let r of Tt)if(typeof n[r]==="function")e[`Intl_${r}`]=n[r];return Object.freeze(Object.assign(Object.create(null),e))})();var bi=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Tt.join(",")}}() are allowed`;var yi=Symbol("stx.sanitizeCache");var Si=`stx-compile-probe:${globalThis.crypto.randomUUID()}`;var vi=new Se(2000,{maxBytes:2097152,sizeOf:(e)=>e.sourceBytes});function ve(e,n,r,t){if(e[n]!==r)return-1;let s=0,i=null;for(let o=n;o<e.length;o++){let a=e[o];if(i){if(a==="\\"){o++;continue}if(a===i)i=null;continue}if(a==="'"||a==='"'||a==="`"){i=a;continue}if(a===r)s++;else if(a===t){if(t===">"&&e[o-1]==="=")continue;if(s--,s===0)return o+1}}return-1}var Rt=require("node:module");var eo=new Set(Rt.builtinModules);function Ue(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function Ge(e){for(let n of ue(Ue(e))){let r=pe(n.attrs);if(!r.has("component")&&!r.has("stx:component"))continue;return{code:e.slice(n.bodyStart,n.bodyEnd),start:n.bodyStart,open:n.start}}}function Ot(e,n){let r=Ge(e);if(!r)return{};let t=r.code.trim();if(!t)return{};try{let s=JSON.parse(t);if(!s||typeof s!=="object"||Array.isArray(s))throw Error("expected a JSON object");return s}catch(s){throw Error(`${n}: <script component> must contain JSON metadata (${s.message})`)}}function Je(e,n){let r=j(e),t=new Set(Ce(e).map((c)=>c.start)),s=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,i=[],o=n?void 0:new Bun.Transpiler({loader:"ts"}),a;while(a=s.exec(r)){if(!t.has(a.index+a[0].indexOf("function")))continue;let c=s.lastIndex;while(/\s/.test(r[c]||""))c++;let l=c;if(r[c]==="<")c=ve(r,c,"<",">");if(c<0)continue;let p=e.slice(l,c).trim();while(/\s/.test(r[c]||""))c++;if(r[c]!=="(")continue;let x=c,b=ve(r,c,"(",")");if(b<0)continue;for(c=b;c<e.length;c++){let _=r[c];if(_!=="{"&&_!==";")continue;let A=e.slice(a.index,c).trim();if(n){if(!n(A,_,a[1]))continue}else{let d;try{d=o.transformSync(A+(_==="{"?"{}":";"))}catch{continue}if(_==="{"&&!d.includes(`function ${a[1]}(`))continue;if(_===";"&&d.trim())continue}let C=_==="{"?ve(r,c,"{","}"):c+1;if(C<0)break;i.push({name:a[1],header:A,generic:p,parameterOffset:x+1,parameters:e.slice(x+1,b-1),returns:e.slice(b,c).trim().replace(/^:\s*/,""),async:/\basync\s+function/.test(a[0]),..._==="{"?{source:e.slice(a.index,C)}:{}}),s.lastIndex=C;break}}return i}function Me(e,n){if(e[n]!=="(")return null;let r=0,t="";for(let s=n;s<e.length;s++){let i=e[s];if(t!==""){if(i==="\\")s++;else if(i===t)t="";continue}if(i==="'"||i==='"'||i==="`"){t=i;continue}if(i==="(")r++;else if(i===")"){if(r--,r===0)return{expression:e.slice(n+1,s),end:s+1}}}return null}function Pt(e){let n=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec(e.trim());return n?{iterable:n[1],key:n[2],value:n[3]}:void 0}function qe(e){if(!e||typeof e!=="object")return"unknown";switch(e.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}var nr=new Set(Pe);function Ie(e){let n=he(e),r=n.find((x)=>x.name==="InheritedContext");if(!r)return;let t=/^(?:interface\s+InheritedContext|type\s+InheritedContext\s*=)\s*\{/.test(j(r.text).trim()),s=j(e),i=U(s).depths,o=[...s.matchAll(/\b(?:interface|type)\s+InheritedContext\b/g)].find((x)=>i[x.index]===0)?.index??0,a=r.text.slice(r.text.indexOf("{")+1,r.text.lastIndexOf("}")),c=j(a),l=U(c).depths,p=[...c.matchAll(/(?:^|[;,\n])\s*(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:/g)].filter((x)=>l[x.index]===0).map((x)=>x[1]);return{keys:t?p:[],types:n.map((x)=>x.text).join(`
46
+ `),offset:Math.max(0,o),...!t?{unsupported:"InheritedContext requires a local non-generic object interface or object type alias with named properties"}:{}}}function rr(e){let n=[],r=j(e);for(let t of e.matchAll(/\bimport\s+(type\s+)?([\w$*{}\s,]+?)\s+from\s*(['"])([^'"]+)\3/g)){if(t[1]||r.slice(t.index,t.index+6)!=="import")continue;let s=t[2].trim(),i=["stx","@stacksjs/stx"].includes(t[4]);if(/^[A-Za-z_$][\w$]*$/.test(s)){n.push(s);continue}if(!s.startsWith("{")||!s.endsWith("}"))continue;for(let o of s.slice(1,-1).split(",")){if(/^\s*type\s+/.test(o))continue;let[a,c=a]=o.trim().split(/\s+as\s+/);if(c&&!(i&&nr.has(a)))n.push(c)}}return n}function Mt(e){let n=Ie(e);if(!n||n.unsupported)return"";let r=new Set(ae(e));return n.keys.filter((t)=>!r.has(t)).map((t)=>`declare const ${t}: InheritedContext[${JSON.stringify(t)}];`).join(`
47
+ `)}function It(e,n){let r=[Ae],t=[],s=new Map,i=J.default.resolve(n.filePath),o=i.split(J.default.sep).lastIndexOf("views"),a=o>=0?i.split(J.default.sep).slice(0,o).join(J.default.sep):J.default.dirname(i),c=J.default.resolve(n.partialsDir||J.default.join(a,"partials")),l=J.default.resolve(n.layoutsDir||J.default.join(a,"views/layouts"));if([c,l].some((d)=>i===d||i.startsWith(d+J.default.sep)))return{declarations:"",checks:t,dependencies:s};let p=(d)=>n.readTemplate?.(d)??(Xe.default.existsSync(d)?Xe.default.readFileSync(d,"utf8"):void 0),x=0,b=!1,_=[];function A(d,f){let w=e.slice(0,d).split(`
48
+ `).length,h=d-e.lastIndexOf(`
49
+ `,d-1),u={code:e.slice(d,e.indexOf(`
50
+ `,d)<0?e.length:e.indexOf(`
51
+ `,d)),line:w,column:h,kind:"directive",offset:d,anchor:!0};t.push({expression:u,statement:{text:`;${f}`,prefixLength:1}})}function C(d,f,w,h,u,m){let E=`__StxInherited${x++}`;while((e+d+[...s.values()].join("")).includes(E))E+="_";let R=me(d).filter((D)=>D.kind==="server").map((D)=>D.code).join(`
52
+ `),v=`${E}ParentValue`,O=`${E}ParentType`;r.push(`type ${O} = ${w};`);let M=Ze(Le(R,J.default.dirname(f)),E);r.push(...M.imports);let I=Ie(R);if(I&&u!==void 0){b=!0;let D=M.imports.length?M.aliases.join(`
53
+ `):"",W=Re(`${D}
48
54
  ${I.types}
49
- const __contract = defineProps<InheritedContext>();`,`${w}Contract`);s.push(H.declarations),s.push(`declare const ${w}Input: ${P};`),A(u,I.unsupported?`({})[${JSON.stringify(I.unsupported)}];`:`${w}Input satisfies ${H.props};`)}let M=[...new Set([...ae(R),...Ln(R)])],z=[...new Set([...h,...I?.keys||[]])].filter((N)=>!M.includes(N)),W=I?`${P} & ${w}Contract.__StxProps`:P,J=Pe(O.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),G=[],ee=ge(p),se=/@(include|extends|layout)\s*\(/g,Z;while(Z=se.exec(ee)){let N=Ae(ee,se.lastIndex-1);if(!N)continue;se.lastIndex=N.end;let H=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(N.expression);if(!H){_.push({offset:u??Z.index,message:`Inherited context cannot be checked across dynamic @${Z[1]}`});continue}let Y=H[2],B=Z[1];if(B!=="include"&&H[3])_.push({offset:u??Z.index,message:`Inherited context cannot be checked for unsupported @${B} data arguments`});let Te=B==="include"?o:l,xe=U.default.resolve(Y.startsWith(".")?U.default.dirname(f):Te,Y.endsWith(".stx")?Y:Y+".stx");if(d(xe)===void 0){_.push({offset:u??Z.index,message:`Inherited context target cannot be resolved: ${Y}`});continue}G.push({name:`edge${G.length}`,target:xe,kind:B,args:B==="include"?H[3]||"{}":"{}",offset:u??Z.index})}let le=`{ ...${v}${M.length?", "+M.join(", "):""} }`;s.push(`namespace ${w} {
50
- ${O.aliases.join(`
55
+ const __contract = defineProps<InheritedContext>();`,`${E}Contract`);r.push(W.declarations),r.push(`declare const ${E}Input: ${O};`),A(u,I.unsupported?`({})[${JSON.stringify(I.unsupported)}];`:`${E}Input satisfies ${W.props};`)}let P=[...new Set([...ae(R),...rr(R)])],B=[...new Set([...h,...I?.keys||[]])].filter((D)=>!P.includes(D)),K=I?`${O} & ${E}Contract.__StxProps`:O,q=Ne(M.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),G=[],ee=ge(d),re=/@(include|extends|layout)\s*\(/g,X;while(X=re.exec(ee)){let D=Me(ee,re.lastIndex-1);if(!D)continue;re.lastIndex=D.end;let W=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(D.expression);if(!W){_.push({offset:u??X.index,message:`Inherited context cannot be checked across dynamic @${X[1]}`});continue}let Y=W[2],F=X[1];if(F!=="include"&&W[3])_.push({offset:u??X.index,message:`Inherited context cannot be checked for unsupported @${F} data arguments`});let ke=F==="include"?c:l,xe=J.default.resolve(Y.startsWith(".")?J.default.dirname(f):ke,Y.endsWith(".stx")?Y:Y+".stx");if(p(xe)===void 0){_.push({offset:u??X.index,message:`Inherited context target cannot be resolved: ${Y}`});continue}G.push({name:`edge${G.length}`,target:xe,kind:F,args:F==="include"?W[3]||"{}":"{}",offset:u??X.index})}let le=`{ ...${v}${P.length?", "+P.join(", "):""} }`;r.push(`namespace ${E} {
56
+ ${M.aliases.join(`
51
57
  `)}
52
- export async function read(${v}: ${u===void 0?"{}":W}) {
53
- ${z.length?`const { ${z.join(", ")} } = ${v};`:""}
54
- ${J}
55
- return { context: ${le}${G.map((N)=>`, ${N.name}: { ...${le}, ...(${N.args}) }`).join("")} };
58
+ export async function read(${v}: ${u===void 0?"{}":K}) {
59
+ ${B.length?`const { ${B.join(", ")} } = ${v};`:""}
60
+ ${q}
61
+ return { context: ${le}${G.map((D)=>`, ${D.name}: { ...${le}, ...(${D.args}) }`).join("")} };
56
62
  }
57
- }`);for(let N of G){if(m.includes(N.target)||m.length>=32){_.push({offset:N.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let H=d(N.target);i.set(N.target,H),C(H,N.target,`Awaited<ReturnType<typeof ${w}.read>>[${JSON.stringify(N.name)}]`,[...new Set([...h,...M])],N.offset,[...m,N.target])}return w}if(C(e,r,"{}",[],void 0,[r]),b||n.contractsKnown)for(let p of _)A(p.offset,`({})[${JSON.stringify(p.message)}];`);return{declarations:b?s.join(`
58
- `):"",checks:t,dependencies:i}}function At(e,n){let s=Ke(e),t=We(e);if(!t)return;let i;try{i=_t(e,"component")}catch(u){let m=t.open,w=u instanceof Error?u.message:"Invalid component metadata";return{declarations:"",checks:[{text:`({})[${JSON.stringify(w)}];`,line:e.slice(0,m).split(`
63
+ }`);for(let D of G){if(m.includes(D.target)||m.length>=32){_.push({offset:D.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let W=p(D.target);s.set(D.target,W),C(W,D.target,`Awaited<ReturnType<typeof ${E}.read>>[${JSON.stringify(D.name)}]`,[...new Set([...h,...P])],D.offset,[...m,D.target])}return E}if(C(e,i,"{}",[],void 0,[i]),b||n.contractsKnown)for(let d of _)A(d.offset,`({})[${JSON.stringify(d.message)}];`);return{declarations:b?r.join(`
64
+ `):"",checks:t,dependencies:s}}function Nt(e,n){let r=Ue(e),t=Ge(e);if(!t)return;let s;try{s=Ot(e,"component")}catch(u){let m=t.open,E=u instanceof Error?u.message:"Invalid component metadata";return{declarations:"",checks:[{text:`({})[${JSON.stringify(E)}];`,line:e.slice(0,m).split(`
59
65
  `).length,column:m-e.lastIndexOf(`
60
- `,m-1),origin:"component"}],project:(R)=>({code:R,columns:new Map})}}let r=ue(s).filter((u)=>{let m=pe(u.attrs);return ye(m)&&m.has("client")&&!m.has("server")&&!m.has("component")&&!m.has("stx:component")&&!m.has("src")}),a=r.map((u)=>e.slice(u.bodyStart,u.bodyEnd)).join(`
61
- `),c=Ge(a,n),o=he(a).some((u)=>u.name==="ComponentState")||Oe(a).includes("ComponentState"),l=Object.entries(i.properties||i.props||{}).map(([u,m])=>`${JSON.stringify(u)}: ${Ue(m)}`).join("; "),d=[...new Set(c.map((u)=>u.name))],x=[`interface __StxMetadataProperties { ${l} }`,"type __StxNativeProperties = Omit<__StxMetadataProperties, keyof HTMLElement> & Pick<HTMLElement, Extract<keyof __StxMetadataProperties, keyof HTMLElement>>;","type __StxAny<T> = 0 extends (1 & T) ? true : false;","type __StxAnyFields<T> = { [K in keyof T]-?: __StxAny<T[K]> extends true ? K : never }[keyof T];","type __StxSpecific<T> = __StxAny<T> extends true ? false : T extends object ? string extends keyof T ? false : number extends keyof T ? false : symbol extends keyof T ? false : __StxAnyFields<T> extends never ? true : false : false;",o?"type __StxState = __StxSpecific<ComponentState> extends true ? ComponentState : {};":"type __StxState = {};",o?'declare function __stxSpecificState(value: __StxSpecific<ComponentState> extends true ? true : "ComponentState requires named explicit fields without any or index signatures"): void;':"",o?"declare const __stxStateProperties: Pick<ComponentState, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;":"",o?'declare function __stxStateMethods(value: Extract<keyof ComponentState, __StxMethodNames | "emit" | "requestUpdate" | "updateComplete" | "renderRoot"> extends never ? true : "ComponentState cannot redeclare component methods"): void;':"",`type __StxMethodNames = ${d.map((u)=>JSON.stringify(u)).join(" | ")||"never"};`,"type __StxInstanceProperties = Omit<HTMLElement, __StxMethodNames | keyof __StxNativeProperties> & __StxNativeProperties;",'type __StxPrivateKeys<T> = Exclude<keyof T, keyof HTMLElement | keyof __StxNativeProperties | __StxMethodNames | "emit" | "updateComplete" | "requestUpdate" | "renderRoot">;',o?'declare function __stxOptionalPrivate(value: { [K in __StxPrivateKeys<ComponentState>]-?: {} extends Pick<ComponentState, K> ? never : K }[__StxPrivateKeys<ComponentState>] extends never ? true : "Private ComponentState fields must be optional until initialized"): void;':"","type __StxRefinedProperties = { [K in keyof __StxNativeProperties]: K extends keyof __StxState ? __StxAny<__StxState[K]> extends true ? __StxNativeProperties[K] : __StxState[K] extends __StxNativeProperties[K] ? __StxState[K] : __StxNativeProperties[K] : __StxNativeProperties[K] };","type __StxNativeComponent = Omit<HTMLElement, keyof __StxNativeProperties | __StxMethodNames> & __StxRefinedProperties & Partial<Pick<__StxState, __StxPrivateKeys<__StxState>>> & {","readonly updateComplete: Promise<void>; requestUpdate(): Promise<void>; readonly renderRoot: HTMLElement | ShadowRoot;","emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean;",...d.map((u)=>`${JSON.stringify(u)}: typeof ${u};`),"}"].filter(Boolean).join(`
62
- `),b=-1;for(let u of r){let m=u.bodyStart,w=e.slice(m,u.bodyEnd),R=L(w),v=q(R).depths,P=[...R.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((O)=>v[O.index]===0)??(Oe(w).includes("ComponentState")?/\bComponentState\b/.exec(R):void 0);if(P){b=m+P.index;break}}let _=o&&b>=0?[{origin:"client",text:"__stxSpecificState(true); __stxStateMethods(true); __stxOptionalPrivate(true); __stxStateProperties satisfies Pick<__StxInstanceProperties, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;",line:e.slice(0,b).split(`
66
+ `,m-1),origin:"component"}],project:(R)=>({code:R,columns:new Map})}}let i=ue(r).filter((u)=>{let m=pe(u.attrs);return ye(m)&&m.has("client")&&!m.has("server")&&!m.has("component")&&!m.has("stx:component")&&!m.has("src")}),o=i.map((u)=>e.slice(u.bodyStart,u.bodyEnd)).join(`
67
+ `),a=Je(o,n),c=he(o).some((u)=>u.name==="ComponentState")||De(o).includes("ComponentState"),l=Object.entries(s.properties||s.props||{}).map(([u,m])=>`${JSON.stringify(u)}: ${qe(m)}`).join("; "),p=[...new Set(a.map((u)=>u.name))],x=[`interface __StxMetadataProperties { ${l} }`,"type __StxNativeProperties = Omit<__StxMetadataProperties, keyof HTMLElement> & Pick<HTMLElement, Extract<keyof __StxMetadataProperties, keyof HTMLElement>>;","type __StxAny<T> = 0 extends (1 & T) ? true : false;","type __StxAnyFields<T> = { [K in keyof T]-?: __StxAny<T[K]> extends true ? K : never }[keyof T];","type __StxSpecific<T> = __StxAny<T> extends true ? false : T extends object ? string extends keyof T ? false : number extends keyof T ? false : symbol extends keyof T ? false : __StxAnyFields<T> extends never ? true : false : false;",c?"type __StxState = __StxSpecific<ComponentState> extends true ? ComponentState : {};":"type __StxState = {};",c?'declare function __stxSpecificState(value: __StxSpecific<ComponentState> extends true ? true : "ComponentState requires named explicit fields without any or index signatures"): void;':"",c?"declare const __stxStateProperties: Pick<ComponentState, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;":"",c?'declare function __stxStateMethods(value: Extract<keyof ComponentState, __StxMethodNames | "emit" | "requestUpdate" | "updateComplete" | "renderRoot"> extends never ? true : "ComponentState cannot redeclare component methods"): void;':"",`type __StxMethodNames = ${p.map((u)=>JSON.stringify(u)).join(" | ")||"never"};`,"type __StxInstanceProperties = Omit<HTMLElement, __StxMethodNames | keyof __StxNativeProperties> & __StxNativeProperties;",'type __StxPrivateKeys<T> = Exclude<keyof T, keyof HTMLElement | keyof __StxNativeProperties | __StxMethodNames | "emit" | "updateComplete" | "requestUpdate" | "renderRoot">;',c?'declare function __stxOptionalPrivate(value: { [K in __StxPrivateKeys<ComponentState>]-?: {} extends Pick<ComponentState, K> ? never : K }[__StxPrivateKeys<ComponentState>] extends never ? true : "Private ComponentState fields must be optional until initialized"): void;':"","type __StxRefinedProperties = { [K in keyof __StxNativeProperties]: K extends keyof __StxState ? __StxAny<__StxState[K]> extends true ? __StxNativeProperties[K] : __StxState[K] extends __StxNativeProperties[K] ? __StxState[K] : __StxNativeProperties[K] : __StxNativeProperties[K] };","type __StxNativeComponent = Omit<HTMLElement, keyof __StxNativeProperties | __StxMethodNames> & __StxRefinedProperties & Partial<Pick<__StxState, __StxPrivateKeys<__StxState>>> & {","readonly updateComplete: Promise<void>; requestUpdate(): Promise<void>; readonly renderRoot: HTMLElement | ShadowRoot;","emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean;",...p.map((u)=>`${JSON.stringify(u)}: typeof ${u};`),"}"].filter(Boolean).join(`
68
+ `),b=-1;for(let u of i){let m=u.bodyStart,E=e.slice(m,u.bodyEnd),R=j(E),v=U(R).depths,O=[...R.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((M)=>v[M.index]===0)??(De(E).includes("ComponentState")?/\bComponentState\b/.exec(R):void 0);if(O){b=m+O.index;break}}let _=c&&b>=0?[{origin:"client",text:"__stxSpecificState(true); __stxStateMethods(true); __stxOptionalPrivate(true); __stxStateProperties satisfies Pick<__StxInstanceProperties, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;",line:e.slice(0,b).split(`
63
69
  `).length,column:b-e.lastIndexOf(`
64
- `,b-1)}]:[],{start:A,code:C}=t,p=L(C),f=q(p).depths,T=new Map,h=!1;for(let u of C.matchAll(/"(?:\\.|[^"\\])*"\s*:/g)){let m=JSON.parse(u[0].slice(0,u[0].lastIndexOf(":")).trim());if(f[u.index]===1&&["properties","props"].includes(m)){h=!0;continue}if(h&&f[u.index]===1)h=!1;if(h&&f[u.index]===2&&!T.has(m))T.set(m,A+u.index)}for(let[u,m]of Object.entries(i.properties||i.props||{})){let w=T.get(u)??A,R=e.slice(0,w).split(`
65
- `).length,v=w-e.lastIndexOf(`
66
- `,w-1);if(!m||typeof m!=="object"||!["string","number","boolean","object","array"].includes(m.type))_.push({text:`({})[${JSON.stringify(`Property ${u} must declare string, number, boolean, object or array`)}];`,line:R,column:v,origin:"component"});if(m&&m.default!==void 0)_.push({text:`const __stxDefault${_.length}: ${Ue(m)} = ${JSON.stringify(m.default)};`,line:R,column:v,origin:"component"})}return{declarations:x,checks:_,project(u){let m=new Map,w=[],R=0;for(let v of Ge(u,n)){if(/^\s*this\s*:/.test(v.parameters))continue;let P=v.parameterOffset,O=`this: __StxNativeComponent${v.parameters.trim()?", ":""}`;w.push(u.slice(R,P),O);let I=u.slice(0,P).split(`
67
- `).length,M=P-u.lastIndexOf(`
68
- `,P-1),z=m.get(I)||[],W=z.at(-1),J=M+(W?W.generatedEnd-W.sourceEnd:0);z.push({sourceStart:M,sourceEnd:M,generatedStart:J,generatedEnd:J+O.length}),m.set(I,z),R=P}return w.push(u.slice(R)),{code:w.join(""),columns:m}}}}function Rt(e){let n=[],s=[],t=/@foreach\s*\(|@endforeach\b/g,i;while(i=t.exec(e)){if(i[0].startsWith("@endforeach")){let o=s.pop();if(o)o.end=i.index,n.push(o);continue}let r=Ae(e,t.lastIndex-1);if(!r)continue;let a=Et(r.expression),c=r.end;if(a)s.push({start:c,end:e.length,iterable:a.iterable,binding:a.key?`${a.value}, ${a.key}`:a.value});t.lastIndex=c}return n.sort((r,a)=>r.start-a.start)}function Pt(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))return[];let n=[],s=[],t=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let i of e.matchAll(t)){let r=i[0];if(/^<\/template\s*>$/i.test(r)){let a=s.pop();if(a)a.end=i.index}else if(/^<template\b/i.test(r)&&!/\/\s*>$/.test(r)){let c=[...r.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((d)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(d[1])),o=(c?.[2]??c?.[3])?.trim();if(o&&c?.[1]==="data-stx-slot-binding")try{o=decodeURIComponent(o)}catch{o=void 0}let l=o?{start:i.index+r.length,end:e.length,binding:o}:void 0;if(s.push(l),l)n.push(l)}}return n}function Bn(e){let n=(s)=>s.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,n).replace(/\{\{--[\s\S]*?--\}\}/g,n)}function me(e){let n=[],s=Bn(e);for(let t of ue(s)){let i=t.attrs.trim(),r=pe(i),{bodyStart:a,bodyEnd:c}=t,o=e.slice(a,c);if(r.has("src")||r.has("component")||r.has("stx:component"))continue;if(!ye(r))continue;let l=r.has("server")?"server":r.has("client")?"client":"plain",d=Se(e,a);n.push({kind:l,code:o,startLine:d,startColumn:ve(e,a),offset:a,attrs:i})}return n}function Se(e,n){let s=1;for(let t=0;t<n&&t<e.length;t++)if(e.charCodeAt(t)===10)s++;return s}function ve(e,n){let s=e.lastIndexOf(`
69
- `,n-1)+1;return n-s+1}function ge(e){let n=e.split(""),s=(i,r)=>{for(let a=i;a<r&&a<n.length;a++)if(n[a]!==`
70
- `)n[a]=" "},t=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let i of t){i.lastIndex=0;let r;while((r=i.exec(e))!==null)s(r.index,r.index+r[0].length)}return n.join("")}function Nt(e){let n=0,s="";for(let t=0;t<e.length;t++){let i=e[t];if(s){if(i==="\\"){t++;continue}if(i===s)s="";continue}if(i==='"'||i==="'"||i==="`"){s=i;continue}if(i==="("||i==="["||i==="{"){n++;continue}if(i===")"||i==="]"||i==="}"){n--;continue}if(i==="|"&&n===0){if(e[t+1]==="|"){t++;continue}if(e[t-1]==="|")continue;return e.slice(0,t)}}return e}var Lt=new Set([":for","x-for","v-for"]),Ie=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,Ye="__stx_interpolated",Mt="__StxElement",Bt="__StxTemplateValue",zn=`type ${Bt}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function Ot(e){return e.replace(/\{\{[\s\S]*?\}\}/g,Ye).replace(/\{!![\s\S]*?!!\}/g,Ye)}function Vn(e,n,s){let t=0;for(let i=n;i<e.length;i++){let r=e[i];if(r==="{"){t++;continue}if(r!=="}"&&r!=="!")continue;if(e.startsWith(s,i)&&t===0)return i;if(r==="}"&&t>0)t--}return-1}function Fn(e,n,s="0"){let t=`__stxScript${s}`;while((e+n).includes(t))t+="_";let i=new Map,r=[],a=[],c=L(e),o=we(e),l=[],d=0;for(let C=0;C<c.length;C++){let p=c.startsWith("{{",C);if(!p&&!c.startsWith("{!!",C))continue;let f=p?2:3,T=p?"}}":"!!}",h=Vn(c,C+f,T);if(h<0)continue;let u=C,m=e.slice(u,h+T.length),w=m.slice(f,-T.length);C=h+T.length-1;let R=a.length,v=ce(o,u),P=ce(o,u+(p?2:3));a.push({code:Nt(w),...P});let O=`${t}_${R}`,I=m.split(`
71
- `),M=I[0].length;I[0]=O+" ".repeat(Math.max(0,M-O.length));for(let G=1;G<I.length;G++)I[G]=I[G].replace(/[^\r]/g," ");let z=i.get(v.line)??[],W=z.at(-1),J=v.column+(W?W.generatedEnd-W.sourceEnd:0);z.push({sourceStart:v.column,sourceEnd:v.column+M,generatedStart:J,generatedEnd:J+I[0].length}),i.set(v.line,z),l.push(e.slice(d,u),I.join(`
72
- `)),d=u+m.length}l.push(e.slice(d));let x=l.join("");if(!a.length)return{code:x,columns:i,declarations:r};let{imports:b,aliases:_,body:A}=Ze(n,t);for(let C of b)r.push({text:C});r.push({text:`namespace ${t}Scope {
70
+ `,b-1)}]:[],{start:A,code:C}=t,d=j(C),f=U(d).depths,w=new Map,h=!1;for(let u of C.matchAll(/"(?:\\.|[^"\\])*"\s*:/g)){let m=JSON.parse(u[0].slice(0,u[0].lastIndexOf(":")).trim());if(f[u.index]===1&&["properties","props"].includes(m)){h=!0;continue}if(h&&f[u.index]===1)h=!1;if(h&&f[u.index]===2&&!w.has(m))w.set(m,A+u.index)}for(let[u,m]of Object.entries(s.properties||s.props||{})){let E=w.get(u)??A,R=e.slice(0,E).split(`
71
+ `).length,v=E-e.lastIndexOf(`
72
+ `,E-1);if(!m||typeof m!=="object"||!["string","number","boolean","object","array"].includes(m.type))_.push({text:`({})[${JSON.stringify(`Property ${u} must declare string, number, boolean, object or array`)}];`,line:R,column:v,origin:"component"});if(m&&m.default!==void 0)_.push({text:`const __stxDefault${_.length}: ${qe(m)} = ${JSON.stringify(m.default)};`,line:R,column:v,origin:"component"})}return{declarations:x,checks:_,project(u){let m=new Map,E=[],R=0;for(let v of Je(u,n)){if(/^\s*this\s*:/.test(v.parameters))continue;let O=v.parameterOffset,M=`this: __StxNativeComponent${v.parameters.trim()?", ":""}`;E.push(u.slice(R,O),M);let I=u.slice(0,O).split(`
73
+ `).length,P=O-u.lastIndexOf(`
74
+ `,O-1),B=m.get(I)||[],K=B.at(-1),q=P+(K?K.generatedEnd-K.sourceEnd:0);B.push({sourceStart:P,sourceEnd:P,generatedStart:q,generatedEnd:q+M.length}),m.set(I,B),R=O}return E.push(u.slice(R)),{code:E.join(""),columns:m}}}}function Lt(e){let n=[],r=[],t=/@foreach\s*\(|@endforeach\b/g,s;while(s=t.exec(e)){if(s[0].startsWith("@endforeach")){let c=r.pop();if(c)c.end=s.index,n.push(c);continue}let i=Me(e,t.lastIndex-1);if(!i)continue;let o=Pt(i.expression),a=i.end;if(o)r.push({start:a,end:e.length,iterable:o.iterable,binding:o.key?`${o.value}, ${o.key}`:o.value});t.lastIndex=a}return n.sort((i,o)=>i.start-o.start)}function Dt(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))return[];let n=[],r=[],t=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let s of e.matchAll(t)){let i=s[0];if(/^<\/template\s*>$/i.test(i)){let o=r.pop();if(o)o.end=s.index}else if(/^<template\b/i.test(i)&&!/\/\s*>$/.test(i)){let a=[...i.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((p)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(p[1])),c=(a?.[2]??a?.[3])?.trim();if(c&&a?.[1]==="data-stx-slot-binding")try{c=decodeURIComponent(c)}catch{c=void 0}let l=c?{start:s.index+i.length,end:e.length,binding:c}:void 0;if(r.push(l),l)n.push(l)}}return n}function sr(e){let n=(r)=>r.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,n).replace(/\{\{--[\s\S]*?--\}\}/g,n)}function me(e){let n=[],r=sr(e);for(let t of ue(r)){let s=t.attrs.trim(),i=pe(s),{bodyStart:o,bodyEnd:a}=t,c=e.slice(o,a);if(i.has("src")||i.has("component")||i.has("stx:component"))continue;if(!ye(i))continue;let l=i.has("server")?"server":i.has("client")?"client":"plain",p=Ee(e,o);n.push({kind:l,code:c,startLine:p,startColumn:we(e,o),offset:o,attrs:s})}return n}function Ee(e,n){let r=1;for(let t=0;t<n&&t<e.length;t++)if(e.charCodeAt(t)===10)r++;return r}function we(e,n){let r=e.lastIndexOf(`
75
+ `,n-1)+1;return n-r+1}function ge(e){let n=e.split(""),r=(s,i)=>{for(let o=s;o<i&&o<n.length;o++)if(n[o]!==`
76
+ `)n[o]=" "},t=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let s of t){s.lastIndex=0;let i;while((i=s.exec(e))!==null)r(i.index,i.index+i[0].length)}return n.join("")}function Wt(e){let n=0,r="";for(let t=0;t<e.length;t++){let s=e[t];if(r){if(s==="\\"){t++;continue}if(s===r)r="";continue}if(s==='"'||s==="'"||s==="`"){r=s;continue}if(s==="("||s==="["||s==="{"){n++;continue}if(s===")"||s==="]"||s==="}"){n--;continue}if(s==="|"&&n===0){if(e[t+1]==="|"){t++;continue}if(e[t-1]==="|")continue;return e.slice(0,t)}}return e}var Ht=new Set([":for","x-for","v-for"]),je=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,et="__stx_interpolated",jt="__StxElement",Kt="__StxTemplateValue",ir=`type ${Kt}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function Ft(e){return e.replace(/\{\{[\s\S]*?\}\}/g,et).replace(/\{!![\s\S]*?!!\}/g,et)}function or(e,n,r){let t=0;for(let s=n;s<e.length;s++){let i=e[s];if(i==="{"){t++;continue}if(i!=="}"&&i!=="!")continue;if(e.startsWith(r,s)&&t===0)return s;if(i==="}"&&t>0)t--}return-1}function ar(e,n,r="0"){let t=`__stxScript${r}`;while((e+n).includes(t))t+="_";let s=new Map,i=[],o=[],a=j(e),c=$e(e),l=[],p=0;for(let C=0;C<a.length;C++){let d=a.startsWith("{{",C);if(!d&&!a.startsWith("{!!",C))continue;let f=d?2:3,w=d?"}}":"!!}",h=or(a,C+f,w);if(h<0)continue;let u=C,m=e.slice(u,h+w.length),E=m.slice(f,-w.length);C=h+w.length-1;let R=o.length,v=ce(c,u),O=ce(c,u+(d?2:3));o.push({code:Wt(E),...O});let M=`${t}_${R}`,I=m.split(`
77
+ `),P=I[0].length;I[0]=M+" ".repeat(Math.max(0,P-M.length));for(let G=1;G<I.length;G++)I[G]=I[G].replace(/[^\r]/g," ");let B=s.get(v.line)??[],K=B.at(-1),q=v.column+(K?K.generatedEnd-K.sourceEnd:0);B.push({sourceStart:v.column,sourceEnd:v.column+P,generatedStart:q,generatedEnd:q+I[0].length}),s.set(v.line,B),l.push(e.slice(p,u),I.join(`
78
+ `)),p=u+m.length}l.push(e.slice(p));let x=l.join("");if(!o.length)return{code:x,columns:s,declarations:i};let{imports:b,aliases:_,body:A}=Ze(n,t);for(let C of b)i.push({text:C});i.push({text:`namespace ${t}Scope {
73
79
  ${_.join(`
74
80
  `)}
75
81
  export async function read() {
76
- ${Pe(A).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
77
- return {`});for(let[C,p]of a.entries())r.push({text:`value${C}: (`}),r.push({text:p.code,origin:{line:p.line,column:p.column}}),r.push({text:"),"});r.push({text:`}
82
+ ${Ne(A).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
83
+ return {`});for(let[C,d]of o.entries())i.push({text:`value${C}: (`}),i.push({text:d.code,origin:{line:d.line,column:d.column}}),i.push({text:"),"});i.push({text:`}
78
84
  }
79
- }`});for(let C=0;C<a.length;C++)r.push({text:`declare var ${t}_${C}: Awaited<ReturnType<typeof ${t}Scope.read>>['value${C}']`});return{code:x,columns:i,declarations:r}}function Ze(e,n){let s=[],{imports:t,body:i}=Zn(e),r=[],a=0;for(let c of t.split(/\n(?=import\b)/)){if(!c.trim())continue;let o=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(c);if(!o){s.push(c);continue}let l=`${n}Module${a++}`;s.push(`import * as ${l} from ${o[2]}`);let d=o[1],x=/\{([\s\S]*?)\}/.exec(d);for(let C of x?.[1].split(",")??[]){let[p,f=p]=C.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(p==="default")r.push(`const ${f} = ${l}.default; type ${f} = import(${o[2]}).default`);else if(p)r.push(`import ${f} = ${l}.${p}`)}let b=d.replace(/\{[\s\S]*?\}/,""),_=/\*\s+as\s+(\w+)/.exec(b);if(_)r.push(`import ${_[1]} = ${l}`);let A=/^\s*([\w$]+)/.exec(b)?.[1];if(A)r.push(`const ${A} = ${l}.default; type ${A} = import(${o[2]}).default`)}return{imports:s,aliases:r,body:i}}function qe(e,n){let s=0;for(let t of e){if(n<t.generatedStart)break;if(n<t.generatedEnd)return t.sourceStart+Math.min(n-t.generatedStart,t.sourceEnd-t.sourceStart);s=t.sourceEnd-t.generatedEnd}return n+s}function Xe(e,n){let s=0;for(let t of e){if(n<t.sourceStart)break;if(n<t.sourceEnd)return t.generatedStart+Math.min(n-t.sourceStart,t.generatedEnd-t.generatedStart);s=t.generatedEnd-t.sourceEnd}return n+s}var Hn=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],Kn=new RegExp(String.raw`^[ \t]*@(?:${Hn.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function Pe(e){return e.replace(Kn,(n)=>n.replace(/[^\n]/g," "))}var It=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function Wn(e){let n=ge(e),s=[],t=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,i;while((i=t.exec(n))!==null){if(i[1]||i[3])continue;let c=i[2]??i[4]??"",o=i[2]!==void 0?2:3,l=Nt(c);if(!l.trim())continue;let d=i.index+o+(l.length-l.trimStart().length);s.push({code:l.trim(),line:Se(n,d),column:ve(n,d),offset:d,kind:"interpolation"})}let r=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((i=r.exec(n))!==null){let a=i.index+i[0].length-1,c=0,o=a;for(;o<n.length;o++){let b=n[o];if(b==="(")c++;else if(b===")"){if(c--,c===0)break}}if(c!==0)continue;let l=n.slice(a+1,o),d=l.trim();if(r.lastIndex=o+1,!d)continue;let x=a+1+(l.length-l.trimStart().length);s.push({code:d,line:Se(n,x),column:ve(n,x),offset:i.index,kind:"condition"})}Ie.lastIndex=0;while((i=Ie.exec(n))!==null){let a=i[1],c=i[3]??"",o=a.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(It.has(o)||It.has(a))continue;if(!c.trim())continue;let l=i.index+i[0].indexOf(i[2],i[0].indexOf(a)+a.length)+1;if(Lt.has(o)){let x=c.match(/\s+(?:in|of)\s+/);if(!x||x.index===void 0)continue;let b=c.slice(x.index+x[0].length),_=x.index+x[0].length+(b.length-b.trimStart().length);s.push({code:Ot(b.trim()),line:Se(n,l+_),column:ve(n,l+_),offset:l+_,kind:"directive",attribute:o});continue}let d=c.length-c.trimStart().length;s.push({code:Ot(c.trim()),line:Se(n,l+d),column:ve(n,l+d),offset:l+d,kind:"directive",attribute:o})}return s.sort((a,c)=>a.line-c.line||a.column-c.column),s}var Gn=2000;function Un(e,n){let s=0,t=Math.min(e.length,n+Gn);for(let i=n;i<t;i++){let r=e[i];if(r==="(")s++;else if(r===")"){if(s--,s===0)return e.slice(n+1,i)}}return null}function Jn(e){let n=new Map,s=(c,o)=>{let l=c.split(/[,[\]{}()\s]+/).filter(Boolean);for(let d of l){let x=d.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(x))continue;let b=l.length===1?o:void 0,_=n.get(x);if(!_)n.set(x,{name:x,iterable:b});else if(_.iterable!==b)_.iterable=void 0}},t=/^\$?[A-Z_$][\w$]*$/i,i=(c)=>{let o=c.trim();return t.test(o)?o:void 0};for(let c of e.matchAll(/@for(?:each|else)\s*\(/g)){let o=Un(e,c.index+c[0].length-1);if(o===null)continue;let l=dt(o);if(!l)continue;s(l.itemVar.replace(/=>/g," "),i(l.arrayExpr))}for(let c of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))s(c[1],c[2]==="of"?i(c[3]):void 0);for(let c of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))s(c[1]);let r=ge(e);Ie.lastIndex=0;let a;while((a=Ie.exec(r))!==null){let c=a[1].replace(/\..*$/,"");if(!Lt.has(c))continue;let o=a[3].match(/\s+(?:in|of)\s+/);if(!o||o.index===void 0)continue;s(a[3].slice(0,o.index),i(a[3].slice(o.index+o[0].length)))}for(let c of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let o of c[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))s(o[1]);return[...n.values()].sort((c,o)=>c.name.localeCompare(o.name))}function ae(e){return pt(e)}var Dt=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"];function zt(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function Zn(e){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,s=[],t=e.replace(n,(i)=>(s.push(i.trim()),i.split(`
85
+ }`});for(let C=0;C<o.length;C++)i.push({text:`declare var ${t}_${C}: Awaited<ReturnType<typeof ${t}Scope.read>>['value${C}']`});return{code:x,columns:s,declarations:i}}function Ze(e,n){let r=[],{imports:t,body:s}=mr(e),i=[],o=0;for(let a of t.split(/\n(?=import\b)/)){if(!a.trim())continue;let c=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(a);if(!c){r.push(a);continue}let l=`${n}Module${o++}`;r.push(`import * as ${l} from ${c[2]}`);let p=c[1],x=/\{([\s\S]*?)\}/.exec(p);for(let C of x?.[1].split(",")??[]){let[d,f=d]=C.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(d==="default")i.push(`const ${f} = ${l}.default; type ${f} = import(${c[2]}).default`);else if(d)i.push(`import ${f} = ${l}.${d}`)}let b=p.replace(/\{[\s\S]*?\}/,""),_=/\*\s+as\s+(\w+)/.exec(b);if(_)i.push(`import ${_[1]} = ${l}`);let A=/^\s*([\w$]+)/.exec(b)?.[1];if(A)i.push(`const ${A} = ${l}.default; type ${A} = import(${c[2]}).default`)}return{imports:r,aliases:i,body:s}}function Ye(e,n){let r=0;for(let t of e){if(n<t.generatedStart)break;if(n<t.generatedEnd)return t.sourceStart+Math.min(n-t.generatedStart,t.sourceEnd-t.sourceStart);r=t.sourceEnd-t.generatedEnd}return n+r}function Qe(e,n){let r=0;for(let t of e){if(n<t.sourceStart)break;if(n<t.sourceEnd)return t.generatedStart+Math.min(n-t.sourceStart,t.generatedEnd-t.generatedStart);r=t.generatedEnd-t.sourceEnd}return n+r}var cr=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],lr=new RegExp(String.raw`^[ \t]*@(?:${cr.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function Ne(e){return e.replace(lr,(n)=>n.replace(/[^\n]/g," "))}var Bt=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function ur(e){let n=ge(e),r=[],t=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,s;while((s=t.exec(n))!==null){if(s[1]||s[3])continue;let a=s[2]??s[4]??"",c=s[2]!==void 0?2:3,l=Wt(a);if(!l.trim())continue;let p=s.index+c+(l.length-l.trimStart().length);r.push({code:l.trim(),line:Ee(n,p),column:we(n,p),offset:p,kind:"interpolation"})}let i=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((s=i.exec(n))!==null){let o=s.index+s[0].length-1,a=0,c=o;for(;c<n.length;c++){let b=n[c];if(b==="(")a++;else if(b===")"){if(a--,a===0)break}}if(a!==0)continue;let l=n.slice(o+1,c),p=l.trim();if(i.lastIndex=c+1,!p)continue;let x=o+1+(l.length-l.trimStart().length);r.push({code:p,line:Ee(n,x),column:we(n,x),offset:s.index,kind:"condition"})}je.lastIndex=0;while((s=je.exec(n))!==null){let o=s[1],a=s[3]??"",c=o.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(Bt.has(c)||Bt.has(o))continue;if(!a.trim())continue;let l=s.index+s[0].indexOf(s[2],s[0].indexOf(o)+o.length)+1;if(Ht.has(c)){let x=a.match(/\s+(?:in|of)\s+/);if(!x||x.index===void 0)continue;let b=a.slice(x.index+x[0].length),_=x.index+x[0].length+(b.length-b.trimStart().length);r.push({code:Ft(b.trim()),line:Ee(n,l+_),column:we(n,l+_),offset:l+_,kind:"directive",attribute:c});continue}let p=a.length-a.trimStart().length;r.push({code:Ft(a.trim()),line:Ee(n,l+p),column:we(n,l+p),offset:l+p,kind:"directive",attribute:c})}return r.sort((o,a)=>o.line-a.line||o.column-a.column),r}var pr=2000;function dr(e,n){let r=0,t=Math.min(e.length,n+pr);for(let s=n;s<t;s++){let i=e[s];if(i==="(")r++;else if(i===")"){if(r--,r===0)return e.slice(n+1,s)}}return null}function fr(e){let n=new Map,r=(a,c)=>{let l=a.split(/[,[\]{}()\s]+/).filter(Boolean);for(let p of l){let x=p.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(x))continue;let b=l.length===1?c:void 0,_=n.get(x);if(!_)n.set(x,{name:x,iterable:b});else if(_.iterable!==b)_.iterable=void 0}},t=/^\$?[A-Z_$][\w$]*$/i,s=(a)=>{let c=a.trim();return t.test(c)?c:void 0};for(let a of e.matchAll(/@for(?:each|else)\s*\(/g)){let c=dr(e,a.index+a[0].length-1);if(c===null)continue;let l=mt(c);if(!l)continue;r(l.itemVar.replace(/=>/g," "),s(l.arrayExpr))}for(let a of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))r(a[1],a[2]==="of"?s(a[3]):void 0);for(let a of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))r(a[1]);let i=ge(e);je.lastIndex=0;let o;while((o=je.exec(i))!==null){let a=o[1].replace(/\..*$/,"");if(!Ht.has(a))continue;let c=o[3].match(/\s+(?:in|of)\s+/);if(!c||c.index===void 0)continue;r(o[3].slice(0,c.index),s(o[3].slice(c.index+c[0].length)))}for(let a of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let c of a[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))r(c[1]);return[...n.values()].sort((a,c)=>a.name.localeCompare(c.name))}function ae(e){return ft(e)}var zt=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"];function Ut(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function mr(e){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,r=[],t=e.replace(n,(s)=>(r.push(s.trim()),s.split(`
80
86
  `).map(()=>"").join(`
81
- `)));return{imports:s.join(`
82
- `),body:t}}function he(e){let n=L(e),s=Array(n.length),t=0;for(let c=0;c<n.length;c++){let o=n[c];if(o==="}"||o===")"||o==="]")t=Math.max(0,t-1);if(s[c]=t,o==="{"||o==="("||o==="[")t++}let i=[],r=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,a;while((a=r.exec(n))!==null){if(s[a.index]!==0)continue;let c=a[1],o=a[2],l;if(c==="interface"){let d=n.indexOf("{",a.index);if(d===-1)continue;let x=0;l=-1;for(let b=d;b<n.length;b++)if(n[b]==="{")x++;else if(n[b]==="}"&&--x===0){l=b+1;break}if(l===-1)continue}else{let d=0;l=n.length;for(let x=n.indexOf("=",a.index)+1;x<n.length;x++){let b=n[x];if(b==="{"||b==="["||b==="("||b==="<")d++;else if(b==="}"||b==="]"||b===")"||b===">")d--;else if(d<=0&&(b===";"||b===`
83
- `&&!/[=|&,<([{]\s*$/.test(n.slice(Math.max(0,x-40),x)))){l=b===";"?x+1:x;break}}}i.push({name:o,text:e.slice(a.index,l).replace(/^[ \t]*export[ \t]+/,"")}),r.lastIndex=l}return i}function qn(e){let n=L(e),s=[],t=/^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+/gm,i,r=0,a=0;while((i=t.exec(n))!==null){for(;a<i.index;a++){let l=n[a];if(l==="{"||l==="("||l==="[")r++;else if(l==="}"||l===")"||l==="]")r=Math.max(0,r-1)}if(r!==0)continue;let c=0,o=n.length;for(let l=i.index+i[0].length;l<n.length;l++){let d=n[l];if(d==="{"||d==="("||d==="[")c++;else if(d==="}"||d===")"||d==="]")c--;else if(c<=0&&(d===";"||d===`
84
- `)){o=d===";"?l+1:l;break}}if(/\bdefineProps\s*(?:<|\()/.test(n.slice(i.index,o)))s.push(e.slice(i.index,o).replace(/^[ \t]*export[ \t]+/,"").trim())}return s}function Xn(e){let n=e.filter((i)=>i.kind==="server").map((i)=>i.code).join(`
85
- `);if(/\bdefineProps\s*(?:<|\()/.test(L(n)))return n;let s=Yn(n),t=e.filter((i)=>i.kind!=="server").flatMap((i)=>{let r=qn(i.code);if(!r.length)return[];return[...he(i.code).filter((a)=>!s.has(a.name)).map((a)=>a.text),...r]});return[n,...t].filter(Boolean).join(`
86
- `)}function Yn(e){return new Set(he(e).map((n)=>n.name))}var jt=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];function Vt(e){let n=new Set,s=new Set;for(let t of e){let i=t.kind==="server"?n:s;for(let r of ae(t.code))i.add(r)}return[...n].filter((t)=>s.has(t)).sort()}var Qn=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function es(e){let n=new Map,s=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let t of e){let i=L(t),{depths:r,balanced:a}=q(i);if(!a)continue;let c=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let o of i.matchAll(c)){let l=o.index??0;if(r[l+o[1].length]!==0)continue;let d=o[2],x=l+o[0].length-o[3].length,b=t.slice(x,l+o[0].length).trim().replace(/;$/,"").trim(),_=o[3],A=s.test(_)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(_)&&!/[,+\-*/%&|?:=]$/.test(b)&&q(_).balanced;n.set(d,n.has(d)||!A?null:b)}}return new Map([...n].filter((t)=>t[1]!==null))}function Ft(e,n,s=0,t=new Set){if(n.size===0||s>=5)return e;let i=L(e),r="",a=0;for(let c of i.matchAll(/[A-Za-z_$][\w$]*/g)){let o=c.index??0,l=c[0],d=n.get(l);if(!d||t.has(l))continue;let x=i.slice(0,o).trimEnd(),b=i.slice(o+l.length).trimStart();if(x.endsWith(".")||/^:(?!:)/.test(b)&&/[{,]$/.test(x))continue;if(o>0&&/[\w$]/.test(i[o-1]))continue;r+=`${e.slice(a,o)}(${Ft(d,n,s+1,new Set([...t,l]))})`,a=o+l.length}return r+e.slice(a)}function ts(e,n){let s=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,t=[],i;while((i=s.exec(e))!==null){if(i.index>n)break;let r=i[1];if(i.index===n){if(r==="elseif"){let c=t[t.length-1];if(c?.current)c.seen.push(c.current);if(c)c.current=null}break}if(r==="endif"||r==="endunless"){t.pop();continue}let a="";if(i[2]==="("){let c=0,o=i.index+i[0].length-1,l=o+1;for(;o<e.length;o++){let d=e[o];if(d==="(")c++;else if(d===")"){if(c--,c===0)break}}a=e.slice(l,o).trim(),s.lastIndex=o+1}if(r==="if")t.push({seen:[],current:a});else if(r==="unless")t.push({seen:[],current:`!(${a})`});else if(r==="elseif"||r==="else"){let c=t[t.length-1];if(!c)continue;if(c.current)c.seen.push(c.current);c.current=r==="elseif"?a:null}}return t.flatMap((r)=>[...r.seen.map((a)=>`!(${a})`),...r.current?[r.current]:[]]).filter(Boolean)}function ns(e){let n=e.code.trim();if(!n)return null;if(e.attribute?.startsWith("@")){if(Qn.test(n))return null;let t=";(($event: any): void => { ";return{text:`${t}${n} });`,prefixLength:t.length}}let s=";void ((";return{text:`${s}${n}));`,prefixLength:s.length}}var ss=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function Me(e,n){return Ht(e,n).code}function Ht(e,n){let s=new Map;if(!n)return{code:e,columns:s};let t=we(e),i=[],r=0;for(let a of e.matchAll(ss)){let c=a.index,[o,l,d,x]=a,b=Qe.default.resolve(n,x).replace(/\\/g,"/"),_=`${l}${d}${b}${d}`;if(i.push(e.slice(r,c),_),r=c+o.length,o.includes(`
87
- `))continue;let A=ce(t,c),C=s.get(A.line)??[],p=C.at(-1),f=A.column+(p?p.generatedEnd-p.sourceEnd:0);C.push({sourceStart:A.column,sourceEnd:A.column+o.length,generatedStart:f,generatedEnd:f+_.length}),s.set(A.line,C)}return i.push(e.slice(r)),{code:i.join(""),columns:s}}function is(e,n,s){let t=qe(e.importColumns?.get(n)??[],s);return qe(e.scriptColumns?.get(n)??[],qe(e.componentColumns?.get(n)??[],t))}function Kt(e,n,s){let t=Xe(e.scriptColumns?.get(n)??[],s);return Xe(e.importColumns?.get(n)??[],Xe(e.componentColumns?.get(n)??[],t))}function rs(e){return" ".repeat(Math.max(0,(e.startColumn??1)-1))}function Oe(e){let n=new Set,s=L(e);for(let t of s.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let i=t[1],r=/\{([^}]*)\}/.exec(i);for(let l of r?.[1].split(",")??[]){let d=l.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(d&&/^[A-Z_$][\w$]*$/i.test(d))n.add(d)}let a=i.replace(/\{[^}]*\}/,""),c=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(a);if(c)n.add(c[1]);let o=/^\s*([A-Z_$][\w$]*)/i.exec(a);if(o&&o[1]!=="type")n.add(o[1])}return[...n].sort()}function Wt(e,n={}){let s=me(e),t=n.scriptKinds?s.filter((u)=>n.scriptKinds.includes(u.kind)):s,i=At(e,n.componentMethodValidator),r=n.filePath&&n.templateExpressions!==!1?kt(e,{filePath:n.filePath,partialsDir:n.partialsDir,layoutsDir:n.layoutsDir,contractsKnown:n.inheritedContractsKnown,readTemplate:n.readComponent}):void 0,a=new Map,c=e.split(`
88
- `),o=Array.from({length:c.length},()=>""),l=new Map,d=new Map,x=new Map,b=[],_=Xn(s),A=n.filePath&&n.templateExpressions!==!1?$t(e,ge(e),{filePath:n.filePath,componentsDir:n.componentsDir,projectRoot:n.projectRoot,readComponent:n.readComponent,scriptCode:(u,m)=>me(u).map((w)=>Me(w.code,Qe.default.dirname(m))).join(`
89
- `)}):void 0,C=new Set,p=[];for(let[u,m]of t.entries()){let w=Fn(rs(m)+m.code,_,String(u));for(let[I,M]of w.columns)d.set(m.startLine+I-1,M);for(let I of w.declarations)b.push({text:Me(I.text,n.originDir??""),origin:I.origin?{...I.origin,line:I.origin.line+m.startLine-1}:void 0});let R=m.kind==="client"&&i?i.project(w.code):void 0;for(let[I,M]of R?.columns??[])a.set(m.startLine+I-1,M);let v=Pe(R?.code??w.code),P=Ht(v,n.originDir??"");for(let[I,M]of P.columns)x.set(m.startLine+I-1,M);let O=P.code.split(`
90
- `);O.forEach((I,M)=>{let z=m.startLine-1+M;if(z<o.length)o[z]=I,C.add(z)}),p.push(m.startLine-1+O.length-1)}for(let u of p){let m=o[u]?.trim()===""?u:u+1;if(m<o.length&&o[m].trim()===""&&(m===u||!C.has(m)))o[m]=";"}let f=(u,m)=>{for(let[w,R]of u.split(`
91
- `).entries())if(o.push(R),m)l.set(o.length,w===0?m:{...m,line:m.line+w,column:1,prefixLength:0})},T=Ct(t.filter((u)=>u.kind==="server").map((u)=>u.code).join(`
92
- `));if(T)f(T);for(let u of t.filter((m)=>m.kind==="server")){let m=Re(u.code);if(!m?.unsupported)continue;let w=u.code.slice(0,m.offset),R=u.startLine+w.split(`
87
+ `)));return{imports:r.join(`
88
+ `),body:t}}function he(e){let n=j(e),r=Array(n.length),t=0;for(let a=0;a<n.length;a++){let c=n[a];if(c==="}"||c===")"||c==="]")t=Math.max(0,t-1);if(r[a]=t,c==="{"||c==="("||c==="[")t++}let s=[],i=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,o;while((o=i.exec(n))!==null){if(r[o.index]!==0)continue;let a=o[1],c=o[2],l;if(a==="interface"){let p=n.indexOf("{",o.index);if(p===-1)continue;let x=0;l=-1;for(let b=p;b<n.length;b++)if(n[b]==="{")x++;else if(n[b]==="}"&&--x===0){l=b+1;break}if(l===-1)continue}else{let p=0;l=n.length;for(let x=n.indexOf("=",o.index)+1;x<n.length;x++){let b=n[x];if(b==="{"||b==="["||b==="("||b==="<")p++;else if(b==="}"||b==="]"||b===")"||b===">")p--;else if(p<=0&&(b===";"||b===`
89
+ `&&!/[=|&,<([{]\s*$/.test(n.slice(Math.max(0,x-40),x)))){l=b===";"?x+1:x;break}}}s.push({name:c,text:e.slice(o.index,l).replace(/^[ \t]*export[ \t]+/,"")}),i.lastIndex=l}return s}function gr(e){let n=j(e),r=[],t=/^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+/gm,s,i=0,o=0;while((s=t.exec(n))!==null){for(;o<s.index;o++){let l=n[o];if(l==="{"||l==="("||l==="[")i++;else if(l==="}"||l===")"||l==="]")i=Math.max(0,i-1)}if(i!==0)continue;let a=0,c=n.length;for(let l=s.index+s[0].length;l<n.length;l++){let p=n[l];if(p==="{"||p==="("||p==="[")a++;else if(p==="}"||p===")"||p==="]")a--;else if(a<=0&&(p===";"||p===`
90
+ `)){c=p===";"?l+1:l;break}}if(/\bdefineProps\s*(?:<|\()/.test(n.slice(s.index,c)))r.push(e.slice(s.index,c).replace(/^[ \t]*export[ \t]+/,"").trim())}return r}function hr(e){let n=e.filter((s)=>s.kind==="server").map((s)=>s.code).join(`
91
+ `);if(/\bdefineProps\s*(?:<|\()/.test(j(n)))return n;let r=xr(n),t=e.filter((s)=>s.kind!=="server").flatMap((s)=>{let i=gr(s.code);if(!i.length)return[];return[...he(s.code).filter((o)=>!r.has(o.name)).map((o)=>o.text),...i]});return[n,...t].filter(Boolean).join(`
92
+ `)}function xr(e){return new Set(he(e).map((n)=>n.name))}var Vt=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];function Gt(e){let n=new Set,r=new Set;for(let t of e){let s=t.kind==="server"?n:r;for(let i of ae(t.code))s.add(i)}return[...n].filter((t)=>r.has(t)).sort()}var br=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function yr(e){let n=new Map,r=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let t of e){let s=j(t),{depths:i,balanced:o}=U(s);if(!o)continue;let a=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let c of s.matchAll(a)){let l=c.index??0;if(i[l+c[1].length]!==0)continue;let p=c[2],x=l+c[0].length-c[3].length,b=t.slice(x,l+c[0].length).trim().replace(/;$/,"").trim(),_=c[3],A=r.test(_)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(_)&&!/[,+\-*/%&|?:=]$/.test(b)&&U(_).balanced;n.set(p,n.has(p)||!A?null:b)}}return new Map([...n].filter((t)=>t[1]!==null))}function Jt(e,n,r=0,t=new Set){if(n.size===0||r>=5)return e;let s=j(e),i="",o=0;for(let a of s.matchAll(/[A-Za-z_$][\w$]*/g)){let c=a.index??0,l=a[0],p=n.get(l);if(!p||t.has(l))continue;let x=s.slice(0,c).trimEnd(),b=s.slice(c+l.length).trimStart();if(x.endsWith(".")||/^:(?!:)/.test(b)&&/[{,]$/.test(x))continue;if(c>0&&/[\w$]/.test(s[c-1]))continue;i+=`${e.slice(o,c)}(${Jt(p,n,r+1,new Set([...t,l]))})`,o=c+l.length}return i+e.slice(o)}function Sr(e,n){let r=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,t=[],s;while((s=r.exec(e))!==null){if(s.index>n)break;let i=s[1];if(s.index===n){if(i==="elseif"){let a=t[t.length-1];if(a?.current)a.seen.push(a.current);if(a)a.current=null}break}if(i==="endif"||i==="endunless"){t.pop();continue}let o="";if(s[2]==="("){let a=0,c=s.index+s[0].length-1,l=c+1;for(;c<e.length;c++){let p=e[c];if(p==="(")a++;else if(p===")"){if(a--,a===0)break}}o=e.slice(l,c).trim(),r.lastIndex=c+1}if(i==="if")t.push({seen:[],current:o});else if(i==="unless")t.push({seen:[],current:`!(${o})`});else if(i==="elseif"||i==="else"){let a=t[t.length-1];if(!a)continue;if(a.current)a.seen.push(a.current);a.current=i==="elseif"?o:null}}return t.flatMap((i)=>[...i.seen.map((o)=>`!(${o})`),...i.current?[i.current]:[]]).filter(Boolean)}function vr(e){let n=e.code.trim();if(!n)return null;if(e.attribute?.startsWith("@")){if(br.test(n))return null;let t=";(($event: any): void => { ";return{text:`${t}${n} });`,prefixLength:t.length}}let r=";void ((";return{text:`${r}${n}));`,prefixLength:r.length}}var Er=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function Le(e,n){return qt(e,n).code}function qt(e,n){let r=new Map;if(!n)return{code:e,columns:r};let t=$e(e),s=[],i=0;for(let o of e.matchAll(Er)){let a=o.index,[c,l,p,x]=o,b=tt.default.resolve(n,x).replace(/\\/g,"/"),_=`${l}${p}${b}${p}`;if(s.push(e.slice(i,a),_),i=a+c.length,c.includes(`
93
+ `))continue;let A=ce(t,a),C=r.get(A.line)??[],d=C.at(-1),f=A.column+(d?d.generatedEnd-d.sourceEnd:0);C.push({sourceStart:A.column,sourceEnd:A.column+c.length,generatedStart:f,generatedEnd:f+_.length}),r.set(A.line,C)}return s.push(e.slice(i)),{code:s.join(""),columns:r}}function wr(e,n,r){let t=Ye(e.importColumns?.get(n)??[],r);return Ye(e.scriptColumns?.get(n)??[],Ye(e.componentColumns?.get(n)??[],t))}function Xt(e,n,r){let t=Qe(e.scriptColumns?.get(n)??[],r);return Qe(e.importColumns?.get(n)??[],Qe(e.componentColumns?.get(n)??[],t))}function $r(e){return" ".repeat(Math.max(0,(e.startColumn??1)-1))}function De(e){let n=new Set,r=j(e);for(let t of r.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let s=t[1],i=/\{([^}]*)\}/.exec(s);for(let l of i?.[1].split(",")??[]){let p=l.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(p&&/^[A-Z_$][\w$]*$/i.test(p))n.add(p)}let o=s.replace(/\{[^}]*\}/,""),a=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(o);if(a)n.add(a[1]);let c=/^\s*([A-Z_$][\w$]*)/i.exec(o);if(c&&c[1]!=="type")n.add(c[1])}return[...n].sort()}function Zt(e,n={}){let r=me(e),t=n.scriptKinds?r.filter((u)=>n.scriptKinds.includes(u.kind)):r,s=Nt(e,n.componentMethodValidator),i=n.filePath&&n.templateExpressions!==!1?It(e,{filePath:n.filePath,partialsDir:n.partialsDir,layoutsDir:n.layoutsDir,contractsKnown:n.inheritedContractsKnown,readTemplate:n.readComponent}):void 0,o=new Map,a=e.split(`
94
+ `),c=Array.from({length:a.length},()=>""),l=new Map,p=new Map,x=new Map,b=[],_=hr(r),A=n.filePath&&n.templateExpressions!==!1?_t(e,ge(e),{filePath:n.filePath,componentsDir:n.componentsDir,projectRoot:n.projectRoot,readComponent:n.readComponent,scriptCode:(u,m)=>me(u).map((E)=>Le(E.code,tt.default.dirname(m))).join(`
95
+ `)}):void 0,C=new Set,d=[];for(let[u,m]of t.entries()){let E=ar($r(m)+m.code,_,String(u));for(let[I,P]of E.columns)p.set(m.startLine+I-1,P);for(let I of E.declarations)b.push({text:Le(I.text,n.originDir??""),origin:I.origin?{...I.origin,line:I.origin.line+m.startLine-1}:void 0});let R=m.kind==="client"&&s?s.project(E.code):void 0;for(let[I,P]of R?.columns??[])o.set(m.startLine+I-1,P);let v=Ne(R?.code??E.code),O=qt(v,n.originDir??"");for(let[I,P]of O.columns)x.set(m.startLine+I-1,P);let M=O.code.split(`
96
+ `);M.forEach((I,P)=>{let B=m.startLine-1+P;if(B<c.length)c[B]=I,C.add(B)}),d.push(m.startLine-1+M.length-1)}for(let u of d){let m=c[u]?.trim()===""?u:u+1;if(m<c.length&&c[m].trim()===""&&(m===u||!C.has(m)))c[m]=";"}let f=(u,m)=>{for(let[E,R]of u.split(`
97
+ `).entries())if(c.push(R),m)l.set(c.length,E===0?m:{...m,line:m.line+E,column:1,prefixLength:0})},w=Mt(t.filter((u)=>u.kind==="server").map((u)=>u.code).join(`
98
+ `));if(w)f(w);for(let u of t.filter((m)=>m.kind==="server")){let m=Ie(u.code);if(!m?.unsupported)continue;let E=u.code.slice(0,m.offset),R=u.startLine+E.split(`
93
99
  `).length-1,v=m.offset-u.code.lastIndexOf(`
94
- `,m.offset-1)+(R===u.startLine?(u.startColumn??1)-1:0);f(`;({})[${JSON.stringify(m.unsupported)}];`,{line:R,column:v,anchor:!0})}if(r?.declarations)f(r.declarations);for(let u of b)f(u.text,u.origin);if(i){if(f(i.declarations),n.nativeChecks!==!1)for(let u of i.checks)f(u.text,{line:u.line,column:u.column,diagnosticOrigin:u.origin,anchor:!0})}if(n.globals!==!1){f("");let u=new Set([...t.flatMap((v)=>ae(v.code)),...t.flatMap((v)=>Oe(v.code))]),m=(v)=>{if(!u.has(v)&&!n.declaredGlobals?.includes(v))f(`declare var ${v}: any`)};if(n.runtimeGlobals!==!1){if(!u.has("window"))f("declare var window: any");for(let v of de)m(v)}let w=[...new Set([...Dt,...Ne,...jt])].filter((v)=>!n.declaredGlobals?.includes(v)&&(n.runtimeGlobals!==!1||!de.includes(v)));if(n.contextScope==="global"){f("declare global {");for(let v of w)f(` var ${v}: any`);f("}")}else{for(let v of Dt)m(v);for(let v of Ne)m(v);for(let v of jt)m(v)}f(`declare var ${Ye}: any`);let R=new Set(t.flatMap((v)=>ae(v.code)));f(`type ${Mt}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let v of i?[]:Jn(e)){if(R.has(v.name))continue;let P=v.iterable&&R.has(v.iterable)?`${Mt}<typeof ${v.iterable}>`:"any";f(`declare var ${v.name}: ${P}`)}}if(n.templateExpressions!==!1){if(A?.declarations)for(let m of A.declarations.split(`
95
- `))f(m);let u=Wn(e).map((m)=>{let w=A?.events.get(m.offset??-1);if(w){m.anchor=!0;let R=m.code.trim(),v=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(R),P=v?`void ((${v[2]}) satisfies __StxAssignedValue<typeof ${v[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(R)?`${R} satisfies (($event: ${w}) => unknown)`:R,O=`;(($event: ${w}): void => { `;return{expression:m,statement:{text:`${O}${P} });`,prefixLength:O.length}}}return{expression:m,statement:ns(m)}}).filter((m)=>m.statement!==null);if(u.push(...A?.checks||[],...r?.checks||[]),u.length>0){let m=ge(e),w=Pt(m),R=i?Rt(m):[];if(i)f("type __StxNativeValue<T> = T extends readonly (infer E)[] ? E : T extends object ? T[keyof T] : never; declare function __stxEach<T>(items: T, callback: (item: __StxNativeValue<T>, key: string) => void): void;");let v=es(t.map((M)=>M.code)),O=[...new Set(t.flatMap((M)=>ae(M.code)))].filter((M)=>/^[A-Z_$][\w$]*$/i.test(M)),I=0;if(i)f("function __stxNativeTemplate(this: __StxNativeComponent) {");if(O.length>0){f(zn);for(let M of O)f(`function __StxRead_${M}() { return ${M} }`),f(`type __StxT_${M} = ${Bt}<ReturnType<typeof __StxRead_${M}>>`);f(`;((${O.map((M)=>`${M}: __StxT_${M}`).join(", ")}) => {`),I=1}for(let{expression:M,statement:z}of u){let W=" ".repeat(I),J=M.offset===void 0?[]:w.filter((B)=>M.offset>=B.start&&M.offset<B.end),G=M.offset===void 0?[]:R.filter((B)=>M.offset>=B.start&&M.offset<B.end),ee=G.map((B)=>`;__stxEach(${B.iterable}, (${B.binding}) => { `).join(""),se=" });".repeat(G.length),Z=ee+J.map((B)=>`;((${B.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),le=" });".repeat(J.length)+se,N=M.offset===void 0?[]:ts(m,M.offset),H=N.length>0?`${N.map((B)=>`if (${Ft(B,v)}) `).join("")}{ `:"",Y=N.length>0?" }":"";f(W+Z+H+z.text+Y+le,{line:M.line,column:M.column,expression:M,prefixLength:z.prefixLength+W.length+Z.length+H.length,guardPrefixLength:W.length+Z.length+H.length})}if(I>0)f("});");if(i)f("}")}}let h=!1;if(n.reference&&o[0]!==void 0&&o[0].trim()==="")o[0]=`/// <reference path=${JSON.stringify(n.reference.replace(/\\/g,"/"))} />`,h=!0;return f("export {}"),{text:o.join(`
96
- `),lineMap:l,sourceLineCount:c.length,componentDependencies:new Map([...A?.dependencies??[],...r?.dependencies??[]]),referenced:h,scriptColumns:d,importColumns:x,componentColumns:a}}function we(e){let n=[0];for(let s=0;s<e.length;s++)if(e.charCodeAt(s)===10)n.push(s+1);return n}function ce(e,n){let s=0,t=e.length-1;while(s<t){let i=Math.ceil((s+t)/2);if(e[i]<=n)s=i;else t=i-1}return{line:s+1,column:n-e[s]+1}}function De(e,n,s){let t=Math.min(Math.max(n,1),e.length)-1,i=t+1<e.length?e[t+1]-1:Number.MAX_SAFE_INTEGER;return Math.min(e[t]+Math.max(s,1)-1,i)}function Gt(e,n){if(!e.expression)return!1;return e.inGuard===!0||n===2774}function Ut(e,n,s){let t=e.lineMap.get(n);if(!t)return n<=e.sourceLineCount?{line:n,column:is(e,n,s)}:null;let i=t.anchor||t.expression?.anchor||t.diagnosticOrigin==="component"?0:Math.max(0,s-1-(t.prefixLength??0));return{line:t.line,column:t.column+i,expression:t.expression,diagnosticOrigin:t.diagnosticOrigin,inGuard:s<=(t.guardPrefixLength??0)}}var os=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),Zt=ke.filter((e)=>!os.has(e)).sort(),qt=[...de].sort(),as=[...new Set([...Zt,...qt])].sort(),cs=new Set(Zt),ls=new Set(qt),us=new Set(as),Jt=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function ps(e,n){if(n==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function Xt(e,n){let s=[];for(let t of n){if(t.offset===void 0)continue;let i=t.kind==="server"?cs:ls;Jt.lastIndex=0;for(let r of t.code.matchAll(Jt)){let a=r.index+r[0].indexOf("{")+1;for(let c of r[1].matchAll(/[^,]+/g)){let o=c[0];if(/^\s*type\s/.test(o))continue;let l=/^\s*([A-Za-z_$][\w$]*)/.exec(o);if(!l)continue;let d=l[1];if(!us.has(d)||i.has(d))continue;let x=t.offset+a+c.index+l[0].length-d.length,b=e.slice(0,x),_=b.split(`
97
- `).length;s.push({line:_,column:x-(b.lastIndexOf(`
98
- `)+1)+1,offset:x,length:d.length,name:d,kind:t.kind,message:ps(d,t.kind)})}}}return s}var ne=Q(require("node:path"),1),ds="@stacksjs/stx-typescript-plugin";function fs(e,n){let s=ne.default.resolve(e);for(;;){let t=ne.default.join(s,"tsconfig.json");if(n(t))return t;let i=ne.default.dirname(s);if(i===s)return;s=i}}function Yt(e,n,s){let t=fs(e,s);if(!t)return;let i=new Set,r=(a)=>{if(i.has(a))return;i.add(a);let c=n(a);if(!c)return;let o=c.compilerOptions?.plugins;if(Array.isArray(o)){let d=o.find((b)=>b?.name===ds),x=Array.isArray(d?.libs)?d.libs.filter((b)=>typeof b==="string"):[];return d?{configPath:a,libs:x.map((b)=>ne.default.resolve(ne.default.dirname(a),b))}:null}let l=typeof c.extends==="string"?[c.extends]:Array.isArray(c.extends)?c.extends:[];for(let d of[...l].reverse()){if(typeof d!=="string"||!d.startsWith("."))continue;let x=ne.default.resolve(ne.default.dirname(a),d.endsWith(".json")?d:`${d}.json`),b=r(x);if(b!==void 0)return b}return};return r(t)??void 0}var Qt=Symbol.for("@stacksjs/stx-typescript-plugin"),ms=new Set([2300,2451,2403]);function $e(e){return e.endsWith(".stx")}function en(e){return $e(e)||e.endsWith(".md")}function gs(e){if(!e)return;return X.existsSync(K.default.join(e,"stx-module.d.ts"))&&X.existsSync(K.default.join(e,"stx.d.ts"))?K.default.join(e,"stx-module.d.ts"):void 0}function hs(e,n=X.existsSync){let s=e;for(;;){let t=K.default.join(s,"node_modules","@stacksjs","stx","stx-module.d.ts");if(n(t))return t;let i=K.default.dirname(s);if(i===s)return;s=i}}function xs(e,n=K.default.join(nn.tmpdir(),"stx-typescript-plugin")){let s=e.map((i)=>`/// <reference path=${JSON.stringify(i.replace(/\\/g,"/"))} />`).join(`
100
+ `,m.offset-1)+(R===u.startLine?(u.startColumn??1)-1:0);f(`;({})[${JSON.stringify(m.unsupported)}];`,{line:R,column:v,anchor:!0})}if(i?.declarations)f(i.declarations);for(let u of b)f(u.text,u.origin);if(s){if(f(s.declarations),n.nativeChecks!==!1)for(let u of s.checks)f(u.text,{line:u.line,column:u.column,diagnosticOrigin:u.origin,anchor:!0})}if(n.globals!==!1){f("");let u=new Set([...t.flatMap((v)=>ae(v.code)),...t.flatMap((v)=>De(v.code))]),m=(v)=>{if(!u.has(v)&&!n.declaredGlobals?.includes(v))f(`declare var ${v}: any`)};if(n.runtimeGlobals!==!1){if(!u.has("window"))f("declare var window: any");for(let v of de)m(v)}let E=[...new Set([...zt,...ze,...Vt])].filter((v)=>!n.declaredGlobals?.includes(v)&&(n.runtimeGlobals!==!1||!de.includes(v)));if(n.contextScope==="global"){f("declare global {");for(let v of E)f(` var ${v}: any`);f("}")}else{for(let v of zt)m(v);for(let v of ze)m(v);for(let v of Vt)m(v)}f(`declare var ${et}: any`);let R=new Set(t.flatMap((v)=>ae(v.code)));f(`type ${jt}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let v of s?[]:fr(e)){if(R.has(v.name))continue;let O=v.iterable&&R.has(v.iterable)?`${jt}<typeof ${v.iterable}>`:"any";f(`declare var ${v.name}: ${O}`)}}if(n.templateExpressions!==!1){if(A?.declarations)for(let m of A.declarations.split(`
101
+ `))f(m);let u=ur(e).map((m)=>{let E=A?.events.get(m.offset??-1);if(E){m.anchor=!0;let R=m.code.trim(),v=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(R),O=v?`void ((${v[2]}) satisfies __StxAssignedValue<typeof ${v[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(R)?`${R} satisfies (($event: ${E}) => unknown)`:R,M=`;(($event: ${E}): void => { `;return{expression:m,statement:{text:`${M}${O} });`,prefixLength:M.length}}}return{expression:m,statement:vr(m)}}).filter((m)=>m.statement!==null);if(u.push(...A?.checks||[],...i?.checks||[]),u.length>0){let m=ge(e),E=Dt(m),R=s?Lt(m):[];if(s)f("type __StxNativeValue<T> = T extends readonly (infer E)[] ? E : T extends object ? T[keyof T] : never; declare function __stxEach<T>(items: T, callback: (item: __StxNativeValue<T>, key: string) => void): void;");let v=yr(t.map((P)=>P.code)),M=[...new Set(t.flatMap((P)=>ae(P.code)))].filter((P)=>/^[A-Z_$][\w$]*$/i.test(P)),I=0;if(s)f("function __stxNativeTemplate(this: __StxNativeComponent) {");if(M.length>0){f(ir);for(let P of M)f(`function __StxRead_${P}() { return ${P} }`),f(`type __StxT_${P} = ${Kt}<ReturnType<typeof __StxRead_${P}>>`);f(`;((${M.map((P)=>`${P}: __StxT_${P}`).join(", ")}) => {`),I=1}for(let{expression:P,statement:B}of u){let K=" ".repeat(I),q=P.offset===void 0?[]:E.filter((F)=>P.offset>=F.start&&P.offset<F.end),G=P.offset===void 0?[]:R.filter((F)=>P.offset>=F.start&&P.offset<F.end),ee=G.map((F)=>`;__stxEach(${F.iterable}, (${F.binding}) => { `).join(""),re=" });".repeat(G.length),X=ee+q.map((F)=>`;((${F.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),le=" });".repeat(q.length)+re,D=P.offset===void 0?[]:Sr(m,P.offset),W=D.length>0?`${D.map((F)=>`if (${Jt(F,v)}) `).join("")}{ `:"",Y=D.length>0?" }":"";f(K+X+W+B.text+Y+le,{line:P.line,column:P.column,expression:P,prefixLength:B.prefixLength+K.length+X.length+W.length,guardPrefixLength:K.length+X.length+W.length})}if(I>0)f("});");if(s)f("}")}}let h=!1;if(n.reference&&c[0]!==void 0&&c[0].trim()==="")c[0]=`/// <reference path=${JSON.stringify(n.reference.replace(/\\/g,"/"))} />`,h=!0;return f("export {}"),{text:c.join(`
102
+ `),lineMap:l,sourceLineCount:a.length,componentDependencies:new Map([...A?.dependencies??[],...i?.dependencies??[]]),referenced:h,scriptColumns:p,importColumns:x,componentColumns:o}}function $e(e){let n=[0];for(let r=0;r<e.length;r++)if(e.charCodeAt(r)===10)n.push(r+1);return n}function ce(e,n){let r=0,t=e.length-1;while(r<t){let s=Math.ceil((r+t)/2);if(e[s]<=n)r=s;else t=s-1}return{line:r+1,column:n-e[r]+1}}function Fe(e,n,r){let t=Math.min(Math.max(n,1),e.length)-1,s=t+1<e.length?e[t+1]-1:Number.MAX_SAFE_INTEGER;return Math.min(e[t]+Math.max(r,1)-1,s)}function Yt(e,n){if(!e.expression)return!1;return e.inGuard===!0||n===2774}function Qt(e,n,r){let t=e.lineMap.get(n);if(!t)return n<=e.sourceLineCount?{line:n,column:wr(e,n,r)}:null;let s=t.anchor||t.expression?.anchor||t.diagnosticOrigin==="component"?0:Math.max(0,r-1-(t.prefixLength??0));return{line:t.line,column:t.column+s,expression:t.expression,diagnosticOrigin:t.diagnosticOrigin,inGuard:r<=(t.guardPrefixLength??0)}}var _r=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),tn=Pe.filter((e)=>!_r.has(e)).sort(),nn=[...de].sort(),kr=[...new Set([...tn,...nn])].sort(),Cr=new Set(tn),Tr=new Set(nn),Ar=new Set(kr),en=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Rr(e,n){if(n==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function rn(e,n){let r=[];for(let t of n){if(t.offset===void 0)continue;let s=t.kind==="server"?Cr:Tr;en.lastIndex=0;for(let i of t.code.matchAll(en)){let o=i.index+i[0].indexOf("{")+1;for(let a of i[1].matchAll(/[^,]+/g)){let c=a[0];if(/^\s*type\s/.test(c))continue;let l=/^\s*([A-Za-z_$][\w$]*)/.exec(c);if(!l)continue;let p=l[1];if(!Ar.has(p)||s.has(p))continue;let x=t.offset+o+a.index+l[0].length-p.length,b=e.slice(0,x),_=b.split(`
103
+ `).length;r.push({line:_,column:x-(b.lastIndexOf(`
104
+ `)+1)+1,offset:x,length:p.length,name:p,kind:t.kind,message:Rr(p,t.kind)})}}}return r}var ne=Q(require("node:path"),1),Or="@stacksjs/stx-typescript-plugin";function Pr(e,n){let r=ne.default.resolve(e);for(;;){let t=ne.default.join(r,"tsconfig.json");if(n(t))return t;let s=ne.default.dirname(r);if(s===r)return;r=s}}function sn(e,n,r){let t=Pr(e,r);if(!t)return;let s=new Set,i=(o)=>{if(s.has(o))return;s.add(o);let a=n(o);if(!a)return;let c=a.compilerOptions?.plugins;if(Array.isArray(c)){let p=c.find((b)=>b?.name===Or),x=Array.isArray(p?.libs)?p.libs.filter((b)=>typeof b==="string"):[];return p?{configPath:o,libs:x.map((b)=>ne.default.resolve(ne.default.dirname(o),b))}:null}let l=typeof a.extends==="string"?[a.extends]:Array.isArray(a.extends)?a.extends:[];for(let p of[...l].reverse()){if(typeof p!=="string"||!p.startsWith("."))continue;let x=ne.default.resolve(ne.default.dirname(o),p.endsWith(".json")?p:`${p}.json`),b=i(x);if(b!==void 0)return b}return};return i(t)??void 0}var on=Symbol.for("@stacksjs/stx-typescript-plugin"),Mr=new Set([2300,2451,2403]);function _e(e){return e.endsWith(".stx")}function an(e){return _e(e)||e.endsWith(".md")}function Ir(e){if(!e)return;return Z.existsSync(H.default.join(e,"stx-module.d.ts"))&&Z.existsSync(H.default.join(e,"stx.d.ts"))?H.default.join(e,"stx-module.d.ts"):void 0}function Nr(e,n=Z.existsSync){let r=e;for(;;){let t=H.default.join(r,"node_modules","@stacksjs","stx","stx-module.d.ts");if(n(t))return t;let s=H.default.dirname(r);if(s===r)return;r=s}}function Lr(e,n=H.default.join(ln.tmpdir(),"stx-typescript-plugin")){let r=e.map((s)=>`/// <reference path=${JSON.stringify(s.replace(/\\/g,"/"))} />`).join(`
99
105
  `)+`
100
- `,t=K.default.join(n,`${tn.createHash("sha1").update(s).digest("hex").slice(0,16)}.d.ts`);if(!X.existsSync(t))X.mkdirSync(n,{recursive:!0}),X.writeFileSync(t,s);return t}function bs(e){let n=new Set,s=new Set;function t(i){if(s.has(i)||!X.existsSync(i))return;s.add(i);let r=X.readFileSync(i,"utf8");for(let a of zt(r))n.add(a);for(let a of r.matchAll(/<reference\s+path=["']([^"']+)["']/g))t(K.default.resolve(K.default.dirname(i),a[1]))}if(e)t(e);return[...n]}function ys(e,n,s,t){let i=(c)=>Wt(n,{templateExpressions:$e(e),componentMethodValidator:(o,l,d)=>{let x=t.typescript.transpileModule(o+(l==="{"?"{}":";"),{reportDiagnostics:!0,compilerOptions:{target:t.typescript.ScriptTarget.ESNext}});if(x.diagnostics?.some((b)=>b.category===t.typescript.DiagnosticCategory.Error))return!1;return l==="{"?x.outputText.includes(`function ${d}(`):!x.outputText.trim()},originDir:K.default.dirname(e),filePath:e,readComponent:t.readComponent,componentsDir:t.componentsDir,projectRoot:t.projectRoot,reference:c,declaredGlobals:bs(c),runtimeGlobals:!c,contextScope:"global"}),r=i(t.declarations);if(t.declarations&&!r.referenced)r=i(void 0);let a=me(n);return{version:s,source:n,virtual:r,blocks:a,sourceStarts:we(n),virtualStarts:we(r.text),collisions:new Set(Vt(a))}}function Ss(e,n){let s=e.findConfigFile(n,e.sys.fileExists);if(!s)return;let t=e.readConfigFile(s,e.sys.readFile);if(t.error)return;let i=e.parseJsonConfigFileContent(t.config,e.sys,K.default.dirname(s),void 0,s),r={};if(i.options.types)r.types=i.options.types;let a=i.options.paths;if(a){let c=i.options.baseUrl??i.options.pathsBasePath??K.default.dirname(s);r.paths={};for(let[o,l]of Object.entries(a))r.paths[o]=l.map((d)=>K.default.isAbsolute(d)?d:K.default.resolve(c,d))}return r}function vs(e,n={}){let s=e.typescript,t={},i=new Set,r=new WeakSet;return{create(a){let c=(g)=>{a.project.projectService.logger.info(`[stx-plugin] ${g}`)};if(a.languageService[Qt])return r.add(a.project),c("already applied to this project by another registration of the plugin; leaving it as it is"),a.languageService;c("TypeScript stx plugin initialized");let{languageService:o,languageServiceHost:l}=a,d=(g)=>{let S=o[g];return typeof S==="function"?S.bind(o):()=>{return}},x=l.getScriptSnapshot?.bind(l),b=l.getScriptVersion?.bind(l),_=gs(n.declarationsDir);if(!_)c("the bundled stx declarations were not found; apps without their own fall back to `any`");let A=(g)=>s.sys?.fileExists(g)??X.existsSync(g),C=(g)=>{let S=s.readConfigFile?.(g,(y)=>s.sys.readFile(y));return S&&!S.error?S.config:void 0},p=new Map,f=(g)=>{let S=K.default.dirname(g);if(!p.has(S)){let y=hs(S,A)??_,k=[];try{k=(Yt(S,C,A)?.libs??[]).filter(A)}catch(E){c(`could not read the stx entry of the project's tsconfig: ${String(E)}`)}p.set(S,y&&k.length>0?xs([y,...k]):y)}return p.get(S)},T=new Map,h=(g)=>{let S=x?.(g);return S?S.getText(0,S.getLength()):s.sys?.readFile(g)},u=()=>t.enabled!==!1;i.add(()=>{T.clear(),a.project.refreshDiagnostics?.()});let m=(g)=>{if(!en(g)||!x)return;let S=`${b?.(g)||"0"}:${l.getProjectVersion?.()||""}`,y=T.get(g);if(y&&y.version===S&&[...y.virtual.componentDependencies||[]].every(([E,D])=>h(E)===D))return y;let k=x(g);if(!k)return;try{let E=a.project.getCurrentDirectory?.(),D=E?K.default.resolve(E,typeof a.config?.componentsDir==="string"?a.config.componentsDir:"components"):void 0,V=ys(g,k.getText(0,k.getLength()),S,{typescript:s,declarations:f(g),readComponent:h,componentsDir:D,projectRoot:E});return T.set(g,V),V}catch(E){c(`failed to build virtual document for ${g}: ${String(E)}`);return}},w=(g)=>$e(g)?m(g):void 0,R=(g,S)=>{let y=ce(g.virtualStarts,S);return Ut(g.virtual,y.line,y.column)},v=(g,S)=>{let y=R(g,S);if(!y)return;return De(g.sourceStarts,y.line,y.column)},P=(g,S)=>{let y=ce(g.sourceStarts,S);return De(g.virtualStarts,y.line,Kt(g.virtual,y.line,y.column))},O=(g,S)=>{let y=v(g,S.start);if(y===void 0)return;let k=v(g,S.start+S.length);return{start:y,length:k!==void 0&&k>=y?k-y:S.length}},I=(g,S)=>g.blocks.some((y)=>y.offset!==void 0&&S>=y.offset&&S<=y.offset+y.code.length),M=(g)=>{let S=w(g.fileName);if(!S)return g;let y=O(S,g.textSpan);if(!y)return;let k=g.contextSpan?O(S,g.contextSpan):void 0;return{...g,textSpan:y,contextSpan:k}},z=(g)=>g?.map(M).filter((S)=>S!==void 0),W=(g)=>g?.filter((S)=>{let y=w(S.fileName);if(!y)return!0;let{line:k}=ce(y.virtualStarts,S.textSpan.start);return k<=y.virtual.sourceLineCount&&!y.virtual.lineMap.has(k)});if(x)l.getScriptSnapshot=(g)=>{let S=m(g);if(S)return s.ScriptSnapshot.fromString(S.virtual.text);return x(g)};let J=l.getCompilationSettings?.bind(l),G=s.server?.ProjectKind!==void 0&&a.project.projectKind===s.server.ProjectKind.Inferred;if(J&&G){let g=null,S;l.getCompilationSettings=()=>{let y=J();if(g===null)try{g=Ss(s,a.project.getCurrentDirectory())}catch(k){c(`could not read the project's tsconfig: ${String(k)}`),g=void 0}if(!g)return y;if(S?.from!==y)S={from:y,options:{...y,...g.paths&&!y.paths?{paths:g.paths}:{},...g.types&&!y.types?{types:g.types}:{}}};return S.options}}let ee=(g,S)=>{let y=m(g);if(!y)return S;if($e(g)&&!u())return[];let k=[];for(let E of S){let D=typeof E.messageText==="string"?E.messageText:E.messageText.messageText;if(ms.has(E.code)){let te=D.match(/'([^']+)'/)?.[1];if(te&&y.collisions.has(te))continue}if(E.start===void 0){k.push(E);continue}let V=R(y,E.start);if(!V||Gt(V,E.code))continue;let F=De(y.sourceStarts,V.line,V.column),be=v(y,E.start+(E.length??0));k.push({...E,start:F,length:be!==void 0&&be>F?be-F:E.length??0})}return k},se=d("getSemanticDiagnostics");o.getSemanticDiagnostics=(g)=>{let S=ee(g,se(g)),y=w(g);if(!y||!u())return S;let k=o.getProgram?.()?.getSourceFile(g);for(let E of Xt(y.source,y.blocks))S.push({file:k,start:E.offset,length:E.length,messageText:E.message,category:s.DiagnosticCategory?.Error??1,code:0,source:"stx"});return S};let Z=d("getSyntacticDiagnostics");o.getSyntacticDiagnostics=(g)=>ee(g,Z(g));let le=d("getSuggestionDiagnostics");o.getSuggestionDiagnostics=(g)=>ee(g,le(g));let N=d("getQuickInfoAtPosition");o.getQuickInfoAtPosition=(g,S,...y)=>{let k=w(g);if(!k)return N(g,S,...y);if(!u())return;let E=N(g,P(k,S),...y);if(!E)return E;let D=O(k,E.textSpan);return D?{...E,textSpan:D}:void 0};let H=d("getCompletionsAtPosition");o.getCompletionsAtPosition=(g,S,y,...k)=>{let E=w(g);if(!E)return H(g,S,y,...k);if(!u()||!I(E,S))return;let D=H(g,P(E,S),{...y,includeCompletionsForModuleExports:!1},...k);if(!D)return D;let V=(F)=>F&&O(E,F);return{...D,optionalReplacementSpan:V(D.optionalReplacementSpan),entries:D.entries.filter((F)=>!F.name.startsWith("__stx")&&!F.name.startsWith("__Stx")).map((F)=>F.replacementSpan?{...F,replacementSpan:V(F.replacementSpan)}:F)}};let Y=d("getCompletionEntryDetails");o.getCompletionEntryDetails=(g,S,...y)=>{let k=w(g);if(!k)return Y(g,S,...y);let E=Y(g,P(k,S),...y);return E?{...E,codeActions:void 0}:E};let B=d("getSignatureHelpItems");o.getSignatureHelpItems=(g,S,...y)=>{let k=w(g);if(!k)return B(g,S,...y);if(!u()||!I(k,S))return;let E=B(g,P(k,S),...y),D=E&&O(k,E.applicableSpan);return E&&D?{...E,applicableSpan:D}:void 0};let Te=d("getDefinitionAndBoundSpan");o.getDefinitionAndBoundSpan=(g,S)=>{let y=w(g);if(!y)return xe(Te(g,S));if(!u())return;let k=Te(g,P(y,S)),E=k&&O(y,k.textSpan);return k&&E?{...xe(k),textSpan:E}:void 0};let xe=(g)=>g&&{...g,definitions:W(g.definitions)};for(let g of["getDefinitionAtPosition","getTypeDefinitionAtPosition","getImplementationAtPosition"]){let S=d(g);o[g]=(y,k,...E)=>{let D=w(y);if(D&&!u())return;return W(S(y,D?P(D,k):k,...E))}}for(let g of["getReferencesAtPosition"]){let S=d(g);o[g]=(y,k,...E)=>{let D=w(y);if(D&&!u())return;return z(S(y,D?P(D,k):k,...E))}}let rn=d("findReferences");o.findReferences=(g,S)=>{let y=w(g);if(y&&!u())return;return rn(g,y?P(y,S):S)?.map((k)=>{let E=M(k.definition);return E?{definition:E,references:z(k.references)}:void 0}).filter((k)=>k!==void 0)};let on=d("getDocumentHighlights");o.getDocumentHighlights=(g,S,y)=>{let k=w(g);if(k&&(!u()||!I(k,S)))return;return on(g,k?P(k,S):S,y)?.map((E)=>{let D=w(E.fileName);if(!D)return E;return{...E,highlightSpans:E.highlightSpans.map((V)=>{let F=O(D,V.textSpan);return F?{...V,textSpan:F,contextSpan:V.contextSpan&&O(D,V.contextSpan)}:void 0}).filter((V)=>V!==void 0)}})};let an=d("getNavigationTree");o.getNavigationTree=(g)=>{let S=an(g),y=w(g);if(!y)return S;let k=(D)=>{let V=D.spans.map((te)=>O(y,te)).filter((te)=>te!==void 0);if(V.length===0)return;let F=D.nameSpan&&O(y,D.nameSpan),be=D.childItems?.map(k).filter((te)=>te!==void 0);return{...D,spans:V,nameSpan:F,childItems:be}},E={...S,spans:[{start:0,length:y.source.length}]};return u()?{...E,childItems:S.childItems?.map(k).filter((D)=>D!==void 0)}:{...E,childItems:[]}};let cn={getEncodedSemanticClassifications:()=>{return},getEncodedSyntacticClassifications:()=>{return},getSemanticClassifications:()=>[],getSyntacticClassifications:()=>[],getFormattingEditsForDocument:()=>[],getFormattingEditsForRange:()=>[],getFormattingEditsAfterKeystroke:()=>[],getNavigationBarItems:()=>[],getOutliningSpans:()=>[],getBraceMatchingAtPosition:()=>[],getTodoComments:()=>[],getDocCommentTemplateAtPosition:()=>{return},getJsxClosingTagAtPosition:()=>{return},getLinkedEditingRangeAtPosition:()=>{return},getSpanOfEnclosingComment:()=>{return},getCodeFixesAtPosition:()=>[],getApplicableRefactors:()=>[],getEditsForRefactor:()=>{return},getRenameInfo:()=>({canRename:!1,localizedErrorMessage:"Rename is not supported in .stx files."}),findRenameLocations:()=>{return},provideInlayHints:()=>[],prepareCallHierarchy:()=>{return},provideCallHierarchyIncomingCalls:()=>[],provideCallHierarchyOutgoingCalls:()=>[],getFileReferences:()=>[]};for(let[g,S]of Object.entries(cn)){let y=o[g];if(typeof y!=="function")continue;let k=y.bind(o);o[g]=(E,...D)=>typeof E==="string"&&$e(E)?S():k(E,...D)}return o[Qt]=!0,c("Language service proxy created"),o},getExternalFiles(a){if(r.has(a))return[];return a.getFileNames().filter(en)},onConfigurationChanged(a){t={...t,...a};for(let c of i)c()}}}var sn=vs;module.exports=sn;
106
+ `,t=H.default.join(n,`${cn.createHash("sha1").update(r).digest("hex").slice(0,16)}.d.ts`);if(!Z.existsSync(t))Z.mkdirSync(n,{recursive:!0}),Z.writeFileSync(t,r);return t}function Dr(e){let n=new Set,r=new Set;function t(s){if(r.has(s)||!Z.existsSync(s))return;r.add(s);let i=Z.readFileSync(s,"utf8");for(let o of Ut(i))n.add(o);for(let o of i.matchAll(/<reference\s+path=["']([^"']+)["']/g))t(H.default.resolve(H.default.dirname(s),o[1]))}if(e)t(e);return[...n]}function jr(e,n,r,t){let s=(a)=>Zt(n,{templateExpressions:_e(e),componentMethodValidator:(c,l,p)=>{let x=t.typescript.transpileModule(c+(l==="{"?"{}":";"),{reportDiagnostics:!0,compilerOptions:{target:t.typescript.ScriptTarget.ESNext}});if(x.diagnostics?.some((b)=>b.category===t.typescript.DiagnosticCategory.Error))return!1;return l==="{"?x.outputText.includes(`function ${p}(`):!x.outputText.trim()},originDir:H.default.dirname(e),filePath:e,readComponent:t.readComponent,componentsDir:t.componentsDir,projectRoot:t.projectRoot,reference:a,declaredGlobals:Dr(a),runtimeGlobals:!a,contextScope:"global"}),i=s(t.declarations);if(t.declarations&&!i.referenced)i=s(void 0);let o=me(n);return{version:r,source:n,virtual:i,blocks:o,sourceStarts:$e(n),virtualStarts:$e(i.text),collisions:new Set(Gt(o))}}function Fr(e,n){let r=e.findConfigFile(n,e.sys.fileExists);if(!r)return;let t=e.readConfigFile(r,e.sys.readFile);if(t.error)return;let s=e.parseJsonConfigFileContent(t.config,e.sys,H.default.dirname(r),void 0,r),i={};if(s.options.types)i.types=s.options.types;let o=s.options.paths;if(o){let a=s.options.baseUrl??s.options.pathsBasePath??H.default.dirname(r);i.paths={};for(let[c,l]of Object.entries(o))i.paths[c]=l.map((p)=>H.default.isAbsolute(p)?p:H.default.resolve(a,p))}return i}function Br(e,n={}){let r=e.typescript,t={},s=new Set,i=new WeakSet;return{create(o){let a=(g)=>{o.project.projectService.logger.info(`[stx-plugin] ${g}`)};if(o.languageService[on])return i.add(o.project),a("already applied to this project by another registration of the plugin; leaving it as it is"),o.languageService;a("TypeScript stx plugin initialized");let{languageService:c,languageServiceHost:l}=o,p=(g)=>{let S=c[g];return typeof S==="function"?S.bind(c):()=>{return}},x=l.getScriptSnapshot?.bind(l),b=l.getScriptVersion?.bind(l),_=Ir(n.declarationsDir);if(!_)a("the bundled stx declarations were not found; apps without their own fall back to `any`");let A=(g)=>r.sys?.fileExists(g)??Z.existsSync(g),C=(g)=>{let S=r.readConfigFile?.(g,(y)=>r.sys.readFile(y));return S&&!S.error?S.config:void 0},d=new Map,f=(g)=>{let S=H.default.dirname(g);if(!d.has(S)){let y=Nr(S,A)??_,T=[];try{T=(sn(S,C,A)?.libs??[]).filter(A)}catch(k){a(`could not read the stx entry of the project's tsconfig: ${String(k)}`)}d.set(S,y&&T.length>0?Lr([y,...T]):y)}return d.get(S)},w=new Map,h=(g)=>{let S=x?.(g);return S?S.getText(0,S.getLength()):r.sys?.readFile(g)},u=()=>t.enabled!==!1;s.add(()=>{w.clear(),o.project.refreshDiagnostics?.()});let m=(g)=>{if(!an(g)||!x)return;let S=`${b?.(g)||"0"}:${l.getProjectVersion?.()||""}`,y=w.get(g);if(y&&y.version===S&&[...y.virtual.componentDependencies||[]].every(([k,N])=>h(k)===N))return y;let T=x(g);if(!T)return;try{let k=o.project.getCurrentDirectory?.(),N=k?H.default.resolve(k,typeof o.config?.componentsDir==="string"?o.config.componentsDir:"components"):void 0,z=jr(g,T.getText(0,T.getLength()),S,{typescript:r,declarations:f(g),readComponent:h,componentsDir:N,projectRoot:k});return w.set(g,z),z}catch(k){a(`failed to build virtual document for ${g}: ${String(k)}`);return}},E=(g)=>_e(g)?m(g):void 0,R=(g,S)=>{let y=ce(g.virtualStarts,S);return Qt(g.virtual,y.line,y.column)},v=(g,S)=>{let y=R(g,S);if(!y)return;return Fe(g.sourceStarts,y.line,y.column)},O=(g,S)=>{let y=ce(g.sourceStarts,S);return Fe(g.virtualStarts,y.line,Xt(g.virtual,y.line,y.column))},M=(g,S)=>{let y=v(g,S.start);if(y===void 0)return;let T=v(g,S.start+S.length);return{start:y,length:T!==void 0&&T>=y?T-y:S.length}},I=(g,S)=>g.blocks.some((y)=>y.offset!==void 0&&S>=y.offset&&S<=y.offset+y.code.length),P=(g)=>{let S=E(g.fileName);if(!S)return g;let y=M(S,g.textSpan);if(!y)return;let T=g.contextSpan?M(S,g.contextSpan):void 0;return{...g,textSpan:y,contextSpan:T}},B=(g)=>g?.map(P).filter((S)=>S!==void 0),K=(g)=>g?.filter((S)=>{let y=E(S.fileName);if(!y)return!0;let{line:T}=ce(y.virtualStarts,S.textSpan.start);return T<=y.virtual.sourceLineCount&&!y.virtual.lineMap.has(T)});if(x)l.getScriptSnapshot=(g)=>{let S=m(g);if(S)return r.ScriptSnapshot.fromString(S.virtual.text);return x(g)};let q=l.getCompilationSettings?.bind(l),G=r.server?.ProjectKind!==void 0&&o.project.projectKind===r.server.ProjectKind.Inferred;if(q&&G){let g=null,S;l.getCompilationSettings=()=>{let y=q();if(g===null)try{g=Fr(r,o.project.getCurrentDirectory())}catch(T){a(`could not read the project's tsconfig: ${String(T)}`),g=void 0}if(!g)return y;if(S?.from!==y)S={from:y,options:{...y,...g.paths&&!y.paths?{paths:g.paths}:{},...g.types&&!y.types?{types:g.types}:{}}};return S.options}}let ee=(g,S)=>{let y=m(g);if(!y)return S;if(_e(g)&&!u())return[];let T=[];for(let k of S){let N=typeof k.messageText==="string"?k.messageText:k.messageText.messageText;if(Mr.has(k.code)){let te=N.match(/'([^']+)'/)?.[1];if(te&&y.collisions.has(te))continue}if(k.start===void 0){T.push(k);continue}let z=R(y,k.start);if(!z||Yt(z,k.code))continue;let V=Fe(y.sourceStarts,z.line,z.column),be=v(y,k.start+(k.length??0));T.push({...k,start:V,length:be!==void 0&&be>V?be-V:k.length??0})}return T},re=p("getSemanticDiagnostics");c.getSemanticDiagnostics=(g)=>{let S=ee(g,re(g)),y=E(g);if(!y||!u())return S;let T=c.getProgram?.()?.getSourceFile(g);for(let k of rn(y.source,y.blocks))S.push({file:T,start:k.offset,length:k.length,messageText:k.message,category:r.DiagnosticCategory?.Error??1,code:0,source:"stx"});return S};let X=p("getSyntacticDiagnostics");c.getSyntacticDiagnostics=(g)=>ee(g,X(g));let le=p("getSuggestionDiagnostics");c.getSuggestionDiagnostics=(g)=>ee(g,le(g));let D=p("getQuickInfoAtPosition");c.getQuickInfoAtPosition=(g,S,...y)=>{let T=E(g);if(!T)return D(g,S,...y);if(!u())return;let k=D(g,O(T,S),...y);if(!k)return k;let N=M(T,k.textSpan);return N?{...k,textSpan:N}:void 0};let W=p("getCompletionsAtPosition");c.getCompletionsAtPosition=(g,S,y,...T)=>{let k=E(g);if(!k)return W(g,S,y,...T);if(!u()||!I(k,S))return;let N=W(g,O(k,S),{...y,includeCompletionsForModuleExports:!1},...T);if(!N)return N;let z=(V)=>V&&M(k,V);return{...N,optionalReplacementSpan:z(N.optionalReplacementSpan),entries:N.entries.filter((V)=>!V.name.startsWith("__stx")&&!V.name.startsWith("__Stx")).map((V)=>V.replacementSpan?{...V,replacementSpan:z(V.replacementSpan)}:V)}};let Y=p("getCompletionEntryDetails");c.getCompletionEntryDetails=(g,S,...y)=>{let T=E(g);if(!T)return Y(g,S,...y);let k=Y(g,O(T,S),...y);return k?{...k,codeActions:void 0}:k};let F=p("getSignatureHelpItems");c.getSignatureHelpItems=(g,S,...y)=>{let T=E(g);if(!T)return F(g,S,...y);if(!u()||!I(T,S))return;let k=F(g,O(T,S),...y),N=k&&M(T,k.applicableSpan);return k&&N?{...k,applicableSpan:N}:void 0};let ke=p("getDefinitionAndBoundSpan");c.getDefinitionAndBoundSpan=(g,S)=>{let y=E(g);if(!y)return xe(ke(g,S));if(!u())return;let T=ke(g,O(y,S)),k=T&&M(y,T.textSpan);return T&&k?{...xe(T),textSpan:k}:void 0};let xe=(g)=>g&&{...g,definitions:K(g.definitions)};for(let g of["getDefinitionAtPosition","getTypeDefinitionAtPosition","getImplementationAtPosition"]){let S=p(g);c[g]=(y,T,...k)=>{let N=E(y);if(N&&!u())return;return K(S(y,N?O(N,T):T,...k))}}for(let g of["getReferencesAtPosition"]){let S=p(g);c[g]=(y,T,...k)=>{let N=E(y);if(N&&!u())return;return B(S(y,N?O(N,T):T,...k))}}let pn=p("findReferences");c.findReferences=(g,S)=>{let y=E(g);if(y&&!u())return;return pn(g,y?O(y,S):S)?.map((T)=>{let k=P(T.definition);return k?{definition:k,references:B(T.references)}:void 0}).filter((T)=>T!==void 0)};let dn=p("getDocumentHighlights");c.getDocumentHighlights=(g,S,y)=>{let T=E(g);if(T&&(!u()||!I(T,S)))return;return dn(g,T?O(T,S):S,y)?.map((k)=>{let N=E(k.fileName);if(!N)return k;return{...k,highlightSpans:k.highlightSpans.map((z)=>{let V=M(N,z.textSpan);return V?{...z,textSpan:V,contextSpan:z.contextSpan&&M(N,z.contextSpan)}:void 0}).filter((z)=>z!==void 0)}})};let fn=p("getNavigationTree");c.getNavigationTree=(g)=>{let S=fn(g),y=E(g);if(!y)return S;let T=(N)=>{let z=N.spans.map((te)=>M(y,te)).filter((te)=>te!==void 0);if(z.length===0)return;let V=N.nameSpan&&M(y,N.nameSpan),be=N.childItems?.map(T).filter((te)=>te!==void 0);return{...N,spans:z,nameSpan:V,childItems:be}},k={...S,spans:[{start:0,length:y.source.length}]};return u()?{...k,childItems:S.childItems?.map(T).filter((N)=>N!==void 0)}:{...k,childItems:[]}};let mn={getEncodedSemanticClassifications:()=>{return},getEncodedSyntacticClassifications:()=>{return},getSemanticClassifications:()=>[],getSyntacticClassifications:()=>[],getFormattingEditsForDocument:()=>[],getFormattingEditsForRange:()=>[],getFormattingEditsAfterKeystroke:()=>[],getNavigationBarItems:()=>[],getOutliningSpans:()=>[],getBraceMatchingAtPosition:()=>[],getTodoComments:()=>[],getDocCommentTemplateAtPosition:()=>{return},getJsxClosingTagAtPosition:()=>{return},getLinkedEditingRangeAtPosition:()=>{return},getSpanOfEnclosingComment:()=>{return},getCodeFixesAtPosition:()=>[],getApplicableRefactors:()=>[],getEditsForRefactor:()=>{return},getRenameInfo:()=>({canRename:!1,localizedErrorMessage:"Rename is not supported in .stx files."}),findRenameLocations:()=>{return},provideInlayHints:()=>[],prepareCallHierarchy:()=>{return},provideCallHierarchyIncomingCalls:()=>[],provideCallHierarchyOutgoingCalls:()=>[],getFileReferences:()=>[]};for(let[g,S]of Object.entries(mn)){let y=c[g];if(typeof y!=="function")continue;let T=y.bind(c);c[g]=(k,...N)=>typeof k==="string"&&_e(k)?S():T(k,...N)}return c[on]=!0,a("Language service proxy created"),c},getExternalFiles(o){if(i.has(o))return[];return o.getFileNames().filter(an)},onConfigurationChanged(o){t={...t,...o};for(let a of s)a()}}}var un=Br;module.exports=un;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx-vscode",
3
3
  "type": "module",
4
- "version": "0.2.888",
4
+ "version": "0.2.890",
5
5
  "description": "stx language support for VS Code extensions to embed: the hovers, completions, diagnostics, grammar, snippets, language configuration and TypeScript server plugin behind the stx extension.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",