@stacksjs/stx 0.2.337 → 0.2.339

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.
Files changed (174) hide show
  1. package/dist/app-shell.js +9 -8
  2. package/dist/caching.d.ts +1 -18
  3. package/dist/caching.js +2 -21
  4. package/dist/{chunk-97yd8erh.js → chunk-066yt1hy.js} +1 -1
  5. package/dist/chunk-09fb200s.js +2 -0
  6. package/dist/chunk-0b3cqgyr.js +2 -0
  7. package/dist/chunk-0tky87hx.js +2 -0
  8. package/dist/{chunk-dwjcmxez.js → chunk-0xgc5t3y.js} +1 -1
  9. package/dist/{chunk-v5d0xj8c.js → chunk-156j37tv.js} +3 -3
  10. package/dist/{chunk-3g2j4eh8.js → chunk-191bg6nt.js} +1 -1
  11. package/dist/{chunk-w52p79xs.js → chunk-1q6xc3m2.js} +1 -1
  12. package/dist/{chunk-apsmgvrk.js → chunk-22hch2me.js} +1 -1
  13. package/dist/{chunk-9btdax2s.js → chunk-28q3vycz.js} +1 -1
  14. package/dist/{chunk-dfymexrx.js → chunk-2gc4cevb.js} +1 -1
  15. package/dist/{chunk-tp6wkx7g.js → chunk-2tjk867y.js} +1 -1
  16. package/dist/chunk-408rnn07.js +2 -0
  17. package/dist/chunk-48d9ey9k.js +2 -0
  18. package/dist/chunk-58j32d7n.js +2 -0
  19. package/dist/{chunk-5ep11kvc.js → chunk-5g6rprcy.js} +1 -1
  20. package/dist/{chunk-er3adkx7.js → chunk-5qsg9q46.js} +1 -1
  21. package/dist/chunk-63h3pg9g.js +2 -0
  22. package/dist/{chunk-jyq43tp9.js → chunk-63xv0h5e.js} +1 -1
  23. package/dist/{chunk-7rf71ecp.js → chunk-64qg8jes.js} +2 -2
  24. package/dist/chunk-6av24ywm.js +2 -0
  25. package/dist/{chunk-as5j2s4h.js → chunk-6n1qbh78.js} +1 -1
  26. package/dist/chunk-6qe53wjc.js +2 -0
  27. package/dist/chunk-7157az6e.js +2 -0
  28. package/dist/{chunk-akdryjck.js → chunk-799s9mwc.js} +2 -2
  29. package/dist/{chunk-g3cyygvf.js → chunk-7a21q2q4.js} +1 -1
  30. package/dist/chunk-7qawmh8w.js +30 -0
  31. package/dist/{chunk-x5y9r3f2.js → chunk-7r79j1hs.js} +1 -1
  32. package/dist/{chunk-yjkaqxtc.js → chunk-7r80apc5.js} +1 -1
  33. package/dist/{chunk-vjp1sg5y.js → chunk-86v2rps7.js} +1 -1
  34. package/dist/{chunk-fckan25d.js → chunk-97ej3abh.js} +1 -1
  35. package/dist/{chunk-w3d5xrdy.js → chunk-a26hcag1.js} +1 -1
  36. package/dist/chunk-a2nsmczq.js +2 -0
  37. package/dist/chunk-ar0fcmpj.js +2 -0
  38. package/dist/{chunk-5sqbd646.js → chunk-aved735s.js} +2 -2
  39. package/dist/{chunk-f6sejeg3.js → chunk-axqfm9b4.js} +1 -1
  40. package/dist/{chunk-9kb0qv47.js → chunk-ay336sqb.js} +1 -1
  41. package/dist/{chunk-vcdt10ke.js → chunk-az4mq459.js} +1 -1
  42. package/dist/chunk-azhpwmty.js +2 -0
  43. package/dist/chunk-b3pn6dh5.js +2 -0
  44. package/dist/{chunk-gwrrs1qh.js → chunk-b4cabzk9.js} +1 -1
  45. package/dist/{chunk-1ybanbh4.js → chunk-c3xmcsvd.js} +10 -10
  46. package/dist/chunk-ca6t6nnn.js +2 -0
  47. package/dist/{chunk-64kky38b.js → chunk-chkbvqq2.js} +3 -3
  48. package/dist/{chunk-hv8j33px.js → chunk-d3kjaae0.js} +1 -1
  49. package/dist/{chunk-s9hsxhb5.js → chunk-d6yyzpsv.js} +174 -72
  50. package/dist/chunk-d72ps148.js +2 -0
  51. package/dist/{chunk-bafd6h7t.js → chunk-d7zxg9bp.js} +2 -2
  52. package/dist/{chunk-3n9rvrk1.js → chunk-dekxwgc2.js} +1 -1
  53. package/dist/{chunk-tjhzxbxa.js → chunk-deqnt1w5.js} +1 -1
  54. package/dist/chunk-e0r2hndd.js +2 -0
  55. package/dist/{chunk-bkwg5cgq.js → chunk-e2emz8yb.js} +1 -1
  56. package/dist/chunk-e4sgv8p0.js +2 -0
  57. package/dist/chunk-eb1v7f55.js +2 -0
  58. package/dist/{chunk-f5wernak.js → chunk-eq2j7w8p.js} +1 -1
  59. package/dist/chunk-evk1dzpg.js +2 -0
  60. package/dist/{chunk-8wqz2s4j.js → chunk-fa2mg49t.js} +2 -2
  61. package/dist/chunk-fx5m9d3t.js +2 -0
  62. package/dist/{chunk-yrj8gad9.js → chunk-gz6mszbx.js} +2 -2
  63. package/dist/{chunk-evmc7vhg.js → chunk-h0y4mb2m.js} +1 -1
  64. package/dist/{chunk-psazw7p1.js → chunk-hrdd26r4.js} +1 -1
  65. package/dist/chunk-jwa2jhd8.js +2 -0
  66. package/dist/{chunk-peqad61h.js → chunk-jx03a693.js} +1 -1
  67. package/dist/{chunk-pt4xht7s.js → chunk-k3dtvay1.js} +1 -1
  68. package/dist/{chunk-xgj1jw4p.js → chunk-kdhrk7x5.js} +1 -1
  69. package/dist/{chunk-xt7bsyj7.js → chunk-m11pb9cx.js} +1 -1
  70. package/dist/{chunk-p4bmz9x3.js → chunk-m46edxtt.js} +1 -1
  71. package/dist/chunk-mjf3xmxn.js +3 -0
  72. package/dist/chunk-mpbbfrpk.js +2 -0
  73. package/dist/{chunk-459qxwp1.js → chunk-mys0rat0.js} +1 -1
  74. package/dist/{chunk-evakht2n.js → chunk-n6eetz4r.js} +2 -2
  75. package/dist/{chunk-wx3kf6tm.js → chunk-nvp546bb.js} +1 -1
  76. package/dist/chunk-nwz43t6d.js +2 -0
  77. package/dist/chunk-p1cddybx.js +2 -0
  78. package/dist/chunk-pqtype7s.js +2 -0
  79. package/dist/{chunk-nzbdgx7d.js → chunk-pswhshrp.js} +3 -3
  80. package/dist/chunk-pvtnhx3j.js +2 -0
  81. package/dist/{chunk-c21x8w2q.js → chunk-q0srntf6.js} +1 -1
  82. package/dist/chunk-q1xcd8jg.js +3 -0
  83. package/dist/{chunk-rb69qb49.js → chunk-q9ckfwhh.js} +1 -1
  84. package/dist/{chunk-wxpwt67g.js → chunk-qtc28zy1.js} +1 -1
  85. package/dist/{chunk-6ex0t14b.js → chunk-r10fypcd.js} +1 -1
  86. package/dist/{chunk-b1w30x36.js → chunk-rkykwy3z.js} +1 -1
  87. package/dist/{chunk-3nv5h7jd.js → chunk-rzayq0ht.js} +1 -1
  88. package/dist/{chunk-zp5z8qwy.js → chunk-sntjqyqq.js} +1 -1
  89. package/dist/{chunk-09xhvt5p.js → chunk-stbns4bg.js} +1 -1
  90. package/dist/{chunk-tf3b833n.js → chunk-t00ga194.js} +1 -1
  91. package/dist/{chunk-557n2zx7.js → chunk-t8ctvjqe.js} +1 -1
  92. package/dist/{chunk-58jwsgr1.js → chunk-tr1174hz.js} +1 -1
  93. package/dist/{chunk-3k4wcezp.js → chunk-tr41gn5j.js} +1 -1
  94. package/dist/{chunk-wmgpb6b6.js → chunk-tr9ynxdw.js} +1 -1
  95. package/dist/{chunk-3405q9eb.js → chunk-tsmdmf5h.js} +1 -1
  96. package/dist/{chunk-b9w95df7.js → chunk-tvc2xwen.js} +1 -1
  97. package/dist/{chunk-at9knbt1.js → chunk-tzywy1s7.js} +1 -1
  98. package/dist/{chunk-sy44sx1e.js → chunk-vafj091j.js} +79 -79
  99. package/dist/{chunk-jc3t5y1y.js → chunk-vaggjvsm.js} +1 -1
  100. package/dist/chunk-vhzc08aa.js +2 -0
  101. package/dist/{chunk-qcf4506g.js → chunk-vxt5c5aq.js} +1 -1
  102. package/dist/{chunk-when7sgs.js → chunk-w72v0ab1.js} +1 -1
  103. package/dist/{chunk-qnx0eb8x.js → chunk-wb90259a.js} +1 -1
  104. package/dist/{chunk-3ys2esa2.js → chunk-wdq75f5k.js} +1 -1
  105. package/dist/chunk-wdvee4kr.js +17 -0
  106. package/dist/chunk-wqyfz0y6.js +2 -0
  107. package/dist/chunk-wwzzyqcg.js +2 -0
  108. package/dist/chunk-x2pzekhq.js +2 -0
  109. package/dist/{chunk-meqcxfpr.js → chunk-x48crnwa.js} +1 -1
  110. package/dist/{chunk-t77fg77q.js → chunk-x4vhn880.js} +1 -1
  111. package/dist/{chunk-zyb5gfr0.js → chunk-xe6zmdfq.js} +1 -1
  112. package/dist/{chunk-0dz59qg5.js → chunk-xhznr05n.js} +2 -2
  113. package/dist/chunk-xnpdkd13.js +2 -0
  114. package/dist/{chunk-jkyvk4x6.js → chunk-xy4jt4ek.js} +1 -1
  115. package/dist/{chunk-m93qtfxw.js → chunk-y8vj3rtt.js} +1 -1
  116. package/dist/{chunk-t2h8prxq.js → chunk-yne23w3c.js} +1 -1
  117. package/dist/{chunk-eeg62zy4.js → chunk-zfz3s2gd.js} +2 -2
  118. package/dist/{chunk-wv9v9mj9.js → chunk-zj039s33.js} +1 -1
  119. package/dist/{chunk-gy9a83n9.js → chunk-zm8b6e9n.js} +1 -1
  120. package/dist/chunk-zqtrg15a.js +2 -0
  121. package/dist/chunk-zzfpwxpp.js +2 -0
  122. package/dist/cli.js +14 -14
  123. package/dist/client-script-bundler.js +10 -8
  124. package/dist/config.js +1 -0
  125. package/dist/craft-entry.js +1 -1
  126. package/dist/craft.js +1 -1
  127. package/dist/database.js +1 -1
  128. package/dist/engine-fingerprint.d.ts +17 -0
  129. package/dist/engine-fingerprint.js +23 -0
  130. package/dist/pwa.js +2 -2
  131. package/dist/runtime-injection.js +2 -0
  132. package/dist/ssg.js +2 -2
  133. package/dist/types/config-types.d.ts +8 -0
  134. package/dist/variable-extractor.d.ts +1 -0
  135. package/dist/variable-extractor.js +8 -0
  136. package/dist/visual-testing.js +1 -1
  137. package/package.json +5 -5
  138. package/dist/chunk-06qm6p8r.js +0 -2
  139. package/dist/chunk-0e8x9jkb.js +0 -2
  140. package/dist/chunk-0tc5p1ty.js +0 -2
  141. package/dist/chunk-1xqe92jv.js +0 -2
  142. package/dist/chunk-1ybaz0a1.js +0 -2
  143. package/dist/chunk-20e4pcq1.js +0 -2
  144. package/dist/chunk-2wn5db49.js +0 -2
  145. package/dist/chunk-3376d979.js +0 -2
  146. package/dist/chunk-42tgak9b.js +0 -2
  147. package/dist/chunk-45bmthfs.js +0 -2
  148. package/dist/chunk-4bcax4rv.js +0 -2
  149. package/dist/chunk-623b1j9c.js +0 -2
  150. package/dist/chunk-6ym84983.js +0 -30
  151. package/dist/chunk-96q01emr.js +0 -2
  152. package/dist/chunk-994aga02.js +0 -3
  153. package/dist/chunk-btqmqzay.js +0 -2
  154. package/dist/chunk-bv65tr40.js +0 -2
  155. package/dist/chunk-ch06z00p.js +0 -2
  156. package/dist/chunk-cs9w9kwy.js +0 -2
  157. package/dist/chunk-czh7agd6.js +0 -2
  158. package/dist/chunk-gab2hnk7.js +0 -2
  159. package/dist/chunk-h3w1y4q7.js +0 -2
  160. package/dist/chunk-hphhqwn5.js +0 -2
  161. package/dist/chunk-j3b8cnss.js +0 -17
  162. package/dist/chunk-jv70d481.js +0 -2
  163. package/dist/chunk-jxqf4y2y.js +0 -2
  164. package/dist/chunk-k14sz6cz.js +0 -2
  165. package/dist/chunk-mppr5jht.js +0 -2
  166. package/dist/chunk-pp2ssem6.js +0 -2
  167. package/dist/chunk-sfaj3res.js +0 -2
  168. package/dist/chunk-tbynnx22.js +0 -2
  169. package/dist/chunk-tgsj4g9k.js +0 -2
  170. package/dist/chunk-thfpfk45.js +0 -2
  171. package/dist/chunk-wj8sx4fx.js +0 -2
  172. package/dist/chunk-wnnv5d1t.js +0 -2
  173. package/dist/chunk-xzhvnk8r.js +0 -2
  174. package/dist/chunk-y97yx6ap.js +0 -2
