@stacksjs/stx-vscode 0.2.876 → 0.2.881

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.876",
3
+ "version": "0.2.881",
4
4
  "private": true,
5
5
  "main": "index.js"
6
6
  }
@@ -1,16 +1,16 @@
1
- var Jt=Object.create;var{getPrototypeOf:Ut,defineProperty:Ke,getOwnPropertyNames:qt}=Object;var We=Object.prototype.hasOwnProperty;function Xt(e){return this[e]}var Yt,Qt,Q=(e,t,n)=>{var s=e!=null&&typeof e==="object";if(s){var r=t?Yt??=new WeakMap:Qt??=new WeakMap,i=r.get(e);if(i)return i}n=e!=null?Jt(Ut(e)):{};let a=t||!e||!e.__esModule||!We.call(e,"default")?Ke(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let o of qt(e))if(!We.call(a,o))Ke(a,o,{get:Xt.bind(e,o),enumerable:!0})}if(s)r.set(e,a);return a};var Vt=require("node:crypto"),U=require("node:fs"),Ft=require("node:os"),F=Q(require("node:path"));var _e=["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 ze=Q(require("node:path"),1);function en(e,t){let n=e[t],s=t+1;while(s<e.length){if(e[s]==="\\"){s+=2;continue}if(e[s]===n)return s+1;s++}return e.length}function tn(e,t){let n=t+1;while(n<e.length){if(e[n]==="\\"){n+=2;continue}if(e[n]==="`")return n+1;if(e[n]==="$"&&e[n+1]==="{"){if(n=He(e,n+2),n<e.length)n++;continue}n++}return e.length}function He(e,t){let n=1,s=t,r="{",i="";while(s<e.length){let a=e[s];if(a==="\\"){s+=2;continue}if(a==='"'||a==="'"){s=en(e,s),r=ne,i="";continue}if(a==="`"){s=tn(e,s),r=ne,i="";continue}if(a==="/"&&e[s+1]==="/"){while(s<e.length&&e[s]!==`
2
- `)s++;continue}if(a==="/"&&e[s+1]==="*"){s+=2;while(s<e.length&&e.slice(s,s+2)!=="*/")s++;s+=2;continue}if(a==="/"&&Ge(r,i)){let o=Ze(e,s);if(o!==-1){s=o,r=ne,i="";continue}}if(a==="{")n++;else if(a==="}"){if(n--,n===0)return s}if(/[\w$]/.test(a))i=/[\w$]/.test(r)?i+a:a,r=a;else if(!/\s/.test(a))r=a,i="";s++}return e.length}var nn=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function Ge(e,t){if(t)return nn.has(t);return!(e===")"||e==="]"||e===ne)}var ne="\x00";function Ze(e,t){let n=t+1,s=!1;while(n<e.length){let r=e[n];if(r===`
3
- `)return-1;if(r==="\\"){n+=2;continue}if(r==="[")s=!0;else if(r==="]")s=!1;else if(r==="/"&&!s){n++;while(n<e.length&&/[a-z]/i.test(e[n]))n++;return n}n++}return-1}function N(e){let t="",n=0,s="",r="";while(n<e.length){let i=e.slice(n,n+2);if(i==="//"){while(n<e.length&&e[n]!==`
4
- `)t+=" ",n++;continue}if(i==="/*"){while(n<e.length&&e.slice(n,n+2)!=="*/")t+=e[n]===`
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]===`
5
5
  `?`
6
- `:" ",n++;t+=" ",n+=2;continue}let a=e[n];if(a==='"'||a==="'"){let o=a;t+=" ",n++;while(n<e.length&&e[n]!==o){if(e[n]==="\\"){t+=" ",n+=2;continue}t+=e[n]===`
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]===`
7
7
  `?`
8
- `:" ",n++}t+=" ",n++,s=ne,r="";continue}if(a==="/"&&Ge(s,r)){let o=Ze(e,n);if(o!==-1){t+=`/${" ".repeat(o-n-2)}/`,n=o,s=ne,r="";continue}}if(a==="`"){t+=" ",n++;while(n<e.length&&e[n]!=="`"){if(e[n]==="\\"){t+=" ",n+=2;continue}if(e[n]==="$"&&e[n+1]==="{"){let o=n+2,c=He(e,o);if(t+=" ",t+=N(e.slice(o,c)),c<e.length)t+=" ";n=c+1;continue}t+=e[n]===`
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]===`
9
9
  `?`
10
- `:" ",n++}t+=" ",n++,s=ne,r="";continue}if(t+=a,n++,/[\w$]/.test(a))r=/[\w$]/.test(s)?r+a:a,s=a;else if(!/\s/.test(a))s=a,r=""}return t}function fe(e){let t=new Uint16Array(e.length),n=0,s=!0;for(let r=0;r<e.length;r++){let i=e[r];if(i===")"||i==="]"||i==="}")if(n===0)s=!1;else n--;if(t[r]=n,i==="("||i==="["||i==="{")n++}return{depths:t,balanced:s&&n===0}}class Ae{cache=new Map;maxSize;options;sizes;bytes=0;constructor(e=100,t){this.maxSize=e,this.options=t??null,this.sizes=t?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 t=this.cache.keys().next().value;if(t===void 0)break;this.delete(t)}}get(e){if(!this.cache.has(e))return;let t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}set(e,t){if(this.cache.has(e))this.delete(e);let n=this.options?this.options.sizeOf(t):0;if(this.options&&n>this.options.maxBytes)return;while(this.cache.size>0&&(this.cache.size>=this.maxSize||this.options!==null&&this.bytes+n>this.options.maxBytes)){let s=this.cache.keys().next().value;if(s===void 0)break;this.delete(s)}if(this.cache.set(e,t),this.sizes)this.sizes.set(e,n),this.bytes+=n}has(e){return this.cache.has(e)}delete(e){if(this.sizes){let t=this.sizes.get(e);if(t!==void 0)this.bytes-=t,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 Je{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator(e){let t=Array.from(new Set(e)),n=t.sort().join(","),s=this.pool.find((o)=>o.context.join(",")===n);if(s)return s.func;let r=this.fnCache,i=this.fnCacheMaxSize,a=(...o)=>(c)=>{try{let l=`${n}:${c}`,u=r.get(l);if(!u){if(r.size>=i){let p=r.keys().next().value;if(p)r.delete(p)}u=Function(...t,`
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,`
11
11
  'use strict';
12
12
  try {
13
- return ${c};
13
+ return ${o};
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,u)}return u(...o)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:a,context:t.slice()});return a}clear(){this.pool.length=0,this.fnCache.clear()}}var rs=new Je;class Ue{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(e){this.enabled=e}isEnabled(){return this.enabled}setBudget(e,t){this.budgets.set(e,{warnThreshold:0.8,action:"warn",...t})}setBudgets(e){for(let[t,n]of Object.entries(e))this.setBudget(t,n)}removeBudget(e){this.budgets.delete(e)}getBudgets(){let e={};for(let[t,n]of this.budgets.entries())e[t]=n;return e}onViolation(e){this.violationHandlers.push(e)}offViolation(e){let t=this.violationHandlers.indexOf(e);if(t!==-1)this.violationHandlers.splice(t,1)}time(e,t){if(!this.enabled)return t();let n=performance.now(),s=t(),r=performance.now()-n;return this.recordTime(e,r),this.checkBudget(e,r),s}async timeAsync(e,t){if(!this.enabled)return t();let n=performance.now(),s=await t(),r=performance.now()-n;return this.recordTime(e,r),this.checkBudget(e,r),s}checkBudget(e,t){let n=this.budgets.get(e);if(!n)return;let s=t/n.maxTime*100,r=n.warnThreshold!==void 0?t>=n.maxTime*n.warnThreshold&&t<n.maxTime:!1,i=t>=n.maxTime;if(!r&&!i)return;let a={label:e,actualTime:t,budgetTime:n.maxTime,exceedancePercent:s,timestamp:new Date,isWarning:r};this.violations.push(a);while(this.violations.length>this.maxViolations)this.violations.shift();for(let c of this.violationHandlers)try{c(a)}catch{}let o=r?`[Performance Warning] "${e}" took ${t.toFixed(2)}ms (${s.toFixed(1)}% of ${n.maxTime}ms budget)`:`[Performance Budget Exceeded] "${e}" took ${t.toFixed(2)}ms (exceeded ${n.maxTime}ms budget by ${(s-100).toFixed(1)}%)`;switch(n.action){case"log":console.log(o);break;case"warn":console.warn(o);break;case"error":console.error(o);break;case"throw":if(i)throw Error(o);else console.warn(o);break}}recordTime(e,t){let n=this.metrics.get(e);if(n)n.count++,n.totalTime+=t,n.maxTime=Math.max(n.maxTime,t),n.minTime=Math.min(n.minTime,t);else this.metrics.set(e,{count:1,totalTime:t,maxTime:t,minTime:t})}getStats(e){if(e){let n=this.metrics.get(e);if(!n)return{};let s=this.budgets.get(e);return{count:n.count,avgTime:n.totalTime/n.count,totalTime:n.totalTime,maxTime:n.maxTime,minTime:n.minTime,budget:s?.maxTime,budgetUtilization:s?n.totalTime/n.count/s.maxTime*100:void 0}}let t={};for(let[n,s]of this.metrics.entries()){let r=this.budgets.get(n);t[n]={count:s.count,avgTime:s.totalTime/s.count,totalTime:s.totalTime,maxTime:s.maxTime,minTime:s.minTime,budget:r?.maxTime,budgetUtilization:r?s.totalTime/s.count/r.maxTime*100:void 0}}return t}getViolations(e){if(e)return this.violations.filter((t)=>t.label===e);return[...this.violations]}getViolationStats(){let e={},t=0,n=0;for(let s of this.violations)if(e[s.label]=(e[s.label]||0)+1,s.isWarning)t++;else n++;return{total:this.violations.length,byLabel:e,warnings:t,errors:n}}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 ke=null;function sn(){if(!ke)ke=new Ue;return ke}var is=new Proxy({},{get(e,t){return sn()[t]}});var ls=new Ae(32,{maxBytes:2097152,sizeOf:(e)=>e.code.length*4});function qe(e){let t=e.indexOf(" as ");if(t!==-1){let i=e.slice(0,t).trim(),a=e.slice(t+4).trim();return i&&a?{arrayExpr:i,itemVar:a}:null}let n=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!n)return null;let s=n[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),r=n[2].trim();return s&&r?{arrayExpr:r,itemVar:s}:null}var ce=["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 rn=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var gs=ce.filter((e)=>!rn.includes(e));var on=["x-text","x-html","x-model","x-show","x-if","x-for","x-cloak","x-ref","x-data","x-bind","x-class","x-style","x-tooltip","x-tooltip-position"],an=["x-init","x-transition","x-effect","x-on"],hs=[...on,...an];var Se=Q(require("node:fs"),1),le=Q(require("node:path"),1);function Xe(e,t,n,s){let r=0;for(let i=t;i<e.length;i++)if(e[i]===n)r++;else if(e[i]===s&&!(s===">"&&e[i-1]==="=")){if(--r===0)return i}return-1}function cn(e){let t=N(e),n=0,s=0,r=[];for(let i=0;i<t.length;i++)if("([{".includes(t[i]))n++;else if(")]}".includes(t[i]))n--;else if(t[i]===","&&n===0)r.push(e.slice(s,i).trim()),s=i+1;return r.push(e.slice(s).trim()),r}function Re(e,t){let n=N(e),s=new RegExp(`\\b(?:${t.map((r)=>r.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g");for(let r of n.matchAll(s)){let i=r.index+r[0].length,a="";if(n[i]==="<"){let c=Xe(n,i,"<",">");if(c<0)continue;a=e.slice(i+1,c),i=c+1;while(/\s/.test(n[i]||"")&&i<n.length)i++}if(n[i]!=="(")continue;let o=Xe(n,i,"(",")");if(o>=0)return{type:a,args:cn(e.slice(i+1,o))}}return null}var be=`
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=`
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,73 +26,75 @@ 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 ye(e,t){let n=[],s={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,(m,h,b,y,x)=>{if(r.slice(x,x+6)!=="import")return m;if(y.endsWith(".stx"))return"";let C=`${t}Import${n.length}`;if(n.push(`import * as ${C} from ${JSON.stringify(y)};`),h.startsWith("*"))return`import ${h.replace(/^\*\s+as\s+/,"")} = ${C};`;if(!h.startsWith("{"))return`import ${h} = ${C}.default;`;return h.slice(1,-1).split(",").map((k)=>{let[R,S=R]=k.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!R)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(y)&&R in s)s[R].push(S);return`import ${S} = ${C}.${R};`}).join(`
30
- `)}),a=Re(e,s.defineProps),o=Re(e,s.defineEmits),c=Re(e,s.withDefaults);if(!a&&!o)return{declarations:"",props:null,events:null};let l=[],u=null,p=null;if(a){l.push(`const __options = (${a.args[0]||"{}"}) as const;`),l.push(`const __defaults = (${c?.args[1]||"{}"});`);let m=a.type||"__StxOptions<typeof __options>";l.push(`export type __StxProps = __StxDefaults<${m}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),u=`${t}.__StxProps`}if(o)l.push(`const __events = (${o.args[0]||"[]"}) as const;`),l.push(`export type __StxEvents = ${o.type||"Record<(typeof __events)[number], any[]>"};`),p=`${t}.__StxEvents`;return{declarations:`${n.join(`
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(`
31
31
  `)}
32
- namespace ${t} {
32
+ namespace ${n} {
33
33
  ${i}
34
34
  ${l.join(`
35
35
  `)}
36
- }`,props:u,events:p}}var se=Q(require("node:fs"),1),M=Q(require("node:path"),1);function Qe(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var Ye=new Map;function et(e,t=!0){let n=Ye.get(e);if(t&&n)return n;let s=new Map,r=[M.default.join(e,"src"),M.default.join(e,"dist"),e];function i(a,o){if(o>6)return;let c;try{c=se.default.readdirSync(a,{withFileTypes:!0})}catch{return}for(let l of c){let u=M.default.join(a,l.name);if(l.isDirectory()){if(l.name==="node_modules"||l.name.startsWith("."))continue;i(u,o+1)}else if(l.isFile()&&l.name.endsWith(".stx")){let p=l.name.slice(0,-4);if(!s.has(p))s.set(p,u);let m=p.toLowerCase();if(!s.has(m))s.set(m,u);let h=Qe(p);if(!s.has(h))s.set(h,u)}}}for(let a of r)if(i(a,0),s.size>0)break;if(t)Ye.set(e,s);return s}function tt(e,t){if(e.startsWith(".")||e.startsWith("/"))return null;let n=t;while(!0){let s=M.default.join(n,"node_modules",e);try{if(se.default.statSync(s).isDirectory())return s}catch{}let r=M.default.dirname(n);if(r===n)return null;n=r}}function nt(e,t,n={}){return[M.default.resolve(M.default.dirname(t),`${e}.stx`),M.default.resolve(M.default.dirname(t),e),M.default.resolve(n.componentsDir||"components",`${e}.stx`),M.default.resolve(n.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function st(e){let t=e.endsWith(".stx")?e.slice(0,-4):e,n=t.split("-").map((r)=>r.charAt(0).toUpperCase()+r.slice(1)).join(""),s=Qe(t);return[t,n,s]}function ln(e,t){let[n,s,r]=st(e);for(let i of[n,n.toLowerCase(),s,r]){let a=t?.__importedComponents?.get(i);if(a!==void 0)return a}}function un(e,t){let n=t?M.default.resolve(t):void 0,s=M.default.dirname(M.default.resolve(e));for(;;){if(se.default.existsSync(M.default.join(s,"package.json")))return n&&s===n?void 0:s;let r=M.default.dirname(s);if(r===s)return;s=r}}var dn=["src/ui","src/components","components","dist"];function pn(e,t){let n=M.default.resolve(e);if(!t&&!n.split(M.default.sep).includes("node_modules"))return[];let s=un(n,t);if(!s)return[];let r=[];try{let o=JSON.parse(se.default.readFileSync(M.default.join(s,"package.json"),"utf8")).stx?.components;if(Array.isArray(o))r=o.filter((c)=>typeof c==="string")}catch{}let i=r.length?r:dn;return[M.default.dirname(M.default.resolve(e)),...i.map((a)=>M.default.resolve(s,a))]}function*fn(e,t,n={},s){let r=st(e);if(r[0].startsWith("./")||r[0].startsWith("../")){yield M.default.resolve(M.default.dirname(t),`${r[0]}.stx`);return}let i=[...new Set(r.map((c)=>`${c}.stx`))],a=n.projectRoot||process.cwd(),o=[...pn(t,n.projectRoot),...s?.__originalFilePath?[M.default.join(M.default.dirname(s.__originalFilePath),"components")]:[],...n.componentsDir?[n.componentsDir]:[],M.default.join(M.default.dirname(t),"components"),M.default.resolve(a,"src/components"),M.default.resolve(a,"components"),M.default.resolve("/home/runner/work/stx/stx/packages/stx/src","components")];for(let c of new Set(o)){for(let l of i)yield M.default.join(c,l);try{for(let l of se.default.readdirSync(c,{withFileTypes:!0}))if(l.isDirectory())for(let u of i)yield M.default.join(c,l.name,u)}catch{}}}function rt(e,t,n={},s){let r=ln(e,s);if(r!==void 0)return r;for(let i of fn(e,t,n,s))try{if(se.default.statSync(i,{throwIfNoEntry:!1})?.isFile())return i}catch{}return null}var it=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 ot(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...it].some((t)=>t.toLowerCase()===e.toLowerCase());return it.has(e)||/[A-Z]/.test(e)}function*mn(e){let t=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,n;while(n=t.exec(e)){let s=t.lastIndex,r=[];while(s<e.length){while(/\s/.test(e[s]||""))s++;if(e[s]===">"||e.slice(s,s+2)==="/>"){s+=e[s]===">"?1:2;break}let i=/^[^\s=/>]+/.exec(e.slice(s))?.[0];if(!i){s++;continue}let a=s;s+=i.length;while(/\s/.test(e[s]||""))s++;if(e[s]!=="="){r.push({name:i,value:!0,offset:a,braced:!1});continue}s++;while(/\s/.test(e[s]||""))s++;let o=e[s],c=o==="{",l=o==='"'||o==="'";if(l||c)s++;let u=s;if(c){let p=N(e.slice(s)),m=1,h=0;for(;h<p.length;h++){if(p[h]==="{")m++;if(p[h]==="}"&&--m===0)break}s+=h}else if(l)while(s<e.length&&e[s]!==o)s++;else while(s<e.length&&!/[\s/>]/.test(e[s]))s++;if(r.push({name:i,value:e.slice(u,s),offset:u,braced:c}),l||c)s++}t.lastIndex=s,yield{name:n[1],offset:n.index,attributes:r}}}function at(e,t,n){let s=[],r=[be,"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,o=new Map,c=n.scriptCode(e,n.filePath),l=N(c);for(let b of c.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(l.slice(b.index,b.index+6)!=="import")continue;let y=b[2],x=le.default.isAbsolute(y)||y.startsWith(".")?le.default.resolve(le.default.dirname(n.filePath),y):tt(y,le.default.dirname(n.filePath));if(!x)continue;let C=x.endsWith(".stx")?x:Se.default.existsSync(`${x}.stx`)?`${x}.stx`:void 0,k=C?null:et(x,!1),R=b[1].startsWith("{")?b[1].slice(1,-1).split(","):[b[1]];for(let S of R){let[v,_=v]=S.trim().split(/\s+as\s+/),O=C||k?.get(v)||k?.get(v.toLowerCase());if(O)o.set(_,O),o.set(_.toLowerCase(),O),o.set(_.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),O)}}for(let b of t.matchAll(/@import\s*\(([^)]+)\)/g))for(let y of b[1].matchAll(/['"]([^'"]+)['"]/g)){let x=nt(y[1],n.filePath,n).find((C)=>Se.default.statSync(C,{throwIfNoEntry:!1})?.isFile());if(x)o.set(le.default.basename(y[1]).replace(/\.stx$/,""),x)}let u={__importedComponents:o},p=new Map,m=(b,y,x)=>{let C=e.slice(0,b);return{code:y,offset:b,attribute:x,anchor:!0,kind:"directive",line:C.split(`
37
- `).length,column:b-C.lastIndexOf(`
38
- `)}},h=(b,y,x)=>s.push({expression:b,statement:{text:y+b.code+x,prefixLength:y.length}});for(let b of mn(t)){if(ot(b.name)||b.name==="component")continue;let y=rt(b.name,n.filePath,n,u);if(!y)continue;let x=p.get(y);if(!x){let k;try{k=n.readComponent?n.readComponent(y):Se.default.readFileSync(y,"utf8")}catch{continue}if(k===void 0)continue;a.set(y,k),x=ye(n.scriptCode(k,y),`__StxComponent${p.size}`),p.set(y,x),r.push(x.declarations)}let C=[];for(let k of b.attributes){let{name:R,offset:S}=k,v=k.value===!0?"true":k.value;if(R.startsWith("@")||R.startsWith("v-on:")){if(x.events&&k.value!==!0)i.set(S,`__StxEvent<${x.events}, ${JSON.stringify(R.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let _=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(R);if(R.startsWith("v-")&&!R.startsWith("v-bind:")&&!_)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(R))continue;let O=(_?_[1]||"modelValue":R.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(D,A)=>A.toUpperCase());if(C.push(O),!x.props)continue;let T=R.startsWith(":")||R.startsWith("v-bind:")||!!_||k.braced,I=T?v:k.value!==!0?JSON.stringify(v):"true",j=!T&&k.value!==!0&&(v==="true"||v==="false");h(m(S,I,R),";void ((",`) satisfies ${j?"__StxStaticProp":"__StxProp"}<${x.props}, ${JSON.stringify(O)}>);`)}if(x.props){let k=[...new Set(C)].map((S)=>`${JSON.stringify(S)}: undefined as any`).join(", "),R=m(b.offset,`<${b.name}>`);s.push({expression:R,statement:{text:`;void ({ ${k} } satisfies ${x.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:p.size?r.join(`
39
- `):"",checks:s,events:i,dependencies:a}}var je=Q(require("node:fs"),1),G=Q(require("node:path"),1);function Oe(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(t)=>t.replace(/[^\n]/g," "))}function ct(e,t){let n=Oe(e).match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!n)return{};let s=n.index+n[0].indexOf(">")+1,r=e.slice(s,s+n[1].length).trim();if(!r)return{};try{let i=JSON.parse(r);if(!i||typeof i!=="object"||Array.isArray(i))throw Error("expected a JSON object");return i}catch(i){throw Error(`${t}: <script component> must contain JSON metadata (${i.message})`)}}function Me(e,t){let n=N(e),s=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,r=[],i=t?void 0:new Bun.Transpiler({loader:"ts"}),a;while(a=s.exec(n)){let o=s.lastIndex;while(/\s/.test(n[o]||""))o++;let c=o;if(n[o]==="<")o=Pe(n,o,"<",">");if(o<0)continue;let l=e.slice(c,o).trim();while(/\s/.test(n[o]||""))o++;if(n[o]!=="(")continue;let u=o,p=Pe(n,o,"(",")");if(p<0)continue;for(o=p;o<e.length;o++){let m=n[o];if(m!=="{"&&m!==";")continue;let h=e.slice(a.index,o).trim();if(t){if(!t(h,m,a[1]))continue}else{let y;try{y=i.transformSync(h+(m==="{"?"{}":";"))}catch{continue}if(m==="{"&&!y.includes(`function ${a[1]}(`))continue;if(m===";"&&y.trim())continue}let b=m==="{"?Pe(n,o,"{","}"):o+1;if(b<0)break;r.push({name:a[1],header:h,generic:l,parameterOffset:u+1,parameters:e.slice(u+1,p-1),returns:e.slice(p,o).trim().replace(/^:\s*/,""),async:/\basync\s+function/.test(a[0]),...m==="{"?{source:e.slice(a.index,b)}:{}}),s.lastIndex=b;break}}return r}function ve(e,t){if(e[t]!=="(")return null;let n=0,s="";for(let r=t;r<e.length;r++){let i=e[r];if(s!==""){if(i==="\\")r++;else if(i===s)s="";continue}if(i==="'"||i==='"'||i==="`"){s=i;continue}if(i==="(")n++;else if(i===")"){if(n--,n===0)return{expression:e.slice(t+1,r),end:r+1}}}return null}function lt(e){let t=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec(e.trim());return t?{iterable:t[1],key:t[2],value:t[3]}:void 0}function Pe(e,t,n,s){if(e[t]!==n)return-1;let r=0,i=null;for(let a=t;a<e.length;a++){let o=e[a];if(i){if(o==="\\"){a++;continue}if(o===i)i=null;continue}if(o==="'"||o==='"'||o==="`"){i=o;continue}if(o===n)r++;else if(o===s){if(s===">"&&e[a-1]==="=")continue;if(r--,r===0)return a+1}}return-1}function De(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"}}function ut(e){let t=$e(e),n=t.find((i)=>i.name==="InheritedContext");if(!n)return;let s=n.text.slice(n.text.indexOf("{")+1,n.text.lastIndexOf("}"));return{keys:[...N(s).matchAll(/(?:^|[;\n])\s*(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:/g)].map((i)=>i[1]),types:t.map((i)=>i.text).join(`
40
- `)}}function dt(e){let t=ut(e);if(!t)return"";let n=new Set(re(e));return t.keys.filter((s)=>!n.has(s)).map((s)=>`declare const ${s}: InheritedContext[${JSON.stringify(s)}];`).join(`
41
- `)}function pt(e,t){let n=[be],s=[],r=new Map,i=G.default.resolve(t.filePath),a=i.split(G.default.sep).lastIndexOf("views"),o=a>=0?i.split(G.default.sep).slice(0,a).join(G.default.sep):G.default.dirname(i),c=G.default.resolve(t.partialsDir||G.default.join(o,"partials")),l=G.default.resolve(t.layoutsDir||G.default.join(o,"views/layouts"));if([c,l].some((x)=>i===x||i.startsWith(x+G.default.sep)))return{declarations:"",checks:s,dependencies:r};let u=(x)=>t.readTemplate?.(x)??(je.default.existsSync(x)?je.default.readFileSync(x,"utf8"):void 0),p=0,m=!1,h=[];function b(x,C){let k=e.slice(0,x).split(`
42
- `).length,R=x-e.lastIndexOf(`
43
- `,x-1),S={code:e.slice(x,e.indexOf(`
44
- `,x)<0?e.length:e.indexOf(`
45
- `,x)),line:k,column:R,kind:"directive",offset:x,anchor:!0};s.push({expression:S,statement:{text:C,prefixLength:0}})}function y(x,C,k,R,S,v){let _=`__StxInherited${p++}`,O=ue(x).filter((L)=>L.kind==="server").map((L)=>L.code).join(`
46
- `),T=Le(Ce(O,G.default.dirname(C)),_);n.push(...T.imports);let I=ut(O);if(I&&S!==void 0){m=!0;let L=T.imports.length?T.aliases.join(`
47
- `):"",H=ye(`${L}
48
- ${I.types}
49
- const __contract = defineProps<InheritedContext>();`,`${_}Contract`);n.push(H.declarations),n.push(`declare const ${_}Input: ${k};`),b(S,`${_}Input satisfies ${H.props};`)}let j=re(O),D=[...new Set([...R,...I?.keys||[]])].filter((L)=>!j.includes(L)),A=I?`${k} & ${_}Contract.__StxProps`:k,K=we(T.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),W=[],Y=de(x),Z=/@(include|extends|layout)\s*\(/g,J;while(J=Z.exec(Y)){let L=ve(Y,Z.lastIndex-1);if(!L)continue;Z.lastIndex=L.end;let H=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(L.expression);if(!H){h.push({offset:S??J.index,message:`Inherited context cannot be checked across dynamic @${J[1]}`});continue}let q=H[2],X=J[1];if(X!=="include"&&H[3])h.push({offset:S??J.index,message:`Inherited context cannot be checked for unsupported @${X} data arguments`});let ae=X==="include"?c:l,V=G.default.resolve(q.startsWith(".")?G.default.dirname(C):ae,q.endsWith(".stx")?q:q+".stx");if(u(V)===void 0){h.push({offset:S??J.index,message:`Inherited context target cannot be resolved: ${q}`});continue}W.push({name:`edge${W.length}`,target:V,kind:X,args:X==="include"?H[3]||"{}":"{}",offset:S??J.index})}let oe=`{ ...parent${j.length?", "+j.join(", "):""} }`;n.push(`namespace ${_} {
50
- ${T.aliases.join(`
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(`
51
51
  `)}
52
- export async function read(parent: ${S===void 0?"{}":A}) {
53
- ${D.length?`const { ${D.join(", ")} } = parent;`:""}
54
- ${K}
55
- return { context: ${oe}${W.map((L)=>`, ${L.name}: { ...${oe}, ...(${L.args}) }`).join("")} };
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("")} };
56
56
  }
57
- }`);for(let L of W){if(v.includes(L.target)||v.length>=32){h.push({offset:L.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let H=u(L.target);r.set(L.target,H),y(H,L.target,`Awaited<ReturnType<typeof ${_}.read>>[${JSON.stringify(L.name)}]`,[...new Set([...R,...j])],L.offset,[...v,L.target])}return _}if(y(e,i,"{}",[],void 0,[i]),m||t.contractsKnown)for(let x of h)b(x.offset,`({})[${JSON.stringify(x.message)}];`);return{declarations:m?n.join(`
58
- `):"",checks:s,dependencies:r}}function ft(e,t){let n=Oe(e);if(!/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))/i.test(n))return;let s;try{s=ct(e,"component")}catch(h){let b=e.search(/<script\b(?=[^>]*\bcomponent\b)/i),y=h instanceof Error?h.message:"Invalid component metadata";return{declarations:"",checks:[{text:`({})[${JSON.stringify(y)}];`,line:e.slice(0,b).split(`
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(`
59
+ `).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(`
59
63
  `).length,column:b-e.lastIndexOf(`
60
- `,b-1),origin:"component"}],project:(x)=>({code:x,columns:new Map})}}let r=[...n.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)].filter((h)=>/\bclient\b/.test(h[1])&&!/\bcomponent\b/.test(h[1])),i=r.map((h)=>{let b=h.index+h[0].indexOf(">")+1;return e.slice(b,b+h[2].length)}).join(`
61
- `),a=Me(i,t),o=/\b(?:interface|type)\s+ComponentState\b/.test(N(i)),c=Object.entries(s.properties||s.props||{}).map(([h,b])=>`${JSON.stringify(h)}: ${De(b)}`).join("; "),l=[...new Set(a.map((h)=>h.name))],u=[`interface __StxMetadataProperties { ${c} }`,"type __StxNativeProperties = Omit<__StxMetadataProperties, keyof HTMLElement> & Pick<HTMLElement, Extract<keyof __StxMetadataProperties, keyof HTMLElement>>;",o?"declare const __stxStateProperties: Pick<ComponentState, Extract<keyof ComponentState, keyof __StxNativeProperties>>;":"",`type __StxNativeComponent = Omit<HTMLElement, keyof __StxNativeProperties | ${o?"keyof ComponentState | ":""}${l.map((h)=>JSON.stringify(h)).join(" | ")||"never"}> & ${o?"Omit<__StxNativeProperties, keyof ComponentState> & ComponentState":"__StxNativeProperties"} & {`,"readonly updateComplete: Promise<void>; requestUpdate(): Promise<void>; readonly renderRoot: HTMLElement | ShadowRoot;","emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean;",...l.map((h)=>`${JSON.stringify(h)}: typeof ${h};`),"}"].filter(Boolean).join(`
62
- `),p=-1;for(let h of r){let b=h.index+h[0].indexOf(">")+1,y=/\b(?:interface|type)\s+ComponentState\b/.exec(N(e.slice(b,b+h[2].length)));if(y){p=b+y.index;break}}let m=o&&p>=0?[{origin:"client",text:"__stxStateProperties satisfies Pick<__StxNativeProperties, Extract<keyof ComponentState, keyof __StxNativeProperties>>;",line:e.slice(0,p).split(`
63
- `).length,column:p-e.lastIndexOf(`
64
- `,p-1)}]:[];for(let[h,b]of Object.entries(s.properties||s.props||{})){let y=e.indexOf(JSON.stringify(h),e.indexOf("<script")),x=e.slice(0,y).split(`
65
- `).length,C=y-e.lastIndexOf(`
66
- `,y-1);if(!b||typeof b!=="object"||!["string","number","boolean","object","array"].includes(b.type))m.push({text:`({})[${JSON.stringify(`Property ${h} must declare string, number, boolean, object or array`)}];`,line:x,column:C,origin:"component"});if(b&&b.default!==void 0)m.push({text:`const __stxDefault${m.length}: ${De(b)} = ${JSON.stringify(b.default)};`,line:x,column:C,origin:"component"})}return{declarations:u,checks:m,project(h){let b=new Map,y=[],x=0;for(let C of Me(h,t)){if(/^\s*this\s*:/.test(C.parameters))continue;let k=C.parameterOffset,R=`this: __StxNativeComponent${C.parameters.trim()?", ":""}`;y.push(h.slice(x,k),R);let S=h.slice(0,k).split(`
67
- `).length,v=k-h.lastIndexOf(`
68
- `,k-1),_=b.get(S)||[],O=_.at(-1),T=v+(O?O.generatedEnd-O.sourceEnd:0);_.push({sourceStart:v,sourceEnd:v,generatedStart:T,generatedEnd:T+R.length}),b.set(S,_),x=k}return y.push(h.slice(x)),{code:y.join(""),columns:b}}}}function mt(e){let t=[],n=[],s=/@foreach\s*\(|@endforeach\b/g,r;while(r=s.exec(e)){if(r[0].startsWith("@endforeach")){let c=n.pop();if(c)c.end=r.index,t.push(c);continue}let i=ve(e,s.lastIndex-1);if(!i)continue;let a=lt(i.expression),o=i.end;if(a)n.push({start:o,end:e.length,iterable:a.iterable,binding:a.key?`${a.value}, ${a.key}`:a.value});s.lastIndex=o}return t.sort((i,a)=>i.start-a.start)}function gt(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))return[];let t=[],n=[],s=/<!--[\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(s)){let i=r[0];if(/^<\/template\s*>$/i.test(i)){let a=n.pop();if(a)a.end=r.index}else if(/^<template\b/i.test(i)&&!/\/\s*>$/.test(i)){let o=[...i.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((u)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(u[1])),c=(o?.[2]??o?.[3])?.trim();if(c&&o?.[1]==="data-stx-slot-binding")try{c=decodeURIComponent(c)}catch{c=void 0}let l=c?{start:r.index+i.length,end:e.length,binding:c}:void 0;if(n.push(l),l)t.push(l)}}return t}var ht=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;function gn(e){let t=(n)=>n.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,t).replace(/\{\{--[\s\S]*?--\}\}/g,t)}function ue(e){let t=[],n=gn(e);ht.lastIndex=0;let s;while((s=ht.exec(n))!==null){let r=(s[1]||"").trim(),i=(s[0].match(/^<script(?:\s[^>]*)?>/i)?.[0]??"<script>").length,a=(s[0].match(/<\/script\s*>$/i)?.[0]??"</script>").length,o=s.index+i,c=s.index+s[0].length-a,l=e.slice(o,c);if(/\bsrc\s*=/.test(r)||/\b(?:stx:)?component\b/.test(r))continue;let u=r.match(/\btype\s*=\s*["']([^"']+)["']/i);if(u&&!/^(?:module|text\/(?:javascript|typescript))$/i.test(u[1]))continue;let p=/\bserver\b/.test(r)?"server":/\bclient\b/.test(r)?"client":"plain",m=me(e,o);t.push({kind:p,code:l,startLine:m,startColumn:ge(e,o),offset:o,attrs:r})}return t}function me(e,t){let n=1;for(let s=0;s<t&&s<e.length;s++)if(e.charCodeAt(s)===10)n++;return n}function ge(e,t){let n=e.lastIndexOf(`
69
- `,t-1)+1;return t-n+1}function de(e){let t=e.split(""),n=(r,i)=>{for(let a=r;a<i&&a<t.length;a++)if(t[a]!==`
70
- `)t[a]=" "},s=[/<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 s){r.lastIndex=0;let i;while((i=r.exec(e))!==null)n(i.index,i.index+i[0].length)}return t.join("")}function wt(e){let t=0,n="";for(let s=0;s<e.length;s++){let r=e[s];if(n){if(r==="\\"){s++;continue}if(r===n)n="";continue}if(r==='"'||r==="'"||r==="`"){n=r;continue}if(r==="("||r==="["||r==="{"){t++;continue}if(r===")"||r==="]"||r==="}"){t--;continue}if(r==="|"&&t===0){if(e[s+1]==="|"){s++;continue}if(e[s-1]==="|")continue;return e.slice(0,s)}}return e}var $t=new Set([":for","x-for","v-for"]),Ee=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,Be="__stx_interpolated",xt="__StxElement",Ct="__StxTemplateValue",hn=`type ${Ct}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function bt(e){return e.replace(/\{\{[\s\S]*?\}\}/g,Be).replace(/\{!![\s\S]*?!!\}/g,Be)}function xn(e,t,n){let s=0;for(let r=t;r<e.length;r++){let i=e[r];if(i==="{"){s++;continue}if(i!=="}"&&i!=="!")continue;if(e.startsWith(n,r)&&s===0)return r;if(i==="}"&&s>0)s--}return-1}function bn(e,t,n="0"){let s=`__stxScript${n}`;while((e+t).includes(s))s+="_";let r=new Map,i=[],a=[],o=N(e),c=he(e),l=[],u=0;for(let y=0;y<o.length;y++){let x=o.startsWith("{{",y);if(!x&&!o.startsWith("{!!",y))continue;let C=x?2:3,k=x?"}}":"!!}",R=xn(o,y+C,k);if(R<0)continue;let S=y,v=e.slice(S,R+k.length),_=v.slice(C,-k.length);y=R+k.length-1;let O=a.length,T=ie(c,S),I=ie(c,S+(x?2:3));a.push({code:wt(_),...I});let j=`${s}_${O}`,D=v.split(`
71
- `),A=D[0].length;D[0]=j+" ".repeat(Math.max(0,A-j.length));for(let Z=1;Z<D.length;Z++)D[Z]=D[Z].replace(/[^\r]/g," ");let K=r.get(T.line)??[],W=K.at(-1),Y=T.column+(W?W.generatedEnd-W.sourceEnd:0);K.push({sourceStart:T.column,sourceEnd:T.column+A,generatedStart:Y,generatedEnd:Y+D[0].length}),r.set(T.line,K),l.push(e.slice(u,S),D.join(`
72
- `)),u=S+v.length}l.push(e.slice(u));let p=l.join("");if(!a.length)return{code:p,columns:r,declarations:i};let{imports:m,aliases:h,body:b}=Le(t,s);for(let y of m)i.push({text:y});i.push({text:`namespace ${s}Scope {
73
- ${h.join(`
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(`
65
+ `).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(`
74
74
  `)}
75
75
  export async function read() {
76
- ${we(b).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
77
- return {`});for(let[y,x]of a.entries())i.push({text:`value${y}: (`}),i.push({text:x.code,origin:{line:x.line,column:x.column}}),i.push({text:"),"});i.push({text:`}
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:`}
78
78
  }
79
- }`});for(let y=0;y<a.length;y++)i.push({text:`declare var ${s}_${y}: Awaited<ReturnType<typeof ${s}Scope.read>>['value${y}']`});return{code:p,columns:r,declarations:i}}function Le(e,t){let n=[],{imports:s,body:r}=En(e),i=[],a=0;for(let o of s.split(/\n(?=import\b)/)){if(!o.trim())continue;let c=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(o);if(!c){n.push(o);continue}let l=`${t}Module${a++}`;n.push(`import * as ${l} from ${c[2]}`);let u=c[1],p=/\{([\s\S]*?)\}/.exec(u);for(let y of p?.[1].split(",")??[]){let[x,C=x]=y.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(x==="default")i.push(`const ${C} = ${l}.default; type ${C} = import(${c[2]}).default`);else if(x)i.push(`import ${C} = ${l}.${x}`)}let m=u.replace(/\{[\s\S]*?\}/,""),h=/\*\s+as\s+(\w+)/.exec(m);if(h)i.push(`import ${h[1]} = ${l}`);let b=/^\s*([\w$]+)/.exec(m)?.[1];if(b)i.push(`const ${b} = ${l}.default; type ${b} = import(${c[2]}).default`)}return{imports:n,aliases:i,body:r}}function Ie(e,t){let n=0;for(let s of e){if(t<s.generatedStart)break;if(t<s.generatedEnd)return s.sourceStart+Math.min(t-s.generatedStart,s.sourceEnd-s.sourceStart);n=s.sourceEnd-s.generatedEnd}return t+n}function Ne(e,t){let n=0;for(let s of e){if(t<s.sourceStart)break;if(t<s.sourceEnd)return s.generatedStart+Math.min(t-s.sourceStart,s.generatedEnd-s.generatedStart);n=s.generatedEnd-s.sourceEnd}return t+n}var yn=["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"],Sn=new RegExp(String.raw`^[ \t]*@(?:${yn.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function we(e){return e.replace(Sn,(t)=>t.replace(/[^\n]/g," "))}var yt=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function vn(e){let t=de(e),n=[],s=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,r;while((r=s.exec(t))!==null){if(r[1]||r[3])continue;let o=r[2]??r[4]??"",c=r[2]!==void 0?2:3,l=wt(o);if(!l.trim())continue;let u=r.index+c+(l.length-l.trimStart().length);n.push({code:l.trim(),line:me(t,u),column:ge(t,u),offset:u,kind:"interpolation"})}let i=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((r=i.exec(t))!==null){let a=r.index+r[0].length-1,o=0,c=a;for(;c<t.length;c++){let m=t[c];if(m==="(")o++;else if(m===")"){if(o--,o===0)break}}if(o!==0)continue;let l=t.slice(a+1,c),u=l.trim();if(i.lastIndex=c+1,!u)continue;let p=a+1+(l.length-l.trimStart().length);n.push({code:u,line:me(t,p),column:ge(t,p),offset:r.index,kind:"condition"})}Ee.lastIndex=0;while((r=Ee.exec(t))!==null){let a=r[1],o=r[3]??"",c=a.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(yt.has(c)||yt.has(a))continue;if(!o.trim())continue;let l=r.index+r[0].indexOf(r[2],r[0].indexOf(a)+a.length)+1;if($t.has(c)){let p=o.match(/\s+(?:in|of)\s+/);if(!p||p.index===void 0)continue;let m=o.slice(p.index+p[0].length),h=p.index+p[0].length+(m.length-m.trimStart().length);n.push({code:bt(m.trim()),line:me(t,l+h),column:ge(t,l+h),offset:l+h,kind:"directive",attribute:c});continue}let u=o.length-o.trimStart().length;n.push({code:bt(o.trim()),line:me(t,l+u),column:ge(t,l+u),offset:l+u,kind:"directive",attribute:c})}return n.sort((a,o)=>a.line-o.line||a.column-o.column),n}var wn=2000;function $n(e,t){let n=0,s=Math.min(e.length,t+wn);for(let r=t;r<s;r++){let i=e[r];if(i==="(")n++;else if(i===")"){if(n--,n===0)return e.slice(t+1,r)}}return null}function Cn(e){let t=new Map,n=(o,c)=>{let l=o.split(/[,[\]{}()\s]+/).filter(Boolean);for(let u of l){let p=u.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(p))continue;let m=l.length===1?c:void 0,h=t.get(p);if(!h)t.set(p,{name:p,iterable:m});else if(h.iterable!==m)h.iterable=void 0}},s=/^\$?[A-Z_$][\w$]*$/i,r=(o)=>{let c=o.trim();return s.test(c)?c:void 0};for(let o of e.matchAll(/@for(?:each|else)\s*\(/g)){let c=$n(e,o.index+o[0].length-1);if(c===null)continue;let l=qe(c);if(!l)continue;n(l.itemVar.replace(/=>/g," "),r(l.arrayExpr))}for(let o of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))n(o[1],o[2]==="of"?r(o[3]):void 0);for(let o of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))n(o[1]);let i=de(e);Ee.lastIndex=0;let a;while((a=Ee.exec(i))!==null){let o=a[1].replace(/\..*$/,"");if(!$t.has(o))continue;let c=a[3].match(/\s+(?:in|of)\s+/);if(!c||c.index===void 0)continue;n(a[3].slice(0,c.index),r(a[3].slice(c.index+c[0].length)))}for(let o of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let c of o[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))n(c[1]);return[...t.values()].sort((o,c)=>o.name.localeCompare(c.name))}function re(e){let t=new Set;for(let n of e.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s+([\w$]+)/gm))t.add(n[1]);for(let n of e.matchAll(/^\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([\w$]+)/gm))t.add(n[1]);for(let n of e.matchAll(/^\s*(?:export\s+)?class\s+([\w$]+)/gm))t.add(n[1]);for(let n of e.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s*[[{]([^\]}]*)[\]}]/gm))for(let s of n[1].split(",")){let r=s.split(":").pop().split("=")[0].replace(/^\.\.\./,"").trim();if(/^[A-Z_$][\w$]*$/i.test(r))t.add(r)}return[...t].sort()}var St=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"];function Et(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((t)=>t[1]))}function En(e){let t=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,n=[],s=e.replace(t,(r)=>(n.push(r.trim()),r.split(`
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(`
80
80
  `).map(()=>"").join(`
81
- `)));return{imports:n.join(`
82
- `),body:s}}function $e(e){let t=N(e),n=Array(t.length),s=0;for(let o=0;o<t.length;o++){let c=t[o];if(c==="}"||c===")"||c==="]")s=Math.max(0,s-1);if(n[o]=s,c==="{"||c==="("||c==="[")s++}let r=[],i=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,a;while((a=i.exec(t))!==null){if(n[a.index]!==0)continue;let o=a[1],c=a[2],l;if(o==="interface"){let u=t.indexOf("{",a.index);if(u===-1)continue;let p=0;l=-1;for(let m=u;m<t.length;m++)if(t[m]==="{")p++;else if(t[m]==="}"&&--p===0){l=m+1;break}if(l===-1)continue}else{let u=0;l=t.length;for(let p=t.indexOf("=",a.index)+1;p<t.length;p++){let m=t[p];if(m==="{"||m==="["||m==="("||m==="<")u++;else if(m==="}"||m==="]"||m===")"||m===">")u--;else if(u<=0&&(m===";"||m===`
83
- `&&!/[=|&,<([{]\s*$/.test(t.slice(Math.max(0,p-40),p)))){l=m===";"?p+1:p;break}}}r.push({name:c,text:e.slice(a.index,l).replace(/^[ \t]*export[ \t]+/,"")}),i.lastIndex=l}return r}function Tn(e){let t=N(e),n=[],s=/^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+/gm,r,i=0,a=0;while((r=s.exec(t))!==null){for(;a<r.index;a++){let l=t[a];if(l==="{"||l==="("||l==="[")i++;else if(l==="}"||l===")"||l==="]")i=Math.max(0,i-1)}if(i!==0)continue;let o=0,c=t.length;for(let l=r.index+r[0].length;l<t.length;l++){let u=t[l];if(u==="{"||u==="("||u==="[")o++;else if(u==="}"||u===")"||u==="]")o--;else if(o<=0&&(u===";"||u===`
84
- `)){c=u===";"?l+1:l;break}}if(/\bdefineProps\s*(?:<|\()/.test(t.slice(r.index,c)))n.push(e.slice(r.index,c).replace(/^[ \t]*export[ \t]+/,"").trim())}return n}function _n(e){let t=e.filter((r)=>r.kind==="server").map((r)=>r.code).join(`
85
- `);if(/\bdefineProps\s*(?:<|\()/.test(N(t)))return t;let n=kn(t),s=e.filter((r)=>r.kind!=="server").flatMap((r)=>{let i=Tn(r.code);if(!i.length)return[];return[...$e(r.code).filter((a)=>!n.has(a.name)).map((a)=>a.text),...i]});return[t,...s].filter(Boolean).join(`
86
- `)}function kn(e){return new Set($e(e).map((t)=>t.name))}var vt=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];function Tt(e){let t=new Set,n=new Set;for(let s of e){let r=s.kind==="server"?t:n;for(let i of re(s.code))r.add(i)}return[...t].filter((s)=>n.has(s)).sort()}var An=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function Rn(e){let t=new Map,n=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let s of e){let r=N(s),{depths:i,balanced:a}=fe(r);if(!a)continue;let o=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let c of r.matchAll(o)){let l=c.index??0;if(i[l+c[1].length]!==0)continue;let u=c[2],p=l+c[0].length-c[3].length,m=s.slice(p,l+c[0].length).trim().replace(/;$/,"").trim(),h=c[3],b=n.test(h)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(h)&&!/[,+\-*/%&|?:=]$/.test(m)&&fe(h).balanced;t.set(u,t.has(u)||!b?null:m)}}return new Map([...t].filter((s)=>s[1]!==null))}function _t(e,t,n=0,s=new Set){if(t.size===0||n>=5)return e;let r=N(e),i="",a=0;for(let o of r.matchAll(/[A-Za-z_$][\w$]*/g)){let c=o.index??0,l=o[0],u=t.get(l);if(!u||s.has(l))continue;let p=r.slice(0,c).trimEnd(),m=r.slice(c+l.length).trimStart();if(p.endsWith(".")||/^:(?!:)/.test(m)&&/[{,]$/.test(p))continue;if(c>0&&/[\w$]/.test(r[c-1]))continue;i+=`${e.slice(a,c)}(${_t(u,t,n+1,new Set([...s,l]))})`,a=c+l.length}return i+e.slice(a)}function Pn(e,t){let n=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,s=[],r;while((r=n.exec(e))!==null){if(r.index>t)break;let i=r[1];if(r.index===t){if(i==="elseif"){let o=s[s.length-1];if(o?.current)o.seen.push(o.current);if(o)o.current=null}break}if(i==="endif"||i==="endunless"){s.pop();continue}let a="";if(r[2]==="("){let o=0,c=r.index+r[0].length-1,l=c+1;for(;c<e.length;c++){let u=e[c];if(u==="(")o++;else if(u===")"){if(o--,o===0)break}}a=e.slice(l,c).trim(),n.lastIndex=c+1}if(i==="if")s.push({seen:[],current:a});else if(i==="unless")s.push({seen:[],current:`!(${a})`});else if(i==="elseif"||i==="else"){let o=s[s.length-1];if(!o)continue;if(o.current)o.seen.push(o.current);o.current=i==="elseif"?a:null}}return s.flatMap((i)=>[...i.seen.map((a)=>`!(${a})`),...i.current?[i.current]:[]]).filter(Boolean)}function On(e){let t=e.code.trim();if(!t)return null;if(e.attribute?.startsWith("@")){if(An.test(t))return null;let s=";(($event: any): void => { ";return{text:`${s}${t} });`,prefixLength:s.length}}let n=";void ((";return{text:`${n}${t}));`,prefixLength:n.length}}var Mn=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function Ce(e,t){return kt(e,t).code}function kt(e,t){let n=new Map;if(!t)return{code:e,columns:n};let s=he(e),r=[],i=0;for(let a of e.matchAll(Mn)){let o=a.index,[c,l,u,p]=a,m=ze.default.resolve(t,p).replace(/\\/g,"/"),h=`${l}${u}${m}${u}`;if(r.push(e.slice(i,o),h),i=o+c.length,c.includes(`
87
- `))continue;let b=ie(s,o),y=n.get(b.line)??[],x=y.at(-1),C=b.column+(x?x.generatedEnd-x.sourceEnd:0);y.push({sourceStart:b.column,sourceEnd:b.column+c.length,generatedStart:C,generatedEnd:C+h.length}),n.set(b.line,y)}return r.push(e.slice(i)),{code:r.join(""),columns:n}}function Dn(e,t,n){let s=Ie(e.importColumns?.get(t)??[],n);return Ie(e.scriptColumns?.get(t)??[],Ie(e.componentColumns?.get(t)??[],s))}function At(e,t,n){let s=Ne(e.scriptColumns?.get(t)??[],n);return Ne(e.importColumns?.get(t)??[],Ne(e.componentColumns?.get(t)??[],s))}function jn(e){return" ".repeat(Math.max(0,(e.startColumn??1)-1))}function Ln(e){let t=new Set,n=N(e);for(let s of n.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let r=s[1],i=/\{([^}]*)\}/.exec(r);for(let l of i?.[1].split(",")??[]){let u=l.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(u&&/^[A-Z_$][\w$]*$/i.test(u))t.add(u)}let a=r.replace(/\{[^}]*\}/,""),o=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(a);if(o)t.add(o[1]);let c=/^\s*([A-Z_$][\w$]*)/i.exec(a);if(c&&c[1]!=="type")t.add(c[1])}return[...t].sort()}function Rt(e,t={}){let n=ue(e),s=t.scriptKinds?n.filter((S)=>t.scriptKinds.includes(S.kind)):n,r=ft(e,t.componentMethodValidator),i=t.filePath&&t.templateExpressions!==!1?pt(e,{filePath:t.filePath,partialsDir:t.partialsDir,layoutsDir:t.layoutsDir,contractsKnown:t.inheritedContractsKnown,readTemplate:t.readComponent}):void 0,a=new Map,o=e.split(`
88
- `),c=Array.from({length:o.length},()=>""),l=new Map,u=new Map,p=new Map,m=[],h=_n(n),b=t.filePath&&t.templateExpressions!==!1?at(e,de(e),{filePath:t.filePath,componentsDir:t.componentsDir,projectRoot:t.projectRoot,readComponent:t.readComponent,scriptCode:(S,v)=>ue(S).map((_)=>Ce(_.code,ze.default.dirname(v))).join(`
89
- `)}):void 0,y=new Set,x=[];for(let[S,v]of s.entries()){let _=bn(jn(v)+v.code,h,String(S));for(let[D,A]of _.columns)u.set(v.startLine+D-1,A);for(let D of _.declarations)m.push({text:Ce(D.text,t.originDir??""),origin:D.origin?{...D.origin,line:D.origin.line+v.startLine-1}:void 0});let O=v.kind==="client"&&r?r.project(_.code):void 0;for(let[D,A]of O?.columns??[])a.set(v.startLine+D-1,A);let T=we(O?.code??_.code),I=kt(T,t.originDir??"");for(let[D,A]of I.columns)p.set(v.startLine+D-1,A);let j=I.code.split(`
90
- `);j.forEach((D,A)=>{let K=v.startLine-1+A;if(K<c.length)c[K]=D,y.add(K)}),x.push(v.startLine-1+j.length-1)}for(let S of x){let v=c[S]?.trim()===""?S:S+1;if(v<c.length&&c[v].trim()===""&&(v===S||!y.has(v)))c[v]=";"}let C=(S,v)=>{for(let[_,O]of S.split(`
91
- `).entries())if(c.push(O),v)l.set(c.length,_===0?v:{...v,line:v.line+_,column:1,prefixLength:0})},k=dt(s.filter((S)=>S.kind==="server").map((S)=>S.code).join(`
92
- `));if(k)C(k);if(i?.declarations)C(i.declarations);for(let S of m)C(S.text,S.origin);if(r){if(C(r.declarations),t.nativeChecks!==!1)for(let S of r.checks)C(S.text,{line:S.line,column:S.column,diagnosticOrigin:S.origin})}if(t.globals!==!1){C("");let S=new Set([...s.flatMap((T)=>re(T.code)),...s.flatMap((T)=>Ln(T.code))]),v=(T)=>{if(!S.has(T)&&!t.declaredGlobals?.includes(T))C(`declare var ${T}: any`)};if(t.runtimeGlobals!==!1){if(!S.has("window"))C("declare var window: any");for(let T of ce)v(T)}let _=[...new Set([...St,..._e,...vt])].filter((T)=>!t.declaredGlobals?.includes(T)&&(t.runtimeGlobals!==!1||!ce.includes(T)));if(t.contextScope==="global"){C("declare global {");for(let T of _)C(` var ${T}: any`);C("}")}else{for(let T of St)v(T);for(let T of _e)v(T);for(let T of vt)v(T)}C(`declare var ${Be}: any`);let O=new Set(s.flatMap((T)=>re(T.code)));C(`type ${xt}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let T of r?[]:Cn(e)){if(O.has(T.name))continue;let I=T.iterable&&O.has(T.iterable)?`${xt}<typeof ${T.iterable}>`:"any";C(`declare var ${T.name}: ${I}`)}}if(t.templateExpressions!==!1){if(b?.declarations)for(let v of b.declarations.split(`
93
- `))C(v);let S=vn(e).map((v)=>{let _=b?.events.get(v.offset??-1);if(_){v.anchor=!0;let O=v.code.trim(),T=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(O),I=T?`void ((${T[2]}) satisfies __StxAssignedValue<typeof ${T[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(O)?`${O} satisfies (($event: ${_}) => unknown)`:O,j=`;(($event: ${_}): void => { `;return{expression:v,statement:{text:`${j}${I} });`,prefixLength:j.length}}}return{expression:v,statement:On(v)}}).filter((v)=>v.statement!==null);if(S.push(...b?.checks||[],...i?.checks||[]),S.length>0){let v=de(e),_=gt(v),O=r?mt(v):[];if(r)C("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 T=Rn(s.map((A)=>A.code)),j=[...new Set(s.flatMap((A)=>re(A.code)))].filter((A)=>/^[A-Z_$][\w$]*$/i.test(A)),D=0;if(r)C("function __stxNativeTemplate(this: __StxNativeComponent) {");if(j.length>0){C(hn);for(let A of j)C(`function __StxRead_${A}() { return ${A} }`),C(`type __StxT_${A} = ${Ct}<ReturnType<typeof __StxRead_${A}>>`);C(`;((${j.map((A)=>`${A}: __StxT_${A}`).join(", ")}) => {`),D=1}for(let{expression:A,statement:K}of S){let W=" ".repeat(D),Y=A.offset===void 0?[]:_.filter((V)=>A.offset>=V.start&&A.offset<V.end),Z=A.offset===void 0?[]:O.filter((V)=>A.offset>=V.start&&A.offset<V.end),J=Z.map((V)=>`;__stxEach(${V.iterable}, (${V.binding}) => { `).join(""),oe=" });".repeat(Z.length),L=J+Y.map((V)=>`;((${V.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),H=" });".repeat(Y.length)+oe,q=A.offset===void 0?[]:Pn(v,A.offset),X=q.length>0?`${q.map((V)=>`if (${_t(V,T)}) `).join("")}{ `:"",ae=q.length>0?" }":"";C(W+L+X+K.text+ae+H,{line:A.line,column:A.column,expression:A,prefixLength:K.prefixLength+W.length+L.length+X.length,guardPrefixLength:W.length+L.length+X.length})}if(D>0)C("});");if(r)C("}")}}let R=!1;if(t.reference&&c[0]!==void 0&&c[0].trim()==="")c[0]=`/// <reference path=${JSON.stringify(t.reference.replace(/\\/g,"/"))} />`,R=!0;return C("export {}"),{text:c.join(`
94
- `),lineMap:l,sourceLineCount:o.length,componentDependencies:new Map([...b?.dependencies??[],...i?.dependencies??[]]),referenced:R,scriptColumns:u,importColumns:p,componentColumns:a}}function he(e){let t=[0];for(let n=0;n<e.length;n++)if(e.charCodeAt(n)===10)t.push(n+1);return t}function ie(e,t){let n=0,s=e.length-1;while(n<s){let r=Math.ceil((n+s)/2);if(e[r]<=t)n=r;else s=r-1}return{line:n+1,column:t-e[n]+1}}function Te(e,t,n){let s=Math.min(Math.max(t,1),e.length)-1,r=s+1<e.length?e[s+1]-1:Number.MAX_SAFE_INTEGER;return Math.min(e[s]+Math.max(n,1)-1,r)}function Pt(e,t){if(!e.expression)return!1;return e.inGuard===!0||t===2774}function Ot(e,t,n){let s=e.lineMap.get(t);if(!s)return t<=e.sourceLineCount?{line:t,column:Dn(e,t,n)}:null;let r=s.expression?.anchor?0:Math.max(0,n-1-(s.prefixLength??0));return{line:s.line,column:s.column+r,expression:s.expression,diagnosticOrigin:s.diagnosticOrigin,inGuard:n<=(s.guardPrefixLength??0)}}var Mt=["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 In=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),jt=Mt.filter((e)=>!In.has(e)).sort(),Lt=[...ce].sort(),Nn=[...new Set([...jt,...Lt])].sort(),Bn=new Set(jt),zn=new Set(Lt),Vn=new Set(Nn),Dt=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Fn(e,t){if(t==="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 It(e,t){let n=[];for(let s of t){if(s.offset===void 0)continue;let r=s.kind==="server"?Bn:zn;Dt.lastIndex=0;for(let i of s.code.matchAll(Dt)){let a=i.index+i[0].indexOf("{")+1;for(let o of i[1].matchAll(/[^,]+/g)){let c=o[0];if(/^\s*type\s/.test(c))continue;let l=/^\s*([A-Za-z_$][\w$]*)/.exec(c);if(!l)continue;let u=l[1];if(!Vn.has(u)||r.has(u))continue;let p=s.offset+a+o.index+l[0].length-u.length,m=e.slice(0,p),h=m.split(`
95
- `).length;n.push({line:h,column:p-(m.lastIndexOf(`
96
- `)+1)+1,offset:p,length:u.length,name:u,kind:s.kind,message:Fn(u,s.kind)})}}}return n}var te=Q(require("node:path"),1),Kn="@stacksjs/stx-typescript-plugin";function Wn(e,t){let n=te.default.resolve(e);for(;;){let s=te.default.join(n,"tsconfig.json");if(t(s))return s;let r=te.default.dirname(n);if(r===n)return;n=r}}function Nt(e,t,n){let s=Wn(e,n);if(!s)return;let r=new Set,i=(a)=>{if(r.has(a))return;r.add(a);let o=t(a);if(!o)return;let c=o.compilerOptions?.plugins;if(Array.isArray(c)){let u=c.find((m)=>m?.name===Kn),p=Array.isArray(u?.libs)?u.libs.filter((m)=>typeof m==="string"):[];return u?{configPath:a,libs:p.map((m)=>te.default.resolve(te.default.dirname(a),m))}:null}let l=typeof o.extends==="string"?[o.extends]:Array.isArray(o.extends)?o.extends:[];for(let u of[...l].reverse()){if(typeof u!=="string"||!u.startsWith("."))continue;let p=te.default.resolve(te.default.dirname(a),u.endsWith(".json")?u:`${u}.json`),m=i(p);if(m!==void 0)return m}return};return i(s)??void 0}var Bt=Symbol.for("@stacksjs/stx-typescript-plugin"),Hn=new Set([2300,2451,2403]);function xe(e){return e.endsWith(".stx")}function zt(e){return xe(e)||e.endsWith(".md")}function Gn(e){if(!e)return;return U.existsSync(F.default.join(e,"stx-module.d.ts"))&&U.existsSync(F.default.join(e,"stx.d.ts"))?F.default.join(e,"stx-module.d.ts"):void 0}function Zn(e,t=U.existsSync){let n=e;for(;;){let s=F.default.join(n,"node_modules","@stacksjs","stx","stx-module.d.ts");if(t(s))return s;let r=F.default.dirname(n);if(r===n)return;n=r}}function Jn(e,t=F.default.join(Ft.tmpdir(),"stx-typescript-plugin")){let n=e.map((r)=>`/// <reference path=${JSON.stringify(r.replace(/\\/g,"/"))} />`).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(`
93
+ `).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(`
97
99
  `)+`
98
- `,s=F.default.join(t,`${Vt.createHash("sha1").update(n).digest("hex").slice(0,16)}.d.ts`);if(!U.existsSync(s))U.mkdirSync(t,{recursive:!0}),U.writeFileSync(s,n);return s}function Un(e){let t=new Set,n=new Set;function s(r){if(n.has(r)||!U.existsSync(r))return;n.add(r);let i=U.readFileSync(r,"utf8");for(let a of Et(i))t.add(a);for(let a of i.matchAll(/<reference\s+path=["']([^"']+)["']/g))s(F.default.resolve(F.default.dirname(r),a[1]))}if(e)s(e);return[...t]}function qn(e,t,n,s){let r=(o)=>Rt(t,{templateExpressions:xe(e),componentMethodValidator:(c,l,u)=>{let p=s.typescript.transpileModule(c+(l==="{"?"{}":";"),{reportDiagnostics:!0,compilerOptions:{target:s.typescript.ScriptTarget.ESNext}});if(p.diagnostics?.some((m)=>m.category===s.typescript.DiagnosticCategory.Error))return!1;return l==="{"?p.outputText.includes(`function ${u}(`):!p.outputText.trim()},originDir:F.default.dirname(e),filePath:e,readComponent:s.readComponent,componentsDir:s.componentsDir,projectRoot:s.projectRoot,reference:o,declaredGlobals:Un(o),runtimeGlobals:!o,contextScope:"global"}),i=r(s.declarations);if(s.declarations&&!i.referenced)i=r(void 0);let a=ue(t);return{version:n,source:t,virtual:i,blocks:a,sourceStarts:he(t),virtualStarts:he(i.text),collisions:new Set(Tt(a))}}function Xn(e,t){let n=e.findConfigFile(t,e.sys.fileExists);if(!n)return;let s=e.readConfigFile(n,e.sys.readFile);if(s.error)return;let r=e.parseJsonConfigFileContent(s.config,e.sys,F.default.dirname(n),void 0,n),i={};if(r.options.types)i.types=r.options.types;let a=r.options.paths;if(a){let o=r.options.baseUrl??r.options.pathsBasePath??F.default.dirname(n);i.paths={};for(let[c,l]of Object.entries(a))i.paths[c]=l.map((u)=>F.default.isAbsolute(u)?u:F.default.resolve(o,u))}return i}function Yn(e,t={}){let n=e.typescript,s={},r=new Set,i=new WeakSet;return{create(a){let o=(d)=>{a.project.projectService.logger.info(`[stx-plugin] ${d}`)};if(a.languageService[Bt])return i.add(a.project),o("already applied to this project by another registration of the plugin; leaving it as it is"),a.languageService;o("TypeScript stx plugin initialized");let{languageService:c,languageServiceHost:l}=a,u=(d)=>{let g=c[d];return typeof g==="function"?g.bind(c):()=>{return}},p=l.getScriptSnapshot?.bind(l),m=l.getScriptVersion?.bind(l),h=Gn(t.declarationsDir);if(!h)o("the bundled stx declarations were not found; apps without their own fall back to `any`");let b=(d)=>n.sys?.fileExists(d)??U.existsSync(d),y=(d)=>{let g=n.readConfigFile?.(d,(f)=>n.sys.readFile(f));return g&&!g.error?g.config:void 0},x=new Map,C=(d)=>{let g=F.default.dirname(d);if(!x.has(g)){let f=Zn(g,b)??h,E=[];try{E=(Nt(g,y,b)?.libs??[]).filter(b)}catch(w){o(`could not read the stx entry of the project's tsconfig: ${String(w)}`)}x.set(g,f&&E.length>0?Jn([f,...E]):f)}return x.get(g)},k=new Map,R=(d)=>{let g=p?.(d);return g?g.getText(0,g.getLength()):n.sys?.readFile(d)},S=()=>s.enabled!==!1;r.add(()=>{k.clear(),a.project.refreshDiagnostics?.()});let v=(d)=>{if(!zt(d)||!p)return;let g=`${m?.(d)||"0"}:${l.getProjectVersion?.()||""}`,f=k.get(d);if(f&&f.version===g&&[...f.virtual.componentDependencies||[]].every(([w,P])=>R(w)===P))return f;let E=p(d);if(!E)return;try{let w=a.project.getCurrentDirectory?.(),P=w?F.default.resolve(w,typeof a.config?.componentsDir==="string"?a.config.componentsDir:"components"):void 0,B=qn(d,E.getText(0,E.getLength()),g,{typescript:n,declarations:C(d),readComponent:R,componentsDir:P,projectRoot:w});return k.set(d,B),B}catch(w){o(`failed to build virtual document for ${d}: ${String(w)}`);return}},_=(d)=>xe(d)?v(d):void 0,O=(d,g)=>{let f=ie(d.virtualStarts,g);return Ot(d.virtual,f.line,f.column)},T=(d,g)=>{let f=O(d,g);if(!f)return;return Te(d.sourceStarts,f.line,f.column)},I=(d,g)=>{let f=ie(d.sourceStarts,g);return Te(d.virtualStarts,f.line,At(d.virtual,f.line,f.column))},j=(d,g)=>{let f=T(d,g.start);if(f===void 0)return;let E=T(d,g.start+g.length);return{start:f,length:E!==void 0&&E>=f?E-f:g.length}},D=(d,g)=>d.blocks.some((f)=>f.offset!==void 0&&g>=f.offset&&g<=f.offset+f.code.length),A=(d)=>{let g=_(d.fileName);if(!g)return d;let f=j(g,d.textSpan);if(!f)return;let E=d.contextSpan?j(g,d.contextSpan):void 0;return{...d,textSpan:f,contextSpan:E}},K=(d)=>d?.map(A).filter((g)=>g!==void 0),W=(d)=>d?.filter((g)=>{let f=_(g.fileName);if(!f)return!0;let{line:E}=ie(f.virtualStarts,g.textSpan.start);return E<=f.virtual.sourceLineCount&&!f.virtual.lineMap.has(E)});if(p)l.getScriptSnapshot=(d)=>{let g=v(d);if(g)return n.ScriptSnapshot.fromString(g.virtual.text);return p(d)};let Y=l.getCompilationSettings?.bind(l),Z=n.server?.ProjectKind!==void 0&&a.project.projectKind===n.server.ProjectKind.Inferred;if(Y&&Z){let d=null,g;l.getCompilationSettings=()=>{let f=Y();if(d===null)try{d=Xn(n,a.project.getCurrentDirectory())}catch(E){o(`could not read the project's tsconfig: ${String(E)}`),d=void 0}if(!d)return f;if(g?.from!==f)g={from:f,options:{...f,...d.paths&&!f.paths?{paths:d.paths}:{},...d.types&&!f.types?{types:d.types}:{}}};return g.options}}let J=(d,g)=>{let f=v(d);if(!f)return g;if(xe(d)&&!S())return[];let E=[];for(let w of g){let P=typeof w.messageText==="string"?w.messageText:w.messageText.messageText;if(Hn.has(w.code)){let ee=P.match(/'([^']+)'/)?.[1];if(ee&&f.collisions.has(ee))continue}if(w.start===void 0){E.push(w);continue}let B=O(f,w.start);if(!B||Pt(B,w.code))continue;let z=Te(f.sourceStarts,B.line,B.column),pe=T(f,w.start+(w.length??0));E.push({...w,start:z,length:pe!==void 0&&pe>z?pe-z:w.length??0})}return E},oe=u("getSemanticDiagnostics");c.getSemanticDiagnostics=(d)=>{let g=J(d,oe(d)),f=_(d);if(!f||!S())return g;let E=c.getProgram?.()?.getSourceFile(d);for(let w of It(f.source,f.blocks))g.push({file:E,start:w.offset,length:w.length,messageText:w.message,category:n.DiagnosticCategory?.Error??1,code:0,source:"stx"});return g};let L=u("getSyntacticDiagnostics");c.getSyntacticDiagnostics=(d)=>J(d,L(d));let H=u("getSuggestionDiagnostics");c.getSuggestionDiagnostics=(d)=>J(d,H(d));let q=u("getQuickInfoAtPosition");c.getQuickInfoAtPosition=(d,g,...f)=>{let E=_(d);if(!E)return q(d,g,...f);if(!S())return;let w=q(d,I(E,g),...f);if(!w)return w;let P=j(E,w.textSpan);return P?{...w,textSpan:P}:void 0};let X=u("getCompletionsAtPosition");c.getCompletionsAtPosition=(d,g,f,...E)=>{let w=_(d);if(!w)return X(d,g,f,...E);if(!S()||!D(w,g))return;let P=X(d,I(w,g),{...f,includeCompletionsForModuleExports:!1},...E);if(!P)return P;let B=(z)=>z&&j(w,z);return{...P,optionalReplacementSpan:B(P.optionalReplacementSpan),entries:P.entries.filter((z)=>!z.name.startsWith("__stx")&&!z.name.startsWith("__Stx")).map((z)=>z.replacementSpan?{...z,replacementSpan:B(z.replacementSpan)}:z)}};let ae=u("getCompletionEntryDetails");c.getCompletionEntryDetails=(d,g,...f)=>{let E=_(d);if(!E)return ae(d,g,...f);let w=ae(d,I(E,g),...f);return w?{...w,codeActions:void 0}:w};let V=u("getSignatureHelpItems");c.getSignatureHelpItems=(d,g,...f)=>{let E=_(d);if(!E)return V(d,g,...f);if(!S()||!D(E,g))return;let w=V(d,I(E,g),...f),P=w&&j(E,w.applicableSpan);return w&&P?{...w,applicableSpan:P}:void 0};let Ve=u("getDefinitionAndBoundSpan");c.getDefinitionAndBoundSpan=(d,g)=>{let f=_(d);if(!f)return Fe(Ve(d,g));if(!S())return;let E=Ve(d,I(f,g)),w=E&&j(f,E.textSpan);return E&&w?{...Fe(E),textSpan:w}:void 0};let Fe=(d)=>d&&{...d,definitions:W(d.definitions)};for(let d of["getDefinitionAtPosition","getTypeDefinitionAtPosition","getImplementationAtPosition"]){let g=u(d);c[d]=(f,E,...w)=>{let P=_(f);if(P&&!S())return;return W(g(f,P?I(P,E):E,...w))}}for(let d of["getReferencesAtPosition"]){let g=u(d);c[d]=(f,E,...w)=>{let P=_(f);if(P&&!S())return;return K(g(f,P?I(P,E):E,...w))}}let Wt=u("findReferences");c.findReferences=(d,g)=>{let f=_(d);if(f&&!S())return;return Wt(d,f?I(f,g):g)?.map((E)=>{let w=A(E.definition);return w?{definition:w,references:K(E.references)}:void 0}).filter((E)=>E!==void 0)};let Ht=u("getDocumentHighlights");c.getDocumentHighlights=(d,g,f)=>{let E=_(d);if(E&&(!S()||!D(E,g)))return;return Ht(d,E?I(E,g):g,f)?.map((w)=>{let P=_(w.fileName);if(!P)return w;return{...w,highlightSpans:w.highlightSpans.map((B)=>{let z=j(P,B.textSpan);return z?{...B,textSpan:z,contextSpan:B.contextSpan&&j(P,B.contextSpan)}:void 0}).filter((B)=>B!==void 0)}})};let Gt=u("getNavigationTree");c.getNavigationTree=(d)=>{let g=Gt(d),f=_(d);if(!f)return g;let E=(P)=>{let B=P.spans.map((ee)=>j(f,ee)).filter((ee)=>ee!==void 0);if(B.length===0)return;let z=P.nameSpan&&j(f,P.nameSpan),pe=P.childItems?.map(E).filter((ee)=>ee!==void 0);return{...P,spans:B,nameSpan:z,childItems:pe}},w={...g,spans:[{start:0,length:f.source.length}]};return S()?{...w,childItems:g.childItems?.map(E).filter((P)=>P!==void 0)}:{...w,childItems:[]}};let Zt={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[d,g]of Object.entries(Zt)){let f=c[d];if(typeof f!=="function")continue;let E=f.bind(c);c[d]=(w,...P)=>typeof w==="string"&&xe(w)?g():E(w,...P)}return c[Bt]=!0,o("Language service proxy created"),c},getExternalFiles(a){if(i.has(a))return[];return a.getFileNames().filter(zt)},onConfigurationChanged(a){s={...s,...a};for(let o of r)o()}}}var Kt=Yn;module.exports=Kt;
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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx-vscode",
3
3
  "type": "module",
4
- "version": "0.2.876",
4
+ "version": "0.2.881",
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",