@stacksjs/stx 0.2.647 → 0.2.648
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-ma7d95f0.js → chunk-06w0z1cm.js} +5 -5
- package/dist/chunk-0en5jwjy.js +2 -0
- package/dist/{chunk-3ghbxena.js → chunk-0h8tg21j.js} +1 -1
- package/dist/{chunk-x8k64g1e.js → chunk-0jhdrgpr.js} +2 -2
- package/dist/{chunk-xnjf1zbn.js → chunk-0vkawews.js} +2 -2
- package/dist/{chunk-5t4qtxgr.js → chunk-2h8ea0we.js} +2 -2
- package/dist/{chunk-jsb4pvj1.js → chunk-2jh21f1n.js} +1 -1
- package/dist/chunk-2n3pa5gm.js +2 -0
- package/dist/chunk-3b5bphcn.js +2 -0
- package/dist/{chunk-h5zr710w.js → chunk-3p7mk3mw.js} +1 -1
- package/dist/{chunk-yfrvbnc6.js → chunk-3q163st5.js} +10 -10
- package/dist/{chunk-nph4d1ff.js → chunk-3zyjqvsq.js} +2 -2
- package/dist/{chunk-aah6csjm.js → chunk-481d4kr9.js} +1 -1
- package/dist/{chunk-0m08316b.js → chunk-4q2dtxdk.js} +1 -1
- package/dist/{chunk-bk96wjaz.js → chunk-55zaxb4s.js} +8 -8
- package/dist/chunk-57md41g9.js +2 -0
- package/dist/{chunk-42rghbqe.js → chunk-67xhsacd.js} +1 -1
- package/dist/{chunk-b0vhe6d4.js → chunk-6ea6az61.js} +1 -1
- package/dist/chunk-6vh8s0pg.js +2 -0
- package/dist/{chunk-myq3hrww.js → chunk-88z4wkrj.js} +2 -2
- package/dist/{chunk-e7sg0fa0.js → chunk-89yj6tcd.js} +1 -1
- package/dist/{chunk-y3vget29.js → chunk-8d2f2e42.js} +1 -1
- package/dist/chunk-8fsq2ynj.js +2 -0
- package/dist/{chunk-c7fs96n6.js → chunk-8p9kpfk8.js} +1 -1
- package/dist/chunk-8tpmz4as.js +2 -0
- package/dist/{chunk-hgy4c6mm.js → chunk-9121nkpj.js} +1 -1
- package/dist/{chunk-zevx9866.js → chunk-9txn4rvb.js} +1 -1
- package/dist/chunk-9x0zt65f.js +2 -0
- package/dist/chunk-a2bw46t9.js +2 -0
- package/dist/chunk-a4sggwcz.js +2 -0
- package/dist/{chunk-7s32fe6k.js → chunk-ab7zqtax.js} +1 -1
- package/dist/chunk-b0hpshvk.js +2 -0
- package/dist/chunk-c1479y92.js +2 -0
- package/dist/{chunk-gc9ftf7r.js → chunk-c1dkh0es.js} +3 -3
- package/dist/{chunk-pw9bhdaz.js → chunk-e87xa4r3.js} +1 -1
- package/dist/chunk-embejqx4.js +2 -0
- package/dist/chunk-er60h3j3.js +2 -0
- package/dist/chunk-eyfxw7ds.js +2 -0
- package/dist/chunk-f3y4fnaa.js +2 -0
- package/dist/{chunk-wzgn9fv7.js → chunk-f46ht5kq.js} +3 -3
- package/dist/chunk-f7930sce.js +2 -0
- package/dist/{chunk-emaexvgz.js → chunk-fsbjat59.js} +1 -1
- package/dist/{chunk-vgt9f7ac.js → chunk-gv793yqq.js} +2 -2
- package/dist/chunk-gz90fqn8.js +2 -0
- package/dist/chunk-h15xb2vd.js +2 -0
- package/dist/{chunk-31714f76.js → chunk-h5nmf98w.js} +1 -1
- package/dist/{chunk-da7x7y7j.js → chunk-hfpv56cp.js} +1 -1
- package/dist/chunk-hhmj9gpk.js +2 -0
- package/dist/{chunk-5yg3tkth.js → chunk-hjm69qnj.js} +1 -1
- package/dist/{chunk-shkysa02.js → chunk-j393gsfd.js} +2 -2
- package/dist/{chunk-p22w6mwr.js → chunk-j5gd0e53.js} +1 -1
- package/dist/{chunk-msr25dhc.js → chunk-jkaszw24.js} +2 -2
- package/dist/{chunk-rwrbdpdk.js → chunk-m6qfqkbh.js} +1 -1
- package/dist/{chunk-ztbzktzg.js → chunk-mnp8ecj9.js} +1 -1
- package/dist/chunk-ncqh5qe5.js +2 -0
- package/dist/{chunk-rb5xdcen.js → chunk-nj1t4g3a.js} +3 -3
- package/dist/{chunk-p08x0z86.js → chunk-np4zm2ph.js} +1 -1
- package/dist/{chunk-0z5cc7qn.js → chunk-nt0n0vjm.js} +2 -2
- package/dist/{chunk-0jq3w712.js → chunk-p44kmbdg.js} +3 -3
- package/dist/{chunk-dpjnjs09.js → chunk-pbtkbe48.js} +23 -23
- package/dist/{chunk-jx3wpgv0.js → chunk-pg0xzsss.js} +2 -2
- package/dist/{chunk-xyjn0rvj.js → chunk-pxs7sgnp.js} +1 -1
- package/dist/{chunk-74pej67a.js → chunk-qfe7ps3v.js} +7 -7
- package/dist/{chunk-b07djygp.js → chunk-qm4672dj.js} +3 -3
- package/dist/chunk-r1r6311d.js +14 -0
- package/dist/{chunk-55x799st.js → chunk-radggg3p.js} +5 -5
- package/dist/{chunk-ar22s1e1.js → chunk-sgptbhrc.js} +1 -1
- package/dist/{chunk-fygp3cs9.js → chunk-sszhz1zh.js} +1 -1
- package/dist/{chunk-mmm6mm16.js → chunk-szyqxcfj.js} +2 -2
- package/dist/{chunk-cj2xj1v6.js → chunk-t1k9160w.js} +4 -4
- package/dist/{chunk-tkkvvt26.js → chunk-t82be9yf.js} +1 -1
- package/dist/{chunk-9y2ncrnq.js → chunk-v2x9vzgw.js} +2 -2
- package/dist/{chunk-w2q32x72.js → chunk-w2zceynt.js} +1 -1
- package/dist/{chunk-pfk9ffbz.js → chunk-wjt0kej9.js} +1 -1
- package/dist/{chunk-9am6dsb1.js → chunk-wpm58d6p.js} +2 -2
- package/dist/{chunk-9z9jtwct.js → chunk-wq6j2h32.js} +1 -1
- package/dist/{chunk-20f1veqy.js → chunk-x34scshq.js} +2 -2
- package/dist/{chunk-pdc9s7bg.js → chunk-x5tjb4y4.js} +1 -1
- package/dist/chunk-xfzcv0jc.js +2 -0
- package/dist/{chunk-ajv5xmjx.js → chunk-xm2mee4a.js} +14 -14
- package/dist/{chunk-ggwm8w5m.js → chunk-xvs04cnp.js} +1 -1
- package/dist/{chunk-3e7haxwt.js → chunk-ye8tgmd3.js} +1 -1
- package/dist/{chunk-asqnaddf.js → chunk-ymymwzt5.js} +1 -1
- package/dist/{chunk-a8j91pqz.js → chunk-yq021b3r.js} +3 -3
- package/dist/{chunk-jyth1zjy.js → chunk-zdnc7a4t.js} +3 -3
- package/dist/{chunk-5gtpswnm.js → chunk-zmh9p9aa.js} +1 -1
- package/dist/{chunk-w1v1d7rq.js → chunk-zsgcsqat.js} +94 -94
- package/dist/chunk-zyqs6a3p.js +2 -0
- package/dist/cli.js +12 -12
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/interpolation-context.js +111 -8
- package/dist/pwa.js +3 -3
- package/dist/runtime-injection.js +9 -3
- package/dist/ssg.js +3 -3
- package/package.json +5 -5
- package/dist/chunk-0ky1j84b.js +0 -2
- package/dist/chunk-1c5p7ede.js +0 -2
- package/dist/chunk-1q6yvbdx.js +0 -2
- package/dist/chunk-1x4qn6fy.js +0 -2
- package/dist/chunk-2c3w367n.js +0 -2
- package/dist/chunk-2cxav9xe.js +0 -2
- package/dist/chunk-2v4s7xtx.js +0 -2
- package/dist/chunk-40y6mb8t.js +0 -2
- package/dist/chunk-4fz2eq7g.js +0 -2
- package/dist/chunk-5e20mvke.js +0 -2
- package/dist/chunk-5fzh8n52.js +0 -2
- package/dist/chunk-70pmthc3.js +0 -2
- package/dist/chunk-8ttg2d3m.js +0 -2
- package/dist/chunk-9qeg5trh.js +0 -2
- package/dist/chunk-apgb7r22.js +0 -2
- package/dist/chunk-aze7k3a5.js +0 -2
- package/dist/chunk-cs0dd5w8.js +0 -2
- package/dist/chunk-cwd65649.js +0 -2
- package/dist/chunk-edz1h5f9.js +0 -2
- package/dist/chunk-ek2adv0n.js +0 -2
- package/dist/chunk-n4cvg2sw.js +0 -2
- package/dist/chunk-qn63btbf.js +0 -2
- package/dist/chunk-vac56rgd.js +0 -12
- package/dist/chunk-vn3yx05b.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{lc,uc}from"./chunk-7rta163c.js";import{j,ss,os,is,So,ko,sr,Re,ce,q,cs,le,Tt,ue,Ze,ir,To,lr,De,n,m,F,fn}from"./chunk-w1v1d7rq.js";import{d,C,et,u}from"./chunk-bk96wjaz.js";import{ee}from"./chunk-asqnaddf.js";import{o}from"./chunk-egg54kd0.js";import{p}from"./chunk-2a4szpje.js";import{createHash as St}from"crypto";import Y from"fs";import J from"path";import{decode as sn,generateThumbHash as on}from"ts-images";import{createImageDeliveryCatalog as ht}from"ts-images/delivery";import Be from"fs";function Se(e,t,r){let s=Buffer.alloc(r),i=Be.readSync(e,s,0,r,t);return s.subarray(0,i)}function Te(e){if(e.length<25)return!1;let t=(s,i)=>String.fromCharCode(...e.subarray(s,i));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let r=t(12,16);if(r==="VP8X")return(e[20]&16)!==0;if(r==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function je(e){let t;try{t=Be.openSync(e,"r");let r=Se(t,0,33);if(r.length>=3&&r[0]===255&&r[1]===216&&r[2]===255)return"none";if(r.length>=26&&r[0]===137&&r.toString("latin1",1,4)==="PNG"){let s=r[25];if(s===4||s===6)return"possible";let i=8;for(let a=0;a<64;a++){let c=Se(t,i,8);if(c.length<8)return"unknown";let f=c.toString("latin1",4,8);if(f==="tRNS")return"possible";if(f==="IDAT"||f==="IEND")return"none";i+=12+c.readUInt32BE(0)}return"unknown"}if(r.length>=25&&r.toString("latin1",0,4)==="RIFF"&&r.toString("latin1",8,12)==="WEBP"){if(Te(r))return"possible";let s=r.toString("latin1",12,16);return s==="VP8 "||s==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)Be.closeSync(t)}}import Jt from"fs";import Ce from"os";import{join as ft}from"path";import{fileURLToPath as dt}from"url";import{Worker as gt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Yt(e=typeof Ce.availableParallelism==="function"?Ce.availableParallelism():Ce.cpus().length){return Math.max(1,Math.min(2,e-1))}var Ae=0,pt=[];async function Qt(){if(Ae<Yt()){Ae++;return}await new Promise((e)=>pt.push(e)),Ae++}function en(){Ae--,pt.shift()?.()}var tn="@stacksjs/stx/builtins/image-warmup-worker";function nn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let r=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(r.protocol==="file:"&&Jt.existsSync(dt(r)))return dt(r)}catch{}try{let r=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return r&&rn(r)?r:void 0}catch{return}}function rn(e,t=process.env){let r=e.replace(/\\/g,"/");if(r.split("/").some((i)=>/@\d[^/]*@@@\d+$/.test(i)))return!1;return![t.BUN_INSTALL_CACHE_DIR,ft(t.BUN_INSTALL||ft(Ce.homedir(),".bun"),"install","cache")].filter((i)=>!!i).map((i)=>`${i.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((i)=>r.startsWith(i))}var mt=!1;function me(e){if(!mt)mt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function Me(e){return e instanceof Error?e.message:String(e)}async function Le(e,t){if(typeof gt!=="function")return me("node:worker_threads has no Worker in this runtime");let r=nn();if(!r)return me("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((s,i)=>{let a;try{a=new gt(r)}catch(h){s(me(`could not start ${r}: ${Me(h)}`));return}let c=!1,f=!1,l=(h)=>{if(f)return;f=!0,h(),a.terminate()};a.on("message",(h)=>{if(h.type==="ready"){c=!0,a.postMessage({task:e,args:t});return}if(h.type==="result"){l(()=>s(h.value));return}let v=Error(h.error?.message??"image worker failed");if(h.error?.name)v.name=h.error.name;if(h.error?.stack)v.stack=h.error.stack;l(()=>i(v))}),a.on("error",(h)=>{l(()=>c?i(h instanceof Error?h:Error(Me(h)||"image worker crashed")):s(me(`the worker failed before it was ready: ${Me(h)}`)))}),a.on("exit",(h)=>{l(()=>c?i(Error("image worker exited before it finished")):s(me(`the worker exited with code ${h} before it was ready`)))})})}finally{en()}}var an=new Set([".avif",".jpeg",".jpg",".png",".webp"]),cn=[320,640,960,1280,1920],pe="/_stx/images",ln=`stx:${pe}:alpha-1`,un=`stx:${pe}:opaque-1`,dn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function gn(e,t){let r=J.dirname(Bun.resolveSync(e,t));while(r!==J.dirname(r)){let s=J.join(r,"package.json");if(Y.existsSync(s)){let i=JSON.parse(Y.readFileSync(s,"utf8"));if(i.name===e)return i.version}r=J.dirname(r)}return}function yt(){if(Pe!==void 0)return Pe;let e;try{e=J.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=dn.map((t)=>{let r;try{r=e?gn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${r??"unknown"}`}).join("+"),Pe}var xt=Symbol.for("stx.image-delivery");function he(){let e=globalThis;return e[xt]??={catalog:new Map,transparent:new Set},e[xt]}var bt=new Set;function mn(e){return`/${e.split(J.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=J.extname(e),r=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),s=St("sha256").update(e).digest("hex").slice(0,8);return`${r||"image"}-${s}`}function vt(e,t=`stx:${pe}`){let r=(s)=>`${pe}/${s.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(s){let i=J.join(e,s);try{let a=await Y.promises.stat(i);return a.size>0?{bytes:a.size,path:i,url:r(s)}:null}catch{return null}},async write(s,i){let a=J.join(e,s);await Y.promises.mkdir(J.dirname(a),{recursive:!0});let c=`${a}.${process.pid}.tmp`;return await Y.promises.writeFile(c,i),await Y.promises.rename(c,a),{bytes:i.byteLength,path:a,url:r(s)}},url:r}}async function Ct(e,t=e){let r=await Y.promises.readdir(t,{withFileTypes:!0});r.sort((i,a)=>i.name.localeCompare(a.name));let s=[];for(let i of r){let a=J.join(t,i.name);if(i.isDirectory()){s.push(...await Ct(e,a));continue}if(!i.isFile()||!an.has(J.extname(i.name).toLowerCase()))continue;s.push({absolutePath:a,relativePath:J.relative(e,a)})}return s}function wt(e,t){return e.map((r)=>({key:mn(r.relativePath),input:r.absolutePath,name:pn(r.relativePath),...hn(r.absolutePath)?{options:{storage:t}}:{}}))}function hn(e){return je(e)==="possible"}function yn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function xn(e){let t=Object.entries(e).filter(([,i])=>i.fallback.format==="png"),r=new Set,s=8;for(let i=0;i<t.length;i+=8)await Promise.all(t.slice(i,i+8).map(async([a,c])=>{let f=c.variants.filter((l)=>l.format==="png").sort((l,h)=>l.width-h.width)[0];try{let l=await sn(new Uint8Array(await Y.promises.readFile(f?.path??c.fallback.path)));if(yn(l.data))r.add(a)}catch{r.add(a)}}));return r}function bn(e,t){let r=[];for(let s of t){let i=e[s],a=i?.variants.filter((f)=>f.format==="webp")??[];if(!i||a.length===0)continue;if(!a.some((f)=>{let l;try{return l=Y.openSync(f.path,"r"),!Te(Se(l,0,32))}catch{return!0}finally{if(l!==void 0)Y.closeSync(l)}}))continue;if(i.variants=i.variants.filter((f)=>f.format!=="webp"),delete i.sources.webp,r.push(s),!bt.has(s))bt.add(s),console.warn(`[stx-images] ${s} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return r}async function vn(e){let t=[],r=8;for(let s=0;s<e.length;s+=8){let i=e.slice(s,s+8),a=await Promise.all(i.map(async(c)=>{try{return await on(c.absolutePath),c}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${c.relativePath}`),null}}));t.push(...a.filter((c)=>c!==null))}return t}function ze(e){return J.join(e,"undecodable.json")}function wn(e){try{let t=Y.readFileSync(ze(e),"utf-8"),r=JSON.parse(t);return r&&typeof r==="object"?r:{}}catch{return{}}}function $n(e,t){try{Y.mkdirSync(J.dirname(ze(e)),{recursive:!0}),Y.writeFileSync(ze(e),JSON.stringify(t))}catch{}}function $t(e){try{let t=Y.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function Rt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Qs(e){let t=Rt(e);return t?he().catalog.get(t):void 0}function eo(e){let t=Rt(e);return t?he().transparent.has(t):!1}function to(e){let t=(s)=>e.variants.filter((i)=>i.format===s).reduce((i,a)=>i+a.bytes,0),r=t(e.fallback.format);return["avif","webp"].map((s)=>({format:s,srcset:e.sources[s]||"",bytes:t(s)})).filter((s)=>s.srcset&&s.bytes>0&&s.bytes<r).sort((s,i)=>s.bytes-i.bytes).map(({format:s,srcset:i})=>({format:s,srcset:i}))}function dp(e){let t=Qs(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:to(t).map(({format:r,srcset:s})=>({type:`image/${r}`,srcset:s})),width:t.source.width,height:t.source.height,placeholder:eo(e)?void 0:t.placeholder?.dataUrl}}function jr(){let e=he();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=he();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function pp(e,t,r={}){if(!e||!Y.existsSync(e))return jr(),{count:0,fingerprint:""};if(r.offThread){let g=await Le("delivery",{publicDir:e,outputDir:t});if(g!==ke)return Sn(g.state),g.result}let s=await Ct(e);if(s.length===0)return jr(),{count:0,fingerprint:""};let i=wn(t),a=s.filter((g)=>{let b=i[g.relativePath];if(!b)return!0;let w=$t(g.absolutePath);return!w||w.mtimeMs!==b.mtimeMs||w.size!==b.size});if(a.length===0)return jr(),{count:0,fingerprint:""};let c=vt(J.join(t,"_stx","images"),`${ln}:${yt()}`),f={outDir:J.join(t,"_stx","images"),storage:vt(J.join(t,"_stx","images"),`${un}:${yt()}`),baseUrl:pe,widths:cn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},l=a,h;try{h=await ht({...f,entries:wt(a,c)})}catch(g){if(l=await vn(a),l.length===a.length)throw g;let b=new Set(l.map((R)=>R.relativePath)),w=!1;for(let R of a){if(b.has(R.relativePath))continue;let P=$t(R.absolutePath);if(!P)continue;i[R.relativePath]=P,w=!0}if(w)$n(t,i);if(l.length===0)return jr(),{count:0,fingerprint:""};h=await ht({...f,entries:wt(l,c)})}let v=await xn(h.entries),y=bn(h.entries,v),S=he();S.catalog=new Map(Object.entries(h.entries)),S.transparent=v;let x=v.size===0&&y.length===0?h.fingerprint:St("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:y.sort()})).digest("hex");return{count:l.length,fingerprint:x}}class At{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,r,s){let i=So(e,s);if(i!==void 0)return i;for(let a of ko(e,t,r,s))if(await n(a))return a;return null}}var oe=new At;function A(e){return F(e)}var ne="\x00stx-boolean-attribute";function Ue(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function We(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Cn.has(t)}function re(e,t){let r=[];for(let[s,i]of Object.entries(e.static)){if(t.has(s))continue;let a=e.staticNames?.[s]??s;if(typeof i==="boolean"){if(i)r.push(m(a));continue}if(i===ne){r.push(m(a));continue}r.push(`${m(a)}="${fn(a,Ue(String(i)))}"`)}return r}function se(e,t){let r=[];for(let[s,i]of Object.entries(e.serverDynamic??{})){if(t.has(s))continue;if(i===null||i===void 0||i===!1)continue;let a=e.serverDynamicNames?.[s]??s;if(i===!0){r.push(m(a));continue}if(typeof i==="object")continue;r.push(`${m(a)}="${fn(a,Ue(String(i)))}"`)}return r}function Rn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Fe={name:"StxLink",aliases:["stx-link"],render(e,t,r){let s=Rn(e),i=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),a=typeof e.static.activeClass==="string"?e.static.activeClass:"active",c=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",f=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,l=[];if(s.reactive)l.push(`:href="${A(s.value)}"`);else l.push(`href="${A(sr(s.value,"navigable"))}"`);if(i)l.push(`class="${A(i)}"`);if(l.push("data-stx-link"),l.push(`data-stx-active-class="${A(a)}"`),l.push(`data-stx-exact-active-class="${A(c)}"`),f)l.push("data-stx-prefetch");let h=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(h)l.push(`data-stx-active-match="${A(h)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return l.push(...re(e,v)),l.push(...se(e,v)),`<a ${l.join(" ")}>${t}</a>`}};var An=new Map;function He(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return An.get(t)}var kn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},qe=[320,640,768,1024,1280,1536,1920];function G(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let r=e.static[t];if(typeof r==="string")return r;return}function _e(e,t,r=!1){let s=e.serverDynamic[t];if(s!==void 0)return s!==!1&&s!=="false";let i=e.static[t];if(i!==void 0)return i!=="false"&&i!==!1;return r}function Xe(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),r=[];for(let s of t)if(s.includes(":")){let[i,a]=s.split(":"),c=kn[i];if(c)r.push(`(max-width: ${c}px) ${a}`);else{let f=Number.parseInt(i);if(!Number.isNaN(f))r.push(`(max-width: ${f}px) ${a}`)}}else r.push(s);return r.join(", ")}function Ve(e,t,r,s){return t.map((i)=>`${ye(e,i,void 0,r,s)} ${i}w`).join(", ")}function Pn(e,t,r,s,i){return t.map((a)=>{let c=r?r*a:void 0;return`${ye(e,c,void 0,s,i)} ${a}x`}).join(", ")}function ye(e,t,r,s,i){if(!s||s==="local"||s==="static")return e;if(s==="cloudinary"){let a=[];if(t)a.push(`w_${t}`);if(r)a.push(`h_${r}`);if(i)a.push(`f_${i}`);a.push("q_auto");let c=a.join(",");return e.replace("/upload/",`/upload/${c}/`)}if(s==="imgix"){let a=new URLSearchParams;if(t)a.set("w",String(t));if(r)a.set("h",String(r));if(i)a.set("fm",i);a.set("auto","format");let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}if(s==="bunny"){let a=new URLSearchParams;if(t)a.set("width",String(t));if(r)a.set("height",String(r));if(i)a.set("format",i);let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function In(e,t,r="#e5e7eb"){let s=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${r}"/></svg>`;return`data:image/svg+xml;base64,${btoa(s)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,r){let s=G(e,"src")||"",i=Qs(s),a=G(e,"alt")||"",c=G(e,"width")||(i?String(i.source.width):void 0),f=G(e,"height")||(i?String(i.source.height):void 0),l=G(e,"sizes"),h=G(e,"srcset"),v=G(e,"densities"),y=G(e,"format"),S=eo(s)||He(s)?.transparent===!0,x=G(e,"placeholder")||(i&&!S?"thumbhash":void 0),g=G(e,"placeholderColor")||"#e5e7eb",b=G(e,"provider"),w=G(e,"class")||G(e,"className")||"",R=G(e,"style")||"",P=G(e,"objectFit")||G(e,"fit"),k=G(e,"objectPosition")||G(e,"position"),E=G(e,"quality"),U=_e(e,"lazy",!0),M=_e(e,"preload",!1),L=_e(e,"priority",!1),X=G(e,"loading"),N=G(e,"decoding")||"async",I=!!i||_e(e,"picture",!1)||!!y,O=c?Number.parseInt(c):void 0,B=f?Number.parseInt(f):void 0,z=h||"",V="";if(i)z=i.sources[i.fallback.format]||"",V=l?Xe(l):"100vw";else if(!z&&l&&b&&b!=="local"&&b!=="static")z=Ve(s,qe,b,y),V=Xe(l);else if(!z&&v){let _=v.split(/\s+/).map((H)=>Number.parseFloat(H.replace("x","")));z=Pn(s,_,O,b,y)}else if(l)V=Xe(l);let D=[];if(R)D.push(R);if(P)D.push(`object-fit:${P}`);if(k)D.push(`object-position:${k}`);if(O&&B)D.push(`aspect-ratio:${O}/${B}`);let W=[],ie=x==="blur"||x==="color"||x==="thumbhash";if(ie&&!S){let _=i?.placeholder?{dataUrl:i.placeholder.dataUrl,color:g}:He(s);if(_&&x==="color")D.push(`background-color:${_.color}`),W.push("backgroundColor");else if(_)D.push(`background-color:${_.color}`),D.push(`background-image:url(${_.dataUrl})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundColor","backgroundImage");else{let H=In(O||16,B||9,g);D.push(`background-image:url(${H})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!ie&&x&&x!=="empty"&&x!=="none")D.push(`background-image:url(${A(x)})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage");let ve=i?.fallback.url||ye(s,O,B,b,y),K=[];if(K.push(`src="${A(sr(ve,"fetched"))}"`),K.push(`alt="${A(a)}"`),c)K.push(`width="${A(c)}"`);if(f)K.push(`height="${A(f)}"`);let te=X||(L||M?"eager":U?"lazy":"");if(te)K.push(`loading="${A(te)}"`);if(L)K.push('fetchpriority="high"');if(K.push(`decoding="${A(N)}"`),w)K.push(`class="${A(w)}"`);if(D.length>0)K.push(`style="${A(D.join(";"))}"`);if(z)K.push(`srcset="${A(sr(z,"fetched"))}"`);if(V)K.push(`sizes="${A(V)}"`);let we=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(W.length>0){let _=typeof e.static.onload==="string"?e.static.onload:"",H=_n(W)+(_?`;${_}`:"");K.push(`onload="${A(H)}"`),we.add("onload")}K.push(...re(e,we)),K.push(...se(e,we));let T=`<img ${K.join(" ")} />`,Z="";if(M){let H=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${A(ve)}"${H?` type="${H}"`:""}${z?` imagesrcset="${A(z)}"`:""}${V?` imagesizes="${A(V)}"`:""} />
|
|
2
|
+
import{lc,uc}from"./chunk-7rta163c.js";import{j,ss,os,is,So,ko,sr,Ae,ce,q,cs,le,Tt,ue,Ze,ir,To,lr,Me,n,m,F,fn}from"./chunk-zsgcsqat.js";import{d,C,et,u}from"./chunk-55zaxb4s.js";import{ee}from"./chunk-ymymwzt5.js";import{o}from"./chunk-egg54kd0.js";import{p}from"./chunk-2a4szpje.js";import{createHash as St}from"crypto";import Y from"fs";import J from"path";import{decode as sn,generateThumbHash as on}from"ts-images";import{createImageDeliveryCatalog as ht}from"ts-images/delivery";import Be from"fs";function Se(e,t,r){let s=Buffer.alloc(r),i=Be.readSync(e,s,0,r,t);return s.subarray(0,i)}function Te(e){if(e.length<25)return!1;let t=(s,i)=>String.fromCharCode(...e.subarray(s,i));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let r=t(12,16);if(r==="VP8X")return(e[20]&16)!==0;if(r==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function De(e){let t;try{t=Be.openSync(e,"r");let r=Se(t,0,33);if(r.length>=3&&r[0]===255&&r[1]===216&&r[2]===255)return"none";if(r.length>=26&&r[0]===137&&r.toString("latin1",1,4)==="PNG"){let s=r[25];if(s===4||s===6)return"possible";let i=8;for(let a=0;a<64;a++){let c=Se(t,i,8);if(c.length<8)return"unknown";let f=c.toString("latin1",4,8);if(f==="tRNS")return"possible";if(f==="IDAT"||f==="IEND")return"none";i+=12+c.readUInt32BE(0)}return"unknown"}if(r.length>=25&&r.toString("latin1",0,4)==="RIFF"&&r.toString("latin1",8,12)==="WEBP"){if(Te(r))return"possible";let s=r.toString("latin1",12,16);return s==="VP8 "||s==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)Be.closeSync(t)}}import Jt from"fs";import Ce from"os";import{join as ft}from"path";import{fileURLToPath as dt}from"url";import{Worker as gt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Yt(e=typeof Ce.availableParallelism==="function"?Ce.availableParallelism():Ce.cpus().length){return Math.max(1,Math.min(2,e-1))}var Re=0,pt=[];async function Qt(){if(Re<Yt()){Re++;return}await new Promise((e)=>pt.push(e)),Re++}function en(){Re--,pt.shift()?.()}var tn="@stacksjs/stx/builtins/image-warmup-worker";function nn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let r=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(r.protocol==="file:"&&Jt.existsSync(dt(r)))return dt(r)}catch{}try{let r=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return r&&rn(r)?r:void 0}catch{return}}function rn(e,t=process.env){let r=e.replace(/\\/g,"/");if(r.split("/").some((i)=>/@\d[^/]*@@@\d+$/.test(i)))return!1;return![t.BUN_INSTALL_CACHE_DIR,ft(t.BUN_INSTALL||ft(Ce.homedir(),".bun"),"install","cache")].filter((i)=>!!i).map((i)=>`${i.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((i)=>r.startsWith(i))}var mt=!1;function me(e){if(!mt)mt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function je(e){return e instanceof Error?e.message:String(e)}async function Le(e,t){if(typeof gt!=="function")return me("node:worker_threads has no Worker in this runtime");let r=nn();if(!r)return me("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((s,i)=>{let a;try{a=new gt(r)}catch(h){s(me(`could not start ${r}: ${je(h)}`));return}let c=!1,f=!1,l=(h)=>{if(f)return;f=!0,h(),a.terminate()};a.on("message",(h)=>{if(h.type==="ready"){c=!0,a.postMessage({task:e,args:t});return}if(h.type==="result"){l(()=>s(h.value));return}let v=Error(h.error?.message??"image worker failed");if(h.error?.name)v.name=h.error.name;if(h.error?.stack)v.stack=h.error.stack;l(()=>i(v))}),a.on("error",(h)=>{l(()=>c?i(h instanceof Error?h:Error(je(h)||"image worker crashed")):s(me(`the worker failed before it was ready: ${je(h)}`)))}),a.on("exit",(h)=>{l(()=>c?i(Error("image worker exited before it finished")):s(me(`the worker exited with code ${h} before it was ready`)))})})}finally{en()}}var an=new Set([".avif",".jpeg",".jpg",".png",".webp"]),cn=[320,640,960,1280,1920],pe="/_stx/images",ln=`stx:${pe}:alpha-1`,un=`stx:${pe}:opaque-1`,dn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function gn(e,t){let r=J.dirname(Bun.resolveSync(e,t));while(r!==J.dirname(r)){let s=J.join(r,"package.json");if(Y.existsSync(s)){let i=JSON.parse(Y.readFileSync(s,"utf8"));if(i.name===e)return i.version}r=J.dirname(r)}return}function yt(){if(Pe!==void 0)return Pe;let e;try{e=J.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=dn.map((t)=>{let r;try{r=e?gn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${r??"unknown"}`}).join("+"),Pe}var xt=Symbol.for("stx.image-delivery");function he(){let e=globalThis;return e[xt]??={catalog:new Map,transparent:new Set},e[xt]}var bt=new Set;function mn(e){return`/${e.split(J.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=J.extname(e),r=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),s=St("sha256").update(e).digest("hex").slice(0,8);return`${r||"image"}-${s}`}function vt(e,t=`stx:${pe}`){let r=(s)=>`${pe}/${s.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(s){let i=J.join(e,s);try{let a=await Y.promises.stat(i);return a.size>0?{bytes:a.size,path:i,url:r(s)}:null}catch{return null}},async write(s,i){let a=J.join(e,s);await Y.promises.mkdir(J.dirname(a),{recursive:!0});let c=`${a}.${process.pid}.tmp`;return await Y.promises.writeFile(c,i),await Y.promises.rename(c,a),{bytes:i.byteLength,path:a,url:r(s)}},url:r}}async function Ct(e,t=e){let r=await Y.promises.readdir(t,{withFileTypes:!0});r.sort((i,a)=>i.name.localeCompare(a.name));let s=[];for(let i of r){let a=J.join(t,i.name);if(i.isDirectory()){s.push(...await Ct(e,a));continue}if(!i.isFile()||!an.has(J.extname(i.name).toLowerCase()))continue;s.push({absolutePath:a,relativePath:J.relative(e,a)})}return s}function wt(e,t){return e.map((r)=>({key:mn(r.relativePath),input:r.absolutePath,name:pn(r.relativePath),...hn(r.absolutePath)?{options:{storage:t}}:{}}))}function hn(e){return De(e)==="possible"}function yn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function xn(e){let t=Object.entries(e).filter(([,i])=>i.fallback.format==="png"),r=new Set,s=8;for(let i=0;i<t.length;i+=8)await Promise.all(t.slice(i,i+8).map(async([a,c])=>{let f=c.variants.filter((l)=>l.format==="png").sort((l,h)=>l.width-h.width)[0];try{let l=await sn(new Uint8Array(await Y.promises.readFile(f?.path??c.fallback.path)));if(yn(l.data))r.add(a)}catch{r.add(a)}}));return r}function bn(e,t){let r=[];for(let s of t){let i=e[s],a=i?.variants.filter((f)=>f.format==="webp")??[];if(!i||a.length===0)continue;if(!a.some((f)=>{let l;try{return l=Y.openSync(f.path,"r"),!Te(Se(l,0,32))}catch{return!0}finally{if(l!==void 0)Y.closeSync(l)}}))continue;if(i.variants=i.variants.filter((f)=>f.format!=="webp"),delete i.sources.webp,r.push(s),!bt.has(s))bt.add(s),console.warn(`[stx-images] ${s} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return r}async function vn(e){let t=[],r=8;for(let s=0;s<e.length;s+=8){let i=e.slice(s,s+8),a=await Promise.all(i.map(async(c)=>{try{return await on(c.absolutePath),c}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${c.relativePath}`),null}}));t.push(...a.filter((c)=>c!==null))}return t}function ze(e){return J.join(e,"undecodable.json")}function wn(e){try{let t=Y.readFileSync(ze(e),"utf-8"),r=JSON.parse(t);return r&&typeof r==="object"?r:{}}catch{return{}}}function $n(e,t){try{Y.mkdirSync(J.dirname(ze(e)),{recursive:!0}),Y.writeFileSync(ze(e),JSON.stringify(t))}catch{}}function $t(e){try{let t=Y.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function Rt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Qs(e){let t=Rt(e);return t?he().catalog.get(t):void 0}function eo(e){let t=Rt(e);return t?he().transparent.has(t):!1}function to(e){let t=(s)=>e.variants.filter((i)=>i.format===s).reduce((i,a)=>i+a.bytes,0),r=t(e.fallback.format);return["avif","webp"].map((s)=>({format:s,srcset:e.sources[s]||"",bytes:t(s)})).filter((s)=>s.srcset&&s.bytes>0&&s.bytes<r).sort((s,i)=>s.bytes-i.bytes).map(({format:s,srcset:i})=>({format:s,srcset:i}))}function dp(e){let t=Qs(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:to(t).map(({format:r,srcset:s})=>({type:`image/${r}`,srcset:s})),width:t.source.width,height:t.source.height,placeholder:eo(e)?void 0:t.placeholder?.dataUrl}}function jr(){let e=he();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=he();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function pp(e,t,r={}){if(!e||!Y.existsSync(e))return jr(),{count:0,fingerprint:""};if(r.offThread){let g=await Le("delivery",{publicDir:e,outputDir:t});if(g!==ke)return Sn(g.state),g.result}let s=await Ct(e);if(s.length===0)return jr(),{count:0,fingerprint:""};let i=wn(t),a=s.filter((g)=>{let b=i[g.relativePath];if(!b)return!0;let w=$t(g.absolutePath);return!w||w.mtimeMs!==b.mtimeMs||w.size!==b.size});if(a.length===0)return jr(),{count:0,fingerprint:""};let c=vt(J.join(t,"_stx","images"),`${ln}:${yt()}`),f={outDir:J.join(t,"_stx","images"),storage:vt(J.join(t,"_stx","images"),`${un}:${yt()}`),baseUrl:pe,widths:cn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},l=a,h;try{h=await ht({...f,entries:wt(a,c)})}catch(g){if(l=await vn(a),l.length===a.length)throw g;let b=new Set(l.map((R)=>R.relativePath)),w=!1;for(let R of a){if(b.has(R.relativePath))continue;let P=$t(R.absolutePath);if(!P)continue;i[R.relativePath]=P,w=!0}if(w)$n(t,i);if(l.length===0)return jr(),{count:0,fingerprint:""};h=await ht({...f,entries:wt(l,c)})}let v=await xn(h.entries),y=bn(h.entries,v),S=he();S.catalog=new Map(Object.entries(h.entries)),S.transparent=v;let x=v.size===0&&y.length===0?h.fingerprint:St("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:y.sort()})).digest("hex");return{count:l.length,fingerprint:x}}class At{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,r,s){let i=So(e,s);if(i!==void 0)return i;for(let a of ko(e,t,r,s))if(await n(a))return a;return null}}var oe=new At;function A(e){return F(e)}var ne="\x00stx-boolean-attribute";function Ue(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function We(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Cn.has(t)}function re(e,t){let r=[];for(let[s,i]of Object.entries(e.static)){if(t.has(s))continue;let a=e.staticNames?.[s]??s;if(typeof i==="boolean"){if(i)r.push(m(a));continue}if(i===ne){r.push(m(a));continue}r.push(`${m(a)}="${fn(a,Ue(String(i)))}"`)}return r}function se(e,t){let r=[];for(let[s,i]of Object.entries(e.serverDynamic??{})){if(t.has(s))continue;if(i===null||i===void 0||i===!1)continue;let a=e.serverDynamicNames?.[s]??s;if(i===!0){r.push(m(a));continue}if(typeof i==="object")continue;r.push(`${m(a)}="${fn(a,Ue(String(i)))}"`)}return r}function Rn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Fe={name:"StxLink",aliases:["stx-link"],render(e,t,r){let s=Rn(e),i=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),a=typeof e.static.activeClass==="string"?e.static.activeClass:"active",c=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",f=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,l=[];if(s.reactive)l.push(`:href="${A(s.value)}"`);else l.push(`href="${A(sr(s.value,"navigable"))}"`);if(i)l.push(`class="${A(i)}"`);if(l.push("data-stx-link"),l.push(`data-stx-active-class="${A(a)}"`),l.push(`data-stx-exact-active-class="${A(c)}"`),f)l.push("data-stx-prefetch");let h=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(h)l.push(`data-stx-active-match="${A(h)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return l.push(...re(e,v)),l.push(...se(e,v)),`<a ${l.join(" ")}>${t}</a>`}};var An=new Map;function He(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return An.get(t)}var kn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},qe=[320,640,768,1024,1280,1536,1920];function G(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let r=e.static[t];if(typeof r==="string")return r;return}function _e(e,t,r=!1){let s=e.serverDynamic[t];if(s!==void 0)return s!==!1&&s!=="false";let i=e.static[t];if(i!==void 0)return i!=="false"&&i!==!1;return r}function Xe(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),r=[];for(let s of t)if(s.includes(":")){let[i,a]=s.split(":"),c=kn[i];if(c)r.push(`(max-width: ${c}px) ${a}`);else{let f=Number.parseInt(i);if(!Number.isNaN(f))r.push(`(max-width: ${f}px) ${a}`)}}else r.push(s);return r.join(", ")}function Ve(e,t,r,s){return t.map((i)=>`${ye(e,i,void 0,r,s)} ${i}w`).join(", ")}function Pn(e,t,r,s,i){return t.map((a)=>{let c=r?r*a:void 0;return`${ye(e,c,void 0,s,i)} ${a}x`}).join(", ")}function ye(e,t,r,s,i){if(!s||s==="local"||s==="static")return e;if(s==="cloudinary"){let a=[];if(t)a.push(`w_${t}`);if(r)a.push(`h_${r}`);if(i)a.push(`f_${i}`);a.push("q_auto");let c=a.join(",");return e.replace("/upload/",`/upload/${c}/`)}if(s==="imgix"){let a=new URLSearchParams;if(t)a.set("w",String(t));if(r)a.set("h",String(r));if(i)a.set("fm",i);a.set("auto","format");let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}if(s==="bunny"){let a=new URLSearchParams;if(t)a.set("width",String(t));if(r)a.set("height",String(r));if(i)a.set("format",i);let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function In(e,t,r="#e5e7eb"){let s=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${r}"/></svg>`;return`data:image/svg+xml;base64,${btoa(s)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,r){let s=G(e,"src")||"",i=Qs(s),a=G(e,"alt")||"",c=G(e,"width")||(i?String(i.source.width):void 0),f=G(e,"height")||(i?String(i.source.height):void 0),l=G(e,"sizes"),h=G(e,"srcset"),v=G(e,"densities"),y=G(e,"format"),S=eo(s)||He(s)?.transparent===!0,x=G(e,"placeholder")||(i&&!S?"thumbhash":void 0),g=G(e,"placeholderColor")||"#e5e7eb",b=G(e,"provider"),w=G(e,"class")||G(e,"className")||"",R=G(e,"style")||"",P=G(e,"objectFit")||G(e,"fit"),k=G(e,"objectPosition")||G(e,"position"),E=G(e,"quality"),U=_e(e,"lazy",!0),M=_e(e,"preload",!1),L=_e(e,"priority",!1),X=G(e,"loading"),N=G(e,"decoding")||"async",I=!!i||_e(e,"picture",!1)||!!y,O=c?Number.parseInt(c):void 0,B=f?Number.parseInt(f):void 0,z=h||"",V="";if(i)z=i.sources[i.fallback.format]||"",V=l?Xe(l):"100vw";else if(!z&&l&&b&&b!=="local"&&b!=="static")z=Ve(s,qe,b,y),V=Xe(l);else if(!z&&v){let _=v.split(/\s+/).map((H)=>Number.parseFloat(H.replace("x","")));z=Pn(s,_,O,b,y)}else if(l)V=Xe(l);let D=[];if(R)D.push(R);if(P)D.push(`object-fit:${P}`);if(k)D.push(`object-position:${k}`);if(O&&B)D.push(`aspect-ratio:${O}/${B}`);let W=[],ie=x==="blur"||x==="color"||x==="thumbhash";if(ie&&!S){let _=i?.placeholder?{dataUrl:i.placeholder.dataUrl,color:g}:He(s);if(_&&x==="color")D.push(`background-color:${_.color}`),W.push("backgroundColor");else if(_)D.push(`background-color:${_.color}`),D.push(`background-image:url(${_.dataUrl})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundColor","backgroundImage");else{let H=In(O||16,B||9,g);D.push(`background-image:url(${H})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!ie&&x&&x!=="empty"&&x!=="none")D.push(`background-image:url(${A(x)})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage");let ve=i?.fallback.url||ye(s,O,B,b,y),K=[];if(K.push(`src="${A(sr(ve,"fetched"))}"`),K.push(`alt="${A(a)}"`),c)K.push(`width="${A(c)}"`);if(f)K.push(`height="${A(f)}"`);let te=X||(L||M?"eager":U?"lazy":"");if(te)K.push(`loading="${A(te)}"`);if(L)K.push('fetchpriority="high"');if(K.push(`decoding="${A(N)}"`),w)K.push(`class="${A(w)}"`);if(D.length>0)K.push(`style="${A(D.join(";"))}"`);if(z)K.push(`srcset="${A(sr(z,"fetched"))}"`);if(V)K.push(`sizes="${A(V)}"`);let we=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(W.length>0){let _=typeof e.static.onload==="string"?e.static.onload:"",H=_n(W)+(_?`;${_}`:"");K.push(`onload="${A(H)}"`),we.add("onload")}K.push(...re(e,we)),K.push(...se(e,we));let T=`<img ${K.join(" ")} />`,Z="";if(M){let H=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${A(ve)}"${H?` type="${H}"`:""}${z?` imagesrcset="${A(z)}"`:""}${V?` imagesizes="${A(V)}"`:""} />
|
|
3
3
|
`}if(I){let _=[];if(i)for(let H of to(i))_.push(`<source type="image/${H.format}" srcset="${A(H.srcset)}"${V?` sizes="${A(V)}"`:""} />`);if(!i&&(y==="avif"||y==="auto")){let H=ye(s,O,B,b,"avif"),Q=z?Ve(s,qe,b,"avif"):`${H}`;_.push(`<source type="image/avif" srcset="${A(Q)}"${V?` sizes="${A(V)}"`:""} />`)}if(!i&&(y==="webp"||y==="auto")){let H=ye(s,O,B,b,"webp"),Q=z?Ve(s,qe,b,"webp"):`${H}`;_.push(`<source type="image/webp" srcset="${A(Q)}"${V?` sizes="${A(V)}"`:""} />`)}return`${Z}<picture>
|
|
4
4
|
${_.join(`
|
|
5
5
|
`)}
|
|
@@ -38,5 +38,5 @@ ${T}
|
|
|
38
38
|
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
39
39
|
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
40
40
|
</style>`}};import{existsSync as On,readFileSync as Bn}from"fs";var Ne=new Map,Nt=new Set;function Tn(e){if(Nt.has(e))return;Nt.add(e),console.warn(`[stx] icon collection "${e}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${e}\`.`)}function Dn(e){let t=process.cwd();for(let r of[`${t}/node_modules/@iconify-json/${e}/icons.json`,`${t}/pantry/@iconify-json/${e}/icons.json`,`${t}/node_modules/@iconify/json/json/${e}.json`,`${t}/pantry/@iconify/json/json/${e}.json`])if(On(r))return r;for(let r of[`@iconify-json/${e}/icons.json`,`@iconify/json/json/${e}.json`])try{return p.resolve(r)}catch{}return null}function jn(e){if(Ne.has(e))return Ne.get(e);let t=Dn(e);if(!t)return Tn(e),null;try{let r=JSON.parse(Bn(t,"utf8"));return Ne.set(e,r.icons),r.icons}catch{return null}}function de(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);if(e.static[t]!==void 0)return String(e.static[t]);if(e.clientReactive[t]!==void 0)return e.clientReactive[t];return}var rt={name:"Icon",aliases:["icon","stx-icon"],render(e,t,r){let s=de(e,"name")??de(e,"icon");if(!s)return"<!-- Icon: missing name/icon prop -->";let i="lucide",a=s;if(s.includes(":")){let P=s.split(":");i=P[0],a=P[1]}let c=A(de(e,"size")||"24"),f=A(de(e,"color")||"currentColor"),l=A(de(e,"class")||""),h=A(de(e,"style")||""),v=Ne.get(i)??jn(i);if(!v)return`<!-- Icon: collection "${i}" not loaded -->`;let y=v[a];if(!y)return`<!-- Icon: "${a}" not found in ${i} -->`;let S=y.width||24,x=y.height||24,g=`0 0 ${S} ${x}`,b=y.body;if(f!=="currentColor")b=b.replace(/currentColor/g,f);let w=l?` class="${l}"`:"",R=h?` style="${h}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${c}" height="${c}" viewBox="${g}" fill="none"${w}${R}>${b}</svg>`}};function Ot(e,...t){for(let r of t){if(e.serverDynamic[r]!==void 0)return String(e.serverDynamic[r]);let s=e.static[r];if(typeof s==="string")return s}return}function Bt(e,t){let r=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${t}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),s=e.match(r);if(!s)return{region:null,rest:e};return{region:s[2],rest:e.replace(s[0],"")}}var st={name:"Suspense",aliases:["suspense"],render(e,t,r){let s=Bt(t,"fallback"),i=s.rest,a=Bt(i,"error"),c=a.rest,f=s.region??Ot(e,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',l=a.region??Ot(e,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${f}</div><div data-stx-suspense-error hidden>${l}</div><div data-stx-suspense-content hidden>${c}</div></div>`}};function Oe(e,...t){for(let r of t){if(e.serverDynamic[r]!==void 0)return String(e.serverDynamic[r]);let s=e.static[r];if(typeof s==="string")return s}return}var it={name:"TransitionGroup",aliases:["transition-group"],render(e,t,r){let s=(Oe(e,"name")||"v").replace(/["'<>]/g,""),i=(Oe(e,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",a=Oe(e,"class"),c=Oe(e,"id"),f=[`data-stx-transition-group="${s}"`,a?`class="${a}"`:"",c?`id="${c}"`:""].filter(Boolean).join(" ");return`<${i} ${f}>${t}</${i}>`}};function Dt(e=oe){e.registerBuiltin(Fe),e.registerBuiltin(Ge),e.registerBuiltin(Ke),e.registerBuiltin(Ye),e.registerBuiltin(Qe),e.registerBuiltin(tt),e.registerBuiltin(nt),e.registerBuiltin(rt),e.registerBuiltin(st),e.registerBuiltin(it)}var jt=new Map;function Mn(e){let t=jt.get(e.source);if(!t)t=new RegExp(`(${e.source})(?![\\w.:-])`,"y"),jt.set(e.source,t);return t}var Mt=new WeakMap;function Lt(e){let t=Mt.get(e);if(!t)t=new Set([...e].map((s)=>s.toLowerCase())),Mt.set(e,t);let r=t;return(s)=>!/[a-z]/.test(s)&&r.has(s.toLowerCase())}function Ln(e,t){let r="";for(let s=t;s<e.length;s++){let i=e[s];if(r){if(i==="\\")s++;else if(i===r)r=""}else if(i==='"'||i==="'")r=i;else if(i===">")return s}return e.length}function zt(e,t,r){let s=[],i=0,a=typeof r==="function"?r:r?(c)=>r.has(c.toLowerCase()):void 0;while(i<e.length){let c=e.indexOf("<",i);if(c===-1)break;let f=Mn(t);f.lastIndex=c+1;let l=f.exec(e);if(!l){i=c+1;continue}let h=l[1];if(a&&a(h)){let w=c+1+h.length;while(w<e.length&&e[w]!==">")w++;i=w+1;continue}let v=c+1+h.length,y=null,S=v,x=-1,g=!1;while(v<e.length){let w=e[v];if(y){if(w==="\\"&&v+1<e.length){v+=2;continue}if(w===y)y=null;v++;continue}if(w==='"'||w==="'"){y=w,v++;continue}if(w==="/"&&v+1<e.length&&e[v+1]===">"){x=v+2,g=!0;break}if(w===">"){x=v+1;break}v++}if(x===-1){i=c+1;continue}let b=e.slice(S,g?x-2:x-1).trim();if(g)s.push({fullMatch:e.slice(c,x),tagName:h,attributes:b,content:"",startIndex:c,endIndex:x,isSelfClosing:!0}),i=x;else{let w=`<${h}`,R=`</${h}>`,P=1,k=x,E=-1;while(P>0&&k<e.length){let L=e.indexOf(w,k),X=e.indexOf(R,k);if(X===-1)break;if(L!==-1&&L<X){let N=e[L+w.length];if(N===" "||N===">"||N==="/"||N===`
|
|
41
|
-
`||N==="\t"){let I=Ln(e,L+w.length);if(e[I-1]!=="/")P++;k=I+1}else k=L+w.length}else{if(P--,P===0){E=X;break}k=X+R.length}}if(E===-1){i=x;continue}let U=e.slice(x,E),M=E+R.length;s.push({fullMatch:e.slice(c,M),tagName:h,attributes:b,content:U,startIndex:c,endIndex:M,isSelfClosing:!1}),i=M}}return s}function ot(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function Ut(e,t){try{let r=Buffer.from(e,"base64").toString("utf8");return JSON.parse(r)}catch{}try{let r=e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(r)}catch(r){if(t?.debug)console.error("Error decoding __stx_ prop:",r);return e}}function at(e,t){let r=0,s="",i=t;while(i<e.length){let a=e[i];if(s){if(a==="\\")i++;else if(a===s)s=""}else if(a==='"'||a==="'"||a==="`")s=a;else if(a==="{")r++;else if(a==="}"){if(r--,r===0)return e.slice(t,i+1)}i++}return e.slice(t)}function Wt(e){let t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;if(at(t,0).length!==t.length)return null;return t.slice(1,-1).trim()}var zn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Un=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Wn(e){return ct(e).map((t)=>[t.start,t.end])}function ct(e){let t=[],r=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,s;while((s=r.exec(e))!==null){let i=s[2]||"",a=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(i);if(!a)continue;let c=Tt(a[1]??a[2]??a[3]??""),f=s.index,l=f+s[0].length,h=s[1].toLowerCase();if(s[0].endsWith("/>")||Un.has(h)){t.push({start:f,end:l,names:c});continue}let v=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),y=new RegExp(`<\\/?${v}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");y.lastIndex=l;let S=1,x=l,g;while((g=y.exec(e))!==null)if(g[0].startsWith("</")){if(S--,S===0){x=g.index+g[0].length;break}}else if(!g[0].endsWith("/>"))S++;t.push({start:f,end:x,names:c})}return t}function Ft(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((t)=>Ft(t)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" ");return e?String(e):""}function oa(e,t){if(!/:[\w-]+=/.test(e))return e;let r=e,s=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,i=[],a;while((a=s.exec(e))!==null)i.push([a.index,a.index+a[0].length]);i.push(...Wn(e));let c=new Set([...Ze(t),...Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]]);function f(S){return i.some(([x,g])=>S>=x&&S<g)}let l=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,h=[],v=new Map,y=256;while((a=l.exec(r))!==null){if(f(a.index))continue;let S=a[0],x=a[2];if(!x||!x.includes(":"))continue;let g=/(?:^|\s)data-native(?:\s|=|$)/i.test(x.replace(/"[^"]*"|'[^']*'/g,"")),b=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,w,R=x,P=!1;while((w=b.exec(x))!==null){if(cs(x,w.index,!0)?.kind==="attribute")continue;let k=w[1],E=w[2];if(lc(k))continue;if(ue(E,c))continue;if(E.includes("()")&&!E.includes(".get(")||E.includes("$store")||E.includes("$ref"))continue;try{let U=Object.keys(t),M=Object.values(t),L=E.match(/^([a-zA-Z_$][\w$]*)/);if(L&&!U.includes(L[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(L[1]))continue;let X=JSON.stringify([U,E]),N=v.get(X);if(!N){if(N=Function(...U,`return (${E})`),v.size>=y)v.clear();v.set(X,N)}let I=N(...M);if(k==="class"){let O=F(Ft(I));if(O){let B=R.match(/\sclass="([^"]*)"/);if(B)R=R.replace(B[0],()=>` class="${B[1]} ${O}"`);else R=R.replace(w[0],()=>` class="${O}"`)}else R=R.replace(w[0],"");P=!0;continue}if(zn.has(k)){if(I)R=R.replace(w[0],` ${k}`);else R=R.replace(w[0],"");P=!0;continue}if(I===null||I===void 0||I===!1)R=R.replace(w[0],"");else{let O=g&&typeof I==="object"?JSON.stringify(I):String(I),B=fn(k,O);R=R.replace(w[0],()=>` ${k}="${B}"`)}P=!0}catch(U){if(U instanceof le)throw U;continue}}if(P){let k=a[3]?" /":"",U=`<${a[1]}${R}${k}>`;h.push({start:a.index,end:a.index+S.length,replacement:U})}}if(h.length>0){let S=Array(h.length*2+1),x=0;for(let g=0;g<h.length;g++){let{start:b,end:w,replacement:R}=h[g];S[g*2]=r.slice(x,b),S[g*2+1]=R,x=w}S[h.length*2]=r.slice(x),r=S.join("")}return r}import Ht from"fs";import qt from"path";var Xt=!1;function Fn(e,t,r,s=!1,i=new Set){let a={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},c=new Set(Array.isArray(t.__stx_client_signal_names)?t.__stx_client_signal_names:[]),f=(y)=>{if(c.size===0)return!1;let S=o(y),x=S.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&c.has(x))return!0;for(let g of c){let b=g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${b}\\s*\\(`).test(S))return!0}return!1},l=new Set(uc),h=(y)=>{if(!y.includes("-")||y.startsWith("@")||y.startsWith(":")||y.startsWith("x-")||y.startsWith("__"))return y;if(y.startsWith("aria-")||y.startsWith("data-"))return y;return y.replace(/-([a-z0-9])/g,(S,x)=>x.toUpperCase())},v=(y,S)=>{let x=h(y);if(a.static[x]=S,x!==y)a.staticNames[x]=y};for(let[y,S]of Object.entries(e)){let x=y.startsWith("x-")&&!l.has(y)&&!y.startsWith("x-bind:")&&!y.startsWith("x-on:")?`:${y.slice(2)}`:y;if(x.startsWith("@")){a.events[x]=S;continue}if(x.startsWith("__stx_")){let g=h(x.slice(6));a.serverDynamic[g]=Ut(S,r);continue}if(x.startsWith(":")){let g=h(x.slice(1)),b=S===ne?g:S;if(g==="if"||g==="for"||g==="show"){a.clientReactive[g]=b;continue}if(s){a.clientReactive[g]=b;continue}if(ue(b,i)){a.clientReactive[g]=b;continue}if(f(b)){a.clientReactive[g]=b;continue}try{if(!d(b)){if(r.debug)console.error(`Unsafe expression in :${g} binding: ${b}`);a.clientReactive[g]=b;continue}let w=Object.keys(t),R=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),P=new Set(Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]);if(et(b).some((M)=>!R.has(M)&&!w.includes(M)&&(!(M in globalThis)||P.has(M)))){a.clientReactive[g]=b;continue}let U=u(b,w)(...Object.values(t));if(a.serverDynamic[g]=U,g!==x.slice(1)&&a.serverDynamicNames)a.serverDynamicNames[g]=x.slice(1)}catch{a.clientReactive[g]=b}continue}if(typeof S==="string"&&S.includes("{{")&&S.includes("}}")){let g=Hn(S,i);if(g!==null){a.clientReactive[h(x)]=g;continue}let b=S.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(b)try{let w=b[1];if(d(w)){let P=u(w,Object.keys(t))(...Object.values(t));v(x,P!=null?String(P):"")}else{if(r.debug)console.error(`Unsafe expression in ${x}: ${w}`);v(x,S)}}catch(w){if(r.debug)console.error(`Error evaluating expression for ${x}:`,w);v(x,S)}else{let w=S,R=/\{\{\s*([\s\S]+?)\s*\}\}/g,P;while((P=R.exec(S))!==null)try{let k=P[1];if(!d(k)){if(r.debug)console.error(`Unsafe expression in ${x}: ${k}`);continue}let U=u(k,Object.keys(t))(...Object.values(t));w=w.replace(P[0],String(U??""))}catch(k){if(r.debug)console.error(`Error evaluating expression in ${x}:`,k)}v(x,w)}continue}v(x,S===ne?"true":ot(S))}return a}function Hn(e,t){if(t.size===0)return null;let r=/\{\{\s*([\s\S]+?)\s*\}\}/g,s=[...e.matchAll(r)];if(!s.some((f)=>ue(f[1],t)))return null;let i=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(i&&s.length===1)return i[1];let a="",c=0;for(let f of s)a+=e.slice(c,f.index).replace(/[`\\$]/g,(l)=>`\\${l}`),a+=`\${${f[1]}}`,c=f.index+f[0].length;return a+=e.slice(c).replace(/[`\\$]/g,(f)=>`\\${f}`),`\`${a}\``}var qn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Xn(e,t,r){if(!e.includes("@"))return e;if(!qn.some(([i,a])=>i.test(e)&&e.includes(a)))return e;try{return ee(e,t,r)}catch{return e}}function ge(e){let t={},r=0,s=e.length;while(r<s){while(r<s&&/\s/.test(e[r]))r++;if(r>=s)break;let i="";while(r<s&&!/[\s=]/.test(e[r]))i+=e[r],r++;if(!i)break;while(r<s&&/\s/.test(e[r]))r++;if(r<s&&e[r]==="="){r++;while(r<s&&/\s/.test(e[r]))r++;let a="";if(r<s&&(e[r]==='"'||e[r]==="'")){let c=e[r];r++;while(r<s){let f=e[r];if(f==="\\"&&r+1<s){r++,a+=e[r],r++;continue}if(f===c){r++;break}a+=f,r++}}else if(e[r]==="{"){a=at(e,r),r+=a.length;let c=Wt(a);if(c!==null){t[`:${i}`]=c;continue}}else while(r<s&&!/\s/.test(e[r]))a+=e[r],r++;t[i]=a}else t[i]=ne}return t}function Zt(e){return Object.entries(e).map(([t,r])=>r===ne?t:`${t}="${Zn(r)}"`).join(" ")}function Zn(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Vn(e){let t=new Set,r=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,s;while((s=r.exec(e))!==null){let i=s[1];if(oe.isBuiltin(i))t.add(i)}return[...t].sort()}async function kl(e,t,r,s,i){if(!/import\s/.test(e))return e;if(!t.__importedComponents)t.__importedComponents=new Map;let a=t.__importedComponents,c=qt.dirname(r),f=[],l=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let y of e.matchAll(l)){let[S,x,g]=y,b=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,w=g,R,P=[];while((R=b.exec(g))!==null){let[k,E,U,M]=R,L=null,X=null;if(M.startsWith(".")||M.startsWith("/")){let O=qt.resolve(c,M);if(O.endsWith(".stx"))X=O;else{let B=`${O}.stx`;try{if(Ht.statSync(B).isFile())X=B}catch{try{if(Ht.statSync(O).isDirectory())L=O}catch{}}}}else L=os(M,c);if(!L&&!X)continue;let N=!1,I=(O,B)=>{a.set(O,B),a.set(O.toLowerCase(),B);let z=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();a.set(z,B),i.add(B)};if(U&&X)I(U,X),N=!0;else if(E){let O=E.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>{let V=z.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(V)return{source:V[1],local:V[2]};return{source:z,local:z}}),B=L?ss(L):null;for(let{source:z,local:V}of O){let D=null;if(X)D=X;else if(B)D=B.get(z)??B.get(z.toLowerCase())??B.get(z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(D)I(V,D),N=!0}}if(N)P.push({start:R.index,end:R.index+k.length})}if(P.length===0)continue;for(let k=P.length-1;k>=0;k--)w=w.slice(0,P[k].start)+w.slice(P[k].end);f.push({start:y.index,end:y.index+S.length,value:`<script${x}>${w}</script>`})}if(f.length===0)return e;let h=[],v=0;for(let y of f)h.push(e.slice(v,y.start),y.value),v=y.end;return h.push(e.slice(v)),h.join("")}async function Gn(e,t,r,s,i){let a=e;if(!t.__importedComponents)t.__importedComponents=new Map;let c=t.__importedComponents,f=/@import\s*\(\s*([^)]+)\s*\)/g,l;while((l=f.exec(a))!==null){let[h,v]=l,y=v.split(",").map((S)=>S.trim().replace(/^['"]|['"]$/g,"")).filter((S)=>S.length>0);for(let S of y){let x=S.split("/"),b=x[x.length-1].replace(/\.stx$/,""),w=b.includes("-")?b.split("-").map((k)=>k.charAt(0).toUpperCase()+k.slice(1)).join(""):b.charAt(0).toUpperCase()+b.slice(1),R=null,P=is(S,r,s);for(let k of P)try{if(await Bun.file(k).exists()){R=k;break}}catch{}if(R){c.set(w,R),c.set(b,R),c.set(b.toLowerCase(),R);let k=w.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(c.set(k,R),i.add(R),s.debug)console.log(`Imported component: ${w} -> ${R}`)}else if(s.debug)console.warn(`Could not resolve imported component: ${S}`)}a=a.replace(h,""),f.lastIndex=0}return a}async function Kn(e,t,r,s,i){let a=e,c=s.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let f=t.__processedComponents,l=/@component\s*\(/g,h;while((h=l.exec(a))!==null){let v=h.index,y=v+h[0].length-1,S=1,x=y+1;while(x<a.length&&S>0){if(a[x]==="(")S++;else if(a[x]===")"){if(S--,S===0)break}x++}if(S!==0)break;let g=a.substring(y+1,x),b=x+1,w=g.match(/^\s*['"]([^'"]+)['"]/);if(!w){l.lastIndex=0;continue}let R=w[1],P,k=g.slice(w[0].length),E=k.match(/^\s*,\s*/);if(E)P=k.slice(E[0].length).trim();let U={};if(P)try{U=C(P,t)}catch(O){let B=O instanceof Error?O.message:String(O);a=a.replace(a.substring(v,b),`[Error parsing component props: ${B}]`);continue}let M="",L=b,N=a.substring(b).match(/^([\s\S]*?)@endcomponent/);if(N)M=N[1].trim(),L=b+N[0].length;let I=await De(R,U,M,c,t,r,s,f,i);a=a.substring(0,v)+I+a.substring(L),l.lastIndex=0}return a}async function Jn(e,t,r,s,i){if(!e)return e;let a=e,c=s.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let f=t.__processedComponents,l=er(a);if(l.size>0){let b=Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[];t.__stx_client_declared_names=[...new Set([...b,...l])]}let h=q(a);a=h.output;let v=Ze(t);return a=await g(a,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),a=await g(a,/[A-Z][a-zA-Z0-9]*/,!0,Lt(ir)),a=await g(a,/[a-z][a-z0-9]*/,!1,ir),a=h.restore(a),a;async function g(b,w,R,P){if(!b)return b;let k=b,E=zt(k,w,P),U=ct(k),M=new Map;for(let N=E.length-1;N>=0;N--){let I=E[N],O=R?j(I.tagName):I.tagName,B=ge(Xn(I.attributes,t,r)),z=U.filter(({start:Z,end:_})=>I.startIndex>=Z&&I.startIndex<_),V=z.length>0,D=new Set(v);for(let Z of z)for(let _ of Z.names)D.add(_);let W=Fn(B,t,s,V,D);if(typeof W.clientReactive.for==="string")for(let Z of Tt(W.clientReactive.for))D.add(Z);let ie=oe.getBuiltin(I.tagName),ve=ie?await lr(I.tagName,c,t,r,s):!1;if(ie&&!ve){let Z={context:t,filePath:r,options:s,dependencies:i},_=ie.render(W,I.content,Z);if(Object.keys(W.events).length>0){let H=Zt(W.events);_=_.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${H}`)}if(Object.keys(W.clientReactive).length>0)_=Vt(_,W.clientReactive);M.set(N,_);continue}if(!R&&I.tagName.includes("-")&&!await lr(O,c,t,r,s))continue;let K={};for(let[Z,_]of Object.entries(W.static))K[Z]=_;for(let[Z,_]of Object.entries(W.serverDynamic))K[Z]=_;let te={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(W.clientReactive),events:Object.keys(W.events)},T=await De(O,K,h.restore(I.content),c,t,r,s,f,i,[...D],te,I.tagName);if(T=Yn(T,W,te.declaredProps,te.consumedProps,s._nativeHostAttrs),s._nativeHostAttrs){let Z=te.reactiveProps.filter((Q)=>!te.consumedProps.has(Q)&&!["if","for","show","key","ref"].includes(Q)).map(j),_=lt(T,!0);if(Z.length&&_){if(!Object.hasOwn(ge(T.slice(_.insertPos,_.tagEnd)),"data-stx-native-host-root"))T=T.slice(0,_.insertPos)+' data-stx-native-host-root="true"'+T.slice(_.insertPos);let Q=be(T);T=T.slice(0,Q.insertPos)+` data-stx-native-forward="${Z.join(" ")}"`+T.slice(Q.insertPos)}let H=lt(T,!0);if(H){let Q=ge(T.slice(H.insertPos,H.tagEnd)),$e=be(T),Kt=ge(T.slice($e.insertPos,$e.tagEnd));if(Object.hasOwn(Q,"data-stx-native-host-root")&&!Object.hasOwn(Kt,"data-stx-native-host-owner"))T=T.slice(0,$e.insertPos)+" data-stx-native-host-owner"+T.slice($e.insertPos)}}if(Object.keys(W.events).length>0){let Z=be(T);if(Z){let _=Zt(W.events),H=Object.keys(W.events).map((Q)=>Q.replace(/^@/,"").split(".")[0]).join(" ");T=T.substring(0,Z.insertPos)+` data-stx-parent-events="${H}" ${_}`+T.substring(Z.insertPos)}}if(Object.keys(W.clientReactive).length>0)T=Vt(T,W.clientReactive);M.set(N,T)}if(M.size===0)return k;let L="",X=0;for(let N=0;N<E.length;N++){let I=M.get(N);if(I===void 0)continue;L+=k.slice(X,E[N].startIndex),L+=I,X=E[N].endIndex}return L+=k.slice(X),L}}function Vt(e,t){let r=new Set(["if","for"]),s=new Set(["show"]),i=Object.entries(t).filter(([v])=>!r.has(v)),a=i.filter(([v])=>!s.has(v)).map(([v])=>j(v)).join(" "),c=e,f=i.length>0?be(c):null;if(f){let v=i.map(([S,x])=>`:${j(S)}="${x.replace(/"/g,""")}"`).join(" "),y=a?` data-stx-parent-bindings="${a}"`:"";c=c.substring(0,f.insertPos)+`${y} ${v}`+c.substring(f.insertPos)}let l=t.if;if(l)c=`<template :if="${l.replace(/"/g,""")}">${c}</template>`;let h=t.for;if(h)c=`<template :for="${h.replace(/"/g,""")}">${c}</template>`;return c}function Yn(e,t,r=new Set,s=new Set,i=!1){let a=lt(e,i);if(!a)return e;let c=e.slice(a.insertPos,a.tagEnd),f=t.serverDynamic.class??t.static.class;if(i&&typeof f==="string"&&f&&!s.has("class")){let g=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,b=g.test(c)?c.replace(g,(w,R,P,k,E)=>`${R}class="${A(`${ot(P??k??E)} ${f}`)}"`):` class="${A(f)}"${c}`;e=e.slice(0,a.insertPos)+b+e.slice(a.tagEnd),a.tagEnd+=b.length-c.length,c=b}let l=i||/\bdata-native(?:\s|=)/i.test(c),h=l?s:r,v=new Set(Object.keys(ge(c))),y=new Set(["class","className"]);for(let g of Object.keys(t.static)){let b=t.staticNames[g]??g;if(v.has(b)||h.has(g)||!l&&!We(b))y.add(g)}for(let g of Object.keys(t.serverDynamic)){let b=t.serverDynamicNames?.[g]??g;if(v.has(b)||h.has(g)||!l&&!We(b))y.add(g)}let S=[];if(l){for(let[g,b]of Object.entries(t.static)){if(y.has(g)||b!==!0&&b!==ne)continue;y.add(g),S.push(`${A(t.staticNames?.[g]??g)}="true"`)}for(let[g,b]of Object.entries(t.serverDynamic)){if(y.has(g)||b!==!0)continue;y.add(g),S.push(`${A(t.serverDynamicNames?.[g]??g)}="true"`)}}let x=[...re(t,y),...se(t,y),...S];if(l){for(let[g,b]of Object.entries(t.serverDynamic)){if(y.has(g)||b!==!1)continue;let w=t.serverDynamicNames?.[g]??g;x.push(`${A(w)}="false"`)}for(let[g,b]of Object.entries(t.serverDynamic)){if(y.has(g)||b===null||typeof b!=="object")continue;let w=JSON.stringify(b);if(w!==void 0){let R=t.serverDynamicNames?.[g]??g;x.push(`${A(R)}="${A(w)}"`)}}}if(x.length===0)return e;return`${e.slice(0,a.insertPos)} ${x.join(" ")}${e.slice(a.insertPos)}`}function be(e){let t=Gt(e,0);if(t)return t;let r=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(r)return{insertPos:r.index+1+r[1].length,tagEnd:ut(e,r.index+1+r[1].length)};return null}function lt(e,t=!1){let r=be(e);if(!r)return null;let s=e.slice(r.insertPos,r.tagEnd),i=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(s)?Gt(e,r.tagEnd+1):r;return i&&t?Qn(e,i)??i:i}function Qn(e,t){if(!e.includes("data-stx-native-host-root"))return null;let r=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),s=e.lastIndexOf("<",t.insertPos),i=0,a;while(s>=0&&s<e.length){if(e.startsWith("<!--",s)){let v=e.indexOf("-->",s+4);if(v<0)return null;s=e.indexOf("<",v+3);continue}let c=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(s));if(!c){s=e.indexOf("<",s+1);continue}let f=c[2].toLowerCase(),l=s+c[0].length,h=ut(e,l);if(c[1]){if(i--,a!==void 0&&i<a)a=void 0;if(i<=0)return null}else if(f==="script"||f==="style"){let v=new RegExp(`</${f}\\s*>`,"gi");if(v.lastIndex=h+1,!v.exec(e))return null;s=e.indexOf("<",v.lastIndex);continue}else{let v=ge(e.slice(l,h)),y=i>0&&(Object.hasOwn(v,"data-stx-component-wrapper")||Object.hasOwn(v,"data-stx-native-host-owner"));if(a===void 0&&!y&&Object.hasOwn(v,"data-stx-native-host-root"))return{insertPos:l,tagEnd:h};if(!r.has(f)&&e[h-1]!=="/"){if(i++,a===void 0&&y)a=i}else if(i===0)return null}s=e.indexOf("<",h+1)}return null}function Gt(e,t){let r=t;while(r<e.length){let s=e.slice(r),i=s.match(/^\s+/);if(i){r+=i[0].length;continue}if(s.startsWith("<!--")){let f=e.indexOf("-->",r+4);if(f===-1)return null;r=f+3;continue}let a=s.match(/^<(script|style)\b[^>]*>/i);if(a){let f=`</${a[1].toLowerCase()}>`,l=e.toLowerCase().indexOf(f,r+a[0].length);if(l===-1)return null;r=l+f.length;continue}let c=s.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!c)return null;return{insertPos:r+1+c[1].length,tagEnd:ut(e,r+1+c[1].length)}}return null}function ut(e,t){let r="";for(let s=t;s<e.length;s++){let i=e[s];if(r){if(i==="\\")s++;else if(i===r)r=""}else if(i==='"'||i==="'")r=i;else if(i===">")return s}return e.length}function er(e){let t=new Set;for(let r of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let s=r[1];if(!/\bclient\b/.test(s)||/\bserver\b/.test(s))continue;for(let i of To(r[2]))t.add(i);for(let i of r[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(i[1])t.add(i[1]);if(i[3])t.add(i[3]);for(let a of(i[2]??"").split(",")){let c=a.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(c))t.add(c)}}}return t}async function Br(e,t,r,s,i){if(!Xt)Dt(oe),Xt=!0;let a=await kl(e,t,r,s,i);a=await Gn(a,t,r,s,i),a=await Kn(a,t,r,s,i);let c=[];for(let f=0;f<3;f++){let l=c.length,h=ce(a,Re,(y,S)=>`\x00STX_COMPONENT_COMMENT_${l+S}\x00`,`STX_COMPONENT_COMMENT:${l}`);c.push(...h.tokens);let v=a;if(a=await Jn(h.output,t,r,s,i),a===v)break}if(c.length>0)a=a.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(f,l)=>c[Number(l)]??"");if(s.debug){let f=Vn(a);if(f.length>0)console.warn(`[stx] ${r}: unresolved component tag(s) after render passes: ${f.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return a}
|
|
41
|
+
`||N==="\t"){let I=Ln(e,L+w.length);if(e[I-1]!=="/")P++;k=I+1}else k=L+w.length}else{if(P--,P===0){E=X;break}k=X+R.length}}if(E===-1){i=x;continue}let U=e.slice(x,E),M=E+R.length;s.push({fullMatch:e.slice(c,M),tagName:h,attributes:b,content:U,startIndex:c,endIndex:M,isSelfClosing:!1}),i=M}}return s}function ot(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function Ut(e,t){try{let r=Buffer.from(e,"base64").toString("utf8");return JSON.parse(r)}catch{}try{let r=e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(r)}catch(r){if(t?.debug)console.error("Error decoding __stx_ prop:",r);return e}}function at(e,t){let r=0,s="",i=t;while(i<e.length){let a=e[i];if(s){if(a==="\\")i++;else if(a===s)s=""}else if(a==='"'||a==="'"||a==="`")s=a;else if(a==="{")r++;else if(a==="}"){if(r--,r===0)return e.slice(t,i+1)}i++}return e.slice(t)}function Wt(e){let t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;if(at(t,0).length!==t.length)return null;return t.slice(1,-1).trim()}var zn=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Un=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Wn(e){return ct(e).map((t)=>[t.start,t.end])}function ct(e){let t=[],r=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,s;while((s=r.exec(e))!==null){let i=s[2]||"",a=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(i);if(!a)continue;let c=Tt(a[1]??a[2]??a[3]??""),f=s.index,l=f+s[0].length,h=s[1].toLowerCase();if(s[0].endsWith("/>")||Un.has(h)){t.push({start:f,end:l,names:c});continue}let v=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),y=new RegExp(`<\\/?${v}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");y.lastIndex=l;let S=1,x=l,g;while((g=y.exec(e))!==null)if(g[0].startsWith("</")){if(S--,S===0){x=g.index+g[0].length;break}}else if(!g[0].endsWith("/>"))S++;t.push({start:f,end:x,names:c})}return t}function Ft(e){if(typeof e==="string")return e;if(Array.isArray(e))return e.filter(Boolean).map((t)=>Ft(t)).join(" ");if(e&&typeof e==="object")return Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" ");return e?String(e):""}function oa(e,t){if(!/:[\w-]+=/.test(e))return e;let r=e,s=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,i=[],a;while((a=s.exec(e))!==null)i.push([a.index,a.index+a[0].length]);i.push(...Wn(e));let c=new Set([...Ze(t),...Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]]);function f(S){return i.some(([x,g])=>S>=x&&S<g)}let l=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,h=[],v=new Map,y=256;while((a=l.exec(r))!==null){if(f(a.index))continue;let S=a[0],x=a[2];if(!x||!x.includes(":"))continue;let g=/(?:^|\s)data-native(?:\s|=|$)/i.test(x.replace(/"[^"]*"|'[^']*'/g,"")),b=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,w,R=x,P=!1;while((w=b.exec(x))!==null){if(cs(x,w.index,!0)?.kind==="attribute")continue;let k=w[1],E=w[2];if(lc(k))continue;if(ue(E,c))continue;if(E.includes("()")&&!E.includes(".get(")||E.includes("$store")||E.includes("$ref"))continue;try{let U=Object.keys(t),M=Object.values(t),L=E.match(/^([a-zA-Z_$][\w$]*)/);if(L&&!U.includes(L[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(L[1]))continue;let X=JSON.stringify([U,E]),N=v.get(X);if(!N){if(N=Function(...U,`return (${E})`),v.size>=y)v.clear();v.set(X,N)}let I=N(...M);if(k==="class"){let O=F(Ft(I));if(O){let B=R.match(/\sclass="([^"]*)"/);if(B)R=R.replace(B[0],()=>` class="${B[1]} ${O}"`);else R=R.replace(w[0],()=>` class="${O}"`)}else R=R.replace(w[0],"");P=!0;continue}if(zn.has(k)){if(I)R=R.replace(w[0],` ${k}`);else R=R.replace(w[0],"");P=!0;continue}if(I===null||I===void 0||I===!1)R=R.replace(w[0],"");else{let O=g&&typeof I==="object"?JSON.stringify(I):String(I),B=fn(k,O);R=R.replace(w[0],()=>` ${k}="${B}"`)}P=!0}catch(U){if(U instanceof le)throw U;continue}}if(P){let k=a[3]?" /":"",U=`<${a[1]}${R}${k}>`;h.push({start:a.index,end:a.index+S.length,replacement:U})}}if(h.length>0){let S=Array(h.length*2+1),x=0;for(let g=0;g<h.length;g++){let{start:b,end:w,replacement:R}=h[g];S[g*2]=r.slice(x,b),S[g*2+1]=R,x=w}S[h.length*2]=r.slice(x),r=S.join("")}return r}import Ht from"fs";import qt from"path";var Xt=!1;function Fn(e,t,r,s=!1,i=new Set){let a={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},c=new Set(Array.isArray(t.__stx_client_signal_names)?t.__stx_client_signal_names:[]),f=(y)=>{if(c.size===0)return!1;let S=o(y),x=S.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(x&&c.has(x))return!0;for(let g of c){let b=g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${b}\\s*\\(`).test(S))return!0}return!1},l=new Set(uc),h=(y)=>{if(!y.includes("-")||y.startsWith("@")||y.startsWith(":")||y.startsWith("x-")||y.startsWith("__"))return y;if(y.startsWith("aria-")||y.startsWith("data-"))return y;return y.replace(/-([a-z0-9])/g,(S,x)=>x.toUpperCase())},v=(y,S)=>{let x=h(y);if(a.static[x]=S,x!==y)a.staticNames[x]=y};for(let[y,S]of Object.entries(e)){let x=y.startsWith("x-")&&!l.has(y)&&!y.startsWith("x-bind:")&&!y.startsWith("x-on:")?`:${y.slice(2)}`:y;if(x.startsWith("@")){a.events[x]=S;continue}if(x.startsWith("__stx_")){let g=h(x.slice(6));a.serverDynamic[g]=Ut(S,r);continue}if(x.startsWith(":")){let g=h(x.slice(1)),b=S===ne?g:S;if(g==="if"||g==="for"||g==="show"){a.clientReactive[g]=b;continue}if(s){a.clientReactive[g]=b;continue}if(ue(b,i)){a.clientReactive[g]=b;continue}if(f(b)){a.clientReactive[g]=b;continue}try{if(!d(b)){if(r.debug)console.error(`Unsafe expression in :${g} binding: ${b}`);a.clientReactive[g]=b;continue}let w=Object.keys(t),R=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),P=new Set(Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[]);if(et(b).some((M)=>!R.has(M)&&!w.includes(M)&&(!(M in globalThis)||P.has(M)))){a.clientReactive[g]=b;continue}let U=u(b,w)(...Object.values(t));if(a.serverDynamic[g]=U,g!==x.slice(1)&&a.serverDynamicNames)a.serverDynamicNames[g]=x.slice(1)}catch{a.clientReactive[g]=b}continue}if(typeof S==="string"&&S.includes("{{")&&S.includes("}}")){let g=Hn(S,i);if(g!==null){a.clientReactive[h(x)]=g;continue}let b=S.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(b)try{let w=b[1];if(d(w)){let P=u(w,Object.keys(t))(...Object.values(t));v(x,P!=null?String(P):"")}else{if(r.debug)console.error(`Unsafe expression in ${x}: ${w}`);v(x,S)}}catch(w){if(r.debug)console.error(`Error evaluating expression for ${x}:`,w);v(x,S)}else{let w=S,R=/\{\{\s*([\s\S]+?)\s*\}\}/g,P;while((P=R.exec(S))!==null)try{let k=P[1];if(!d(k)){if(r.debug)console.error(`Unsafe expression in ${x}: ${k}`);continue}let U=u(k,Object.keys(t))(...Object.values(t));w=w.replace(P[0],String(U??""))}catch(k){if(r.debug)console.error(`Error evaluating expression in ${x}:`,k)}v(x,w)}continue}v(x,S===ne?"true":ot(S))}return a}function Hn(e,t){if(t.size===0)return null;let r=/\{\{\s*([\s\S]+?)\s*\}\}/g,s=[...e.matchAll(r)];if(!s.some((f)=>ue(f[1],t)))return null;let i=e.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(i&&s.length===1)return i[1];let a="",c=0;for(let f of s)a+=e.slice(c,f.index).replace(/[`\\$]/g,(l)=>`\\${l}`),a+=`\${${f[1]}}`,c=f.index+f[0].length;return a+=e.slice(c).replace(/[`\\$]/g,(f)=>`\\${f}`),`\`${a}\``}var qn=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function Xn(e,t,r){if(!e.includes("@"))return e;if(!qn.some(([i,a])=>i.test(e)&&e.includes(a)))return e;try{return ee(e,t,r)}catch{return e}}function ge(e){let t={},r=0,s=e.length;while(r<s){while(r<s&&/\s/.test(e[r]))r++;if(r>=s)break;let i="";while(r<s&&!/[\s=]/.test(e[r]))i+=e[r],r++;if(!i)break;while(r<s&&/\s/.test(e[r]))r++;if(r<s&&e[r]==="="){r++;while(r<s&&/\s/.test(e[r]))r++;let a="";if(r<s&&(e[r]==='"'||e[r]==="'")){let c=e[r];r++;while(r<s){let f=e[r];if(f==="\\"&&r+1<s){r++,a+=e[r],r++;continue}if(f===c){r++;break}a+=f,r++}}else if(e[r]==="{"){a=at(e,r),r+=a.length;let c=Wt(a);if(c!==null){t[`:${i}`]=c;continue}}else while(r<s&&!/\s/.test(e[r]))a+=e[r],r++;t[i]=a}else t[i]=ne}return t}function Zt(e){return Object.entries(e).map(([t,r])=>r===ne?t:`${t}="${Zn(r)}"`).join(" ")}function Zn(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Vn(e){let t=new Set,r=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,s;while((s=r.exec(e))!==null){let i=s[1];if(oe.isBuiltin(i))t.add(i)}return[...t].sort()}async function kl(e,t,r,s,i){if(!/import\s/.test(e))return e;if(!t.__importedComponents)t.__importedComponents=new Map;let a=t.__importedComponents,c=qt.dirname(r),f=[],l=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let y of e.matchAll(l)){let[S,x,g]=y,b=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,w=g,R,P=[];while((R=b.exec(g))!==null){let[k,E,U,M]=R,L=null,X=null;if(M.startsWith(".")||M.startsWith("/")){let O=qt.resolve(c,M);if(O.endsWith(".stx"))X=O;else{let B=`${O}.stx`;try{if(Ht.statSync(B).isFile())X=B}catch{try{if(Ht.statSync(O).isDirectory())L=O}catch{}}}}else L=os(M,c);if(!L&&!X)continue;let N=!1,I=(O,B)=>{a.set(O,B),a.set(O.toLowerCase(),B);let z=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();a.set(z,B),i.add(B)};if(U&&X)I(U,X),N=!0;else if(E){let O=E.slice(1,-1).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>{let V=z.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(V)return{source:V[1],local:V[2]};return{source:z,local:z}}),B=L?ss(L):null;for(let{source:z,local:V}of O){let D=null;if(X)D=X;else if(B)D=B.get(z)??B.get(z.toLowerCase())??B.get(z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(D)I(V,D),N=!0}}if(N)P.push({start:R.index,end:R.index+k.length})}if(P.length===0)continue;for(let k=P.length-1;k>=0;k--)w=w.slice(0,P[k].start)+w.slice(P[k].end);f.push({start:y.index,end:y.index+S.length,value:`<script${x}>${w}</script>`})}if(f.length===0)return e;let h=[],v=0;for(let y of f)h.push(e.slice(v,y.start),y.value),v=y.end;return h.push(e.slice(v)),h.join("")}async function Gn(e,t,r,s,i){let a=e;if(!t.__importedComponents)t.__importedComponents=new Map;let c=t.__importedComponents,f=/@import\s*\(\s*([^)]+)\s*\)/g,l;while((l=f.exec(a))!==null){let[h,v]=l,y=v.split(",").map((S)=>S.trim().replace(/^['"]|['"]$/g,"")).filter((S)=>S.length>0);for(let S of y){let x=S.split("/"),b=x[x.length-1].replace(/\.stx$/,""),w=b.includes("-")?b.split("-").map((k)=>k.charAt(0).toUpperCase()+k.slice(1)).join(""):b.charAt(0).toUpperCase()+b.slice(1),R=null,P=is(S,r,s);for(let k of P)try{if(await Bun.file(k).exists()){R=k;break}}catch{}if(R){c.set(w,R),c.set(b,R),c.set(b.toLowerCase(),R);let k=w.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(c.set(k,R),i.add(R),s.debug)console.log(`Imported component: ${w} -> ${R}`)}else if(s.debug)console.warn(`Could not resolve imported component: ${S}`)}a=a.replace(h,""),f.lastIndex=0}return a}async function Kn(e,t,r,s,i){let a=e,c=s.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let f=t.__processedComponents,l=/@component\s*\(/g,h;while((h=l.exec(a))!==null){let v=h.index,y=v+h[0].length-1,S=1,x=y+1;while(x<a.length&&S>0){if(a[x]==="(")S++;else if(a[x]===")"){if(S--,S===0)break}x++}if(S!==0)break;let g=a.substring(y+1,x),b=x+1,w=g.match(/^\s*['"]([^'"]+)['"]/);if(!w){l.lastIndex=0;continue}let R=w[1],P,k=g.slice(w[0].length),E=k.match(/^\s*,\s*/);if(E)P=k.slice(E[0].length).trim();let U={};if(P)try{U=C(P,t)}catch(O){let B=O instanceof Error?O.message:String(O);a=a.replace(a.substring(v,b),`[Error parsing component props: ${B}]`);continue}let M="",L=b,N=a.substring(b).match(/^([\s\S]*?)@endcomponent/);if(N)M=N[1].trim(),L=b+N[0].length;let I=await Me(R,U,M,c,t,r,s,f,i);a=a.substring(0,v)+I+a.substring(L),l.lastIndex=0}return a}async function Jn(e,t,r,s,i){if(!e)return e;let a=e,c=s.componentsDir||"components";if(!t.__processedComponents)t.__processedComponents=new Set;let f=t.__processedComponents,l=er(a);if(l.size>0){let b=Array.isArray(t.__stx_client_declared_names)?t.__stx_client_declared_names:[];t.__stx_client_declared_names=[...new Set([...b,...l])]}let h=q(a);a=h.output;let v=Ze(t);return a=await g(a,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),a=await g(a,/[A-Z][a-zA-Z0-9]*/,!0,Lt(ir)),a=await g(a,/[a-z][a-z0-9]*/,!1,ir),a=h.restore(a),a;async function g(b,w,R,P){if(!b)return b;let k=b,E=zt(k,w,P),U=ct(k),M=new Map;for(let N=E.length-1;N>=0;N--){let I=E[N],O=R?j(I.tagName):I.tagName,B=ge(Xn(I.attributes,t,r)),z=U.filter(({start:Z,end:_})=>I.startIndex>=Z&&I.startIndex<_),V=z.length>0,D=new Set(v);for(let Z of z)for(let _ of Z.names)D.add(_);let W=Fn(B,t,s,V,D);if(typeof W.clientReactive.for==="string")for(let Z of Tt(W.clientReactive.for))D.add(Z);let ie=oe.getBuiltin(I.tagName),ve=ie?await lr(I.tagName,c,t,r,s):!1;if(ie&&!ve){let Z={context:t,filePath:r,options:s,dependencies:i},_=ie.render(W,I.content,Z);if(Object.keys(W.events).length>0){let H=Zt(W.events);_=_.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${H}`)}if(Object.keys(W.clientReactive).length>0)_=Vt(_,W.clientReactive);M.set(N,_);continue}if(!R&&I.tagName.includes("-")&&!await lr(O,c,t,r,s))continue;let K={};for(let[Z,_]of Object.entries(W.static))K[Z]=_;for(let[Z,_]of Object.entries(W.serverDynamic))K[Z]=_;let te={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(W.clientReactive),events:Object.keys(W.events)},T=await Me(O,K,h.restore(I.content),c,t,r,s,f,i,[...D],te,I.tagName);if(T=Yn(T,W,te.declaredProps,te.consumedProps,s._nativeHostAttrs),s._nativeHostAttrs){let Z=te.reactiveProps.filter((Q)=>!te.consumedProps.has(Q)&&!["if","for","show","key","ref"].includes(Q)).map(j),_=lt(T,!0);if(Z.length&&_){if(!Object.hasOwn(ge(T.slice(_.insertPos,_.tagEnd)),"data-stx-native-host-root"))T=T.slice(0,_.insertPos)+' data-stx-native-host-root="true"'+T.slice(_.insertPos);let Q=be(T);T=T.slice(0,Q.insertPos)+` data-stx-native-forward="${Z.join(" ")}"`+T.slice(Q.insertPos)}let H=lt(T,!0);if(H){let Q=ge(T.slice(H.insertPos,H.tagEnd)),$e=be(T),Kt=ge(T.slice($e.insertPos,$e.tagEnd));if(Object.hasOwn(Q,"data-stx-native-host-root")&&!Object.hasOwn(Kt,"data-stx-native-host-owner"))T=T.slice(0,$e.insertPos)+" data-stx-native-host-owner"+T.slice($e.insertPos)}}if(Object.keys(W.events).length>0){let Z=be(T);if(Z){let _=Zt(W.events),H=Object.keys(W.events).map((Q)=>Q.replace(/^@/,"").split(".")[0]).join(" ");T=T.substring(0,Z.insertPos)+` data-stx-parent-events="${H}" ${_}`+T.substring(Z.insertPos)}}if(Object.keys(W.clientReactive).length>0)T=Vt(T,W.clientReactive);M.set(N,T)}if(M.size===0)return k;let L="",X=0;for(let N=0;N<E.length;N++){let I=M.get(N);if(I===void 0)continue;L+=k.slice(X,E[N].startIndex),L+=I,X=E[N].endIndex}return L+=k.slice(X),L}}function Vt(e,t){let r=new Set(["if","for"]),s=new Set(["show"]),i=Object.entries(t).filter(([v])=>!r.has(v)),a=i.filter(([v])=>!s.has(v)).map(([v])=>j(v)).join(" "),c=e,f=i.length>0?be(c):null;if(f){let v=i.map(([S,x])=>`:${j(S)}="${x.replace(/"/g,""")}"`).join(" "),y=a?` data-stx-parent-bindings="${a}"`:"";c=c.substring(0,f.insertPos)+`${y} ${v}`+c.substring(f.insertPos)}let l=t.if;if(l)c=`<template :if="${l.replace(/"/g,""")}">${c}</template>`;let h=t.for;if(h)c=`<template :for="${h.replace(/"/g,""")}">${c}</template>`;return c}function Yn(e,t,r=new Set,s=new Set,i=!1){let a=lt(e,i);if(!a)return e;let c=e.slice(a.insertPos,a.tagEnd),f=t.serverDynamic.class??t.static.class;if(i&&typeof f==="string"&&f&&!s.has("class")){let g=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,b=g.test(c)?c.replace(g,(w,R,P,k,E)=>`${R}class="${A(`${ot(P??k??E)} ${f}`)}"`):` class="${A(f)}"${c}`;e=e.slice(0,a.insertPos)+b+e.slice(a.tagEnd),a.tagEnd+=b.length-c.length,c=b}let l=i||/\bdata-native(?:\s|=)/i.test(c),h=l?s:r,v=new Set(Object.keys(ge(c))),y=new Set(["class","className"]);for(let g of Object.keys(t.static)){let b=t.staticNames[g]??g;if(v.has(b)||h.has(g)||!l&&!We(b))y.add(g)}for(let g of Object.keys(t.serverDynamic)){let b=t.serverDynamicNames?.[g]??g;if(v.has(b)||h.has(g)||!l&&!We(b))y.add(g)}let S=[];if(l){for(let[g,b]of Object.entries(t.static)){if(y.has(g)||b!==!0&&b!==ne)continue;y.add(g),S.push(`${A(t.staticNames?.[g]??g)}="true"`)}for(let[g,b]of Object.entries(t.serverDynamic)){if(y.has(g)||b!==!0)continue;y.add(g),S.push(`${A(t.serverDynamicNames?.[g]??g)}="true"`)}}let x=[...re(t,y),...se(t,y),...S];if(l){for(let[g,b]of Object.entries(t.serverDynamic)){if(y.has(g)||b!==!1)continue;let w=t.serverDynamicNames?.[g]??g;x.push(`${A(w)}="false"`)}for(let[g,b]of Object.entries(t.serverDynamic)){if(y.has(g)||b===null||typeof b!=="object")continue;let w=JSON.stringify(b);if(w!==void 0){let R=t.serverDynamicNames?.[g]??g;x.push(`${A(R)}="${A(w)}"`)}}}if(x.length===0)return e;return`${e.slice(0,a.insertPos)} ${x.join(" ")}${e.slice(a.insertPos)}`}function be(e){let t=Gt(e,0);if(t)return t;let r=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(e);if(r)return{insertPos:r.index+1+r[1].length,tagEnd:ut(e,r.index+1+r[1].length)};return null}function lt(e,t=!1){let r=be(e);if(!r)return null;let s=e.slice(r.insertPos,r.tagEnd),i=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(s)?Gt(e,r.tagEnd+1):r;return i&&t?Qn(e,i)??i:i}function Qn(e,t){if(!e.includes("data-stx-native-host-root"))return null;let r=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),s=e.lastIndexOf("<",t.insertPos),i=0,a;while(s>=0&&s<e.length){if(e.startsWith("<!--",s)){let v=e.indexOf("-->",s+4);if(v<0)return null;s=e.indexOf("<",v+3);continue}let c=/^<(\/?)([a-z][\w-]*)\b/i.exec(e.slice(s));if(!c){s=e.indexOf("<",s+1);continue}let f=c[2].toLowerCase(),l=s+c[0].length,h=ut(e,l);if(c[1]){if(i--,a!==void 0&&i<a)a=void 0;if(i<=0)return null}else if(f==="script"||f==="style"){let v=new RegExp(`</${f}\\s*>`,"gi");if(v.lastIndex=h+1,!v.exec(e))return null;s=e.indexOf("<",v.lastIndex);continue}else{let v=ge(e.slice(l,h)),y=i>0&&(Object.hasOwn(v,"data-stx-component-wrapper")||Object.hasOwn(v,"data-stx-native-host-owner"));if(a===void 0&&!y&&Object.hasOwn(v,"data-stx-native-host-root"))return{insertPos:l,tagEnd:h};if(!r.has(f)&&e[h-1]!=="/"){if(i++,a===void 0&&y)a=i}else if(i===0)return null}s=e.indexOf("<",h+1)}return null}function Gt(e,t){let r=t;while(r<e.length){let s=e.slice(r),i=s.match(/^\s+/);if(i){r+=i[0].length;continue}if(s.startsWith("<!--")){let f=e.indexOf("-->",r+4);if(f===-1)return null;r=f+3;continue}let a=s.match(/^<(script|style)\b[^>]*>/i);if(a){let f=`</${a[1].toLowerCase()}>`,l=e.toLowerCase().indexOf(f,r+a[0].length);if(l===-1)return null;r=l+f.length;continue}let c=s.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!c)return null;return{insertPos:r+1+c[1].length,tagEnd:ut(e,r+1+c[1].length)}}return null}function ut(e,t){let r="";for(let s=t;s<e.length;s++){let i=e[s];if(r){if(i==="\\")s++;else if(i===r)r=""}else if(i==='"'||i==="'")r=i;else if(i===">")return s}return e.length}function er(e){let t=new Set;for(let r of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let s=r[1];if(!/\bclient\b/.test(s)||/\bserver\b/.test(s))continue;for(let i of To(r[2]))t.add(i);for(let i of r[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(i[1])t.add(i[1]);if(i[3])t.add(i[3]);for(let a of(i[2]??"").split(",")){let c=a.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(c))t.add(c)}}}return t}async function Br(e,t,r,s,i){if(!Xt)Dt(oe),Xt=!0;let a=await kl(e,t,r,s,i);a=await Gn(a,t,r,s,i),a=await Kn(a,t,r,s,i);let c=[];for(let f=0;f<3;f++){let l=c.length,h=ce(a,Ae,(y,S)=>`\x00STX_COMPONENT_COMMENT_${l+S}\x00`,`STX_COMPONENT_COMMENT:${l}`);c.push(...h.tokens);let v=a;if(a=await Jn(h.output,t,r,s,i),a===v)break}if(c.length>0)a=a.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(f,l)=>c[Number(l)]??"");if(s.debug){let f=Vn(a);if(f.length>0)console.warn(`[stx] ${r}: unresolved component tag(s) after render passes: ${f.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return a}
|
|
42
42
|
export{Qs,eo,to,dp,jr,pp,oa,kl,Br};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{f,g,m}from"./chunk-
|
|
2
|
+
import{f,g,m}from"./chunk-zsgcsqat.js";import{N}from"./chunk-3q163st5.js";import{s}from"./chunk-pbtkbe48.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let r=n[1],i=n[2];t.push({type:"suspense",name:r,content:i}),o=n.index+n[0].length}if(o<e.length){let r=e.slice(o);if(r.trim())t.push({type:t.length===0?"shell":"content",content:r})}if(t.length===0)t.push({type:"shell",content:e});return t}async function rd(e,t={},o={}){let n={...N,...o,streaming:{...q,...o.streaming}},r=n.streaming?.bufferSize||16384;return new ReadableStream({async start(i){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),p=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),h={...t,__filename:e,__dirname:k.dirname(e)};if(p.trim())await f(p,h,e);let E=H(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await s(c,h,e,n,l);for(let b=0;b<u.length;b+=r)i.enqueue(u.slice(b,b+r)),await new Promise((y)=>setTimeout(y,0))}else{let u=[],b=new RegExp(T.source,"g"),y;while((y=b.exec(c))!==null)u.push({name:y[1],content:y[2],start:y.index,end:y.index+y[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await s(I,h,e,n,l);i.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await s(_.content,h,e,n,l);i.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await s(_,h,e,n,l);i.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await s(d.content,h,e,n,l);i.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;i.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
4
|
</div>`),w.set(d.name,s(d.content,h,e,n,l))}i.enqueue(`
|
|
5
5
|
<script>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{mo,ho,yo,bo,Xr,Jr,kp,_p,Cp,Ep,Yr,Tp}from"./chunk-
|
|
2
|
+
import{mo,ho,yo,bo,Xr,Jr,kp,_p,Cp,Ep,Yr,Tp}from"./chunk-p44kmbdg.js";import"./chunk-55zaxb4s.js";export{Tp as generateDefaultRobotsTxt,Yr as generateRobotsTxt,_p as generateSitemap,Cp as generateSitemapIndex,bo as injectSeoTags,Xr as metaDirective,mo as processMetaDirectives,yo as processSeoDirective,ho as processStructuredData,kp as registerSeoDirectives,Ep as scanForSitemapEntries,Jr as structuredDataDirective};
|
|
@@ -17,7 +17,7 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
17
17
|
`)}function gt(e,n,r){let i=e.split(`
|
|
18
18
|
`),s=Math.max(0,n-r-1),o=Math.min(i.length-1,n+r-1),c="\x1B[90m",g="\x1B[31m",f="\x1B[0m",p=[];for(let h=s;h<=o;h++){let m=(h+1).toString().padStart(4),y=h===n-1,b=y?"\x1B[31m>\x1B[0m":" ",S=y?`\x1B[31m${i[h]}\x1B[0m`:`\x1B[90m${i[h]}\x1B[0m`;p.push(`${b}\x1B[90m${m}\x1B[0m | ${S}`)}return p.join(`
|
|
19
19
|
`)}function de(e){return e.replace(/--/g,"- -").replace(/>/g,">")}function pt(e,n){let i=e.substring(0,n).split(`
|
|
20
|
-
`);return{line:i.length,column:i[i.length-1].length}}function a(e,n,r){return me({type:e,message:n,code:r,format:"html"}).formatted}async function
|
|
20
|
+
`);return{line:i.length,column:i[i.length-1].length}}function a(e,n,r){return me({type:e,message:n,code:r,format:"html"}).formatted}async function ve(e,n,r){try{return await e()}catch(i){if(r&&i instanceof Error)r(i);return n}}var zo={isEnabled(){return N().enableAutoRecovery},fixCommonSyntaxErrors(e){let n=N();if(!n.enableAutoRecovery)return{fixed:e,fixes:[]};let r=e,i=[],s=(r.match(/\{\{/g)||[]).length,o=(r.match(/\}\}/g)||[]).length;if(s>o){let g=s-o;r+="}}".repeat(g),i.push(`Added ${g} missing closing braces '}}'`)}let c=["if","foreach","for","switch","section"];for(let g of c){let f=(r.match(new RegExp(`@${g}\\b`,"g"))||[]).length,p=(r.match(new RegExp(`@end${g}\\b`,"g"))||[]).length;if(f>p){let h=f-p;for(let m=0;m<h;m++)r+=`
|
|
21
21
|
@end${g}`;i.push(`Added ${h} missing @end${g}`)}}if(i.length>0&&n.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),i.forEach((g)=>console.warn(` - ${g}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:r,fixes:i}},createFallbackContent(e,n){if(H())return`<!-- ${e} failed: ${n.message} -->`;return"<!-- stx rendering error -->"}};class J{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor(e={}){this.maxErrors=e.maxErrors??1000,this.enableFileLogging=e.enableFileLogging??!1,this.logFilePath=e.logFilePath??".stx/errors.log",this.logFormat=e.logFormat??"json",this.maxFileSize=e.maxFileSize??10485760,this.maxLogFiles=e.maxLogFiles??5,this.minLevel=e.minLevel??"all"}configure(e){if(e.maxErrors!==void 0)this.maxErrors=e.maxErrors;if(e.enableFileLogging!==void 0)this.enableFileLogging=e.enableFileLogging;if(e.logFilePath!==void 0)this.logFilePath=e.logFilePath;if(e.logFormat!==void 0)this.logFormat=e.logFormat;if(e.maxFileSize!==void 0)this.maxFileSize=e.maxFileSize;if(e.maxLogFiles!==void 0)this.maxLogFiles=e.maxLogFiles;if(e.minLevel!==void 0)this.minLevel=e.minLevel}log(e,n,r="error"){let i={timestamp:new Date,error:e,context:n,level:r};if(this.errors.push(i),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(r))this.writeToFile(i)}shouldLog(e){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return e==="error"||e==="warning";if(this.minLevel==="error")return e==="error";return!0}formatEntry(e){if(this.logFormat==="json")return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level||"error",type:e.error.constructor.name,message:e.error.message,stack:e.error.stack,context:e.context});let n=[`[${e.timestamp.toISOString()}] [${(e.level||"error").toUpperCase()}] ${e.error.constructor.name}: ${e.error.message}`];if(e.error.stack)n.push(` Stack: ${e.error.stack.split(`
|
|
22
22
|
`).slice(1).join(`
|
|
23
23
|
`)}`);if(e.context)n.push(` Context: ${JSON.stringify(e.context)}`);return n.join(`
|
|
@@ -25,7 +25,7 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
25
25
|
`;n.appendFileSync(this.logFilePath,s,"utf-8")}catch(n){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",n)}})}async rotateIfNeeded(e){try{if(!e.existsSync(this.logFilePath))return;if(e.statSync(this.logFilePath).size<this.maxFileSize)return;for(let r=this.maxLogFiles-1;r>=1;r--){let i=`${this.logFilePath}.${r}`,s=`${this.logFilePath}.${r+1}`;if(e.existsSync(i))if(r>=this.maxLogFiles-1)e.unlinkSync(i);else e.renameSync(i,s)}if(this.maxLogFiles<=1)e.writeFileSync(this.logFilePath,"");else e.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(n){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",n)}}getRecentErrors(e=10){return this.errors.slice(-e)}getErrorsByType(e){return this.errors.filter((n)=>n.error.constructor.name===e)}getErrorsByLevel(e){return this.errors.filter((n)=>n.level===e)}clear(){this.errors.length=0}async clearLogFile(){try{let e=await import("fs");if(e.existsSync(this.logFilePath))e.writeFileSync(this.logFilePath,"","utf-8")}catch(e){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",e)}}getStats(){let e={},n={error:0,warning:0,info:0};for(let r of this.errors){let i=r.error.constructor.name;e[i]=(e[i]||0)+1;let s=r.level||"error";n[s]=(n[s]||0)+1}return{total:this.errors.length,byType:e,byLevel:n}}async exportToFile(e,n="json"){let r=await import("fs"),i=await import("path"),s=i.dirname(e);if(!r.existsSync(s))r.mkdirSync(s,{recursive:!0});if(n==="json"){let o=this.errors.map((c)=>({timestamp:c.timestamp.toISOString(),level:c.level||"error",type:c.error.constructor.name,message:c.error.message,stack:c.error.stack,context:c.context}));r.writeFileSync(e,JSON.stringify(o,null,2),"utf-8")}else{let o=this.errors.map((c)=>this.formatEntry(c));r.writeFileSync(e,o.join(`
|
|
26
26
|
|
|
27
27
|
`),"utf-8")}}async flush(){await this.writeQueue}}var D=new J,hn={isDevelopment(){return H()},logDetailedError(e,n){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",e.message),console.error("Stack:",e.stack),n)console.error("Context:",n);console.error("========================")},createErrorReport(e,n){let r=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${e.message}`,`Type: ${e.constructor.name}`,`Stack: ${e.stack}`];if(n)r.push(`Context: ${JSON.stringify(n,null,2)}`);return r.push("========================"),r.join(`
|
|
28
|
-
`)}};function w(e,n,r,i=0){let s=0,o=i,c=null,g=0,f=!1;while(o<e.length){let p=e[o];if(c&&f){f=!1,o++;continue}if(c&&p==="\\"){f=!0,o++;continue}if(f=!1,(p==='"'||p==="'"||p==="`")&&!c){c=p,o++;continue}if(p===c&&c!=="`"){c=null,o++;continue}if(c==="`"&&p==="$"&&e[o+1]==="{"){g++,o+=2;continue}if(g>0&&p==="}"){g--,o++;continue}if(p==="`"&&c==="`"&&g===0){c=null,o++;continue}if(c){o++;continue}if(p===n)s++;else if(p===r){if(s--,s===0)return o}o++}return-1}var ft={maxSanitizeDepth:10,allowBracketNotation:!1},Se={...ft};var j=/\bnew\s+/,B="__stx_safe_ctors",ke=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],Z=[...ke,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],he=Z.map(()=>{return}),Q=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is})),te=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,j,/\bdelete\s+/,/\bthis\b/,/\\u(?:\{[\dA-Fa-f]+\}|[\dA-Fa-f]{4})/],re=new Set([...ke,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",B]),ie=new Set(["__proto__","constructor","prototype"]);function $e(e){let n="",r=[],i=null,s=!1;for(let o=0;o<e.length;o++){let c=e[o];if(s){s=!1;continue}if(c==="\\"&&i){s=!0;continue}if(i){if(i==="`"&&c==="$"&&o+1<e.length&&e[o+1]==="{"){let g=1;o+=2;while(o<e.length&&g>0){if(e[o]==="{")g++;else if(e[o]==="}")g--;if(g>0)n+=e[o],r.push(o),o++}continue}if(c===i)i=null;continue}if(c==='"'||c==="'"||c==="`"){i=c;continue}n+=c,r.push(o)}return{text:n,map:r}}function Re(e){return $e(e).text}var Ce=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],Ae=(()=>{let e={Date,URL,URLSearchParams},n=Intl;for(let r of Ce)if(typeof n[r]==="function")e[`Intl_${r}`]=n[r];return Object.freeze(Object.assign(Object.create(null),e))})(),dt=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,ye=/(?<![\w$])new(?![\w$])/g,Ee=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Ce.join(",")}}() are allowed`;function mt(e){let{text:n,map:r}=$e(e),i=[];ye.lastIndex=0;let s;while((s=ye.exec(n))!==null){let c=s.index;if(/(?<!\.)\.\s*$/.test(n.slice(0,c)))continue;let g=dt.exec(n.slice(c)),f=g?.[3],p=!g?null:f?`Intl_${f}`:g[2];if(!g||!p||!(p in Ae))throw new k(`matched /${j.source}/; ${Ee}`,e);let h=c+g[0].length,m=r[c],y=r[h-1]+1;if(e.slice(m,y)!==n.slice(c,h))throw new k(`matched /${j.source}/; ${Ee}`,e);let b=m+3+g[1].length;i.push({start:b,end:b+g[2].length,key:p})}let o=e;for(let c=i.length-1;c>=0;c--){let g=i[c];o=`${o.slice(0,g.start)}${B}.${g.key}${o.slice(g.end)}`}return{source:o,usesSafeConstructors:i.length>0}}class k extends Error{rule;expression;constructor(e,n,r){super(r??`Potentially unsafe expression (${e}): ${n}`);this.name="UnsafeExpressionError",this.rule=e,this.expression=n}}function bs(e){try{return se(e),null}catch(n){return n instanceof k?n.rule:n instanceof Error?n.message:String(n)}}function Te(e,n){let r=/[$A-Z_a-z][$\w]*/g,i;while((i=r.exec(e))!==null){let s=i[0],o=e[i.index-1];if(re.has(s))throw new k(`matched /\\b${s}\\b/; identifier ${s}`,n);if(o==="."&&ie.has(s))throw new k(`matched /.${s}/; property ${s}`,n)}}function _e(e,n=!0){let r=/(?:[$\w)\].]|\?\.)\s*\[([^\]]*)\]/g,i=new Set,s;while((s=r.exec(e))!==null){let o=s.index+s[0].indexOf("["),c=e.slice(0,o);if(/(?:^|[^$\w])(?:let|const|var)\s*$/.test(c))continue;let g=s[1].trim(),f=/^'(?:[^'\\]|\\.)*'$/.test(g),p=/^"(?:[^"\\]|\\.)*"$/.test(g);if(/^\d+$/.test(g))continue;if(f||p){let m=g.slice(1,-1);if(ie.has(m))throw new k(`bracket key ${m}`,e);if(!Se.allowBracketNotation)throw new k("bracket notation with a string key; enable with configureSafeEvaluator({ allowBracketNotation: true })",e,`Bracket notation with strings not allowed: ${e}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);continue}if(n&&/^[$A-Z_a-z][$\w]*$/.test(g)){i.add(g);continue}throw new k("dynamic bracket notation is not allowed",e)}return[...i]}function se(e){let n=e.trim(),r=Re(n);Te(r,n);let i=_e(n);for(let s of te){if(s===j)continue;if(s.test(r))throw new k(`matched /${s.source}/`,n)}return{...mt(n),dynamicKeys:i}}function Fo(e){return se(e),e.trim()}var vs=Symbol("stx.sanitizeCache");function U(e){let n={},r=e[vs];n.Math=Math,n.JSON=JSON,n.Date=Date,n.String=String,n.Number=Number,n.Boolean=Boolean,n.Array=Array,n.Object=Q,n.parseInt=Number.parseInt,n.parseFloat=Number.parseFloat,n.isNaN=Number.isNaN,n.isFinite=Number.isFinite,n.encodeURIComponent=encodeURIComponent,n.decodeURIComponent=decodeURIComponent;for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||te.some((o)=>o.test(i)))continue;if(s&&typeof s==="object"&&!Array.isArray(s)){let o=r?.get(s);if(o===void 0)o=ee(s),r?.set(s,o);n[i]=o}else n[i]=s}return n}function ee(e,n=0){if(n>=Se.maxSanitizeDepth)return"[Object too deep]";if(e===null||typeof e!=="object")return e;if(Array.isArray(e))return e.map((i)=>ee(i,n+1));if(e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error)return e;let r={};for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||i==="constructor"||i==="prototype")continue;if(s&&typeof s==="object")r[i]=ee(s,n+1);else r[i]=s}return r}function l(e,n){try{let r=U(n),i=Object.keys(r),s=Object.values(r);return u(e,i)(...s)}catch{return}}function d(e){try{return Fo(e),!0}catch{return!1}}function Qa(e,n){try{let r=U(n),i=Object.keys(r),s=Object.values(r),o=!1,g=u(e,i,()=>{o=!0})(...s);return!o&&Boolean(g)}catch{return!1}}function C(e,n){try{let r=l(e,n);if(r&&typeof r==="object"&&!Array.isArray(r))return r;return{}}catch{return{}}}var Ie=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]),ht=2000,F=new Map;function
|
|
28
|
+
`)}};function w(e,n,r,i=0){let s=0,o=i,c=null,g=0,f=!1;while(o<e.length){let p=e[o];if(c&&f){f=!1,o++;continue}if(c&&p==="\\"){f=!0,o++;continue}if(f=!1,(p==='"'||p==="'"||p==="`")&&!c){c=p,o++;continue}if(p===c&&c!=="`"){c=null,o++;continue}if(c==="`"&&p==="$"&&e[o+1]==="{"){g++,o+=2;continue}if(g>0&&p==="}"){g--,o++;continue}if(p==="`"&&c==="`"&&g===0){c=null,o++;continue}if(c){o++;continue}if(p===n)s++;else if(p===r){if(s--,s===0)return o}o++}return-1}var ft={maxSanitizeDepth:10,allowBracketNotation:!1},Se={...ft};var j=/\bnew\s+/,B="__stx_safe_ctors",ke=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],Z=[...ke,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],he=Z.map(()=>{return}),Q=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is})),te=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,j,/\bdelete\s+/,/\bthis\b/,/\\u(?:\{[\dA-Fa-f]+\}|[\dA-Fa-f]{4})/],re=new Set([...ke,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",B]),ie=new Set(["__proto__","constructor","prototype"]);function $e(e){let n="",r=[],i=null,s=!1;for(let o=0;o<e.length;o++){let c=e[o];if(s){s=!1;continue}if(c==="\\"&&i){s=!0;continue}if(i){if(i==="`"&&c==="$"&&o+1<e.length&&e[o+1]==="{"){let g=1;o+=2;while(o<e.length&&g>0){if(e[o]==="{")g++;else if(e[o]==="}")g--;if(g>0)n+=e[o],r.push(o),o++}continue}if(c===i)i=null;continue}if(c==='"'||c==="'"||c==="`"){i=c;continue}n+=c,r.push(o)}return{text:n,map:r}}function Re(e){return $e(e).text}var Ce=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],Ae=(()=>{let e={Date,URL,URLSearchParams},n=Intl;for(let r of Ce)if(typeof n[r]==="function")e[`Intl_${r}`]=n[r];return Object.freeze(Object.assign(Object.create(null),e))})(),dt=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,ye=/(?<![\w$])new(?![\w$])/g,Ee=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Ce.join(",")}}() are allowed`;function mt(e){let{text:n,map:r}=$e(e),i=[];ye.lastIndex=0;let s;while((s=ye.exec(n))!==null){let c=s.index;if(/(?<!\.)\.\s*$/.test(n.slice(0,c)))continue;let g=dt.exec(n.slice(c)),f=g?.[3],p=!g?null:f?`Intl_${f}`:g[2];if(!g||!p||!(p in Ae))throw new k(`matched /${j.source}/; ${Ee}`,e);let h=c+g[0].length,m=r[c],y=r[h-1]+1;if(e.slice(m,y)!==n.slice(c,h))throw new k(`matched /${j.source}/; ${Ee}`,e);let b=m+3+g[1].length;i.push({start:b,end:b+g[2].length,key:p})}let o=e;for(let c=i.length-1;c>=0;c--){let g=i[c];o=`${o.slice(0,g.start)}${B}.${g.key}${o.slice(g.end)}`}return{source:o,usesSafeConstructors:i.length>0}}class k extends Error{rule;expression;constructor(e,n,r){super(r??`Potentially unsafe expression (${e}): ${n}`);this.name="UnsafeExpressionError",this.rule=e,this.expression=n}}function bs(e){try{return se(e),null}catch(n){return n instanceof k?n.rule:n instanceof Error?n.message:String(n)}}function Te(e,n){let r=/[$A-Z_a-z][$\w]*/g,i;while((i=r.exec(e))!==null){let s=i[0],o=e[i.index-1];if(re.has(s))throw new k(`matched /\\b${s}\\b/; identifier ${s}`,n);if(o==="."&&ie.has(s))throw new k(`matched /.${s}/; property ${s}`,n)}}function _e(e,n=!0){let r=/(?:[$\w)\].]|\?\.)\s*\[([^\]]*)\]/g,i=new Set,s;while((s=r.exec(e))!==null){let o=s.index+s[0].indexOf("["),c=e.slice(0,o);if(/(?:^|[^$\w])(?:let|const|var)\s*$/.test(c))continue;let g=s[1].trim(),f=/^'(?:[^'\\]|\\.)*'$/.test(g),p=/^"(?:[^"\\]|\\.)*"$/.test(g);if(/^\d+$/.test(g))continue;if(f||p){let m=g.slice(1,-1);if(ie.has(m))throw new k(`bracket key ${m}`,e);if(!Se.allowBracketNotation)throw new k("bracket notation with a string key; enable with configureSafeEvaluator({ allowBracketNotation: true })",e,`Bracket notation with strings not allowed: ${e}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);continue}if(n&&/^[$A-Z_a-z][$\w]*$/.test(g)){i.add(g);continue}throw new k("dynamic bracket notation is not allowed",e)}return[...i]}function se(e){let n=e.trim(),r=Re(n);Te(r,n);let i=_e(n);for(let s of te){if(s===j)continue;if(s.test(r))throw new k(`matched /${s.source}/`,n)}return{...mt(n),dynamicKeys:i}}function Fo(e){return se(e),e.trim()}var vs=Symbol("stx.sanitizeCache");function U(e){let n={},r=e[vs];n.Math=Math,n.JSON=JSON,n.Date=Date,n.String=String,n.Number=Number,n.Boolean=Boolean,n.Array=Array,n.Object=Q,n.parseInt=Number.parseInt,n.parseFloat=Number.parseFloat,n.isNaN=Number.isNaN,n.isFinite=Number.isFinite,n.encodeURIComponent=encodeURIComponent,n.decodeURIComponent=decodeURIComponent;for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||te.some((o)=>o.test(i)))continue;if(s&&typeof s==="object"&&!Array.isArray(s)){let o=r?.get(s);if(o===void 0)o=ee(s),r?.set(s,o);n[i]=o}else n[i]=s}return n}function ee(e,n=0){if(n>=Se.maxSanitizeDepth)return"[Object too deep]";if(e===null||typeof e!=="object")return e;if(Array.isArray(e))return e.map((i)=>ee(i,n+1));if(e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error)return e;let r={};for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||i==="constructor"||i==="prototype")continue;if(s&&typeof s==="object")r[i]=ee(s,n+1);else r[i]=s}return r}function l(e,n){try{let r=U(n),i=Object.keys(r),s=Object.values(r);return u(e,i)(...s)}catch{return}}function d(e){try{return Fo(e),!0}catch{return!1}}function Qa(e,n){try{let r=U(n),i=Object.keys(r),s=Object.values(r),o=!1,g=u(e,i,()=>{o=!0})(...s);return!o&&Boolean(g)}catch{return!1}}function C(e,n){try{let r=l(e,n);if(r&&typeof r==="object"&&!Array.isArray(r))return r;return{}}catch{return{}}}var Ie=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]),ht=2000,F=new Map;function be(e,n){let r=`${e.join(",")}\x00${n}`,i=F.get(r);if(i)return i;let s=Function(...e,n);if(F.size>=ht)F.clear();return F.set(r,s),s}function et(e){return e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g,"$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g)||[]}var yt=/^[A-Za-z_$][\w$]*$/;function Nt(e){return yt.test(e)&&!Ie.has(e)}function u(e,n,r){let{source:i,usesSafeConstructors:s,dynamicKeys:o}=se(e),c=[];for(let m=0;m<n.length;m++){if(!Nt(n[m]))continue;if(n[m]===B||n[m]==="Object"||re.has(n[m]))continue;c.push({key:n[m],index:m})}c.sort((m,y)=>m.key.localeCompare(y.key));let g=c.map((m)=>m.key),f=c.map((m)=>m.index),p=`
|
|
29
29
|
'use strict';
|
|
30
30
|
try {
|
|
31
31
|
return ${i};
|
|
@@ -36,9 +36,9 @@ catch (e) {
|
|
|
36
36
|
}
|
|
37
37
|
throw e;
|
|
38
38
|
}
|
|
39
|
-
`;return Et(bt(s?(m)=>{let y=
|
|
40
|
-
`:c==="t"?"\t":c;continue}if(o===r)return null;if(r==="`"&&o==="$"&&n[s+1]==="{")return null;i+=o}return i}var xt=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Lt(e,n){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:t.INVALID_DIRECTIVE_SYNTAX};let i=bs(r);if(i)return{ok:!1,message:`the expression is not allowed (${i})`,code:t.UNSAFE_EXPRESSION};let s=U(n),o;try{o=u(r,Object.keys(s))(...Object.values(s))}catch(g){return{ok:!1,message:`the expression could not be evaluated: ${g instanceof Error?g.message:String(g)}`,code:t.EVALUATION_ERROR}}if(o!==void 0&&o!==null)return{ok:!0,value:o};let c=[...new Set(et(r))].filter((g)=>!xt.has(g)&&!(g in s)&&!(g in globalThis));if(c.length>0)return{ok:!1,message:`${c.map((f)=>`"${f}"`).join(", ")} ${c.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:t.UNDEFINED_VARIABLE};if(o===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:t.EVALUATION_ERROR};return{ok:!0,value:o}}function
|
|
41
|
-
${i}${e.slice(r)}`}var ce=dr,At=new RegExp(`<script\\b[^>]*\\b${le}\\b[^>]*>[\\s\\S]*?<\\/script>`,"i"),
|
|
39
|
+
`;return Et(bt(s?(m)=>{let y=be([B,"Object",...Z,...g,...m],p);return(...b)=>y(Ae,Q,...he,...b)}:(m)=>{let y=be(["Object",...Z,...g,...m],p);return(...b)=>y(Q,...he,...b)},g,n,c,f,r),n,o)}function Et(e,n,r){if(r.length===0)return e;let i=r.map((s)=>n.indexOf(s));return(...s)=>{for(let o of i){if(o<0)continue;let c=s[o];if(typeof c==="string"&&ie.has(c))return}return e(...s)}}function bt(e,n,r,i,s,o){let c=e([]),g=i.every((p,h)=>p.index===h);if(n.length===r.length&&g)return xe(c,n,e,void 0,o);return xe((...p)=>{let h=Array(s.length);for(let m=0;m<s.length;m++)h[m]=p[s[m]];return c(...h)},n,e,(p)=>{c=e(p)},o)}function xe(e,n,r,i,s){let c=/^(\w+) is not defined$/,g=e,f=[],p=new Set(n);return(...h)=>{for(let m=0;m<=8;m++)try{return g(...h)}catch(y){let b=y instanceof Error?y.message:"",S=c.exec(b);if(!(y instanceof ReferenceError)||!S)return;let x=S[1];if(p.has(x)||Ie.has(x)||re.has(x))return;if(s?.(x),p.add(x),f.push(x),i)i(f);else g=r(f)}return}}function ws(e){let n=e.trim();try{let r=Re(n);if(/\b(?:eval|function|import|require|process|globalthis|window|document|fetch|bun|deno|buffer|console|reflect|proxy|prototype|constructor|this)\b/i.test(r))return!1;Te(r,n),_e(n);for(let i of te)if(i.test(r))return!1}catch{return!1}return!0}function Ho(e,n){let r=[];n.lastIndex=0;let i;while((i=n.exec(e))!==null){let s=i.index,o=s+i[0].length-1,c=w(e,"(",")",o);if(c===-1){r.push({start:s,end:-1,args:"",call:e.slice(s,Math.min(e.length,s+80))}),n.lastIndex=o+1;continue}r.push({start:s,end:c+1,args:e.slice(o+1,c),call:e.slice(s,c+1)}),n.lastIndex=c+1}return r}function Dt(e,n,r,i){let s="",o=0;for(let c of Ho(e,n)){if(s+=e.slice(o,c.start),c.end===-1){s+=i(c.call),o=c.start;continue}s+=r(c.args,c.call),o=c.end}return s+e.slice(o)}function Mt(e){let n=[],r=0,i=null,s="";for(let o=0;o<e.length;o++){let c=e[o];if(i){if(s+=c,c==="\\"&&o+1<e.length){s+=e[++o];continue}if(c===i)i=null;continue}if(c==="'"||c==='"'||c==="`")i=c;else if(c==="("||c==="["||c==="{")r++;else if(c===")"||c==="]"||c==="}")r--;else if(c===","&&r===0){n.push(s.trim()),s="";continue}s+=c}if(s.trim())n.push(s.trim());return n}function ae(e){let n=e.trim(),r=n[0];if(r!=="'"&&r!=='"'&&r!=="`"||n.length<2||n.at(-1)!==r)return null;let i="";for(let s=1;s<n.length-1;s++){let o=n[s];if(o==="\\"&&s+1<n.length-1){let c=n[++s];i+=c==="n"?`
|
|
40
|
+
`:c==="t"?"\t":c;continue}if(o===r)return null;if(r==="`"&&o==="$"&&n[s+1]==="{")return null;i+=o}return i}var xt=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Lt(e,n){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:t.INVALID_DIRECTIVE_SYNTAX};let i=bs(r);if(i)return{ok:!1,message:`the expression is not allowed (${i})`,code:t.UNSAFE_EXPRESSION};let s=U(n),o;try{o=u(r,Object.keys(s))(...Object.values(s))}catch(g){return{ok:!1,message:`the expression could not be evaluated: ${g instanceof Error?g.message:String(g)}`,code:t.EVALUATION_ERROR}}if(o!==void 0&&o!==null)return{ok:!0,value:o};let c=[...new Set(et(r))].filter((g)=>!xt.has(g)&&!(g in s)&&!(g in globalThis));if(c.length>0)return{ok:!1,message:`${c.map((f)=>`"${f}"`).join(", ")} ${c.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:t.UNDEFINED_VARIABLE};if(o===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:t.EVALUATION_ERROR};return{ok:!0,value:o}}function je(e){if(e===null)return"null";if(Array.isArray(e))return"an array";if(typeof e==="object")return"an object";if(typeof e==="string")return`a string ("${e.length>40?`${e.slice(0,40)}...`:e}")`;return`${/^[aeiou]/.test(typeof e)?"an":"a"} ${typeof e}`}function tt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Le(e){if(!e)return"";return Oe.isAbsolute(e)?Oe.relative(process.cwd(),e)||e:e}function oe(e){let n=e.replace(/\s+/g," ").trim();return n.length>80?`${n.slice(0,77)}...`:n}function P(e,n,r,i,s=t.EVALUATION_ERROR){let o=i?` in ${Le(i)}`:"";return console.warn(`[stx] ${oe(n)}${o}: ${r}`),a(e,`${oe(n)}: ${r}`,s)}function xs(e,n,r){let i=r?` in ${Le(r)}`:"";console.warn(`[stx] ${oe(e)}${i}: ${n}`)}function Vo(){return{afterOpen:[],beforeClose:[]}}function wt(e){return e.afterOpen.length>0||e.beforeClose.length>0}function ec(e,n){if(!wt(n))return e;let r=n.afterOpen.join(""),i=n.beforeClose.join(""),s=e.lastIndexOf("</head>"),o=r?dr(e):null,c=i&&s!==-1?s:null;if(o===null&&c===null)return e;if(o!==null&&c!==null)return`${e.slice(0,o)}${r}${e.slice(o,c)}${i}${e.slice(c)}`;if(o!==null)return`${e.slice(0,o)}${r}${e.slice(o)}`;return`${e.slice(0,c)}${i}${e.slice(c)}`}var Ne=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function dr(e){let n=/<head\b[^>]*>/i.exec(e);if(!n)return null;let r=n.index+n[0].length;Ne.lastIndex=r;let i=Ne.exec(e);return i?r+i[0].length:r}var le="data-stx-color-mode-boot",Me="__STX_COLOR_MODE__",St=new Set(["light","dark","auto","system"]),kt=new Set(["auto","system"]),vt=/^[a-z][\w:-]*$/i,$t=/^[\w-]+$/;function Rt(e){let n=e.storageKey??"stx-color-mode",r=e.initialMode??"auto",i=e.darkClass===void 0?"dark":e.darkClass,s=e.attribute??null,o=e.autoValue??null,c=e.respectExisting===!0;if(typeof n!=="string"||n.length===0)throw Error("colorMode.storageKey must be a non-empty string");if(!St.has(r))throw Error(`colorMode.initialMode must be one of light, dark, auto, system \u2014 got ${JSON.stringify(r)}`);if(i!==null&&(typeof i!=="string"||!$t.test(i)))throw Error(`colorMode.darkClass must be a single CSS class name, or null to opt out \u2014 got ${JSON.stringify(i)}`);if(s!==null&&(typeof s!=="string"||!vt.test(s)))throw Error(`colorMode.attribute must be a valid HTML attribute name \u2014 got ${JSON.stringify(s)}`);if(o!==null&&!kt.has(o))throw Error(`colorMode.autoValue must be 'auto' or 'system' \u2014 got ${JSON.stringify(o)}`);if(i===null&&s===null)throw Error("colorMode needs at least one of darkClass or attribute \u2014 with both null nothing would mark the mode on <html>");if(c&&s===null)throw Error("colorMode.respectExisting needs an attribute to read \u2014 the dark class alone cannot say whether a mode was chosen");return{storageKey:n,initialMode:r==="system"?"auto":r,darkClass:i,attribute:s,autoValue:o,respectExisting:c}}function Ct(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function ue(e={}){let n=Rt(e),r=Ct(n),i=`(function(){"use strict";var o=window.${Me};if(o&&typeof o.sync==="function"){o.sync();return}var c=${r};var r=document.documentElement;function read(){var p=c.initialMode,a=c.autoValue;try{var v=localStorage.getItem(c.storageKey);if(v==="light"||v==="dark"){p=v}else if(v==="auto"||v==="system"){p="auto";if(!a)a=v}}catch(e){}return{p:p,a:a}}function sys(){try{return matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(e){return"light"}}function stamp(m){if(c.attribute)r.setAttribute(c.attribute,m);if(c.darkClass){if(m==="dark")r.classList.add(c.darkClass);else r.classList.remove(c.darkClass)}}var s=read();var f=null;if(c.respectExisting&&c.attribute){var x=r.getAttribute(c.attribute);if(x==="light"||x==="dark")f=x}var m=f||(s.p==="auto"?sys():s.p);var p=s.p;stamp(m);var g=null;function sync(){var t=read(),n=f||(t.p==="auto"?sys():t.p);var moved=n!==m,chose=t.p!==p;if(moved){r.style.setProperty("transition","none","important");stamp(n);void r.offsetHeight;r.style.removeProperty("transition")}else stamp(n);m=n;p=t.p;if(g){g.mode=n;g.preference=t.p;if(t.a)g.autoValue=t.a}if(moved||chose){try{window.dispatchEvent(new CustomEvent("stx:color-mode",{detail:{mode:n,preference:t.p}}))}catch(e){}}}try{g=window.${Me}={storageKey:c.storageKey,initialMode:c.initialMode,darkClass:c.darkClass,attribute:c.attribute,autoValue:s.a||"auto",respectExisting:c.respectExisting,forced:f,preference:p,mode:m,watching:true,sync:sync}}catch(e){}try{var q=matchMedia("(prefers-color-scheme: dark)");if(q.addEventListener)q.addEventListener("change",sync);else if(q.addListener)q.addListener(sync)}catch(e){}try{addEventListener("pageshow",sync);addEventListener("storage",function(e){if(e.key===null||e.key===c.storageKey)sync()});document.addEventListener("visibilitychange",function(){if(document.visibilityState==="visible")sync()})}catch(e){}}());`;return`<script ${le}>${i}</script>`}function pr(e,n={}){if(e.includes(le))return e;let r=ce(e);if(r===null)return e;let i=ue(n);return`${e.slice(0,r)}
|
|
41
|
+
${i}${e.slice(r)}`}var ce=dr,At=new RegExp(`<script\\b[^>]*\\b${le}\\b[^>]*>[\\s\\S]*?<\\/script>`,"i"),Pe=/<meta\b[^>]*\bcharset\b[^>]*>/gi,Fe=/<\/head>/gi;function Tt(e){let n=/<head\b[^>]*>/i.exec(e);if(!n)return e;let r=n.index+n[0].length;Fe.lastIndex=r;let i=Fe.exec(e),s=i?i.index:e.length;Pe.lastIndex=r;let o=Pe.exec(e);if(!o||o.index>=s)return e;if(e.slice(r,o.index).trim()==="")return e;let c=o.index+o[0].length;return`${e.slice(0,r)}
|
|
42
42
|
${o[0]}${e.slice(r,o.index)}${e.slice(c,s)}${e.slice(s)}`}function tc(e){return _t(Tt(e))}function _t(e){let n=At.exec(e);if(!n)return e;let r=ce(e);if(r===null)return e;if(n.index<=r||e.slice(r,n.index).trim()==="")return e;let i=e.slice(0,n.index)+e.slice(n.index+n[0].length),s=ce(i);if(s===null)return e;return`${i.slice(0,s)}
|
|
43
43
|
${n[0]}${i.slice(s)}`}var He="<style data-stx-cloak>[x-cloak]{display:none !important}</style>",V="data-stx-html-attrs",W="data-stx-html-class",Ue=/^[A-Za-z_:][\w:.-]*$/;function v(e){return String(e).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function It(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function nt(e){if(e.name)return`name="${e.name}"`;if(e.property)return`property="${e.property}"`;if(e.charset!=null)return"charset=";if(e["http-equiv"])return`http-equiv="${e["http-equiv"]}"`;return""}function Ot(e){let n=/^\s*<meta\b([^>]*)>/i.exec(e);if(!n)return null;let r={};for(let i of n[1].matchAll(/([\w:-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g))r[i[1].toLowerCase()]=i[2]??i[3]??i[4]??"";return r}function _(e,n){return Object.entries(e).filter(([r])=>!n?.(r)).map(([r,i])=>`${r}="${v(String(i))}"`).join(" ")}function X(e){let n=String(e.content),r=typeof e.type==="string"?e.type.trim().toLowerCase():"";return/json$|^importmap$/.test(r)?n.replace(/<\//g,"<\\/"):n}function Ve(e){let n=_(e,(r)=>r==="content");return`<script${n?` ${n}`:""}>${X(e)}</script>`}function Pt(e={},n="en"){let r=[],i=[],s="",o=n;for(let[g,f]of Object.entries(e||{})){if(f==null)continue;let p=g.trim();if(!Ue.test(p))continue;let h=p.toLowerCase();if(h==="lang"){o=String(f);continue}if(h==="class"){s=String(f).trim();continue}r.push(` ${p}="${v(String(f))}"`),i.push(p)}let c=` lang="${v(o)}"`;if(s)c+=` class="${v(s)}"`;if(c+=r.join(""),s)c+=` ${W}="${v(s)}"`;if(i.length)c+=` ${V}="${v(i.join(" "))}"`;return c}function nc(e={},n={}){let r={...e,...n};if(e.class&&n.class){let i=e.class.split(/\s+/).filter(Boolean);for(let s of n.class.split(/\s+/).filter(Boolean))if(!i.includes(s))i.push(s);r.class=i.join(" ")}return r}function fr(e,n={}){if(!n||Object.keys(n).length===0)return e;let r=e.match(/<html\b([^>]*)>/i);if(!r)return e;let i={},s=[],o=/([A-Za-z_:][\w:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g,c;while((c=o.exec(r[1]))!==null){let h=c[1];if(!(h in i))s.push(h);i[h]=c[2]??c[3]??c[4]??""}let g=[],f=[];for(let[h,m]of Object.entries(n)){if(m==null)continue;let y=h.trim();if(!Ue.test(y))continue;let b=y.toLowerCase();if(b==="class"){let S=(i.class||"").split(/\s+/).filter(Boolean);for(let x of String(m).split(/\s+/).filter(Boolean))if(!S.includes(x))S.push(x),g.push(x);if(!("class"in i))s.push("class");i.class=S.join(" ");continue}if(!(y in i))s.push(y);if(i[y]=String(m),b!=="lang")f.push(y)}if(g.length){if(!(W in i))s.push(W);i[W]=g.join(" ")}if(f.length){if(!(V in i))s.push(V);i[V]=f.join(" ")}let p=s.map((h)=>` ${h}="${v(i[h])}"`).join("");return e.replace(r[0],()=>`<html${p}>`)}function rc(e){if(e.includes("data-stx-cloak"))return null;if(e.lastIndexOf("</head>")===-1)return null;return`${He}
|
|
44
44
|
`}function Ft(e){let n=[],r=0;while(r<e.length){let o=e.slice(r),c=o.match(/^\s+/);if(c){r+=c[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",r);if(m===-1)break;r=m+3;continue}let g=o.match(/^<script\b[^>]*>/i);if(g){let m=e.toLowerCase().indexOf("</script>",r+g[0].length);if(m===-1)break;r=m+9;continue}let f=o.match(/^<link\b[^>]*>/i);if(f){n.push(f[0]),r+=f[0].length;continue}let p=o.match(/^<meta\b[^>]*>/i);if(p){n.push(p[0]),r+=p[0].length;continue}let h=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(h){n.push(h[0]),r+=h[0].length;continue}break}if(n.length===0)return{body:e,hoisted:n};let i="",s=0;while(s<e.length&&s<r){let o=e.slice(s),c=o.match(/^<link\b[^>]*>/i);if(c&&n.includes(c[0])){s+=c[0].length;continue}let g=o.match(/^<meta\b[^>]*>/i);if(g&&n.includes(g[0])){s+=g[0].length;continue}let f=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(f&&n.includes(f[0])){s+=f[0].length;continue}i+=e[s],s++}return i+=e.slice(r),{body:i,hoisted:n}}function jt(e,n={},r={}){let{title:i="stx App",lang:s="en",meta:o=[],link:c=[],script:g=[],headRaw:f="",htmlAttrs:p={},bodyClass:h="",bodyAttrs:m={}}=n,y=r.title||i,b=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],S=new Set(o.map(nt).filter(Boolean)),{body:x,hoisted:R}=Ft(e),T=new Set(R.flatMap((E)=>{let O=Ot(E);return O?[nt(O)].filter(Boolean):[]})),Ke=[...b.filter((E)=>!S.has(nt(E))),...o].filter((E)=>!T.has(nt(E))).map((E)=>` <meta ${_(E)}>`).join(`
|
|
@@ -54,8 +54,8 @@ ${rt.join(`
|
|
|
54
54
|
${it.join(`
|
|
55
55
|
`)}
|
|
56
56
|
</body>
|
|
57
|
-
</html>`}var ge=/\s+/y,pe=/<(script|style)\b[^>]*>/iy,zt=/<\/script>/gi,Bt=/<\/style>/gi,
|
|
57
|
+
</html>`}var ge=/\s+/y,pe=/<(script|style)\b[^>]*>/iy,zt=/<\/script>/gi,Bt=/<\/style>/gi,De=/<!DOCTYPE\b/iy,ze=/<html[\s>]/iy;function yn(e){let n=0;while(n<e.length){if(ge.lastIndex=n,ge.exec(e)){n=ge.lastIndex;continue}if(e.startsWith("<!--",n)){let s=e.indexOf("-->",n);if(s===-1)return!1;n=s+3;continue}pe.lastIndex=n;let i=pe.exec(e);if(i){let s=i[1].toLowerCase()==="script"?zt:Bt;s.lastIndex=pe.lastIndex;let o=s.exec(e);if(o===null)return!1;n=o.index+o[0].length;continue}if(De.lastIndex=n,De.test(e))return!0;return ze.lastIndex=n,ze.test(e)}return!1}function Uo(e){return yn(e)}function sc(e,n={}){let r=e.lastIndexOf("</head>");if(r===-1)return e;let{meta:i=[],link:s=[],script:o=[],headRaw:c=""}=n,g=e.slice(0,r),f=[];for(let p of i){let h=nt(p);if(h&&g.includes(h))continue;f.push(` <meta ${_(p)}>`)}for(let p of s){if(p.href&&g.includes(`href="${p.href}"`))continue;f.push(` <link ${_(p)}>`)}for(let p of o)if(p.src){if(g.includes(`src="${p.src}"`))continue;f.push(` <script ${_(p,(h)=>h==="content")}></script>`)}else if(p.content){if(g.includes(X(p)))continue;f.push(` ${Ve(p)}`)}if(c&&!g.includes(c))f.push(` ${c}`);if(f.length===0)return e;return`${e.slice(0,r)}${f.join(`
|
|
58
58
|
`)}
|
|
59
|
-
${e.slice(r)}`}function gr(e,n={},r={},i){if(i??Uo(e))return e;return jt(e,n,r)}var Ht=["og:","article:","book:","profile:","fb:","music:","video:"],Ut=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function mr(e,n){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:t.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:t.INVALID_DIRECTIVE_SYNTAX};let r=Vt(e[0],n);if(typeof r!=="string")return r;let i;if(e.length===2){let o=Wt(e[1],n);if(typeof o!=="string")return o;i=o}else{let o=r.includes(":")?r.slice(r.indexOf(":")+1):r,c=n.openGraph,g=n[o]??(tt(c)?c[o]:void 0);i=g===void 0||g===null||typeof g==="object"?"":String(g)}if(!i)return{kind:"empty"};return{kind:"tag",tag:Ht.some((o)=>r.startsWith(o))?{property:r,content:i}:{name:r,content:i}}}function Vt(e,n){let r=ae(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:t.INVALID_DIRECTIVE_SYNTAX};if(Ut.test(e.trim()))return e.trim();let i=Lt(e,n);if(!i.ok)return{kind:"error",message:`meta name: ${i.message}`,code:i.code};if(typeof i.value!=="string"||!i.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${
|
|
59
|
+
${e.slice(r)}`}function gr(e,n={},r={},i){if(i??Uo(e))return e;return jt(e,n,r)}var Ht=["og:","article:","book:","profile:","fb:","music:","video:"],Ut=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function mr(e,n){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:t.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:t.INVALID_DIRECTIVE_SYNTAX};let r=Vt(e[0],n);if(typeof r!=="string")return r;let i;if(e.length===2){let o=Wt(e[1],n);if(typeof o!=="string")return o;i=o}else{let o=r.includes(":")?r.slice(r.indexOf(":")+1):r,c=n.openGraph,g=n[o]??(tt(c)?c[o]:void 0);i=g===void 0||g===null||typeof g==="object"?"":String(g)}if(!i)return{kind:"empty"};return{kind:"tag",tag:Ht.some((o)=>r.startsWith(o))?{property:r,content:i}:{name:r,content:i}}}function Vt(e,n){let r=ae(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:t.INVALID_DIRECTIVE_SYNTAX};if(Ut.test(e.trim()))return e.trim();let i=Lt(e,n);if(!i.ok)return{kind:"error",message:`meta name: ${i.message}`,code:i.code};if(typeof i.value!=="string"||!i.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${je(i.value)}`,code:t.TYPE_ERROR};return i.value}function Wt(e,n){let r=ae(e);if(r!==null)return r;let i=Lt(e,n);if(!i.ok)return{kind:"error",message:i.message,code:i.code};let s=i.value;if(s===void 0||s===null||s===!1)return"";if(Array.isArray(s))return s.filter((o)=>o!==void 0&&o!==null&&o!=="").map(String).join(", ");if(typeof s==="object"&&!(s instanceof Date))return{kind:"error",message:`the content must be text, got ${je(s)}`,code:t.TYPE_ERROR};return String(s)}var hr=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],Ss=["title","titleTemplate","base","meta","link","script","style","htmlAttrs","bodyAttrs"],qe={links:"link",metas:"meta",scripts:"script",styles:"style"},We=new Set,Xe=new WeakMap;function fe(e){if(We.has(e))return;We.add(e),console.warn(e)}function Xt(e,n){let r=Array.from({length:n.length+1},(i,s)=>s);for(let i=1;i<=e.length;i++){let s=r[0];r[0]=i;for(let o=1;o<=n.length;o++){let c=r[o];r[o]=Math.min(r[o]+1,r[o-1]+1,s+(e[i-1]===n[o-1]?0:1)),s=c}}return r[n.length]}function qt(e,n){let r=e.toLowerCase(),i=n.find((f)=>f.toLowerCase()===r);if(i)return i;let s=qe[r];if(s&&n.includes(s))return s;let o,c=1/0;for(let f of n){let p=Xt(r,f.toLowerCase());if(p<c)o=f,c=p}let g=Math.min(e.length,o?.length??0)<=4?1:2;return c<=g?o:void 0}function we(e,n){if(!e||typeof e!=="object"||Array.isArray(e))return e||{};let r=Xe.get(e);if(r)return r;let{known:i,source:s}=n,o=e;for(let c of Object.keys(e)){if(i.includes(c))continue;let g=qe[c];if(g&&i.includes(g)&&Array.isArray(e[c])){if(o===e)o={...e};let p=Array.isArray(o[g])?o[g]:[];o[g]=[...p,...e[c]],delete o[c],fe(`[stx] ${s}.${c} is not a head key; reading it as ${s}.${g}. Rename it to \`${g}\`.`);continue}if(/^styles?$/.test(c)&&!i.includes("style")){fe(`[stx] ${s}.${c} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let f=qt(c,i);fe(f?`[stx] ${s}.${c} is not a head key and is ignored. Did you mean \`${f}\`?`:`[stx] ${s}.${c} is not a head key and is ignored. Known keys: ${i.join(", ")}.`)}return Xe.set(e,o),o}var A={},Kt=[],q={};function Wo(){return A}function Dp(){return q}function Mp(){A={},Kt.length=0,q={}}function oc(e){A=Be(A,we(e,{known:Ss,source:"useHead()"}))}function Be(e,n){return{title:n.title??e.title,titleTemplate:n.titleTemplate??e.titleTemplate,base:n.base??e.base,meta:[...e.meta||[],...n.meta||[]],link:[...e.link||[],...n.link||[]],script:[...e.script||[],...n.script||[]],style:[...e.style||[],...n.style||[]],htmlAttrs:{...e.htmlAttrs,...n.htmlAttrs},bodyAttrs:{...e.bodyAttrs,...n.bodyAttrs}}}function cu(e){oc(ks(e))}function ks(e){let n=[];if(e.description)n.push({name:"description",content:e.description});if(e.keywords){let f=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;n.push({name:"keywords",content:f})}if(e.author)n.push({name:"author",content:e.author});if(e.robots)n.push({name:"robots",content:e.robots});let r=e.ogTitle??e.title,i=e.ogDescription??e.description;if(r)n.push({property:"og:title",content:r});if(i)n.push({property:"og:description",content:i});if(e.ogImage){if(n.push({property:"og:image",content:e.ogImage}),e.ogImageType)n.push({property:"og:image:type",content:e.ogImageType});if(e.ogImageWidth)n.push({property:"og:image:width",content:String(e.ogImageWidth)});if(e.ogImageHeight)n.push({property:"og:image:height",content:String(e.ogImageHeight)});if(e.ogImageAlt)n.push({property:"og:image:alt",content:e.ogImageAlt})}if(e.ogUrl)n.push({property:"og:url",content:e.ogUrl});if(e.ogType)n.push({property:"og:type",content:e.ogType});if(e.ogSiteName)n.push({property:"og:site_name",content:e.ogSiteName});if(e.ogLocale)n.push({property:"og:locale",content:e.ogLocale});if(e.profileFirstName)n.push({property:"profile:first_name",content:e.profileFirstName});if(e.profileLastName)n.push({property:"profile:last_name",content:e.profileLastName});if(e.profileUsername)n.push({property:"profile:username",content:e.profileUsername});let s=e.twitterTitle??e.title,o=e.twitterDescription??e.description,c=e.twitterImage??e.ogImage;if(e.twitterCard)n.push({name:"twitter:card",content:e.twitterCard});if(s)n.push({name:"twitter:title",content:s});if(o)n.push({name:"twitter:description",content:o});if(c){n.push({name:"twitter:image",content:c});let f=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(f)n.push({name:"twitter:image:alt",content:f})}if(e.twitterSite)n.push({name:"twitter:site",content:e.twitterSite});if(e.twitterCreator)n.push({name:"twitter:creator",content:e.twitterCreator});if(e.articleAuthor)n.push({property:"article:author",content:e.articleAuthor});if(e.articlePublishedTime)n.push({property:"article:published_time",content:e.articlePublishedTime});if(e.articleModifiedTime)n.push({property:"article:modified_time",content:e.articleModifiedTime});if(e.articleSection)n.push({property:"article:section",content:e.articleSection});if(e.articleTags)for(let f of e.articleTags)n.push({property:"article:tag",content:f});let g=[];if(e.canonical)g.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:n,link:g}}function Lp(e){if(q={...q,...e},e.title||e.description)cu({title:e.title,description:e.description})}function jp(e){let n=typeof e==="function"?e():e;oc({title:n})}function Bp(e=A){let n=[];if(e.title){let r=e.title;if(e.titleTemplate)r=typeof e.titleTemplate==="function"?e.titleTemplate(r):e.titleTemplate.replace("%s",r);n.push(`<title>${I(r)}</title>`)}if(e.base){let r=Object.entries(e.base).map(([i,s])=>`${i}="${I(s)}"`).join(" ");n.push(`<base ${r}>`)}for(let r of e.meta||[]){let i=Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s==="httpEquiv"?"http-equiv":s}="${I(String(o))}"`).join(" ");n.push(`<meta ${i}>`)}for(let r of e.link||[]){let i=Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s}="${I(String(o))}"`).join(" ");n.push(`<link ${i}>`)}for(let r of e.script||[]){let{content:i,...s}=r,o=Object.entries(s).filter(([c,g])=>g!==void 0).map(([c,g])=>{if(typeof g==="boolean")return g?c:"";return`${c}="${I(String(g))}"`}).filter(Boolean).join(" ");if(i)n.push(`<script ${o}>${X(r)}</script>`);else n.push(`<script ${o}></script>`)}for(let r of e.style||[]){let i=r.type?` type="${r.type}"`:"";n.push(`<style${i}>${r.content}</style>`)}return n.join(`
|
|
60
60
|
`)}function Fp(e=A){if(!e.htmlAttrs)return"";return Object.entries(e.htmlAttrs).map(([n,r])=>`${n}="${I(r)}"`).join(" ")}function zp(e=A){if(!e.bodyAttrs)return"";return Object.entries(e.bodyAttrs).map(([n,r])=>`${n}="${I(r)}"`).join(" ")}function I(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Hp(e=A){if(typeof document>"u")return;if(e.title){let n=e.title;if(e.titleTemplate)n=typeof e.titleTemplate==="function"?e.titleTemplate(n):e.titleTemplate.replace("%s",n);document.title=n}for(let n of e.meta||[]){let r=n.name?`meta[name="${n.name}"]`:n.property?`meta[property="${n.property}"]`:null;if(r){let i=document.querySelector(r);if(!i){if(i=document.createElement("meta"),n.name)i.setAttribute("name",n.name);if(n.property)i.setAttribute("property",n.property);document.head.appendChild(i)}i.setAttribute("content",n.content)}}for(let n of e.link||[]){let r=`link[rel="${n.rel}"]${n.href?`[href="${n.href}"]`:""}`,i=document.querySelector(r);if(!i)i=document.createElement("link"),document.head.appendChild(i);for(let[s,o]of Object.entries(n))if(o!==void 0)i.setAttribute(s,String(o))}if(e.htmlAttrs)for(let[n,r]of Object.entries(e.htmlAttrs))if(n==="class")for(let i of String(r).split(/\s+/).filter(Boolean))document.documentElement.classList.add(i);else document.documentElement.setAttribute(n,r);if(e.bodyAttrs)for(let[n,r]of Object.entries(e.bodyAttrs))document.body.setAttribute(n,r)}function Vp(e){let n="";return{content:e.replace(/@head\s*([\s\S]*?)@endhead/g,(i,s)=>(n+=s.trim()+`
|
|
61
|
-
`,"")),headContent:n.trim()}}function Up(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,i,s,o)=>{let c=i?s:n[(o||"").trim()]??o,g=n.__stx_runtime_head??{};return n.__stx_runtime_head=
|
|
61
|
+
`,"")),headContent:n.trim()}}function Up(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,i,s,o)=>{let c=i?s:n[(o||"").trim()]??o,g=n.__stx_runtime_head??{};return n.__stx_runtime_head=Be(g,{title:c}),""})}function Wp(e,n,r=""){if(!e.includes("@meta"))return e;return Dt(e,/(?<![\w$@])@meta\s*\(/g,(i,s)=>{let o=mr(Mt(i),n);if(o.kind==="error")return P("Meta",s,o.message,r,o.code);if(o.kind==="tag"){let c=n.__stx_runtime_head??{};n.__stx_runtime_head=Be(c,{meta:[o.tag]})}return""},(i)=>P("Meta",i,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX))}export{bs,Fo,vs,l,d,Qa,C,et,Nt,u,ws,t,ne,ur,z,a,ve,zo,D,hn,w,Ho,Dt,Mt,Lt,je,tt,P,xs,Vo,ec,dr,pr,tc,nt,nc,fr,rc,yn,Uo,sc,gr,mr,hr,Ss,we,Wo,Dp,Mp,oc,Be,cu,ks,Lp,jp,Bp,Fp,zp,Hp,Vp,Up,Wp};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Hi,Vi,Ui,Wi,tp}from"./chunk-t1k9160w.js";import"./chunk-qm4672dj.js";import"./chunk-c1dkh0es.js";import"./chunk-pbtkbe48.js";import"./chunk-qfe7ps3v.js";import"./chunk-prf164ct.js";import"./chunk-nj1t4g3a.js";import"./chunk-radggg3p.js";import"./chunk-3zyjqvsq.js";import"./chunk-ymymwzt5.js";import"./chunk-0vkawews.js";import"./chunk-r1r6311d.js";import"./chunk-ye8tgmd3.js";import"./chunk-pxs7sgnp.js";import"./chunk-3q163st5.js";import"./chunk-e87xa4r3.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-p44kmbdg.js";import"./chunk-gv793yqq.js";import"./chunk-zsgcsqat.js";import"./chunk-x5tjb4y4.js";import"./chunk-2h8ea0we.js";import"./chunk-55zaxb4s.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Hi as buildNative,tp as default,Vi as findCraftBinary,Wi as getAvailableFormats,Ui as getAvailableTargets};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import{y,b,S,G}from"./chunk-
|
|
2
|
+
import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import{y,b,S,G}from"./chunk-zsgcsqat.js";import"./chunk-55zaxb4s.js";import"./chunk-2h8ea0we.js";import"./chunk-x5tjb4y4.js";import f from"path";var h=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAmbientSound","useAnimationFrame","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBreathPacer","useBroadcastChannel","useBroadcastStream","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],L=new Set(h);var l=new Map,w=y(64),x=new Set,O=0,R=new Set(h);function T(){l.clear(),w.clear()}function P(n){let o=new Map;for(let r of n){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=o.get(t);if(i&&!i.endsWith(".js"))continue;o.set(t,r)}return[...o.values()].sort()}function I(n,o){let r=o.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(n)}function M(n){if(!n)return[];let o=b(n,O),r=w.get(o);if(r)return r.slice();let a=n.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of R){if(x.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),w.set(o,t),t.slice()}async function A(n,o){let r=M(n);if(r.length===0)return null;let a=o??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=G({loader:"ts",target:"browser",define:S()}),C=new Set(r),m=[],d=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=P(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let g=[];try{g=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!g.some((c)=>C.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),m.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
|
|
3
3
|
${u.transformSync(e).trim()}`);for(let c of g)d.add(c)}catch(c){console.warn(`[stx] framework composable ${f.basename(s)} could not be bundled:`,c)}}let v=r.filter((s)=>!d.has(s)&&!I(n,s));if(v.length>0)console.warn(`[stx] could not bundle ${v.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(m.length===0)return l.set(t,""),null;let E=[...d].map((s)=>` try { if (!(${JSON.stringify(s)} in __s)) { __s[${JSON.stringify(s)}] = ${s}; if (!(${JSON.stringify(s)} in window)) window[${JSON.stringify(s)}] = ${s}; } } catch (e) {}`).join(`
|
|
4
4
|
`),k=`<script data-stx-scoped data-stx-run="always" data-stx-framework-composables>
|
|
5
5
|
;(function(){
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{k}from"./chunk-
|
|
2
|
+
import{k}from"./chunk-zsgcsqat.js";import{se}from"./chunk-84djpte6.js";function g(e,t){let r={};for(let n of e)r[n]=se(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=se(o);return!0},has:(n,a)=>(a in r),deleteProperty:(n,a)=>(delete r[a],!0),ownKeys:()=>Reflect.ownKeys(r),getOwnPropertyDescriptor:(n,a)=>(a in r)?{enumerable:!0,configurable:!0,writable:!0,value:r[a]()}:void 0})}function v(e,t){let r={};for(let n of t)r[n]=e[n];return r}function Mi(e,t){let r=Object.keys(e),n=g(r,(i)=>t?.[i]??e[i].getDefaultValue()),a=g(r,()=>[]),o=g(r,()=>!1),c=g(r,()=>!1),f=g(r,()=>!1),s=se(!1);async function u(i){f[i]=!0;let d=await e[i].validate(n[i],n);return a[i]=d,f[i]=!1,d.length===0}async function l(){s.set(!0);let i=await Promise.all(r.map(u));return s.set(!1),i.every(Boolean)}function m(){for(let i of r)n[i]=t?.[i]??e[i].getDefaultValue(),a[i]=[],o[i]=!1,c[i]=!1}function h(i){for(let d of r)if(d in i)n[d]=i[d],c[d]=!0}function b(i,d){n[i]=d,c[i]=!0}function y(i,d=!0){if(o[i]=d,d)u(i)}function p(i){return{value:n[i],errors:a[i],touched:o[i],dirty:c[i],valid:a[i].length===0,validating:f[i]}}function V(i){return async(d)=>{d?.preventDefault?.();for(let w of r)o[w]=!0;if(await l())await i(v(n,r))}}return{values:n,errors:a,touched:o,dirty:c,get isValid(){return r.every((i)=>a[i].length===0)},get isValidating(){return s()||r.some((i)=>f[i])},get isDirty(){return r.some((i)=>c[i])},validate:l,validateField:u,reset:m,setValues:h,setFieldValue:b,setFieldTouched:y,getFieldState:p,handleSubmit:V}}var tl=Mi;class Pn{rules=[];defaultValue="";addRule(e){let t=new Pn;return t.rules=[...this.rules,e],t.defaultValue=this.defaultValue,t}required(e="This field is required"){return this.addRule({name:"required",message:e,validate:(t)=>{if(t===null||t===void 0)return e;if(typeof t==="string"&&t.trim()==="")return e;if(Array.isArray(t)&&t.length===0)return e;return!0}})}email(e="Please enter a valid email"){return this.addRule({name:"email",message:e,validate:(t)=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t))||e}})}url(e="Please enter a valid URL"){return this.addRule({name:"url",message:e,validate:(t)=>{if(!t)return!0;try{return new URL(String(t)),!0}catch{return e}}})}min(e,t){let r=t||`Must be at least ${e} characters`;return this.addRule({name:"min",message:r,validate:(n)=>{if(!n)return!0;return String(n).length>=e||r}})}max(e,t){let r=t||`Must be no more than ${e} characters`;return this.addRule({name:"max",message:r,validate:(n)=>{if(!n)return!0;return String(n).length<=e||r}})}length(e,t,r){let n=r||`Must be between ${e} and ${t} characters`;return this.addRule({name:"length",message:n,validate:(a)=>{if(!a)return!0;let o=String(a).length;return o>=e&&o<=t||n}})}pattern(e,t="Invalid format"){return this.addRule({name:"pattern",message:t,validate:(r)=>{if(!r)return!0;return e.test(String(r))||t}})}hasUppercase(e="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,e)}hasLowercase(e="Must contain a lowercase letter"){return this.pattern(/[a-z]/,e)}hasNumber(e="Must contain a number"){return this.pattern(/\d/,e)}hasSpecial(e="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,e)}alphanumeric(e="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,e)}startsWithLetter(e="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,e)}noSpaces(e="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:e,validate:(t)=>{if(!t)return!0;return!String(t).includes(" ")||e}})}number(e="Must be a number"){let t=this.addRule({name:"number",message:e,validate:(r)=>{if(!r&&r!==0)return!0;return!Number.isNaN(Number(r))||e}});return t.defaultValue=0,t}integer(e="Must be a whole number"){return this.addRule({name:"integer",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number.isInteger(Number(t))||e}})}positive(e="Must be a positive number"){return this.addRule({name:"positive",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)>0||e}})}negative(e="Must be a negative number"){return this.addRule({name:"negative",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)<0||e}})}minValue(e,t){let r=t||`Must be at least ${e}`;return this.addRule({name:"minValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)>=e||r}})}maxValue(e,t){let r=t||`Must be no more than ${e}`;return this.addRule({name:"maxValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)<=e||r}})}between(e,t,r){let n=r||`Must be between ${e} and ${t}`;return this.addRule({name:"between",message:n,validate:(a)=>{if(!a&&a!==0)return!0;let o=Number(a);return o>=e&&o<=t||n}})}matches(e,t){let r=t||`Must match ${e}`;return this.addRule({name:"matches",message:r,validate:(n,a)=>{if(!a)return!0;return n===a[e]||r}})}oneOf(e,t){let r=t||`Must be one of: ${e.join(", ")}`;return this.addRule({name:"oneOf",message:r,validate:(n)=>{if(!n)return!0;return e.includes(n)||r}})}notOneOf(e,t){let r=t||`Cannot be one of: ${e.join(", ")}`;return this.addRule({name:"notOneOf",message:r,validate:(n)=>{if(!n)return!0;return!e.includes(n)||r}})}date(e="Must be a valid date"){return this.addRule({name:"date",message:e,validate:(t)=>{if(!t)return!0;let r=new Date(String(t));return!Number.isNaN(r.getTime())||e}})}before(e,t){let r=new Date(e),n=t||`Must be before ${r.toLocaleDateString()}`;return this.addRule({name:"before",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))<r||n}})}after(e,t){let r=new Date(e),n=t||`Must be after ${r.toLocaleDateString()}`;return this.addRule({name:"after",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))>r||n}})}custom(e,t="Invalid value"){return this.addRule({name:"custom",message:t,validate:e})}async(e,t="Invalid value"){return this.addRule({name:"async",message:t,async:!0,validate:e})}when(e,t){let r=new Pn;r.rules=[...this.rules],r.defaultValue=this.defaultValue;for(let n of t.getRules())r.rules.push({...n,validate:(a,o)=>{if(!e(a,o||{}))return!0;return n.validate(a,o)}});return r}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(e){let t=new Pn;return t.rules=[...this.rules],t.defaultValue=e,t}async validate(e,t){let r=[];for(let n of this.rules){let a=await n.validate(e,t);if(a!==!0)r.push(a)}return r}validateSync(e,t){let r=[];for(let n of this.rules){if(n.async)continue;let a=n.validate(e,t);if(a!==!0)r.push(a)}return r}}var td=new Pn;function nl(e,t,r){let n=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>k(c,{...t,message:l},r)).join(`
|
|
3
3
|
`)}catch{return""}})}function rl(e,t,r){let n=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return u.map((l)=>k(c,{...t,message:l},r)).join(`
|
|
4
4
|
`)}catch{return""}})}function sl(e,t,r){let n=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return e.replace(n,(a,o,c)=>{try{let f=o.trim().split("."),s=t;for(let l of f)if(s&&typeof s==="object"&&l in s)s=s[l];else return"";let u=s;if(!u||!Array.isArray(u)||u.length===0)return"";return c}catch{return""}})}function nd(e,t,r){let n=e;return n=nl(n,t,r),n=rl(n,t,r),n=sl(n,t,r),n}export{Mi,tl,Pn,td,nl,rl,sl,nd};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{N,Rl,po,i,R,xp,Sp}from"./chunk-3q163st5.js";import"./chunk-e87xa4r3.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-p44kmbdg.js";import"./chunk-gv793yqq.js";import"./chunk-zsgcsqat.js";import"./chunk-x5tjb4y4.js";import"./chunk-2h8ea0we.js";import"./chunk-55zaxb4s.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{R as config,N as defaultConfig,xp as defineStxConfig,po as discoverConfig,i as loadStxConfig,Rl as resolveStxDirectories,Sp as validateConfig};
|