@@ -1,19 +1,108 @@
1
1
  // @bun
2
- import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>v.includes(a))}function w(t){return N(t.replace(/^\//,""))}var v;var k=d(()=>{v=["components","layouts","partials","emails"]});import f from"fs";import b from"path";function A(t,e){let a=t.filter((s)=>!w(s.pattern)),r=["// Auto-generated by STX - do not edit"];if(a.length===0)r.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{r.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let s of a){let l=[];for(let c of s.params){let u=s.pattern.includes(`:${c}?`)?"?":"";l.push(`${c}${u}: string`)}let i=l.join("; ");r.push(` '${s.pattern}': { ${i} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
3
- `),o=b.join(e,"route-types.d.ts");try{if(f.existsSync(o)&&f.readFileSync(o,"utf8")===n)return;f.mkdirSync(e,{recursive:!0}),f.writeFileSync(o,n)}catch{}}function C(t,e,a){let r=process.cwd(),n=b.relative(r,a),o=t.filter((l)=>!w(l.pattern)),s=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let l of o){let i=b.relative(r,l.filePath).replace(/\\/g,"/"),c=JSON.stringify(l.params),u=l.layout?`, layout: '${b.relative(r,l.layout).replace(/\\/g,"/")}'`:"";s.push(` { pattern: '${l.pattern}', filePath: '${i}', isDynamic: ${l.isDynamic}, params: ${c}${u} },`)}s.push("] as const",""),s.push("export type RouteName = typeof routes[number]['pattern']",""),f.mkdirSync(e,{recursive:!0}),f.writeFileSync(b.join(e,"routes.ts"),s.join(`
4
- `))}var P=d(()=>{k()});import K from"path";function T(t,e){let r=K.relative(e,t).replace(/\.(stx|md)$/,"");if(r=r.split(K.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function x(t){let e=[],a="",r=0;while(r<t.length){let n=t.slice(r),o=/^\/:([^/?*]+)\?/.exec(n);if(o){e.push(o[1]),a+="(?:/([^/]+))?",r+=o[0].length;continue}let s=/^:([^/?*]+)\*/.exec(n);if(s){e.push(s[1]),a+="(.+)",r+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(n);if(l){e.push(l[1]),a+="([^/]+)",r+=l[0].length;continue}a+=t[r].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),r+=1}return{regex:new RegExp(`^${a}$`),params:e}}function $(t,e){let a=t===""?"/":t;for(let r of e){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((s,l)=>{o[s]=n[l+1]}),{route:r,params:o}}}return null}function z(t){let e=t.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return x(e)}var B=()=>{};import Ce from"fs";import G from"path";function E(t,e){let a=[],r=G.dirname(t);while(r.startsWith(e)||r===e){let n=G.join(r,"_layout.stx");if(Ce.existsSync(n))a.unshift(n);if(r===e)break;r=G.dirname(r)}return a}var U=()=>{};import R from"fs";import p from"path";function Y(t,e){let a=[];if(!R.existsSync(t))return a;let r=R.readdirSync(t,{withFileTypes:!0});for(let n of r){let o=p.join(t,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(v.includes(n.name))continue;a.push(...Y(o,e))}else if(n.isFile()){let s=p.extname(n.name);if(e.includes(s)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class L{routes;pagesDir;pagesDirs;config;constructor(t,e={}){this.config=e;let a=e.pagesDirs&&e.pagesDirs.length>0?e.pagesDirs:[e.pagesDir||"pages"];this.pagesDirs=a.map((i)=>p.resolve(t,i)),this.pagesDir=this.pagesDirs[0];let r=e.extensions||[".stx"],n=(i)=>{let c=p.resolve(t,i);try{return R.realpathSync(c)}catch{return c}},o=(e.exclude??[]).filter((i)=>typeof i==="string"&&i.trim()!=="").map(n),s=(i)=>{if(o.length===0)return!1;let c=n(i);return o.some((u)=>c===u||c.startsWith(`${u}${p.sep}`))},l=new Set;this.routes=[];for(let i of this.pagesDirs){let c=Y(i,r).filter((h)=>!s(h)),u=new Map;for(let h of c){let m=T(h,i),y=e.pagesDirs?m.replace(/:[\w]+/g,":param"):m;if(e.pagesDirs&&u.has(y))throw Error(`Conflicting layer pages for ${m}: ${u.get(y)} and ${h}`);if(u.set(y,h),l.has(y))continue;l.add(y);let{regex:Ae,params:W}=x(m),I=e.layouts!==!1?E(h,i):[];this.routes.push({pattern:m,regex:Ae,params:W,filePath:h,isDynamic:W.length>0,layout:I.length>0?I[I.length-1]:void 0})}}if(this.routes.sort((i,c)=>{if(!i.isDynamic&&c.isDynamic)return-1;if(i.isDynamic&&!c.isDynamic)return 1;let u=i.pattern.split("/").length,h=c.pattern.split("/").length;if(u!==h)return h-u;return i.pattern.localeCompare(c.pattern)}),e.emit!==!1){let i=p.resolve(t,e.stateDir||process.env.STX_DIR?.trim()||".stx");A(this.routes,i),C(this.routes,i,this.pagesDir)}}match(t){let e=t===""?"/":t;for(let a of this.routes){let r=e.match(a.regex);if(r){let n={};return a.params.forEach((o,s)=>{n[o]=r[s+1]}),{route:a,params:n}}}return null}resolve(t,e){let a=this.routes.find((n)=>n.pattern===t||n.filePath.includes(t));if(!a)return"#not-found";let r=a.pattern;if(e)for(let[n,o]of Object.entries(e))r=r.replace(`:${n}`,encodeURIComponent(o));return r}addRoute(t){this.routes.push(t),this.routes.sort((e,a)=>{if(!e.isDynamic&&a.isDynamic)return-1;if(e.isDynamic&&!a.isDynamic)return 1;return e.pattern.localeCompare(a.pattern)})}getLayout(t){return t.layout??null}}function J(t,e){return new L(t,e)}function Z(t,e){let a=[`${e}.stx`,"error.stx"];for(let r of a){let n=p.join(t,r);if(R.existsSync(n))return n}return null}function Q(t,e){return t.map((a)=>{let r=p.relative(e,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var ee=d(()=>{P();B();U();k()});function te(t){_=t.replace(/\/$/,"")}function re(t,e,a={}){g[t]={path:e,name:t,params:a}}function ae(t){for(let[e,a]of Object.entries(t))if(typeof a==="string")g[e]={path:a,name:e};else g[e]={...a,name:e}}function ne(t,e={},a=!1){let r=g[t];if(!r)return console.warn(`Route [${t}] not defined.`),"#undefined-route";let n={...r.params,...e},o=r.path;o=o.replace(/:(\w+)/g,(l,i)=>{let c=n[i];if(c===void 0)return console.warn(`Missing parameter [${i}] for route [${t}].`),`:${i}`;return delete n[i],encodeURIComponent(String(c))});let s=Object.entries(n);if(s.length>0){let l=s.map(([i,c])=>`${encodeURIComponent(i)}=${encodeURIComponent(String(c))}`).join("&");o+=(o.includes("?")?"&":"?")+l}return a&&_?`${_}${o}`:o}function se(){for(let t of Object.keys(g))delete g[t];_=""}var g,_="";var oe=d(()=>{g={}});import ie from"fs";import le from"path";function ce(t,e={}){return{type:"redirect",path:t,options:{replace:e.replace??!1,external:e.external??!1,redirectCode:e.redirectCode??302}}}function ue(t){return{type:"abort",error:typeof t==="string"?{statusCode:500,message:t}:t}}function he(t,e={}){return{handler:t,mode:e.mode??"universal"}}function X(t){let e={};if(!t)return e;let a=t.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let s=n.trim(),l=o.join("=").trim();if(s)e[s]=decodeURIComponent(l)}}return e}function O(t,e,a={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(e)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function j(t,e){let a=t.headers.get("cookie")||"",r=X(a);return{get(n){return r[n]},set(n,o,s={}){r[n]=o,e.append("Set-Cookie",O(n,o,s))},delete(n){delete r[n],e.append("Set-Cookie",O(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function q(){return{get(t){if(typeof document>"u")return;return X(document.cookie)[t]},set(t,e,a={}){if(typeof document>"u")return;document.cookie=O(t,e,a)},delete(t){if(typeof document>"u")return;document.cookie=O(t,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return X(document.cookie)}}}function H(){let t=typeof window<"u"&&typeof window.localStorage<"u";return{get(e){if(!t)return null;try{return window.localStorage.getItem(e)}catch{return null}},set(e,a){if(!t)return;try{window.localStorage.setItem(e,a)}catch{}},remove(e){if(!t)return;try{window.localStorage.removeItem(e)}catch{}},isAvailable(){return t}}}function M(t,e){S.set(t,e)}function V(t){return S.get(t)}function de(t){return S.has(t)}function pe(){S.clear()}function fe(){return Array.from(S.keys())}async function ge(t,e="middleware"){let a=le.resolve(t,e);if(!ie.existsSync(a))return;let r=ie.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),s=le.join(a,n);try{let i=(await import(s)).default;if(i&&typeof i.handler==="function")M(o,i);else if(typeof i==="function")M(o,{handler:i,mode:"universal"})}catch(l){console.warn(`Failed to load middleware '${o}' from ${s}:`,l)}}}function Te(t){let e={};if(!t)return e;let a=new URLSearchParams(t);for(let[r,n]of a)e[r]=n;return e}function me(t,e,a,r=""){return{path:t,params:e,query:Te(r),fullPath:r?`${t}?${r}`:t,meta:a}}function ye(t,e,a,r){let n=r?.isServer??typeof window>"u",o=!n,s=new Headers;return{to:t,from:e,isClient:o,isServer:n,cookies:n&&a?j(a,s):q(),storage:H(),state:{},request:a,responseHeaders:s}}async function ve(t,e){let a=Array.isArray(t)?t:[t],r=e.isServer;for(let n of a){let o=V(n);if(!o)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:e.state,responseHeaders:e.responseHeaders};if(o.mode==="server"&&!r)continue;try{let s=await o.handler(e);if(s){if(s.type==="redirect")return{passed:!1,redirect:s,state:e.state,responseHeaders:e.responseHeaders};if(s.type==="abort")return{passed:!1,abort:s,state:e.state,responseHeaders:e.responseHeaders}}}catch(s){return console.error(`Error in middleware '${n}':`,s),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:s instanceof Error?s.message:"Middleware error"}},state:e.state,responseHeaders:e.responseHeaders}}}return{passed:!0,state:e.state,responseHeaders:e.responseHeaders}}var S;var we=d(()=>{S=new Map});function D(t){let a=t.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function be(t){let e=t.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=t.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=t.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=e?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||D(n)}}var xe=()=>{};function Ee(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}function Se(){if(F)return F;return F=Ee(`
2
+ import{rw as v$,sw as G}from"./chunk-5g6rprcy.js";function y($){return $.split(/[\\/]/).filter(Boolean).slice(0,-1).some((O)=>F.includes(O))}function A($){return y($.replace(/^\//,""))}var F;var C=G(()=>{F=["components","layouts","partials","emails"]});import W from"fs";import E from"path";function H($,U){let O=$.filter((K)=>!A(K.pattern)),I=["// Auto-generated by STX - do not edit"];if(O.length===0)I.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{I.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let K of O){let V=[];for(let X of K.params){let Y=K.pattern.includes(`:${X}?`)?"?":"";V.push(`${X}${Y}: string`)}let J=V.join("; ");I.push(` '${K.pattern}': { ${J} }`)}I.push(" }","}","","export {}","")}let B=I.join(`
3
+ `),L=E.join(U,"route-types.d.ts");try{if(W.existsSync(L)&&W.readFileSync(L,"utf8")===B)return;W.mkdirSync(U,{recursive:!0}),W.writeFileSync(L,B)}catch{}}function q($,U,O){let I=process.cwd(),B=E.relative(I,O),L=$.filter((V)=>!A(V.pattern)),K=["// Auto-generated by stx \u2014 do not edit",`// Source: ${B||"pages"}/`,"","export const routes = ["];for(let V of L){let J=E.relative(I,V.filePath).replace(/\\/g,"/"),X=JSON.stringify(V.params),Y=V.layout?`, layout: '${E.relative(I,V.layout).replace(/\\/g,"/")}'`:"";K.push(` { pattern: '${V.pattern}', filePath: '${J}', isDynamic: ${V.isDynamic}, params: ${X}${Y} },`)}K.push("] as const",""),K.push("export type RouteName = typeof routes[number]['pattern']",""),W.mkdirSync(U,{recursive:!0}),W.writeFileSync(E.join(U,"routes.ts"),K.join(`
4
+ `))}var f=G(()=>{C()});import i from"path";function N($,U){let I=i.relative(U,$).replace(/\.(stx|md)$/,"");if(I=I.split(i.sep).join("/"),I==="index")return"/";if(I.endsWith("/index"))I=I.slice(0,-6);return I=I.replace(/\[\[([^\]]+)\]\]/g,":$1?"),I=I.replace(/\[([^\]]+)\]/g,":$1"),I=I.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${I}`}function j($){let U=[],O="",I=0;while(I<$.length){let B=$.slice(I),L=/^\/:([^/?*]+)\?/.exec(B);if(L){U.push(L[1]),O+="(?:/([^/]+))?",I+=L[0].length;continue}let K=/^:([^/?*]+)\*/.exec(B);if(K){U.push(K[1]),O+="(.+)",I+=K[0].length;continue}let V=/^:([^/?*]+)/.exec(B);if(V){U.push(V[1]),O+="([^/]+)",I+=V[0].length;continue}O+=$[I].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),I+=1}return{regex:new RegExp(`^${O}$`),params:U}}function o($,U){let O=$===""?"/":$;for(let I of U){let B=O.match(I.regex);if(B){let L={};return I.params.forEach((K,V)=>{L[K]=B[V+1]}),{route:I,params:L}}}return null}function r($){let U=$.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return j(U)}var g=()=>{};import b$ from"fs";import d from"path";function R($,U){let O=[],I=d.dirname($);while(I.startsWith(U)||I===U){let B=d.join(I,"_layout.stx");if(b$.existsSync(B))O.unshift(B);if(I===U)break;I=d.dirname(I)}return O}var m=()=>{};import S from"fs";import Q from"path";function t($,U){let O=[];if(!S.existsSync($))return O;let I=S.readdirSync($,{withFileTypes:!0});for(let B of I){let L=Q.join($,B.name);if(B.isDirectory()){if(B.name.startsWith("."))continue;if(F.includes(B.name))continue;O.push(...t(L,U))}else if(B.isFile()){let K=Q.extname(B.name);if(U.includes(K)){if(B.name.startsWith("_")&&B.name!=="_layout.stx")continue;if(B.name==="_layout.stx")continue;O.push(L)}}}return O}class b{routes;pagesDir;pagesDirs;config;constructor($,U={}){this.config=U;let O=U.pagesDirs&&U.pagesDirs.length>0?U.pagesDirs:[U.pagesDir||"pages"];this.pagesDirs=O.map((J)=>Q.resolve($,J)),this.pagesDir=this.pagesDirs[0];let I=U.extensions||[".stx"],B=(J)=>{let X=Q.resolve($,J);try{return S.realpathSync(X)}catch{return X}},L=(U.exclude??[]).filter((J)=>typeof J==="string"&&J.trim()!=="").map(B),K=(J)=>{if(L.length===0)return!1;let X=B(J);return L.some((Y)=>X===Y||X.startsWith(`${Y}${Q.sep}`))},V=new Set;this.routes=[];for(let J of this.pagesDirs){let X=t(J,I).filter((Z)=>!K(Z)),Y=new Map;for(let Z of X){let _=N(Z,J),z=U.pagesDirs?_.replace(/:[\w]+/g,":param"):_;if(U.pagesDirs&&Y.has(z))throw Error(`Conflicting layer pages for ${_}: ${Y.get(z)} and ${Z}`);if(Y.set(z,Z),V.has(z))continue;V.add(z);let{regex:S$,params:s}=j(_),D=U.layouts!==!1?R(Z,J):[];this.routes.push({pattern:_,regex:S$,params:s,filePath:Z,isDynamic:s.length>0,layout:D.length>0?D[D.length-1]:void 0})}}if(this.routes.sort((J,X)=>{if(!J.isDynamic&&X.isDynamic)return-1;if(J.isDynamic&&!X.isDynamic)return 1;let Y=J.pattern.split("/").length,Z=X.pattern.split("/").length;if(Y!==Z)return Z-Y;return J.pattern.localeCompare(X.pattern)}),U.emit!==!1){let J=Q.resolve($,U.stateDir||process.env.STX_DIR?.trim()||".stx");H(this.routes,J),q(this.routes,J,this.pagesDir)}}match($){let U=$===""?"/":$;for(let O of this.routes){let I=U.match(O.regex);if(I){let B={};return O.params.forEach((L,K)=>{B[L]=I[K+1]}),{route:O,params:B}}}return null}resolve($,U){let O=this.routes.find((B)=>B.pattern===$||B.filePath.includes($));if(!O)return"#not-found";let I=O.pattern;if(U)for(let[B,L]of Object.entries(U))I=I.replace(`:${B}`,encodeURIComponent(L));return I}addRoute($){this.routes.push($),this.routes.sort((U,O)=>{if(!U.isDynamic&&O.isDynamic)return-1;if(U.isDynamic&&!O.isDynamic)return 1;return U.pattern.localeCompare(O.pattern)})}getLayout($){return $.layout??null}}function a($,U){return new b($,U)}function e($,U){let O=[`${U}.stx`,"error.stx"];for(let I of O){let B=Q.join($,I);if(S.existsSync(B))return B}return null}function $$($,U){return $.map((O)=>{let I=Q.relative(U,O.filePath),B=O.isDynamic?" (dynamic)":"";return`${O.pattern} \u2192 ${I}${B}`})}var U$=G(()=>{f();g();m();C()});function I$($){x=$.replace(/\/$/,"")}function O$($,U,O={}){M[$]={path:U,name:$,params:O}}function B$($){for(let[U,O]of Object.entries($))if(typeof O==="string")M[U]={path:O,name:U};else M[U]={...O,name:U}}function J$($,U={},O=!1){let I=M[$];if(!I)return console.warn(`Route [${$}] not defined.`),"#undefined-route";let B={...I.params,...U},L=I.path;L=L.replace(/:(\w+)/g,(V,J)=>{let X=B[J];if(X===void 0)return console.warn(`Missing parameter [${J}] for route [${$}].`),`:${J}`;return delete B[J],encodeURIComponent(String(X))});let K=Object.entries(B);if(K.length>0){let V=K.map(([J,X])=>`${encodeURIComponent(J)}=${encodeURIComponent(String(X))}`).join("&");L+=(L.includes("?")?"&":"?")+V}return O&&x?`${x}${L}`:L}function K$(){for(let $ of Object.keys(M))delete M[$];x=""}var M,x="";var L$=G(()=>{M={}});import V$ from"fs";import X$ from"path";function Y$($,U={}){return{type:"redirect",path:$,options:{replace:U.replace??!1,external:U.external??!1,redirectCode:U.redirectCode??302}}}function Z$($){return{type:"abort",error:typeof $==="string"?{statusCode:500,message:$}:$}}function G$($,U={}){return{handler:$,mode:U.mode??"universal"}}function h($){let U={};if(!$)return U;let O=$.split(";");for(let I of O){let[B,...L]=I.split("=");if(B){let K=B.trim(),V=L.join("=").trim();if(K)U[K]=decodeURIComponent(V)}}return U}function k($,U,O={}){let I=`${encodeURIComponent($)}=${encodeURIComponent(U)}`;if(O.expires){let B=typeof O.expires==="number"?new Date(Date.now()+O.expires*1000):O.expires;I+=`; Expires=${B.toUTCString()}`}if(O.path)I+=`; Path=${O.path}`;if(O.domain)I+=`; Domain=${O.domain}`;if(O.secure)I+="; Secure";if(O.httpOnly)I+="; HttpOnly";if(O.sameSite)I+=`; SameSite=${O.sameSite}`;return I}function c($,U){let O=$.headers.get("cookie")||"",I=h(O);return{get(B){return I[B]},set(B,L,K={}){I[B]=L,U.append("Set-Cookie",k(B,L,K))},delete(B){delete I[B],U.append("Set-Cookie",k(B,"",{expires:new Date(0),path:"/"}))},getAll(){return{...I}}}}function l(){return{get($){if(typeof document>"u")return;return h(document.cookie)[$]},set($,U,O={}){if(typeof document>"u")return;document.cookie=k($,U,O)},delete($){if(typeof document>"u")return;document.cookie=k($,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return h(document.cookie)}}}function u(){let $=typeof window<"u"&&typeof window.localStorage<"u";return{get(U){if(!$)return null;try{return window.localStorage.getItem(U)}catch{return null}},set(U,O){if(!$)return;try{window.localStorage.setItem(U,O)}catch{}},remove(U){if(!$)return;try{window.localStorage.removeItem(U)}catch{}},isAvailable(){return $}}}function v($,U){T.set($,U)}function p($){return T.get($)}function Q$($){return T.has($)}function W$(){T.clear()}function M$(){return Array.from(T.keys())}async function _$($,U="middleware"){let O=X$.resolve($,U);if(!V$.existsSync(O))return;let I=V$.readdirSync(O);for(let B of I){if(!B.endsWith(".ts")&&!B.endsWith(".js"))continue;if(B.includes(".test.")||B.includes(".spec."))continue;let L=B.replace(/\.(ts|js)$/,""),K=X$.join(O,B);try{let J=(await import(K)).default;if(J&&typeof J.handler==="function")v(L,J);else if(typeof J==="function")v(L,{handler:J,mode:"universal"})}catch(V){console.warn(`Failed to load middleware '${L}' from ${K}:`,V)}}}function x$($){let U={};if(!$)return U;let O=new URLSearchParams($);for(let[I,B]of O)U[I]=B;return U}function z$($,U,O,I=""){return{path:$,params:U,query:x$(I),fullPath:I?`${$}?${I}`:$,meta:O}}function F$($,U,O,I){let B=I?.isServer??typeof window>"u",L=!B,K=new Headers;return{to:$,from:U,isClient:L,isServer:B,cookies:B&&O?c(O,K):l(),storage:u(),state:{},request:O,responseHeaders:K}}async function A$($,U){let O=Array.isArray($)?$:[$],I=U.isServer;for(let B of O){let L=p(B);if(!L)return console.error(`Route middleware '${B}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${B}' is not registered`}},state:U.state,responseHeaders:U.responseHeaders};if(L.mode==="server"&&!I)continue;try{let K=await L.handler(U);if(K){if(K.type==="redirect")return{passed:!1,redirect:K,state:U.state,responseHeaders:U.responseHeaders};if(K.type==="abort")return{passed:!1,abort:K,state:U.state,responseHeaders:U.responseHeaders}}}catch(K){return console.error(`Error in middleware '${B}':`,K),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:K instanceof Error?K.message:"Middleware error"}},state:U.state,responseHeaders:U.responseHeaders}}}return{passed:!0,state:U.state,responseHeaders:U.responseHeaders}}var T;var E$=G(()=>{T=new Map});function n($){let O=$.replace(/\\/g,"/").split("/").filter(Boolean),I=O.lastIndexOf("layouts"),B=I>=0?O[I+1]:O.at(-1);if(!B)return"app";return B.replace(/\.stx$/i,"")||"app"}function j$($){let U=$.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),O=$.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),I=$.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),B=U?.[1]||I?.[1]||"";return{layout:B,group:O?.[1]||n(B)}}var T$=()=>{};function k$($){let U=[],O="log(",I=0;while(I<$.length){let B=$.indexOf("log(",I);if(B===-1){U.push($.slice(I));break}let L=B>0?$[B-1]:" ",K=/\bfunction\s+$/.test($.slice(Math.max(0,B-16),B));if(/[\w$.]/.test(L)||K){U.push($.slice(I,B+4)),I=B+4;continue}U.push($.slice(I,B));let V=1,J=B+4;while(J<$.length&&V>0){let X=$[J];if(X==='"'||X==="'"||X==="`"){let Y=X;J++;while(J<$.length&&$[J]!==Y){if($[J]==="\\")J++;J++}J++;continue}if(X==="(")V++;else if(X===")")V--;J++}U.push("0"),I=J}return U.join("")}function C$($){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync($).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return $}}function H$(){return`
5
5
  ;(function(){
6
6
  'use strict';
7
7
  var ROUTER_REV=7;
8
8
  if(window.__stxRouter&&window.__stxRouter.__rev===ROUTER_REV)return;
9
9
 
10
10
  // \u2500\u2500 Configuration \u2500\u2500
11
- var defaults={container:'main',loadingClass:'stx-navigating',viewTransitions:true,cache:true,scrollToTop:true,prefetch:true,progress:true,progressColor:'#78dce8',progressHeight:'2px',interceptAllLinks:false,prefetchCacheMax:50,routeFocus:true,announceRoute:true,interceptForms:false,cssLoadTimeout:1500};
11
+ var defaults={container:'main',loadingClass:'stx-navigating',viewTransitions:true,cache:true,scrollToTop:true,prefetch:true,progress:true,progressColor:'#78dce8',progressHeight:'2px',interceptAllLinks:false,prefetchCacheMax:50,routeFocus:true,announceRoute:true,interceptForms:false,cssLoadTimeout:1500,scrollRestoration:true};
12
12
  var o=Object.assign({},defaults,window.__stxRouterConfig||{},window.STX_ROUTER_OPTIONS||{});
13
13
  var containerSel=o.container;
14
14
  var debug=!!o.debug;
15
15
  function log(){if(debug&&typeof console!=='undefined'&&console.log)console.log.apply(console,arguments)}
16
16
 
17
+ // Shorthands for the document-rooted queries this script makes ~33 times.
18
+ // Every page carries these bytes, and the budget in
19
+ // scripts/performance-budgets.ts is what noticed.
20
+ var LAYOUT_META='meta[name="stx-layout"]';
21
+ var LAYOUT_GROUP_META='meta[name="stx-layout-group"]';
22
+ var BUILD_META='meta[name="stx-build"]';
23
+ function qs(sel){return document.querySelector(sel)}
24
+ function qsa(sel){return document.querySelectorAll(sel)}
25
+ function ce(tag){return document.createElement(tag)}
26
+ function dhead(){return document.head}
27
+
28
+ // \u2500\u2500 Scroll position \u2500\u2500
29
+ // Forward navigation goes to the top, or to the hash. Back and forward return
30
+ // to where the entry was left -- the browser cannot do that for us, because
31
+ // by the time it would restore, the content of the entry has not been fetched
32
+ // yet, so it clamps to whatever height the outgoing page happened to have.
33
+ // history.scrollRestoration therefore goes to manual and the positions are
34
+ // kept here, keyed by a token written into each history entry (two entries
35
+ // for the same URL keep their own positions, which is the point).
36
+ //
37
+ // Manual restoration also takes the browser's reload behaviour away, so the
38
+ // positions are mirrored into sessionStorage: a reload, or a return to the
39
+ // tab, finds the entry's token already in history.state and restores from
40
+ // there. sessionStorage is per tab and dies with it, same as the history.
41
+ var SCROLL_TOKEN='__stxScroll';
42
+ var SCROLL_STORE='stx:scroll:';
43
+ var scrollSeq=0;
44
+ var pendingScroll=null;
45
+ var restoreScroll=!!o.scrollRestoration;
46
+ function newScrollToken(){return 's'+(++scrollSeq)+'-'+Date.now()}
47
+ var scrollToken=(history.state&&history.state[SCROLL_TOKEN])||newScrollToken();
48
+ // sessionStorage is the only store: it is synchronous, it is per tab, it dies
49
+ // with the tab exactly as the history does, and it is the one that survives a
50
+ // reload. A private window that refuses it degrades to scrolling to the top.
51
+ function readScroll(token){
52
+ try{
53
+ var parts=(window.sessionStorage.getItem(SCROLL_STORE+token)||'').split(',');
54
+ return parts.length===2?[parseFloat(parts[0])||0,parseFloat(parts[1])||0]:null;
55
+ }catch(e){return null}
56
+ }
57
+ // Called while the outgoing entry is still the current one, so the position
58
+ // read here belongs to the token being written.
59
+ function rememberScroll(){
60
+ if(!restoreScroll)return;
61
+ try{window.sessionStorage.setItem(SCROLL_STORE+scrollToken,(window.pageXOffset||window.scrollX||0)+','+(window.pageYOffset||window.scrollY||0))}catch(e){}
62
+ }
63
+ // One place decides where a swap leaves the viewport, so the fragment path
64
+ // and the whole-document path cannot drift apart.
65
+ function applyScroll(hash){
66
+ if(pendingScroll){
67
+ var at=pendingScroll;
68
+ pendingScroll=null;
69
+ window.scrollTo({left:at[0],top:at[1],behavior:'instant'});
70
+ return;
71
+ }
72
+ if(o.scrollToTop&&!hash){window.scrollTo({top:0,behavior:'instant'});return}
73
+ if(hash){var el=qs(hash);if(el)el.scrollIntoView({behavior:'smooth'})}
74
+ }
75
+ // Keeps whatever another script put in the entry; only adds the token.
76
+ function stampScrollToken(){
77
+ var state={};
78
+ var current=history.state;
79
+ if(current&&typeof current==='object')for(var key in current)state[key]=current[key];
80
+ state[SCROLL_TOKEN]=scrollToken;
81
+ try{history.replaceState(state,'',location.href)}catch(e){}
82
+ }
83
+ if(restoreScroll){
84
+ try{history.scrollRestoration='manual'}catch(e){}
85
+ // A token already in the entry means this document is a reload or a
86
+ // restore of an entry visited before, so its position is worth asking for.
87
+ var known=history.state&&history.state[SCROLL_TOKEN];
88
+ if(known){
89
+ var saved=readScroll(scrollToken);
90
+ if(saved&&(saved[0]||saved[1])){
91
+ var restoreAt=function(){window.scrollTo({left:saved[0],top:saved[1],behavior:'instant'})};
92
+ if(document.readyState==='complete')restoreAt();
93
+ else window.addEventListener('load',restoreAt,{once:true});
94
+ }
95
+ }
96
+ else{
97
+ stampScrollToken();
98
+ }
99
+ // A reload or a link out of the app never calls writeHistory, so this is
100
+ // the only chance to record where the page was left. pagehide fires for
101
+ // both, and unlike beforeunload it does not keep the page out of the
102
+ // back/forward cache.
103
+ window.addEventListener('pagehide',rememberScroll);
104
+ }
105
+
17
106
  // Replace, never merge: absent payloads must forget the outgoing page's data.
18
107
  // Run at the committed swap, not during prefetch or a superseded navigation.
19
108
  function hydrateServerData(html){
@@ -36,7 +125,7 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
36
125
  // Conservative on purpose: act only when BOTH ids are known. A missing id is
37
126
  // "no information", never "mismatch", so statically hosted output (no headers)
38
127
  // and older servers behave exactly as before.
39
- var buildMeta=document.querySelector('meta[name="stx-build"]');
128
+ var buildMeta=qs(BUILD_META);
40
129
  var loadedBuild=buildMeta?(buildMeta.getAttribute('content')||''):'';
41
130
  window.__stxBuild=loadedBuild;
42
131
  function isBuildSkew(incoming){
@@ -184,7 +273,7 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
184
273
  function parseContainerAttrs(attrStr){
185
274
  var map={};
186
275
  if(!attrStr)return map;
187
- var probe=document.createElement('div');
276
+ var probe=ce('div');
188
277
  probe.innerHTML='<i '+attrStr+'></i>';
189
278
  var src=probe.firstChild;
190
279
  // getAttributeNames first: it is the same standard DOM answer and it is
@@ -273,7 +362,7 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
273
362
  }
274
363
 
275
364
  function getContainer(){
276
- return document.querySelector(containerSel)||document.querySelector('[data-stx-content]')||document.querySelector('main');
365
+ return qs(containerSel)||qs('[data-stx-content]')||qs('main');
277
366
  }
278
367
 
279
368
  // \u2500\u2500 Navigation \u2500\u2500
@@ -357,7 +446,7 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
357
446
  // navigation. Scripts without an owner are unaffected.
358
447
  function ownerStays(owner){
359
448
  if(!owner)return false;
360
- var root=document.querySelector('[data-stx-scope="'+owner+'"]');
449
+ var root=qs('[data-stx-scope="'+owner+'"]');
361
450
  return !root||typeof root.__stx_disposers==='function';
362
451
  }
363
452
  function hashScript(code){
@@ -524,7 +613,7 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
524
613
  if(!key||loadedExternalScripts[key])return null;
525
614
  loadedExternalScripts[key]=1;
526
615
  return new Promise(function(resolve){
527
- var el=document.createElement('script');
616
+ var el=ce('script');
528
617
  el.src=key;
529
618
  // Deliberately NOT data-stx-page: both swap paths clear those on every
530
619
  // navigation, which would sweep this away and \u2014 since it is never loaded
@@ -533,12 +622,12 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
533
622
  el.setAttribute('data-stx-external','');
534
623
  el.onload=function(){resolve()};
535
624
  el.onerror=function(){log('[router] container script failed:',key);resolve()};
536
- document.head.appendChild(el);
625
+ dhead().appendChild(el);
537
626
  });
538
627
  }
539
628
 
540
629
  // Record scripts from the initial page load
541
- document.querySelectorAll('script').forEach(function(s){
630
+ qsa('script').forEach(function(s){
542
631
  var text=s.textContent||'';
543
632
  if(s.hasAttribute('src'))rememberExternalScript(s.getAttribute('src'));
544
633
  else if(text.trim())executedScriptHashes[hashScript(text)]=1;
@@ -565,17 +654,17 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
565
654
  return part?part.replace(/\\.stx$/i,''):'app';
566
655
  }
567
656
  function getCurrentLayoutGroup(){
568
- var meta=document.querySelector('meta[name="stx-layout-group"]');
657
+ var meta=qs(LAYOUT_GROUP_META);
569
658
  if(meta&&meta.getAttribute('content'))return meta.getAttribute('content');
570
- var layout=document.querySelector('meta[name="stx-layout"]');
659
+ var layout=qs(LAYOUT_META);
571
660
  return defaultLayoutGroup(layout?layout.getAttribute('content'):'');
572
661
  }
573
662
  function getDocLayoutGroup(doc,layout){
574
- var meta=doc&&doc.querySelector?doc.querySelector('meta[name="stx-layout-group"]'):null;
663
+ var meta=doc&&doc.querySelector?doc.querySelector(LAYOUT_GROUP_META):null;
575
664
  return meta&&meta.getAttribute('content')?meta.getAttribute('content'):defaultLayoutGroup(layout||'');
576
665
  }
577
666
  function checkLayoutChange(newLayout,targetUrl,newGroup){
578
- var currentLayout=document.querySelector('meta[name="stx-layout"]');
667
+ var currentLayout=qs(LAYOUT_META);
579
668
  var curLayoutName=currentLayout?currentLayout.getAttribute('content'):'';
580
669
  var curGroup=getCurrentLayoutGroup();
581
670
  var nextGroup=newGroup||defaultLayoutGroup(newLayout);
@@ -604,9 +693,14 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
604
693
  // through swap() to each of the three history sites would have been the
605
694
  // alternative (#1807).
606
695
  function writeHistory(mode,href){
607
- if(mode==='replace')history.replaceState({},'',href);
608
- else history.pushState({},'',href);
696
+ // The position belongs to the entry being left, and scrollToken still
697
+ // names it here.
698
+ rememberScroll();
699
+ if(mode==='replace'){history.replaceState(tokenState(),'',href);return}
700
+ scrollToken=newScrollToken();
701
+ history.pushState(tokenState(),'',href);
609
702
  }
703
+ function tokenState(){var state={};state[SCROLL_TOKEN]=scrollToken;return state}
610
704
 
611
705
  // Second arg accepts the legacy pushState boolean OR an options object
612
706
  // { replace }. Callers inside this file still pass the boolean.
@@ -628,7 +722,7 @@ import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/
628
722
 
629
723
  if(t.pathname===location.pathname&&t.hash){
630
724
  if(pushState!==false)writeHistory(pushState,t.href);
631
- var el=document.querySelector(t.hash);
725
+ var el=qs(t.hash);
632
726
  if(el)el.scrollIntoView({behavior:'smooth'});
633
727
  return Promise.resolve(true);
634
728
  }
@@ -773,7 +867,7 @@ else {
773
867
  function routeAnnouncer(){
774
868
  var el=document.getElementById('stx-route-announcer');
775
869
  if(el)return el;
776
- el=document.createElement('div');
870
+ el=ce('div');
777
871
  el.id='stx-route-announcer';
778
872
  el.setAttribute('aria-live','polite');
779
873
  el.setAttribute('role','status');
@@ -806,7 +900,7 @@ else {
806
900
  function focusAfterNavigation(hash){
807
901
  if(o.routeFocus===false)return;
808
902
  var target=null;
809
- if(hash){try{target=document.querySelector(hash)}catch(e){target=null}}
903
+ if(hash){try{target=qs(hash)}catch(e){target=null}}
810
904
  if(!target)target=getContainer();
811
905
  if(!target||!target.focus)return;
812
906
  // The container is not naturally focusable. tabindex="-1" makes it
@@ -829,7 +923,7 @@ else {
829
923
  // be the last one, every navigation, not just the first time it is seen.
830
924
  function findGeneratedCss(abs){
831
925
  var found=null;
832
- document.querySelectorAll('head link[data-css][href]').forEach(function(link){
926
+ qsa('head link[data-css][href]').forEach(function(link){
833
927
  if(new URL(link.getAttribute('href'),location.href).href!==abs)return;
834
928
  // Collapse duplicates, so moving one copy to the end can never leave an
835
929
  // older copy of the same sheet behind to fight it.
@@ -858,7 +952,7 @@ else {
858
952
  if(link.__stxCssReady)pending.push(link.__stxCssReady);
859
953
  return;
860
954
  }
861
- link=document.createElement('link');
955
+ link=ce('link');
862
956
  link.setAttribute('data-css','generated');
863
957
  link.setAttribute('rel','stylesheet');
864
958
  link.setAttribute('href',new URL(href,location.href).href===abs?href:abs);
@@ -879,7 +973,7 @@ else {
879
973
  link.onerror=function(){finish(true)};
880
974
  });
881
975
  pending.push(link.__stxCssReady);
882
- document.head.appendChild(link);
976
+ dhead().appendChild(link);
883
977
  });
884
978
  return pending.length?Promise.all(pending).then(function(results){return results.every(function(ok){return ok!==false})}):null;
885
979
  }
@@ -915,7 +1009,7 @@ else {
915
1009
  link.removeAttribute('data-stx-css-pending');
916
1010
  link.removeAttribute('media');
917
1011
  }
918
- document.head.appendChild(link);
1012
+ dhead().appendChild(link);
919
1013
  });
920
1014
  }
921
1015
 
@@ -1028,18 +1122,18 @@ else {
1028
1122
  });
1029
1123
  cleanFrag=cleanFrag.replace(new RegExp('<!--stx-held-script-(\\\\d+)-->','g'),function(m,i){return heldScripts[Number(i)]});
1030
1124
  // Remove old page styles (not css \u2014 that gets merged)
1031
- document.querySelectorAll('style[data-stx-page]').forEach(function(s){s.remove()});
1125
+ qsa('style[data-stx-page]').forEach(function(s){s.remove()});
1032
1126
  // Merge css CSS from fragment into existing css style
1033
1127
  if(fragCss){
1034
- var curCss=document.querySelector('head style[data-css]');
1128
+ var curCss=qs('head style[data-css]');
1035
1129
  if(curCss){
1036
1130
  var merged=mergeCss(curCss.textContent||'',fragCss);
1037
1131
  if(merged)curCss.textContent=merged;
1038
1132
  }else{
1039
- var cw=document.createElement('style');
1133
+ var cw=ce('style');
1040
1134
  cw.setAttribute('data-css','generated');
1041
1135
  cw.textContent=fragCss;
1042
- document.head.appendChild(cw);
1136
+ dhead().appendChild(cw);
1043
1137
  }
1044
1138
  }
1045
1139
  // Already present ones are MOVED last, not skipped \u2014 see
@@ -1047,10 +1141,10 @@ else {
1047
1141
  promoteGeneratedCss(fragCssHrefs,location.href);
1048
1142
  // Add new page styles
1049
1143
  fragStyles.forEach(function(s){
1050
- var el=document.createElement('style');
1144
+ var el=ce('style');
1051
1145
  el.textContent=s.css;
1052
1146
  el.setAttribute('data-stx-page','');
1053
- document.head.appendChild(el);
1147
+ dhead().appendChild(el);
1054
1148
  });
1055
1149
  // Swap content \u2014 apply the destination container's own attributes first
1056
1150
  // so the incoming markup lands in a correctly-laid-out container instead
@@ -1058,11 +1152,10 @@ else {
1058
1152
  applyContainerAttrs(currentContent,pendingContainerAttrs);
1059
1153
  currentContent.innerHTML=cleanFrag;
1060
1154
  // Remove old page scripts
1061
- document.querySelectorAll('script[data-stx-page]').forEach(function(s){s.remove()});
1155
+ qsa('script[data-stx-page]').forEach(function(s){s.remove()});
1062
1156
  if(pushState!==false)writeHistory(pushState,url+(hash||''));
1063
1157
  refreshCurrentLinks();
1064
- if(o.scrollToTop&&!hash)window.scrollTo({top:0,behavior:'instant'});
1065
- else if(hash){var el=document.querySelector(hash);if(el)el.scrollIntoView({behavior:'smooth'})}
1158
+ applyScroll(hash);
1066
1159
  window.dispatchEvent(new CustomEvent('stx:navigate',{detail:{url:url}}));
1067
1160
  // Before page scripts run, so a page that focuses its own control on
1068
1161
  // mount still wins \u2014 its script executes after this.
@@ -1072,7 +1165,7 @@ else {
1072
1165
  setTimeout(announceRoute,0);
1073
1166
  // Execute page scripts FIRST \u2014 they define setup functions and set _latestSetup
1074
1167
  log('[router] frag scripts:', fragScripts.length);
1075
- document.querySelectorAll('script[data-stx-page]').forEach(function(s){s.remove()});
1168
+ qsa('script[data-stx-page]').forEach(function(s){s.remove()});
1076
1169
  // The page's module registry first (#1957), setups last. A fragment
1077
1170
  // lists its scripts in document order, and the registry is emitted
1078
1171
  // after the content it serves: a component that imports a package ran
@@ -1084,11 +1177,11 @@ else {
1084
1177
  fragScripts.forEach(function(entry){
1085
1178
  var code=entry.text;
1086
1179
  log('[router] exec script len:', code.length, 'has __stx_setup:', code.indexOf('__stx_setup')>-1);
1087
- var placeholder=document.querySelector('script[data-stx-route-script="'+entry.slot+'"]');
1180
+ var placeholder=qs('script[data-stx-route-script="'+entry.slot+'"]');
1088
1181
  var nestedScopedTemplate=false;
1089
1182
  var scopedLoopSetup=false;
1090
1183
  if(entry.scoped&&placeholder){
1091
- document.querySelectorAll('template').forEach(function(template){
1184
+ qsa('template').forEach(function(template){
1092
1185
  if(template.contains(placeholder)||(template.content&&template.content.contains(placeholder)))
1093
1186
  nestedScopedTemplate=true;
1094
1187
  });
@@ -1131,7 +1224,7 @@ else {
1131
1224
  return;
1132
1225
  }
1133
1226
  executedScriptHashes[h]=1;
1134
- var ns=document.createElement('script');
1227
+ var ns=ce('script');
1135
1228
  var hasImport=hasStaticImport(code);
1136
1229
  if(hasImport){
1137
1230
  ns.type='module';
@@ -1194,7 +1287,7 @@ else {
1194
1287
  var doc=parser.parseFromString(html,'text/html');
1195
1288
  // Full documents carry the build id as a meta rather than a header, and
1196
1289
  // this path also serves cached HTML, so check here too (#1772).
1197
- var docBuildMeta=doc.querySelector('meta[name="stx-build"]');
1290
+ var docBuildMeta=doc.querySelector(BUILD_META);
1198
1291
  var docBuild=docBuildMeta?(docBuildMeta.getAttribute('content')||''):'';
1199
1292
  if(isBuildSkew(docBuild)){reloadForSkew(url,docBuild);return Promise.resolve(false)}
1200
1293
  // Same hand-off as the fragment path, for the same reason (#1809, #1839).
@@ -1228,12 +1321,12 @@ else {
1228
1321
  // \u2500\u2500 Swap <head> styles \u2500\u2500
1229
1322
  // Inject new styles FIRST, then remove old to prevent unstyled flash
1230
1323
  var keepIds={'stx-view-transitions':1,'stx-r-css':1};
1231
- var curStyles=document.querySelectorAll('head style');
1324
+ var curStyles=qsa('head style');
1232
1325
  var newStyles=doc.querySelectorAll('head style');
1233
1326
 
1234
1327
  // Merge css styles instead of replacing \u2014 persistent elements
1235
1328
  // (nav, footer) outside <main> still need their utility classes
1236
- var curCss=document.querySelector('head style[data-css]');
1329
+ var curCss=qs('head style[data-css]');
1237
1330
  var newCss=null;
1238
1331
  newStyles.forEach(function(s){if(s.getAttribute('data-css'))newCss=s});
1239
1332
 
@@ -1245,20 +1338,20 @@ else {
1245
1338
  var incoming=[];
1246
1339
  newStyles.forEach(function(s){
1247
1340
  if(!keepIds[s.id]&&!s.getAttribute('data-css')){
1248
- var ns=document.createElement('style');
1341
+ var ns=ce('style');
1249
1342
  ns.textContent=s.textContent;
1250
1343
  ns.setAttribute('data-stx-incoming','');
1251
- document.head.appendChild(ns);
1344
+ dhead().appendChild(ns);
1252
1345
  incoming.push(ns);
1253
1346
  }
1254
1347
  });
1255
1348
 
1256
1349
  // If no existing css but new page has one, add it
1257
1350
  if(!curCss&&newCss){
1258
- var ns=document.createElement('style');
1351
+ var ns=ce('style');
1259
1352
  ns.textContent=newCss.textContent;
1260
1353
  ns.setAttribute('data-css',newCss.getAttribute('data-css'));
1261
- document.head.appendChild(ns);
1354
+ dhead().appendChild(ns);
1262
1355
  }
1263
1356
 
1264
1357
  // Remove old styles (except persistent ones, css, and incoming)
@@ -1285,7 +1378,7 @@ else {
1285
1378
  try{docBase=new URL(url,location.href).href}catch(e){docBase=location.href}
1286
1379
  var linkSel='link[rel="stylesheet"],link[rel="preconnect"]';
1287
1380
  var curLinks={};
1288
- document.querySelectorAll('head '+linkSel).forEach(function(l){var h=l.getAttribute('href');if(h)curLinks[new URL(h,location.href).href]=1});
1381
+ qsa('head '+linkSel).forEach(function(l){var h=l.getAttribute('href');if(h)curLinks[new URL(h,location.href).href]=1});
1289
1382
  doc.querySelectorAll('head '+linkSel).forEach(function(l){
1290
1383
  var href=l.getAttribute('href');
1291
1384
  if(!href)return;
@@ -1295,9 +1388,9 @@ else {
1295
1388
  var abs=new URL(href,docBase).href;
1296
1389
  if(curLinks[abs])return;
1297
1390
  curLinks[abs]=1;
1298
- var nl=document.createElement('link');
1391
+ var nl=ce('link');
1299
1392
  Array.from(l.attributes).forEach(function(a){nl.setAttribute(a.name,a.value)});
1300
- document.head.appendChild(nl);
1393
+ dhead().appendChild(nl);
1301
1394
  });
1302
1395
  // After every other stylesheet link, so the destination's complete
1303
1396
  // utility sheet is last in the cascade.
@@ -1311,8 +1404,8 @@ else {
1311
1404
  var declaredLayout=pendingLayoutDecl;
1312
1405
  pendingLayoutDecl=null;
1313
1406
  if(newBody){
1314
- var newMeta=doc.querySelector('meta[name="stx-layout"]');
1315
- var curMeta=document.querySelector('meta[name="stx-layout"]');
1407
+ var newMeta=doc.querySelector(LAYOUT_META);
1408
+ var curMeta=qs(LAYOUT_META);
1316
1409
  var curLayout=curMeta?curMeta.getAttribute('content'):'';
1317
1410
  // The server's answer wins over the document's metas. We are only here
1318
1411
  // because checkLayoutChange already said the group changed, based on
@@ -1380,16 +1473,16 @@ else {
1380
1473
  // Copy body attributes (class, data-stx, etc.)
1381
1474
  Array.from(newBody.attributes).forEach(function(attr){document.body.setAttribute(attr.name,attr.value)});
1382
1475
  // Update layout meta tag
1383
- var oldMeta=document.querySelector('meta[name="stx-layout"]');
1384
- var freshMeta=doc.querySelector('meta[name="stx-layout"]');
1476
+ var oldMeta=qs(LAYOUT_META);
1477
+ var freshMeta=doc.querySelector(LAYOUT_META);
1385
1478
  if(oldMeta&&freshMeta)oldMeta.setAttribute('content',freshMeta.getAttribute('content')||'');
1386
- else if(freshMeta){var m=document.createElement('meta');m.name='stx-layout';m.content=freshMeta.getAttribute('content')||'';document.head.appendChild(m)}
1387
- var oldGroupMeta=document.querySelector('meta[name="stx-layout-group"]');
1388
- var freshGroupMeta=doc.querySelector('meta[name="stx-layout-group"]');
1479
+ else if(freshMeta){var m=ce('meta');m.name='stx-layout';m.content=freshMeta.getAttribute('content')||'';dhead().appendChild(m)}
1480
+ var oldGroupMeta=qs(LAYOUT_GROUP_META);
1481
+ var freshGroupMeta=doc.querySelector(LAYOUT_GROUP_META);
1389
1482
  if(oldGroupMeta&&freshGroupMeta)oldGroupMeta.setAttribute('content',freshGroupMeta.getAttribute('content')||'');
1390
- else if(freshGroupMeta){var gm=document.createElement('meta');gm.name='stx-layout-group';gm.content=freshGroupMeta.getAttribute('content')||'';document.head.appendChild(gm)}
1483
+ else if(freshGroupMeta){var gm=ce('meta');gm.name='stx-layout-group';gm.content=freshGroupMeta.getAttribute('content')||'';dhead().appendChild(gm)}
1391
1484
  // Update container reference for script execution below
1392
- currentContent=document.querySelector(containerSel)||document.querySelector('main')||document.body;
1485
+ currentContent=qs(containerSel)||qs('main')||document.body;
1393
1486
  } else {
1394
1487
  // Same layout \u2014 swap only container content. Carry the destination
1395
1488
  // container's attributes across too (same reason as the fragment path:
@@ -1408,7 +1501,7 @@ else {
1408
1501
 
1409
1502
  // \u2500\u2500 Load new external <head> scripts \u2500\u2500
1410
1503
  var loadedSrcs={};
1411
- document.querySelectorAll('head script[src]').forEach(function(s){loadedSrcs[s.src]=1});
1504
+ qsa('head script[src]').forEach(function(s){loadedSrcs[s.src]=1});
1412
1505
  var extPromises=[];
1413
1506
  doc.querySelectorAll('head script[src]').forEach(function(s){
1414
1507
  if(isSharedClientScript(s))return;
@@ -1418,11 +1511,11 @@ else {
1418
1511
  if(loadedSrcs[src])return;
1419
1512
  loadedSrcs[src]=1;
1420
1513
  extPromises.push(new Promise(function(resolve,reject){
1421
- var ns=document.createElement('script');
1514
+ var ns=ce('script');
1422
1515
  ns.src=src;
1423
1516
  ns.onload=resolve;
1424
1517
  ns.onerror=reject;
1425
- document.head.appendChild(ns);
1518
+ dhead().appendChild(ns);
1426
1519
  }));
1427
1520
  });
1428
1521
 
@@ -1436,7 +1529,7 @@ else {
1436
1529
 
1437
1530
  // \u2500\u2500 Script re-execution \u2500\u2500
1438
1531
  // Remove previously injected page scripts
1439
- document.querySelectorAll('script[data-stx-page]').forEach(function(s){s.remove()});
1532
+ qsa('script[data-stx-page]').forEach(function(s){s.remove()});
1440
1533
 
1441
1534
  var scripts=routedBodyScripts.slice();
1442
1535
  function addScript(text, runAlways, slot, owner){
@@ -1520,8 +1613,7 @@ else {
1520
1613
  refreshCurrentLinks();
1521
1614
 
1522
1615
  // Scroll
1523
- if(o.scrollToTop&&!hash)window.scrollTo({top:0,behavior:'instant'});
1524
- else if(hash){var el=document.querySelector(hash);if(el)el.scrollIntoView({behavior:'smooth'})}
1616
+ applyScroll(hash);
1525
1617
 
1526
1618
  // Update title
1527
1619
  var newTitle=doc.querySelector('title');
@@ -1582,7 +1674,7 @@ else {
1582
1674
  if(!runAlways&&!isSetup&&executedScriptHashes[h])return;
1583
1675
  executedScriptHashes[h]=1;
1584
1676
  // Wrap scripts with import statements as modules (Bug 3 fix)
1585
- var ns=document.createElement('script');
1677
+ var ns=ce('script');
1586
1678
  if(hasImport){
1587
1679
  ns.type='module';
1588
1680
  }
@@ -1595,7 +1687,7 @@ else {
1595
1687
  var alreadyScoped=runsAlways(typeof entry==='string'?'':entry.run,text);
1596
1688
  ns.textContent=(hasImport||alreadyScoped)?text:'{'+text+'}';
1597
1689
  ns.setAttribute('data-stx-page','');
1598
- var placeholder=entry.slot?document.querySelector('script[data-stx-route-script="'+entry.slot+'"]'):null;
1690
+ var placeholder=entry.slot?qs('script[data-stx-route-script="'+entry.slot+'"]'):null;
1599
1691
  if(placeholder&&placeholder.parentNode){
1600
1692
  ns.setAttribute('data-stx-positioned','');
1601
1693
  placeholder.parentNode.replaceChild(ns,placeholder);
@@ -1887,6 +1979,16 @@ else {
1887
1979
 
1888
1980
  // \u2500\u2500 Back/forward \u2500\u2500
1889
1981
  window.addEventListener('popstate',function(){
1982
+ // Nothing has scrolled yet (restoration is manual), so the viewport still
1983
+ // shows the entry being left: save it under its own token before adopting
1984
+ // the popped entry's, and hand the swap the position to land on.
1985
+ rememberScroll();
1986
+ if(restoreScroll){
1987
+ var popped=history.state&&history.state[SCROLL_TOKEN];
1988
+ scrollToken=popped||newScrollToken();
1989
+ if(!popped)stampScrollToken();
1990
+ pendingScroll=readScroll(scrollToken);
1991
+ }
1890
1992
  navigate(location.pathname+location.search+location.hash,false);
1891
1993
  });
1892
1994
 
@@ -1953,7 +2055,7 @@ else {
1953
2055
  }
1954
2056
 
1955
2057
  function updateNav(){
1956
- document.querySelectorAll('nav a[href], #mobileNav a[href], [data-stx-nav] a[href]').forEach(function(a){
2058
+ qsa('nav a[href], #mobileNav a[href], [data-stx-nav] a[href]').forEach(function(a){
1957
2059
  if(!a.hasAttribute('data-stx-link'))return;
1958
2060
  var st=linkState(a.getAttribute('href'),a.getAttribute('data-stx-active-match'));
1959
2061
  if(!st)return;
@@ -1974,7 +2076,7 @@ else {
1974
2076
 
1975
2077
  function updateActiveLinks(){
1976
2078
  // Update active classes on <stx-link> elements (and legacy data-stx-link)
1977
- var links=document.querySelectorAll('[data-stx-link]');
2079
+ var links=qsa('[data-stx-link]');
1978
2080
  links.forEach(function(link){
1979
2081
  var st=linkState(link.getAttribute('to')||link.getAttribute('href')||'',link.getAttribute('data-stx-active-match'));
1980
2082
  if(!st)return;
@@ -2016,7 +2118,7 @@ else {
2016
2118
  // the cascade, or opt out entirely with viewTransitions:false.
2017
2119
  function injectStyles(){
2018
2120
  if(!document.getElementById('stx-r-css')){
2019
- var s=document.createElement('style');s.id='stx-r-css';
2121
+ var s=ce('style');s.id='stx-r-css';
2020
2122
  // Strip characters that could escape our CSS block and inject new
2021
2123
  // declarations: ; { } ( ) " ' \\ < > plus whitespace control chars.
2022
2124
  // This keeps the value safe to concat into a stylesheet even if a
@@ -2038,10 +2140,10 @@ else {
2038
2140
  css+='@media (prefers-reduced-motion: reduce){::view-transition-old(root),::view-transition-new(root){animation-duration:0s;animation-name:none}}';
2039
2141
  }
2040
2142
  s.textContent=css;
2041
- document.head.appendChild(s);
2143
+ dhead().appendChild(s);
2042
2144
  }
2043
2145
  if(o.progress&&!document.getElementById('stx-router-progress')){
2044
- var el=document.createElement('div');
2146
+ var el=ce('div');
2045
2147
  el.id='stx-router-progress';
2046
2148
  el.setAttribute('role','progressbar');
2047
2149
  el.setAttribute('aria-hidden','true');
@@ -2058,7 +2160,7 @@ else {
2058
2160
 
2059
2161
  function injectViewTransitionCSS(){
2060
2162
  if(document.getElementById('stx-view-transitions'))return;
2061
- var s=document.createElement('style');s.id='stx-view-transitions';
2163
+ var s=ce('style');s.id='stx-view-transitions';
2062
2164
  s.textContent='::view-transition-group(root){animation:none}::view-transition-old(root){animation:none}::view-transition-new(root){animation:none}main,#app-content,[data-stx-content]{view-transition-name:stx-content}::view-transition-old(stx-content){animation:stx-fade-out .15s ease-out both}::view-transition-new(stx-content){animation:stx-fade-in .15s ease-in .1s both}@keyframes stx-fade-out{from{opacity:1}to{opacity:0}}@keyframes stx-fade-in{from{opacity:0}to{opacity:1}}::view-transition{background:transparent}::view-transition-group(stx-content){background:inherit;overflow:hidden}';
2063
2165
  (document.head||document.documentElement).appendChild(s);
2064
2166
  }
@@ -2115,5 +2217,5 @@ else {
2115
2217
 
2116
2218
  if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
2117
2219
  })();
2118
- `),F}var F;var ke=()=>{};var Le={};Re(Le,{setAppUrl:()=>te,runMiddleware:()=>ve,route:()=>ne,resolveLayoutChain:()=>E,resetRoutes:()=>se,registerMiddleware:()=>M,patternToRegex:()=>x,navigateTo:()=>ce,matchRoute:()=>$,loadMiddlewareFromDirectory:()=>ge,isNonPageRoutePattern:()=>w,isNonPageRoutePath:()=>N,hasMiddleware:()=>de,getRouterScript:()=>Se,getMiddlewareNames:()=>fe,getMiddleware:()=>V,generateRouteTypes:()=>A,generateRouteManifest:()=>C,formatRoutes:()=>Q,findErrorPage:()=>Z,filePathToPattern:()=>T,extractLayoutMetadata:()=>be,deriveLayoutGroup:()=>D,defineRoutes:()=>ae,defineRoute:()=>re,defineMiddleware:()=>he,createStorageManager:()=>H,createServerCookieManager:()=>j,createRouter:()=>J,createRouteLocation:()=>me,createMiddlewareContext:()=>ye,createClientCookieManager:()=>q,clearMiddleware:()=>pe,bracketPathToRegex:()=>z,abortNavigation:()=>ue,Router:()=>L,NON_PAGE_DIRS:()=>v});var _e=d(()=>{ee();B();oe();we();U();xe();P();k();ke()});
2119
- export{v as wv,N as xv,w as yv,A as zv,C as Av,T as Bv,x as Cv,$ as Dv,z as Ev,E as Fv,L as Gv,J as Hv,Z as Iv,Q as Jv,te as Kv,re as Lv,ae as Mv,ne as Nv,se as Ov,ce as Pv,ue as Qv,he as Rv,j as Sv,q as Tv,H as Uv,M as Vv,V as Wv,de as Xv,pe as Yv,fe as Zv,ge as _v,me as $v,ye as aw,ve as bw,D as cw,be as dw,xe as ew,Se as fw,Le as gw,_e as hw};
2220
+ `}function q$(){if(w)return w;return w=C$(k$(H$())),w}function N$(){if(P)return P;return P=C$(H$()),P}var w,P;var R$=()=>{};var w$={};v$(w$,{setAppUrl:()=>I$,runMiddleware:()=>A$,route:()=>J$,resolveLayoutChain:()=>R,resetRoutes:()=>K$,registerMiddleware:()=>v,patternToRegex:()=>j,navigateTo:()=>Y$,matchRoute:()=>o,loadMiddlewareFromDirectory:()=>_$,isNonPageRoutePattern:()=>A,isNonPageRoutePath:()=>y,hasMiddleware:()=>Q$,getRouterScriptDev:()=>N$,getRouterScript:()=>q$,getMiddlewareNames:()=>M$,getMiddleware:()=>p,generateRouteTypes:()=>H,generateRouteManifest:()=>q,formatRoutes:()=>$$,findErrorPage:()=>e,filePathToPattern:()=>N,extractLayoutMetadata:()=>j$,deriveLayoutGroup:()=>n,defineRoutes:()=>B$,defineRoute:()=>O$,defineMiddleware:()=>G$,createStorageManager:()=>u,createServerCookieManager:()=>c,createRouter:()=>a,createRouteLocation:()=>z$,createMiddlewareContext:()=>F$,createClientCookieManager:()=>l,clearMiddleware:()=>W$,bracketPathToRegex:()=>r,abortNavigation:()=>Z$,Router:()=>b,NON_PAGE_DIRS:()=>F});var P$=G(()=>{U$();g();L$();E$();m();T$();f();C();R$()});
2221
+ export{F as xv,y as yv,A as zv,H as Av,q as Bv,N as Cv,j as Dv,o as Ev,r as Fv,R as Gv,b as Hv,a as Iv,e as Jv,$$ as Kv,I$ as Lv,O$ as Mv,B$ as Nv,J$ as Ov,K$ as Pv,Y$ as Qv,Z$ as Rv,G$ as Sv,c as Tv,l as Uv,u as Vv,v as Wv,p as Xv,Q$ as Yv,W$ as Zv,M$ as _v,_$ as $v,z$ as aw,F$ as bw,A$ as cw,n as dw,j$ as ew,T$ as fw,q$ as gw,N$ as hw,w$ as iw,P$ as jw};