@stacksjs/stx 0.2.661 → 0.2.663
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-wc3e138p.js → chunk-0c0g8x6p.js} +2 -2
- package/dist/{chunk-3p8p8sfw.js → chunk-0q2y47xq.js} +1 -1
- package/dist/{chunk-d5vz53t1.js → chunk-0rryv3h4.js} +2 -2
- package/dist/{chunk-5n6sej6b.js → chunk-104wkd4z.js} +1 -1
- package/dist/{chunk-snwps673.js → chunk-1ddsvtye.js} +14 -14
- package/dist/{chunk-n4x9hytk.js → chunk-1pettdfm.js} +6 -6
- package/dist/{chunk-5nfc2tw2.js → chunk-20g54d4x.js} +70 -70
- package/dist/{chunk-afavkkkq.js → chunk-34763y0h.js} +1 -1
- package/dist/chunk-3632qt5h.js +2 -0
- package/dist/{chunk-9rh5anvd.js → chunk-3wtxp6xm.js} +2 -2
- package/dist/{chunk-ghge79wv.js → chunk-510vd60c.js} +1 -1
- package/dist/{chunk-pp4pyeg4.js → chunk-511rs0zz.js} +4 -4
- package/dist/{chunk-mmern3j1.js → chunk-55ttbbc0.js} +1 -1
- package/dist/{chunk-6qd27t9k.js → chunk-56b02x0s.js} +1 -1
- package/dist/chunk-56gd7dhw.js +2 -0
- package/dist/{chunk-7ek9yvwk.js → chunk-5eddytbs.js} +1 -1
- package/dist/{chunk-vp9hse5k.js → chunk-5z1n02nd.js} +1 -1
- package/dist/{chunk-2cb9r3r9.js → chunk-6jrm0aks.js} +1 -1
- package/dist/chunk-6v2v7tnf.js +2 -0
- package/dist/{chunk-eyvex6fk.js → chunk-6vx5vqx9.js} +1 -1
- package/dist/{chunk-w82nvp7r.js → chunk-793ddtq2.js} +1 -1
- package/dist/{chunk-3fyj98v9.js → chunk-8bf0ebmx.js} +1 -1
- package/dist/{chunk-09a8tn6e.js → chunk-8pmcg1sv.js} +1 -1
- package/dist/chunk-8w06n007.js +2 -0
- package/dist/chunk-9cra84gy.js +2 -0
- package/dist/{chunk-9zy4kzqk.js → chunk-bmtxdtcd.js} +1 -1
- package/dist/{chunk-z4fa7nsm.js → chunk-brdbnkwq.js} +4 -4
- package/dist/chunk-bxpctk61.js +2 -0
- package/dist/{chunk-wcmzr1sk.js → chunk-bz9w91ct.js} +1 -1
- package/dist/{chunk-rzxhdmz9.js → chunk-cdxmdp9g.js} +1 -1
- package/dist/{chunk-2jv7g2fs.js → chunk-db2g2k9r.js} +1 -1
- package/dist/chunk-db5vyvb3.js +2 -0
- package/dist/{chunk-57nbg2f9.js → chunk-fa6xrfj8.js} +2 -2
- package/dist/{chunk-z5qj7enn.js → chunk-fawahej5.js} +1 -1
- package/dist/{chunk-dr1vedj2.js → chunk-fnc50e50.js} +1 -1
- package/dist/{chunk-f9fty8ty.js → chunk-g3qvz863.js} +1 -1
- package/dist/{chunk-5em9ak8r.js → chunk-g8h93d38.js} +1 -1
- package/dist/{chunk-r1y1k2ky.js → chunk-g8xht25s.js} +2 -2
- package/dist/chunk-g9319n9s.js +2 -0
- package/dist/{chunk-sk82mf97.js → chunk-gwjjrhf2.js} +1 -1
- package/dist/{chunk-k99f2njc.js → chunk-jqxn430n.js} +1 -1
- package/dist/{chunk-nw9x9gsb.js → chunk-khn42pf7.js} +1 -1
- package/dist/{chunk-t1fxzg0m.js → chunk-m8yhs4dp.js} +2 -2
- package/dist/chunk-meqeg0re.js +2 -0
- package/dist/chunk-nv81qr04.js +2 -0
- package/dist/{chunk-dv709hnm.js → chunk-nvgy1y0x.js} +1 -1
- package/dist/{chunk-dn2h9g79.js → chunk-pmyn85rn.js} +1 -1
- package/dist/{chunk-bt4bd4f5.js → chunk-px1qz3vc.js} +1 -1
- package/dist/{chunk-7rjm58gn.js → chunk-qq5ng2f7.js} +1 -1
- package/dist/{chunk-xt9t5wvx.js → chunk-r4jj8njy.js} +1 -1
- package/dist/{chunk-2yvqydak.js → chunk-rr6qk4t0.js} +1 -1
- package/dist/{chunk-dyzgrvg3.js → chunk-rs53mztk.js} +1 -1
- package/dist/{chunk-mvv5cpen.js → chunk-t267mq36.js} +1 -1
- package/dist/{chunk-d5k8gx93.js → chunk-t74evmw0.js} +1 -1
- package/dist/{chunk-px8e8qgp.js → chunk-tn68h8jf.js} +1 -1
- package/dist/{chunk-0961mx93.js → chunk-ty6qtdwn.js} +1 -1
- package/dist/{chunk-qzv0mqw5.js → chunk-wcez7djm.js} +1 -1
- package/dist/{chunk-jtheqwp2.js → chunk-wk9v5bj3.js} +5 -5
- package/dist/{chunk-zjnh64wm.js → chunk-x2yxb53d.js} +1 -1
- package/dist/{chunk-2x9h3whx.js → chunk-xtpemhhv.js} +1 -1
- package/dist/{chunk-dah90qrm.js → chunk-xytf5yzv.js} +1 -1
- package/dist/{chunk-714gdfj9.js → chunk-zk9wkhkg.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/compiler/html-to-ir.js +2 -2
- package/dist/native/compiler/inline-style.js +13 -0
- package/dist/native/compiler/render-screen.js +1 -1
- package/dist/native/runtime/native-host.d.ts +1 -1
- package/dist/native/runtime/native-host.js +10 -2
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/dist/utils.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-7j486x8f.js +0 -2
- package/dist/chunk-8xypmt6s.js +0 -2
- package/dist/chunk-avmqg5t6.js +0 -2
- package/dist/chunk-j02834qv.js +0 -2
- package/dist/chunk-mdk323pn.js +0 -2
- package/dist/chunk-p6p29613.js +0 -2
- package/dist/chunk-pnnqftq6.js +0 -2
- package/dist/chunk-w7dcy972.js +0 -2
- package/dist/chunk-yharrk8v.js +0 -2
- package/dist/chunk-zdfja1ap.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-hb08vrbb.js";import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import"./chunk-
|
|
2
|
+
import"./chunk-hb08vrbb.js";import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import"./chunk-20g54d4x.js";import"./chunk-2h8ea0we.js";import"./chunk-wcez7djm.js";import"./chunk-a3d0g4mr.js";import"./chunk-x2yxb53d.js";import{c}from"./chunk-zhf01af3.js";import u from"fs";import l from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||c(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=l.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),m=JSON.parse(p);if(m.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
|
|
3
3
|
`)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Mu}from"./chunk-104wkd4z.js";import"./chunk-3wtxp6xm.js";import"./chunk-pxqh758g.js";import"./chunk-bmtxdtcd.js";import"./chunk-wk9v5bj3.js";import"./chunk-0c0g8x6p.js";import"./chunk-prf164ct.js";import"./chunk-gwjjrhf2.js";import"./chunk-511rs0zz.js";import"./chunk-rs53mztk.js";import"./chunk-r7kmsq3n.js";import"./chunk-fa6xrfj8.js";import"./chunk-brdbnkwq.js";import"./chunk-8nryyqb5.js";import"./chunk-px1qz3vc.js";import"./chunk-g8xht25s.js";import"./chunk-x2yxb53d.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-t9mfztcs.js";import"./chunk-zaaeneq6.js";import"./chunk-20g54d4x.js";import"./chunk-wcez7djm.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Mu as buildForProduction};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{yn}from"./chunk-hb08vrbb.js";import{W,Ae,ce,Rt,At,cr,f,Ya,Mo,F,_}from"./chunk-
|
|
2
|
+
import{yn}from"./chunk-hb08vrbb.js";import{W,Ae,ce,Rt,At,cr,f,Ya,Mo,F,_}from"./chunk-20g54d4x.js";import{H}from"./chunk-fbtv2k1p.js";var V=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function B(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(V.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var q=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function _i(t){let n=[],e=[],r=[],i=0;while(i<t.length){let s=t.indexOf("<",i);if(s===-1)break;let a=Ae(t,s);if(a>s){i=a;continue}let o=W(t,s);if(o>s){let c=t.slice(s,o),u=q.exec(c);if(u){let l=B(u[1],u[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}i=o;continue}i=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var z=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function G(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function U(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,i=r.match(/^[a-z][\w-]*/i);if(i)e.tag=i[0].toLowerCase(),r=r.slice(i[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let o=r.match(/^\.([\w-]+)/);if(o){e.className=o[1],r=r.slice(o[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function X(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function T(t,n="main"){let e=U(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,i=G(t),s;while((s=r.exec(t))!==null){if(P(s.index,i))continue;let a=s[1].toLowerCase(),o=s[2]||"";if(o.trimEnd().endsWith("/")||z.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!X(o,e))continue;let c=s[0],u=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=u;let g=1,m;while((m=l.exec(t))!==null){if(P(m.index,i))continue;let x=m[1]==="/";if(!x&&(m[2]||"").trimEnd().endsWith("/"))continue;if(g+=x?-1:1,g===0)return{openTag:c,openIndex:s.index,start:u,end:m.index,tagName:a}}return null}return null}var lt="private, no-store";function Ci(t){return t.replace(/&#(\d+);/g,(n,e)=>M(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>M(Number.parseInt(e,16),n)).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function M(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function xe(t){return t.headers.get("X-STX-Router")==="true"}function J(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function O(t){return{Vary:J(t,"X-STX-Router")}}import A from"path";var K="stx-page-head:",Y=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,C={dev:null,prod:null};function Z(){let t=H()?"dev":"prod",n=C[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-gzd7bmp5.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;C[t]=`<script>${r()}</script>`}catch{C[t]=""}return C[t]}async function Ei(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=A.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=A.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function js(t,n){try{let e=await Bun.file(t).text(),r=e,i=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(i)r=i[1].trim();let s=_i(e),a=[...s.client.map((d)=>d.fullTag),...s.signals.map((d)=>d.fullTag)],o=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=c.exec(e))!==null)o.push(u[0]);let l=r;for(let d of s.server)l=l.replace(d.fullTag,"");for(let d of s.client)l=l.replace(d.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let g="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,g).replace(/<slot\s*>\s*<\/slot>/gi,g),!l.includes(g))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:m,extractVariables:x,defaultConfig:y,loadStxConfig:R}=await import("./chunk-6v2v7tnf.js"),S=await R(),p={__filename:t,__dirname:A.dirname(t)};for(let d of a){let w=d.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(w&&!d.includes("client")&&!d.includes('type="module"'))await x(w[1],p,t)}let b=await m(l,p,t,{...y,...S,...n},new Set),h=b.indexOf(g);if(h===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:b.substring(0,h),afterSlot:b.substring(h+g.length),filePath:t,shellScripts:a,shellStyles:o}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function $r(t,n,e){let r,i="",s=n.match(Y);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),g=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(g)r=g[1].trim();i=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",o=Z(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -27,5 +27,5 @@ ${o}
|
|
|
27
27
|
`));if(i.length>0)S.push(i.filter((p)=>!c.has(p)).join(`
|
|
28
28
|
`));if(x.length>0)S.push(x.filter((p)=>!c.has(p)).join(`
|
|
29
29
|
`));return S.push(m),S.join(`
|
|
30
|
-
`)}import E from"fs";import I from"path";function $i(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function Ri(t,n){let e=I.join(n,"manifest.json");E.writeFileSync(e,JSON.stringify(t,null,2))}function Ai(t){let n=I.join(t,"manifest.json");if(!E.existsSync(n))return null;try{let e=E.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}function k(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function tt(t){let n=t.headers.get("content-type")||"",e={},r=(i,s)=>{let a=e[i];if(a===void 0)e[i]=s;else if(Array.isArray(a))a.push(s);else e[i]=[a,s]};if(n.includes("multipart/form-data")){let i=await t.formData();for(let[s,a]of i.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[i,s]of new URLSearchParams(await t.text()).entries())r(i,s);return e}return e}function Bs(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function D(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Bs(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let i={};try{i=await tt(e)}catch{}let s=await t.action({request:e,form:i,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,o=et(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...o.length>0?{cookies:o}:{}};let{cookies:u,redirect:l,...g}=a;if(Object.assign(t,g),o.length>0)return{ran:!0,cookies:o}}return{ran:!0}}function et(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(k(e,r));continue}if(r&&typeof r==="object"){let i=r;if(typeof i.value!=="string")continue;n.push(k(e,i.value,i))}}return n}function Pi(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let i of n)r.append("Set-Cookie",i);for(let[i,s]of Object.entries(e??{}))if(i.toLowerCase()!=="location")r.set(i,s);return new Response(null,{status:303,headers:r})}async function kn(t,n={}){let{html:e,context:r,redirect:i,cookies:s}=await nt(t,n),a=Rt(r),o=At(r);if(i)return{html:e,redirect:i,cookies:s,status:a,headers:o};let{extractStreamBoundaries:c}=await import("./chunk-
|
|
30
|
+
`)}import E from"fs";import I from"path";function $i(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function Ri(t,n){let e=I.join(n,"manifest.json");E.writeFileSync(e,JSON.stringify(t,null,2))}function Ai(t){let n=I.join(t,"manifest.json");if(!E.existsSync(n))return null;try{let e=E.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}function k(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function tt(t){let n=t.headers.get("content-type")||"",e={},r=(i,s)=>{let a=e[i];if(a===void 0)e[i]=s;else if(Array.isArray(a))a.push(s);else e[i]=[a,s]};if(n.includes("multipart/form-data")){let i=await t.formData();for(let[s,a]of i.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[i,s]of new URLSearchParams(await t.text()).entries())r(i,s);return e}return e}function Bs(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function D(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Bs(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let i={};try{i=await tt(e)}catch{}let s=await t.action({request:e,form:i,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,o=et(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...o.length>0?{cookies:o}:{}};let{cookies:u,redirect:l,...g}=a;if(Object.assign(t,g),o.length>0)return{ran:!0,cookies:o}}return{ran:!0}}function et(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(k(e,r));continue}if(r&&typeof r==="object"){let i=r;if(typeof i.value!=="string")continue;n.push(k(e,i.value,i))}}return n}function Pi(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let i of n)r.append("Set-Cookie",i);for(let[i,s]of Object.entries(e??{}))if(i.toLowerCase()!=="location")r.set(i,s);return new Response(null,{status:303,headers:r})}async function kn(t,n={}){let{html:e,context:r,redirect:i,cookies:s}=await nt(t,n),a=Rt(r),o=At(r);if(i)return{html:e,redirect:i,cookies:s,status:a,headers:o};let{extractStreamBoundaries:c}=await import("./chunk-nv81qr04.js"),u=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:g}=await import("./chunk-8w06n007.js"),{defaultConfig:m}=await import("./chunk-jqxn430n.js"),x=r.streamBoundaries||{},y={...m,autoShell:!1},R=Object.keys(l).map((p)=>({id:p,render:async()=>{let b=typeof x[p]==="function"?await x[p]():void 0;return g(l[p],{...r,$boundary:b},t.sourceFile,y,new Set)}})),S=new Set(R.map((p)=>p.id));u=[...(u||[]).filter((p)=>!S.has(p.id)),...R]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:s,status:a,headers:o}}async function nt(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Mo(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await f(a,e,t.sourceFile)}catch(o){if(n.__stx_strict_hydration)throw o;console.warn(`[stx] Server script error in ${t.sourceFile}:`,o)}let r=await D(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),i=(a)=>{let o=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=cr(e);if(!c)return o;let u=o.indexOf("</head>");return u<0?c+o:o.slice(0,u)+c+o.slice(u)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Mo(t.html))return{html:i(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,o]of Object.entries(t.placeholders))if(o.expression)try{let c=_(o.expression,e);if(o.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?F(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:i(Ya(t.html,s)),context:e,cookies:r.cookies}}
|
|
31
31
|
export{_i,lt,Ci,xe,O,Ei,js,$r,ze,Ti,Se,$i,Ri,Ai,Bs,Pi,kn};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{zn,Ce}from"./chunk-v2x9vzgw.js";import{L,y,rr,as,S}from"./chunk-5nfc2tw2.js";import{o,R}from"./chunk-r1y1k2ky.js";import{Js}from"./chunk-9zy4kzqk.js";import{Ye}from"./chunk-x34scshq.js";import{c}from"./chunk-zhf01af3.js";import{i,Qe}from"./chunk-eqrkhc18.js";import d from"path";import b from"fs";import{AsyncLocalStorage as gt}from"async_hooks";var ht=11;function X(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||Js(t,e,n)}var ot=2;function ll(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):c(t,"bundle-cache")}function nt(t,e){let n=t;for(let r of xt(e))if(r!==d.sep)n=n.split(r).join("\x00root");return n}var st=new Map;function xt(t){let e=d.resolve(t),n=st.get(e);if(!n){let r=e;try{r=b.realpathSync(e)}catch{}n=[...new Set([e,r])].sort((u,m)=>m.length-u.length),st.set(e,n)}return n}function $t(t,e){try{let n=b.statSync(t),r=d.resolve(e),u=t.startsWith(`${r}${d.sep}`);return{path:u?d.relative(r,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(b.readFileSync(t)).toString(36)}}catch{return null}}function at(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function yt(t,e){for(let n of t){let r=at(n,e);try{let u=b.statSync(r);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(b.readFileSync(r)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var ct=new Map,bt=100;function ul(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function wt(t){let e=G.get(t)??0;if(e>0&&e<bt){G.set(t,e+1);return}G.set(t,1);try{let n=(await b.promises.readdir(t)).filter((l)=>l.endsWith(".js")),r=ul();if(n.length<=r)return;let m=(await Promise.all(n.map(async(l)=>{try{return{name:l,at:(await b.promises.stat(d.join(t,l))).mtimeMs}}catch{return null}}))).filter((l)=>l!==null);m.sort((l,w)=>w.at-l.at);for(let l of m.slice(r)){let w=l.name.slice(0,-3);await b.promises.rm(d.join(t,`${w}.js`),{force:!0}),await b.promises.rm(d.join(t,`${w}.deps.json`),{force:!0})}C("pruned bundle cache to",r,"entries")}catch{}}function _e(t){return ct.get(t)??[]}function q(t,e){if(t)ct.set(t,e)}function dl(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function C(...t){if(dl())console.log("[stx:bundler]",...t)}var Y=[];function Qi(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function Gt(){return Y.slice()}function Kt(){Y.length=0}var Z;function rp(t){Z=t}function ea(){if(Z)return Z;try{let t=R.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function Xt(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!Q.some((l)=>l.test(u)))return C("detected user import:",u),!0}let r=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=r.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Q.some((l)=>l.test(u)))return C("detected side-effect import:",u),!0}return!1}var Fn="stx-module:",St=/\.(?:[cm]?[jt]sx?|json)$/i;function pl(t,e){return d.relative(t,e).split(d.sep).join("/")}function fl(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,r,u,m)=>{let l=e.get(m);return l&&!m.startsWith(Fn)?`${r}${u}${l}${u}`:n})}function gl(t,e){let n=0,r=(m)=>{let l=`__stxMod${n++}`,w=JSON.stringify(m);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${w}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(w)} + " is not registered on this page (#1957)");`),l},u=(m,l)=>{for(let w of m.split(",")){let F=w.trim();if(!F)continue;let j=F.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let p=j[1].startsWith('"')?JSON.parse(j[1]):j[1],s=j[2]??p;e.push(`var ${s} = ${l}[${JSON.stringify(p)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l,w)=>{let F=w.slice(Fn.length),j=r(F),p=l.trim(),s=p.match(/^([\w$]+)\s*(?:,\s*|$)/);if(s&&!p.startsWith("{")&&!p.startsWith("*"))e.push(`var ${s[1]} = ${j}.default;`),p=p.slice(s[0].length).trim();let a=p.match(/^\*\s*as\s+([\w$]+)$/);if(a)e.push(`var ${a[1]} = ${j};`);else if(p.startsWith("{"))u(p.replace(/^\{|\}$/g,""),j);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l)=>(r(l.slice(Fn.length)),"")),t}function rt(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(b.existsSync(n)&&b.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var K=new gt;function qs(t,e){let n=new Bun.CryptoHasher("md5");for(let[r,u]of[...t].sort(([m],[l])=>m<l?-1:m>l?1:0))n.update(`${r}\x00${u}\x00`);return K.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Jt(){return K.getStore()?.key??""}function vt(t,e,n,r,u,m=new Map,l,w){let F=(p,s,a)=>{if(X(s,t,l))return null;if(!u||p!==n||!St.test(s))return null;try{if(!b.statSync(s,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}r.add(s);let h=`${Fn}${pl(process.cwd(),s)}`;return m.set(a,h),{path:h,external:!0}},j=(p,s)=>{let a=p===n?e:d.dirname(p),h=d.resolve(a,s);return rt(h)??h};return{name:"stx-client-bundle",setup(p){if(p.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^\//},(s)=>{let a=rt(s.path);if(a){let h=F(s.importer,a,s.path);if(h)return h;if(a!==n)r.add(a);return{path:a}}return{path:s.path,external:!0}}),p.onResolve({filter:/^\.\.?\//},(s)=>{let a=j(s.importer,s.path),h=F(s.importer,a,s.path);if(h)return h;return r.add(a),{path:a}}),p.onResolve({filter:/^[@~]\//},(s)=>{let a=d.resolve(t,s.path.slice(2)),h=[a,`${a}.ts`,`${a}.tsx`,`${a}.js`,`${a}.mjs`,`${a}.jsx`,d.join(a,"index.ts"),d.join(a,"index.tsx"),d.join(a,"index.js"),d.join(a,"index.mjs")];for(let I of h)if(b.existsSync(I)&&b.statSync(I,{throwIfNoEntry:!1})?.isFile()){let E=F(s.importer,I,s.path);if(E)return E;return C(`resolved ${s.path[0]}/ import:`,s.path,"\u2192",I),r.add(I),{path:I}}return console.warn(`[stx:bundler] could not resolve ${s.path[0]}/ import:`,s.path),{path:a}}),u)p.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(s)=>{if(s.importer!==n)return;let a=`${Fn}npm:${s.path}`;return m.set(s.path,a),{path:a,external:!0}});p.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(s)=>{if(X(s.path,t,l))throw Error(`Server-only API source cannot be imported by a client script: ${s.path}`);let a=d.extname(s.path).toLowerCase(),h=a===".json"?"json":a===".tsx"?"tsx":a===".jsx"?"jsx":a===".ts"||a===".mts"||a===".cts"?"ts":"js";if(s.path!==n)r.add(s.path);let I=w?.get(s.path);if(I!==void 0)return{contents:I,loader:"js"};return{contents:b.readFileSync(s.path,"utf8"),loader:h}})}}}var H=new Map,z=y(64),it=Symbol.for("stx.client-bundle-build-queue");function ml(t){let e=globalThis,r=(e[it]??Promise.resolve()).then(t,t);return e[it]=r.then(()=>{return},()=>{return}),r}async function Yt(t,e,n={}){let r=n.projectRoot||process.cwd(),u=(await o(r)).serverApi,m=n.minify??!1,l=n.externalizeUserModules??!0,w=n.expose?.length?[...new Set(n.expose)].sort():void 0,F=n.cacheDir||ll(r),j=K.getStore(),p=new Bun.CryptoHasher("md5");p.update(`${ht}\x00${Ye()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${w?w.join(","):"*"}\x00${m?"minified":"readable"}\x00${j?.key??""}\x00${nt(t,r)}\x00${nt(e,r)}`);let s=p.digest("hex").slice(0,12),a=d.join(F,`${s}.js`),h=z.get(a);if(h){if(as(h.files)&&h.files.every((M)=>!X(M.path,r,u))){C("memo hit:",s);let M=h.files.map((A)=>A.path);return q(e,M),n.collectInputs?.push(...M),h.code}z.delete(a),C("memo invalidated by dep change:",s)}let I=d.join(F,`${s}.deps.json`),E=Bun.file(a);if(await E.exists()){let M=Bun.file(I),A=!1,O=null;if(await M.exists())try{let D=JSON.parse(await M.text());if(D.metadataVersion===ot&&Array.isArray(D.files)&&yt(D.files,r))O=rr(D.files.map((g)=>at(g,r))),A=O.length===D.files.length&&!O.some((g)=>X(g.path,r,u))}catch{A=!1}if(A){if(C("cache hit:",s),O)q(e,O.map((T)=>T.path)),n.collectInputs?.push(...O.map((T)=>T.path));let D=await E.text(),g=new Date;if(b.promises.utimes(a,g,g).catch(()=>{}),O)z.set(a,{code:D,files:O});return D}C("cache invalidated by dep change:",s)}let P=H.get(s);if(P){let M=await P;if(n.collectInputs)n.collectInputs.push(...(z.get(a)?.files??[]).map((A)=>A.path));return M}let V=ml(()=>jt(t,e,{projectRoot:r,minify:m,cacheDir:F,hash:s,cachePath:a,depsPath:I,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:w,throwOnFailure:n.throwOnFailure,substitutes:j?.modules}));H.set(s,V);try{return await V}finally{H.delete(s)}}var Bt=0;function hl(t){return`${t}-${process.pid}-${++Bt}`}async function jt(t,e,n){let{projectRoot:r,minify:u,cacheDir:m,hash:l,cachePath:w,depsPath:F,externalizeUserModules:j}=n,p=c(r,"bundle-tmp"),s=hl(l),a=d.join(p,`${s}.ts`),h=d.join(p,"out",s);b.mkdirSync(p,{recursive:!0}),b.mkdirSync(h,{recursive:!0});let I=d.dirname(e),E=new Set,P=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,M=i(t),{depths:A,balanced:O}=Qe(M),D=(B)=>!O||A[B]===0,g;while((g=P.exec(M))!==null){if(g[1])continue;if(!D(g.index))continue;if(g[2])g[2].split(",").forEach((B)=>{let f=Et(B);if(f)E.add(f)});else if(g[3])E.add(g[3])}while((g=V.exec(M))!==null){if(g[1])continue;if(!D(g.index))continue;E.add(g[2])}let T=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=T.exec(M))!==null){if(!D(g.index))continue;let B=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(B&&Q.some((f)=>f.test(B)))continue;if(g[1])E.add(g[1]);if(g[2])E.add(g[2]);for(let f of(g[3]??"").split(",")){let v=f.trim();if(!v||/^type\s/.test(v))continue;let U=/\bas\s+(\w+)\s*$/.exec(v)?.[1]??/^\w+$/.exec(v)?.[0];if(U)E.add(U)}}for(let B of M.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of B[1].split(",")){let v=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(v)E.delete(v)}let lt=E.size>0?`
|
|
2
|
+
import{zn,Ce}from"./chunk-v2x9vzgw.js";import{L,y,rr,as,S}from"./chunk-20g54d4x.js";import{o,R}from"./chunk-g8xht25s.js";import{Js}from"./chunk-bmtxdtcd.js";import{Ye}from"./chunk-x34scshq.js";import{c}from"./chunk-zhf01af3.js";import{i,Qe}from"./chunk-eqrkhc18.js";import d from"path";import b from"fs";import{AsyncLocalStorage as gt}from"async_hooks";var ht=11;function X(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||Js(t,e,n)}var ot=2;function ll(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):c(t,"bundle-cache")}function nt(t,e){let n=t;for(let r of xt(e))if(r!==d.sep)n=n.split(r).join("\x00root");return n}var st=new Map;function xt(t){let e=d.resolve(t),n=st.get(e);if(!n){let r=e;try{r=b.realpathSync(e)}catch{}n=[...new Set([e,r])].sort((u,m)=>m.length-u.length),st.set(e,n)}return n}function $t(t,e){try{let n=b.statSync(t),r=d.resolve(e),u=t.startsWith(`${r}${d.sep}`);return{path:u?d.relative(r,t):t,...u?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(b.readFileSync(t)).toString(36)}}catch{return null}}function at(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function yt(t,e){for(let n of t){let r=at(n,e);try{let u=b.statSync(r);if(u.size!==n.size)return!1;if(u.mtimeMs!==n.mtimeMs&&Bun.hash(b.readFileSync(r)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var ct=new Map,bt=100;function ul(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function wt(t){let e=G.get(t)??0;if(e>0&&e<bt){G.set(t,e+1);return}G.set(t,1);try{let n=(await b.promises.readdir(t)).filter((l)=>l.endsWith(".js")),r=ul();if(n.length<=r)return;let m=(await Promise.all(n.map(async(l)=>{try{return{name:l,at:(await b.promises.stat(d.join(t,l))).mtimeMs}}catch{return null}}))).filter((l)=>l!==null);m.sort((l,w)=>w.at-l.at);for(let l of m.slice(r)){let w=l.name.slice(0,-3);await b.promises.rm(d.join(t,`${w}.js`),{force:!0}),await b.promises.rm(d.join(t,`${w}.deps.json`),{force:!0})}C("pruned bundle cache to",r,"entries")}catch{}}function _e(t){return ct.get(t)??[]}function q(t,e){if(t)ct.set(t,e)}function dl(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function C(...t){if(dl())console.log("[stx:bundler]",...t)}var Y=[];function Qi(t,e,n){Y.push({filePath:t||"<inline>",message:e,details:n})}function Gt(){return Y.slice()}function Kt(){Y.length=0}var Z;function rp(t){Z=t}function ea(){if(Z)return Z;try{let t=R.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function Xt(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let u=n[1];if(!Q.some((l)=>l.test(u)))return C("detected user import:",u),!0}let r=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=r.exec(t))!==null){let u=n[1];if(/\.css(?:\?.*)?$/.test(u))continue;if(!Q.some((l)=>l.test(u)))return C("detected side-effect import:",u),!0}return!1}var Fn="stx-module:",St=/\.(?:[cm]?[jt]sx?|json)$/i;function pl(t,e){return d.relative(t,e).split(d.sep).join("/")}function fl(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,r,u,m)=>{let l=e.get(m);return l&&!m.startsWith(Fn)?`${r}${u}${l}${u}`:n})}function gl(t,e){let n=0,r=(m)=>{let l=`__stxMod${n++}`,w=JSON.stringify(m);return e.push(`var ${l} = globalThis.__stxModules && globalThis.__stxModules[${w}];`,`if (${l} === undefined) throw new Error("[stx] module " + ${JSON.stringify(w)} + " is not registered on this page (#1957)");`),l},u=(m,l)=>{for(let w of m.split(",")){let F=w.trim();if(!F)continue;let j=F.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!j)continue;let p=j[1].startsWith('"')?JSON.parse(j[1]):j[1],s=j[2]??p;e.push(`var ${s} = ${l}[${JSON.stringify(p)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l,w)=>{let F=w.slice(Fn.length),j=r(F),p=l.trim(),s=p.match(/^([\w$]+)\s*(?:,\s*|$)/);if(s&&!p.startsWith("{")&&!p.startsWith("*"))e.push(`var ${s[1]} = ${j}.default;`),p=p.slice(s[0].length).trim();let a=p.match(/^\*\s*as\s+([\w$]+)$/);if(a)e.push(`var ${a[1]} = ${j};`);else if(p.startsWith("{"))u(p.replace(/^\{|\}$/g,""),j);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(m,l)=>(r(l.slice(Fn.length)),"")),t}function rt(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(b.existsSync(n)&&b.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var K=new gt;function qs(t,e){let n=new Bun.CryptoHasher("md5");for(let[r,u]of[...t].sort(([m],[l])=>m<l?-1:m>l?1:0))n.update(`${r}\x00${u}\x00`);return K.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function Jt(){return K.getStore()?.key??""}function vt(t,e,n,r,u,m=new Map,l,w){let F=(p,s,a)=>{if(X(s,t,l))return null;if(!u||p!==n||!St.test(s))return null;try{if(!b.statSync(s,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}r.add(s);let h=`${Fn}${pl(process.cwd(),s)}`;return m.set(a,h),{path:h,external:!0}},j=(p,s)=>{let a=p===n?e:d.dirname(p),h=d.resolve(a,s);return rt(h)??h};return{name:"stx-client-bundle",setup(p){if(p.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(s)=>({path:s.path,external:!0})),p.onResolve({filter:/^\//},(s)=>{let a=rt(s.path);if(a){let h=F(s.importer,a,s.path);if(h)return h;if(a!==n)r.add(a);return{path:a}}return{path:s.path,external:!0}}),p.onResolve({filter:/^\.\.?\//},(s)=>{let a=j(s.importer,s.path),h=F(s.importer,a,s.path);if(h)return h;return r.add(a),{path:a}}),p.onResolve({filter:/^[@~]\//},(s)=>{let a=d.resolve(t,s.path.slice(2)),h=[a,`${a}.ts`,`${a}.tsx`,`${a}.js`,`${a}.mjs`,`${a}.jsx`,d.join(a,"index.ts"),d.join(a,"index.tsx"),d.join(a,"index.js"),d.join(a,"index.mjs")];for(let I of h)if(b.existsSync(I)&&b.statSync(I,{throwIfNoEntry:!1})?.isFile()){let E=F(s.importer,I,s.path);if(E)return E;return C(`resolved ${s.path[0]}/ import:`,s.path,"\u2192",I),r.add(I),{path:I}}return console.warn(`[stx:bundler] could not resolve ${s.path[0]}/ import:`,s.path),{path:a}}),u)p.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(s)=>{if(s.importer!==n)return;let a=`${Fn}npm:${s.path}`;return m.set(s.path,a),{path:a,external:!0}});p.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(s)=>{if(X(s.path,t,l))throw Error(`Server-only API source cannot be imported by a client script: ${s.path}`);let a=d.extname(s.path).toLowerCase(),h=a===".json"?"json":a===".tsx"?"tsx":a===".jsx"?"jsx":a===".ts"||a===".mts"||a===".cts"?"ts":"js";if(s.path!==n)r.add(s.path);let I=w?.get(s.path);if(I!==void 0)return{contents:I,loader:"js"};return{contents:b.readFileSync(s.path,"utf8"),loader:h}})}}}var H=new Map,z=y(64),it=Symbol.for("stx.client-bundle-build-queue");function ml(t){let e=globalThis,r=(e[it]??Promise.resolve()).then(t,t);return e[it]=r.then(()=>{return},()=>{return}),r}async function Yt(t,e,n={}){let r=n.projectRoot||process.cwd(),u=(await o(r)).serverApi,m=n.minify??!1,l=n.externalizeUserModules??!0,w=n.expose?.length?[...new Set(n.expose)].sort():void 0,F=n.cacheDir||ll(r),j=K.getStore(),p=new Bun.CryptoHasher("md5");p.update(`${ht}\x00${Ye()}\x00${JSON.stringify(u??!1)}\x00${l?"registry":"inline"}\x00${w?w.join(","):"*"}\x00${m?"minified":"readable"}\x00${j?.key??""}\x00${nt(t,r)}\x00${nt(e,r)}`);let s=p.digest("hex").slice(0,12),a=d.join(F,`${s}.js`),h=z.get(a);if(h){if(as(h.files)&&h.files.every((M)=>!X(M.path,r,u))){C("memo hit:",s);let M=h.files.map((A)=>A.path);return q(e,M),n.collectInputs?.push(...M),h.code}z.delete(a),C("memo invalidated by dep change:",s)}let I=d.join(F,`${s}.deps.json`),E=Bun.file(a);if(await E.exists()){let M=Bun.file(I),A=!1,O=null;if(await M.exists())try{let D=JSON.parse(await M.text());if(D.metadataVersion===ot&&Array.isArray(D.files)&&yt(D.files,r))O=rr(D.files.map((g)=>at(g,r))),A=O.length===D.files.length&&!O.some((g)=>X(g.path,r,u))}catch{A=!1}if(A){if(C("cache hit:",s),O)q(e,O.map((T)=>T.path)),n.collectInputs?.push(...O.map((T)=>T.path));let D=await E.text(),g=new Date;if(b.promises.utimes(a,g,g).catch(()=>{}),O)z.set(a,{code:D,files:O});return D}C("cache invalidated by dep change:",s)}let P=H.get(s);if(P){let M=await P;if(n.collectInputs)n.collectInputs.push(...(z.get(a)?.files??[]).map((A)=>A.path));return M}let V=ml(()=>jt(t,e,{projectRoot:r,minify:m,cacheDir:F,hash:s,cachePath:a,depsPath:I,collectInputs:n.collectInputs,externalizeUserModules:l,serverApi:u,expose:w,throwOnFailure:n.throwOnFailure,substitutes:j?.modules}));H.set(s,V);try{return await V}finally{H.delete(s)}}var Bt=0;function hl(t){return`${t}-${process.pid}-${++Bt}`}async function jt(t,e,n){let{projectRoot:r,minify:u,cacheDir:m,hash:l,cachePath:w,depsPath:F,externalizeUserModules:j}=n,p=c(r,"bundle-tmp"),s=hl(l),a=d.join(p,`${s}.ts`),h=d.join(p,"out",s);b.mkdirSync(p,{recursive:!0}),b.mkdirSync(h,{recursive:!0});let I=d.dirname(e),E=new Set,P=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,M=i(t),{depths:A,balanced:O}=Qe(M),D=(B)=>!O||A[B]===0,g;while((g=P.exec(M))!==null){if(g[1])continue;if(!D(g.index))continue;if(g[2])g[2].split(",").forEach((B)=>{let f=Et(B);if(f)E.add(f)});else if(g[3])E.add(g[3])}while((g=V.exec(M))!==null){if(g[1])continue;if(!D(g.index))continue;E.add(g[2])}let T=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=T.exec(M))!==null){if(!D(g.index))continue;let B=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(B&&Q.some((f)=>f.test(B)))continue;if(g[1])E.add(g[1]);if(g[2])E.add(g[2]);for(let f of(g[3]??"").split(",")){let v=f.trim();if(!v||/^type\s/.test(v))continue;let U=/\bas\s+(\w+)\s*$/.exec(v)?.[1]??/^\w+$/.exec(v)?.[0];if(U)E.add(U)}}for(let B of M.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let f of B[1].split(",")){let v=/\bas\s+(\w+)\s*$/.exec(f)?.[1]??/^\s*(\w+)\s*$/.exec(f)?.[1];if(v)E.delete(v)}let lt=E.size>0?`
|
|
3
3
|
export { ${[...E].join(", ")} }`:"";await Bun.write(a,t+lt),C("bundling:",l,"from:",d.basename(e));let tt=new Set,et=new Map;try{let B=await Bun.build({entrypoints:[a],outdir:h,target:"browser",format:"esm",minify:u?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[vt(r,I,a,tt,j,et,n.serverApi,n.substitutes)],define:{"process.env.NODE_ENV":u?'"production"':'"development"',...S()},root:r});if(!B.success){let _=B.logs.filter((N)=>N.level==="error").map((N)=>N.message).join(", ")||`Unable to bundle ${d.basename(e)}`,k=zn(B.logs,e||void 0);if(console.warn("[stx:bundler] build failed:",_),Qi(e||"",_,k),n.throwOnFailure||ea()==="error")throw Error(_);return t}let f="";for(let x of B.outputs){f=await x.text();break}let v=[];for(let x of f.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let _ of x[1].split(",")){let k=_.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(k){v.push([k[2],k[1]]);continue}let N=_.trim();if(/^[A-Za-z_$][\w$]*$/.test(N))v.push([N,N])}if(n.expose){let x=new Set(n.expose);for(let _=v.length-1;_>=0;_--)if(!x.has(v[_][0]))v.splice(_,1)}let U=[];f=gl(fl(f,et),U);let ut=f.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(f=f.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),u&&f)try{f=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(f)}catch{}let J=`__stxBundle_${l}`,dt=new Set(L(t,!0).split(",").map((x)=>x.trim())),pt=v.map(([x,_])=>`get ${JSON.stringify(x)}() { return ${_} }${dt.has(x)?`, set ${JSON.stringify(x)}(__stxValue_${_}) { ${_} = __stxValue_${_} }`:""}`).join(", "),ft=v.map(([x])=>`var ${x} = undefined;`).join(`
|
|
4
4
|
`),mt=v.map(([x])=>`${x} = ${J}[${JSON.stringify(x)}];`).join(`
|
|
5
5
|
`);if(f=`${ut.join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{l,d,E,u,z}from"./chunk-hb08vrbb.js";import{L,ns,B,Re,ae,ar,Ne,De,n,g,be,k}from"./chunk-
|
|
2
|
+
import{l,d,E,u,z}from"./chunk-hb08vrbb.js";import{L,ns,B,Re,ae,ar,Ne,De,n,g,be,k}from"./chunk-20g54d4x.js";import{rt}from"./chunk-7rta163c.js";import{T}from"./chunk-ce6zddpf.js";import{ee}from"./chunk-r7kmsq3n.js";import{U,qe}from"./chunk-szyqxcfj.js";import{C,bn}from"./chunk-fbtv2k1p.js";import A from"path";import{existsSync as St}from"fs";function at(a,t){let c=0;for(let i=t;i<a.length;i++){let b=a[i];if(b==="("||b==="["||b==="{")c++;else if(b===")"||b==="]"||b==="}")c--;else if(b===","&&c===0)return i}return-1}function yt(a,t,c){let i=a,b=new RegExp(`${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),s=b.exec(i);while(s){let m=s.index,e=m+s[0].length-1,D=1,H=e+1;while(H<i.length&&D>0){if(i[H]==="(")D++;else if(i[H]===")")D--;H++}if(D!==0)break;let it=i.substring(e+1,H-1),j=`${c}(${it})`;i=i.substring(0,m)+j+i.substring(H),b.lastIndex=m+j.length,s=b.exec(i)}return i}function $t(a){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(a)}function mt(a){let t=a,c=[],i=new Set,b=0,s=0,m=t.length,e=(j)=>{s++;while(s<m){if(t[s]==="\\"){s+=2;continue}if(t[s]===j){s++;return}s++}},D=()=>{s++;while(s<m){if(t[s]==="\\"){s+=2;continue}if(t[s]==="`"){s++;return}if(t[s]==="$"&&t[s+1]==="{"){s+=2;let j=1;while(s<m&&j>0)if(t[s]==="{")j++,s++;else if(t[s]==="}")j--,s++;else if(t[s]==="'"||t[s]==='"')e(t[s]);else if(t[s]==="`")D();else s++;continue}s++}},H=()=>{if(t[s]==="/"&&t[s+1]==="/"){while(s<m&&t[s]!==`
|
|
3
3
|
`)s++;return!0}if(t[s]==="/"&&t[s+1]==="*"){s+=2;while(s<m-1&&!(t[s]==="*"&&t[s+1]==="/"))s++;return s+=2,!0}return!1},it=()=>{if(b!==0)return;let j=t.slice(s).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(j){let V=j[2];if(!i.has(V))c.push(V),i.add(V);return}let et=t.slice(s).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(et){let V=et[1];if(!i.has(V))c.push(V),i.add(V);return}let Y=t.slice(s).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Y){let V=Y[1];if(!i.has(V))c.push(V),i.add(V)}};while(s<m){if(H())continue;if(t[s]==="'"||t[s]==='"'){e(t[s]);continue}if(t[s]==="`"){D();continue}if(t[s]==="{"){b++,s++;continue}if(t[s]==="}"){b--,s++;continue}if(b===0&&/[a-z]/i.test(t[s])&&(s===0||/\s|[;{}()]/.test(t[s-1])))it();s++}return c.join(", ")}function Et(a,t=""){let c=mt(a).split(",").map((i)=>i.trim()).filter(Boolean);return`
|
|
4
4
|
(function() {
|
|
5
5
|
${rt("var",c)}
|
|
@@ -44,10 +44,10 @@ ${s}
|
|
|
44
44
|
}
|
|
45
45
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
46
46
|
}
|
|
47
|
-
})();`;return c+a+i}function It(a,t){if(U(a)){let b=U(a).tag.match(/data-stx-scope="([^"]*)"/);if(b)return{html:a,mergedIntoExisting:b[1],stamped:!0,root:"body"};return{html:qe(a,(s,m)=>`<body${m} data-stx-scope="${t}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let c=a.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(c){let i=c[2]+c[3],b=c[2].slice(1),s=i.match(/data-stx-scope="([^"]*)"/);if(s)return{html:a,mergedIntoExisting:s[1],stamped:!0,root:b};let m=c[1],e=c[2],D=c[3];return{html:`${m}${e} data-stx-scope="${t}"${D}${a.slice(c[0].length)}`,mergedIntoExisting:null,stamped:!0,root:b}}return{html:a,mergedIntoExisting:null,stamped:!1,root:null}}var Mt=0;function ut(a,t){let c=A.basename(a,".stx").replace(/[^a-zA-Z0-9]/g,"_"),i=t.__stx_scope_seq;return i?`stx_scope_${c}_${++i.n}_${i.key}`:`stx_scope_${c}_${++Mt}`}var lt=new Set,pt=new Set;function lp(){lt.clear(),pt.clear()}var Tt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Sl(a){let t=(e)=>e.replace(/[^\n]/g," "),c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,t).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,t).replace(/<!--[\s\S]*?-->/g,t).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,t).replace(/\{\{[\s\S]*?\}\}/g,t).replace(/\{!![\s\S]*?!!\}/g,t),i=[],b=0,s=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,m;while((m=s.exec(c))!==null){let e=m[1]==="/",D=m[2],H=m[3]==="/"||Tt.has(D.toLowerCase());if(e){b=Math.max(0,b-1);continue}if(b===0)i.push(D);if(!H)b++}return i}function ft(a){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(a)}var We=new B(500),sa=new Set;function up(){sa.clear()}function Ct(a){if(a.__onceStore instanceof Set)return a.__onceStore;return sa}async function Dr(a,t,c,i,b,s=new Set){let m=i.partialsDir||A.join(A.dirname(c),"partials");if(m&&!A.isAbsolute(m))m=A.resolve(process.cwd(),m);let e=yt(a,"@partial","@include"),D=Ct(t);e=e.replace(/@once([\s\S]*?)@endonce/g,(h,R,x)=>{let f=R.trim(),r=`${c}:${f}`;if(D.has(r))return"";return D.add(r),R});{let h=/@includeIf\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,f=x+R[0].length-1,r=1,_=f+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")")r--;_++}if(r!==0)break;let p=e.substring(f+1,_-1),o=p.match(/^\s*['"]([^'"]+)['"]/);if(!o){h.lastIndex=_;continue}let O=o[1],W=H(O,m,c),v="";if(W&&await Bun.file(W).exists())b.add(W),v=`@include(${p})`;e=e.substring(0,x)+v+e.substring(_),h.lastIndex=0}}for(let[h,R]of[["@includeWhen",!1],["@includeUnless",!0]]){let x=new RegExp(`${h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),f;while((f=x.exec(e))!==null){let r=f.index,_=r+f[0].length-1,p=1,o=_+1;while(o<e.length&&p>0){if(e[o]==="(")p++;else if(e[o]===")")p--;o++}if(p!==0)break;let O=e.substring(_+1,o-1),W=at(O,0);if(W===-1){x.lastIndex=o;continue}let v=O.substring(0,W).trim(),X=O.substring(W+1).trim(),F=X.match(/^\s*['"]([^'"]+)['"]/);if(!F){x.lastIndex=o;continue}let w=F[1],J=X.substring(F[0].length),N,I=at(J,0);if(I!==-1)N=J.substring(I+1).trim();try{let M=`Boolean(${v})`,P;if(d(M)){let ot=u(M,Object.keys(t));P=Boolean(ot(...Object.values(t)))}else P=Boolean(l(M,t));let tt=R?!P:P,nt="";if(tt){let ot=H(w,m,c);if(ot&&await Bun.file(ot).exists())b.add(ot);nt=`@include('${w}'${N?`, ${N}`:""})`}e=e.substring(0,r)+nt+e.substring(o),x.lastIndex=0}catch(M){let P=M instanceof Error?M.message:String(M),tt=g("Include",`Error evaluating ${h} condition: ${P}`,c,a,r);e=e.substring(0,r)+tt+e.substring(o),x.lastIndex=0}}}{let h=/@each\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,f=x+R[0].length-1,r=1,_=f+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")"){if(r--,r===0)break}_++}if(r!==0)break;let p=e.substring(f+1,_),o=e.substring(x,_+1),O=p.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let[,W,v,X,F]=O;try{let w,J=v.trim();if(d(J))w=u(J,Object.keys(t))(...Object.values(t));else w=l(J,t);let N="";if(Array.isArray(w)&&w.length>0)for(let I of w){let M={...t,[X]:I},P=await et(W,M,a,x);N+=P}else if(F)N=await et(F,{},a,x);e=e.substring(0,x)+N+e.substring(_+1),h.lastIndex=0}catch(w){let J=w instanceof Error?w.message:String(w);e=e.substring(0,x)+g("Each",`Error in @each: ${J}`,c,a,x)+e.substring(_+1),h.lastIndex=0}}}{let h=/@includeFirst\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,f=x+R[0].length-1,r=1,_=f+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")"){if(r--,r===0)break}_++}if(r!==0)break;let p=e.substring(f+1,_),o=e.substring(x,_+1),O=p.match(/^\s*(\[[^\]]+\])/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let W=O[1],v=p.slice(O[0].length),X,F=v.match(/^\s*,\s*\{/);if(F){v=v.slice(F[0].length-1);let N=1,I=1;while(I<v.length&&N>0){if(v[I]==="{")N++;else if(v[I]==="}"){if(N--,N===0)break}I++}X=v.substring(0,I+1),v=v.slice(I+1)}let w,J=v.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)w=J[1];try{let N=JSON.parse(W.replace(/'/g,'"')),I={};if(X)try{I=E(X,t)}catch(P){let tt=P instanceof Error?P.message:String(P);if(i.debug){let nt=g("Include",`Error parsing includeFirst variables: ${tt}`,c,a,x,o);e=e.replace(o,()=>nt)}else e=e.replace(o,()=>w||"");continue}let M=!1;for(let P of N){let tt=H(P,m,c);if(!tt)continue;if(await n(tt)){let nt=await et(P,I,a,x);e=e.replace(o,()=>nt),M=!0;break}}if(!M)if(w!==void 0)e=e.replace(o,()=>w);else if(i.debug){let P=g("Include",`None of the includeFirst paths exist: ${W}`,c,a,x,o);e=e.replace(o,()=>P)}else e=e.replace(o,"")}catch(N){let I=N instanceof Error?N.message:String(N),M=g("Include",`Error processing @includeFirst: ${I}`,c,a,x,o);e=e.replace(o,()=>M)}h.lastIndex=0}}function H(h,R,x){try{let f=h;if(!h.endsWith(".stx"))f=`${h}.stx`;let r=A.resolve(R),_=A.resolve(A.dirname(x)),p;if(!f.startsWith("./")&&!f.startsWith("../")){for(let F of i._layerPartialDirs??[]){let w=A.resolve(F,f);if(w.startsWith(`${A.resolve(F)}${A.sep}`)&&St(w))return w}p=A.resolve(R,f)}else p=A.resolve(_,f);let o=A.normalize(p),O=o.startsWith(r+A.sep)||o===r,W=o.startsWith(_+A.sep)||o===_,v=!1,X=A.dirname(_);if(o.startsWith(X+A.sep)){if(!A.relative(X,o).split(A.sep).some((N)=>N.startsWith(".")&&N!=="."&&N!==".."))v=!0}if(!O&&!W&&!v)return console.error(`Security: Path traversal attempt blocked for include path: ${h}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${r}, ${_}`),null;return o}catch(f){return console.error(`Error resolving path ${h}: ${f}`),null}}let it=A.resolve(c);s.add(it);function j(h,R,x,f){return i.onIncludeError?.({includePath:h,templatePath:c,message:R,partialsDir:m}),g("Include",R,c,x,f)}async function et(h,R={},x,f){let r=H(h,m,c);if(!r)return j(h,`Could not resolve path for include: ${h}`,x,f);let _=A.resolve(r);if(s.has(_)){let p=[...s,_].map((o)=>A.basename(o)).join(" -> ");return j(h,`Circular include detected: ${p}`,x,f)}try{b.add(r);let p;if(!p)try{p=await Bun.file(r).text()}catch(y){let q=y instanceof Error?y.message:String(y);return j(h,`Error loading include file ${h}: ${q}`,x,f)}if(p)p=p.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(p&&p.includes("@stream")){let{processStreamDirectives:y}=await import("./chunk-
|
|
47
|
+
})();`;return c+a+i}function It(a,t){if(U(a)){let b=U(a).tag.match(/data-stx-scope="([^"]*)"/);if(b)return{html:a,mergedIntoExisting:b[1],stamped:!0,root:"body"};return{html:qe(a,(s,m)=>`<body${m} data-stx-scope="${t}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let c=a.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(c){let i=c[2]+c[3],b=c[2].slice(1),s=i.match(/data-stx-scope="([^"]*)"/);if(s)return{html:a,mergedIntoExisting:s[1],stamped:!0,root:b};let m=c[1],e=c[2],D=c[3];return{html:`${m}${e} data-stx-scope="${t}"${D}${a.slice(c[0].length)}`,mergedIntoExisting:null,stamped:!0,root:b}}return{html:a,mergedIntoExisting:null,stamped:!1,root:null}}var Mt=0;function ut(a,t){let c=A.basename(a,".stx").replace(/[^a-zA-Z0-9]/g,"_"),i=t.__stx_scope_seq;return i?`stx_scope_${c}_${++i.n}_${i.key}`:`stx_scope_${c}_${++Mt}`}var lt=new Set,pt=new Set;function lp(){lt.clear(),pt.clear()}var Tt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Sl(a){let t=(e)=>e.replace(/[^\n]/g," "),c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,t).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,t).replace(/<!--[\s\S]*?-->/g,t).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,t).replace(/\{\{[\s\S]*?\}\}/g,t).replace(/\{!![\s\S]*?!!\}/g,t),i=[],b=0,s=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,m;while((m=s.exec(c))!==null){let e=m[1]==="/",D=m[2],H=m[3]==="/"||Tt.has(D.toLowerCase());if(e){b=Math.max(0,b-1);continue}if(b===0)i.push(D);if(!H)b++}return i}function ft(a){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(a)}var We=new B(500),sa=new Set;function up(){sa.clear()}function Ct(a){if(a.__onceStore instanceof Set)return a.__onceStore;return sa}async function Dr(a,t,c,i,b,s=new Set){let m=i.partialsDir||A.join(A.dirname(c),"partials");if(m&&!A.isAbsolute(m))m=A.resolve(process.cwd(),m);let e=yt(a,"@partial","@include"),D=Ct(t);e=e.replace(/@once([\s\S]*?)@endonce/g,(h,R,x)=>{let f=R.trim(),r=`${c}:${f}`;if(D.has(r))return"";return D.add(r),R});{let h=/@includeIf\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,f=x+R[0].length-1,r=1,_=f+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")")r--;_++}if(r!==0)break;let p=e.substring(f+1,_-1),o=p.match(/^\s*['"]([^'"]+)['"]/);if(!o){h.lastIndex=_;continue}let O=o[1],W=H(O,m,c),v="";if(W&&await Bun.file(W).exists())b.add(W),v=`@include(${p})`;e=e.substring(0,x)+v+e.substring(_),h.lastIndex=0}}for(let[h,R]of[["@includeWhen",!1],["@includeUnless",!0]]){let x=new RegExp(`${h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),f;while((f=x.exec(e))!==null){let r=f.index,_=r+f[0].length-1,p=1,o=_+1;while(o<e.length&&p>0){if(e[o]==="(")p++;else if(e[o]===")")p--;o++}if(p!==0)break;let O=e.substring(_+1,o-1),W=at(O,0);if(W===-1){x.lastIndex=o;continue}let v=O.substring(0,W).trim(),X=O.substring(W+1).trim(),F=X.match(/^\s*['"]([^'"]+)['"]/);if(!F){x.lastIndex=o;continue}let w=F[1],J=X.substring(F[0].length),N,I=at(J,0);if(I!==-1)N=J.substring(I+1).trim();try{let M=`Boolean(${v})`,P;if(d(M)){let ot=u(M,Object.keys(t));P=Boolean(ot(...Object.values(t)))}else P=Boolean(l(M,t));let tt=R?!P:P,nt="";if(tt){let ot=H(w,m,c);if(ot&&await Bun.file(ot).exists())b.add(ot);nt=`@include('${w}'${N?`, ${N}`:""})`}e=e.substring(0,r)+nt+e.substring(o),x.lastIndex=0}catch(M){let P=M instanceof Error?M.message:String(M),tt=g("Include",`Error evaluating ${h} condition: ${P}`,c,a,r);e=e.substring(0,r)+tt+e.substring(o),x.lastIndex=0}}}{let h=/@each\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,f=x+R[0].length-1,r=1,_=f+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")"){if(r--,r===0)break}_++}if(r!==0)break;let p=e.substring(f+1,_),o=e.substring(x,_+1),O=p.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let[,W,v,X,F]=O;try{let w,J=v.trim();if(d(J))w=u(J,Object.keys(t))(...Object.values(t));else w=l(J,t);let N="";if(Array.isArray(w)&&w.length>0)for(let I of w){let M={...t,[X]:I},P=await et(W,M,a,x);N+=P}else if(F)N=await et(F,{},a,x);e=e.substring(0,x)+N+e.substring(_+1),h.lastIndex=0}catch(w){let J=w instanceof Error?w.message:String(w);e=e.substring(0,x)+g("Each",`Error in @each: ${J}`,c,a,x)+e.substring(_+1),h.lastIndex=0}}}{let h=/@includeFirst\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,f=x+R[0].length-1,r=1,_=f+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")"){if(r--,r===0)break}_++}if(r!==0)break;let p=e.substring(f+1,_),o=e.substring(x,_+1),O=p.match(/^\s*(\[[^\]]+\])/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let W=O[1],v=p.slice(O[0].length),X,F=v.match(/^\s*,\s*\{/);if(F){v=v.slice(F[0].length-1);let N=1,I=1;while(I<v.length&&N>0){if(v[I]==="{")N++;else if(v[I]==="}"){if(N--,N===0)break}I++}X=v.substring(0,I+1),v=v.slice(I+1)}let w,J=v.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)w=J[1];try{let N=JSON.parse(W.replace(/'/g,'"')),I={};if(X)try{I=E(X,t)}catch(P){let tt=P instanceof Error?P.message:String(P);if(i.debug){let nt=g("Include",`Error parsing includeFirst variables: ${tt}`,c,a,x,o);e=e.replace(o,()=>nt)}else e=e.replace(o,()=>w||"");continue}let M=!1;for(let P of N){let tt=H(P,m,c);if(!tt)continue;if(await n(tt)){let nt=await et(P,I,a,x);e=e.replace(o,()=>nt),M=!0;break}}if(!M)if(w!==void 0)e=e.replace(o,()=>w);else if(i.debug){let P=g("Include",`None of the includeFirst paths exist: ${W}`,c,a,x,o);e=e.replace(o,()=>P)}else e=e.replace(o,"")}catch(N){let I=N instanceof Error?N.message:String(N),M=g("Include",`Error processing @includeFirst: ${I}`,c,a,x,o);e=e.replace(o,()=>M)}h.lastIndex=0}}function H(h,R,x){try{let f=h;if(!h.endsWith(".stx"))f=`${h}.stx`;let r=A.resolve(R),_=A.resolve(A.dirname(x)),p;if(!f.startsWith("./")&&!f.startsWith("../")){for(let F of i._layerPartialDirs??[]){let w=A.resolve(F,f);if(w.startsWith(`${A.resolve(F)}${A.sep}`)&&St(w))return w}p=A.resolve(R,f)}else p=A.resolve(_,f);let o=A.normalize(p),O=o.startsWith(r+A.sep)||o===r,W=o.startsWith(_+A.sep)||o===_,v=!1,X=A.dirname(_);if(o.startsWith(X+A.sep)){if(!A.relative(X,o).split(A.sep).some((N)=>N.startsWith(".")&&N!=="."&&N!==".."))v=!0}if(!O&&!W&&!v)return console.error(`Security: Path traversal attempt blocked for include path: ${h}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${r}, ${_}`),null;return o}catch(f){return console.error(`Error resolving path ${h}: ${f}`),null}}let it=A.resolve(c);s.add(it);function j(h,R,x,f){return i.onIncludeError?.({includePath:h,templatePath:c,message:R,partialsDir:m}),g("Include",R,c,x,f)}async function et(h,R={},x,f){let r=H(h,m,c);if(!r)return j(h,`Could not resolve path for include: ${h}`,x,f);let _=A.resolve(r);if(s.has(_)){let p=[...s,_].map((o)=>A.basename(o)).join(" -> ");return j(h,`Circular include detected: ${p}`,x,f)}try{b.add(r);let p;if(!p)try{p=await Bun.file(r).text()}catch(y){let q=y instanceof Error?y.message:String(y);return j(h,`Error loading include file ${h}: ${q}`,x,f)}if(p)p=p.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(p&&p.includes("@stream")){let{processStreamDirectives:y}=await import("./chunk-nv81qr04.js");p=y(p,t)}if(p&&(i.debug||!C()&&!bn()))try{let{warnUnbalancedTags:y}=await import("./chunk-z8p6tk5z.js");y(p,r)}catch{}try{let{processESImports:y}=await import("./chunk-ty6qtdwn.js");p=await y(p,t,r,i,b)}catch(y){if(i.debug)console.warn(`[stx] partial ES import extraction skipped for ${r}:`,y instanceof Error?y.message:y)}let o=p,O=ae(o);if(O)o=O.content.trim();let v=p.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),X="";if(v)X=`<style${v[1]}>${v[2]}</style>`;let F=[];o=o.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(y,q,S)=>{if(!ft(q))return"";return F.push({attrs:q,body:S}),`__STX_DATA_BLOCK_${F.length-1}__`}),o=o.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let w={...t};w.__stx_signals_gate=be(p,r);for(let[y,q]of Object.entries(R))w[y]=q;let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,N=[...p.matchAll(J)].sort((y,q)=>{let S=(y[1]||"").includes("server"),K=(q[1]||"").includes("server");return Number(K)-Number(S)}),I="",M=null,P=!1,tt=!1;for(let y of N){let q=y[1]||"",S=y[2]||"";if(ft(q))continue;let K=q.includes("server"),wt=Ne(q);if(!K&&!/\bsrc\s*=/i.test(q))Re(S,r,i.strict);if(!K&&S.trim()){let{interpolateScriptExpressions:Z}=await import("./chunk-qq5ng2f7.js");S=Z(S,w,h)}let ct="";try{let{extractAndStripCssImports:Z,renderVendorStyleTags:Q}=await import("./chunk-zk9wkhkg.js"),st=Z(S,{filePath:r,projectRoot:process.cwd()});S=st.code,ct=Q(st.styles)}catch(Z){if(i.debug)console.warn(`[stx] vendor-css extractor skipped for ${r}:`,Z instanceof Error?Z.message:Z)}if(wt&&S.trim())S=De(S);if(!K){try{let{injectBrowserCoreAutoImports:Q}=await import("./chunk-zk9wkhkg.js");S=Q(S).code;let{hasUserImports:st,bundleClientScript:bt}=await import("./chunk-pmyn85rn.js");if(st(S))S=await bt(S,r,{projectRoot:process.cwd()})}catch(Q){if(i.debug)console.warn(`[stx] bundler skipped for ${r}:`,Q instanceof Error?Q.message:Q)}let{stripStxRuntimeImports:Z}=await import("./chunk-t267mq36.js");S=Z(S)}let dt=$t(S);if(!K){let{extractBridgeData:Z,generateServerDataBridge:Q}=await import("./chunk-zk9wkhkg.js"),st=Q(S,Z(w));if(st)S=`${st}
|
|
48
48
|
${S}`}if(dt&&!K){P=!0,M=ut(r,t);let Z=T(S),Q=gt(Z,M);I+=`${ct}<script data-stx-scoped data-stx-run="always" data-stx-owner="${M}">${Q}</script>
|
|
49
|
-
`;continue}if(K)try{let{extractVariables:Z}=await import("./chunk-
|
|
50
|
-
`}}if(F.length>0){let{interpolateScriptExpressions:y}=await import("./chunk-
|
|
49
|
+
`;continue}if(K)try{let{extractVariables:Z}=await import("./chunk-fnc50e50.js");await Z(S,w,r)}catch(Z){if(i.debug)console.warn(`Warning: Could not extract variables from server script in ${r}:`,Z)}if(!K&&!dt){let Z=q.replace(/\bclient\b/i,"").trim();M=ut(r,t);let Q=T(S),st=gt(Q,M);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(st))tt=!0;I+=`${ct}<script data-stx-scoped data-stx-run="always" data-stx-owner="${M}"${Z?` ${Z}`:""}>${st}</script>
|
|
50
|
+
`}}if(F.length>0){let{interpolateScriptExpressions:y}=await import("./chunk-qq5ng2f7.js");o=o.replace(/__STX_DATA_BLOCK_(\d+)__/g,(q,S)=>{let K=F[Number(S)];return`<script${K.attrs}>${y(K.body,w,h)}</script>`})}if(M){let y=It(o,M);if(o=y.html,y.mergedIntoExisting){let S=M,K=y.mergedIntoExisting;I=I.split(`'${S}'`).join(`'${K}'`).split(`"${S}"`).join(`"${K}"`),M=K}else if(!y.stamped&&P&&!lt.has(r))lt.add(r),console.warn(`[stx] ${A.relative(process.cwd(),r)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);if(y.stamped&&y.root!=="body"&&(P||tt)&&!pt.has(r)){let S=Sl(o);if(S.length>1)pt.add(r),console.warn(`[stx] ${A.relative(process.cwd(),r)} declares ${P?"signals":"bindings"} and has ${S.length} top-level elements (${S.map((K)=>`<${K}>`).join(", ")}). Only the first is scoped, so bindings in the others cannot see what this partial's script declares. Wrap the partial's markup in a single root element.`)}let q=y.stamped&&y.root!==null&&ar(y.root);I=Rt(I,q?M:null)}if(o.includes("@include")||o.includes("@partial"))o=await Dr(o,w,r,i,b,s);let{processLoops:nt,reportDeferredLoopWarnings:ot}=await import("./chunk-g8h93d38.js"),G=nt(o,w,r,void 0,!0);G=ee(G,w,r),G=ot(G);let{processMetaDirectives:ht,processSeoDirective:xt,processStructuredData:_t}=await import("./chunk-gf3bxnpq.js");if(G=ht(G,w,r,i),G=_t(G,w,r),G=xt(G,w,r,i),G=k(G,w,r),X)G+=`
|
|
51
51
|
`+X;if(I)G+=`
|
|
52
52
|
`+I;return G}catch(p){if(p instanceof z)throw p;let o=p instanceof Error?p.message:String(p);return j(h,`Error processing include ${h}: ${o}`,x,f)}}let Y=/@include\s*\(/g,V;while((V=Y.exec(e))!==null){let h=V.index,R=h+V[0].length-1,x=1,f=R+1;while(f<e.length&&x>0){if(e[f]==="(")x++;else if(e[f]===")")x--;f++}if(x!==0)break;let r=e.substring(h,f),_=e.substring(R+1,f-1),p=_.match(/^\s*['"]([^'"]+)['"]/);if(!p){Y.lastIndex=f;continue}let o=p[1],O,W=_.substring(p[0].length),v=at(W,0);if(v!==-1)O=W.substring(v+1).trim();let X={};if(O)try{X=E(O,t)}catch(w){let J=w instanceof Error?w.message:String(w);e=e.replace(r,g("Include",`Error parsing include variables for ${o}: ${J}`,c,a,h)),Y.lastIndex=0;continue}let F=await et(o,X,a,h);e=e.substring(0,h)+F+e.substring(f),Y.lastIndex=0}return e}function Mr(a,t){let c=a;function i(b,s,m,e){let D=b,H=!0;while(H){H=!1;let it=new RegExp(`@${s}\\(['"]([^'"]+)['"]\\)`),j=D.match(it);if(!j||j.index===void 0)break;let et=j.index,Y=j[1],V=et+j[0].length,h=new RegExp(`@${s}\\(`),R=new RegExp(`@${m}(?![a-z])`),x=1,f=V,r=-1;while(x>0&&f<D.length){let p=D.slice(f),o=p.match(h),O=p.match(R),W=o?f+o.index:1/0,v=O?f+O.index:1/0;if(W<v)x++,f=W+(o[0].length||1);else if(v<1/0){if(x--,x===0){r=v;break}f=v+m.length+1}else break}if(r===-1)break;let _=D.slice(V,r);if(!t[Y])t[Y]=[];if(e)t[Y].unshift(_);else t[Y].push(_);D=D.substring(0,et)+D.substring(r+`@${m}`.length),H=!0}return D}return c=i(c,"push","endpush",!1),c=i(c,"prepend","endprepend",!0),c}function Lr(a,t){return a.replace(/@stack\(['"]([^'"]+)['"]\)/g,(c,i)=>{if(!t[i]||t[i].length===0)return"";return t[i].join(`
|
|
53
53
|
`)})}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{k}from"./chunk-
|
|
2
|
+
import{k}from"./chunk-20g54d4x.js";import{oe}from"./chunk-wbzmr6a4.js";function g(e,t){let r={};for(let n of e)r[n]=oe(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,o)=>{if(r[a])r[a].set(o);else r[a]=oe(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=oe(!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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{El,gp,mp,hp,yp,Tl,$l,bp,vp,uo,wp,Xn,Jn,Wr}from"./chunk-
|
|
2
|
+
import{El,gp,mp,hp,yp,Tl,$l,bp,vp,uo,wp,Xn,Jn,Wr}from"./chunk-px1qz3vc.js";import{Ye}from"./chunk-x34scshq.js";import"./chunk-20g54d4x.js";import"./chunk-wcez7djm.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{yp as __setSignalsGeneratorsForTest,Ye as cacheEngineFingerprint,Jn as cacheTemplate,Xn as checkCache,wp as clearDevCaches,$l as getCachedRouterScript,Tl as getCachedSignalsRuntime,bp as getServeClientAsset,uo as getServeModuleBundle,Wr as hashFilePath,mp as invalidateFileCache,hp as invalidateFileCacheByDir,gp as readFileCached,vp as registerServeModuleBundle,El as templateCache};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$u}from"./chunk-nvgy1y0x.js";import"./chunk-3wtxp6xm.js";import"./chunk-bmtxdtcd.js";import"./chunk-brdbnkwq.js";import"./chunk-g8xht25s.js";import"./chunk-x2yxb53d.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-t9mfztcs.js";import"./chunk-zaaeneq6.js";import"./chunk-20g54d4x.js";import"./chunk-wcez7djm.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{$u as startProductionServer};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{o}from"./chunk-
|
|
2
|
+
import{o}from"./chunk-g8xht25s.js";import{Fs}from"./chunk-vqc4h16r.js";import p from"path";async function Ku(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if(Fs(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");n=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-3632qt5h.js");l=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
|
|
3
3
|
export{Ku};
|
|
@@ -923,7 +923,7 @@ NoDisplay=true`:""}
|
|
|
923
923
|
`;if(!q(i))st(i,{recursive:!0});lt(n,l,"utf-8")}else if(q(n))ct(n)}async function vo(e){return q(ut(e))}async function Po(e){let t=pt(e);if(!q(t))return!1;try{let r=bo(t,"utf-8");if(r.includes("X-GNOME-Autostart-enabled=false"))return!1;if(r.includes("Hidden=true"))return!1;return!0}catch{return!1}}function So(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function ko(e,t={}){let r=dt();switch(r){case"darwin":return xo(e,t);case"linux":return yo(e,t);default:throw Error(`Auto-launch is not yet supported on ${r}`)}}async function Ao(e){let t=e||"StxApp";switch(dt()){case"darwin":return vo(t);case"linux":return Po(t);default:return!1}}var R=new Map,Co=0,se=!1;function ft(e){let t=e.split("+").map((n)=>n.trim()),r={key:"",meta:!1,ctrl:!1,shift:!1,alt:!1};for(let n of t){let i=n.toLowerCase();switch(i){case"cmd":case"command":case"meta":case"\u2318":r.meta=!0;break;case"ctrl":case"control":case"\u2303":r.ctrl=!0;break;case"shift":case"\u21E7":r.shift=!0;break;case"alt":case"option":case"opt":case"\u2325":r.alt=!0;break;case"cmdorctrl":case"commandorcontrol":if(typeof process<"u"&&process.platform==="darwin")r.meta=!0;else r.ctrl=!0;break;default:r.key=i}}return r}function Io(e){let t=[];if(e.ctrl)t.push("\u2303");if(e.alt)t.push("\u2325");if(e.shift)t.push("\u21E7");if(e.meta)t.push("\u2318");return t.push(e.key.toUpperCase()),t.join("")}function $o(e,t){if(t.meta!==e.metaKey)return!1;if(t.ctrl!==e.ctrlKey)return!1;if(t.shift!==e.shiftKey)return!1;if(t.alt!==e.altKey)return!1;return e.key.toLowerCase()===t.key||e.code.toLowerCase()===`key${t.key}`}function mt(e){for(let[,t]of R)if($o(e,t.parsed)){e.preventDefault(),e.stopPropagation();try{t.handler()}catch{}break}}function To(){if(se)return;if(typeof document>"u")return;document.addEventListener("keydown",mt,!0),se=!0}function ke(){if(!se)return;if(typeof document>"u")return;document.removeEventListener("keydown",mt,!0),se=!1}async function Eo(e,t){if(typeof window>"u")return!1;let r=window.craft;if(!r?.hotkeys?.register)return!1;try{return await r.hotkeys.register(e,t),!0}catch{return!1}}async function Ae(e){if(typeof window>"u")return;let t=window.craft;if(!t?.hotkeys?.unregister)return;try{await t.hotkeys.unregister(e)}catch{}}function Mo(e,t){let r=`hotkey_${++Co}_${Date.now()}`,n=ft(e);R.set(r,{shortcut:e,handler:t,parsed:n}),Eo(r,e),To();let i={shortcut:e,id:r,unregister(){gt(i)}};return i}function gt(e){if(R.delete(e.id),Ae(e.id),R.size===0)ke()}function Do(){for(let[e]of R)Ae(e);R.clear(),ke()}function Bo(){return Array.from(R.entries()).map(([e,t])=>({shortcut:t.shortcut,id:e,unregister(){if(R.delete(e),Ae(e),R.size===0)ke()}}))}class ht{_duration;_tickInterval;_remaining;_running=!1;_paused=!1;_complete=!1;_intervalId=null;_lastTick=0;_completionHandlers=new Set;_tickHandlers=new Set;constructor(e){if(this._duration=e.duration,this._tickInterval=e.tickInterval||1000,this._remaining=e.duration,e.onComplete)this._completionHandlers.add(e.onComplete);if(e.onTick)this._tickHandlers.add(e.onTick);if(e.autoStart)this.start()}get isRunning(){return this._running&&!this._paused}get isPaused(){return this._paused}get isComplete(){return this._complete}get remaining(){if(this._running&&!this._paused){let e=Date.now()-this._lastTick;return Math.max(0,this._remaining-e)}return Math.max(0,this._remaining)}get elapsed(){return this._duration-this.remaining}get duration(){return this._duration}get progress(){if(this._duration===0)return 1;return Math.min(1,this.elapsed/this._duration)}start(){if(this._running)return;this._running=!0,this._paused=!1,this._complete=!1,this._lastTick=Date.now(),this._startInterval()}stop(){this._clearInterval(),this._running=!1,this._paused=!1,this._remaining=this._duration}pause(){if(!this._running||this._paused)return;let e=Date.now()-this._lastTick;this._remaining=Math.max(0,this._remaining-e),this._clearInterval(),this._paused=!0}resume(){if(!this._paused)return;this._paused=!1,this._lastTick=Date.now(),this._startInterval()}reset(){this._clearInterval(),this._running=!1,this._paused=!1,this._complete=!1,this._remaining=this._duration}onComplete(e){return this._completionHandlers.add(e),()=>{this._completionHandlers.delete(e)}}onTick(e){return this._tickHandlers.add(e),()=>{this._tickHandlers.delete(e)}}_startInterval(){this._clearInterval(),this._intervalId=setInterval(()=>{let e=Date.now(),t=e-this._lastTick;this._lastTick=e,this._remaining=Math.max(0,this._remaining-t);for(let r of this._tickHandlers)try{r(this._remaining)}catch{}if(this._remaining<=0){this._clearInterval(),this._running=!1,this._complete=!0;for(let r of this._completionHandlers)try{r()}catch{}}},this._tickInterval)}_clearInterval(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null}}class wt{_interval;_handler;_immediate;_running=!1;_intervalId=null;constructor(e){if(this._interval=e.interval,this._handler=e.handler,this._immediate=e.immediate!==!1,this._immediate)this.start()}get isRunning(){return this._running}start(){if(this._running)return;this._running=!0,this._intervalId=setInterval(()=>{try{this._handler()}catch{}},this._interval)}stop(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null;this._running=!1}}function Oo(e){return new ht(e)}function Ro(e){return new wt(e)}function Lo(e){return new Promise((t)=>setTimeout(t,e))}function _o(e){let t=Math.ceil(e/1000),r=Math.floor(t/3600),n=Math.floor(t%3600/60),i=t%60;if(r>0)return`${r}:${String(n).padStart(2,"0")}:${String(i).padStart(2,"0")}`;return`${n}:${String(i).padStart(2,"0")}`}function No(e){let t=Math.ceil(e/1000),r=Math.floor(t/3600),n=Math.floor(t%3600/60),i=t%60;if(r>0){if(n>0)return`${r}h ${n}m`;return`${r}h`}if(n>0){if(i>0)return`${n}m ${i}s`;return`${n}m`}return`${i}s`}function o(e){if(typeof window>"u")return!1;let t=window.craft;return!!(t&&t[e])}function v(e){if(!o(e))throw Error(`craft.${e} is not available \u2014 this API requires a Craft native window`);return window.craft[e]}function h(e,t){if(typeof window>"u")return()=>{};let r=(n)=>t(n.detail??{});return window.addEventListener(e,r),()=>window.removeEventListener(e,r)}var Fo={async writeText(e){if(o("clipboard")){await window.craft.clipboard.writeText(e);return}if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(e)},async readText(){if(o("clipboard")){let e=await window.craft.clipboard.readText();return typeof e==="string"?e:""}if(typeof navigator<"u"&&navigator.clipboard?.readText)try{return await navigator.clipboard.readText()}catch{return""}return""},async writeHTML(e){if(o("clipboard")){await window.craft.clipboard.writeHTML(e);return}if(typeof navigator<"u"&&navigator.clipboard?.write)try{let t=new window.ClipboardItem({"text/html":new Blob([e],{type:"text/html"}),"text/plain":new Blob([Wo(e)],{type:"text/plain"})});await navigator.clipboard.write([t])}catch{}},async readHTML(){if(o("clipboard")){let e=await window.craft.clipboard.readHTML();return typeof e==="string"?e:""}if(typeof navigator<"u"&&navigator.clipboard?.read)try{let e=await navigator.clipboard.read();for(let t of e)if(t.types.includes("text/html"))return await(await t.getType("text/html")).text()}catch{}return""},async clear(){if(o("clipboard")){await window.craft.clipboard.clear();return}if(typeof navigator<"u"&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText("")}catch{}},async hasText(){if(o("clipboard"))return await window.craft.clipboard.hasText();return(await this.readText()).length>0},async hasHTML(){if(o("clipboard"))return await window.craft.clipboard.hasHTML();return(await this.readHTML()).length>0},async hasImage(){if(o("clipboard"))return await window.craft.clipboard.hasImage();return!1}};function Wo(e){return e.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<\/?(br|p|div|li|h[1-6])\b[^>]*>/gi,`
|
|
924
924
|
`).replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/\n{3,}/g,`
|
|
925
925
|
|
|
926
|
-
`).trim()}var zo={async show(e){if(!e.title)throw Error("notification title is required");if(o("notifications")){await window.craft.notifications.show(e);return}if(typeof window<"u"&&"Notification"in window){let t=window.Notification;if(t.permission==="granted")new t(e.title,{body:e.body,icon:e.icon});else if(t.permission==="default"){if(await t.requestPermission()==="granted")new t(e.title,{body:e.body,icon:e.icon})}}},async schedule(e){if(o("notifications")){let n={...e};if(n.triggerAt instanceof Date)n.triggerAt=n.triggerAt.toISOString();await window.craft.notifications.schedule(n);return}let t=Ho(e.triggerAt),r=Math.max(0,t-Date.now());setTimeout(()=>{this.show(e).catch(()=>{})},r)},async cancel(e){if(o("notifications"))await window.craft.notifications.cancel(e)},async cancelAll(){if(o("notifications"))await window.craft.notifications.cancelAll()},async setBadge(e){let t=Math.max(0,Math.round(Number.isFinite(e)?e:0));if(o("notifications")){await window.craft.notifications.setBadge(t);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge(t)}catch{}},async clearBadge(){if(o("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(o("notifications"))return await window.craft.notifications.requestPermission();if(typeof window<"u"&&"Notification"in window){let e=window.Notification;if(e.permission==="granted")return!0;if(e.permission==="denied")return!1;return await e.requestPermission()==="granted"}return!1},async registerCategories(e){if(!Array.isArray(e)||e.length===0)return;if(o("notifications")){let t=window.craft.notifications.registerCategories;if(typeof t==="function")await t(e)}},onActionClicked(e){return h("craft:notification:actionClicked",e)},onReply(e){return h("craft:notification:reply",e)}};function Ho(e){if(e==null)return Date.now();if(e instanceof Date)return e.getTime();if(typeof e==="number")return e;let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}var Uo={async readFile(e){let t=await v("fs").readFile(e);return t&&t.data||""},async readBuffer(e){let t=await v("fs").readFile(e),r=t&&t.data||"";if(t&&t.base64===!0)return Vo(r);return new TextEncoder().encode(r)},async writeFile(e,t){await v("fs").writeFile(e,t)},async writeBuffer(e,t){let r=qo(t),n=v("fs");if(typeof n.writeFileBytes==="function")await n.writeFileBytes(e,r);else await n.writeFile(e,r)},async copy(e,t){if(e===t)throw Error("fs.copy: source and destination must differ");await v("fs").copy(e,t)},async move(e,t){if(e===t)throw Error("fs.move: source and destination must differ");await v("fs").move(e,t)},async appendFile(e,t){await v("fs").appendFile(e,t)},async deleteFile(e){await v("fs").deleteFile(e)},async exists(e){return await v("fs").exists(e)},async stat(e){return jo(await v("fs").stat(e))},async readDir(e){let t=await v("fs").readDir(e),r=t&&t.entries||[],n=e.endsWith("/")?e.slice(0,-1):e;return r.map((i)=>({name:i.name,path:`${n}/${i.name}`,isDirectory:!!i.isDirectory}))},async mkdir(e,t){await v("fs").mkdir(e,t)},async rmdir(e,t){await v("fs").rmdir(e,t)},async watch(e,t){await v("fs").watch(e,t)},async unwatch(e){await v("fs").unwatch(e)},onChange(e){return h("craft:fs:change",e)},async watchTree(e,t,r){let n=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,i=v("fs");await i.watch(e,n,{recursive:!!t.recursive});let a=t.kinds&&t.kinds.length>0?new Set(t.kinds):null,s=Math.max(0,Math.floor(t.coalesceMs??0)),c=[],l=null,d=!1,f=()=>{if(l=null,c.length===0)return;let u=c;c=[];try{r(u)}catch{}},m=h("craft:fs:change",(u)=>{if(d)return;if(u.id!==n)return;if(a&&u.kind&&!a.has(u.kind))return;if(c.push(u),s===0){f();return}if(l==null)l=setTimeout(f,s)});return{id:n,async stop(){if(d)return;if(d=!0,m(),l)clearTimeout(l),l=null;if(c.length>0)f();try{await i.unwatch(n)}catch{}}}},async homeDir(){return await v("fs").homeDir()},async tempDir(){return await v("fs").tempDir()},async appDataDir(){return await v("fs").appDataDir()}};function qo(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return typeof btoa==="function"?btoa(t):Buffer.from(e).toString("base64")}function Vo(e){let t=typeof atob==="function"?atob(e):Buffer.from(e,"base64").toString("binary"),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function jo(e){return{isFile:!!e.isFile,isDirectory:!!e.isDirectory,isSymlink:!!e.isSymlink,size:Number(e.size)||0,modifiedAt:e.modifiedAt!=null?e.modifiedAt<1000000000000?e.modifiedAt*1000:e.modifiedAt:0}}var X=new Set,bt=!1;function Ko(){if(bt)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(e)=>{let t=e.detail;if(t?.id)X.delete(t.id)}),bt=!0}var Go=new Set(["javascript:","data:","file:","vbscript:"]),Yo={async openExternal(e){let t=e.trim().toLowerCase();for(let r of Go)if(t.startsWith(r))throw Error(`shell.openExternal: ${r} URLs are blocked for safety`);if(o("shell")){await window.craft.shell.openExternal(e);return}if(typeof window<"u"&&typeof window.open==="function")window.open(e,"_blank","noopener,noreferrer")},async openPath(e){await v("shell").openPath(e)},async showInFinder(e){await v("shell").showInFinder(e)},async spawn(e,t,r=[],n={}){if(Ko(),!e||typeof e!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!t||typeof t!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray(r))throw Error("shell.spawn: args must be an array");for(let i of r)if(typeof i!=="string")throw Error("shell.spawn: args entries must be strings");if(X.has(e))throw Error(`shell.spawn: id "${e}" is already in use \u2014 call kill(id) first or pick a different id`);X.add(e);try{await v("shell").spawn(e,t,r,n)}catch(i){throw X.delete(e),i}},async kill(e){await v("shell").kill(e),X.delete(e)},async getEnv(e){if(o("shell")){let t=await window.craft.shell.getEnv(e);return t==null?void 0:String(t)}return},async setEnv(e,t){await v("shell").setEnv(e,t)},onStdout(e){return h("craft:shell:stdout",e)},onStderr(e){return h("craft:shell:stderr",e)},onExit(e){return h("craft:shell:exit",e)}};function W(){return window.craft.shortcuts}var Xo={async register(e,t,r){if(!o("shortcuts"))return;await W().register(e,t,r)},async unregister(e){if(!o("shortcuts"))return;await W().unregister(e)},async unregisterAll(){if(!o("shortcuts"))return;await W().unregisterAll()},async enable(e){if(!o("shortcuts"))return;await W().enable(e)},async disable(e){if(!o("shortcuts"))return;await W().disable(e)},async isRegistered(e){if(!o("shortcuts"))return!1;return await W().isRegistered(e)},async list(){if(!o("shortcuts"))return[];return await W().list()},on(e){return h("craft:shortcut",e)}};var Jo={get(){if(o("theme"))try{return window.craft.theme.get()}catch{}return{appearance:Qo()}},onChange(e){if(e(this.get()),o("theme"))return h("craft:theme",e);if(typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>e({appearance:t.matches?"dark":"light"});return t.addEventListener("change",r),()=>t.removeEventListener("change",r)}return()=>{}},async current(){return this.get()}};function Qo(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function Zo(e,t={}){if(!o("dragOut"))throw Error("dragOut requires a Craft native window");let r=Array.isArray(e)?e:[e];if(r.length===0)throw Error("dragOut: at least one path required");await window.craft.dragOut.start(r,t)}function ei(){return o("dragOut")}var ti={onUrl(e){if(!o("deepLink"))return()=>{};return h("craft:deepLink",e)},getInitialUrl(){if(typeof window>"u")return null;if(o("deepLink"))try{return window.craft.deepLink.getInitialUrl()}catch{return null}return window.__craftPendingDeepLink||null},consumeInitialUrl(){let e=this.getInitialUrl();if(typeof window<"u")window.__craftPendingDeepLink=void 0;return e},isAvailable(){return o("deepLink")}};var ri={async isCharging(){if(o("power"))return await window.craft.power.isCharging();let e=await ce();return e?!!e.charging:!1},async isPluggedIn(){if(o("power"))return await window.craft.power.isPluggedIn();let e=await ce();return e?!!e.charging||e.level>=0.999:!1},async isLowPowerMode(){if(o("power"))return await window.craft.power.isLowPowerMode();return!1},async level(){if(o("power")){let t=await window.craft.power.batteryLevel();return typeof t==="number"?t:null}let e=await ce();return e?e.level:null},async timeRemaining(){if(o("power")){let r=await window.craft.power.timeRemaining();return typeof r==="number"?r:null}let e=await ce();if(!e)return null;let t=e.charging?e.chargingTime:e.dischargingTime;return Number.isFinite(t)?Math.round(t/60):null},async thermalState(){if(o("power"))return await window.craft.power.thermalState()||"unknown";return"unknown"},async uptimeSeconds(){if(o("power"))return await window.craft.power.uptimeSeconds();if(typeof performance<"u"&&typeof performance.now==="function")return Math.round(performance.now()/1000);return 0},async preventSleep(e="app is busy"){if(o("power")){await window.craft.power.preventSleep(e);return}if(typeof navigator>"u"||!navigator.wakeLock)return;let t=window;if(t.__craftWebWakeLock?.release){try{await t.__craftWebWakeLock.release()}catch{}t.__craftWebWakeLock=null}try{let r=await navigator.wakeLock.request("screen");t.__craftWebWakeLock=r}catch{}},async allowSleep(){if(o("power")){await window.craft.power.allowSleep();return}let e=window.__craftWebWakeLock;if(e&&typeof e.release==="function"){try{await e.release()}catch{}window.__craftWebWakeLock=null}},onSleep(e){return h("craft:powerSleep",e)},onWake(e){return h("craft:powerWake",e)}};async function ce(){if(typeof navigator>"u")return null;let e=navigator;if(typeof e.getBattery!=="function")return null;try{return await e.getBattery()}catch{return null}}var ni={async connectionType(){if(o("network"))return await window.craft.network.connectionType();return xt()},async wifiSSID(){if(o("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(o("network")){let e=await window.craft.network.wifiSignalStrength();return typeof e==="number"?e:void 0}return},async ipAddress(){if(o("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(o("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(o("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(o("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(o("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(o("network"))await window.craft.network.openPreferences()},onChange(e){if(o("network"))return h("craft:networkChange",e);if(typeof window>"u")return()=>{};let t=()=>e({type:xt(),online:!0}),r=()=>e({type:"none",online:!1});return window.addEventListener("online",t),window.addEventListener("offline",r),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}};function xt(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let e=navigator.connection;if(!e)return"unknown";let t=String(e.type||e.effectiveType||"unknown").toLowerCase();if(t==="wifi"||t==="cellular"||t==="ethernet"||t==="bluetooth"||t==="none")return t;return"unknown"}var oi={async checkForUpdates(){if(!o("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!o("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(e){if(!o("updater"))return;await window.craft.updater.setAutomaticChecks(e)},async setCheckInterval(e){if(!o("updater"))return;if(!Number.isFinite(e))throw Error("setCheckInterval: must be a finite number");let t=e<=0?0:Math.max(60,Math.round(e));await window.craft.updater.setCheckInterval(t)},async setFeedURL(e){if(!o("updater"))return;await window.craft.updater.setFeedURL(e)},async getLastUpdateCheckDate(){if(!o("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!o("updater"))return null;let e=await window.craft.updater.getUpdateInfo();if(!e||typeof e.version!=="string"||e.version.length===0)return null;return e},onAvailable(e){return h("craft:updateAvailable",e)},onDownloaded(e){return h("craft:updateDownloaded",e)},async verifySignature({payload:e,signatureB64:t,publicKeyB64:r}){let n=yt(e),i;try{i=await crypto.subtle.importKey("raw",le(r),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",i,le(t),n)}catch{return!1}},async verifyDownload({url:e,signatureB64:t,publicKeyB64:r,fetchInit:n}){let i;try{i=await fetch(e,n)}catch{return{ok:!1,reason:"fetch-failed"}}if(!i.ok)return{ok:!1,reason:"http-error",status:i.status};let a=new Uint8Array(await i.arrayBuffer()),s;try{s=await crypto.subtle.importKey("raw",le(r),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let c=!1;try{c=await crypto.subtle.verify("Ed25519",s,le(t),yt(a))}catch{c=!1}if(!c)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:a}}};function yt(e){if(e instanceof ArrayBuffer)return new Uint8Array(e);let t=new ArrayBuffer(e.byteLength),r=new Uint8Array(t);return r.set(e),r}function le(e){if(typeof atob==="function"){let n=atob(e),i=new ArrayBuffer(n.length),a=new Uint8Array(i);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);return a}let t=Buffer.from(e,"base64"),r=new ArrayBuffer(t.length);return new Uint8Array(r).set(t),new Uint8Array(r)}var ii={onFocus(e){if(o("window"))return h("craft:window:focus",()=>e());return Ce("focus",e)},onBlur(e){if(o("window"))return h("craft:window:blur",()=>e());return Ce("blur",e)},onResize(e){if(o("window"))return h("craft:window:resize",e);if(typeof window>"u")return()=>{};let t=()=>e({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},onMove(e){if(o("window"))return h("craft:window:move",e);return()=>{}},onClose(e){if(o("window"))return h("craft:window:close",()=>e());return Ce("beforeunload",e)},onMinimize(e){if(o("window"))return h("craft:window:minimize",()=>e());if(typeof document>"u")return()=>{};let t=()=>{if(document.visibilityState==="hidden")e()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},onRestore(e){if(o("window"))return h("craft:window:restore",()=>e());if(typeof document>"u")return()=>{};let t=()=>{if(document.visibilityState==="visible")e()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)}};function Ce(e,t){if(typeof window>"u")return()=>{};let r=()=>t();return window.addEventListener(e,r),()=>window.removeEventListener(e,r)}var vt={name:"",version:"0.0.0"},ai={async hideDockIcon(){if(o("app"))await window.craft.app.hideDockIcon()},async showDockIcon(){if(o("app"))await window.craft.app.showDockIcon()},async quit(){if(o("app"))await window.craft.app.quit()},async getInfo(){if(!o("app"))return vt;let e=await window.craft.app.getInfo();return{...vt,...e||{}}},async notify(e){if(!e.title)throw Error("notify: title is required");if(o("app"))await window.craft.app.notify(e)},async setBadge(e){if(o("app"))await window.craft.app.setBadge(e)},async bounce(e="informational"){if(o("app"))await window.craft.app.bounce(e)}};var si={app(e,t={}){return{label:e,items:[{label:`About ${e}`,role:"about"},{separator:!0},...t.settings?[{id:"stx.menu.settings",label:"Settings\u2026",shortcut:"cmd+,",onClick:t.settings},{separator:!0}]:[],{label:`Hide ${e}`,role:"hide",shortcut:"cmd+h"},{label:"Hide Others",role:"hideOthers",shortcut:"cmd+alt+h"},{label:"Show All",role:"showAll"},{separator:!0},{label:`Quit ${e}`,role:"quit",shortcut:"cmd+q"}]}},edit(){return{label:"Edit",items:[{label:"Undo",role:"undo",shortcut:"cmd+z"},{label:"Redo",role:"redo",shortcut:"cmd+shift+z"},{separator:!0},{label:"Cut",role:"cut",shortcut:"cmd+x"},{label:"Copy",role:"copy",shortcut:"cmd+c"},{label:"Paste",role:"paste",shortcut:"cmd+v"},{label:"Select All",role:"selectAll",shortcut:"cmd+a"}]}},window(){return{label:"Window",items:[{label:"Minimize",role:"minimize",shortcut:"cmd+m"},{label:"Zoom",role:"zoom"},{separator:!0},{label:"Close Window",role:"close",shortcut:"cmd+w"}]}},leading(e,t={}){return[this.app(e,t),this.edit()]}},ci=0;function li(e){let t=new Map;return{payload:{menus:e.menus.map((n)=>({label:n.label,items:n.items.map((i)=>{let{onClick:a,...s}=i;if(s.separator)return s;let c=s.id??`stx.menu.${ci++}`;if(a)t.set(c,a);return{...s,id:c}})}))},handlers:t}}var Ie=null,di={async set(e){if(!o("menu"))return!1;let{payload:t,handlers:r}=li(e);if(Ie?.(),Ie=null,r.size>0)Ie=h("craft:menu:action",(n)=>{r.get(n.id)?.()});return await window.craft.menu.set(t),!0},async setDock(e){if(o("menu"))await window.craft.menu.setDock(e)},async addItem(e,t){if(o("menu"))await window.craft.menu.addItem(e,t)},async removeItem(e){if(o("menu"))await window.craft.menu.removeItem(e)},async enableItem(e){if(o("menu"))await window.craft.menu.enableItem(e)},async disableItem(e){if(o("menu"))await window.craft.menu.disableItem(e)},async checkItem(e){if(o("menu"))await window.craft.menu.checkItem(e)},async uncheckItem(e){if(o("menu"))await window.craft.menu.uncheckItem(e)},async setItemLabel(e,t){if(o("menu"))await window.craft.menu.setItemLabel(e,t)},async clearDock(){if(o("menu"))await window.craft.menu.clearDock()},onAction(e){return h("craft:menu:action",e)}};function St(e){if(e.separator)return{id:e.id||"",title:"",type:"separator"};return{id:e.id||"",title:e.title||"",icon:e.icon,shortcut:e.shortcut,enabled:e.disabled?!1:void 0,checked:e.checked?!0:void 0,type:e.submenu?"submenu":void 0,submenu:e.submenu?.map(St)}}async function Pt(e){if(!e.items||e.items.length===0)throw Error("contextMenu.show requires at least one item");if(!o("nativeUI"))return null;let t=window.craft?.nativeUI;if(!t)return null;let r=await t.showContextMenu({targetId:e.targetId||"",targetType:"general",x:Math.round(e.x),y:Math.round(e.y),items:e.items.map(St)});return{id:typeof r?.id==="string"?r.id:null,targetId:r?.targetId}}var ui={available(){return o("nativeUI")},async show(e){return await Pt(e)!==null},async pick(e){return(await Pt(e))?.id??null},onAction(e){return h("craft:contextmenu:action",(t)=>{if(typeof t.id==="string")e({id:t.id,targetId:t.targetId??""})})}};function $e(e){if(e===null||e===void 0||e===0)return"";return String(e)}function kt(e){return e.map((t)=>({id:t.id,header:t.header,items:t.items.map((r)=>({id:r.id,label:r.label,icon:r.icon,badge:$e(r.badge)||void 0}))}))}function At(e){return JSON.stringify(e.map((t)=>[t.id,t.header??"",t.items.map((r)=>[r.id,r.label,r.icon??""])]))}function Ct(e){return new Map(e.flatMap((t)=>t.items.map((r)=>[r.id,$e(r.badge)])))}var It={available(){return o("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(e){if(!It.available())return null;let t=window.craft?.nativeUI;if(!t)return null;let r=t.createSidebar({id:e.id,sections:kt(e.sections),selected:e.selected}),n=e.sections,i=new Set;return r.onSelect((a)=>{for(let s of[...i])s(a)}),{id:r.id,update(a){if(At(a)===At(n)){let s=Ct(n);for(let[c,l]of Ct(a))if(s.get(c)!==l)r.updateItem(c,{badge:l})}else r.setSections(kt(a));n=a},updateItem(a,s){r.updateItem(a,{...s.label!==void 0?{label:s.label}:{},...s.icon!==void 0?{icon:s.icon}:{},..."badge"in s?{badge:$e(s.badge)}:{}}),n=n.map((c)=>({...c,items:c.items.map((l)=>l.id===a?{...l,...s}:l)}))},select(a){r.setSelectedItem(a)},onSelect(a){return i.add(a),()=>i.delete(a)},destroy(){i.clear(),r.destroy()}}}};var pi={accentColor:()=>E("system","accentColor",()=>""),highlightColor:()=>E("system","highlightColor",()=>""),language:()=>E("system","language",()=>{if(typeof navigator>"u")return"";return navigator.language?.split("-")[0]||""}),locale:()=>E("system","locale",()=>{if(typeof navigator>"u")return"";return navigator.language||""}),timezone:()=>E("system","timezone",()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||""}catch{return""}}),is24HourTime:()=>E("system","is24HourTime",()=>{try{let e=new Intl.DateTimeFormat([],{hour:"numeric"}).resolvedOptions();return e.hourCycle==="h23"||e.hourCycle==="h24"}catch{return!1}}),reduceMotion:()=>E("system","reduceMotion",()=>Te("(prefers-reduced-motion: reduce)")),reduceTransparency:()=>E("system","reduceTransparency",()=>Te("(prefers-reduced-transparency: reduce)")),increaseContrast:()=>E("system","increaseContrast",()=>Te("(prefers-contrast: more)")),systemVersion:()=>E("system","systemVersion",()=>""),hostname:()=>E("system","hostname",()=>""),username:()=>E("system","username",()=>""),async openPreferences(){if(o("system"))await window.craft.system.openPreferences()}};async function E(e,t,r){if(o(e))return await window.craft[e][t]();return await r()}function Te(e){if(typeof window>"u"||!window.matchMedia)return!1;return window.matchMedia(e).matches}var fi={async getDisplays(){if(o("screen"))return await window.craft.screen.getDisplays();return $t()},async getPrimary(){if(o("screen")){let e=await window.craft.screen.getPrimary();return e&&typeof e.width==="number"?e:null}return $t()[0]??null},onChange(e){if(o("screen"))return h("craft:screen:change",()=>e());if(typeof window>"u")return()=>{};let t=()=>e();return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}};function $t(){if(typeof window>"u"||!window.screen)return[];let e=window.screen;return[{id:0,x:e.left??0,y:e.top??0,width:e.width||0,height:e.height||0,workX:e.availLeft??0,workY:e.availTop??0,workWidth:e.availWidth??e.width??0,workHeight:e.availHeight??e.height??0,scaleFactor:window.devicePixelRatio||1}]}var mi={async set(e,t,r){if(!e)throw Error("keychain.set: service is required");if(!t)throw Error("keychain.set: account is required");await v("keychain").set(e,t,r)},async get(e,t){if(!e)throw Error("keychain.get: service is required");if(!t)throw Error("keychain.get: account is required");let r=await v("keychain").get(e,t);return typeof r==="string"?r:null},async delete(e,t){if(!e)throw Error("keychain.delete: service is required");if(!t)throw Error("keychain.delete: account is required");await v("keychain").delete(e,t)},async has(e,t){if(!e)throw Error("keychain.has: service is required");if(!t)throw Error("keychain.has: account is required");return await v("keychain").has(e,t)}};var gi={async check(e){if(o("permissions"))return await window.craft.permissions.check(e);return await Tt(e)},async request(e){if(o("permissions"))return await window.craft.permissions.request(e);return await hi(e)},async openSettings(e){if(o("permissions"))await window.craft.permissions.openSettings(e)}};async function Tt(e){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let t=await navigator.permissions.query({name:e});return wi(t.state)}catch{return"not-supported"}}async function hi(e){if(e==="notifications"&&typeof window<"u"&&"Notification"in window){let t=await window.Notification.requestPermission();return t==="granted"?"granted":t==="denied"?"denied":"undetermined"}return await Tt(e)}function wi(e){if(e==="granted")return"granted";if(e==="denied")return"denied";if(e==="prompt")return"undetermined";return"undetermined"}var bi={async print(){if(o("printing")){await window.craft.printing.print();return}if(typeof window<"u"&&typeof window.print==="function")window.print()},async printToPDF(e){if(!e)throw Error("printToPDF: path is required");let t=e.startsWith("/"),r=/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\");if(!t&&!r)throw Error("printToPDF: path must be absolute");let n=await v("printing").printToPDF(e);return{ok:!!(n&&n.ok),path:n?.path}}};var xi={async enable(){if(!o("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!o("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!o("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};async function Ee(e){if(!o("tray"))return;let t=window.craft.tray;await e(t)}var yi={setIcon:(e)=>Ee((t)=>t.setIcon({icon:e})),setTitle:(e)=>Ee((t)=>t.setTitle({title:e})),setTooltip:(e)=>Ee((t)=>t.setTooltip({tooltip:e}))};function Me(){if(!o("window"))return null;return window.craft.window}function D(e){let t=Me();if(!t)return Promise.resolve();try{return Promise.resolve(e(t)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var vi={get available(){return Me()!==null},open(e){let t=()=>{if(typeof window<"u"&&e.url)window.open(e.url,e.name);return{name:e.name}},r=Me();if(!r?.open)return Promise.resolve(t());return r.open(e).then((n)=>({name:n?.name||e.name})).catch(t)},close:()=>D((e)=>e.close?.()),show:()=>D((e)=>e.show?.()),hide:()=>D((e)=>e.hide?.()),focus:()=>D((e)=>e.focus?.()),minimize:()=>D((e)=>e.minimize?.()),maximize:()=>D((e)=>e.maximize?.()),center:()=>D((e)=>e.center?.()),startDrag:()=>D((e)=>e.startDrag?.()),setTitle:(e)=>D((t)=>t.setTitle?.(e)),setSize:(e,t)=>D((r)=>r.setSize?.(e,t)),setAppearance:(e)=>D((t)=>t.setAppearance?.(e))};var Pi={async addItem(e){if(o("touchbar"))await window.craft.touchbar.addItem(e)},async removeItem(e){if(o("touchbar"))await window.craft.touchbar.removeItem(e)},async updateItem(e,t){if(o("touchbar"))await window.craft.touchbar.updateItem(e,t)},async setLabel(e,t){if(o("touchbar"))await window.craft.touchbar.setLabel(e,t)},async setIcon(e,t){if(o("touchbar"))await window.craft.touchbar.setIcon(e,t)},async setEnabled(e,t){if(o("touchbar"))await window.craft.touchbar.setEnabled(e,t)},async setSliderValue(e,t){if(o("touchbar"))await window.craft.touchbar.setSliderValue(e,t)},async clear(){if(o("touchbar"))await window.craft.touchbar.clear()},async show(){if(o("touchbar"))await window.craft.touchbar.show()},async hide(){if(o("touchbar"))await window.craft.touchbar.hide()},onAction(e){return h("craft:touchbar:action",e)}};var Si=/^[\da-f]*$/i;function ki(e,t){if(typeof t!=="string"||!Si.test(t)||t.length%2!==0)throw Error(`${e}: must be a hex string with even length, got ${JSON.stringify(t)}`)}var Ai={async isEnabled(){return o("bluetooth")?await window.craft.bluetooth.isEnabled():!1},async powerState(){return o("bluetooth")?await window.craft.bluetooth.powerState():"unknown"},async connectedDevices(){return o("bluetooth")?await window.craft.bluetooth.connectedDevices():[]},async pairedDevices(){return o("bluetooth")?await window.craft.bluetooth.pairedDevices():[]},async startDiscovery(){if(o("bluetooth"))await window.craft.bluetooth.startDiscovery()},async stopDiscovery(){if(o("bluetooth"))await window.craft.bluetooth.stopDiscovery()},async isDiscovering(){return o("bluetooth")?await window.craft.bluetooth.isDiscovering():!1},async connect(e){if(o("bluetooth"))await window.craft.bluetooth.connect(e)},async disconnect(e){if(o("bluetooth"))await window.craft.bluetooth.disconnect(e)},async openPreferences(){if(o("bluetooth"))await window.craft.bluetooth.openPreferences()},async discoverServices(e){if(!e)throw Error("bluetooth.discoverServices: deviceId is required");if(!o("bluetooth"))return[];let t=await window.craft.bluetooth.discoverServices(e);return Array.isArray(t)?t:[]},async discoverCharacteristics(e,t){if(!e||!t)throw Error("bluetooth.discoverCharacteristics: deviceId and serviceUuid are required");if(!o("bluetooth"))return[];let r=await window.craft.bluetooth.discoverCharacteristics(e,t);return Array.isArray(r)?r:[]},async readCharacteristic(e,t,r){if(!e||!t||!r)throw Error("bluetooth.readCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(!o("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.readCharacteristic(e,t,r)},async writeCharacteristic(e,t,r,n,i="with-response"){if(!e||!t||!r)throw Error("bluetooth.writeCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(ki("bluetooth.writeCharacteristic.valueHex",n),!o("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.writeCharacteristic(e,t,r,n,i)},async setCharacteristicNotify(e,t,r,n){if(!e||!t||!r)throw Error("bluetooth.setCharacteristicNotify: deviceId, serviceUuid, characteristicUuid are required");if(!o("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.setCharacteristicNotify(e,t,r,n)},onDeviceFound(e){return h("craft:bluetooth:deviceFound",e)},onDeviceConnected(e){return h("craft:bluetooth:deviceConnected",e)},onDeviceDisconnected(e){return h("craft:bluetooth:deviceDisconnected",e)},onCharacteristicValue(e){return h("craft:bluetooth:characteristicValue",e)}};var Ci={async speak(e,t){if(!e)throw Error("speech.speak: text is required");if(o("speech")){await window.craft.speech.speak(e,t);return}if(typeof window<"u"&&window.speechSynthesis){let r=new window.SpeechSynthesisUtterance(e);if(t){if(t.rate!=null)r.rate=t.rate;if(t.pitch!=null)r.pitch=t.pitch;if(t.volume!=null)r.volume=t.volume;if(t.voice){let i=window.speechSynthesis.getVoices().find((a)=>a.voiceURI===t.voice||a.name===t.voice||a.lang===t.voice);if(i)r.voice=i}}window.speechSynthesis.speak(r)}},async stop(){if(o("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(o("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(o("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(o("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(o("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map((t)=>({id:t.voiceURI||t.name,name:t.name,language:t.lang||"",quality:"default"}));return[]}};var J=[],De=!0,Be,Oe,Q={async report(e){if(o("crashReporter")){await window.craft.crashReporter.report(e);return}if(!De)return;let t=e instanceof Error?{timestamp:Date.now(),severity:"error",message:e.message,source:"js",stack:e.stack||"",userId:Be,appVersion:Oe}:{timestamp:Date.now(),severity:e.severity||"error",message:e.message||"",source:e.source||"js",stack:e.stack||"",userId:Be,appVersion:Oe};if(J.length>=64)J.shift();J.push(t)},async flush(){if(o("crashReporter"))return await window.craft.crashReporter.flush();return[...J]},async clear(){if(o("crashReporter")){await window.craft.crashReporter.clear();return}J.length=0},async setEnabled(e){if(o("crashReporter")){await window.craft.crashReporter.setEnabled(e);return}De=e},async isEnabled(){if(o("crashReporter"))return await window.craft.crashReporter.isEnabled();return De},async setUser(e){if(o("crashReporter")){await window.craft.crashReporter.setUser(e);return}Be=e||void 0},async setAppVersion(e){if(o("crashReporter")){await window.craft.crashReporter.setAppVersion(e);return}Oe=e||void 0},attachGlobalHandlers(){if(o("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let e=(r)=>{Q.report({severity:"error",message:r.message,source:"js",stack:r.error?.stack||`${r.message}
|
|
926
|
+
`).trim()}var zo={async show(e){if(!e.title)throw Error("notification title is required");if(o("notifications")){await window.craft.notifications.show(e);return}if(typeof window<"u"&&"Notification"in window){let t=window.Notification;if(t.permission==="granted")new t(e.title,{body:e.body,icon:e.icon});else if(t.permission==="default"){if(await t.requestPermission()==="granted")new t(e.title,{body:e.body,icon:e.icon})}}},async schedule(e){if(o("notifications")){let n={...e};if(n.triggerAt instanceof Date)n.triggerAt=n.triggerAt.toISOString();await window.craft.notifications.schedule(n);return}let t=Ho(e.triggerAt),r=Math.max(0,t-Date.now());setTimeout(()=>{this.show(e).catch(()=>{})},r)},async cancel(e){if(o("notifications"))await window.craft.notifications.cancel(e)},async cancelAll(){if(o("notifications"))await window.craft.notifications.cancelAll()},async setBadge(e){let t=Math.max(0,Math.round(Number.isFinite(e)?e:0));if(o("notifications")){await window.craft.notifications.setBadge(t);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge(t)}catch{}},async clearBadge(){if(o("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(o("notifications"))return await window.craft.notifications.requestPermission();if(typeof window<"u"&&"Notification"in window){let e=window.Notification;if(e.permission==="granted")return!0;if(e.permission==="denied")return!1;return await e.requestPermission()==="granted"}return!1},async registerCategories(e){if(!Array.isArray(e)||e.length===0)return;if(o("notifications")){let t=window.craft.notifications.registerCategories;if(typeof t==="function")await t(e)}},onActionClicked(e){return h("craft:notification:actionClicked",e)},onReply(e){return h("craft:notification:reply",e)}};function Ho(e){if(e==null)return Date.now();if(e instanceof Date)return e.getTime();if(typeof e==="number")return e;let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}var Uo={async readFile(e){let t=await v("fs").readFile(e);return t&&t.data||""},async readBuffer(e){let t=await v("fs").readFile(e),r=t&&t.data||"";if(t&&t.base64===!0)return Vo(r);return new TextEncoder().encode(r)},async writeFile(e,t){await v("fs").writeFile(e,t)},async writeBuffer(e,t){let r=qo(t),n=v("fs");if(typeof n.writeFileBytes==="function")await n.writeFileBytes(e,r);else await n.writeFile(e,r)},async copy(e,t){if(e===t)throw Error("fs.copy: source and destination must differ");await v("fs").copy(e,t)},async move(e,t){if(e===t)throw Error("fs.move: source and destination must differ");await v("fs").move(e,t)},async appendFile(e,t){await v("fs").appendFile(e,t)},async deleteFile(e){await v("fs").deleteFile(e)},async exists(e){return await v("fs").exists(e)},async stat(e){return jo(await v("fs").stat(e))},async readDir(e){let t=await v("fs").readDir(e),r=t&&t.entries||[],n=e.endsWith("/")?e.slice(0,-1):e;return r.map((i)=>({name:i.name,path:`${n}/${i.name}`,isDirectory:!!i.isDirectory}))},async mkdir(e,t){await v("fs").mkdir(e,t)},async rmdir(e,t){await v("fs").rmdir(e,t)},async watch(e,t){await v("fs").watch(e,t)},async unwatch(e){await v("fs").unwatch(e)},onChange(e){return h("craft:fs:change",e)},async watchTree(e,t,r){let n=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,i=v("fs");await i.watch(e,n,{recursive:!!t.recursive});let a=t.kinds&&t.kinds.length>0?new Set(t.kinds):null,s=Math.max(0,Math.floor(t.coalesceMs??0)),c=[],l=null,d=!1,f=()=>{if(l=null,c.length===0)return;let u=c;c=[];try{r(u)}catch{}},m=h("craft:fs:change",(u)=>{if(d)return;if(u.id!==n)return;if(a&&u.kind&&!a.has(u.kind))return;if(c.push(u),s===0){f();return}if(l==null)l=setTimeout(f,s)});return{id:n,async stop(){if(d)return;if(d=!0,m(),l)clearTimeout(l),l=null;if(c.length>0)f();try{await i.unwatch(n)}catch{}}}},async homeDir(){return await v("fs").homeDir()},async tempDir(){return await v("fs").tempDir()},async appDataDir(){return await v("fs").appDataDir()}};function qo(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return typeof btoa==="function"?btoa(t):Buffer.from(e).toString("base64")}function Vo(e){let t=typeof atob==="function"?atob(e):Buffer.from(e,"base64").toString("binary"),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function jo(e){return{isFile:!!e.isFile,isDirectory:!!e.isDirectory,isSymlink:!!e.isSymlink,size:Number(e.size)||0,modifiedAt:e.modifiedAt!=null?e.modifiedAt<1000000000000?e.modifiedAt*1000:e.modifiedAt:0}}var X=new Set,bt=!1;function Ko(){if(bt)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(e)=>{let t=e.detail;if(t?.id)X.delete(t.id)}),bt=!0}var Go=new Set(["javascript:","data:","file:","vbscript:"]),Yo={async openExternal(e){let t=e.trim().toLowerCase();for(let r of Go)if(t.startsWith(r))throw Error(`shell.openExternal: ${r} URLs are blocked for safety`);if(o("shell")){await window.craft.shell.openExternal(e);return}if(typeof window<"u"&&typeof window.open==="function")window.open(e,"_blank","noopener,noreferrer")},async openPath(e){await v("shell").openPath(e)},async showInFinder(e){await v("shell").showInFinder(e)},async spawn(e,t,r=[],n={}){if(Ko(),!e||typeof e!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!t||typeof t!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray(r))throw Error("shell.spawn: args must be an array");for(let i of r)if(typeof i!=="string")throw Error("shell.spawn: args entries must be strings");if(X.has(e))throw Error(`shell.spawn: id "${e}" is already in use \u2014 call kill(id) first or pick a different id`);X.add(e);try{await v("shell").spawn(e,t,r,n)}catch(i){throw X.delete(e),i}},async kill(e){await v("shell").kill(e),X.delete(e)},async getEnv(e){if(o("shell")){let t=await window.craft.shell.getEnv(e);return t==null?void 0:String(t)}return},async setEnv(e,t){await v("shell").setEnv(e,t)},onStdout(e){return h("craft:shell:stdout",e)},onStderr(e){return h("craft:shell:stderr",e)},onExit(e){return h("craft:shell:exit",e)}};function W(){return window.craft.shortcuts}var Xo={async register(e,t,r){if(!o("shortcuts"))return;await W().register(e,t,r)},async unregister(e){if(!o("shortcuts"))return;await W().unregister(e)},async unregisterAll(){if(!o("shortcuts"))return;await W().unregisterAll()},async enable(e){if(!o("shortcuts"))return;await W().enable(e)},async disable(e){if(!o("shortcuts"))return;await W().disable(e)},async isRegistered(e){if(!o("shortcuts"))return!1;return await W().isRegistered(e)},async list(){if(!o("shortcuts"))return[];return await W().list()},on(e){return h("craft:shortcut",e)}};var Jo={get(){if(o("theme"))try{return window.craft.theme.get()}catch{}return{appearance:Qo()}},onChange(e){if(e(this.get()),o("theme"))return h("craft:theme",e);if(typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>e({appearance:t.matches?"dark":"light"});return t.addEventListener("change",r),()=>t.removeEventListener("change",r)}return()=>{}},async current(){return this.get()}};function Qo(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function Zo(e,t={}){if(!o("dragOut"))throw Error("dragOut requires a Craft native window");let r=Array.isArray(e)?e:[e];if(r.length===0)throw Error("dragOut: at least one path required");await window.craft.dragOut.start(r,t)}function ei(){return o("dragOut")}var ti={onUrl(e){if(!o("deepLink"))return()=>{};return h("craft:deepLink",e)},getInitialUrl(){if(typeof window>"u")return null;if(o("deepLink"))try{return window.craft.deepLink.getInitialUrl()}catch{return null}return window.__craftPendingDeepLink||null},consumeInitialUrl(){let e=this.getInitialUrl();if(typeof window<"u")window.__craftPendingDeepLink=void 0;return e},isAvailable(){return o("deepLink")}};var ri={async isCharging(){if(o("power"))return await window.craft.power.isCharging();let e=await ce();return e?!!e.charging:!1},async isPluggedIn(){if(o("power"))return await window.craft.power.isPluggedIn();let e=await ce();return e?!!e.charging||e.level>=0.999:!1},async isLowPowerMode(){if(o("power"))return await window.craft.power.isLowPowerMode();return!1},async level(){if(o("power")){let t=await window.craft.power.batteryLevel();return typeof t==="number"?t:null}let e=await ce();return e?e.level:null},async timeRemaining(){if(o("power")){let r=await window.craft.power.timeRemaining();return typeof r==="number"?r:null}let e=await ce();if(!e)return null;let t=e.charging?e.chargingTime:e.dischargingTime;return Number.isFinite(t)?Math.round(t/60):null},async thermalState(){if(o("power"))return await window.craft.power.thermalState()||"unknown";return"unknown"},async uptimeSeconds(){if(o("power"))return await window.craft.power.uptimeSeconds();if(typeof performance<"u"&&typeof performance.now==="function")return Math.round(performance.now()/1000);return 0},async preventSleep(e="app is busy"){if(o("power")){await window.craft.power.preventSleep(e);return}if(typeof navigator>"u"||!navigator.wakeLock)return;let t=window;if(t.__craftWebWakeLock?.release){try{await t.__craftWebWakeLock.release()}catch{}t.__craftWebWakeLock=null}try{let r=await navigator.wakeLock.request("screen");t.__craftWebWakeLock=r}catch{}},async allowSleep(){if(o("power")){await window.craft.power.allowSleep();return}let e=window.__craftWebWakeLock;if(e&&typeof e.release==="function"){try{await e.release()}catch{}window.__craftWebWakeLock=null}},onSleep(e){return h("craft:powerSleep",e)},onWake(e){return h("craft:powerWake",e)}};async function ce(){if(typeof navigator>"u")return null;let e=navigator;if(typeof e.getBattery!=="function")return null;try{return await e.getBattery()}catch{return null}}var ni={async connectionType(){if(o("network"))return await window.craft.network.connectionType();return xt()},async wifiSSID(){if(o("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(o("network")){let e=await window.craft.network.wifiSignalStrength();return typeof e==="number"?e:void 0}return},async ipAddress(){if(o("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(o("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(o("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(o("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(o("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(o("network"))await window.craft.network.openPreferences()},onChange(e){if(o("network"))return h("craft:networkChange",e);if(typeof window>"u")return()=>{};let t=()=>e({type:xt(),online:!0}),r=()=>e({type:"none",online:!1});return window.addEventListener("online",t),window.addEventListener("offline",r),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}};function xt(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let e=navigator.connection;if(!e)return"unknown";let t=String(e.type||e.effectiveType||"unknown").toLowerCase();if(t==="wifi"||t==="cellular"||t==="ethernet"||t==="bluetooth"||t==="none")return t;return"unknown"}var oi={async checkForUpdates(){if(!o("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!o("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(e){if(!o("updater"))return;await window.craft.updater.setAutomaticChecks(e)},async setCheckInterval(e){if(!o("updater"))return;if(!Number.isFinite(e))throw Error("setCheckInterval: must be a finite number");let t=e<=0?0:Math.max(60,Math.round(e));await window.craft.updater.setCheckInterval(t)},async setFeedURL(e){if(!o("updater"))return;await window.craft.updater.setFeedURL(e)},async getLastUpdateCheckDate(){if(!o("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!o("updater"))return null;let e=await window.craft.updater.getUpdateInfo();if(!e||typeof e.version!=="string"||e.version.length===0)return null;return e},onAvailable(e){return h("craft:updateAvailable",e)},onDownloaded(e){return h("craft:updateDownloaded",e)},async verifySignature({payload:e,signatureB64:t,publicKeyB64:r}){let n=yt(e),i;try{i=await crypto.subtle.importKey("raw",le(r),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",i,le(t),n)}catch{return!1}},async verifyDownload({url:e,signatureB64:t,publicKeyB64:r,fetchInit:n}){let i;try{i=await fetch(e,n)}catch{return{ok:!1,reason:"fetch-failed"}}if(!i.ok)return{ok:!1,reason:"http-error",status:i.status};let a=new Uint8Array(await i.arrayBuffer()),s;try{s=await crypto.subtle.importKey("raw",le(r),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let c=!1;try{c=await crypto.subtle.verify("Ed25519",s,le(t),yt(a))}catch{c=!1}if(!c)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:a}}};function yt(e){if(e instanceof ArrayBuffer)return new Uint8Array(e);let t=new ArrayBuffer(e.byteLength),r=new Uint8Array(t);return r.set(e),r}function le(e){if(typeof atob==="function"){let n=atob(e),i=new ArrayBuffer(n.length),a=new Uint8Array(i);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);return a}let t=Buffer.from(e,"base64"),r=new ArrayBuffer(t.length);return new Uint8Array(r).set(t),new Uint8Array(r)}var ii={onFocus(e){if(o("window"))return h("craft:window:focus",()=>e());return Ce("focus",e)},onBlur(e){if(o("window"))return h("craft:window:blur",()=>e());return Ce("blur",e)},onResize(e){if(o("window"))return h("craft:window:resize",e);if(typeof window>"u")return()=>{};let t=()=>e({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},onMove(e){if(o("window"))return h("craft:window:move",e);return()=>{}},onClose(e){if(o("window"))return h("craft:window:close",()=>e());return Ce("beforeunload",e)},onMinimize(e){if(o("window"))return h("craft:window:minimize",()=>e());if(typeof document>"u")return()=>{};let t=()=>{if(document.visibilityState==="hidden")e()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},onRestore(e){if(o("window"))return h("craft:window:restore",()=>e());if(typeof document>"u")return()=>{};let t=()=>{if(document.visibilityState==="visible")e()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)}};function Ce(e,t){if(typeof window>"u")return()=>{};let r=()=>t();return window.addEventListener(e,r),()=>window.removeEventListener(e,r)}var vt={name:"",version:"0.0.0"},ai={async hideDockIcon(){if(o("app"))await window.craft.app.hideDockIcon()},async showDockIcon(){if(o("app"))await window.craft.app.showDockIcon()},async quit(){if(o("app"))await window.craft.app.quit()},async getInfo(){if(!o("app"))return vt;let e=await window.craft.app.getInfo();return{...vt,...e||{}}},async notify(e){if(!e.title)throw Error("notify: title is required");if(o("app"))await window.craft.app.notify(e)},async setBadge(e){if(o("app"))await window.craft.app.setBadge(e)},async bounce(e="informational"){if(o("app"))await window.craft.app.bounce(e)}};var si={app(e,t={}){return{label:e,items:[{label:`About ${e}`,role:"about"},{separator:!0},...t.settings?[{id:"stx.menu.settings",label:"Settings\u2026",shortcut:"cmd+,",onClick:t.settings},{separator:!0}]:[],{label:`Hide ${e}`,role:"hide",shortcut:"cmd+h"},{label:"Hide Others",role:"hideOthers",shortcut:"cmd+alt+h"},{label:"Show All",role:"showAll"},{separator:!0},{label:`Quit ${e}`,role:"quit",shortcut:"cmd+q"}]}},edit(){return{label:"Edit",items:[{label:"Undo",role:"undo",shortcut:"cmd+z"},{label:"Redo",role:"redo",shortcut:"cmd+shift+z"},{separator:!0},{label:"Cut",role:"cut",shortcut:"cmd+x"},{label:"Copy",role:"copy",shortcut:"cmd+c"},{label:"Paste",role:"paste",shortcut:"cmd+v"},{label:"Select All",role:"selectAll",shortcut:"cmd+a"}]}},window(){return{label:"Window",items:[{label:"Minimize",role:"minimize",shortcut:"cmd+m"},{label:"Zoom",role:"zoom"},{separator:!0},{label:"Close Window",role:"close",shortcut:"cmd+w"}]}},leading(e,t={}){return[this.app(e,t),this.edit()]}},ci=0;function li(e){let t=new Map;return{payload:{menus:e.menus.map((n)=>({label:n.label,items:n.items.map((i)=>{let{onClick:a,...s}=i;if(s.separator)return s;let c=s.id??`stx.menu.${ci++}`;if(a)t.set(c,a);return{...s,id:c}})}))},handlers:t}}var Ie=null,di={async set(e){if(!o("menu"))return!1;let{payload:t,handlers:r}=li(e);if(Ie?.(),Ie=null,r.size>0)Ie=h("craft:menu:action",(n)=>{r.get(n.id)?.()});return await window.craft.menu.set(t),!0},async setDock(e){if(o("menu"))await window.craft.menu.setDock(e)},async addItem(e,t){if(o("menu"))await window.craft.menu.addItem(e,t)},async removeItem(e){if(o("menu"))await window.craft.menu.removeItem(e)},async enableItem(e){if(o("menu"))await window.craft.menu.enableItem(e)},async disableItem(e){if(o("menu"))await window.craft.menu.disableItem(e)},async checkItem(e){if(o("menu"))await window.craft.menu.checkItem(e)},async uncheckItem(e){if(o("menu"))await window.craft.menu.uncheckItem(e)},async setItemLabel(e,t){if(o("menu"))await window.craft.menu.setItemLabel(e,t)},async clearDock(){if(o("menu"))await window.craft.menu.clearDock()},onAction(e){return h("craft:menu:action",e)}};function St(e){if(e.separator)return{id:e.id||"",title:"",type:"separator"};return{id:e.id||"",title:e.title||"",icon:e.icon,shortcut:e.shortcut,enabled:e.disabled?!1:void 0,checked:e.checked?!0:void 0,type:e.submenu?"submenu":void 0,submenu:e.submenu?.map(St)}}async function Pt(e){if(!e.items||e.items.length===0)throw Error("contextMenu.show requires at least one item");if(!o("nativeUI"))return null;let t=window.craft?.nativeUI;if(!t)return null;let r=await t.showContextMenu({targetId:e.targetId||"",targetType:"general",x:Math.round(e.x),y:Math.round(e.y),items:e.items.map(St)});return{id:typeof r?.id==="string"?r.id:null,targetId:r?.targetId}}var ui={available(){return o("nativeUI")},async show(e){return await Pt(e)!==null},async pick(e){return(await Pt(e))?.id??null},onAction(e){return h("craft:contextmenu:action",(t)=>{if(typeof t.id==="string")e({id:t.id,targetId:t.targetId??""})})}};function $e(e){if(e===null||e===void 0||e===0)return"";return String(e)}function kt(e){return e.map((t)=>({id:t.id,header:t.header,items:t.items.map((r)=>({id:r.id,label:r.label,icon:r.icon,badge:$e(r.badge)||void 0}))}))}function At(e){return JSON.stringify(e.map((t)=>[t.id,t.header??"",t.items.map((r)=>[r.id,r.label,r.icon??""])]))}function Ct(e){return new Map(e.flatMap((t)=>t.items.map((r)=>[r.id,$e(r.badge)])))}var It={available(){return o("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(e){if(!It.available())return null;let t=window.craft?.nativeUI;if(!t)return null;let r=t.createSidebar({id:e.id,sections:kt(e.sections),selected:e.selected}),n=e.sections,i=new Set;return r.onSelect((a)=>{for(let s of[...i])s(a)}),{id:r.id,update(a){if(At(a)===At(n)){let s=Ct(n);for(let[c,l]of Ct(a))if(s.get(c)!==l)r.updateItem(c,{badge:l})}else r.setSections(kt(a));n=a},updateItem(a,s){r.updateItem(a,{...s.label!==void 0?{label:s.label}:{},...s.icon!==void 0?{icon:s.icon}:{},..."badge"in s?{badge:$e(s.badge)}:{}}),n=n.map((c)=>({...c,items:c.items.map((l)=>l.id===a?{...l,...s}:l)}))},select(a){r.setSelectedItem(a)},onSelect(a){return i.add(a),()=>i.delete(a)},destroy(){i.clear(),r.destroy()}}}};var pi={accentColor:()=>E("system","accentColor",()=>""),highlightColor:()=>E("system","highlightColor",()=>""),language:()=>E("system","language",()=>{if(typeof navigator>"u")return"";return navigator.language?.split("-")[0]||""}),locale:()=>E("system","locale",()=>{if(typeof navigator>"u")return"";return navigator.language||""}),timezone:()=>E("system","timezone",()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||""}catch{return""}}),is24HourTime:()=>E("system","is24HourTime",()=>{try{let e=new Intl.DateTimeFormat([],{hour:"numeric"}).resolvedOptions();return e.hourCycle==="h23"||e.hourCycle==="h24"}catch{return!1}}),reduceMotion:()=>E("system","reduceMotion",()=>Te("(prefers-reduced-motion: reduce)")),reduceTransparency:()=>E("system","reduceTransparency",()=>Te("(prefers-reduced-transparency: reduce)")),increaseContrast:()=>E("system","increaseContrast",()=>Te("(prefers-contrast: more)")),systemVersion:()=>E("system","systemVersion",()=>""),hostname:()=>E("system","hostname",()=>""),username:()=>E("system","username",()=>""),async openPreferences(){if(o("system"))await window.craft.system.openPreferences()}};async function E(e,t,r){if(o(e))return await window.craft[e][t]();return await r()}function Te(e){if(typeof window>"u"||!window.matchMedia)return!1;return window.matchMedia(e).matches}var fi={async getDisplays(){if(o("screen"))return await window.craft.screen.getDisplays();return $t()},async getPrimary(){if(o("screen")){let e=await window.craft.screen.getPrimary();return e&&typeof e.width==="number"?e:null}return $t()[0]??null},onChange(e){if(o("screen"))return h("craft:screen:change",()=>e());if(typeof window>"u")return()=>{};let t=()=>e();return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}};function $t(){if(typeof window>"u"||!window.screen)return[];let e=window.screen;return[{id:0,x:e.left??0,y:e.top??0,width:e.width||0,height:e.height||0,workX:e.availLeft??0,workY:e.availTop??0,workWidth:e.availWidth??e.width??0,workHeight:e.availHeight??e.height??0,scaleFactor:window.devicePixelRatio||1}]}var mi={async set(e,t,r){if(!e)throw Error("keychain.set: service is required");if(!t)throw Error("keychain.set: account is required");await v("keychain").set(e,t,r)},async get(e,t){if(!e)throw Error("keychain.get: service is required");if(!t)throw Error("keychain.get: account is required");let r=await v("keychain").get(e,t);return typeof r==="string"?r:null},async delete(e,t){if(!e)throw Error("keychain.delete: service is required");if(!t)throw Error("keychain.delete: account is required");await v("keychain").delete(e,t)},async has(e,t){if(!e)throw Error("keychain.has: service is required");if(!t)throw Error("keychain.has: account is required");return await v("keychain").has(e,t)}};var gi={async check(e){if(o("permissions"))return await window.craft.permissions.check(e);return await Tt(e)},async request(e){if(o("permissions"))return await window.craft.permissions.request(e);return await hi(e)},async openSettings(e){if(o("permissions"))await window.craft.permissions.openSettings(e)}};async function Tt(e){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let t=await navigator.permissions.query({name:e});return wi(t.state)}catch{return"not-supported"}}async function hi(e){if(e==="notifications"&&typeof window<"u"&&"Notification"in window){let t=await window.Notification.requestPermission();return t==="granted"?"granted":t==="denied"?"denied":"undetermined"}return await Tt(e)}function wi(e){if(e==="granted")return"granted";if(e==="denied")return"denied";if(e==="prompt")return"undetermined";return"undetermined"}var bi={async print(){if(o("printing")){await window.craft.printing.print();return}if(typeof window<"u"&&typeof window.print==="function")window.print()},async printToPDF(e){if(!e)throw Error("printToPDF: path is required");let t=e.startsWith("/"),r=/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\");if(!t&&!r)throw Error("printToPDF: path must be absolute");let n=await v("printing").printToPDF(e);return{ok:!!(n&&n.ok),path:n?.path}}};var xi={async enable(){if(!o("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!o("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!o("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};async function Ee(e){if(!o("tray"))return;let t=window.craft.tray;await e(t)}var yi={setIcon:(e)=>Ee((t)=>t.setIcon(e)),setTitle:(e)=>Ee((t)=>t.setTitle(e)),setTooltip:(e)=>Ee((t)=>t.setTooltip(e))};function Me(){if(!o("window"))return null;return window.craft.window}function D(e){let t=Me();if(!t)return Promise.resolve();try{return Promise.resolve(e(t)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var vi={get available(){return Me()!==null},open(e){let t=()=>{if(typeof window<"u"&&e.url)window.open(e.url,e.name);return{name:e.name}},r=Me();if(!r?.open)return Promise.resolve(t());return r.open(e).then((n)=>({name:n?.name||e.name})).catch(t)},close:()=>D((e)=>e.close?.()),show:()=>D((e)=>e.show?.()),hide:()=>D((e)=>e.hide?.()),focus:()=>D((e)=>e.focus?.()),minimize:()=>D((e)=>e.minimize?.()),maximize:()=>D((e)=>e.maximize?.()),center:()=>D((e)=>e.center?.()),startDrag:()=>D((e)=>e.startDrag?.()),setTitle:(e)=>D((t)=>t.setTitle?.(e)),setSize:(e,t)=>D((r)=>r.setSize?.(e,t)),setAppearance:(e)=>D((t)=>t.setAppearance?.(e))};var Pi={async addItem(e){if(o("touchbar"))await window.craft.touchbar.addItem(e)},async removeItem(e){if(o("touchbar"))await window.craft.touchbar.removeItem(e)},async updateItem(e,t){if(o("touchbar"))await window.craft.touchbar.updateItem(e,t)},async setLabel(e,t){if(o("touchbar"))await window.craft.touchbar.setLabel(e,t)},async setIcon(e,t){if(o("touchbar"))await window.craft.touchbar.setIcon(e,t)},async setEnabled(e,t){if(o("touchbar"))await window.craft.touchbar.setEnabled(e,t)},async setSliderValue(e,t){if(o("touchbar"))await window.craft.touchbar.setSliderValue(e,t)},async clear(){if(o("touchbar"))await window.craft.touchbar.clear()},async show(){if(o("touchbar"))await window.craft.touchbar.show()},async hide(){if(o("touchbar"))await window.craft.touchbar.hide()},onAction(e){return h("craft:touchbar:action",e)}};var Si=/^[\da-f]*$/i;function ki(e,t){if(typeof t!=="string"||!Si.test(t)||t.length%2!==0)throw Error(`${e}: must be a hex string with even length, got ${JSON.stringify(t)}`)}var Ai={async isEnabled(){return o("bluetooth")?await window.craft.bluetooth.isEnabled():!1},async powerState(){return o("bluetooth")?await window.craft.bluetooth.powerState():"unknown"},async connectedDevices(){return o("bluetooth")?await window.craft.bluetooth.connectedDevices():[]},async pairedDevices(){return o("bluetooth")?await window.craft.bluetooth.pairedDevices():[]},async startDiscovery(){if(o("bluetooth"))await window.craft.bluetooth.startDiscovery()},async stopDiscovery(){if(o("bluetooth"))await window.craft.bluetooth.stopDiscovery()},async isDiscovering(){return o("bluetooth")?await window.craft.bluetooth.isDiscovering():!1},async connect(e){if(o("bluetooth"))await window.craft.bluetooth.connect(e)},async disconnect(e){if(o("bluetooth"))await window.craft.bluetooth.disconnect(e)},async openPreferences(){if(o("bluetooth"))await window.craft.bluetooth.openPreferences()},async discoverServices(e){if(!e)throw Error("bluetooth.discoverServices: deviceId is required");if(!o("bluetooth"))return[];let t=await window.craft.bluetooth.discoverServices(e);return Array.isArray(t)?t:[]},async discoverCharacteristics(e,t){if(!e||!t)throw Error("bluetooth.discoverCharacteristics: deviceId and serviceUuid are required");if(!o("bluetooth"))return[];let r=await window.craft.bluetooth.discoverCharacteristics(e,t);return Array.isArray(r)?r:[]},async readCharacteristic(e,t,r){if(!e||!t||!r)throw Error("bluetooth.readCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(!o("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.readCharacteristic(e,t,r)},async writeCharacteristic(e,t,r,n,i="with-response"){if(!e||!t||!r)throw Error("bluetooth.writeCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(ki("bluetooth.writeCharacteristic.valueHex",n),!o("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.writeCharacteristic(e,t,r,n,i)},async setCharacteristicNotify(e,t,r,n){if(!e||!t||!r)throw Error("bluetooth.setCharacteristicNotify: deviceId, serviceUuid, characteristicUuid are required");if(!o("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.setCharacteristicNotify(e,t,r,n)},onDeviceFound(e){return h("craft:bluetooth:deviceFound",e)},onDeviceConnected(e){return h("craft:bluetooth:deviceConnected",e)},onDeviceDisconnected(e){return h("craft:bluetooth:deviceDisconnected",e)},onCharacteristicValue(e){return h("craft:bluetooth:characteristicValue",e)}};var Ci={async speak(e,t){if(!e)throw Error("speech.speak: text is required");if(o("speech")){await window.craft.speech.speak(e,t);return}if(typeof window<"u"&&window.speechSynthesis){let r=new window.SpeechSynthesisUtterance(e);if(t){if(t.rate!=null)r.rate=t.rate;if(t.pitch!=null)r.pitch=t.pitch;if(t.volume!=null)r.volume=t.volume;if(t.voice){let i=window.speechSynthesis.getVoices().find((a)=>a.voiceURI===t.voice||a.name===t.voice||a.lang===t.voice);if(i)r.voice=i}}window.speechSynthesis.speak(r)}},async stop(){if(o("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(o("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(o("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(o("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(o("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map((t)=>({id:t.voiceURI||t.name,name:t.name,language:t.lang||"",quality:"default"}));return[]}};var J=[],De=!0,Be,Oe,Q={async report(e){if(o("crashReporter")){await window.craft.crashReporter.report(e);return}if(!De)return;let t=e instanceof Error?{timestamp:Date.now(),severity:"error",message:e.message,source:"js",stack:e.stack||"",userId:Be,appVersion:Oe}:{timestamp:Date.now(),severity:e.severity||"error",message:e.message||"",source:e.source||"js",stack:e.stack||"",userId:Be,appVersion:Oe};if(J.length>=64)J.shift();J.push(t)},async flush(){if(o("crashReporter"))return await window.craft.crashReporter.flush();return[...J]},async clear(){if(o("crashReporter")){await window.craft.crashReporter.clear();return}J.length=0},async setEnabled(e){if(o("crashReporter")){await window.craft.crashReporter.setEnabled(e);return}De=e},async isEnabled(){if(o("crashReporter"))return await window.craft.crashReporter.isEnabled();return De},async setUser(e){if(o("crashReporter")){await window.craft.crashReporter.setUser(e);return}Be=e||void 0},async setAppVersion(e){if(o("crashReporter")){await window.craft.crashReporter.setAppVersion(e);return}Oe=e||void 0},attachGlobalHandlers(){if(o("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let e=(r)=>{Q.report({severity:"error",message:r.message,source:"js",stack:r.error?.stack||`${r.message}
|
|
927
927
|
at ${r.filename}:${r.lineno}:${r.colno}`}).catch(()=>{})},t=(r)=>{let n=r.reason;Q.report({severity:"error",message:n?.message||String(n),source:"js",stack:n?.stack||""}).catch(()=>{})};return window.addEventListener("error",e),window.addEventListener("unhandledrejection",t),()=>{window.removeEventListener("error",e),window.removeEventListener("unhandledrejection",t)}},forwardTo(e){return Di(e)}},Ii="craft:crashReporter:pending",$i=/[\w.+-]+@[\w-]+\.[\w.-]+/g,Ti=/\b(?:\d{1,3}\.){3}\d{1,3}\b/g,Ei=/\/(?:Users|home)\/[^\s/'"`]+/g;function Mt(e){let t=(r)=>r.replace($i,"<email>").replace(Ti,"<ip>").replace(Ei,"/<home>");return{...e,message:t(e.message),stack:t(e.stack)}}async function Dt(e,t){let r=new TextEncoder,n=await crypto.subtle.importKey("raw",r.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),i=await crypto.subtle.sign("HMAC",n,r.encode(t));return[...new Uint8Array(i)].map((a)=>a.toString(16).padStart(2,"0")).join("")}function Mi(e){if(!e||typeof localStorage>"u")return[];try{let t=localStorage.getItem(e);if(!t)return[];let r=JSON.parse(t);return Array.isArray(r)?r:[]}catch{return[]}}function Et(e,t){if(!e||typeof localStorage>"u")return;try{if(t.length===0)localStorage.removeItem(e);else localStorage.setItem(e,JSON.stringify(t))}catch{}}function Di(e){let{endpoint:t,intervalMs:r=60000,signingSecret:n,redact:i=!0,headers:a={},maxRetries:s=5,persistKey:c}=e,l=c===null?null:c??Ii,d=Mi(l),f=!1,m=null,u=null,w=typeof i==="function"?i:i===!1?(k)=>k:Mt;async function b(k){let A=JSON.stringify({entries:k}),B={"Content-Type":"application/json",...a};if(n)B["X-Craft-Signature"]=await Dt(n,A);let ee=0,O=1000;while(!f)try{let z=await fetch(t,{method:"POST",headers:B,body:A});if(z.ok)return;if(z.status>=400&&z.status<500)return;throw Error(`HTTP ${z.status}`)}catch(z){if(ee+=1,ee>s)throw d=[...k,...d],Et(l,d),z;await new Promise((Ft)=>{setTimeout(Ft,O)}),O=Math.min(O*2,60000)}}async function S(){if(f||u)return u??void 0;let k=await Q.flush();if(k.length>0)await Q.clear();if(d=[...d,...k.map((B)=>w(B))],d.length===0)return;let A=d;return d=[],Et(l,d),u=b(A).catch(()=>{}).finally(()=>{u=null}),u}if(r>0)m=setInterval(()=>{S().catch(()=>{})},r);return{async flushNow(){await S()},stop(){if(f=!0,m)clearInterval(m);m=null},pending(){return[...d]}}}var Bi={async isAvailable(){if(!o("iap"))return!1;return await window.craft.iap.isAvailable()},async getProducts(e){if(!o("iap"))return[];let t=Array.isArray(e)?e:[String(e)];return await window.craft.iap.getProducts(t)},async purchase(e){if(!o("iap"))return{queued:!1,productId:e,reason:"IAP bridge not available"};let t=await window.craft.iap.purchase(e);return{queued:!!(t&&t.queued),productId:t?.productId,reason:t?.reason}},async restorePurchases(){if(!o("iap"))return{ok:!1};let e=await window.craft.iap.restorePurchases();return{ok:!!(e&&e.ok)}},async finishTransaction(e){if(!o("iap"))return;await window.craft.iap.finishTransaction(e)},async getReceiptData(){if(!o("iap"))return null;let e=await window.craft.iap.getReceiptData();return e?String(e):null},onPurchased(e){return h("craft:iap:purchased",e)},onFailed(e){return h("craft:iap:failed",e)},onRestored(e){return h("craft:iap:restored",e)},onProductsLoaded(e){return h("craft:iap:productsLoaded",(t)=>e(t.products||[]))},onRefunded(e){return h("craft:iap:refunded",e)},onSubscriptionStatusChanged(e){return h("craft:iap:subscriptionStatusChanged",e)},async getActiveSubscriptions(){if(!o("iap"))return[];let e=window.craft.iap.getActiveSubscriptions;if(typeof e!=="function")return[];let t=await e();return Array.isArray(t)?t:[]},async isEligibleForIntroOffer(e){if(!o("iap"))return!1;let t=window.craft.iap.isEligibleForIntroOffer;if(typeof t!=="function")return!1;return!!await t(e)}};var Z={async startActivity(e,t){if(!e)throw Error("handoff.startActivity: type is required");if(!o("handoff"))return!1;let r=await window.craft.handoff.startActivity(e,t);return typeof r==="boolean"?r:!!(r&&r.ok)},async updateActivity(e){if(!o("handoff"))return!1;let t=await window.craft.handoff.updateActivity(e);return typeof t==="boolean"?t:!!(t&&t.ok)},async stopActivity(){if(!o("handoff"))return;await window.craft.handoff.stopActivity()},async getCurrentActivity(){if(!o("handoff"))return null;let e=await window.craft.handoff.getCurrentActivity();return e&&typeof e.type==="string"?e:null},onIncoming(e){return h("craft:handoff:incoming",e)}};var Oi={async start(e,t){return Z.startActivity(e,{title:t?.title,webpageURL:t?.webpageURL,userInfo:t?.state})},async update(e){return Z.updateActivity({title:e.title,webpageURL:e.webpageURL,userInfo:e.state})},async stop(){await Z.stopActivity()}};var Ri={async requestPermission(e="whenInUse"){if(o("location"))return await window.craft.location.requestPermission(e);if(typeof navigator<"u"&&navigator.geolocation)return"undetermined";return"not-supported"},async getAuthorization(){if(o("location"))return await window.craft.location.getAuthorization();return"unknown"},async getCurrentLocation(){if(o("location"))return await window.craft.location.getCurrentLocation();if(typeof navigator<"u"&&navigator.geolocation)return navigator.geolocation.getCurrentPosition((e)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:e.coords.latitude,longitude:e.coords.longitude,altitude:e.coords.altitude,horizontalAccuracy:e.coords.accuracy,verticalAccuracy:e.coords.altitudeAccuracy,speed:e.coords.speed}}))},(e)=>{window.dispatchEvent(new CustomEvent("craft:location:error",{detail:{message:e.message||String(e)}}))}),{requested:!0};return{requested:!1}},async startWatching(e){if(o("location"))return await window.craft.location.startWatching(e);if(typeof navigator<"u"&&navigator.geolocation){let t=navigator.geolocation.watchPosition((r)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:r.coords.latitude,longitude:r.coords.longitude,altitude:r.coords.altitude,horizontalAccuracy:r.coords.accuracy,verticalAccuracy:r.coords.altitudeAccuracy,speed:r.coords.speed}}))});return window.__craftWebLocationWatchId=t,!0}return!1},async stopWatching(){if(o("location")){await window.craft.location.stopWatching();return}if(typeof navigator<"u"&&navigator.geolocation){let e=window.__craftWebLocationWatchId;if(e!=null)navigator.geolocation.clearWatch(e),window.__craftWebLocationWatchId=null}},onUpdate(e){return h("craft:location:update",e)},onError(e){return h("craft:location:error",e)},onAuthChanged(e){return h("craft:location:authChanged",e)}};var Li={async captureScreen(){if(!o("screenCapture"))return null;let e=await window.craft.screenCapture.captureScreen();return e?String(e):null},async captureWindow(e){if(!o("screenCapture"))return null;if(!Number.isFinite(e)||e<=0)throw Error("captureWindow: id must be a positive number");let t=await window.craft.screenCapture.captureWindow(e);return t?String(t):null},async listWindows(){if(!o("screenCapture"))return[];return await window.craft.screenCapture.listWindows()}};var Ot=250,Rt=60000,ue=2000,Bt={sharing:!1,signals:{systemScreenShare:!1,remoteSession:!1,conferenceSharing:!1,screenRecording:!1},sources:[]};function _i(){return{...Bt,signals:{...Bt.signals},sources:[]}}var de={async getState(){if(!o("screenSharing"))return _i();return await window.craft.screenSharing.getState()},async watch(e=ue){let t=Number.isFinite(e)?Math.min(Rt,Math.max(Ot,Math.round(e))):ue;if(!o("screenSharing"))return t;let r=await window.craft.screenSharing.watch(t);return r&&r.intervalMs||t},async stop(){if(!o("screenSharing"))return;await window.craft.screenSharing.unwatch()},onChange(e){return h("craft:screenSharing:change",e)}};async function Ni(e,t=ue){let r=de.onChange(e);try{await de.watch(t)}catch(i){throw r(),i}let n;return()=>{if(!n)r(),n=de.stop();return n}}var Fi={supported:!1,isFocused:null,authorization:"unsupported"};function Lt(){return{ok:!1,error:"Focus control is only available in a Craft window on macOS"}}var Re={async getStatus(){if(!o("focus"))return{...Fi};return await window.craft.focus.getStatus()},async requestAuthorization(){if(!o("focus"))return"unsupported";return await window.craft.focus.requestAuthorization()},async setEnabled(e,t={}){if(!o("focus"))return Lt();if(!(e?t.onShortcut:t.offShortcut))return{ok:!1,error:`focus.setEnabled: no ${e?"onShortcut":"offShortcut"} configured`};return await window.craft.focus.setEnabled(e,t)},async runShortcut(e){if(!o("focus"))return Lt();if(!e)throw Error("focus.runShortcut: name is required");return await window.craft.focus.runShortcut(e)},async listShortcuts(){if(!o("focus"))return[];return await window.craft.focus.listShortcuts()},async listShortcutsResult(){if(!o("focus"))return{canList:!1,shortcuts:[]};let t=await window.craft.focus.listShortcutsResult?.();return{canList:Boolean(t?.canList),shortcuts:t?.shortcuts??[]}}};async function Wi(...e){if(e.length===0)return!1;let t=new Set(await Re.listShortcuts());return e.every((r)=>t.has(r))}async function zi(...e){if(e.length===0)return!1;let{canList:t,shortcuts:r}=await Re.listShortcutsResult();if(!t)return"unknown";let n=new Set(r);return e.every((i)=>n.has(i))}var Hi={async start(e=0,t="127.0.0.1"){if(!o("localServer"))return{port:0,started:!1,reason:"bridge unavailable"};return await window.craft.localServer.start(e,t)},async stop(){if(!o("localServer"))return;await window.craft.localServer.stop()},async respond(e){if(!o("localServer"))return;await window.craft.localServer.respond(e||{status:200,body:"OK"})},onRequest(e){return h("craft:localServer:request",e)},async awaitOAuthCallback(e={}){v("localServer");let{port:t=0,host:r="127.0.0.1",timeoutMs:n=300000,successHTML:i}=e,a=await this.start(t,r);if(!a.started)throw Error(`localServer: start failed${a.reason?` \u2014 ${a.reason}`:""}`);return new Promise((s,c)=>{let l=setTimeout(()=>{d(),this.stop().catch(()=>{}),c(Error("localServer: OAuth callback timed out"))},n),d=this.onRequest(({url:f})=>{clearTimeout(l),d();let m=i??`<!doctype html><meta charset="utf-8"><title>Done</title>
|
|
928
928
|
<style>body{font-family:-apple-system,BlinkMacSystemFont,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f7}</style>
|
|
929
929
|
<div><h1>You can close this tab.</h1><p>Returning to the app\u2026</p></div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{x}from"./chunk-7rta163c.js";import{ye,$t,Co,Eo,Ra,Aa,Pa,Ia,ls,$o,Oa,Na,Da,un}from"./chunk-
|
|
2
|
+
import{x}from"./chunk-7rta163c.js";import{ye,$t,Co,Eo,Ra,Aa,Pa,Ia,ls,$o,Oa,Na,Da,un}from"./chunk-20g54d4x.js";import{o}from"./chunk-g8xht25s.js";import{zs}from"./chunk-rr6qk4t0.js";import{c}from"./chunk-zhf01af3.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=un.filter((e)=>!ge.has(e)).sort(),te=[...x].sort(),me=[...new Set([...ee,...te])].sort(),he=new Set(ee),be=new Set(te),xe=new Set(me),Y=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ne(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?he:be;Y.lastIndex=0;for(let l of u.code.matchAll(Y)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let y=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!y)continue;let r=y[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+y[0].length-r.length,p=e.slice(0,f),w=p.split(`
|
|
3
3
|
`).length;s.push({line:w,column:f-(p.lastIndexOf(`
|
|
4
4
|
`)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:Se(r,u.kind)})}}}return s}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let s=T.resolve(e);for(;;){let u=T.join(s,"tsconfig.json");if(t(u))return u;let i=T.dirname(s);if(i===s)return;s=i}}function ie(e,t,s){let u=we(e,s);if(!u)return;let i=new Set,l=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let S=m.compilerOptions?.plugins;if(Array.isArray(S)){let r=S.find((p)=>p?.name===ke),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let y=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...y].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=T.resolve(T.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function Pc(e,t="",s=""){let u=e.startLine>1?`
|
|
5
5
|
`.repeat(e.startLine-1):"",i=$o(e)+Eo(Co(e.code)),l=e.kind==="client"||e.kind==="plain"?Pa(t,e.code):"";return ls(`${u+i}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{xc,Sc}from"./chunk-1pettdfm.js";import"./chunk-793ddtq2.js";import"./chunk-nvgy1y0x.js";import"./chunk-rjh2jwxx.js";import"./chunk-yq021b3r.js";import"./chunk-6jrm0aks.js";import"./chunk-zqtbtqbq.js";import"./chunk-104wkd4z.js";import{_i}from"./chunk-3wtxp6xm.js";import"./chunk-jxda11cg.js";import"./chunk-2jh21f1n.js";import"./chunk-5eddytbs.js";import"./chunk-rcadtv3x.js";import"./chunk-khn42pf7.js";import"./chunk-0jhdrgpr.js";import"./chunk-ym41ybz2.js";import"./chunk-n38yb274.js";import"./chunk-55ttbbc0.js";import"./chunk-tre98h62.js";import"./chunk-db2g2k9r.js";import"./chunk-dgb4z4kw.js";import"./chunk-r3e6x87d.js";import"./chunk-mmwedr93.js";import"./chunk-aprhqxky.js";import"./chunk-kgfgb971.js";import"./chunk-nrvwejdw.js";import"./chunk-xytf5yzv.js";import"./chunk-rr6qk4t0.js";import"./chunk-pxqh758g.js";import"./chunk-m8yhs4dp.js";import"./chunk-c1dkh0es.js";import"./chunk-6ajahb2x.js";import"./chunk-510vd60c.js";import"./chunk-bmtxdtcd.js";import"./chunk-v2x9vzgw.js";import{Ee,s}from"./chunk-wk9v5bj3.js";import"./chunk-0c0g8x6p.js";import"./chunk-prf164ct.js";import"./chunk-gwjjrhf2.js";import"./chunk-511rs0zz.js";import"./chunk-rs53mztk.js";import"./chunk-r7kmsq3n.js";import"./chunk-fa6xrfj8.js";import{me}from"./chunk-brdbnkwq.js";import"./chunk-8nryyqb5.js";import{Xn,Jn}from"./chunk-px1qz3vc.js";import{qr,N,o}from"./chunk-g8xht25s.js";import"./chunk-x2yxb53d.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-t9mfztcs.js";import"./chunk-zaaeneq6.js";import{f,Oe}from"./chunk-20g54d4x.js";import"./chunk-wcez7djm.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";import"./chunk-9p6efb17.js";import"./chunk-t2pzy3x1.js";export{qr as buildWebComponents,Jn as cacheTemplate,Xn as checkCache,_i as classifyAllScripts,xc as createMiddleware,Sc as createRoute,N as defaultConfig,f as extractVariables,me as injectRouterScript,o as loadStxConfig,Oe as processClientScript,s as processDirectives,Ee as readMarkdownFile};
|