@stacksjs/stx-vscode 0.2.887 → 0.2.889

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.887",
3
+ "version": "0.2.889",
4
4
  "private": true,
5
5
  "main": "index.js"
6
6
  }
@@ -1,16 +1,16 @@
1
- var cn=Object.create;var{getPrototypeOf:ln,defineProperty:et,getOwnPropertyNames:un}=Object;var tt=Object.prototype.hasOwnProperty;function dn(e){return this[e]}var pn,fn,Q=(e,n,s)=>{var t=e!=null&&typeof e==="object";if(t){var r=n?pn??=new WeakMap:fn??=new WeakMap,i=r.get(e);if(i)return i}s=e!=null?cn(ln(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 un(e))if(!tt.call(a,c))et(a,c,{get:dn.bind(e,c),enumerable:!0})}if(t)r.set(e,a);return a};var en=require("node:crypto"),X=require("node:fs"),tn=require("node:os"),F=Q(require("node:path"));var je=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b/y,mn=new Map(["textarea","title","xmp","iframe","noembed","noframes"].map((e)=>[e,new RegExp(`</${e}\\s*>`,"ig")]));function gn(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 r=je.exec(e);if(!r){s=t+1;continue}let i=je.lastIndex,a=i,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=r[1]==="/",l=e[a-1]==="/";n.push({start:t,end:a+1,name:r[2],attributes:e.slice(i,l?a-1:a),closing:o,selfClosing:l}),s=a+1;let p=r[2].toLowerCase();if(!o&&p==="plaintext")break;let x=mn.get(p);if(!o&&(p==="script"||p==="style"||x)){let b=x??(p==="script"?hn:xn);b.lastIndex=s;let C=b.exec(e);if(!C)break;s=C.index}}return n}var hn=/<\/script\s*>/ig;var xn=/<\/style\s*>/ig;function ue(e){let n=gn(e),s=[];for(let t=0;t<n.length;t++){let r=n[t],i=n[t+1];if(r.name.toLowerCase()!=="script"||r.closing||i?.name.toLowerCase()!=="script"||!i.closing)continue;s.push({start:r.start,end:i.end,bodyStart:r.end,bodyEnd:i.start,attrs:r.attributes})}return s}function de(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 Le=["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 bn(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 yn(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,r="{",i="";while(t<e.length){let a=e[t];if(a==="\\"){t+=2;continue}if(a==='"'||a==="'"){t=bn(e,t),r=re,i="";continue}if(a==="`"){t=yn(e,t),r=re,i="";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(r,i)){let c=rt(e,t);if(c!==-1){t=c,r=re,i="";continue}}if(a==="{")s++;else if(a==="}"){if(s--,s===0)return t}if(/[\w$]/.test(a))i=/[\w$]/.test(r)?i+a:a,r=a;else if(!/\s/.test(a))r=a,i="";t++}return e.length}var Sn=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function st(e,n){if(n)return Sn.has(n);return!(e===")"||e==="]"||e===re)}var re="\x00";function rt(e,n){let s=n+1,t=!1;while(s<e.length){let r=e[s];if(r===`
3
- `)return-1;if(r==="\\"){s+=2;continue}if(r==="[")t=!0;else if(r==="]")t=!1;else if(r==="/"&&!t){s++;while(s<e.length&&/[a-z]/i.test(e[s]))s++;return s}s++}return-1}function N(e){return Ne(e,!1)}function it(e){return Ne(e,!0)}function Ne(e,n){let s="",t=0,r="",i="";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 mn=Object.create;var{getPrototypeOf:gn,defineProperty:nt,getOwnPropertyNames:hn}=Object;var rt=Object.prototype.hasOwnProperty;function xn(e){return this[e]}var bn,yn,Q=(e,n,r)=>{var t=e!=null&&typeof e==="object";if(t){var s=n?bn??=new WeakMap:yn??=new WeakMap,i=s.get(e);if(i)return i}r=e!=null?mn(gn(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 c of hn(e))if(!rt.call(o,c))nt(o,c,{get:xn.bind(e,c),enumerable:!0})}if(t)s.set(e,o);return o};var an=require("node:crypto"),Z=require("node:fs"),cn=require("node:os"),U=Q(require("node:path"));var Fe=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b/y,Sn=new Map(["textarea","title","xmp","iframe","noembed","noframes"].map((e)=>[e,new RegExp(`</${e}\\s*>`,"ig")]));function vn(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}Fe.lastIndex=t;let s=Fe.exec(e);if(!s){r=t+1;continue}let i=Fe.lastIndex,o=i,c=null;for(;o<e.length;o++){let b=e[o];if(c){if(b===c)c=null}else if(b==='"'||b==="'")c=b;else if(b===">")break}if(o===e.length)break;let a=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:a,selfClosing:l}),r=o+1;let f=s[2].toLowerCase();if(!a&&f==="plaintext")break;let x=Sn.get(f);if(!a&&(f==="script"||f==="style"||x)){let b=x??(f==="script"?wn:En);b.lastIndex=r;let _=b.exec(e);if(!_)break;r=_.index}}return n}var wn=/<\/script\s*>/ig;var En=/<\/style\s*>/ig;function ue(e){let n=vn(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 Be=["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 _n(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=_n(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 c=ot(e,t);if(c!==-1){t=c,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 kn=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function it(e,n){if(n)return kn.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 ze(e,!1)}function at(e){return ze(e,!0)}function ze(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 c=e[t];if(c==='"'||c==="'"){let a=c;r+=" ",t++;while(t<e.length&&e[t]!==a){if(e[t]==="\\"){r+=" ",t+=2;continue}r+=e[t]===`
7
7
  `?`
8
- `:" ",t++}s+=n?"$":" ",t++,r=re,i="";continue}if(c==="/"&&st(r,i)){let o=rt(e,t);if(o!==-1){s+=`/${" ".repeat(o-t-2)}/`,t=o,r=re,i="";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+=Ne(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(c==="/"&&it(s,i)){let a=ot(e,t);if(a!==-1){r+=`/${" ".repeat(a-t-2)}/`,t=a,s=se,i="";continue}}if(c==="`"){r+=n?"(":" ",t++;while(t<e.length&&e[t]!=="`"){if(e[t]==="\\"){r+=" ",t+=2;continue}if(e[t]==="$"&&e[t+1]==="{"){let a=t+2,l=st(e,a);if(r+=n?" {":" ",r+=ze(e.slice(a,l),n),l<e.length)r+=n?"}":" ";t=l+1;continue}r+=e[t]===`
9
9
  `?`
10
- `:" ",t++}s+=n?")":" ",t++,r=re,i="";continue}if(s+=c,t++,/[\w$]/.test(c))i=/[\w$]/.test(r)?i+c:c,r=c;else if(!/\s/.test(c))r=c,i=""}return s}function U(e){let n=new Uint16Array(e.length),s=0,t=!0;for(let r=0;r<e.length;r++){let i=e[r];if(i===")"||i==="]"||i==="}")if(s===0)t=!1;else s--;if(n[r]=s,i==="("||i==="["||i==="{")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 r=this.fnCache,i=this.fnCacheMaxSize,a=(...c)=>(o)=>{try{let l=`${s}:${o}`,p=r.get(l);if(!p){if(r.size>=i){let x=r.keys().next().value;if(x)r.delete(x)}p=Function(...n,`
10
+ `:" ",t++}r+=n?")":" ",t++,s=se,i="";continue}if(r+=c,t++,/[\w$]/.test(c))i=/[\w$]/.test(s)?i+c:c,s=c;else if(!/\s/.test(c))s=c,i=""}return r}function J(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((c)=>c.context.join(",")===r);if(t)return t.func;let s=this.fnCache,i=this.fnCacheMaxSize,o=(...c)=>(a)=>{try{let l=`${r}:${a}`,f=s.get(l);if(!f){if(s.size>=i){let x=s.keys().next().value;if(x)s.delete(x)}f=Function(...n,`
11
11
  'use strict';
12
12
  try {
13
- return ${o};
13
+ return ${a};
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
- `),r.set(l,p)}return p(...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 ks=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(),r=performance.now()-s;return this.recordTime(e,r),this.checkBudget(e,r),t}async timeAsync(e,n){if(!this.enabled)return n();let s=performance.now(),t=await n(),r=performance.now()-s;return this.recordTime(e,r),this.checkBudget(e,r),t}checkBudget(e,n){let s=this.budgets.get(e);if(!s)return;let t=n/s.maxTime*100,r=s.warnThreshold!==void 0?n>=s.maxTime*s.warnThreshold&&n<s.maxTime:!1,i=n>=s.maxTime;if(!r&&!i)return;let a={label:e,actualTime:n,budgetTime:s.maxTime,exceedancePercent:t,timestamp:new Date,isWarning:r};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=r?`[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(i)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 r=this.budgets.get(s);n[s]={count:t.count,avgTime:t.totalTime/t.count,totalTime:t.totalTime,maxTime:t.maxTime,minTime:t.minTime,budget:r?.maxTime,budgetUtilization:r?t.totalTime/t.count/r.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 vn(){if(!Be)Be=new at;return Be}var As=new Proxy({},{get(e,n){return vn()[n]}});var ct=new ze(32,{maxBytes:2097152,sizeOf:(e)=>e.code.length*4}),ie=/^[A-Za-z_$][\w$]*$/,wn=new Set(["if","for","while","switch","with"]),lt=["(","[","{"],ut=[")","]","}"],$n=new Set(["const","let","var","return","if","for","while","do","switch","try","throw","export"]);function _n(e){let n=N(e),s=[];for(let t of n.matchAll(/[A-Za-z_$][\w$]*|=>|\.\.\.|[^\s]/g)){let r=t.index??0;s.push({text:t[0],start:r,end:r+t[0].length})}return{code:n,tokens:s}}function Cn(e){let n=ct.get(e);if(n)return n;let{code:s,tokens:t}=_n(e),r=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 _=i.at(-1);if(_!==void 0&&["()","[]","{}"].includes(t[_].text+f))i.pop(),r.set(_,d),r.set(d,_)}}function a(d,f){let _=[],h=d;for(let u=d;u<f;u++){if(["(","[","{"].includes(t[u].text)&&(r.get(u)??f)<f){u=r.get(u);continue}if(t[u].text===",")_.push([h,u]),h=u+1}return _.push([h,f]),_}let c=[];function o(d,f,_,h=!1,u){if(t[d]?.text==="...")d++;if(d>=f)return;let m=t[d].text;if(ie.test(m)){if(_.add(m),_===x)c.push({name:m,token:d,functionScoped:h,declarationToken:u});return}if(m!=="{"&&m!=="[")return;let w=r.get(d);if(w===void 0||w>=f)return;for(let[P,v]of a(d+1,w)){let R=P;if(m==="{")for(let O=P;O<v;O++){if(t[O].text===":"){R=O+1;break}if(t[O].text==="=")break;if(["(","[","{"].includes(t[O].text)&&r.has(O))O=r.get(O)}o(R,v,_,h,u)}}function l(d,f){let _=new Set;for(let[h,u]of a(d,f))o(h,u,_);return _}function p(d){let f=d;for(;f<t.length;f++){let _=t[f].text;if(["(","[","{"].includes(_)&&r.has(f)){f=r.get(f);continue}if([",",";",")","]","}"].includes(_))break}return t[Math.max(d,f-1)]?.end??s.length}let x=new Set,b=[];for(let d=0;d<t.length;d++)if(t[d].text==="=>"){let f=d-1,_=f,h;if(t[f]?.text===")"&&r.has(f))_=r.get(f),h=l(_+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==="{"&&r.has(u)?t[r.get(u)].end:p(u);b.push({start:t[_].start,end:m,bodyStart:t[u]?.start??m,functionBody:!0,names:h})}else if(t[d].text==="("&&r.has(d)){let f=t[d-1]?.text;if(!f||wn.has(f)||!ie.test(f)&&f!=="*"&&f!=="]")continue;let _=r.get(d),h=_+1;if(t[h]?.text===":"){h++;while(h<t.length&&!["{","=>",";","="].includes(t[h].text))h++}if(t[h]?.text!=="{"||!r.has(h))continue;b.push({start:t[d].start,end:t[r.get(h)].end,bodyStart:t[h].start,functionBody:f!=="catch",names:l(d+1,_)})}function C(d){let f=d;for(;f<t.length;f++){let _=t[f].text;if(lt.includes(_)&&r.has(f)){f=r.get(f);continue}if(_===";"||ut.includes(_))break;let h=t[f-1];if(f>d&&$n.has(_)&&h.text!==".")break;if(f>d&&/[\n\r]/.test(s.slice(h.end,t[f].start))&&(/^[\w$]+$/.test(h.text)||ut.includes(h.text)||['"',"'","`"].includes(h.text))&&ie.test(_)&&!["in","of","instanceof"].includes(_))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!=="("||!r.has(f))continue;let _=r.get(f),h=_+1,u=t[h]?.text==="{"&&r.has(h)?r.get(h):C(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:_,start:t[f].start,end:m})}for(let d=0;d<t.length;d++){let f=t[d].text,_=t[d-1]?.text;if(_==="."||t[d+1]?.text===":")continue;if(_==="as"||_==="<")continue;if(f==="const"||f==="let"||f==="var"){let h=C(d+1),u=d+1,m=!1,w=!1,P=0;for(let v=d+1;v<=h;v++){let R=t[v]?.text;if(v<h&&lt.includes(R)&&r.has(v)&&r.get(v)<h){v=r.get(v);continue}if(v<h&&R===":"&&!w)m=!0;else if(v<h&&R==="="&&P===0)m=!1,w=!0;else if(v<h&&m&&R==="<")P++;else if(v<h&&m&&R===">"&&P>0)P--;else if(v===h||R===","&&P===0)o(u,v,x,f==="var",d),u=v+1,m=!1,w=!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),c.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),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&&r.has(m)){let w=r.get(m);for(let[P,v]of a(m+1,w)){let R=v-1;while(R>=P&&!ie.test(t[R].text))R--;if(R>=P&&t[R].text!=="type")c.push({name:t[R].text,token:R,file:!0})}}}}let T={code:s,scopes:b,loops:A,declarations:x,sites:c,tokens:t,pairs:r};return ct.set(e,T),T}function Ve(e){let n=Cn(e),s=it(e),{depths:t}=U(s),r=[];for(let i of n.sites){if(i.file||i.declarationToken===void 0)continue;let a=n.tokens[i.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 p=c.slice(l.index+l[0].length);if(!/[\r\n]/.test(p)||!/^(?:[\w$]+|[)\]])$/.test(l[0])||["return","throw","yield","await","new"].includes(l[0]))continue}}r.push({name:i.name,start:a.start})}return r}function dt(e){return[...new Set(Ve(e).map((n)=>n.name))].sort()}function pt(e){let n=e.indexOf(" as ");if(n!==-1){let i=e.slice(0,n).trim(),a=e.slice(n+4).trim();return i&&a?{arrayExpr:i,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(),r=s[2].trim();return t&&r?{arrayExpr:r,itemVar:t}:null}var pe=["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 En=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var Ns=pe.filter((e)=>!En.includes(e));var Tn=["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"],kn=["x-init","x-transition","x-effect","x-on"],Bs=[...Tn,...kn];var Te=Q(require("node:fs"),1),fe=Q(require("node:path"),1);function ft(e,n,s,t){let r=0;for(let i=n;i<e.length;i++)if(e[i]===s)r++;else if(e[i]===t&&!(t===">"&&e[i-1]==="=")){if(--r===0)return i}return-1}function An(e){let n=N(e),s=0,t=0,r=[];for(let i=0;i<n.length;i++)if("([{".includes(n[i]))s++;else if(")]}".includes(n[i]))s--;else if(n[i]===","&&s===0)r.push(e.slice(t,i).trim()),t=i+1;return r.push(e.slice(t).trim()),r}function Ke(e,n){let s=N(e),t=new RegExp(`\\b(?:${n.map((r)=>r.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g");for(let r of s.matchAll(t)){let i=r.index+r[0].length,a="";if(s[i]==="<"){let o=ft(s,i,"<",">");if(o<0)continue;a=e.slice(i+1,o),i=o+1;while(/\s/.test(s[i]||"")&&i<s.length)i++}if(s[i]!=="(")continue;let c=ft(s,i,"(",")");if(c>=0)return{type:a,args:An(e.slice(i+1,c))}}return null}var Ce=`
21
+ `),s.set(l,f)}return f(...c)}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 Hr=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 a of this.violationHandlers)try{a(o)}catch{}let c=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(c);break;case"warn":console.warn(c);break;case"error":console.error(c);break;case"throw":if(i)throw Error(c);else console.warn(c);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 Ve=null;function Cn(){if(!Ve)Ve=new lt;return Ve}var Kr=new Proxy({},{get(e,n){return Cn()[n]}});var ut=new Se(32,{maxBytes:2097152,sizeOf:(e)=>e.code.length*4}),ie=/^[A-Za-z_$][\w$]*$/,Tn=new Set(["if","for","while","switch","with"]),pt=["(","[","{"],ft=[")","]","}"],An=new Set(["const","let","var","return","if","for","while","do","switch","try","throw","export"]);function Rn(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 On(e){let n=ut.get(e);if(n)return n;let{code:r,tokens:t}=Rn(e),s=new Map,i=[];for(let p=0;p<t.length;p++){let d=t[p].text;if(["(","[","{"].includes(d))i.push(p);else if([")","]","}"].includes(d)){let E=i.at(-1);if(E!==void 0&&["()","[]","{}"].includes(t[E].text+d))i.pop(),s.set(E,p),s.set(p,E)}}function o(p,d){let E=[],h=p;for(let u=p;u<d;u++){if(["(","[","{"].includes(t[u].text)&&(s.get(u)??d)<d){u=s.get(u);continue}if(t[u].text===",")E.push([h,u]),h=u+1}return E.push([h,d]),E}let c=[];function a(p,d,E,h=!1,u){if(t[p]?.text==="...")p++;if(p>=d)return;let m=t[p].text;if(ie.test(m)){if(E.add(m),E===x)c.push({name:m,token:p,functionScoped:h,declarationToken:u});return}if(m!=="{"&&m!=="[")return;let w=s.get(p);if(w===void 0||w>=d)return;for(let[R,v]of o(p+1,w)){let O=R;if(m==="{")for(let I=R;I<v;I++){if(t[I].text===":"){O=I+1;break}if(t[I].text==="=")break;if(["(","[","{"].includes(t[I].text)&&s.has(I))I=s.get(I)}a(O,v,E,h,u)}}function l(p,d){let E=new Set;for(let[h,u]of o(p,d))a(h,u,E);return E}function f(p){let d=p;for(;d<t.length;d++){let E=t[d].text;if(["(","[","{"].includes(E)&&s.has(d)){d=s.get(d);continue}if([",",";",")","]","}"].includes(E))break}return t[Math.max(p,d-1)]?.end??r.length}let x=new Set,b=[];for(let p=0;p<t.length;p++)if(t[p].text==="=>"){let d=p-1,E=d,h;if(t[d]?.text===")"&&s.has(d))E=s.get(d),h=l(E+1,d);else if(t[d]&&ie.test(t[d].text))h=new Set([t[d].text]);else continue;let u=p+1,m=t[u]?.text==="{"&&s.has(u)?t[s.get(u)].end:f(u);b.push({start:t[E].start,end:m,bodyStart:t[u]?.start??m,functionBody:!0,names:h})}else if(t[p].text==="("&&s.has(p)){let d=t[p-1]?.text;if(!d||Tn.has(d)||!ie.test(d)&&d!=="*"&&d!=="]")continue;let E=s.get(p),h=E+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[p].start,end:t[s.get(h)].end,bodyStart:t[h].start,functionBody:d!=="catch",names:l(p+1,E)})}function _(p){let d=p;for(;d<t.length;d++){let E=t[d].text;if(pt.includes(E)&&s.has(d)){d=s.get(d);continue}if(E===";"||ft.includes(E))break;let h=t[d-1];if(d>p&&An.has(E)&&h.text!==".")break;if(d>p&&/[\n\r]/.test(r.slice(h.end,t[d].start))&&(/^[\w$]+$/.test(h.text)||ft.includes(h.text)||['"',"'","`"].includes(h.text))&&ie.test(E)&&!["in","of","instanceof"].includes(E))break}return d}let A=[];for(let p=0;p<t.length;p++){if(t[p].text!=="for")continue;let d=t[p+1]?.text==="await"?p+2:p+1;if(t[d]?.text!=="("||!s.has(d))continue;let E=s.get(d),h=E+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:d,headEnd:E,start:t[d].start,end:m})}for(let p=0;p<t.length;p++){let d=t[p].text,E=t[p-1]?.text;if(E==="."||t[p+1]?.text===":")continue;if(E==="as"||E==="<")continue;if(d==="const"||d==="let"||d==="var"){let h=_(p+1),u=p+1,m=!1,w=!1,R=0;for(let v=p+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===":"&&!w)m=!0;else if(v<h&&O==="="&&R===0)m=!1,w=!0;else if(v<h&&m&&O==="<")R++;else if(v<h&&m&&O===">"&&R>0)R--;else if(v===h||O===","&&R===0)a(u,v,x,d==="var",p),u=v+1,m=!1,w=!1}}else if(d==="function"||d==="class"){let h=p+1;if(t[h]?.text==="*")h++;if(t[h]&&ie.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(d==="import"){let h=p+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),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&&s.has(m)){let w=s.get(m);for(let[R,v]of o(m+1,w)){let O=v-1;while(O>=R&&!ie.test(t[O].text))O--;if(O>=R&&t[O].text!=="type")c.push({name:t[O].text,token:O,file:!0})}}}}let C={code:r,scopes:b,loops:A,declarations:x,sites:c,tokens:t,pairs:s};return ut.set(e,C),C}function ke(e){let n=On(e),r=at(e),{depths:t}=J(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 c=r.slice(0,o.start),a=[...c.matchAll(/[A-Za-z_$][\w$]*|\d+(?:[.]\d+)?|[^\s]/g)],l=a.pop();if(l?.[0]==="declare")continue;if(o.text==="function"||o.text==="class"){while(l&&["async","export","default","abstract"].includes(l[0]))l=a.pop();if(l&&![";","}"].includes(l[0])){let f=c.slice(l.index+l[0].length);if(!/[\r\n]/.test(f)||!/^(?:[\w$]+|[)\]])$/.test(l[0])||["return","throw","yield","await","new"].includes(l[0]))continue}}s.push({name:i.name,start:o.start})}return s}function dt(e){return[...new Set(ke(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 fe=["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 Pn=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var ts=fe.filter((e)=>!Pn.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"],ns=[...In,...Nn];var Ae=Q(require("node:fs"),1),de=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 Mn(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 We(e,n){let r=j(e),t=new RegExp(`\\b(?:${n.map((s)=>s.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g");for(let s of r.matchAll(t)){let i=s.index+s[0].length,o="";if(r[i]==="<"){let a=gt(r,i,"<",">");if(a<0)continue;o=e.slice(i+1,a),i=a+1;while(/\s/.test(r[i]||"")&&i<r.length)i++}if(r[i]!=="(")continue;let c=gt(r,i,"(",")");if(c>=0)return{type:o,args:Mn(e.slice(i+1,c))}}return null}var Ce=`
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"]},r=N(e),i=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(b,C,A,T,d)=>{if(r.slice(d,d+6)!=="import")return b;if(T.endsWith(".stx"))return"";let f=`${n}Import${s.length}`;if(s.push(`import * as ${f} from ${JSON.stringify(T)};`),C.startsWith("*"))return`import ${C.replace(/^\*\s+as\s+/,"")} = ${f};`;if(!C.startsWith("{"))return`import ${C} = ${f}.default;`;return C.slice(1,-1).split(",").map((_)=>{let[h,u=h]=_.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!h)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(T)&&h in t)t[h].push(u);return`import ${u} = ${f}.${h};`}).join(`
30
- `)}),a=Ke(e,t.defineProps),c=Ke(e,t.defineEmits),o=Ke(e,t.withDefaults);if(!a&&!c)return{declarations:"",props:null,events:null};let l=[],p=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>>;`),p=`${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 Te(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,p)=>{if(s.slice(p,p+6)!=="import")return b;if(C.endsWith(".stx"))return"";let d=`${n}Import${r.length}`;if(r.push(`import * as ${d} from ${JSON.stringify(C)};`),_.startsWith("*"))return`import ${_.replace(/^\*\s+as\s+/,"")} = ${d};`;if(!_.startsWith("{"))return`import ${_} = ${d}.default;`;return _.slice(1,-1).split(",").map((E)=>{let[h,u=h]=E.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} = ${d}.${h};`}).join(`
30
+ `)}),o=We(e,t.defineProps),c=We(e,t.defineEmits),a=We(e,t.withDefaults);if(!o&&!c)return{declarations:"",props:null,events:null};let l=[],f=null,x=null;if(o){l.push(`const __options = (${o.args[0]||"{}"}) as const;`),l.push(`const __defaults = (${a?.args[1]||"{}"});`);let b=o.type||"__StxOptions<typeof __options>";l.push(`export type __StxProps = __StxDefaults<${b}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),f=`${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:`${r.join(`
31
31
  `)}
32
32
  namespace ${n} {
33
33
  ${i}
34
34
  ${l.join(`
35
35
  `)}
36
- }`,props:p,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,r=[j.default.join(e,"src"),j.default.join(e,"dist"),e];function i(a,c){if(c>6)return;let o;try{o=oe.default.readdirSync(a,{withFileTypes:!0})}catch{return}for(let l of o){let p=j.default.join(a,l.name);if(l.isDirectory()){if(l.name==="node_modules"||l.name.startsWith("."))continue;i(p,c+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 C=gt(x);if(!t.has(C))t.set(C,p)}}}for(let a of r)if(i(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 r=j.default.dirname(s);if(r===s)return null;s=r}}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((r)=>r.charAt(0).toUpperCase()+r.slice(1)).join(""),t=gt(n);return[n,s,t]}function Pn(e,n){let[s,t,r]=yt(e);for(let i of[s,s.toLowerCase(),t,r]){let a=n?.__importedComponents?.get(i);if(a!==void 0)return a}}function Rn(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 r=j.default.dirname(t);if(r===t)return;t=r}}var Mn=["src/ui","src/components","components","dist"];function On(e,n){let s=j.default.resolve(e);if(!n&&!s.split(j.default.sep).includes("node_modules"))return[];let t=Rn(s,n);if(!t)return[];let r=[];try{let c=JSON.parse(oe.default.readFileSync(j.default.join(t,"package.json"),"utf8")).stx?.components;if(Array.isArray(c))r=c.filter((o)=>typeof o==="string")}catch{}let i=r.length?r:Mn;return[j.default.dirname(j.default.resolve(e)),...i.map((a)=>j.default.resolve(t,a))]}function*Dn(e,n,s={},t){let r=yt(e);if(r[0].startsWith("./")||r[0].startsWith("../")){yield j.default.resolve(j.default.dirname(n),`${r[0]}.stx`);return}let i=[...new Set(r.map((o)=>`${o}.stx`))],a=s.projectRoot||process.cwd(),c=[...On(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 i)yield j.default.join(o,l);try{for(let l of oe.default.readdirSync(o,{withFileTypes:!0}))if(l.isDirectory())for(let p of i)yield j.default.join(o,l.name,p)}catch{}}}function St(e,n,s={},t){let r=Pn(e,t);if(r!==void 0)return r;for(let i of Dn(e,n,s,t))try{if(oe.default.statSync(i,{throwIfNoEntry:!1})?.isFile())return i}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*In(e){let n=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,s;while(s=n.exec(e)){let t=n.lastIndex,r=[];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 a=t;t+=i.length;while(/\s/.test(e[t]||""))t++;if(e[t]!=="="){r.push({name:i,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 p=t;if(o){let x=N(e.slice(t)),b=1,C=0;for(;C<x.length;C++){if(x[C]==="{")b++;if(x[C]==="}"&&--b===0)break}t+=C}else if(l)while(t<e.length&&e[t]!==c)t++;else while(t<e.length&&!/[\s/>]/.test(e[t]))t++;if(r.push({name:i,value:e.slice(p,t),offset:p,braced:o}),l||o)t++}n.lastIndex=t,yield{name:s[1],offset:s.index,attributes:r}}}function $t(e,n,s){let t=[],r=[Ce,"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,a=new Map,c=new Map,o=s.scriptCode(e,s.filePath),l=N(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 T=A[2],d=fe.default.isAbsolute(T)||T.startsWith(".")?fe.default.resolve(fe.default.dirname(s.filePath),T):xt(T,fe.default.dirname(s.filePath));if(!d)continue;let f=d.endsWith(".stx")?d:Te.default.existsSync(`${d}.stx`)?`${d}.stx`:void 0,_=f?null:ht(d,!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+/),P=f||_?.get(m)||_?.get(m.toLowerCase());if(P)c.set(w,P),c.set(w.toLowerCase(),P),c.set(w.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),P)}}for(let A of n.matchAll(/@import\s*\(([^)]+)\)/g))for(let T of A[1].matchAll(/['"]([^'"]+)['"]/g)){let d=bt(T[1],s.filePath,s).find((f)=>Te.default.statSync(f,{throwIfNoEntry:!1})?.isFile());if(d)c.set(fe.default.basename(T[1]).replace(/\.stx$/,""),d)}let p={__importedComponents:c},x=new Map,b=(A,T,d)=>{let f=e.slice(0,A);return{code:T,offset:A,attribute:d,anchor:!0,kind:"directive",line:f.split(`
37
- `).length,column:A-f.lastIndexOf(`
38
- `)}},C=(A,T,d)=>t.push({expression:A,statement:{text:T+A.code+d,prefixLength:T.length}});for(let A of In(n)){if(wt(A.name)||A.name==="component")continue;let T=St(A.name,s.filePath,s,p);if(!T)continue;let d=x.get(T);if(!d){let _;try{_=s.readComponent?s.readComponent(T):Te.default.readFileSync(T,"utf8")}catch{continue}if(_===void 0)continue;a.set(T,_),d=Ee(s.scriptCode(_,T),`__StxComponent${x.size}`),x.set(T,d),r.push(d.declarations)}let f=[];for(let _ of A.attributes){let{name:h,offset:u}=_,m=_.value===!0?"true":_.value;if(h.startsWith("@")||h.startsWith("v-on:")){if(d.events&&_.value!==!0)i.set(u,`__StxEvent<${d.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 P=(w?w[1]||"modelValue":h.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(D,M)=>M.toUpperCase());if(f.push(P),!d.props)continue;let v=h.startsWith(":")||h.startsWith("v-bind:")||!!w||_.braced,R=v?m:_.value!==!0?JSON.stringify(m):"true",O=!v&&_.value!==!0&&(m==="true"||m==="false");C(b(u,R,h),";void ((",`) satisfies ${O?"__StxStaticProp":"__StxProp"}<${d.props}, ${JSON.stringify(P)}>);`)}if(d.props){let _=[...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 ({ ${_} } satisfies ${d.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:x.size?r.join(`
39
- `):"",checks:t,events:i,dependencies:a}}var qe=Q(require("node:fs"),1),Z=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"];function Fe(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function We(e){for(let n of ue(Fe(e))){let s=de(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 r=JSON.parse(t);if(!r||typeof r!=="object"||Array.isArray(r))throw Error("expected a JSON object");return r}catch(r){throw Error(`${n}: <script component> must contain JSON metadata (${r.message})`)}}function Ge(e,n){let s=N(e),t=new Set(Ve(e).map((o)=>o.start)),r=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,i=[],a=n?void 0:new Bun.Transpiler({loader:"ts"}),c;while(c=r.exec(s)){if(!t.has(c.index+c[0].indexOf("function")))continue;let o=r.lastIndex;while(/\s/.test(s[o]||""))o++;let l=o;if(s[o]==="<")o=He(s,o,"<",">");if(o<0)continue;let p=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 C=s[o];if(C!=="{"&&C!==";")continue;let A=e.slice(c.index,o).trim();if(n){if(!n(A,C,c[1]))continue}else{let d;try{d=a.transformSync(A+(C==="{"?"{}":";"))}catch{continue}if(C==="{"&&!d.includes(`function ${c[1]}(`))continue;if(C===";"&&d.trim())continue}let T=C==="{"?He(s,o,"{","}"):o+1;if(T<0)break;i.push({name:c[1],header:A,generic:p,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]),...C==="{"?{source:e.slice(c.index,T)}:{}}),r.lastIndex=T;break}}return i}function Ae(e,n){if(e[n]!=="(")return null;let s=0,t="";for(let r=n;r<e.length;r++){let i=e[r];if(t!==""){if(i==="\\")r++;else if(i===t)t="";continue}if(i==="'"||i==='"'||i==="`"){t=i;continue}if(i==="(")s++;else if(i===")"){if(s--,s===0)return{expression:e.slice(n+1,r),end:r+1}}}return null}function Ct(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 r=0,i=null;for(let a=n;a<e.length;a++){let c=e[a];if(i){if(c==="\\"){a++;continue}if(c===i)i=null;continue}if(c==="'"||c==='"'||c==="`"){i=c;continue}if(c===s)r++;else if(c===t){if(t===">"&&e[a-1]==="=")continue;if(r--,r===0)return a+1}}return-1}function Ze(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 jn=new Set(ke);function Pe(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(N(s.text).trim()),r=N(e),i=U(r).depths,a=[...r.matchAll(/\b(?:interface|type)\s+InheritedContext\b/g)].find((x)=>i[x.index]===0)?.index??0,c=s.text.slice(s.text.indexOf("{")+1,s.text.lastIndexOf("}")),o=N(c),l=U(o).depths,p=[...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?p:[],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=N(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 r=t[2].trim(),i=["stx","@stacksjs/stx"].includes(t[4]);if(/^[A-Za-z_$][\w$]*$/.test(r)){n.push(r);continue}if(!r.startsWith("{")||!r.endsWith("}"))continue;for(let a of r.slice(1,-1).split(",")){if(/^\s*type\s+/.test(a))continue;let[c,o=c]=a.trim().split(/\s+as\s+/);if(o&&!(i&&jn.has(c)))n.push(o)}}return n}function Et(e){let n=Pe(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 Tt(e,n){let s=[Ce],t=[],r=new Map,i=Z.default.resolve(n.filePath),a=i.split(Z.default.sep).lastIndexOf("views"),c=a>=0?i.split(Z.default.sep).slice(0,a).join(Z.default.sep):Z.default.dirname(i),o=Z.default.resolve(n.partialsDir||Z.default.join(c,"partials")),l=Z.default.resolve(n.layoutsDir||Z.default.join(c,"views/layouts"));if([o,l].some((d)=>i===d||i.startsWith(d+Z.default.sep)))return{declarations:"",checks:t,dependencies:r};let p=(d)=>n.readTemplate?.(d)??(qe.default.existsSync(d)?qe.default.readFileSync(d,"utf8"):void 0),x=0,b=!1,C=[];function A(d,f){let _=e.slice(0,d).split(`
42
- `).length,h=d-e.lastIndexOf(`
43
- `,d-1),u={code:e.slice(d,e.indexOf(`
44
- `,d)<0?e.length:e.indexOf(`
45
- `,d)),line:_,column:h,kind:"directive",offset:d,anchor:!0};t.push({expression:u,statement:{text:`;${f}`,prefixLength:1}})}function T(d,f,_,h,u,m){let w=`__StxInherited${x++}`;while((e+d+[...r.values()].join("")).includes(w))w+="_";let P=me(d).filter((L)=>L.kind==="server").map((L)=>L.code).join(`
46
- `),v=`${w}ParentValue`,R=`${w}ParentType`;s.push(`type ${R} = ${_};`);let O=Je(Me(P,Z.default.dirname(f)),w);s.push(...O.imports);let D=Pe(P);if(D&&u!==void 0){b=!0;let L=O.imports.length?O.aliases.join(`
47
- `):"",H=Ee(`${L}
48
- ${D.types}
49
- const __contract = defineProps<InheritedContext>();`,`${w}Contract`);s.push(H.declarations),s.push(`declare const ${w}Input: ${R};`),A(u,D.unsupported?`({})[${JSON.stringify(D.unsupported)}];`:`${w}Input satisfies ${H.props};`)}let M=[...new Set([...ae(P),...Ln(P)])],z=[...new Set([...h,...D?.keys||[]])].filter((L)=>!M.includes(L)),W=D?`${R} & ${w}Contract.__StxProps`:R,q=Re(O.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),G=[],ee=ge(d),se=/@(include|extends|layout)\s*\(/g,J;while(J=se.exec(ee)){let L=Ae(ee,se.lastIndex-1);if(!L)continue;se.lastIndex=L.end;let H=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(L.expression);if(!H){C.push({offset:u??J.index,message:`Inherited context cannot be checked across dynamic @${J[1]}`});continue}let Y=H[2],B=J[1];if(B!=="include"&&H[3])C.push({offset:u??J.index,message:`Inherited context cannot be checked for unsupported @${B} data arguments`});let _e=B==="include"?o:l,xe=Z.default.resolve(Y.startsWith(".")?Z.default.dirname(f):_e,Y.endsWith(".stx")?Y:Y+".stx");if(p(xe)===void 0){C.push({offset:u??J.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??J.index})}let le=`{ ...${v}${M.length?", "+M.join(", "):""} }`;s.push(`namespace ${w} {
50
- ${O.aliases.join(`
36
+ }`,props:f,events:x}}var oe=Q(require("node:fs"),1),D=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=[D.default.join(e,"src"),D.default.join(e,"dist"),e];function i(o,c){if(c>6)return;let a;try{a=oe.default.readdirSync(o,{withFileTypes:!0})}catch{return}for(let l of a){let f=D.default.join(o,l.name);if(l.isDirectory()){if(l.name==="node_modules"||l.name.startsWith("."))continue;i(f,c+1)}else if(l.isFile()&&l.name.endsWith(".stx")){let x=l.name.slice(0,-4);if(!t.has(x))t.set(x,f);let b=x.toLowerCase();if(!t.has(b))t.set(b,f);let _=xt(x);if(!t.has(_))t.set(_,f)}}}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=D.default.join(r,"node_modules",e);try{if(oe.default.statSync(t).isDirectory())return t}catch{}let s=D.default.dirname(r);if(s===r)return null;r=s}}function St(e,n,r={}){return[D.default.resolve(D.default.dirname(n),`${e}.stx`),D.default.resolve(D.default.dirname(n),e),D.default.resolve(r.componentsDir||"components",`${e}.stx`),D.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 Ln(e,n){let r=n?D.default.resolve(n):void 0,t=D.default.dirname(D.default.resolve(e));for(;;){if(oe.default.existsSync(D.default.join(t,"package.json")))return r&&t===r?void 0:t;let s=D.default.dirname(t);if(s===t)return;t=s}}var jn=["src/ui","src/components","components","dist"];function Fn(e,n){let r=D.default.resolve(e);if(!n&&!r.split(D.default.sep).includes("node_modules"))return[];let t=Ln(r,n);if(!t)return[];let s=[];try{let c=JSON.parse(oe.default.readFileSync(D.default.join(t,"package.json"),"utf8")).stx?.components;if(Array.isArray(c))s=c.filter((a)=>typeof a==="string")}catch{}let i=s.length?s:jn;return[D.default.dirname(D.default.resolve(e)),...i.map((o)=>D.default.resolve(t,o))]}function*Bn(e,n,r={},t){let s=vt(e);if(s[0].startsWith("./")||s[0].startsWith("../")){yield D.default.resolve(D.default.dirname(n),`${s[0]}.stx`);return}let i=[...new Set(s.map((a)=>`${a}.stx`))],o=r.projectRoot||process.cwd(),c=[...Fn(n,r.projectRoot),...t?.__originalFilePath?[D.default.join(D.default.dirname(t.__originalFilePath),"components")]:[],...r.componentsDir?[r.componentsDir]:[],D.default.join(D.default.dirname(n),"components"),D.default.resolve(o,"src/components"),D.default.resolve(o,"components"),D.default.resolve("/home/runner/work/stx/stx/packages/stx/src","components")];for(let a of new Set(c)){for(let l of i)yield D.default.join(a,l);try{for(let l of oe.default.readdirSync(a,{withFileTypes:!0}))if(l.isDirectory())for(let f of i)yield D.default.join(a,l.name,f)}catch{}}}function wt(e,n,r={},t){let s=Dn(e,t);if(s!==void 0)return s;for(let i of Bn(e,n,r,t))try{if(oe.default.statSync(i,{throwIfNoEntry:!1})?.isFile())return i}catch{}return null}var Et=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)&&[...Et].some((n)=>n.toLowerCase()===e.toLowerCase());return Et.has(e)||/[A-Z]/.test(e)}function*zn(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 c=e[t],a=c==="{",l=c==='"'||c==="'";if(l||a)t++;let f=t;if(a){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]!==c)t++;else while(t<e.length&&!/[\s/>]/.test(e[t]))t++;if(s.push({name:i,value:e.slice(f,t),offset:f,braced:a}),l||a)t++}n.lastIndex=t,yield{name:r[1],offset:r.index,attributes:s}}}function _t(e,n,r){let t=[],s=[Ce,"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,c=new Map,a=r.scriptCode(e,r.filePath),l=j(a);for(let A of a.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(l.slice(A.index,A.index+6)!=="import")continue;let C=A[2],p=de.default.isAbsolute(C)||C.startsWith(".")?de.default.resolve(de.default.dirname(r.filePath),C):yt(C,de.default.dirname(r.filePath));if(!p)continue;let d=p.endsWith(".stx")?p:Ae.default.existsSync(`${p}.stx`)?`${p}.stx`:void 0,E=d?null:bt(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=d||E?.get(m)||E?.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=St(C[1],r.filePath,r).find((d)=>Ae.default.statSync(d,{throwIfNoEntry:!1})?.isFile());if(p)c.set(de.default.basename(C[1]).replace(/\.stx$/,""),p)}let f={__importedComponents:c},x=new Map,b=(A,C,p)=>{let d=e.slice(0,A);return{code:C,offset:A,attribute:p,anchor:!0,kind:"directive",line:d.split(`
37
+ `).length,column:A-d.lastIndexOf(`
38
+ `)}},_=(A,C,p)=>t.push({expression:A,statement:{text:C+A.code+p,prefixLength:C.length}});for(let A of zn(n)){if($t(A.name)||A.name==="component")continue;let C=wt(A.name,r.filePath,r,f);if(!C)continue;let p=x.get(C);if(!p){let E;try{E=r.readComponent?r.readComponent(C):Ae.default.readFileSync(C,"utf8")}catch{continue}if(E===void 0)continue;o.set(C,E),p=Te(r.scriptCode(E,C),`__StxComponent${x.size}`),x.set(C,p),s.push(p.declarations)}let d=[];for(let E of A.attributes){let{name:h,offset:u}=E,m=E.value===!0?"true":E.value;if(h.startsWith("@")||h.startsWith("v-on:")){if(p.events&&E.value!==!0)i.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,(N,P)=>P.toUpperCase());if(d.push(R),!p.props)continue;let v=h.startsWith(":")||h.startsWith("v-bind:")||!!w||E.braced,O=v?m:E.value!==!0?JSON.stringify(m):"true",I=!v&&E.value!==!0&&(m==="true"||m==="false");_(b(u,O,h),";void ((",`) satisfies ${I?"__StxStaticProp":"__StxProp"}<${p.props}, ${JSON.stringify(R)}>);`)}if(p.props){let E=[...new Set(d)].map((u)=>`${JSON.stringify(u)}: undefined as any`).join(", "),h=b(A.offset,`<${A.name}>`);t.push({expression:h,statement:{text:`;void ({ ${E} } satisfies ${p.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:x.size?s.join(`
39
+ `):"",checks:t,events:i,dependencies:o}}var Je=Q(require("node:fs"),1),G=Q(require("node:path"),1);var Re=["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 At=require("node:module");function Vn(){let{NODE_ENV:e}=process.env;return e==="production"}function Ue(){let{STX_DEBUG:e}=process.env;return!Vn()||e==="true"}var Wn={showRelativePaths:!1,enableAutoRecovery:Ue(),logRecoveryWarnings:!0},ys={...Wn};class He{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 Gn=new He;var qn={maxSanitizeDepth:10,allowBracketNotation:!1},ui={...qn};var Jn="__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"],Zn=[...Ct,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],pi=Zn.map(()=>{return}),fi=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 di=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",Jn]);var Tt=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],mi=(()=>{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 gi=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Tt.join(",")}}() are allowed`;var hi=Symbol("stx.sanitizeCache");var xi=`stx-compile-probe:${globalThis.crypto.randomUUID()}`;var bi=new Se(2000,{maxBytes:2097152,sizeOf:(e)=>e.sourceBytes});function Oe(e,n,r,t){if(e[n]!==r)return-1;let s=0,i=null;for(let o=n;o<e.length;o++){let c=e[o];if(i){if(c==="\\"){o++;continue}if(c===i)i=null;continue}if(c==="'"||c==='"'||c==="`"){i=c;continue}if(c===r)s++;else if(c===t){if(t===">"&&e[o-1]==="=")continue;if(s--,s===0)return o+1}}return-1}var Hi=new Set(At.builtinModules);function Ke(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function Ge(e){for(let n of ue(Ke(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 Rt(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 Xe(e,n){let r=j(e),t=new Set(ke(e).map((a)=>a.start)),s=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,i=[],o=n?void 0:new Bun.Transpiler({loader:"ts"}),c;while(c=s.exec(r)){if(!t.has(c.index+c[0].indexOf("function")))continue;let a=s.lastIndex;while(/\s/.test(r[a]||""))a++;let l=a;if(r[a]==="<")a=Oe(r,a,"<",">");if(a<0)continue;let f=e.slice(l,a).trim();while(/\s/.test(r[a]||""))a++;if(r[a]!=="(")continue;let x=a,b=Oe(r,a,"(",")");if(b<0)continue;for(a=b;a<e.length;a++){let _=r[a];if(_!=="{"&&_!==";")continue;let A=e.slice(c.index,a).trim();if(n){if(!n(A,_,c[1]))continue}else{let p;try{p=o.transformSync(A+(_==="{"?"{}":";"))}catch{continue}if(_==="{"&&!p.includes(`function ${c[1]}(`))continue;if(_===";"&&p.trim())continue}let C=_==="{"?Oe(r,a,"{","}"):a+1;if(C<0)break;i.push({name:c[1],header:A,generic:f,parameterOffset:x+1,parameters:e.slice(x+1,b-1),returns:e.slice(b,a).trim().replace(/^:\s*/,""),async:/\basync\s+function/.test(c[0]),..._==="{"?{source:e.slice(c.index,C)}:{}}),s.lastIndex=C;break}}return i}function Pe(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 Ot(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 Qn=new Set(Re);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=J(s).depths,o=[...s.matchAll(/\b(?:interface|type)\s+InheritedContext\b/g)].find((x)=>i[x.index]===0)?.index??0,c=r.text.slice(r.text.indexOf("{")+1,r.text.lastIndexOf("}")),a=j(c),l=J(a).depths,f=[...a.matchAll(/(?:^|[;,\n])\s*(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:/g)].filter((x)=>l[x.index]===0).map((x)=>x[1]);return{keys:t?f:[],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 er(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[c,a=c]=o.trim().split(/\s+as\s+/);if(a&&!(i&&Qn.has(c)))n.push(a)}}return n}function Pt(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=[Ce],t=[],s=new Map,i=G.default.resolve(n.filePath),o=i.split(G.default.sep).lastIndexOf("views"),c=o>=0?i.split(G.default.sep).slice(0,o).join(G.default.sep):G.default.dirname(i),a=G.default.resolve(n.partialsDir||G.default.join(c,"partials")),l=G.default.resolve(n.layoutsDir||G.default.join(c,"views/layouts"));if([a,l].some((p)=>i===p||i.startsWith(p+G.default.sep)))return{declarations:"",checks:t,dependencies:s};let f=(p)=>n.readTemplate?.(p)??(Je.default.existsSync(p)?Je.default.readFileSync(p,"utf8"):void 0),x=0,b=!1,_=[];function A(p,d){let E=e.slice(0,p).split(`
48
+ `).length,h=p-e.lastIndexOf(`
49
+ `,p-1),u={code:e.slice(p,e.indexOf(`
50
+ `,p)<0?e.length:e.indexOf(`
51
+ `,p)),line:E,column:h,kind:"directive",offset:p,anchor:!0};t.push({expression:u,statement:{text:`;${d}`,prefixLength:1}})}function C(p,d,E,h,u,m){let w=`__StxInherited${x++}`;while((e+p+[...s.values()].join("")).includes(w))w+="_";let R=me(p).filter((L)=>L.kind==="server").map((L)=>L.code).join(`
52
+ `),v=`${w}ParentValue`,O=`${w}ParentType`;r.push(`type ${O} = ${E};`);let I=Ze(Me(R,G.default.dirname(d)),w);r.push(...I.imports);let N=Ie(R);if(N&&u!==void 0){b=!0;let L=I.imports.length?I.aliases.join(`
53
+ `):"",W=Te(`${L}
54
+ ${N.types}
55
+ const __contract = defineProps<InheritedContext>();`,`${w}Contract`);r.push(W.declarations),r.push(`declare const ${w}Input: ${O};`),A(u,N.unsupported?`({})[${JSON.stringify(N.unsupported)}];`:`${w}Input satisfies ${W.props};`)}let P=[...new Set([...ae(R),...er(R)])],B=[...new Set([...h,...N?.keys||[]])].filter((L)=>!P.includes(L)),H=N?`${O} & ${w}Contract.__StxProps`:O,X=Ne(I.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),K=[],ee=ge(p),re=/@(include|extends|layout)\s*\(/g,q;while(q=re.exec(ee)){let L=Pe(ee,re.lastIndex-1);if(!L)continue;re.lastIndex=L.end;let W=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(L.expression);if(!W){_.push({offset:u??q.index,message:`Inherited context cannot be checked across dynamic @${q[1]}`});continue}let Y=W[2],F=q[1];if(F!=="include"&&W[3])_.push({offset:u??q.index,message:`Inherited context cannot be checked for unsupported @${F} data arguments`});let _e=F==="include"?a:l,xe=G.default.resolve(Y.startsWith(".")?G.default.dirname(d):_e,Y.endsWith(".stx")?Y:Y+".stx");if(f(xe)===void 0){_.push({offset:u??q.index,message:`Inherited context target cannot be resolved: ${Y}`});continue}K.push({name:`edge${K.length}`,target:xe,kind:F,args:F==="include"?W[3]||"{}":"{}",offset:u??q.index})}let le=`{ ...${v}${P.length?", "+P.join(", "):""} }`;r.push(`namespace ${w} {
56
+ ${I.aliases.join(`
51
57
  `)}
52
- export async function read(${v}: ${u===void 0?"{}":W}) {
53
- ${z.length?`const { ${z.join(", ")} } = ${v};`:""}
54
- ${q}
55
- return { context: ${le}${G.map((L)=>`, ${L.name}: { ...${le}, ...(${L.args}) }`).join("")} };
58
+ export async function read(${v}: ${u===void 0?"{}":H}) {
59
+ ${B.length?`const { ${B.join(", ")} } = ${v};`:""}
60
+ ${X}
61
+ return { context: ${le}${K.map((L)=>`, ${L.name}: { ...${le}, ...(${L.args}) }`).join("")} };
56
62
  }
57
- }`);for(let L of G){if(m.includes(L.target)||m.length>=32){C.push({offset:L.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let H=p(L.target);r.set(L.target,H),T(H,L.target,`Awaited<ReturnType<typeof ${w}.read>>[${JSON.stringify(L.name)}]`,[...new Set([...h,...M])],L.offset,[...m,L.target])}return w}if(T(e,i,"{}",[],void 0,[i]),b||n.contractsKnown)for(let d of C)A(d.offset,`({})[${JSON.stringify(d.message)}];`);return{declarations:b?s.join(`
58
- `):"",checks:t,dependencies:r}}function kt(e,n){let s=Fe(e),t=We(e);if(!t)return;let r;try{r=_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 L of K){if(m.includes(L.target)||m.length>=32){_.push({offset:L.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let W=f(L.target);s.set(L.target,W),C(W,L.target,`Awaited<ReturnType<typeof ${w}.read>>[${JSON.stringify(L.name)}]`,[...new Set([...h,...P])],L.offset,[...m,L.target])}return w}if(C(e,i,"{}",[],void 0,[i]),b||n.contractsKnown)for(let p of _)A(p.offset,`({})[${JSON.stringify(p.message)}];`);return{declarations:b?r.join(`
64
+ `):"",checks:t,dependencies:s}}function Nt(e,n){let r=Ke(e),t=Ge(e);if(!t)return;let s;try{s=Rt(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(`
59
65
  `).length,column:m-e.lastIndexOf(`
60
- `,m-1),origin:"component"}],project:(P)=>({code:P,columns:new Map})}}let i=ue(s).filter((u)=>{let m=de(u.attrs);return ye(m)&&m.has("client")&&!m.has("server")&&!m.has("component")&&!m.has("stx:component")&&!m.has("src")}),a=i.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(r.properties||r.props||{}).map(([u,m])=>`${JSON.stringify(u)}: ${Ze(m)}`).join("; "),p=[...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 = ${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">;',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;",...p.map((u)=>`${JSON.stringify(u)}: typeof ${u};`),"}"].filter(Boolean).join(`
62
- `),b=-1;for(let u of i){let m=u.bodyStart,w=e.slice(m,u.bodyEnd),P=N(w),v=U(P).depths,R=[...P.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((O)=>v[O.index]===0)??(Oe(w).includes("ComponentState")?/\bComponentState\b/.exec(P):void 0);if(R){b=m+R.index;break}}let C=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
+ `),c=Xe(o,n),a=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("; "),f=[...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;",a?"type __StxState = __StxSpecific<ComponentState> extends true ? ComponentState : {};":"type __StxState = {};",a?'declare function __stxSpecificState(value: __StxSpecific<ComponentState> extends true ? true : "ComponentState requires named explicit fields without any or index signatures"): void;':"",a?"declare const __stxStateProperties: Pick<ComponentState, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;":"",a?'declare function __stxStateMethods(value: Extract<keyof ComponentState, __StxMethodNames | "emit" | "requestUpdate" | "updateComplete" | "renderRoot"> extends never ? true : "ComponentState cannot redeclare component methods"): void;':"",`type __StxMethodNames = ${f.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">;',a?'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;",...f.map((u)=>`${JSON.stringify(u)}: typeof ${u};`),"}"].filter(Boolean).join(`
68
+ `),b=-1;for(let u of i){let m=u.bodyStart,w=e.slice(m,u.bodyEnd),R=j(w),v=J(R).depths,O=[...R.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((I)=>v[I.index]===0)??(De(w).includes("ComponentState")?/\bComponentState\b/.exec(R):void 0);if(O){b=m+O.index;break}}let _=a&&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:T}=t,d=N(T),f=U(d).depths,_=new Map,h=!1;for(let u of T.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&&!_.has(m))_.set(m,A+u.index)}for(let[u,m]of Object.entries(r.properties||r.props||{})){let w=_.get(u)??A,P=e.slice(0,w).split(`
70
+ `,b-1)}]:[],{start:A,code:C}=t,p=j(C),d=J(p).depths,E=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(d[u.index]===1&&["properties","props"].includes(m)){h=!0;continue}if(h&&d[u.index]===1)h=!1;if(h&&d[u.index]===2&&!E.has(m))E.set(m,A+u.index)}for(let[u,m]of Object.entries(s.properties||s.props||{})){let w=E.get(u)??A,R=e.slice(0,w).split(`
65
71
  `).length,v=w-e.lastIndexOf(`
66
- `,w-1);if(!m||typeof m!=="object"||!["string","number","boolean","object","array"].includes(m.type))C.push({text:`({})[${JSON.stringify(`Property ${u} must declare string, number, boolean, object or array`)}];`,line:P,column:v,origin:"component"});if(m&&m.default!==void 0)C.push({text:`const __stxDefault${C.length}: ${Ze(m)} = ${JSON.stringify(m.default)};`,line:P,column:v,origin:"component"})}return{declarations:x,checks:C,project(u){let m=new Map,w=[],P=0;for(let v of Ge(u,n)){if(/^\s*this\s*:/.test(v.parameters))continue;let R=v.parameterOffset,O=`this: __StxNativeComponent${v.parameters.trim()?", ":""}`;w.push(u.slice(P,R),O);let D=u.slice(0,R).split(`
67
- `).length,M=R-u.lastIndexOf(`
68
- `,R-1),z=m.get(D)||[],W=z.at(-1),q=M+(W?W.generatedEnd-W.sourceEnd:0);z.push({sourceStart:M,sourceEnd:M,generatedStart:q,generatedEnd:q+O.length}),m.set(D,z),P=R}return w.push(u.slice(P)),{code:w.join(""),columns:m}}}}function At(e){let n=[],s=[],t=/@foreach\s*\(|@endforeach\b/g,r;while(r=t.exec(e)){if(r[0].startsWith("@endforeach")){let o=s.pop();if(o)o.end=r.index,n.push(o);continue}let i=Ae(e,t.lastIndex-1);if(!i)continue;let a=Ct(i.expression),c=i.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((i,a)=>i.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 r of e.matchAll(t)){let i=r[0];if(/^<\/template\s*>$/i.test(i)){let a=s.pop();if(a)a.end=r.index}else if(/^<template\b/i.test(i)&&!/\/\s*>$/.test(i)){let c=[...i.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((p)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(p[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:r.index+i.length,end:e.length,binding:o}:void 0;if(s.push(l),l)n.push(l)}}return n}function Nn(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=Nn(e);for(let t of ue(s)){let r=t.attrs.trim(),i=de(r),{bodyStart:a,bodyEnd:c}=t,o=e.slice(a,c);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=Se(e,a);n.push({kind:l,code:o,startLine:p,startColumn:ve(e,a),offset:a,attrs:r})}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=(r,i)=>{for(let a=r;a<i&&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 r of t){r.lastIndex=0;let i;while((i=r.exec(e))!==null)s(i.index,i.index+i[0].length)}return n.join("")}function jt(e){let n=0,s="";for(let t=0;t<e.length;t++){let r=e[t];if(s){if(r==="\\"){t++;continue}if(r===s)s="";continue}if(r==='"'||r==="'"||r==="`"){s=r;continue}if(r==="("||r==="["||r==="{"){n++;continue}if(r===")"||r==="]"||r==="}"){n--;continue}if(r==="|"&&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"]),De=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,Ye="__stx_interpolated",Rt="__StxElement",Nt="__StxTemplateValue",Bn=`type ${Nt}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function Mt(e){return e.replace(/\{\{[\s\S]*?\}\}/g,Ye).replace(/\{!![\s\S]*?!!\}/g,Ye)}function zn(e,n,s){let t=0;for(let r=n;r<e.length;r++){let i=e[r];if(i==="{"){t++;continue}if(i!=="}"&&i!=="!")continue;if(e.startsWith(s,r)&&t===0)return r;if(i==="}"&&t>0)t--}return-1}function Vn(e,n,s="0"){let t=`__stxScript${s}`;while((e+n).includes(t))t+="_";let r=new Map,i=[],a=[],c=N(e),o=we(e),l=[],p=0;for(let T=0;T<c.length;T++){let d=c.startsWith("{{",T);if(!d&&!c.startsWith("{!!",T))continue;let f=d?2:3,_=d?"}}":"!!}",h=zn(c,T+f,_);if(h<0)continue;let u=T,m=e.slice(u,h+_.length),w=m.slice(f,-_.length);T=h+_.length-1;let P=a.length,v=ce(o,u),R=ce(o,u+(d?2:3));a.push({code:jt(w),...R});let O=`${t}_${P}`,D=m.split(`
71
- `),M=D[0].length;D[0]=O+" ".repeat(Math.max(0,M-O.length));for(let G=1;G<D.length;G++)D[G]=D[G].replace(/[^\r]/g," ");let z=r.get(v.line)??[],W=z.at(-1),q=v.column+(W?W.generatedEnd-W.sourceEnd:0);z.push({sourceStart:v.column,sourceEnd:v.column+M,generatedStart:q,generatedEnd:q+D[0].length}),r.set(v.line,z),l.push(e.slice(p,u),D.join(`
72
- `)),p=u+m.length}l.push(e.slice(p));let x=l.join("");if(!a.length)return{code:x,columns:r,declarations:i};let{imports:b,aliases:C,body:A}=Je(n,t);for(let T of b)i.push({text:T});i.push({text:`namespace ${t}Scope {
73
- ${C.join(`
72
+ `,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}: ${qe(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 Xe(u,n)){if(/^\s*this\s*:/.test(v.parameters))continue;let O=v.parameterOffset,I=`this: __StxNativeComponent${v.parameters.trim()?", ":""}`;w.push(u.slice(R,O),I);let N=u.slice(0,O).split(`
73
+ `).length,P=O-u.lastIndexOf(`
74
+ `,O-1),B=m.get(N)||[],H=B.at(-1),X=P+(H?H.generatedEnd-H.sourceEnd:0);B.push({sourceStart:P,sourceEnd:P,generatedStart:X,generatedEnd:X+I.length}),m.set(N,B),R=O}return w.push(u.slice(R)),{code:w.join(""),columns:m}}}}function Mt(e){let n=[],r=[],t=/@foreach\s*\(|@endforeach\b/g,s;while(s=t.exec(e)){if(s[0].startsWith("@endforeach")){let a=r.pop();if(a)a.end=s.index,n.push(a);continue}let i=Pe(e,t.lastIndex-1);if(!i)continue;let o=Ot(i.expression),c=i.end;if(o)r.push({start:c,end:e.length,iterable:o.iterable,binding:o.key?`${o.value}, ${o.key}`:o.value});t.lastIndex=c}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 c=[...i.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((f)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(f[1])),a=(c?.[2]??c?.[3])?.trim();if(a&&c?.[1]==="data-stx-slot-binding")try{a=decodeURIComponent(a)}catch{a=void 0}let l=a?{start:s.index+i.length,end:e.length,binding:a}:void 0;if(r.push(l),l)n.push(l)}}return n}function tr(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=tr(e);for(let t of ue(r)){let s=t.attrs.trim(),i=pe(s),{bodyStart:o,bodyEnd:c}=t,a=e.slice(o,c);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",f=ve(e,o);n.push({kind:l,code:a,startLine:f,startColumn:we(e,o),offset:o,attrs:s})}return n}function ve(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 Vt(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 Wt=new Set([":for","x-for","v-for"]),Le=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,et="__stx_interpolated",Lt="__StxElement",Ut="__StxTemplateValue",nr=`type ${Ut}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function jt(e){return e.replace(/\{\{[\s\S]*?\}\}/g,et).replace(/\{!![\s\S]*?!!\}/g,et)}function rr(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 sr(e,n,r="0"){let t=`__stxScript${r}`;while((e+n).includes(t))t+="_";let s=new Map,i=[],o=[],c=j(e),a=Ee(e),l=[],f=0;for(let C=0;C<c.length;C++){let p=c.startsWith("{{",C);if(!p&&!c.startsWith("{!!",C))continue;let d=p?2:3,E=p?"}}":"!!}",h=rr(c,C+d,E);if(h<0)continue;let u=C,m=e.slice(u,h+E.length),w=m.slice(d,-E.length);C=h+E.length-1;let R=o.length,v=ce(a,u),O=ce(a,u+(p?2:3));o.push({code:Vt(w),...O});let I=`${t}_${R}`,N=m.split(`
77
+ `),P=N[0].length;N[0]=I+" ".repeat(Math.max(0,P-I.length));for(let K=1;K<N.length;K++)N[K]=N[K].replace(/[^\r]/g," ");let B=s.get(v.line)??[],H=B.at(-1),X=v.column+(H?H.generatedEnd-H.sourceEnd:0);B.push({sourceStart:v.column,sourceEnd:v.column+P,generatedStart:X,generatedEnd:X+N[0].length}),s.set(v.line,B),l.push(e.slice(f,u),N.join(`
78
+ `)),f=u+m.length}l.push(e.slice(f));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 {
79
+ ${_.join(`
74
80
  `)}
75
81
  export async function read() {
76
- ${Re(A).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
77
- return {`});for(let[T,d]of a.entries())i.push({text:`value${T}: (`}),i.push({text:d.code,origin:{line:d.line,column:d.column}}),i.push({text:"),"});i.push({text:`}
82
+ ${Ne(A).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
83
+ return {`});for(let[C,p]of o.entries())i.push({text:`value${C}: (`}),i.push({text:p.code,origin:{line:p.line,column:p.column}}),i.push({text:"),"});i.push({text:`}
78
84
  }
79
- }`});for(let T=0;T<a.length;T++)i.push({text:`declare var ${t}_${T}: Awaited<ReturnType<typeof ${t}Scope.read>>['value${T}']`});return{code:x,columns:r,declarations:i}}function Je(e,n){let s=[],{imports:t,body:r}=qn(e),i=[],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 p=o[1],x=/\{([\s\S]*?)\}/.exec(p);for(let T of x?.[1].split(",")??[]){let[d,f=d]=T.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(d==="default")i.push(`const ${f} = ${l}.default; type ${f} = import(${o[2]}).default`);else if(d)i.push(`import ${f} = ${l}.${d}`)}let b=p.replace(/\{[\s\S]*?\}/,""),C=/\*\s+as\s+(\w+)/.exec(b);if(C)i.push(`import ${C[1]} = ${l}`);let A=/^\s*([\w$]+)/.exec(b)?.[1];if(A)i.push(`const ${A} = ${l}.default; type ${A} = import(${o[2]}).default`)}return{imports:s,aliases:i,body:r}}function Ue(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 Kn=["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"],Hn=new RegExp(String.raw`^[ \t]*@(?:${Kn.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function Re(e){return e.replace(Hn,(n)=>n.replace(/[^\n]/g," "))}var Ot=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function Fn(e){let n=ge(e),s=[],t=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,r;while((r=t.exec(n))!==null){if(r[1]||r[3])continue;let c=r[2]??r[4]??"",o=r[2]!==void 0?2:3,l=jt(c);if(!l.trim())continue;let p=r.index+o+(l.length-l.trimStart().length);s.push({code:l.trim(),line:Se(n,p),column:ve(n,p),offset:p,kind:"interpolation"})}let i=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((r=i.exec(n))!==null){let a=r.index+r[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),p=l.trim();if(i.lastIndex=o+1,!p)continue;let x=a+1+(l.length-l.trimStart().length);s.push({code:p,line:Se(n,x),column:ve(n,x),offset:r.index,kind:"condition"})}De.lastIndex=0;while((r=De.exec(n))!==null){let a=r[1],c=r[3]??"",o=a.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(Ot.has(o)||Ot.has(a))continue;if(!c.trim())continue;let l=r.index+r[0].indexOf(r[2],r[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),C=x.index+x[0].length+(b.length-b.trimStart().length);s.push({code:Mt(b.trim()),line:Se(n,l+C),column:ve(n,l+C),offset:l+C,kind:"directive",attribute:o});continue}let p=c.length-c.trimStart().length;s.push({code:Mt(c.trim()),line:Se(n,l+p),column:ve(n,l+p),offset:l+p,kind:"directive",attribute:o})}return s.sort((a,c)=>a.line-c.line||a.column-c.column),s}var Wn=2000;function Gn(e,n){let s=0,t=Math.min(e.length,n+Wn);for(let r=n;r<t;r++){let i=e[r];if(i==="(")s++;else if(i===")"){if(s--,s===0)return e.slice(n+1,r)}}return null}function Zn(e){let n=new Map,s=(c,o)=>{let l=c.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?o:void 0,C=n.get(x);if(!C)n.set(x,{name:x,iterable:b});else if(C.iterable!==b)C.iterable=void 0}},t=/^\$?[A-Z_$][\w$]*$/i,r=(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=Gn(e,c.index+c[0].length-1);if(o===null)continue;let l=pt(o);if(!l)continue;s(l.itemVar.replace(/=>/g," "),r(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"?r(c[3]):void 0);for(let c of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))s(c[1]);let i=ge(e);De.lastIndex=0;let a;while((a=De.exec(i))!==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),r(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 dt(e)}var Dt=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"];function Bt(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function qn(e){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,s=[],t=e.replace(n,(r)=>(s.push(r.trim()),r.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}=pr(e),i=[],o=0;for(let c of t.split(/\n(?=import\b)/)){if(!c.trim())continue;let a=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(c);if(!a){r.push(c);continue}let l=`${n}Module${o++}`;r.push(`import * as ${l} from ${a[2]}`);let f=a[1],x=/\{([\s\S]*?)\}/.exec(f);for(let C of x?.[1].split(",")??[]){let[p,d=p]=C.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(p==="default")i.push(`const ${d} = ${l}.default; type ${d} = import(${a[2]}).default`);else if(p)i.push(`import ${d} = ${l}.${p}`)}let b=f.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(${a[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 ir=["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"],or=new RegExp(String.raw`^[ \t]*@(?:${ir.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function Ne(e){return e.replace(or,(n)=>n.replace(/[^\n]/g," "))}var Ft=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function ar(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 c=s[2]??s[4]??"",a=s[2]!==void 0?2:3,l=Vt(c);if(!l.trim())continue;let f=s.index+a+(l.length-l.trimStart().length);r.push({code:l.trim(),line:ve(n,f),column:we(n,f),offset:f,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,c=0,a=o;for(;a<n.length;a++){let b=n[a];if(b==="(")c++;else if(b===")"){if(c--,c===0)break}}if(c!==0)continue;let l=n.slice(o+1,a),f=l.trim();if(i.lastIndex=a+1,!f)continue;let x=o+1+(l.length-l.trimStart().length);r.push({code:f,line:ve(n,x),column:we(n,x),offset:s.index,kind:"condition"})}Le.lastIndex=0;while((s=Le.exec(n))!==null){let o=s[1],c=s[3]??"",a=o.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(Ft.has(a)||Ft.has(o))continue;if(!c.trim())continue;let l=s.index+s[0].indexOf(s[2],s[0].indexOf(o)+o.length)+1;if(Wt.has(a)){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);r.push({code:jt(b.trim()),line:ve(n,l+_),column:we(n,l+_),offset:l+_,kind:"directive",attribute:a});continue}let f=c.length-c.trimStart().length;r.push({code:jt(c.trim()),line:ve(n,l+f),column:we(n,l+f),offset:l+f,kind:"directive",attribute:a})}return r.sort((o,c)=>o.line-c.line||o.column-c.column),r}var cr=2000;function lr(e,n){let r=0,t=Math.min(e.length,n+cr);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 ur(e){let n=new Map,r=(c,a)=>{let l=c.split(/[,[\]{}()\s]+/).filter(Boolean);for(let f of l){let x=f.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(x))continue;let b=l.length===1?a: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=(c)=>{let a=c.trim();return t.test(a)?a:void 0};for(let c of e.matchAll(/@for(?:each|else)\s*\(/g)){let a=lr(e,c.index+c[0].length-1);if(a===null)continue;let l=mt(a);if(!l)continue;r(l.itemVar.replace(/=>/g," "),s(l.arrayExpr))}for(let c of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))r(c[1],c[2]==="of"?s(c[3]):void 0);for(let c of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))r(c[1]);let i=ge(e);Le.lastIndex=0;let o;while((o=Le.exec(i))!==null){let c=o[1].replace(/\..*$/,"");if(!Wt.has(c))continue;let a=o[3].match(/\s+(?:in|of)\s+/);if(!a||a.index===void 0)continue;r(o[3].slice(0,a.index),s(o[3].slice(a.index+a[0].length)))}for(let c of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let a of c[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))r(a[1]);return[...n.values()].sort((c,a)=>c.name.localeCompare(a.name))}function ae(e){return dt(e)}var Bt=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"];function Ht(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function pr(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=N(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 r=[],i=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,a;while((a=i.exec(n))!==null){if(s[a.index]!==0)continue;let c=a[1],o=a[2],l;if(c==="interface"){let p=n.indexOf("{",a.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("=",a.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===`
83
- `&&!/[=|&,<([{]\s*$/.test(n.slice(Math.max(0,x-40),x)))){l=b===";"?x+1:x;break}}}r.push({name:o,text:e.slice(a.index,l).replace(/^[ \t]*export[ \t]+/,"")}),i.lastIndex=l}return r}function Jn(e){let n=N(e),s=[],t=/^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+/gm,r,i=0,a=0;while((r=t.exec(n))!==null){for(;a<r.index;a++){let l=n[a];if(l==="{"||l==="("||l==="[")i++;else if(l==="}"||l===")"||l==="]")i=Math.max(0,i-1)}if(i!==0)continue;let c=0,o=n.length;for(let l=r.index+r[0].length;l<n.length;l++){let p=n[l];if(p==="{"||p==="("||p==="[")c++;else if(p==="}"||p===")"||p==="]")c--;else if(c<=0&&(p===";"||p===`
84
- `)){o=p===";"?l+1:l;break}}if(/\bdefineProps\s*(?:<|\()/.test(n.slice(r.index,o)))s.push(e.slice(r.index,o).replace(/^[ \t]*export[ \t]+/,"").trim())}return s}function Un(e){let n=e.filter((r)=>r.kind==="server").map((r)=>r.code).join(`
85
- `);if(/\bdefineProps\s*(?:<|\()/.test(N(n)))return n;let s=Xn(n),t=e.filter((r)=>r.kind!=="server").flatMap((r)=>{let i=Jn(r.code);if(!i.length)return[];return[...he(r.code).filter((a)=>!s.has(a.name)).map((a)=>a.text),...i]});return[n,...t].filter(Boolean).join(`
86
- `)}function Xn(e){return new Set(he(e).map((n)=>n.name))}var It=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];function zt(e){let n=new Set,s=new Set;for(let t of e){let r=t.kind==="server"?n:s;for(let i of ae(t.code))r.add(i)}return[...n].filter((t)=>s.has(t)).sort()}var Yn=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function Qn(e){let n=new Map,s=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let t of e){let r=N(t),{depths:i,balanced:a}=U(r);if(!a)continue;let c=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let o of r.matchAll(c)){let l=o.index??0;if(i[l+o[1].length]!==0)continue;let p=o[2],x=l+o[0].length-o[3].length,b=t.slice(x,l+o[0].length).trim().replace(/;$/,"").trim(),C=o[3],A=s.test(C)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(C)&&!/[,+\-*/%&|?:=]$/.test(b)&&U(C).balanced;n.set(p,n.has(p)||!A?null:b)}}return new Map([...n].filter((t)=>t[1]!==null))}function Vt(e,n,s=0,t=new Set){if(n.size===0||s>=5)return e;let r=N(e),i="",a=0;for(let c of r.matchAll(/[A-Za-z_$][\w$]*/g)){let o=c.index??0,l=c[0],p=n.get(l);if(!p||t.has(l))continue;let x=r.slice(0,o).trimEnd(),b=r.slice(o+l.length).trimStart();if(x.endsWith(".")||/^:(?!:)/.test(b)&&/[{,]$/.test(x))continue;if(o>0&&/[\w$]/.test(r[o-1]))continue;i+=`${e.slice(a,o)}(${Vt(p,n,s+1,new Set([...t,l]))})`,a=o+l.length}return i+e.slice(a)}function es(e,n){let s=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,t=[],r;while((r=s.exec(e))!==null){if(r.index>n)break;let i=r[1];if(r.index===n){if(i==="elseif"){let c=t[t.length-1];if(c?.current)c.seen.push(c.current);if(c)c.current=null}break}if(i==="endif"||i==="endunless"){t.pop();continue}let a="";if(r[2]==="("){let c=0,o=r.index+r[0].length-1,l=o+1;for(;o<e.length;o++){let p=e[o];if(p==="(")c++;else if(p===")"){if(c--,c===0)break}}a=e.slice(l,o).trim(),s.lastIndex=o+1}if(i==="if")t.push({seen:[],current:a});else if(i==="unless")t.push({seen:[],current:`!(${a})`});else if(i==="elseif"||i==="else"){let c=t[t.length-1];if(!c)continue;if(c.current)c.seen.push(c.current);c.current=i==="elseif"?a:null}}return t.flatMap((i)=>[...i.seen.map((a)=>`!(${a})`),...i.current?[i.current]:[]]).filter(Boolean)}function ts(e){let n=e.code.trim();if(!n)return null;if(e.attribute?.startsWith("@")){if(Yn.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 ns=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function Me(e,n){return Kt(e,n).code}function Kt(e,n){let s=new Map;if(!n)return{code:e,columns:s};let t=we(e),r=[],i=0;for(let a of e.matchAll(ns)){let c=a.index,[o,l,p,x]=a,b=Qe.default.resolve(n,x).replace(/\\/g,"/"),C=`${l}${p}${b}${p}`;if(r.push(e.slice(i,c),C),i=c+o.length,o.includes(`
87
- `))continue;let A=ce(t,c),T=s.get(A.line)??[],d=T.at(-1),f=A.column+(d?d.generatedEnd-d.sourceEnd:0);T.push({sourceStart:A.column,sourceEnd:A.column+o.length,generatedStart:f,generatedEnd:f+C.length}),s.set(A.line,T)}return r.push(e.slice(i)),{code:r.join(""),columns:s}}function ss(e,n,s){let t=Ue(e.importColumns?.get(n)??[],s);return Ue(e.scriptColumns?.get(n)??[],Ue(e.componentColumns?.get(n)??[],t))}function Ht(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=N(e);for(let t of s.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let r=t[1],i=/\{([^}]*)\}/.exec(r);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 a=r.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 Ft(e,n={}){let s=me(e),t=n.scriptKinds?s.filter((u)=>n.scriptKinds.includes(u.kind)):s,r=kt(e,n.componentMethodValidator),i=n.filePath&&n.templateExpressions!==!1?Tt(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,p=new Map,x=new Map,b=[],C=Un(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,T=new Set,d=[];for(let[u,m]of t.entries()){let w=Vn(rs(m)+m.code,C,String(u));for(let[D,M]of w.columns)p.set(m.startLine+D-1,M);for(let D of w.declarations)b.push({text:Me(D.text,n.originDir??""),origin:D.origin?{...D.origin,line:D.origin.line+m.startLine-1}:void 0});let P=m.kind==="client"&&r?r.project(w.code):void 0;for(let[D,M]of P?.columns??[])a.set(m.startLine+D-1,M);let v=Re(P?.code??w.code),R=Kt(v,n.originDir??"");for(let[D,M]of R.columns)x.set(m.startLine+D-1,M);let O=R.code.split(`
90
- `);O.forEach((D,M)=>{let z=m.startLine-1+M;if(z<o.length)o[z]=D,T.add(z)}),d.push(m.startLine-1+O.length-1)}for(let u of d){let m=o[u]?.trim()===""?u:u+1;if(m<o.length&&o[m].trim()===""&&(m===u||!T.has(m)))o[m]=";"}let f=(u,m)=>{for(let[w,P]of u.split(`
91
- `).entries())if(o.push(P),m)l.set(o.length,w===0?m:{...m,line:m.line+w,column:1,prefixLength:0})},_=Et(t.filter((u)=>u.kind==="server").map((u)=>u.code).join(`
92
- `));if(_)f(_);for(let u of t.filter((m)=>m.kind==="server")){let m=Pe(u.code);if(!m?.unsupported)continue;let w=u.code.slice(0,m.offset),P=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 c=0;c<n.length;c++){let a=n[c];if(a==="}"||a===")"||a==="]")t=Math.max(0,t-1);if(r[c]=t,a==="{"||a==="("||a==="[")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 c=o[1],a=o[2],l;if(c==="interface"){let f=n.indexOf("{",o.index);if(f===-1)continue;let x=0;l=-1;for(let b=f;b<n.length;b++)if(n[b]==="{")x++;else if(n[b]==="}"&&--x===0){l=b+1;break}if(l===-1)continue}else{let f=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==="<")f++;else if(b==="}"||b==="]"||b===")"||b===">")f--;else if(f<=0&&(b===";"||b===`
89
+ `&&!/[=|&,<([{]\s*$/.test(n.slice(Math.max(0,x-40),x)))){l=b===";"?x+1:x;break}}}s.push({name:a,text:e.slice(o.index,l).replace(/^[ \t]*export[ \t]+/,"")}),i.lastIndex=l}return s}function fr(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 c=0,a=n.length;for(let l=s.index+s[0].length;l<n.length;l++){let f=n[l];if(f==="{"||f==="("||f==="[")c++;else if(f==="}"||f===")"||f==="]")c--;else if(c<=0&&(f===";"||f===`
90
+ `)){a=f===";"?l+1:l;break}}if(/\bdefineProps\s*(?:<|\()/.test(n.slice(s.index,a)))r.push(e.slice(s.index,a).replace(/^[ \t]*export[ \t]+/,"").trim())}return r}function dr(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=mr(n),t=e.filter((s)=>s.kind!=="server").flatMap((s)=>{let i=fr(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 mr(e){return new Set(he(e).map((n)=>n.name))}var zt=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];function Kt(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 gr=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function hr(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}=J(s);if(!o)continue;let c=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let a of s.matchAll(c)){let l=a.index??0;if(i[l+a[1].length]!==0)continue;let f=a[2],x=l+a[0].length-a[3].length,b=t.slice(x,l+a[0].length).trim().replace(/;$/,"").trim(),_=a[3],A=r.test(_)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(_)&&!/[,+\-*/%&|?:=]$/.test(b)&&J(_).balanced;n.set(f,n.has(f)||!A?null:b)}}return new Map([...n].filter((t)=>t[1]!==null))}function Gt(e,n,r=0,t=new Set){if(n.size===0||r>=5)return e;let s=j(e),i="",o=0;for(let c of s.matchAll(/[A-Za-z_$][\w$]*/g)){let a=c.index??0,l=c[0],f=n.get(l);if(!f||t.has(l))continue;let x=s.slice(0,a).trimEnd(),b=s.slice(a+l.length).trimStart();if(x.endsWith(".")||/^:(?!:)/.test(b)&&/[{,]$/.test(x))continue;if(a>0&&/[\w$]/.test(s[a-1]))continue;i+=`${e.slice(o,a)}(${Gt(f,n,r+1,new Set([...t,l]))})`,o=a+l.length}return i+e.slice(o)}function xr(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 c=t[t.length-1];if(c?.current)c.seen.push(c.current);if(c)c.current=null}break}if(i==="endif"||i==="endunless"){t.pop();continue}let o="";if(s[2]==="("){let c=0,a=s.index+s[0].length-1,l=a+1;for(;a<e.length;a++){let f=e[a];if(f==="(")c++;else if(f===")"){if(c--,c===0)break}}o=e.slice(l,a).trim(),r.lastIndex=a+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 c=t[t.length-1];if(!c)continue;if(c.current)c.seen.push(c.current);c.current=i==="elseif"?o:null}}return t.flatMap((i)=>[...i.seen.map((o)=>`!(${o})`),...i.current?[i.current]:[]]).filter(Boolean)}function br(e){let n=e.code.trim();if(!n)return null;if(e.attribute?.startsWith("@")){if(gr.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 yr=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function Me(e,n){return Xt(e,n).code}function Xt(e,n){let r=new Map;if(!n)return{code:e,columns:r};let t=Ee(e),s=[],i=0;for(let o of e.matchAll(yr)){let c=o.index,[a,l,f,x]=o,b=tt.default.resolve(n,x).replace(/\\/g,"/"),_=`${l}${f}${b}${f}`;if(s.push(e.slice(i,c),_),i=c+a.length,a.includes(`
93
+ `))continue;let A=ce(t,c),C=r.get(A.line)??[],p=C.at(-1),d=A.column+(p?p.generatedEnd-p.sourceEnd:0);C.push({sourceStart:A.column,sourceEnd:A.column+a.length,generatedStart:d,generatedEnd:d+_.length}),r.set(A.line,C)}return s.push(e.slice(i)),{code:s.join(""),columns:r}}function Sr(e,n,r){let t=Ye(e.importColumns?.get(n)??[],r);return Ye(e.scriptColumns?.get(n)??[],Ye(e.componentColumns?.get(n)??[],t))}function qt(e,n,r){let t=Qe(e.scriptColumns?.get(n)??[],r);return Qe(e.importColumns?.get(n)??[],Qe(e.componentColumns?.get(n)??[],t))}function vr(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 f=l.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(f&&/^[A-Z_$][\w$]*$/i.test(f))n.add(f)}let o=s.replace(/\{[^}]*\}/,""),c=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(o);if(c)n.add(c[1]);let a=/^\s*([A-Z_$][\w$]*)/i.exec(o);if(a&&a[1]!=="type")n.add(a[1])}return[...n].sort()}function Jt(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,c=e.split(`
94
+ `),a=Array.from({length:c.length},()=>""),l=new Map,f=new Map,x=new Map,b=[],_=dr(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((w)=>Me(w.code,tt.default.dirname(m))).join(`
95
+ `)}):void 0,C=new Set,p=[];for(let[u,m]of t.entries()){let w=sr(vr(m)+m.code,_,String(u));for(let[N,P]of w.columns)f.set(m.startLine+N-1,P);for(let N of w.declarations)b.push({text:Me(N.text,n.originDir??""),origin:N.origin?{...N.origin,line:N.origin.line+m.startLine-1}:void 0});let R=m.kind==="client"&&s?s.project(w.code):void 0;for(let[N,P]of R?.columns??[])o.set(m.startLine+N-1,P);let v=Ne(R?.code??w.code),O=Xt(v,n.originDir??"");for(let[N,P]of O.columns)x.set(m.startLine+N-1,P);let I=O.code.split(`
96
+ `);I.forEach((N,P)=>{let B=m.startLine-1+P;if(B<a.length)a[B]=N,C.add(B)}),p.push(m.startLine-1+I.length-1)}for(let u of p){let m=a[u]?.trim()===""?u:u+1;if(m<a.length&&a[m].trim()===""&&(m===u||!C.has(m)))a[m]=";"}let d=(u,m)=>{for(let[w,R]of u.split(`
97
+ `).entries())if(a.push(R),m)l.set(a.length,w===0?m:{...m,line:m.line+w,column:1,prefixLength:0})},E=Pt(t.filter((u)=>u.kind==="server").map((u)=>u.code).join(`
98
+ `));if(E)d(E);for(let u of t.filter((m)=>m.kind==="server")){let m=Ie(u.code);if(!m?.unsupported)continue;let w=u.code.slice(0,m.offset),R=u.startLine+w.split(`
93
99
  `).length-1,v=m.offset-u.code.lastIndexOf(`
94
- `,m.offset-1)+(P===u.startLine?(u.startColumn??1)-1:0);f(`;({})[${JSON.stringify(m.unsupported)}];`,{line:P,column:v,anchor:!0})}if(i?.declarations)f(i.declarations);for(let u of b)f(u.text,u.origin);if(r){if(f(r.declarations),n.nativeChecks!==!1)for(let u of r.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 pe)m(v)}let w=[...new Set([...Dt,...Le,...It])].filter((v)=>!n.declaredGlobals?.includes(v)&&(n.runtimeGlobals!==!1||!pe.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 Le)m(v);for(let v of It)m(v)}f(`declare var ${Ye}: any`);let P=new Set(t.flatMap((v)=>ae(v.code)));f(`type ${Rt}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let v of r?[]:Zn(e)){if(P.has(v.name))continue;let R=v.iterable&&P.has(v.iterable)?`${Rt}<typeof ${v.iterable}>`:"any";f(`declare var ${v.name}: ${R}`)}}if(n.templateExpressions!==!1){if(A?.declarations)for(let m of A.declarations.split(`
95
- `))f(m);let u=Fn(e).map((m)=>{let w=A?.events.get(m.offset??-1);if(w){m.anchor=!0;let P=m.code.trim(),v=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(P),R=v?`void ((${v[2]}) satisfies __StxAssignedValue<typeof ${v[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(P)?`${P} satisfies (($event: ${w}) => unknown)`:P,O=`;(($event: ${w}): void => { `;return{expression:m,statement:{text:`${O}${R} });`,prefixLength:O.length}}}return{expression:m,statement:ts(m)}}).filter((m)=>m.statement!==null);if(u.push(...A?.checks||[],...i?.checks||[]),u.length>0){let m=ge(e),w=Pt(m),P=r?At(m):[];if(r)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=Qn(t.map((M)=>M.code)),O=[...new Set(t.flatMap((M)=>ae(M.code)))].filter((M)=>/^[A-Z_$][\w$]*$/i.test(M)),D=0;if(r)f("function __stxNativeTemplate(this: __StxNativeComponent) {");if(O.length>0){f(Bn);for(let M of O)f(`function __StxRead_${M}() { return ${M} }`),f(`type __StxT_${M} = ${Nt}<ReturnType<typeof __StxRead_${M}>>`);f(`;((${O.map((M)=>`${M}: __StxT_${M}`).join(", ")}) => {`),D=1}for(let{expression:M,statement:z}of u){let W=" ".repeat(D),q=M.offset===void 0?[]:w.filter((B)=>M.offset>=B.start&&M.offset<B.end),G=M.offset===void 0?[]:P.filter((B)=>M.offset>=B.start&&M.offset<B.end),ee=G.map((B)=>`;__stxEach(${B.iterable}, (${B.binding}) => { `).join(""),se=" });".repeat(G.length),J=ee+q.map((B)=>`;((${B.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),le=" });".repeat(q.length)+se,L=M.offset===void 0?[]:es(m,M.offset),H=L.length>0?`${L.map((B)=>`if (${Vt(B,v)}) `).join("")}{ `:"",Y=L.length>0?" }":"";f(W+J+H+z.text+Y+le,{line:M.line,column:M.column,expression:M,prefixLength:z.prefixLength+W.length+J.length+H.length,guardPrefixLength:W.length+J.length+H.length})}if(D>0)f("});");if(r)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??[],...i?.dependencies??[]]),referenced:h,scriptColumns:p,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 r=Math.ceil((s+t)/2);if(e[r]<=n)s=r;else t=r-1}return{line:s+1,column:n-e[s]+1}}function Ie(e,n,s){let t=Math.min(Math.max(n,1),e.length)-1,r=t+1<e.length?e[t+1]-1:Number.MAX_SAFE_INTEGER;return Math.min(e[t]+Math.max(s,1)-1,r)}function Wt(e,n){if(!e.expression)return!1;return e.inGuard===!0||n===2774}function Gt(e,n,s){let t=e.lineMap.get(n);if(!t)return n<=e.sourceLineCount?{line:n,column:ss(e,n,s)}:null;let r=t.anchor||t.expression?.anchor||t.diagnosticOrigin==="component"?0:Math.max(0,s-1-(t.prefixLength??0));return{line:t.line,column:t.column+r,expression:t.expression,diagnosticOrigin:t.diagnosticOrigin,inGuard:s<=(t.guardPrefixLength??0)}}var is=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),qt=ke.filter((e)=>!is.has(e)).sort(),Jt=[...pe].sort(),os=[...new Set([...qt,...Jt])].sort(),as=new Set(qt),cs=new Set(Jt),ls=new Set(os),Zt=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function us(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 Ut(e,n){let s=[];for(let t of n){if(t.offset===void 0)continue;let r=t.kind==="server"?as:cs;Zt.lastIndex=0;for(let i of t.code.matchAll(Zt)){let a=i.index+i[0].indexOf("{")+1;for(let c of i[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 p=l[1];if(!ls.has(p)||r.has(p))continue;let x=t.offset+a+c.index+l[0].length-p.length,b=e.slice(0,x),C=b.split(`
97
- `).length;s.push({line:C,column:x-(b.lastIndexOf(`
98
- `)+1)+1,offset:x,length:p.length,name:p,kind:t.kind,message:us(p,t.kind)})}}}return s}var ne=Q(require("node:path"),1),ds="@stacksjs/stx-typescript-plugin";function ps(e,n){let s=ne.default.resolve(e);for(;;){let t=ne.default.join(s,"tsconfig.json");if(n(t))return t;let r=ne.default.dirname(s);if(r===s)return;s=r}}function Xt(e,n,s){let t=ps(e,s);if(!t)return;let r=new Set,i=(a)=>{if(r.has(a))return;r.add(a);let c=n(a);if(!c)return;let o=c.compilerOptions?.plugins;if(Array.isArray(o)){let p=o.find((b)=>b?.name===ds),x=Array.isArray(p?.libs)?p.libs.filter((b)=>typeof b==="string"):[];return p?{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 p of[...l].reverse()){if(typeof p!=="string"||!p.startsWith("."))continue;let x=ne.default.resolve(ne.default.dirname(a),p.endsWith(".json")?p:`${p}.json`),b=i(x);if(b!==void 0)return b}return};return i(t)??void 0}var Yt=Symbol.for("@stacksjs/stx-typescript-plugin"),fs=new Set([2300,2451,2403]);function $e(e){return e.endsWith(".stx")}function Qt(e){return $e(e)||e.endsWith(".md")}function ms(e){if(!e)return;return X.existsSync(F.default.join(e,"stx-module.d.ts"))&&X.existsSync(F.default.join(e,"stx.d.ts"))?F.default.join(e,"stx-module.d.ts"):void 0}function gs(e,n=X.existsSync){let s=e;for(;;){let t=F.default.join(s,"node_modules","@stacksjs","stx","stx-module.d.ts");if(n(t))return t;let r=F.default.dirname(s);if(r===s)return;s=r}}function hs(e,n=F.default.join(tn.tmpdir(),"stx-typescript-plugin")){let s=e.map((r)=>`/// <reference path=${JSON.stringify(r.replace(/\\/g,"/"))} />`).join(`
100
+ `,m.offset-1)+(R===u.startLine?(u.startColumn??1)-1:0);d(`;({})[${JSON.stringify(m.unsupported)}];`,{line:R,column:v,anchor:!0})}if(i?.declarations)d(i.declarations);for(let u of b)d(u.text,u.origin);if(s){if(d(s.declarations),n.nativeChecks!==!1)for(let u of s.checks)d(u.text,{line:u.line,column:u.column,diagnosticOrigin:u.origin,anchor:!0})}if(n.globals!==!1){d("");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))d(`declare var ${v}: any`)};if(n.runtimeGlobals!==!1){if(!u.has("window"))d("declare var window: any");for(let v of fe)m(v)}let w=[...new Set([...Bt,...Be,...zt])].filter((v)=>!n.declaredGlobals?.includes(v)&&(n.runtimeGlobals!==!1||!fe.includes(v)));if(n.contextScope==="global"){d("declare global {");for(let v of w)d(` var ${v}: any`);d("}")}else{for(let v of Bt)m(v);for(let v of Be)m(v);for(let v of zt)m(v)}d(`declare var ${et}: any`);let R=new Set(t.flatMap((v)=>ae(v.code)));d(`type ${Lt}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let v of s?[]:ur(e)){if(R.has(v.name))continue;let O=v.iterable&&R.has(v.iterable)?`${Lt}<typeof ${v.iterable}>`:"any";d(`declare var ${v.name}: ${O}`)}}if(n.templateExpressions!==!1){if(A?.declarations)for(let m of A.declarations.split(`
101
+ `))d(m);let u=ar(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),O=v?`void ((${v[2]}) satisfies __StxAssignedValue<typeof ${v[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(R)?`${R} satisfies (($event: ${w}) => unknown)`:R,I=`;(($event: ${w}): void => { `;return{expression:m,statement:{text:`${I}${O} });`,prefixLength:I.length}}}return{expression:m,statement:br(m)}}).filter((m)=>m.statement!==null);if(u.push(...A?.checks||[],...i?.checks||[]),u.length>0){let m=ge(e),w=Dt(m),R=s?Mt(m):[];if(s)d("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=hr(t.map((P)=>P.code)),I=[...new Set(t.flatMap((P)=>ae(P.code)))].filter((P)=>/^[A-Z_$][\w$]*$/i.test(P)),N=0;if(s)d("function __stxNativeTemplate(this: __StxNativeComponent) {");if(I.length>0){d(nr);for(let P of I)d(`function __StxRead_${P}() { return ${P} }`),d(`type __StxT_${P} = ${Ut}<ReturnType<typeof __StxRead_${P}>>`);d(`;((${I.map((P)=>`${P}: __StxT_${P}`).join(", ")}) => {`),N=1}for(let{expression:P,statement:B}of u){let H=" ".repeat(N),X=P.offset===void 0?[]:w.filter((F)=>P.offset>=F.start&&P.offset<F.end),K=P.offset===void 0?[]:R.filter((F)=>P.offset>=F.start&&P.offset<F.end),ee=K.map((F)=>`;__stxEach(${F.iterable}, (${F.binding}) => { `).join(""),re=" });".repeat(K.length),q=ee+X.map((F)=>`;((${F.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),le=" });".repeat(X.length)+re,L=P.offset===void 0?[]:xr(m,P.offset),W=L.length>0?`${L.map((F)=>`if (${Gt(F,v)}) `).join("")}{ `:"",Y=L.length>0?" }":"";d(H+q+W+B.text+Y+le,{line:P.line,column:P.column,expression:P,prefixLength:B.prefixLength+H.length+q.length+W.length,guardPrefixLength:H.length+q.length+W.length})}if(N>0)d("});");if(s)d("}")}}let h=!1;if(n.reference&&a[0]!==void 0&&a[0].trim()==="")a[0]=`/// <reference path=${JSON.stringify(n.reference.replace(/\\/g,"/"))} />`,h=!0;return d("export {}"),{text:a.join(`
102
+ `),lineMap:l,sourceLineCount:c.length,componentDependencies:new Map([...A?.dependencies??[],...i?.dependencies??[]]),referenced:h,scriptColumns:f,importColumns:x,componentColumns:o}}function Ee(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 je(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 Zt(e,n){if(!e.expression)return!1;return e.inGuard===!0||n===2774}function Yt(e,n,r){let t=e.lineMap.get(n);if(!t)return n<=e.sourceLineCount?{line:n,column:Sr(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 wr=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),en=Re.filter((e)=>!wr.has(e)).sort(),tn=[...fe].sort(),Er=[...new Set([...en,...tn])].sort(),$r=new Set(en),_r=new Set(tn),kr=new Set(Er),Qt=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Cr(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 nn(e,n){let r=[];for(let t of n){if(t.offset===void 0)continue;let s=t.kind==="server"?$r:_r;Qt.lastIndex=0;for(let i of t.code.matchAll(Qt)){let o=i.index+i[0].indexOf("{")+1;for(let c of i[1].matchAll(/[^,]+/g)){let a=c[0];if(/^\s*type\s/.test(a))continue;let l=/^\s*([A-Za-z_$][\w$]*)/.exec(a);if(!l)continue;let f=l[1];if(!kr.has(f)||s.has(f))continue;let x=t.offset+o+c.index+l[0].length-f.length,b=e.slice(0,x),_=b.split(`
103
+ `).length;r.push({line:_,column:x-(b.lastIndexOf(`
104
+ `)+1)+1,offset:x,length:f.length,name:f,kind:t.kind,message:Cr(f,t.kind)})}}}return r}var ne=Q(require("node:path"),1),Tr="@stacksjs/stx-typescript-plugin";function Ar(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 rn(e,n,r){let t=Ar(e,r);if(!t)return;let s=new Set,i=(o)=>{if(s.has(o))return;s.add(o);let c=n(o);if(!c)return;let a=c.compilerOptions?.plugins;if(Array.isArray(a)){let f=a.find((b)=>b?.name===Tr),x=Array.isArray(f?.libs)?f.libs.filter((b)=>typeof b==="string"):[];return f?{configPath:o,libs:x.map((b)=>ne.default.resolve(ne.default.dirname(o),b))}:null}let l=typeof c.extends==="string"?[c.extends]:Array.isArray(c.extends)?c.extends:[];for(let f of[...l].reverse()){if(typeof f!=="string"||!f.startsWith("."))continue;let x=ne.default.resolve(ne.default.dirname(o),f.endsWith(".json")?f:`${f}.json`),b=i(x);if(b!==void 0)return b}return};return i(t)??void 0}var sn=Symbol.for("@stacksjs/stx-typescript-plugin"),Rr=new Set([2300,2451,2403]);function $e(e){return e.endsWith(".stx")}function on(e){return $e(e)||e.endsWith(".md")}function Or(e){if(!e)return;return Z.existsSync(U.default.join(e,"stx-module.d.ts"))&&Z.existsSync(U.default.join(e,"stx.d.ts"))?U.default.join(e,"stx-module.d.ts"):void 0}function Pr(e,n=Z.existsSync){let r=e;for(;;){let t=U.default.join(r,"node_modules","@stacksjs","stx","stx-module.d.ts");if(n(t))return t;let s=U.default.dirname(r);if(s===r)return;r=s}}function Ir(e,n=U.default.join(cn.tmpdir(),"stx-typescript-plugin")){let r=e.map((s)=>`/// <reference path=${JSON.stringify(s.replace(/\\/g,"/"))} />`).join(`
99
105
  `)+`
100
- `,t=F.default.join(n,`${en.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 xs(e){let n=new Set,s=new Set;function t(r){if(s.has(r)||!X.existsSync(r))return;s.add(r);let i=X.readFileSync(r,"utf8");for(let a of Bt(i))n.add(a);for(let a of i.matchAll(/<reference\s+path=["']([^"']+)["']/g))t(F.default.resolve(F.default.dirname(r),a[1]))}if(e)t(e);return[...n]}function bs(e,n,s,t){let r=(c)=>Ft(n,{templateExpressions:$e(e),componentMethodValidator:(o,l,p)=>{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 ${p}(`):!x.outputText.trim()},originDir:F.default.dirname(e),filePath:e,readComponent:t.readComponent,componentsDir:t.componentsDir,projectRoot:t.projectRoot,reference:c,declaredGlobals:xs(c),runtimeGlobals:!c,contextScope:"global"}),i=r(t.declarations);if(t.declarations&&!i.referenced)i=r(void 0);let a=me(n);return{version:s,source:n,virtual:i,blocks:a,sourceStarts:we(n),virtualStarts:we(i.text),collisions:new Set(zt(a))}}function ys(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 r=e.parseJsonConfigFileContent(t.config,e.sys,F.default.dirname(s),void 0,s),i={};if(r.options.types)i.types=r.options.types;let a=r.options.paths;if(a){let c=r.options.baseUrl??r.options.pathsBasePath??F.default.dirname(s);i.paths={};for(let[o,l]of Object.entries(a))i.paths[o]=l.map((p)=>F.default.isAbsolute(p)?p:F.default.resolve(c,p))}return i}function Ss(e,n={}){let s=e.typescript,t={},r=new Set,i=new WeakSet;return{create(a){let c=(g)=>{a.project.projectService.logger.info(`[stx-plugin] ${g}`)};if(a.languageService[Yt])return i.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,p=(g)=>{let S=o[g];return typeof S==="function"?S.bind(o):()=>{return}},x=l.getScriptSnapshot?.bind(l),b=l.getScriptVersion?.bind(l),C=ms(n.declarationsDir);if(!C)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),T=(g)=>{let S=s.readConfigFile?.(g,(y)=>s.sys.readFile(y));return S&&!S.error?S.config:void 0},d=new Map,f=(g)=>{let S=F.default.dirname(g);if(!d.has(S)){let y=gs(S,A)??C,k=[];try{k=(Xt(S,T,A)?.libs??[]).filter(A)}catch(E){c(`could not read the stx entry of the project's tsconfig: ${String(E)}`)}d.set(S,y&&k.length>0?hs([y,...k]):y)}return d.get(S)},_=new Map,h=(g)=>{let S=x?.(g);return S?S.getText(0,S.getLength()):s.sys?.readFile(g)},u=()=>t.enabled!==!1;r.add(()=>{_.clear(),a.project.refreshDiagnostics?.()});let m=(g)=>{if(!Qt(g)||!x)return;let S=`${b?.(g)||"0"}:${l.getProjectVersion?.()||""}`,y=_.get(g);if(y&&y.version===S&&[...y.virtual.componentDependencies||[]].every(([E,I])=>h(E)===I))return y;let k=x(g);if(!k)return;try{let E=a.project.getCurrentDirectory?.(),I=E?F.default.resolve(E,typeof a.config?.componentsDir==="string"?a.config.componentsDir:"components"):void 0,V=bs(g,k.getText(0,k.getLength()),S,{typescript:s,declarations:f(g),readComponent:h,componentsDir:I,projectRoot:E});return _.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,P=(g,S)=>{let y=ce(g.virtualStarts,S);return Gt(g.virtual,y.line,y.column)},v=(g,S)=>{let y=P(g,S);if(!y)return;return Ie(g.sourceStarts,y.line,y.column)},R=(g,S)=>{let y=ce(g.sourceStarts,S);return Ie(g.virtualStarts,y.line,Ht(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}},D=(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 q=l.getCompilationSettings?.bind(l),G=s.server?.ProjectKind!==void 0&&a.project.projectKind===s.server.ProjectKind.Inferred;if(q&&G){let g=null,S;l.getCompilationSettings=()=>{let y=q();if(g===null)try{g=ys(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 I=typeof E.messageText==="string"?E.messageText:E.messageText.messageText;if(fs.has(E.code)){let te=I.match(/'([^']+)'/)?.[1];if(te&&y.collisions.has(te))continue}if(E.start===void 0){k.push(E);continue}let V=P(y,E.start);if(!V||Wt(V,E.code))continue;let K=Ie(y.sourceStarts,V.line,V.column),be=v(y,E.start+(E.length??0));k.push({...E,start:K,length:be!==void 0&&be>K?be-K:E.length??0})}return k},se=p("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 Ut(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 J=p("getSyntacticDiagnostics");o.getSyntacticDiagnostics=(g)=>ee(g,J(g));let le=p("getSuggestionDiagnostics");o.getSuggestionDiagnostics=(g)=>ee(g,le(g));let L=p("getQuickInfoAtPosition");o.getQuickInfoAtPosition=(g,S,...y)=>{let k=w(g);if(!k)return L(g,S,...y);if(!u())return;let E=L(g,R(k,S),...y);if(!E)return E;let I=O(k,E.textSpan);return I?{...E,textSpan:I}:void 0};let H=p("getCompletionsAtPosition");o.getCompletionsAtPosition=(g,S,y,...k)=>{let E=w(g);if(!E)return H(g,S,y,...k);if(!u()||!D(E,S))return;let I=H(g,R(E,S),{...y,includeCompletionsForModuleExports:!1},...k);if(!I)return I;let V=(K)=>K&&O(E,K);return{...I,optionalReplacementSpan:V(I.optionalReplacementSpan),entries:I.entries.filter((K)=>!K.name.startsWith("__stx")&&!K.name.startsWith("__Stx")).map((K)=>K.replacementSpan?{...K,replacementSpan:V(K.replacementSpan)}:K)}};let Y=p("getCompletionEntryDetails");o.getCompletionEntryDetails=(g,S,...y)=>{let k=w(g);if(!k)return Y(g,S,...y);let E=Y(g,R(k,S),...y);return E?{...E,codeActions:void 0}:E};let B=p("getSignatureHelpItems");o.getSignatureHelpItems=(g,S,...y)=>{let k=w(g);if(!k)return B(g,S,...y);if(!u()||!D(k,S))return;let E=B(g,R(k,S),...y),I=E&&O(k,E.applicableSpan);return E&&I?{...E,applicableSpan:I}:void 0};let _e=p("getDefinitionAndBoundSpan");o.getDefinitionAndBoundSpan=(g,S)=>{let y=w(g);if(!y)return xe(_e(g,S));if(!u())return;let k=_e(g,R(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=p(g);o[g]=(y,k,...E)=>{let I=w(y);if(I&&!u())return;return W(S(y,I?R(I,k):k,...E))}}for(let g of["getReferencesAtPosition"]){let S=p(g);o[g]=(y,k,...E)=>{let I=w(y);if(I&&!u())return;return z(S(y,I?R(I,k):k,...E))}}let sn=p("findReferences");o.findReferences=(g,S)=>{let y=w(g);if(y&&!u())return;return sn(g,y?R(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 rn=p("getDocumentHighlights");o.getDocumentHighlights=(g,S,y)=>{let k=w(g);if(k&&(!u()||!D(k,S)))return;return rn(g,k?R(k,S):S,y)?.map((E)=>{let I=w(E.fileName);if(!I)return E;return{...E,highlightSpans:E.highlightSpans.map((V)=>{let K=O(I,V.textSpan);return K?{...V,textSpan:K,contextSpan:V.contextSpan&&O(I,V.contextSpan)}:void 0}).filter((V)=>V!==void 0)}})};let on=p("getNavigationTree");o.getNavigationTree=(g)=>{let S=on(g),y=w(g);if(!y)return S;let k=(I)=>{let V=I.spans.map((te)=>O(y,te)).filter((te)=>te!==void 0);if(V.length===0)return;let K=I.nameSpan&&O(y,I.nameSpan),be=I.childItems?.map(k).filter((te)=>te!==void 0);return{...I,spans:V,nameSpan:K,childItems:be}},E={...S,spans:[{start:0,length:y.source.length}]};return u()?{...E,childItems:S.childItems?.map(k).filter((I)=>I!==void 0)}:{...E,childItems:[]}};let an={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(an)){let y=o[g];if(typeof y!=="function")continue;let k=y.bind(o);o[g]=(E,...I)=>typeof E==="string"&&$e(E)?S():k(E,...I)}return o[Yt]=!0,c("Language service proxy created"),o},getExternalFiles(a){if(i.has(a))return[];return a.getFileNames().filter(Qt)},onConfigurationChanged(a){t={...t,...a};for(let c of r)c()}}}var nn=Ss;module.exports=nn;
106
+ `,t=U.default.join(n,`${an.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 Nr(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 Ht(i))n.add(o);for(let o of i.matchAll(/<reference\s+path=["']([^"']+)["']/g))t(U.default.resolve(U.default.dirname(s),o[1]))}if(e)t(e);return[...n]}function Mr(e,n,r,t){let s=(c)=>Jt(n,{templateExpressions:$e(e),componentMethodValidator:(a,l,f)=>{let x=t.typescript.transpileModule(a+(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 ${f}(`):!x.outputText.trim()},originDir:U.default.dirname(e),filePath:e,readComponent:t.readComponent,componentsDir:t.componentsDir,projectRoot:t.projectRoot,reference:c,declaredGlobals:Nr(c),runtimeGlobals:!c,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:Ee(n),virtualStarts:Ee(i.text),collisions:new Set(Kt(o))}}function Dr(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,U.default.dirname(r),void 0,r),i={};if(s.options.types)i.types=s.options.types;let o=s.options.paths;if(o){let c=s.options.baseUrl??s.options.pathsBasePath??U.default.dirname(r);i.paths={};for(let[a,l]of Object.entries(o))i.paths[a]=l.map((f)=>U.default.isAbsolute(f)?f:U.default.resolve(c,f))}return i}function Lr(e,n={}){let r=e.typescript,t={},s=new Set,i=new WeakSet;return{create(o){let c=(g)=>{o.project.projectService.logger.info(`[stx-plugin] ${g}`)};if(o.languageService[sn])return i.add(o.project),c("already applied to this project by another registration of the plugin; leaving it as it is"),o.languageService;c("TypeScript stx plugin initialized");let{languageService:a,languageServiceHost:l}=o,f=(g)=>{let S=a[g];return typeof S==="function"?S.bind(a):()=>{return}},x=l.getScriptSnapshot?.bind(l),b=l.getScriptVersion?.bind(l),_=Or(n.declarationsDir);if(!_)c("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},p=new Map,d=(g)=>{let S=U.default.dirname(g);if(!p.has(S)){let y=Pr(S,A)??_,T=[];try{T=(rn(S,C,A)?.libs??[]).filter(A)}catch(k){c(`could not read the stx entry of the project's tsconfig: ${String(k)}`)}p.set(S,y&&T.length>0?Ir([y,...T]):y)}return p.get(S)},E=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(()=>{E.clear(),o.project.refreshDiagnostics?.()});let m=(g)=>{if(!on(g)||!x)return;let S=`${b?.(g)||"0"}:${l.getProjectVersion?.()||""}`,y=E.get(g);if(y&&y.version===S&&[...y.virtual.componentDependencies||[]].every(([k,M])=>h(k)===M))return y;let T=x(g);if(!T)return;try{let k=o.project.getCurrentDirectory?.(),M=k?U.default.resolve(k,typeof o.config?.componentsDir==="string"?o.config.componentsDir:"components"):void 0,z=Mr(g,T.getText(0,T.getLength()),S,{typescript:r,declarations:d(g),readComponent:h,componentsDir:M,projectRoot:k});return E.set(g,z),z}catch(k){c(`failed to build virtual document for ${g}: ${String(k)}`);return}},w=(g)=>$e(g)?m(g):void 0,R=(g,S)=>{let y=ce(g.virtualStarts,S);return Yt(g.virtual,y.line,y.column)},v=(g,S)=>{let y=R(g,S);if(!y)return;return je(g.sourceStarts,y.line,y.column)},O=(g,S)=>{let y=ce(g.sourceStarts,S);return je(g.virtualStarts,y.line,qt(g.virtual,y.line,y.column))},I=(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}},N=(g,S)=>g.blocks.some((y)=>y.offset!==void 0&&S>=y.offset&&S<=y.offset+y.code.length),P=(g)=>{let S=w(g.fileName);if(!S)return g;let y=I(S,g.textSpan);if(!y)return;let T=g.contextSpan?I(S,g.contextSpan):void 0;return{...g,textSpan:y,contextSpan:T}},B=(g)=>g?.map(P).filter((S)=>S!==void 0),H=(g)=>g?.filter((S)=>{let y=w(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 X=l.getCompilationSettings?.bind(l),K=r.server?.ProjectKind!==void 0&&o.project.projectKind===r.server.ProjectKind.Inferred;if(X&&K){let g=null,S;l.getCompilationSettings=()=>{let y=X();if(g===null)try{g=Dr(r,o.project.getCurrentDirectory())}catch(T){c(`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 M=typeof k.messageText==="string"?k.messageText:k.messageText.messageText;if(Rr.has(k.code)){let te=M.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||Zt(z,k.code))continue;let V=je(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=f("getSemanticDiagnostics");a.getSemanticDiagnostics=(g)=>{let S=ee(g,re(g)),y=w(g);if(!y||!u())return S;let T=a.getProgram?.()?.getSourceFile(g);for(let k of nn(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 q=f("getSyntacticDiagnostics");a.getSyntacticDiagnostics=(g)=>ee(g,q(g));let le=f("getSuggestionDiagnostics");a.getSuggestionDiagnostics=(g)=>ee(g,le(g));let L=f("getQuickInfoAtPosition");a.getQuickInfoAtPosition=(g,S,...y)=>{let T=w(g);if(!T)return L(g,S,...y);if(!u())return;let k=L(g,O(T,S),...y);if(!k)return k;let M=I(T,k.textSpan);return M?{...k,textSpan:M}:void 0};let W=f("getCompletionsAtPosition");a.getCompletionsAtPosition=(g,S,y,...T)=>{let k=w(g);if(!k)return W(g,S,y,...T);if(!u()||!N(k,S))return;let M=W(g,O(k,S),{...y,includeCompletionsForModuleExports:!1},...T);if(!M)return M;let z=(V)=>V&&I(k,V);return{...M,optionalReplacementSpan:z(M.optionalReplacementSpan),entries:M.entries.filter((V)=>!V.name.startsWith("__stx")&&!V.name.startsWith("__Stx")).map((V)=>V.replacementSpan?{...V,replacementSpan:z(V.replacementSpan)}:V)}};let Y=f("getCompletionEntryDetails");a.getCompletionEntryDetails=(g,S,...y)=>{let T=w(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=f("getSignatureHelpItems");a.getSignatureHelpItems=(g,S,...y)=>{let T=w(g);if(!T)return F(g,S,...y);if(!u()||!N(T,S))return;let k=F(g,O(T,S),...y),M=k&&I(T,k.applicableSpan);return k&&M?{...k,applicableSpan:M}:void 0};let _e=f("getDefinitionAndBoundSpan");a.getDefinitionAndBoundSpan=(g,S)=>{let y=w(g);if(!y)return xe(_e(g,S));if(!u())return;let T=_e(g,O(y,S)),k=T&&I(y,T.textSpan);return T&&k?{...xe(T),textSpan:k}:void 0};let xe=(g)=>g&&{...g,definitions:H(g.definitions)};for(let g of["getDefinitionAtPosition","getTypeDefinitionAtPosition","getImplementationAtPosition"]){let S=f(g);a[g]=(y,T,...k)=>{let M=w(y);if(M&&!u())return;return H(S(y,M?O(M,T):T,...k))}}for(let g of["getReferencesAtPosition"]){let S=f(g);a[g]=(y,T,...k)=>{let M=w(y);if(M&&!u())return;return B(S(y,M?O(M,T):T,...k))}}let un=f("findReferences");a.findReferences=(g,S)=>{let y=w(g);if(y&&!u())return;return un(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 pn=f("getDocumentHighlights");a.getDocumentHighlights=(g,S,y)=>{let T=w(g);if(T&&(!u()||!N(T,S)))return;return pn(g,T?O(T,S):S,y)?.map((k)=>{let M=w(k.fileName);if(!M)return k;return{...k,highlightSpans:k.highlightSpans.map((z)=>{let V=I(M,z.textSpan);return V?{...z,textSpan:V,contextSpan:z.contextSpan&&I(M,z.contextSpan)}:void 0}).filter((z)=>z!==void 0)}})};let fn=f("getNavigationTree");a.getNavigationTree=(g)=>{let S=fn(g),y=w(g);if(!y)return S;let T=(M)=>{let z=M.spans.map((te)=>I(y,te)).filter((te)=>te!==void 0);if(z.length===0)return;let V=M.nameSpan&&I(y,M.nameSpan),be=M.childItems?.map(T).filter((te)=>te!==void 0);return{...M,spans:z,nameSpan:V,childItems:be}},k={...S,spans:[{start:0,length:y.source.length}]};return u()?{...k,childItems:S.childItems?.map(T).filter((M)=>M!==void 0)}:{...k,childItems:[]}};let dn={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(dn)){let y=a[g];if(typeof y!=="function")continue;let T=y.bind(a);a[g]=(k,...M)=>typeof k==="string"&&$e(k)?S():T(k,...M)}return a[sn]=!0,c("Language service proxy created"),a},getExternalFiles(o){if(i.has(o))return[];return o.getFileNames().filter(on)},onConfigurationChanged(o){t={...t,...o};for(let c of s)c()}}}var ln=Lr;module.exports=ln;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx-vscode",
3
3
  "type": "module",
4
- "version": "0.2.887",
4
+ "version": "0.2.889",
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",