rari 0.16.0 → 0.17.0

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 (63) hide show
  1. package/dist/api-routes-Dc2tv31o.mjs +1 -0
  2. package/dist/cli.d.mts +1 -1
  3. package/dist/cli.mjs +39 -39
  4. package/dist/constants-CRK2JRKf.mjs +1 -0
  5. package/dist/{define-CRafeveU.mjs → define-B_ozIapW.mjs} +1 -1
  6. package/dist/dist-paths-C4EV064W.mjs +1 -0
  7. package/dist/{execute-B1z6YRUF.mjs → execute-CbhDMAQ3.mjs} +1 -1
  8. package/dist/feed-NrJzjZyg.mjs +10 -0
  9. package/dist/form-state-DAygOjc8.mjs +1 -0
  10. package/dist/get-client-component-s7qprTUa.mjs +1 -0
  11. package/dist/headers.d.mts +1 -1
  12. package/dist/image/static.d.mts +1 -0
  13. package/dist/image/static.mjs +1 -0
  14. package/dist/image.d.mts +4 -35
  15. package/dist/image.mjs +1 -1
  16. package/dist/index.d.mts +6 -1
  17. package/dist/index.mjs +1 -1
  18. package/dist/mdx/define.mjs +1 -1
  19. package/dist/mdx.mjs +1 -1
  20. package/dist/navigation-transition-store-CSKrbtbK.mjs +1 -0
  21. package/dist/path-CTEC1xmy.mjs +1 -0
  22. package/dist/preload-modules-Dv_GzGCm.mjs +2 -0
  23. package/dist/proxy/RariResponse.mjs +1 -1
  24. package/dist/proxy/runtime-executor.mjs +1 -1
  25. package/dist/regex-constants-DzXwNGh2.mjs +1 -0
  26. package/dist/{robots-B1bFAd4J.mjs → robots-BOPIkPcN.mjs} +1 -1
  27. package/dist/router-Cl4J7j1A.mjs +1 -0
  28. package/dist/router.d.mts +8 -5
  29. package/dist/router.mjs +1 -1
  30. package/dist/{rsc-vite-build-Cpu5suGN.mjs → rsc-vite-build-CSnu8C3P.mjs} +1 -1
  31. package/dist/runtime/AppRouterProvider.mjs +1 -1
  32. package/dist/runtime/ClientRouter.mjs +4 -4
  33. package/dist/runtime/call-server.mjs +1 -1
  34. package/dist/runtime/entry-client.d.mts +1 -1
  35. package/dist/runtime/entry-client.mjs +3 -3
  36. package/dist/runtime/flight-router-state.d.mts +1 -0
  37. package/dist/runtime/flight-router-state.mjs +1 -1
  38. package/dist/runtime/merge-flight-refresh.d.mts +4 -0
  39. package/dist/runtime/merge-flight-refresh.mjs +1 -1
  40. package/dist/runtime/rsc-client-runtime.d.mts +1 -1
  41. package/dist/runtime/rsc-client-runtime.mjs +1 -1
  42. package/dist/serialize-router-state-uOGGpmBr.mjs +1 -0
  43. package/dist/sitemap--bdIkWl5.mjs +13 -0
  44. package/dist/static-modules-DBL6iFbg.d.mts +61 -0
  45. package/dist/{types-Q-x_0kVB.d.mts → types-C8N3Hc8I.d.mts} +1 -0
  46. package/dist/{types-xTbuE-Js.d.mts → types-DfSnnFaF.d.mts} +3 -1
  47. package/dist/vite.d.mts +3 -1
  48. package/dist/vite.mjs +141 -197
  49. package/dist/{xml-EW5iM39h.mjs → xml-DPsk9WTz.mjs} +1 -1
  50. package/package.json +20 -17
  51. package/dist/api-routes-ChRr3O5-.mjs +0 -1
  52. package/dist/constants-BFdy-wPN.mjs +0 -1
  53. package/dist/feed-uUGeOZmR.mjs +0 -10
  54. package/dist/form-state-DZJs9bve.mjs +0 -1
  55. package/dist/get-client-component-DU5z65us.mjs +0 -1
  56. package/dist/path-C74rvUep.mjs +0 -1
  57. package/dist/preload-modules-1i2BJqux.mjs +0 -2
  58. package/dist/prompt-uaCPq0_A-BW0EkzOD.mjs +0 -45
  59. package/dist/regex-constants-DBMCJbMw.mjs +0 -1
  60. package/dist/router-D6X8JHst.mjs +0 -1
  61. package/dist/runtime/LoadingErrorBoundary.d.mts +0 -10
  62. package/dist/runtime/LoadingErrorBoundary.mjs +0 -1
  63. package/dist/sitemap-DJY3OiJ0.mjs +0 -13
package/dist/vite.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{t as e}from"./api-routes-ChRr3O5-.mjs";import{T as t,a as n,b as r,c as i,d as a,n as o,r as s,t as c,v as l,w as u,x as d,y as f}from"./type-guards-BJXKlA6x.mjs";import{a as p,n as m,r as h,t as g}from"./constants-BFdy-wPN.mjs";import{a as _,d as ee,g as te,h as v,i as ne,l as re,m as ie,n as ae,o as oe,p as se,r as ce,s as le}from"./regex-constants-DBMCJbMw.mjs";import{a as ue,i as de,n as fe,o as y,t as pe}from"./path-C74rvUep.mjs";import{a as me,c as he,i as ge,l as _e,n as ve,o as ye,r as be,s as xe,u as Se}from"./rsc-vite-build-Cpu5suGN.mjs";import{t as Ce}from"./timer-Duul5JHq.mjs";import{t as we}from"./names-CLmM0CPi.mjs";import{builtinModules as Te,createRequire as Ee}from"node:module";import{Buffer as De}from"node:buffer";import{spawn as Oe,spawnSync as ke}from"node:child_process";import b,{promises as x}from"node:fs";import S,{sep as Ae}from"node:path";import C from"node:process";import{text as je}from"node:stream/consumers";import{fileURLToPath as w,pathToFileURL as Me}from"node:url";import{createHash as Ne}from"node:crypto";import{fromBuffer as Pe}from"@capsizecss/unpack";import Fe from"@capsizecss/metrics/arial";import Ie from"@capsizecss/metrics/timesNewRoman";import Le from"node:fs/promises";import{formatWithOptions as Re,styleText as ze}from"node:util";import*as Be from"node:tty";function Ve(e){return e.map(e=>e)}function He(e){return e}const Ue=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mts`,`.mjs`];async function We(e=C.cwd(),t=`src`,n={}){let r=n.proxyFileName??`proxy`,i=n.extensions??Ue;for(let t of i){let n=S.join(e,`${r}${t}`);try{return await x.access(n),n}catch{}}for(let n of i){let i=S.join(e,t,`${r}${n}`);try{return await x.access(i),i}catch{}}return null}function Ge(e={}){let{root:t=C.cwd(),srcDir:n=`src`,proxyFileName:r=`proxy`,extensions:i=Ue,verbose:a=!1}=e,o=null,s=e=>{a&&console.warn(`[rari] Proxy: ${e}`)};async function c(){let e=await We(t,n,{proxyFileName:r,extensions:i});if(e==null)return null;let a=S.relative(t,e);return s(`Found proxy file: ${a}`),{filePath:e,exists:!0,relativePath:a}}return He({name:`rari:proxy`,async buildStart(){o=await c(),s(o?`Proxy enabled: ${o.relativePath}`:`No proxy file found`)},configureServer(e){o&&(e.watcher.add(o.filePath),e.watcher.on(`change`,t=>{t===o?.filePath&&(s(`Proxy file changed, reloading...`),e.ws.send({type:`custom`,event:`rari:proxy-reload`}))}))},handleHotUpdate({file:e,server:t}){if(e===o?.filePath)return s(`Hot reloading proxy...`),t.ws.send({type:`custom`,event:`rari:proxy-reload`,data:{file:o.relativePath}}),[]}})}function Ke(e){if(e==null||e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}function qe(){let{SERVER_PORT:e,PORT:t,RSC_PORT:n}=C.env;return Ke(e)??Ke(t)??Ke(n)??3e3}function Je(){return`http://localhost:${qe()}`}const Ye=6e4;async function Xe(e){let t=Me(e).href,n=`
1
+ import{r as e,t}from"./api-routes-Dc2tv31o.mjs";import{T as n,a as r,b as i,c as a,d as o,n as s,r as c,t as l,v as u,w as d,x as f,y as p}from"./type-guards-BJXKlA6x.mjs";import{a as m,i as h,r as g,s as _}from"./constants-CRK2JRKf.mjs";import{a as v,d as y,f as ee,i as te,m as ne,n as b,o as x,p as S,r as re,s as ie,u as ae}from"./regex-constants-DzXwNGh2.mjs";import{a as C,i as oe,n as w,o as T,t as se}from"./path-CTEC1xmy.mjs";import{a as ce,c as le,i as ue,l as de,n as fe,o as pe,r as me,s as E,u as he}from"./rsc-vite-build-CSnu8C3P.mjs";import{t as ge}from"./timer-Duul5JHq.mjs";import{t as _e}from"./names-CLmM0CPi.mjs";import{a as ve,i as ye,n as be,r as xe}from"./dist-paths-C4EV064W.mjs";import{builtinModules as Se,createRequire as Ce}from"node:module";import{Buffer as we}from"node:buffer";import{spawn as Te,spawnSync as Ee}from"node:child_process";import D,{promises as O}from"node:fs";import k from"node:path";import A from"node:process";import{text as De}from"node:stream/consumers";import{fileURLToPath as j,pathToFileURL as Oe}from"node:url";import{createHash as ke}from"node:crypto";import{isFileLoadingAllowed as Ae}from"vite-plus";import{fromBuffer as je}from"@capsizecss/unpack";import M from"@capsizecss/metrics/arial";import Me from"@capsizecss/metrics/timesNewRoman";import{reactRefreshWrapperPlugin as Ne}from"vite-plus/internal";function Pe(e){return e.map(e=>e)}function Fe(e){return e}const Ie=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mts`,`.mjs`];async function Le(e=A.cwd(),t=`src`,n={}){let r=n.proxyFileName??`proxy`,i=n.extensions??Ie;for(let t of i){let n=k.join(e,`${r}${t}`);try{return await O.access(n),n}catch{}}for(let n of i){let i=k.join(e,t,`${r}${n}`);try{return await O.access(i),i}catch{}}return null}function Re(e={}){let{root:t=A.cwd(),srcDir:n=`src`,proxyFileName:r=`proxy`,extensions:i=Ie,verbose:a=!1}=e,o=null,s=e=>{a&&console.warn(`[rari] Proxy: ${e}`)};async function c(){let e=await Le(t,n,{proxyFileName:r,extensions:i});if(e==null)return null;let a=k.relative(t,e);return s(`Found proxy file: ${a}`),{filePath:e,exists:!0,relativePath:a}}return Fe({name:`rari:proxy`,async buildStart(){o=await c(),s(o?`Proxy enabled: ${o.relativePath}`:`No proxy file found`)},configureServer(e){o&&(e.watcher.add(o.filePath),e.watcher.on(`change`,t=>{t===o?.filePath&&(s(`Proxy file changed, reloading...`),e.ws.send({type:`custom`,event:`rari:proxy-reload`}))}))},handleHotUpdate({file:e,server:t}){if(e===o?.filePath)return s(`Hot reloading proxy...`),t.ws.send({type:`custom`,event:`rari:proxy-reload`,data:{file:o.relativePath}}),[]}})}function ze(e){if(e==null||e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}function N(){let{SERVER_PORT:e,PORT:t,RSC_PORT:n}=A.env;return ze(e)??ze(t)??ze(n)??3e3}function Be(){return`http://localhost:${N()}`}const Ve=6e4;async function He(e){let t=Oe(e).href,n=`
2
2
  import { registerHooks } from "node:module";
3
3
  registerHooks({
4
4
  resolve(specifier, context, nextResolve) {
@@ -16,24 +16,17 @@ const result =
16
16
  process.send(result, () => {
17
17
  process.disconnect();
18
18
  });
19
- `;return new Promise((t,r)=>{let i=Oe(C.execPath,[`--conditions=react-server`,`--input-type=module`,`--eval`,n],{stdio:[`ignore`,`pipe`,`pipe`,`ipc`],env:C.env}),a=``,o=``,s=!1,c=!1,l,u,d,f=()=>{u!==void 0&&clearTimeout(u),d!==void 0&&clearTimeout(d),u=void 0,d=void 0};u=setTimeout(()=>{s||(s=!0,u!==void 0&&clearTimeout(u),u=void 0,i.kill(`SIGTERM`),d=setTimeout(()=>{i.kill(`SIGKILL`)},1e3),r(/* @__PURE__ */ Error(`generateStaticParams timed out after ${Ye}ms for ${e}`)))},Ye),i.stdout?.setEncoding(`utf8`),i.stderr?.setEncoding(`utf8`),i.stdout?.on(`data`,e=>{a+=e}),i.stderr?.on(`data`,e=>{o+=e}),i.on(`message`,e=>{c=!0,l=e}),i.on(`error`,e=>{s||(s=!0,f(),r(e))}),i.on(`close`,n=>{if(f(),s)return;s=!0;let i=[o.trim(),a.trim()].filter(Boolean).join(`
20
- `);if(n!==0){r(Error(i||`generateStaticParams worker exited with code ${n}`));return}if(!c){r(Error(i||`generateStaticParams worker exited without an IPC result for ${e}`));return}t(l)})})}const Ze=/\\\*/g;function Qe(e,t={}){let{escapeAsterisk:n=!0}=t,r=RegExp.escape(e);return n?r:r.replace(Ze,`*`)}const $e=[`.ico`],et=[`.ico`,`.jpg`,`.jpeg`,`.png`,`.svg`],tt=[`.jpg`,`.jpeg`,`.png`],nt={".ico":`image/x-icon`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".svg":`image/svg+xml`};function rt(e){return nt[e.toLowerCase()]??`application/octet-stream`}function it(e,t,n){let r=n.map(e=>Qe(e.replace(/^\./,``))).join(`|`),i=RegExp(`^${Qe(t)}(\\d*)\\.(${r})$`,`i`);return e.filter(e=>i.test(e)).sort((e,t)=>e.localeCompare(t))}function at(e,t){let n=y(e).replace(/^\/+|\/+$/g,``);return n===``?`/${t}`:`/${n}/${t}`.replace(/\/+/g,`/`)}function ot(e){if(e.length<24||e[0]!==137||e[1]!==80||e[2]!==78||e[3]!==71)return;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:t.getUint32(16),height:t.getUint32(20)}}async function st(e){let t=S.extname(e).toLowerCase();if(t===`.svg`||t===`.ico`)return{sizes:`any`};try{let n=await x.readFile(e);if(t===`.png`){let e=ot(n);if(e)return{...e,sizes:`${e.width}x${e.height}`}}}catch{}return{sizes:`any`}}function ct(e){let t=y(S.join(e.relativeDir,e.fileName)),n=S.extname(e.fileName).toLowerCase();return{path:e.routePath,filePath:t,kind:e.kind,url:at(e.relativeDir,e.fileName),contentType:rt(n),width:e.width,height:e.height,sizes:e.sizes}}async function lt(e){let{appDir:t,relativeDir:n,routePath:r,files:i}=e,a=[],o=async(e,o,s,c)=>{if(c&&r!==`/`)return;let l=it(i,o,s);for(let i of l){let o=await st(S.join(t,n,i));a.push(ct({routePath:r,relativeDir:n,fileName:i,kind:e,width:o.width,height:o.height,sizes:o.sizes}))}};return await o(`favicon`,`favicon`,$e,!0),await o(`icon`,`icon`,et,!1),await o(`apple-icon`,`apple-icon`,tt,!1),a}async function ut(e){let{appDir:t,outDir:n,icons:r}=e,i=0;for(let e of r){let r=S.join(t,e.filePath),a=S.join(n,e.url.replace(/^\//,``));await x.mkdir(S.dirname(a),{recursive:!0}),await x.copyFile(r,a),i+=1}return i}function dt(e){return l(e)?typeof e.path==`string`&&typeof e.filePath==`string`&&(e.kind===`favicon`||e.kind===`icon`||e.kind===`apple-icon`)&&typeof e.url==`string`&&typeof e.contentType==`string`&&(e.sizes===void 0||typeof e.sizes==`string`)&&(e.width===void 0||typeof e.width==`number`)&&(e.height===void 0||typeof e.height==`number`):!1}function ft(e){let t;try{t=JSON.parse(e)}catch{return[]}return!l(t)||!Array.isArray(t.appIcons)?[]:t.appIcons.filter(dt)}const pt={PAGE:`page`,LAYOUT:`layout`,LOADING:`loading`,ERROR:`error`,NOT_FOUND:`not-found`,TEMPLATE:`template`,DEFAULT:`default`,ROUTE:`route`,OG_IMAGE:`opengraph-image`,TWITTER_IMAGE:`twitter-image`,ICON:`icon`,APPLE_ICON:`apple-icon`},mt={DYNAMIC:/^\[([^\]]+)\]$/,CATCH_ALL:/^\[\.\.\.([^\]]+)\]$/,OPTIONAL_CATCH_ALL:/^\[\[\.\.\.([^\]]+)\]\]$/},ht=[{pattern:mt.OPTIONAL_CATCH_ALL,type:`optional-catch-all`,format:e=>`[[...${e}]]`},{pattern:mt.CATCH_ALL,type:`catch-all`,format:e=>`[...${e}]`},{pattern:mt.DYNAMIC,type:`dynamic`,format:e=>`[${e}]`}],gt=/^\([^/]+\)$/;function _t(e){return gt.test(e)}function vt(e){return e?y(e).split(`/`).filter(Boolean).some(_t):!1}function yt(e){for(let t of ht){let n=e.match(t.pattern);if(n)return{type:t.type,param:n[1],format:t.format}}}function bt(e){let t=yt(e);return t?t.format(t.param):e}function xt(e){let t=yt(e);return t?{type:t.type,value:e,param:t.param}:{type:`static`,value:e}}const St=/export\s+const\s+size\s*=\s*\{\s*width\s*:\s*(\d+)\s*,\s*height\s*:\s*(\d+)\s*[,}]/,Ct=/export\s+const\s+contentType\s*=\s*['"]([^'"]+)['"]/,wt=[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`];var Tt=class{appDir;extensions;verbose;constructor(e){this.appDir=S.resolve(e.appDir),this.extensions=[...e.extensions??[`.tsx`,`.jsx`,`.ts`,`.js`]],this.verbose=e.verbose??!1}async generateManifest(){this.verbose&&console.warn(`[rari] Router: Scanning app directory: ${this.appDir}`);let e=[],t=[],n=[],r=[],i=[],a=[],o=[],s=[],c=[];await this.scanDirectory(``,e,t,n,r,i,a,o,s,c);for(let o of[t,n,r,i,a,s])this.finalizeGroupEntries(e,o);return this.assertNoDuplicateRoutes(e),this.assertNoDuplicateRoutes(o),this.verbose&&(console.warn(`[rari] Router: Found ${e.length} routes`),console.warn(`[rari] Router: Found ${t.length} layouts`),console.warn(`[rari] Router: Found ${n.length} loading components`),console.warn(`[rari] Router: Found ${r.length} error boundaries`),console.warn(`[rari] Router: Found ${a.length} templates`),console.warn(`[rari] Router: Found ${o.length} API routes`),console.warn(`[rari] Router: Found ${s.length} OG images`),console.warn(`[rari] Router: Found ${c.length} app icons`)),{routes:this.sortRoutes(e),layouts:this.sortLayouts(t),loading:n,errors:r,notFound:i,templates:this.sortTemplates(a),apiRoutes:this.sortApiRoutes(o),ogImages:s,appIcons:c,generated:(/* @__PURE__ */ new Date()).toISOString()}}finalizeGroupEntries(e,t){for(let n=t.length-1;n>=0;n--){let r=t[n],i=y(S.dirname(r.filePath));if(!vt(i))continue;let a=e.filter(e=>{let t=y(S.dirname(e.filePath));return t===i||t.startsWith(`${i}/`)}).map(e=>e.path);if(a.length===0){t.splice(n,1);continue}let o=Array.from(new Set(a)).sort();r.path=o[0],o.length>1&&(r.additionalPaths=o.slice(1))}}assertNoDuplicateRoutes(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.path);if(e!=null&&e!==``)throw Error(`[rari] Route conflict: path '${n.path}' is defined by both '${e}' and '${n.filePath}'.`);t.set(n.path,n.filePath)}}async scanDirectory(e,t,n,r,i,a,o,s,c,l){let u=S.join(this.appDir,e),d;try{d=await x.readdir(u)}catch{return}let f=[],p=[];for(let e of d){let t=S.join(u,e),n=await x.stat(t);n.isDirectory()?this.shouldScanDirectory(e)&&p.push(e):n.isFile()&&f.push(e)}await this.processSpecialFiles(e,f,t,n,r,i,a,o,s,c,l);for(let u of p){let d=e?S.join(e,u):u;await this.scanDirectory(d,t,n,r,i,a,o,s,c,l)}}async processSpecialFiles(e,t,n,r,i,a,o,s,c,l,u){let d=this.pathToRoute(e),f=this.findFile(t,pt.PAGE);if(f!=null&&f!==``){let t=this.parseRouteSegments(e),r=this.extractParams(t);n.push({path:d,filePath:y(S.join(e,f)),segments:t,params:r,isDynamic:r.length>0})}let p=this.findFile(t,pt.LAYOUT);if(p!=null&&p!==``){let t=this.getParentPath(e);r.push({path:d,filePath:y(S.join(e,p)),parentPath:t===null?void 0:this.pathToRoute(t)})}let m=this.findFile(t,pt.LOADING);m!=null&&m!==``&&i.push({path:d,filePath:y(S.join(e,m))});let h=this.findFile(t,pt.ERROR);h!=null&&h!==``&&a.push({path:d,filePath:y(S.join(e,h))});let g=this.findFile(t,pt.NOT_FOUND);g!=null&&g!==``&&o.push({path:d,filePath:y(S.join(e,g))});let _=this.findFile(t,pt.TEMPLATE);if(_!=null&&_!==``){let t=this.getParentPath(e);s.push({path:d,filePath:y(S.join(e,_)),parentPath:t===null?void 0:this.pathToRoute(t)})}let ee=this.findFile(t,pt.OG_IMAGE);if(ee!=null&&ee!==``){let t=y(S.join(e,ee)),n=S.join(this.appDir,t),r,i,a;try{let e=await x.readFile(n,`utf-8`),t=St.exec(e);t&&(r=Number.parseInt(t[1],10),i=Number.parseInt(t[2],10));let o=Ct.exec(e);o&&(a=o[1])}catch{}l.push({path:d,filePath:t,width:r,height:i,contentType:a})}let te=await lt({appDir:this.appDir,relativeDir:e,routePath:d,files:t});u.push(...te);let v=this.findFile(t,pt.ROUTE);if(v!=null&&v!==``){let t=await this.processApiRouteFile(e,v);c.push(t)}}findFile(e,t){for(let n of this.extensions){let r=`${t}${n}`;if(e.includes(r))return r}}pathToRoute(e){return e?`/${y(e).split(`/`).filter(Boolean).filter(e=>!_t(e)).map(bt).join(`/`)}`:`/`}parseRouteSegments(e){return e?e.split(ee).filter(Boolean).filter(e=>!_t(e)).map(xt):[]}extractParams(e){return e.filter(e=>e.param!==void 0).map(e=>e.param)}getParentPath(e){if(!e)return null;let t=e.split(ee).filter(Boolean);
19
+ `;return new Promise((t,r)=>{let i=Te(A.execPath,[`--conditions=react-server`,`--input-type=module`,`--eval`,n],{stdio:[`ignore`,`pipe`,`pipe`,`ipc`],env:A.env}),a=``,o=``,s=!1,c=!1,l,u,d,f=()=>{u!==void 0&&clearTimeout(u),d!==void 0&&clearTimeout(d),u=void 0,d=void 0};u=setTimeout(()=>{s||(s=!0,u!==void 0&&clearTimeout(u),u=void 0,i.kill(`SIGTERM`),d=setTimeout(()=>{i.kill(`SIGKILL`)},1e3),r(/* @__PURE__ */ Error(`generateStaticParams timed out after ${Ve}ms for ${e}`)))},Ve),i.stdout?.setEncoding(`utf8`),i.stderr?.setEncoding(`utf8`),i.stdout?.on(`data`,e=>{a+=e}),i.stderr?.on(`data`,e=>{o+=e}),i.on(`message`,e=>{c=!0,l=e}),i.on(`error`,e=>{s||(s=!0,f(),r(e))}),i.on(`close`,n=>{if(f(),s)return;s=!0;let i=[o.trim(),a.trim()].filter(Boolean).join(`
20
+ `);if(n!==0){r(Error(i||`generateStaticParams worker exited with code ${n}`));return}if(!c){r(Error(i||`generateStaticParams worker exited without an IPC result for ${e}`));return}t(l)})})}const Ue=/\\\*/g;function We(e,t={}){let{escapeAsterisk:n=!0}=t,r=RegExp.escape(e);return n?r:r.replace(Ue,`*`)}const Ge=[`.ico`],Ke=[`.ico`,`.jpg`,`.jpeg`,`.png`,`.svg`],qe=[`.jpg`,`.jpeg`,`.png`],Je={".ico":`image/x-icon`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".svg":`image/svg+xml`};function Ye(e){return Je[e.toLowerCase()]??`application/octet-stream`}function Xe(e,t,n){let r=n.map(e=>We(e.replace(/^\./,``))).join(`|`),i=RegExp(`^${We(t)}(\\d*)\\.(${r})$`,`i`);return e.filter(e=>i.test(e)).sort((e,t)=>e.localeCompare(t))}function Ze(e,t){let n=T(e).replace(/^\/+|\/+$/g,``);return n===``?`/${t}`:`/${n}/${t}`.replace(/\/+/g,`/`)}function Qe(e){if(e.length<24||e[0]!==137||e[1]!==80||e[2]!==78||e[3]!==71)return;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:t.getUint32(16),height:t.getUint32(20)}}async function $e(e){let t=k.extname(e).toLowerCase();if(t===`.svg`||t===`.ico`)return{sizes:`any`};try{let n=await O.readFile(e);if(t===`.png`){let e=Qe(n);if(e)return{...e,sizes:`${e.width}x${e.height}`}}}catch{}return{sizes:`any`}}function et(e){let t=T(k.join(e.relativeDir,e.fileName)),n=k.extname(e.fileName).toLowerCase();return{path:e.routePath,filePath:t,kind:e.kind,url:Ze(e.relativeDir,e.fileName),contentType:Ye(n),width:e.width,height:e.height,sizes:e.sizes}}async function tt(e){let{appDir:t,relativeDir:n,routePath:r,files:i}=e,a=[],o=async(e,o,s,c)=>{if(c&&r!==`/`)return;let l=Xe(i,o,s);for(let i of l){let o=await $e(k.join(t,n,i));a.push(et({routePath:r,relativeDir:n,fileName:i,kind:e,width:o.width,height:o.height,sizes:o.sizes}))}};return await o(`favicon`,`favicon`,Ge,!0),await o(`icon`,`icon`,Ke,!1),await o(`apple-icon`,`apple-icon`,qe,!1),a}async function nt(e){let{appDir:t,outDir:n,icons:r}=e,i=0;for(let e of r){let r=k.join(t,e.filePath),a=k.join(n,e.url.replace(/^\//,``));await O.mkdir(k.dirname(a),{recursive:!0}),await O.copyFile(r,a),i+=1}return i}function rt(e){return u(e)?typeof e.path==`string`&&typeof e.filePath==`string`&&(e.kind===`favicon`||e.kind===`icon`||e.kind===`apple-icon`)&&typeof e.url==`string`&&typeof e.contentType==`string`&&(e.sizes===void 0||typeof e.sizes==`string`)&&(e.width===void 0||typeof e.width==`number`)&&(e.height===void 0||typeof e.height==`number`):!1}function it(e){let t;try{t=JSON.parse(e)}catch{return[]}return!u(t)||!Array.isArray(t.appIcons)?[]:t.appIcons.filter(rt)}const P={PAGE:`page`,LAYOUT:`layout`,LOADING:`loading`,ERROR:`error`,NOT_FOUND:`not-found`,TEMPLATE:`template`,DEFAULT:`default`,ROUTE:`route`,OG_IMAGE:`opengraph-image`,TWITTER_IMAGE:`twitter-image`,ICON:`icon`,APPLE_ICON:`apple-icon`},at={DYNAMIC:/^\[([^\]]+)\]$/,CATCH_ALL:/^\[\.\.\.([^\]]+)\]$/,OPTIONAL_CATCH_ALL:/^\[\[\.\.\.([^\]]+)\]\]$/},ot=[{pattern:at.OPTIONAL_CATCH_ALL,type:`optional-catch-all`,format:e=>`[[...${e}]]`},{pattern:at.CATCH_ALL,type:`catch-all`,format:e=>`[...${e}]`},{pattern:at.DYNAMIC,type:`dynamic`,format:e=>`[${e}]`}],st=/^\([^/]+\)$/;function ct(e){return st.test(e)}function lt(e){return e?T(e).split(`/`).filter(Boolean).some(ct):!1}function ut(e){for(let t of ot){let n=e.match(t.pattern);if(n)return{type:t.type,param:n[1],format:t.format}}}function dt(e){let t=ut(e);return t?t.format(t.param):e}function ft(e){let t=ut(e);return t?{type:t.type,value:e,param:t.param}:{type:`static`,value:e}}const pt=/export\s+const\s+size\s*=\s*\{\s*width\s*:\s*(\d+)\s*,\s*height\s*:\s*(\d+)\s*[,}]/,mt=/export\s+const\s+contentType\s*=\s*['"]([^'"]+)['"]/,ht=[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`];var gt=class{appDir;extensions;verbose;constructor(e){this.appDir=k.resolve(e.appDir),this.extensions=[...e.extensions??[`.tsx`,`.jsx`,`.ts`,`.js`]],this.verbose=e.verbose??!1}async generateManifest(){this.verbose&&console.warn(`[rari] Router: Scanning app directory: ${this.appDir}`);let e=[],t=[],n=[],r=[],i=[],a=[],o=[],s=[],c=[];await this.scanDirectory(``,e,t,n,r,i,a,o,s,c);for(let o of[t,n,r,i,a,s])this.finalizeGroupEntries(e,o);return this.assertNoDuplicateRoutes(e),this.assertNoDuplicateRoutes(o),this.verbose&&(console.warn(`[rari] Router: Found ${e.length} routes`),console.warn(`[rari] Router: Found ${t.length} layouts`),console.warn(`[rari] Router: Found ${n.length} loading components`),console.warn(`[rari] Router: Found ${r.length} error boundaries`),console.warn(`[rari] Router: Found ${a.length} templates`),console.warn(`[rari] Router: Found ${o.length} API routes`),console.warn(`[rari] Router: Found ${s.length} OG images`),console.warn(`[rari] Router: Found ${c.length} app icons`)),{routes:this.sortRoutes(e),layouts:this.sortLayouts(t),loading:n,errors:r,notFound:i,templates:this.sortTemplates(a),apiRoutes:this.sortApiRoutes(o),ogImages:s,appIcons:c,generated:(/* @__PURE__ */ new Date()).toISOString()}}finalizeGroupEntries(e,t){for(let n=t.length-1;n>=0;n--){let r=t[n],i=T(k.dirname(r.filePath));if(!lt(i))continue;let a=e.filter(e=>{let t=T(k.dirname(e.filePath));return t===i||t.startsWith(`${i}/`)}).map(e=>e.path);if(a.length===0){t.splice(n,1);continue}let o=Array.from(new Set(a)).sort();r.path=o[0],o.length>1&&(r.additionalPaths=o.slice(1))}}assertNoDuplicateRoutes(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.path);if(e!=null&&e!==``)throw Error(`[rari] Route conflict: path '${n.path}' is defined by both '${e}' and '${n.filePath}'.`);t.set(n.path,n.filePath)}}async scanDirectory(e,t,n,r,i,a,o,s,c,l){let u=k.join(this.appDir,e),d;try{d=await O.readdir(u)}catch{return}let f=[],p=[];for(let e of d){let t=k.join(u,e),n=await O.stat(t);n.isDirectory()?this.shouldScanDirectory(e)&&p.push(e):n.isFile()&&f.push(e)}await this.processSpecialFiles(e,f,t,n,r,i,a,o,s,c,l);for(let u of p){let d=e?k.join(e,u):u;await this.scanDirectory(d,t,n,r,i,a,o,s,c,l)}}async processSpecialFiles(e,t,n,r,i,a,o,s,c,l,u){let d=this.pathToRoute(e);this.pushPageRoute(e,t,d,n),this.pushLayoutEntry(e,t,d,r),this.pushNamedSpecial(e,t,d,P.LOADING,i),this.pushNamedSpecial(e,t,d,P.ERROR,a),this.pushNamedSpecial(e,t,d,P.NOT_FOUND,o),this.pushTemplateEntry(e,t,d,s),await this.pushOgImageEntry(e,t,d,l);let f=await tt({appDir:this.appDir,relativeDir:e,routePath:d,files:t});u.push(...f);let p=this.findFile(t,P.ROUTE);if(p!=null&&p!==``){let t=await this.processApiRouteFile(e,p);c.push(t)}}pushPageRoute(e,t,n,r){let i=this.findFile(t,P.PAGE);if(i==null||i===``)return;let a=this.parseRouteSegments(e),o=this.extractParams(a);r.push({path:n,filePath:T(k.join(e,i)),segments:a,params:o,isDynamic:o.length>0})}pushLayoutEntry(e,t,n,r){let i=this.findFile(t,P.LAYOUT);if(i==null||i===``)return;let a=this.getParentPath(e);r.push({path:n,filePath:T(k.join(e,i)),parentPath:a===null?void 0:this.pathToRoute(a)})}pushNamedSpecial(e,t,n,r,i){let a=this.findFile(t,r);a!=null&&a!==``&&i.push({path:n,filePath:T(k.join(e,a))})}pushTemplateEntry(e,t,n,r){let i=this.findFile(t,P.TEMPLATE);if(i==null||i===``)return;let a=this.getParentPath(e);r.push({path:n,filePath:T(k.join(e,i)),parentPath:a===null?void 0:this.pathToRoute(a)})}async pushOgImageEntry(e,t,n,r){let i=this.findFile(t,P.OG_IMAGE);if(i==null||i===``)return;let a=T(k.join(e,i)),o=k.join(this.appDir,a),s,c,l;try{let e=await O.readFile(o,`utf-8`),t=pt.exec(e);t&&(s=Number.parseInt(t[1],10),c=Number.parseInt(t[2],10));let n=mt.exec(e);n&&(l=n[1])}catch{}r.push({path:n,filePath:a,width:s,height:c,contentType:l})}findFile(e,t){for(let n of this.extensions){let r=`${t}${n}`;if(e.includes(r))return r}}pathToRoute(e){return e?`/${T(e).split(`/`).filter(Boolean).filter(e=>!ct(e)).map(dt).join(`/`)}`:`/`}parseRouteSegments(e){return e?e.split(ae).filter(Boolean).filter(e=>!ct(e)).map(ft):[]}extractParams(e){return e.filter(e=>e.param!==void 0).map(e=>e.param)}getParentPath(e){if(!e)return null;let t=e.split(ae).filter(Boolean);
21
21
  /* v8 ignore stop */
22
22
  return t.length===0?null:t.slice(0,-1).join(`/`)}shouldScanDirectory(e){return![`node_modules`,`.git`,`dist`,`build`,`__tests__`,`test`,`tests`,`coverage`].includes(e)&&!e.startsWith(`_`)&&!e.startsWith(`.`)}sortRoutes(e){return e.sort((e,t)=>{let n=e=>{if(!e.isDynamic)return 0;let t=e.segments.some(e=>e.type===`catch-all`);return e.segments.some(e=>e.type===`optional-catch-all`)?3:t?2:1},r=n(e),i=n(t);if(r!==i)return r-i;let a=e.path.split(`/`).length,o=t.path.split(`/`).length;return a===o?e.path.localeCompare(t.path):o-a})}sortApiRoutes(e){return e.sort((e,t)=>{if(!e.isDynamic&&t.isDynamic)return-1;if(e.isDynamic&&!t.isDynamic)return 1;let n=e.path.split(`/`).length,r=t.path.split(`/`).length;
23
23
  /* v8 ignore stop */
24
- return n===r?e.path.localeCompare(t.path):n-r})}sortLayouts(e){return e.sort((e,t)=>e.path===`/`&&t.path!==`/`?-1:t.path===`/`&&e.path!==`/`?1:e.path.split(`/`).length-t.path.split(`/`).length)}sortTemplates(e){return e.sort((e,t)=>e.path===`/`&&t.path!==`/`?-1:t.path===`/`&&e.path!==`/`?1:e.path.split(`/`).length-t.path.split(`/`).length)}async detectHttpMethods(e){let t=S.join(this.appDir,e),n=await x.readFile(t,`utf-8`),r=[];for(let e of wt){let t=RegExp(`export\\s+(?:async\\s+)?function\\s+${e}\\s*\\(`),i=RegExp(`export\\s+(?:async\\s+)?(?:const|let|var)\\s+${e}\\s*=`);(t.test(n)||i.test(n))&&r.push(e)}return r}async processApiRouteFile(e,t){let n=y(S.join(e,t)),r=this.pathToRoute(e),i=this.parseRouteSegments(e),a=this.extractParams(i),o=await this.detectHttpMethods(n);return{path:r,filePath:n,segments:i,params:a,isDynamic:a.length>0,methods:o}}};async function Et(e,t={}){return new Tt({appDir:e,...t}).generateManifest()}const Dt=/export\s+const\s+metadata\s*(?::\s*\w+\s*)?=\s*(\{[\s\S]*?\n\})/,Ot=/title\s*:\s*['"]([^'"]+)['"]/,kt=/description\s*:\s*['"]([^'"]+)['"]/,At=/keywords\s*:\s*\[([\s\S]*?)\]/,jt={appDir:`src/app`,extensions:[`.tsx`,`.jsx`,`.ts`,`.js`],outDir:`dist`};function Mt(e){switch(S.basename(e).replace(v,``)){case`page`:return`page`;case`layout`:return`layout`;case`template`:return`template`;case`loading`:return`loading`;case`error`:return`error`;case`not-found`:return`not-found`;case`route`:return`route`;default:return null}}function Nt(e){if(!e||e===`/`)return`/`;let t=y(e).split(`/`).filter(e=>!!e&&!_t(e));return t.length>0?`/${t.join(`/`)}`:`/`}function Pt(e,t){let n=S.relative(S.normalize(t),S.normalize(S.dirname(e)));return!n||n===`.`?`/`:Nt(`/${y(n).split(`/`).filter(Boolean).join(`/`)}`)}function Ft(e,t,n){if(t===`page`)return[e];let r=`${e}${e===`/`?``:`/`}`,i=n.filter(t=>t===e||t.startsWith(r));return i.length>0?i:[e]}function It(e){try{let t=Dt.exec(e);if(!t)return null;let n=t[1],r={},i=Ot.exec(n);i&&(r.title=i[1]);let a=kt.exec(n);a&&(r.description=a[1]);let o=At.exec(n);o&&(r.keywords=o[1].split(`,`).map(e=>e.trim().replace(se,``)).filter(Boolean));for(let e of[`author`,`viewport`,`themeColor`,`robots`,`openGraph`,`twitter`]){let t=RegExp(`${e}\\s*:\\s*['"]([^'"]+)['"]`,`m`),i=n.match(t);i&&(r[e]=i[1])}return Object.keys(r).length>0?r:null}catch(e){return console.error(`[rari] Router: Failed to extract metadata:`,e),null}}function Lt(e){let t=[];for(let n of[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`]){let r=RegExp(`export\\s+(?:async\\s+)?function\\s+${n}\\s*\\(`),i=RegExp(`export\\s+(?:async\\s+)?(?:const|let|var)\\s+${n}\\s*=`);(r.test(e)||i.test(e))&&t.push(n)}return t}function Rt(e){return l(e)&&Array.isArray(e.routes)}async function zt(e){try{let t=await fetch(`${Je()}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate-api-route`,filePath:e})});if(!t.ok){console.error(`[rari] Router: Failed to invalidate API route cache: ${t.statusText}`);return}let n=d(await t.text());if(n?.success!==!0){let e=typeof n?.error==`string`&&n.error!==``?n.error:`Unknown error`;console.error(`[rari] HMR: Failed to invalidate API route cache: ${e}`)}}catch(e){console.error(`[rari] Router: Failed to notify API route invalidation:`,e)}}function Bt(e={}){let n={...jt,...e},r=null,i=/* @__PURE__ */ new Map,a=null,o=/* @__PURE__ */ new Set,s=e=>[...e].toSorted().join(`|`),c=async e=>{let t=/* @__PURE__ */ new Set,r=async e=>{try{let i=await x.readdir(e,{withFileTypes:!0});for(let a of i){let i=S.join(e,a.name);a.isDirectory()?await r(i):a.isFile()&&n.extensions.some(e=>a.name.endsWith(e))&&Mt(i)&&t.add(y(i))}}catch{}};return await r(e),t},l=async(e,t=!1)=>{let i=S.resolve(e,n.appDir);try{await x.access(i)}catch{return null}try{let l=await c(i),u=s(l);if(!t&&a===u&&r!=null&&r!==``)return r;let d=await Et(i,{extensions:n.extensions}),f=JSON.stringify(d),p=S.resolve(e,n.outDir);await x.mkdir(p,{recursive:!0});let m=S.join(p,`server`);return await x.mkdir(m,{recursive:!0}),await x.writeFile(S.join(m,`routes.json`),f,`utf-8`),a=u,o.clear(),l.forEach(e=>{o.add(e)}),f}catch(e){return console.error(`[rari] Router: Failed to generate app routes:`,e),null}},u=e=>{let t=S.resolve(e.config.root,n.appDir);e.watcher.on(`all`,(r,i)=>{(async()=>{if(pe(i,t)&&n.extensions.some(e=>i.endsWith(e)))try{let n=Mt(i)!==null,a=r===`add`||r===`unlink`,s=n&&!o.has(y(i));(a||s)&&(await l(e.config.root,!0),pe(i,t)&&e.ws.send({type:`full-reload`,path:`*`}))}catch(e){console.error(`[rari] Router: Failed to regenerate app routes:`,e)}})()})},p;return He({name:`rari-router`,configResolved(e){p=e.root;let t=e.logger.warn.bind(e.logger);e.logger.warn=(e,n)=>{typeof e==`string`&&e.includes(`The above dynamic import cannot be analyzed`)&&e.includes(`packages/rari/dist/`)||t(e,n)}},async writeBundle(){let e=p||C.cwd();r=await l(e,!0)},configureServer(e){u(e)},async handleHotUpdate(e){let{file:t,server:a}=e,s=S.resolve(a.config.root,n.appDir);if(pe(t,s)&&n.extensions.some(e=>t.endsWith(e))){let e=Mt(t);if(e){let n=i.get(t);n&&clearTimeout(n);let c=setTimeout(()=>{(async()=>{i.delete(t);let n=y(t),c=!o.has(n),u=r;r=await l(a.config.root,c);let f=u!==r,p=Pt(t,s),m=[p];if(r!=null&&r!==``)try{let e=d(r);e&&Rt(e)&&(m=e.routes.map(e=>e.path))}catch(e){console.error(`[rari] Router: Failed to parse manifest for affected routes:`,e)}let h=Ft(p,e,m),g,_=!1,ee;if(e===`page`||e===`layout`)try{let e=It(await x.readFile(t,`utf-8`));e&&(g=e,_=!0)}catch(e){console.error(`[rari] Router: Failed to extract metadata:`,e)}if(e===`route`)try{ee=Lt(await x.readFile(t,`utf-8`)),await zt(S.relative(s,t))}catch(e){console.error(`[rari] Router: Failed to detect HTTP methods:`,e)}let te={fileType:e,filePath:y(S.relative(a.config.root,t)),routePath:p,affectedRoutes:h,manifestUpdated:f,timestamp:Date.now(),metadata:g,metadataChanged:_,methods:ee};a.ws.send({type:`custom`,event:`rari:app-router-updated`,data:te})})()},200);return i.set(t,c),[]}return r=await l(a.config.root),[]}},async closeBundle(){for(let e of i.values())clearTimeout(e);i.clear();let e=p||C.cwd(),r=S.resolve(e,n.outDir,`server`),a=S.join(r,`routes.json`);try{let e=await x.readFile(a,`utf-8`),n=d(e);if(!n||!Rt(n))return;let i=n,o=i.routes.flatMap(e=>{if(!e.isDynamic)return[];let t=e.componentId;return t==null||t===``?[]:[{route:e,componentId:t}]}),s=Math.min(8,Math.max(1,o.length)),c=o.map(()=>!1),l=0,u=0;await new Promise(e=>{let n=()=>{for(;u<s&&l<o.length;){let i=l++,{route:a,componentId:s}=o[i],d=S.join(r,`${s}.js`);u++,(async()=>{try{let e=await Xe(d);if(e==null)return;f(e)?(a.staticParams=e,c[i]=!0):t(s)}catch(e){console.warn(`[rari] Failed to evaluate generateStaticParams for ${s}:`,e)}finally{u--,l>=o.length&&u===0?e():n()}})()}o.length===0&&e()};n()}),c.some(Boolean)&&await x.writeFile(a,JSON.stringify(i),`utf-8`)}catch(e){console.warn(`[rari] Failed to enrich routes manifest with static params:`,e)}}})}function Vt(e,t,n,r){let i=e.indexOf(t);if(i===-1)throw Error(`Failed to patch flight browser client: anchor for ${r} not found. The react-server-dom-webpack sources likely changed shape after a version bump; update the anchors in patch-flight-browser-client.ts.`);if(e.includes(t,i+1))throw Error(`Failed to patch flight browser client: anchor for ${r} matched more than once. Update the anchors in patch-flight-browser-client.ts to be unambiguous.`);return e.slice(0,i)+n+e.slice(i+t.length)}function Ht(e,t){let n=t.indexOf(`var boundCache = new WeakMap();`),r=t.indexOf(`function createBoundServerReference`,n);if(n===-1||r===-1)throw Error(`Failed to locate edge client form-action helpers for browser patch`);return Vt(e,`function registerBoundServerReference(reference, id, bound) {
25
- knownServerReferences.has(reference) ||
26
- knownServerReferences.set(reference, {
27
- id: id,
28
- originalBind: reference.bind,
29
- bound: bound
30
- });
31
- }`,Vt(t.slice(n,r),`return {
32
- name: referenceClosure,
33
- method: "POST",
34
- encType: "multipart/form-data",
35
- data: data
36
- };`,`function resolveRariFormActionUrl() {
24
+ return n===r?e.path.localeCompare(t.path):n-r})}sortLayouts(e){return e.sort((e,t)=>e.path===`/`&&t.path!==`/`?-1:t.path===`/`&&e.path!==`/`?1:e.path.split(`/`).length-t.path.split(`/`).length)}sortTemplates(e){return e.sort((e,t)=>e.path===`/`&&t.path!==`/`?-1:t.path===`/`&&e.path!==`/`?1:e.path.split(`/`).length-t.path.split(`/`).length)}async detectHttpMethods(e){let t=k.join(this.appDir,e),n=await O.readFile(t,`utf-8`),r=[];for(let e of ht){let t=RegExp(`export\\s+(?:async\\s+)?function\\s+${e}\\s*\\(`),i=RegExp(`export\\s+(?:async\\s+)?(?:const|let|var)\\s+${e}\\s*=`);(t.test(n)||i.test(n))&&r.push(e)}return r}async processApiRouteFile(e,t){let n=T(k.join(e,t)),r=this.pathToRoute(e),i=this.parseRouteSegments(e),a=this.extractParams(i),o=await this.detectHttpMethods(n);return{path:r,filePath:n,segments:i,params:a,isDynamic:a.length>0,methods:o}}};async function _t(e,t={}){return new gt({appDir:e,...t}).generateManifest()}const vt=/export\s+const\s+metadata\s*(?::\s*\w+\s*)?=\s*(\{[\s\S]*?\n\})/,yt=/title\s*:\s*['"]([^'"]+)['"]/,bt=/description\s*:\s*['"]([^'"]+)['"]/,xt=/keywords\s*:\s*\[([\s\S]*?)\]/,St={appDir:`src/app`,extensions:[`.tsx`,`.jsx`,`.ts`,`.js`],outDir:`dist`};function Ct(e){switch(k.basename(e).replace(S,``)){case`page`:return`page`;case`layout`:return`layout`;case`template`:return`template`;case`loading`:return`loading`;case`error`:return`error`;case`not-found`:return`not-found`;case`route`:return`route`;default:return null}}function wt(e){if(!e||e===`/`)return`/`;let t=T(e).split(`/`).filter(e=>!!e&&!ct(e));return t.length>0?`/${t.join(`/`)}`:`/`}function Tt(e,t){let n=k.relative(k.normalize(t),k.normalize(k.dirname(e)));return!n||n===`.`?`/`:wt(`/${T(n).split(`/`).filter(Boolean).join(`/`)}`)}function Et(e,t,n){if(t===`page`)return[e];let r=`${e}${e===`/`?``:`/`}`,i=n.filter(t=>t===e||t.startsWith(r));return i.length>0?i:[e]}function Dt(e){try{let t=vt.exec(e);if(!t)return null;let n=t[1],r={},i=yt.exec(n);i&&(r.title=i[1]);let a=bt.exec(n);a&&(r.description=a[1]);let o=xt.exec(n);o&&(r.keywords=o[1].split(`,`).map(e=>e.trim().replace(y,``)).filter(Boolean));for(let e of[`author`,`viewport`,`themeColor`,`robots`,`openGraph`,`twitter`]){let t=RegExp(`${e}\\s*:\\s*['"]([^'"]+)['"]`,`m`),i=n.match(t);i&&(r[e]=i[1])}return Object.keys(r).length>0?r:null}catch(e){return console.error(`[rari] Router: Failed to extract metadata:`,e),null}}function Ot(e){let t=[];for(let n of[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`]){let r=RegExp(`export\\s+(?:async\\s+)?function\\s+${n}\\s*\\(`),i=RegExp(`export\\s+(?:async\\s+)?(?:const|let|var)\\s+${n}\\s*=`);(r.test(e)||i.test(e))&&t.push(n)}return t}function kt(e){return u(e)&&Array.isArray(e.routes)}async function At(e){try{let t=await fetch(`${Be()}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate-api-route`,filePath:e})});if(!t.ok){console.error(`[rari] Router: Failed to invalidate API route cache: ${t.statusText}`);return}let n=f(await t.text());if(n?.success!==!0){let e=typeof n?.error==`string`&&n.error!==``?n.error:`Unknown error`;console.error(`[rari] HMR: Failed to invalidate API route cache: ${e}`)}}catch(e){console.error(`[rari] Router: Failed to notify API route invalidation:`,e)}}function jt(e={}){let t={...St,...e},r=null,i=/* @__PURE__ */ new Map,a=null,o=/* @__PURE__ */ new Set,s=e=>[...e].toSorted().join(`|`),c=async e=>{let n=/* @__PURE__ */ new Set,r=async e=>{try{let i=await O.readdir(e,{withFileTypes:!0});for(let a of i){let i=k.join(e,a.name);a.isDirectory()?await r(i):a.isFile()&&t.extensions.some(e=>a.name.endsWith(e))&&Ct(i)&&n.add(T(i))}}catch{}};return await r(e),n},l=async(e,n=!1)=>{let i=k.resolve(e,t.appDir);try{await O.access(i)}catch{return null}try{let l=await c(i),u=s(l);if(!n&&a===u&&r!=null&&r!==``)return r;let d=await _t(i,{extensions:t.extensions}),f=JSON.stringify(d),p=k.resolve(e,t.outDir);await O.mkdir(p,{recursive:!0});let m=k.join(p,`server`);return await O.mkdir(m,{recursive:!0}),await O.writeFile(k.join(m,`routes.json`),f,`utf-8`),a=u,o.clear(),l.forEach(e=>{o.add(e)}),f}catch(e){return console.error(`[rari] Router: Failed to generate app routes:`,e),null}},u=e=>{let n=k.resolve(e.config.root,t.appDir);e.watcher.on(`all`,(r,i)=>{(async()=>{if(se(i,n)&&t.extensions.some(e=>i.endsWith(e)))try{let t=Ct(i)!==null,a=r===`add`||r===`unlink`,s=t&&!o.has(T(i));(a||s)&&(await l(e.config.root,!0),se(i,n)&&e.ws.send({type:`full-reload`,path:`*`}))}catch(e){console.error(`[rari] Router: Failed to regenerate app routes:`,e)}})()})},d;return Fe({name:`rari-router`,configResolved(e){d=e.root;let t=e.logger.warn.bind(e.logger);e.logger.warn=(e,n)=>{typeof e==`string`&&e.includes(`The above dynamic import cannot be analyzed`)&&e.includes(`packages/rari/dist/`)||t(e,n)}},async writeBundle(){let e=d||A.cwd();r=await l(e,!0)},configureServer(e){u(e)},async handleHotUpdate(e){let{file:n,server:a}=e,s=k.resolve(a.config.root,t.appDir);if(se(n,s)&&t.extensions.some(e=>n.endsWith(e))){let e=Ct(n);if(e){let t=i.get(n);t&&clearTimeout(t);let c=setTimeout(()=>{(async()=>{i.delete(n);let t=T(n),c=!o.has(t),u=r;r=await l(a.config.root,c);let d=u!==r,p=Tt(n,s),m=[p];if(r!=null&&r!==``)try{let e=f(r);e&&kt(e)&&(m=e.routes.map(e=>e.path))}catch(e){console.error(`[rari] Router: Failed to parse manifest for affected routes:`,e)}let h=Et(p,e,m),g,_=!1,v;if(e===`page`||e===`layout`)try{let e=Dt(await O.readFile(n,`utf-8`));e&&(g=e,_=!0)}catch(e){console.error(`[rari] Router: Failed to extract metadata:`,e)}if(e===`route`)try{v=Ot(await O.readFile(n,`utf-8`)),await At(k.relative(s,n))}catch(e){console.error(`[rari] Router: Failed to detect HTTP methods:`,e)}let y={fileType:e,filePath:T(k.relative(a.config.root,n)),routePath:p,affectedRoutes:h,manifestUpdated:d,timestamp:Date.now(),metadata:g,metadataChanged:_,methods:v};a.ws.send({type:`custom`,event:`rari:app-router-updated`,data:y})})()},200);return i.set(n,c),[]}return r=await l(a.config.root),[]}},async closeBundle(){for(let e of i.values())clearTimeout(e);i.clear();let e=d||A.cwd(),r=k.resolve(e,t.outDir,`server`),a=k.join(r,`routes.json`);try{let e=await O.readFile(a,`utf-8`),t=f(e);if(!t||!kt(t))return;let i=t,o=i.routes.flatMap(e=>{if(!e.isDynamic)return[];let t=e.componentId;return t==null||t===``?[]:[{route:e,componentId:t}]}),s=Math.min(8,Math.max(1,o.length)),c=o.map(()=>!1),l=0,u=0;await new Promise(e=>{let t=()=>{for(;u<s&&l<o.length;){let i=l++,{route:a,componentId:s}=o[i],d=k.join(r,`${s}.js`);u++,(async()=>{try{let e=await He(d);if(e==null)return;p(e)?(a.staticParams=e,c[i]=!0):n(s)}catch(e){console.warn(`[rari] Failed to evaluate generateStaticParams for ${s}:`,e)}finally{u--,l>=o.length&&u===0?e():t()}})()}o.length===0&&e()};t()}),c.some(Boolean)&&await O.writeFile(a,JSON.stringify(i),`utf-8`)}catch(e){console.warn(`[rari] Failed to enrich routes manifest with static params:`,e)}}})}const Mt=/return \{\s*name: referenceClosure,\s*method: "POST",\s*encType: "multipart\/form-data",\s*data: data\s*\};/,Nt=/function registerBoundServerReference\(reference, id, bound\) \{\s*knownServerReferences\.has\(reference\) \|\|\s*knownServerReferences\.set\(reference, \{\s*id: id,\s*originalBind: reference\.bind,\s*bound: bound\s*\}\);\s*\}/,Pt=/Object\.defineProperty\(value\._store, "validated", \{\s*configurable: !1,\s*enumerable: !1,\s*writable: !0,\s*value: i\s*\}\);/;function Ft(e,t,n,r){let i=new RegExp(t.source,t.flags.includes(`g`)?t.flags:`${t.flags}g`),a=[...e.matchAll(i)];if(a.length===0)throw Error(`Failed to patch flight browser client: pattern for ${r} not found. The react-server-dom-webpack sources likely changed shape after a version bump; update the anchors in patch-flight-browser-client.ts.`);if(a.length>1)throw Error(`Failed to patch flight browser client: pattern for ${r} matched more than once. Update the anchors in patch-flight-browser-client.ts to be unambiguous.`);let o=a[0];return e.slice(0,o.index)+n+e.slice(o.index+o[0].length)}function It(e){return Pt.test(e)?(Pt.lastIndex=0,Ft(e,Pt,`Object.defineProperty(value._store, "validated", {
25
+ configurable: !1,
26
+ enumerable: !1,
27
+ writable: !0,
28
+ value: void 0 === i ? 1 : i
29
+ });`,`DEV _store.validated default for production wire`)):e}function Lt(e){let t=e.indexOf(`var boundCache = new WeakMap();`),n=e.indexOf(`function encodeFormData`),r=t===-1?n===-1?-1:n:t,i=e.indexOf(`function createBoundServerReference`,r);if(r===-1||i===-1)throw Error(`Failed to locate edge client form-action helpers for browser patch`);let a=e.slice(r,i);a.includes(`var boundCache = new WeakMap()`)||(a=`var boundCache = new WeakMap();\n${a}`);let o=/FunctionBind\s*=\s*Function\.prototype\.bind/.test(a),s=/ArraySlice\s*=\s*Array\.prototype\.slice/.test(a);return!o&&!s?a=`var FunctionBind = Function.prototype.bind,\n ArraySlice = Array.prototype.slice;\n${a}`:o?s||(a=`var ArraySlice = Array.prototype.slice;\n${a}`):a=`var FunctionBind = Function.prototype.bind;\n${a}`,Ft(a,Mt,`function resolveRariFormActionUrl() {
37
30
  var g = typeof globalThis !== "undefined" ? globalThis : {};
38
31
  var rari = g["~rari"];
39
32
  if (rari && rari.actionPostUrl)
@@ -48,20 +41,20 @@ return n===r?e.path.localeCompare(t.path):n-r})}sortLayouts(e){return e.sort((e,
48
41
  encType: "multipart/form-data",
49
42
  action: resolveRariFormActionUrl(),
50
43
  data: data
51
- };`,`edge $$FORM_ACTION return block`),`browser registerBoundServerReference`)}const Ut=[`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react/compiler-runtime`,`react-dom/client`];function Wt(e){return l(e)&&typeof e.find==`string`&&typeof e.replacement==`string`}function Gt(e,t=new Set(Ut)){let n={},r=e.resolve?.alias;if(Array.isArray(r))for(let e of r)Wt(e)&&!t.has(e.find)&&(n[e.find]=e.replacement);else if(l(r))for(let[e,i]of Object.entries(r))typeof i==`string`&&!t.has(e)&&(n[e]=i);return n}function Kt(e){return{projectRoot:e.root,outDir:S.resolve(e.root,e.build.outDir),assetsDir:fe(e.build.assetsDir)}}function qt(e,t=8){return Ne(`sha256`).update(e).digest(`hex`).slice(0,t)}function Jt(e,t=C.cwd()){let n=S.isAbsolute(e)?e:S.resolve(t,e),r=S.relative(t,n);return S.isAbsolute(r)?y(n):y(r)}function Yt(e){return e.replace(v,``).replace(ae,`_`).replace(ie,``)}function Xt(e,t=C.cwd()){let n=Jt(e,t);return`${Yt(n)}_${qt(n)}`}const Zt=/* @__PURE__ */ new Set([`return`,`throw`,`case`,`typeof`,`instanceof`,`new`,`delete`,`void`,`in`,`of`]),Qt=8232,$t=8233;function en(e){return e===32||e===9||e===13||e===10||e===Qt||e===$t||e===65279}function tn(e){return e===13||e===10||e===Qt||e===$t}function T(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function nn(e){return e>=97&&e<=122||e>=65&&e<=90||e===95||e===36}function rn(e,t,n){for(;t<n&&en(e.charCodeAt(t));)t++;return t}function E(e,t,n){for(;t<n;){let r=rn(e,t,n);if(r!==t){t=r;continue}let i=e.charCodeAt(t);if(i===47&&e.charCodeAt(t+1)===47){t=an(e,t,n);continue}if(i===47&&e.charCodeAt(t+1)===42){t=on(e,t,n);continue}break}return t}function an(e,t,n){for(;t<n&&!tn(e.charCodeAt(t));)t++;return t}function on(e,t,n){for(t+=2;t<n-1&&(e.charCodeAt(t)!==42||e.charCodeAt(t+1)!==47);)t++;return t+2}function sn(e,t,n,r){for(t++;t<n;){let n=e.charCodeAt(t);if(n===92){t+=2;continue}if(n===r)return t+1;t++}return t}function cn(e,t,n){t++;let r=e.charCodeAt(t)===47;for(r&&t++;t<n;){let n=e.charCodeAt(t);if(T(n)||n===46||n===45)t++;else break}let i=+!r;for(;t<n&&i>0;){let a=e.charCodeAt(t);if(a===39||a===34||a===96){t=sn(e,t,n,a);continue}if(a===123){t++;let r=1;for(;t<n&&r>0;){let i=e.charCodeAt(t);if(i===39||i===34||i===96){t=sn(e,t,n,i);continue}i===123&&r++,i===125&&r--,t++}continue}if(a===47&&e.charCodeAt(t+1)===62){i--,t+=2;continue}if(a===62){t++,r&&i--;continue}if(a===60){let r=e.charCodeAt(t+1);if(r===47||r===46||r===62||nn(r)){for(r===47?(i--,t++):r!==33&&i++,t++;t<n;){let n=e.charCodeAt(t);if(T(n)||n===46||n===45)t++;else break}continue}t++;continue}t++}return t}function ln(e,t,n){for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;return!0}function D(e,t,n){if(t+n.length>e.length)return!1;for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;let r=t>0?e.charCodeAt(t-1):-1,i=t+n.length,a=i<e.length?e.charCodeAt(i):-1;return!(r!==-1&&T(r)||a!==-1&&T(a))}function un(e,t,n){let r=E(e,t,n);if(r>=n)return null;let i=e.charCodeAt(r);if(i!==39&&i!==34)return null;let a=r+1,o=sn(e,r,n,i);return o<=a?null:{source:e.slice(a,o-1),end:o}}function dn(e,t,n){if(!D(e,t,`import`))return{sources:[],end:t+6};let r=t+6;if(r=E(e,r,n),D(e,r,`type`)&&(r=E(e,r+4,n)),e.charCodeAt(r)===46){for(r++;r<n&&T(e.charCodeAt(r));)r++;for(;r<n&&e.charCodeAt(r)===46;)for(r++;r<n&&T(e.charCodeAt(r));)r++;return{sources:[],end:r}}if(e.charCodeAt(r)===40){r++;let t=un(e,r,n);return t?{sources:[t.source],end:t.end}:{sources:[],end:r}}let i=un(e,r,n);if(i)return{sources:[i.source],end:i.end};let a=0;for(;r<n&&(r=E(e,r,n),!(r>=n));){let t=e.charCodeAt(r);if(a===0&&D(e,r,`from`)){let t=un(e,r+4,n);if(t)return{sources:[t.source],end:t.end};break}if(t===39||t===34||t===96){r=sn(e,r,n,t);continue}t===123||t===40||t===91?a++:(t===125||t===41||t===93)&&(a=Math.max(0,a-1)),r++}return{sources:[],end:r}}function fn(e,t){return e.charCodeAt(t)===101&&e.charCodeAt(t+1)===120&&e.charCodeAt(t+2)===112&&e.charCodeAt(t+3)===111&&e.charCodeAt(t+4)===114&&e.charCodeAt(t+5)===116}function pn(e,t){return e.charCodeAt(t)===100&&e.charCodeAt(t+1)===101&&e.charCodeAt(t+2)===102&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===117&&e.charCodeAt(t+5)===108&&e.charCodeAt(t+6)===116}function mn(e){let t={hasUseClient:!1,hasUseServer:!1},n=!1,r=!1,i=!1,a=!1,o=[],s=!0,c=!1,l=0,u=e.length;for(;l<u;){let d=e.charCodeAt(l);if(s&&(d===39||d===34)){let i=l+1,a=sn(e,l,u,d);if(a<=i){s=!1,l++;continue}let o=a-1-i,f=o===10&&ln(e,i,`use client`),p=o===10&&ln(e,i,`use server`);c||(c=!0,n=f,r=p),f&&(t.hasUseClient=!0),p&&(t.hasUseServer=!0);let m=a,h=!1;for(;m<u;){let t=e.charCodeAt(m);if(en(t)&&!tn(t)){m++;continue}if(tn(t)||t===59){h=!0,l=m+1;break}if(t===47&&e.charCodeAt(m+1)===47){m=an(e,m,u);continue}if(t===47&&e.charCodeAt(m+1)===42){m=on(e,m,u);continue}s=!1,h=!1;break}if(!h){m>=u&&(s=!1),l=s?a:m;continue}continue}let f=Mn(e,l,u);if(f!==-1){s&&!Nn(e,l)&&(s=!1),l=f;continue}if(s=!1,D(e,l,`import`)){let t=dn(e,l,u);for(let e of t.sources)o.push(e);l=t.end;continue}if(fn(e,l)){let t=l+6;if(t<u){let n=e.charCodeAt(t);if(en(n)||n===123||n===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42)){let n=E(e,t,u);if(pn(e,n)){i=!0,a=!0;let r=n+7;if(r>=u||!T(e.charCodeAt(r))){l=t;continue}}if(e.charCodeAt(n)===123){let t=n+1;for(;t<u&&(t=E(e,t,u),e.charCodeAt(t)!==125);){let n=t;for(;t<u&&T(e.charCodeAt(t));)t++;let r=t-n;if(r===0)break;t=E(e,t,u);let o=!1;if(e.charCodeAt(t)===97&&e.charCodeAt(t+1)===115){o=!0;let n=t+2;if(n<u&&!T(e.charCodeAt(n))){t=E(e,n,u);let r=t;for(;t<u&&T(e.charCodeAt(t));)t++;t-r===7&&pn(e,r)&&(i=!0,a=!0)}}if(!o&&r===7&&pn(e,n)&&(i=!0,a=!0),e.charCodeAt(t)===44){t++;continue}if(e.charCodeAt(t)===125)break;t++}}else(D(e,n,`async`)||D(e,n,`function`)||D(e,n,`class`))&&(a=!0)}}}l++}return{directives:t,topLevelUseClient:n,topLevelUseServer:r,hasDefaultExport:i,hasComponentExport:a,importSources:[...new Set(o)]}}function hn(e,t,n){if(t>=n||!nn(e.charCodeAt(t)))return null;let r=t+1;for(;r<n&&T(e.charCodeAt(r));)r++;return{name:e.slice(t,r),end:r}}function gn(e,t,n){let r=t;for(;r<n;){let t=e.charCodeAt(r);if(t===32||t===9){r++;continue}if(t===59)return r+1;break}return t}function _n(e,t,n){let r=[],i=t+1;for(;;){if(i=E(e,i,n),i>=n)return null;if(e.charCodeAt(i)===125)return{named:r,end:i+1};let t=!1;if(D(e,i,`type`)){let r=E(e,i+4,n),a=e.charCodeAt(r);(a===39||a===34||hn(e,r,n)!==null)&&!D(e,r,`as`)&&(t=!0,i=r)}let a,o=e.charCodeAt(i);if(o===39||o===34){let t=sn(e,i,n,o);a=e.slice(i+1,t-1),i=t}else{let t=hn(e,i,n);if(!t)return null;a=t.name,i=t.end}i=E(e,i,n);let s=a;if(D(e,i,`as`)){i=E(e,i+2,n);let t=hn(e,i,n);if(!t)return null;s=t.name,i=E(e,t.end,n)}r.push({imported:a,local:s,typeOnly:t});let c=e.charCodeAt(i);if(c===44){i++;continue}return c===125?{named:r,end:i+1}:null}}function vn(e,t,n){let r=E(e,t+6,n);if(r>=n)return null;let i=e.charCodeAt(r);if(i===40||i===46)return null;if(i===39||i===34){let i=un(e,r,n);return i?{start:t,end:gn(e,i.end,n),source:i.source,typeOnly:!1,sideEffectOnly:!0,defaultBinding:null,namespaceBinding:null,named:[]}:null}let a=!1;if(D(e,r,`type`)){let t=E(e,r+4,n);!D(e,t,`from`)&&e.charCodeAt(t)!==44&&(a=!0,r=t)}let o=null,s=null,c=[],l=e.charCodeAt(r);if(l!==123&&l!==42){let t=hn(e,r,n);if(!t)return null;o=t.name,r=E(e,t.end,n),e.charCodeAt(r)===44?(r=E(e,r+1,n),l=e.charCodeAt(r)):l=-1}if(l===42){if(r=E(e,r+1,n),!D(e,r,`as`))return null;r=E(e,r+2,n);let t=hn(e,r,n);if(!t)return null;s=t.name,r=t.end}else if(l===123){let t=_n(e,r,n);if(!t)return null;c=t.named,r=t.end}if(r=E(e,r,n),!D(e,r,`from`))return null;let u=un(e,r+4,n);return u?{start:t,end:gn(e,u.end,n),source:u.source,typeOnly:a,sideEffectOnly:!1,defaultBinding:o,namespaceBinding:s,named:c}:null}function yn(e){let t=[],n=0,r=e.length;for(;n<r;){let i=Mn(e,n,r);if(i!==-1){n=i;continue}if(D(e,n,`import`)){let i=vn(e,n,r);if(i){t.push(i),n=i.end;continue}n+=6;continue}n++}return t}function bn(e){let t=/* @__PURE__ */ new Set,n=0,r=e.length;for(;n<r;){let i=Mn(e,n,r);if(i!==-1){n=i;continue}if(!D(e,n,`export`)){n++;continue}let a=E(e,n+6,r);if(D(e,a,`type`)||D(e,a,`interface`)){n=a+1;continue}if(e.charCodeAt(a)===42){let i=E(e,a+1,r);if(D(e,i,`as`)){i=E(e,i+2,r);let a=hn(e,i,r);a&&t.add(a.name),n=a?.end??i+1}else n=a+1;continue}if(D(e,a,`default`)){t.add(`default`),n=a+7;continue}if(e.charCodeAt(a)===123){let i=xn(e,a,r),o=e.slice(a+1,i-1);for(let e of o.split(`,`)){let n=e.trim();if(!n||n.startsWith(`type `)||n.startsWith(`typeof `))continue;let r=(n.split(/\s+as\s+/).at(-1)??``).trim();r!==``&&r!==`type`&&t.add(r)}n=i;continue}if(D(e,a,`async`)&&(a=E(e,a+5,r)),D(e,a,`function`)||D(e,a,`class`)||D(e,a,`const`)||D(e,a,`let`)||D(e,a,`var`)){let i=D(e,a,`function`)?8:D(e,a,`class`)||D(e,a,`const`)?5:3,o=E(e,a+i,r);e.charCodeAt(o)===42&&(o=E(e,o+1,r));let s=hn(e,o,r);s&&t.add(s.name),n=s?.end??o+1;continue}n++}return[...t]}function xn(e,t,n){let r=t,i=0;for(;r<n;){let t=e.charCodeAt(r);if(t===39||t===34||t===96){r=sn(e,r,n,t);continue}if(t===47&&e.charCodeAt(r+1)===47){r=an(e,r,n);continue}if(t===47&&e.charCodeAt(r+1)===42){r=on(e,r,n);continue}if(t===123){i++,r++;continue}if(t===125){if(i--,r++,i===0)return r;continue}r++}return r}function Sn(e){return mn(e).topLevelUseServer}function Cn(e){return mn(e).hasDefaultExport}function wn(e){return e===40||e===91||e===123||e===44||e===59||e===61||e===58||e===63||e===33||e===43||e===45||e===42||e===37||e===38||e===124||e===94||e===126||e===60||e===62}function Tn(e,t){let n=t-1;for(;n>=0;){let t=e.charCodeAt(n);if(en(t)){n--;continue}if(n>=1&&t===47&&e.charCodeAt(n-1)===42){for(n-=2;n>=1;){if(e.charCodeAt(n)===42&&e.charCodeAt(n-1)===47){n-=2;break}n--}if(n<0)return;continue}if(n>=1&&t===47&&e.charCodeAt(n-1)===47){n-=2;continue}let r=n;for(;r>=0&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13;)r--;let i=r+1;for(;i<n&&(e.charCodeAt(i)===32||e.charCodeAt(i)===9);)i++;if(i<n&&e.charCodeAt(i)===47&&e.charCodeAt(i+1)===47){n=i-1;continue}break}if(n<0||!T(e.charCodeAt(n)))return;let r=n;for(;n>=0&&T(e.charCodeAt(n));)n--;return e.slice(n+1,r+1)}function En(e,t){let n=t-1;for(;n>=0;){let t=e.charCodeAt(n);if(en(t)){n--;continue}if(n>=1&&t===47&&e.charCodeAt(n-1)===42){for(n-=2;n>=1;){if(e.charCodeAt(n)===42&&e.charCodeAt(n-1)===47){n-=2;break}n--}if(n<0)return-1;continue}if(n>=1&&t===47&&e.charCodeAt(n-1)===47){n-=2;continue}let r=n;for(;r>=0&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13;)r--;let i=r+1;for(;i<n&&(e.charCodeAt(i)===32||e.charCodeAt(i)===9);)i++;if(i<n&&e.charCodeAt(i)===47&&e.charCodeAt(i+1)===47){n=i-1;continue}return t}return-1}function Dn(e,t){let n=En(e,t);if(n===-1||wn(n))return!0;let r=Tn(e,t);return r!=null&&r!==``&&Zt.has(r)}const On=/* @__PURE__ */ new Set([`return`,`throw`,`case`,`default`,`else`,`do`,`typeof`,`void`,`yield`,`await`,`delete`]);function kn(e,t){let n=En(e,t);if(n===-1)return!0;if(T(n)||n>=48&&n<=57){let n=Tn(e,t);return n!=null&&n!==``&&On.has(n)}return n!==41&&n!==93&&n!==125}function An(e,t,n){if(!kn(e,t))return-1;let r=e.charCodeAt(t+1);if(r!==47&&r!==46&&r!==62&&!nn(r))return-1;let i=cn(e,t,n);return i<n&&e.charCodeAt(i)===62&&i++,i>t&&e.charCodeAt(i-1)===62?i:-1}function jn(e,t,n){t++;let r=!1;for(;t<n;){let i=e.charCodeAt(t);if(i===92){t+=2;continue}if(r){i===93&&(r=!1),t++;continue}if(i===91){r=!0,t++;continue}if(i===47){for(t++;t<n&&T(e.charCodeAt(t));)t++;return t}if(tn(i))return t;t++}return t}function Mn(e,t,n){if(t>=n)return-1;let r=e.charCodeAt(t);if(en(r))return t+1;if(r===47&&e.charCodeAt(t+1)===47)return an(e,t,n);if(r===47&&e.charCodeAt(t+1)===42)return on(e,t,n);if(r===39||r===34||r===96)return sn(e,t,n,r);if(r===47&&e.charCodeAt(t+1)!==47&&e.charCodeAt(t+1)!==42&&Dn(e,t))return jn(e,t,n);if(r===60){let r=An(e,t,n);if(r!==-1)return r}return-1}function Nn(e,t){let n=e.charCodeAt(t);return en(n)?!0:n===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42)}function Pn(e){let t=e.length,n=0;for(;n<t;){let r=Mn(e,n,t);if(r!==-1){n=r;continue}if(D(e,n,`export`)){let r=E(e,n+6,t);if(!D(e,r,`default`)){n++;continue}let i=E(e,r+7,t),a=i,o=null;if(D(e,a,`async`)){let n=E(e,a+5,t);D(e,n,`function`)&&(a=n)}if(D(e,a,`function`)||D(e,a,`class`)){let n=D(e,a,`function`)?8:5,r=E(e,a+n,t);e.charCodeAt(r)===42&&(r=E(e,r+1,t));let i=hn(e,r,t);i&&(o=i.name)}let s=Ln(e,i,t),c=gn(e,s,t);return{exportStart:n,valueStart:i,valueEnd:s,statementEnd:c,bindingName:o}}n++}return null}function Fn(e,t,n){if(t>=n)return!1;let r=e.charCodeAt(t),i=t+1<n?e.charCodeAt(t+1):-1;return r===46||r===63&&i===46||r===40||r===91||r===96||r===61&&i===62||r===43||r===45||r===42||r===47||r===37||r===38||r===124||r===94||r===60||r===62||r===61||r===33||r===63||r===58||r===44||r===126||D(e,t,`instanceof`)||D(e,t,`in`)||D(e,t,`of`)||D(e,t,`as`)}const In=/* @__PURE__ */ new Set([`typeof`,`void`,`delete`,`await`,`yield`,`new`]);function Ln(e,t,n){let r=t,i=0,a=0,o=0,s=!1;for(;r<n;){let t=e.charCodeAt(r);if(t===39||t===34||t===96){r=sn(e,r,n,t),s=!0;continue}if(t===47&&e.charCodeAt(r+1)===47){r=an(e,r,n);continue}if(t===47&&e.charCodeAt(r+1)===42){r=on(e,r,n);continue}if(t===47&&e.charCodeAt(r+1)!==47&&e.charCodeAt(r+1)!==42&&Dn(e,r)){r=jn(e,r,n),s=!0;continue}if(t===60&&i===0&&a===0&&o===0){let t=An(e,r,n);if(t!==-1){r=t,s=!0;continue}}if(t===40){i++,s=!1,r++;continue}if(t===41){i=Math.max(0,i-1),s=!0,r++;continue}if(t===123){a++,s=!1,r++;continue}if(t===125){if(a=Math.max(0,a-1),s=!0,r++,i===0&&a===0&&o===0)return r;continue}if(t===91){o++,s=!1,r++;continue}if(t===93){o=Math.max(0,o-1),s=!0,r++;continue}if(i===0&&a===0&&o===0){if(t===59)return r;if(tn(t)){let t=E(e,r+1,n);if(!s||Fn(e,t,n)){r++;continue}return r}}if(nn(t)){let t=hn(e,r,n);if(t){s=!In.has(t.name),r=t.end;continue}}if(t>=48&&t<=57){for(s=!0,r++;r<n;){let t=e.charCodeAt(r);if(t>=48&&t<=57||t===46||t===110||t===101||t===69){r++;continue}break}continue}if(t===61&&e.charCodeAt(r+1)===62){s=!1,r+=2;continue}if(t===46||t===44||t===58||t===63||t===61||t===43||t===45||t===42||t===47||t===37||t===38||t===124||t===94||t===33||t===126||t===60||t===62){s=!1,r++;continue}r++}return r}function Rn(e,t){let n=Pn(e);if(n==null||n.bindingName!=null)return null;let r=`const ${t} = ${e.slice(n.valueStart,n.valueEnd).trimEnd()};\nexport default ${t}${e.slice(n.statementEnd)}`;return e.slice(0,n.exportStart)+r}const zn=/* @__PURE__ */ new Set([`node_modules`,`.git`,`.cache`,`dist`]);function Bn(e,t){let n=/* @__PURE__ */ new Set,r=e=>{if(!b.existsSync(e))return;let i=b.readdirSync(e,{withFileTypes:!0});for(let a of i){let i=S.join(e,a.name);if(a.isDirectory()){if(zn.has(a.name))continue;r(i)}else if(a.isFile()&&v.test(a.name)){if(n.has(i))continue;n.add(i),t(i)}}};for(let t of e)t&&b.existsSync(t)&&r(t)}function Vn(e){let t=[];return Bn(e,e=>{t.push(e)}),t}function Hn(e,t=[]){let n=[e],r=S.resolve(e);for(let e of t){if(!e)continue;let t=S.resolve(e);if(t===r)continue;let i=S.relative(r,t);if(i!==``&&(i.startsWith(`..`)||S.isAbsolute(i)))try{b.statSync(e).isDirectory()&&n.push(e)}catch{}}return n}const Un=new Set(Te);function Wn(e){return Un.has(e)}function Gn(e){for(let t of e.importSources)if(t.startsWith(`node:`)||Wn(t))return!0;return!1}function Kn(e,t=Un){let n=[];for(let r of e)!r.startsWith(`.`)&&!r.startsWith(`/`)&&!r.startsWith(`@/`)&&!r.startsWith(`node:`)&&!t.has(r)&&n.push(r);return[...new Set(n)]}function qn(e){let t=[];for(let n of e)(n.startsWith(`./`)||n.startsWith(`../`)||n.startsWith(`@/`))&&t.push(n);return t}function Jn(e){try{return b.realpathSync(e)}catch{return S.resolve(e)}}function Yn(e,t){e.delete(t);try{e.delete(b.realpathSync(t))}catch{e.delete(S.resolve(t))}}function Xn(e,t){let n=[];for(let r of Vn(e))try{t.get(r).directives.hasUseClient&&n.push(r)}catch{}return n}var Zn=class{cache=/* @__PURE__ */ new Map;get(e,t){let n=Jn(e),r=this.cache.get(n);if(t!==void 0){if(r?.source===t)return r.analysis}else if(r){let e=this.readMtimeMs(n);if(e>=0&&r.mtimeMs===e)return r.analysis}t??=b.readFileSync(n,`utf-8`);let i=this.readMtimeMs(n),a=mn(t);return this.cache.set(n,{mtimeMs:i,source:t,analysis:a}),a}getSource(e){return this.get(e),this.cache.get(Jn(e)).source}invalidate(e){Yn(this.cache,e)}clear(){this.cache.clear()}readMtimeMs(e){try{return b.statSync(e).mtimeMs}catch{return-1}}};function Qn(e){return e.code===`MODULE_LEVEL_DIRECTIVE`&&(e.message?.includes(`use client`)===!0||e.message?.includes(`use server`)===!0)}function $n(){return{name:`rari:silence-react-directive-logs`,onLog(e,t){return!Qn(t)&&void 0}}}const er=`virtual:rari-entry-client`,tr=/^layout\.(?:tsx|ts|jsx|js)$/,nr=/\.css(?:\?.*)?$/,rr=/* @__PURE__ */ new Set;function ir(){rr.clear()}function ar(e){let t=e.trim();t!==``&&rr.add(t)}function or(){return[...rr]}function sr(e,t,n,r){let i=e.replace(/[?#].*$/,``);if(!nr.test(i))return null;if(i.startsWith(`./`)||i.startsWith(`../`)){let e=S.resolve(S.dirname(t),i);return!b.existsSync(e)||!b.statSync(e).isFile()?null:e}let a=xe(i,r,n);return a!=null&&a!==``&&b.existsSync(a)&&b.statSync(a).isFile()?a:i}function cr(e,t,n,r){if(b.existsSync(e))for(let i of b.readdirSync(e,{withFileTypes:!0})){let a=S.join(e,i.name);if(i.isDirectory()){cr(a,t,n,r);continue}if(!i.isFile()||!tr.test(i.name))continue;let o=b.readFileSync(a,`utf-8`);for(let e of yn(o)){let i=sr(e.source,a,t,n);i!=null&&r.add(i)}}}function lr(e,t={}){let n=/* @__PURE__ */ new Set;return cr(S.join(e,`src`,`app`),e,t,n),n}function ur(e,t){if(!S.isAbsolute(e))return e.startsWith(`/`)?e:`/${e}`;let n=y(S.relative(t,e));return n.startsWith(`..`)||S.isAbsolute(n)?`/@fs/${e}`:`/${n}`}function dr(e,t={}){return[...lr(e,t)].sort().map(t=>ur(t,e))}function fr(e,t){if(!S.isAbsolute(e))return e;let n=y(S.relative(t,e));return n.startsWith(`..`)||S.isAbsolute(n)?e:`/${n}`}function pr(e,t={}){return[...lr(e,t)].sort().map(t=>`import ${JSON.stringify(fr(t,e))};`).join(`
52
- `)}function mr(e){return e.startsWith(`/`)?e:`/${e}`}function hr(e){let t=[...or()],n=new Set(t),r=e=>{n.has(e)||(n.add(e),t.push(e))},i=!1;for(let[t,n]of Object.entries(e)){if(n.type!==`chunk`||n.isEntry!==!0)continue;let e=n.viteMetadata?.importedCss;if(e){let t=[...e];t.length>0&&(i=!0);for(let e of t)r(`<link rel="stylesheet" href="${mr(e)}" />`)}r(`<script type="module" src="${mr(t)}"><\/script>`)}if(!i)for(let[t,n]of Object.entries(e))n.type===`asset`&&t.endsWith(`.css`)&&!t.includes(`/server/`)&&r(`<link rel="stylesheet" href="${mr(t)}" />`);return t.length>0?`${t.join(`
53
- `)}\n`:``}function gr(e,t={}){let n=S.extname(e),r=n.toLowerCase(),i=r===``?t.defaultExt??``:r,a=S.basename(e,n);return t.sanitizeBase&&(a=a.replaceAll(/[?#]/g,`_`)),t.encodeBase&&(a=encodeURIComponent(a)),{base:a,ext:i}}function _r(e,t,n,r={}){let{base:i,ext:a}=gr(e,r);return`${fe(n)}/${i}-${t}${a}`}function vr(e,t,n,r={}){return`/${_r(e,t,n,r)}`}function yr(e){return`/${e.split(S.sep).join(`/`)}`}function br(e,t,n){return _r(e,t,n,{defaultExt:`.woff2`,sanitizeBase:!0})}function xr(e){return yr(e)}function Sr(e){b.mkdirSync(e,{recursive:!0})}function Cr(e,t){return`${e}_${t}`}function wr(e){return`${(e*100).toFixed(2)}%`}function Tr(e,t){if(!Number.isFinite(e.unitsPerEm)||e.unitsPerEm===0||!Number.isFinite(e.xWidthAvg))return null;let n=t===`Times New Roman`?Ie:Fe;if(!Number.isFinite(n.unitsPerEm)||n.unitsPerEm===0||!Number.isFinite(n.xWidthAvg))return null;let r=e.xWidthAvg/e.unitsPerEm,i=n.xWidthAvg/n.unitsPerEm;if(!Number.isFinite(i)||i===0)return null;let a=r/i;return!Number.isFinite(a)||a===0?null:{fallbackFont:t,sizeAdjust:wr(a),ascentOverride:wr(e.ascent/e.unitsPerEm/a),descentOverride:wr(Math.abs(e.descent)/e.unitsPerEm/a),lineGapOverride:wr(e.lineGap/e.unitsPerEm/a)}}async function Er(e){let t=e.replaceAll(/\s+/g,``).replace(/^(.)/,e=>e.toLowerCase());try{let e=await import(`@capsizecss/metrics/${t}`);if(typeof e!=`object`||!e||!(`default`in e))return null;let n=e.default;return typeof n!=`object`||!n||!(`ascent`in n)||!(`descent`in n)||!(`lineGap`in n)||!(`unitsPerEm`in n)||!(`xWidthAvg`in n)||typeof n.ascent!=`number`||typeof n.descent!=`number`||typeof n.lineGap!=`number`||typeof n.unitsPerEm!=`number`||typeof n.xWidthAvg!=`number`?null:{ascent:n.ascent,descent:n.descent,lineGap:n.lineGap,unitsPerEm:n.unitsPerEm,xWidthAvg:n.xWidthAvg,category:`category`in n&&typeof n.category==`string`?n.category:void 0}}catch{return null}}function Dr(e){return e===`serif`?`Times New Roman`:`Arial`}const Or=/* @__PURE__ */ new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`]);function kr(e){return e===`serif`?`serif`:e===`monospace`?`monospace`:`sans-serif`}function Ar(e){return(e??[]).some(e=>Or.has(e))}function jr(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}function Mr(e,t){return`url("${jr(e)}") format("${t}")`}function Nr(e){let t=e.toLowerCase();return t.endsWith(`.woff2`)?`woff2`:t.endsWith(`.woff`)?`woff`:t.endsWith(`.ttf`)?`truetype`:t.endsWith(`.otf`)?`opentype`:`woff2`}function Pr(e){return e===`woff`?`font/woff`:e===`truetype`?`font/ttf`:e===`opentype`?`font/otf`:`font/woff2`}function Fr(e){let t=e.src.map(e=>Mr(e.url,e.format)).join(`, `),n=(e.declarations??[]).map(e=>` ${e.prop}: ${e.value};`).join(`
54
- `),r=`@font-face {\n font-family: "${jr(e.family)}";\n src: ${t};\n font-display: ${e.display};\n font-weight: ${e.weight};\n font-style: ${e.style};\n`;return e.unicodeRange!=null&&e.unicodeRange!==``&&(r+=` unicode-range: ${e.unicodeRange};\n`),n!==``&&(r+=`${n}\n`),r+=`}
55
- `,r}function Ir(e,t,n,r=`sans-serif`){let i=[`"${jr(e)}"`];n&&i.push(`"${jr(`${e} Fallback`)}"`);for(let e of t??[])i.push(e.includes(` `)?`"${jr(e)}"`:e);return Ar(t)||i.push(r),i.join(`, `)}function Lr(e){return e??`swap`}function Rr(e){return e==null?`400`:String(e)}function zr(e){return e??`normal`}const Br=/* @__PURE__ */ new Map,Vr=/* @__PURE__ */ new Map;function Hr(e){return!l(e)||!Array.isArray(e.familyMetadataList)?!1:e.familyMetadataList.every(e=>l(e)&&typeof e.family==`string`&&e.family!==``)}function Ur(e){let t=e.replace(/^\)\]\}'\n?/,``);return JSON.parse(t)}function Wr(e){return[...new Set(e)].sort((e,t)=>e.localeCompare(t))}function Gr(e){let t=Wr((e.subsets??[]).filter(e=>e!==`menu`&&e!==``)),n=(e.axes??[]).filter(e=>typeof e.tag==`string`&&e.tag!==``&&typeof e.min==`number`&&typeof e.max==`number`).map(e=>({tag:e.tag,min:e.min,max:e.max})).sort((e,t)=>e.tag.localeCompare(t.tag));return{family:e.family,subsets:t,axisRanges:n}}function Kr(e){if(!Hr(e))throw Error(`Unexpected fonts.google.com/metadata/fonts shape`);let t=/* @__PURE__ */ new Map;for(let n of e.familyMetadataList){let e=Gr(n);t.set(e.family,e)}return t}async function qr(e){let t=Br.get(e);if(t!=null)return t;let n=Vr.get(e);if(n!=null)return n;let r=Promise.resolve().then(async()=>{let t=S.join(e,`google-fonts-metadata.json`);if(b.existsSync(t))try{let n=Kr(Ur(b.readFileSync(t,`utf8`)));return Br.set(e,n),n}catch{try{b.unlinkSync(t)}catch{}}let n=await fetch(`https://fonts.google.com/metadata/fonts`,{headers:{"User-Agent":`rari-google-font-meta`},signal:AbortSignal.timeout(3e4)});if(!n.ok)throw Error(`Failed to fetch Google font metadata: ${n.status} ${n.statusText}`);let r=await n.text(),i=Kr(Ur(r));return Sr(e),b.writeFileSync(t,r.replace(/^\)\]\}'\n?/,``)),Br.set(e,i),i});return Vr.set(e,r),r.finally(()=>{Vr.get(e)===r&&Vr.delete(e)})}async function Jr(e,t){try{return(await qr(e)).get(t)??null}catch(e){return console.warn(`[rari/font] Failed to load Google font metadata for ${t}:`,e),null}}function Yr(e,t,n){let r=t.subsets!=null&&t.subsets.length>0,i=r?t.preload!==!1:t.preload===!0,a=t.subsets;if(i&&!r&&console.warn(`[rari/font] ${e}: \`preload\` is true but no \`subsets\` were specified. Specify subsets to avoid downloading unused glyphs, or set \`preload: false\`.`),a==null||a.length===0||n==null||n.length===0)return;let o=new Set(n.map(e=>e.toLowerCase())),s=[...new Set(a.map(e=>e.toLowerCase())).difference(o)];s.length!==0&&console.warn(`[rari/font] ${e}: unknown subset(s) ${s.map(e=>JSON.stringify(e)).join(`, `)}. Available: ${n.join(`, `)}`)}const Xr=1e4,Zr=/* @__PURE__ */ new Set([`fonts.gstatic.com`]);function Qr(e){let t=URL.parse(e);if(t==null)throw Error(`Invalid Google font URL: ${e}`);if(t.protocol!==`https:`)throw Error(`Google font URL must use HTTPS: ${e}`);if(!Zr.has(t.hostname))throw Error(`Google font URL host not allowlisted (${t.hostname}): ${e}. Allowed: ${[...Zr].join(`, `)}`);return t}function $r(e){return e.subsets!=null&&e.subsets.length>0?e.preload!==!1:e.preload===!0}function ei(e){return e.trim().replaceAll(` `,`+`)}function ti(e){if(e==null)return[`400`];if(Array.isArray(e)){let t=e.map(String);return t.length>0?t:[`400`]}return[String(e)]}const ni=/^(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)$/;function ri(e){return ni.test(e.trim())}function ii(e){return e===`variable`||typeof e==`string`&&ri(e)?!0:Array.isArray(e)?e.some(e=>e===`variable`||typeof e==`string`&&ri(e)):!1}function ai(e){if(typeof e==`string`){let t=ni.exec(e.trim());if(t!=null)return`${t[1]}..${t[2]}`}if(Array.isArray(e))for(let t of e){if(typeof t!=`string`)continue;let e=ni.exec(t.trim());if(e!=null)return`${e[1]}..${e[2]}`}return`100..900`}function oi(e,t){if(e==null)return null;let n=e.find(e=>e.tag===t);return n==null?null:`${n.min}..${n.max}`}function si(e,t){if(ii(e)){if(typeof e==`string`&&ri(e))return ai(e);if(Array.isArray(e)){for(let t of e)if(typeof t==`string`&&ri(t))return ai(t)}return oi(t,`wght`)??ai(e)}if(e!=null){let t=ti(e);if(t.length===1)return`${t[0]}..${t[0]}`}return oi(t,`wght`)??`100..900`}function ci(e){if(e==null)return[`normal`];if(typeof e==`string`)return[e];let t=e.filter(e=>e!==``);return t.length>0?[...t]:[`normal`]}function li(e){let t=(e.axes??[]).map(e=>e.trim()).filter(Boolean),n=[];for(let e of t)n.includes(e)||n.push(e);return n}function ui(e){return e==null||ii(e)?null:ti(e)}function di(e,t,n){let r=ei(e),i=Lr(t.display),a=ci(t.style),o=a.includes(`italic`),s=a.includes(`normal`)||!o,c=li(t),l=ii(t.weight)||c.length>0,u;if(l){let e=[`wght`,...c.filter(e=>e!==`wght`&&e!==`ital`)].sort((e,t)=>e.localeCompare(t)),r=ui(t.weight),i=(e,t)=>e===`wght`?t:oi(n,e)??`1..1000`;if(r!=null){let t=r.map(t=>e.map(e=>i(e,t)).join(`,`));u=o&&s?`ital,${e.join(`,`)}@${[...t.map(e=>`0,${e}`),...t.map(e=>`1,${e}`)].join(`;`)}`:o?`ital,${e.join(`,`)}@${t.map(e=>`1,${e}`).join(`;`)}`:e.length===1&&e[0]===`wght`?`wght@${r.join(`;`)}`:`${e.join(`,`)}@${t.join(`;`)}`}else{let r=si(t.weight,n),a=e.map(e=>i(e,r));u=o&&s?`ital,${e.join(`,`)}@0,${a.join(`,`)};1,${a.join(`,`)}`:o?`ital,${e.join(`,`)}@1,${a.join(`,`)}`:e.length===1&&e[0]===`wght`?`wght@${a[0]}`:`${e.join(`,`)}@${a.join(`,`)}`}}else{let e=ti(t.weight);u=o&&s?`ital,wght@${[...e.map(e=>`0,${e}`),...e.map(e=>`1,${e}`)].join(`;`)}`:o?`ital,wght@${e.map(e=>`1,${e}`).join(`;`)}`:`wght@${e.join(`;`)}`}return`https://fonts.googleapis.com/css2?family=${r}:${u}&display=${i}`}function fi(e){let t=[],n=e.split(`@font-face`);for(let e=1;e<n.length;e+=1){let r=n[e-1]??``,i=n[e]??``,a=i.indexOf(`{`),o=i.indexOf(`}`,a);if(a===-1||o===-1)continue;let s=i.slice(a+1,o),c=/\/\*\s*([\w-]+)\s*\*\/\s*$/.exec(r)?.[1]??null,l=/font-family:\s*'([^']+)'/.exec(s)?.[1]??/font-family:\s*"([^"]+)"/.exec(s)?.[1],u=/font-style:\s*([^;\s]+)\s*;/.exec(s)?.[1]??`normal`,d=/font-weight:([^;]+);/.exec(s)?.[1]?.trim()??`400`,f=/src:\s*url\(([^)]+)\)/.exec(s)?.[1]?.replaceAll(/['"]/g,``),p=/unicode-range:([^;]+);/.exec(s)?.[1]?.trim()??null;l!=null&&f!=null&&f!==``&&t.push({family:l,style:u,weight:d,url:f,subset:c,unicodeRange:p})}return t}function pi(e,t){if(t==null||t.length===0)return[...e];let n=new Set(t.map(e=>e.toLowerCase()));return e.filter(e=>e.subset!=null&&n.has(e.subset.toLowerCase()))}async function mi(e,t){if(b.existsSync(t))return b.readFileSync(t);let n=Qr(e).href,r=null;for(let e=0;e<=3;e+=1){let e=await fetch(n,{signal:AbortSignal.timeout(Xr),redirect:`manual`});if(e.status>=300&&e.status<400){let t=e.headers.get(`location`);if(t==null||t===``)throw Error(`Font download redirect missing Location from ${n}`);n=Qr(new URL(t,n).href).href;continue}r=e;break}if(r==null)throw Error(`Too many redirects downloading font ${e}`);if(!r.ok)throw Error(`Failed to download font ${e}: ${r.status} ${r.statusText}`);let i=Buffer.from(await r.arrayBuffer());return Sr(S.dirname(t)),b.writeFileSync(t,i),i}async function hi(e,t,n){let r=await Jr(n,e);Yr(e,t,r?.subsets);let i=di(e,t,r?.axisRanges),a=S.join(n,`${qt(i)}.css`),o;if(b.existsSync(a))o=b.readFileSync(a,`utf8`);else{let t=await fetch(i,{headers:{"User-Agent":`Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36`},signal:AbortSignal.timeout(Xr)});if(!t.ok)throw Error(`Failed to fetch Google Font CSS for ${e}: ${t.status} ${t.statusText}`);o=await t.text(),Sr(n),b.writeFileSync(a,o)}let s=pi(fi(o),t.subsets);if(s.length===0)throw Error(`No @font-face rules returned for Google font "${e}"`);let c=Lr(t.display),l=$r(t),u=[];for(let r of s){let i=Qr(r.url),a=qt(r.url),o=S.extname(i.pathname)||`.woff2`,s=`${e.replaceAll(/\s+/g,``)}-${r.weight}-${r.style}-${a}${o}`,d=S.join(n,s);await mi(r.url,d),u.push({family:r.family,style:zr(r.style),weight:Rr(r.weight),display:c,src:[{url:``,format:Nr(d)}],preload:l,variable:t.variable,fallback:t.fallback,adjustFontFallback:t.adjustFontFallback!==!1&&void 0,unicodeRange:r.unicodeRange??void 0,filePaths:[d]})}return u}function gi(e){return e.replaceAll(`_`,` `)}function _i(e){return typeof e==`string`?[{path:e}]:e.map(e=>({...e}))}function vi(e,t,n){let r=Lr(e.display),i=e.preload!==!1,a=_i(e.src);if(a.length===0)throw Error("rari/font/local: `src` must include at least one font file");let o=a.map(r=>{let i=S.isAbsolute(r.path)?r.path:S.resolve(t,r.path);if(!b.existsSync(i))throw Error(`rari/font/local: font file not found: ${r.path} (from ${t})`);let a=S.relative(n,i);if(a.startsWith(`..`)||S.isAbsolute(a))throw Error(`rari/font/local: font file must be inside the project: ${r.path}`);return{absolute:i,weight:Rr(r.weight??e.weight),style:zr(r.style??e.style),familyBase:S.basename(i,S.extname(i))}}),s=o[0].familyBase;return o.map(t=>({family:s,style:t.style,weight:t.weight,display:r,src:[{url:``,format:Nr(t.absolute)}],preload:i,variable:e.variable,fallback:e.fallback,adjustFontFallback:e.adjustFontFallback,declarations:e.declarations,filePaths:[t.absolute]}))}function yi(e,t){if(e[t]!==`{`)return null;try{let{json:n,end:r}=xi(e,t);return typeof n!=`object`||!n||Array.isArray(n)?null:{value:n,end:r}}catch{return null}}function bi(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]??``);)n+=1;return n}function xi(e,t){let n=bi(e,t),r=e[n];if(r===`{`)return Ti(e,n);if(r===`[`)return wi(e,n);if(r===`'`||r===`"`)return Si(e,n);if(r===`-`||r>=`0`&&r<=`9`)return Ci(e,n);if(e.startsWith(`true`,n))return{json:!0,end:n+4};if(e.startsWith(`false`,n))return{json:!1,end:n+5};if(e.startsWith(`null`,n))return{json:null,end:n+4};throw Error(`Unsupported token at ${n}`)}function Si(e,t){let n=e[t],r=t+1,i=``;for(;r<e.length;){let t=e[r];if(t===`\\`){if(r+1>=e.length)throw Error(`Unterminated string escape`);i+=e[r+1],r+=2;continue}if(t===n)return{json:i,end:r+1};i+=t,r+=1}throw Error(`Unterminated string`)}function Ci(e,t){let n=/^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?/i.exec(e.slice(t));if(n==null)throw Error(`Invalid number`);return{json:Number(n[0]),end:t+n[0].length}}function wi(e,t){let n=[],r=bi(e,t+1);if(e[r]===`]`)return{json:n,end:r+1};for(;r<e.length;){let t=xi(e,r);if(n.push(t.json),r=bi(e,t.end),e[r]===`,`){if(r=bi(e,r+1),e[r]===`]`)return{json:n,end:r+1};continue}if(e[r]===`]`)return{json:n,end:r+1};throw Error(`Expected comma or ]`)}throw Error(`Unterminated array`)}function Ti(e,t){let n={},r=bi(e,t+1);if(e[r]===`}`)return{json:n,end:r+1};for(;r<e.length;){let t;if(e[r]===`'`||e[r]===`"`){let n=Si(e,r);t=n.json,r=bi(e,n.end)}else{let n=/^[A-Z_$][\w$]*/i.exec(e.slice(r));if(n==null)throw Error(`Expected property name`);t=n[0],r=bi(e,r+t.length)}if(e[r]!==`:`)throw Error(`Expected :`);let i=xi(e,r+1);if(n[t]=i.json,r=bi(e,i.end),e[r]===`,`){if(r=bi(e,r+1),e[r]===`}`)return{json:n,end:r+1};continue}if(e[r]===`}`)return{json:n,end:r+1};throw Error(`Expected comma or }`)}throw Error(`Unterminated object`)}const Ei=`rari/font/local`,Di=`rari/font/google`,Oi=`\0rari-font-css:`,ki=/\.(?:woff2?|ttf|otf)$/i;function Ai(e){if(e!=null){if(typeof e==`string`)return[e];if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}}function ji(e){if(e===`auto`||e===`block`||e===`swap`||e===`fallback`||e===`optional`)return e}function Mi(e){let t=e.src,n;if(typeof t==`string`)n=t;else if(Array.isArray(t))n=t.map(e=>{if(typeof e==`string`)return{path:e};if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`rari/font/local: invalid src entry`);let t=e.path;if(typeof t!=`string`)throw Error(`rari/font/local: src.path must be a string`);return{path:t,weight:typeof e.weight==`string`||typeof e.weight==`number`?e.weight:void 0,style:typeof e.style==`string`?e.style:void 0}});else throw TypeError("rari/font/local: `src` is required");return{src:n,display:ji(e.display),weight:typeof e.weight==`string`||typeof e.weight==`number`?e.weight:void 0,style:typeof e.style==`string`?e.style:void 0,variable:typeof e.variable==`string`?e.variable:void 0,preload:typeof e.preload==`boolean`?e.preload:void 0,fallback:Ai(e.fallback),adjustFontFallback:e.adjustFontFallback===!1?!1:e.adjustFontFallback===`Arial`||e.adjustFontFallback===`Times New Roman`?e.adjustFontFallback:void 0,declarations:Ni(e.declarations)}}function Ni(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(typeof n!=`object`||!n||Array.isArray(n))continue;let e=n.prop,r=n.value;typeof e==`string`&&typeof r==`string`&&t.push({prop:e,value:r})}return t.length>0?t:void 0}function Pi(e){let t=e.weight,n=e.style;return{weight:typeof t==`string`||typeof t==`number`?t:Array.isArray(t)?t.filter(e=>typeof e==`string`||typeof e==`number`):void 0,style:typeof n==`string`?n:Array.isArray(n)?n.filter(e=>typeof e==`string`):void 0,subsets:Ai(e.subsets),display:ji(e.display),variable:typeof e.variable==`string`?e.variable:void 0,preload:typeof e.preload==`boolean`?e.preload:void 0,fallback:Ai(e.fallback),adjustFontFallback:typeof e.adjustFontFallback==`boolean`?e.adjustFontFallback:void 0,axes:Ai(e.axes)}}function Fi(e,t){let n=0;for(let r=t;r<e.length;r+=1){let t=e[r];if(t===`(`)n+=1;else if(t===`)`&&(--n,n===0))return r}return-1}async function Ii(e,t,n){let r=[],i=[],a=[];for(let o of e){if(o.filePaths.length===0)continue;let e=o.filePaths[0],s=b.readFileSync(e),c=qt(s);a.push(c);let l=br(e,c,t);r.push({fileName:l,source:s}),i.push({...o,family:n,src:[{url:xr(l),format:o.src[0]?.format??`woff2`}]})}if(i.length===0)throw Error(`rari/font: no font files resolved`);let o=i[0],s=JSON.stringify({display:o.display,weight:i.map(e=>e.weight),style:i.map(e=>e.style),fallback:o.fallback??null,adjustFontFallback:o.adjustFontFallback??null,declarations:o.declarations??null,unicodeRange:i.map(e=>e.unicodeRange??null),variable:o.variable??null}),c=qt(`${a.join(`|`)}|${n}|${s}`),l=Cr(`rari_font`,c),u=o.variable==null?null:Cr(`rari_font_var`,c),d=null,f=await Er(n);if(o.adjustFontFallback!==!1){let e=o.adjustFontFallback===`Arial`||o.adjustFontFallback===`Times New Roman`?o.adjustFontFallback:null;if(f==null)try{let e=await Pe(b.readFileSync(o.filePaths[0]));f={ascent:e.ascent,descent:e.descent,lineGap:e.lineGap,unitsPerEm:e.unitsPerEm,xWidthAvg:e.xWidthAvg}}catch{f=null}f!=null&&(e??=Dr(f.category),d=Tr(f,e))}let p=``;for(let e of i)p+=Fr(e);d!=null&&(p+=`@font-face {\n font-family: "${n} Fallback";\n src: local("${d.fallbackFont}");\n ascent-override: ${d.ascentOverride};\n descent-override: ${d.descentOverride};\n line-gap-override: ${d.lineGapOverride};\n size-adjust: ${d.sizeAdjust};\n}\n`);let m=Ir(n,o.fallback,d!=null,kr(f?.category));p+=`.${l} {\n font-family: ${m};\n}\n`,o.variable!=null&&u!=null&&(p+=`.${u} {\n ${o.variable}: ${m};\n}\n`);let h=Number(o.weight),g={className:l,style:{fontFamily:m,fontWeight:Number.isFinite(h)?h:o.weight,fontStyle:o.style===`normal`?void 0:o.style},variable:u??void 0},_=i.filter(e=>e.preload).flatMap(e=>e.src.map(e=>e.url)).filter(e=>e!==``);return{font:g,css:p,cssId:`${Oi}${c}.css`,assets:r,preloadUrls:_}}function Li(e){let t=[];for(let n=0;n<e.length;n+=1)t.push(!0);let n=(e,n)=>{for(let r=e;r<n;r+=1)t[r]=!1},r=0;for(;r<e.length;){let t=e.charCodeAt(r);if(t===47&&e.charCodeAt(r+1)===47){let t=r,i=e.indexOf(`
56
- `,r+2);r=i===-1?e.length:i,n(t,r);continue}if(t===47&&e.charCodeAt(r+1)===42){let t=r,i=e.indexOf(`*/`,r+2);r=i===-1?e.length:i+2,n(t,r);continue}if(t===34||t===39||t===96){let t=r;r=Ui(e,r),n(t,r);continue}r+=1}return t}function Ri(e,t){let n=Li(e),r=t.replaceAll(`/`,`\\/`),i=RegExp(`import\\s+(\\w+)\\s*,\\s*\\{([^}]+)\\}\\s*from\\s*['"]${r}['"]`,`g`),a=RegExp(`import\\s*\\{([^}]+)\\}\\s*from\\s*['"]${r}['"]`,`g`),o=RegExp(`import\\s+(\\w+)\\s*from\\s*['"]${r}['"]`,`g`),s=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.split(/\s+as\s+/),n=t[0]?.trim()??``;return{imported:n,local:t[1]?.trim()??n}}).filter(e=>e.imported!==``&&e.local!==``),c=[],l=[],u=[],d=e=>u.some(t=>e>=t.start&&e<t.end);for(let t of e.matchAll(i))n[t.index]&&!d(t.index)&&(u.push({start:t.index,end:t.index+t[0].length}),l.push(t[1]),c.push(...s(t[2])));for(let t of e.matchAll(a))n[t.index]&&!d(t.index)&&(u.push({start:t.index,end:t.index+t[0].length}),c.push(...s(t[1])));for(let t of e.matchAll(o))n[t.index]&&!d(t.index)&&(u.push({start:t.index,end:t.index+t[0].length}),l.push(t[1]));return{names:c.filter(e=>e.imported!==``),defaultNames:l.filter(e=>e!==``),statements:u}}function zi(e,t){let n=Li(e),r=t.replaceAll(`/`,`\\/`),i=RegExp(`import\\s+\\*\\s+as\\s+\\w+\\s+from\\s*['"]${r}['"]`,`g`),a=RegExp(`import\\s*['"]${r}['"]`,`g`);for(let t of e.matchAll(i))if(n[t.index])return!0;for(let t of e.matchAll(a))if(n[t.index])return!0;return!1}function Bi(e){let t=[`fontFamily: ${JSON.stringify(e.style.fontFamily)}`,e.style.fontWeight==null?null:`fontWeight: ${JSON.stringify(e.style.fontWeight)}`,e.style.fontStyle==null?null:`fontStyle: ${JSON.stringify(e.style.fontStyle)}`].filter(Boolean),n=e.variable==null?``:` variable: ${JSON.stringify(e.variable)},\n`;return`{\n className: ${JSON.stringify(e.className)},\n style: { ${t.join(`, `)} },\n${n}}`}function Vi(e){return e>=65&&e<=90||e>=97&&e<=122||e===36||e===95||e>=128}function Hi(e){return Vi(e)||e>=48&&e<=57}function Ui(e,t){let n=e.charCodeAt(t),r=t+1;if(n===96){for(;r<e.length;){let t=e.charCodeAt(r);if(t===92){r+=2;continue}if(t===96)return r+1;if(t===36&&e.charCodeAt(r+1)===123){r+=2;let t=1;for(;r<e.length&&t>0;){let n=e.charCodeAt(r);if(n===34||n===39||n===96){r=Ui(e,r);continue}if(n===47&&e.charCodeAt(r+1)===47){let t=e.indexOf(`
57
- `,r+2);r=t===-1?e.length:t+1;continue}if(n===47&&e.charCodeAt(r+1)===42){let t=e.indexOf(`*/`,r+2);r=t===-1?e.length:t+2;continue}n===123?t+=1:n===125&&--t,r+=1}continue}r+=1}return r}for(;r<e.length;){let t=e.charCodeAt(r);if(t===92){r+=2;continue}if(t===n)return r+1;r+=1}return r}function Wi(e,t){let n=[],r=0;for(;r<e.length;){let i=e.charCodeAt(r);if(i===47&&e.charCodeAt(r+1)===47){let t=e.indexOf(`
58
- `,r+2);r=t===-1?e.length:t+1;continue}if(i===47&&e.charCodeAt(r+1)===42){let t=e.indexOf(`*/`,r+2);r=t===-1?e.length:t+2;continue}if(i===34||i===39||i===96){r=Ui(e,r);continue}if(Vi(i)&&e.startsWith(t,r)){let i=r+t.length,a=r===0?0:e.charCodeAt(r-1);if((r===0||!Hi(a))&&(i>=e.length||!Hi(e.charCodeAt(i)))){let t=i;for(;t<e.length&&(e[t]===` `||e[t]===` `||e[t]===`
59
- `||e[t]===`\r`);)t+=1;if(e[t]===`(`){n.push({start:r,openParen:t}),r=t+1;continue}}}r+=1}return n}async function Gi(e,t,n,r){if(!e.includes(`rari/font/`))return null;let i=Ri(e,Ei),a=Ri(e,Di);if(zi(e,Ei)||zi(e,Di))throw Error("rari/font only supports default imports from `rari/font/local` and named imports from `rari/font/google` (optionally with `as`). Namespace and side-effect imports are not supported.");if(i.statements.length===0&&a.statements.length===0)return null;let o=e,s=[],c=[],l=[],u=/* @__PURE__ */ new Set,d=S.dirname(t),f=S.join(n,`node_modules`,`.cache`,`rari-fonts`),p=[...i.statements,...a.statements].map(e=>({start:e.start,end:e.end})),m=(e,t,n)=>{for(let e of p)e.start>=t&&(e.start+=n,e.end+=n)},h=async(e,t)=>{let n=t=>{throw Error(`rari/font: failed to transform \`${e}()\` call: ${t}`)};for(let r of Wi(o,e).sort((e,t)=>t.start-e.start)){let e=Fi(o,r.openParen);e===-1&&n(`unbalanced parentheses`);let i=o.slice(r.openParen+1,e).trim(),a=null,d=e+1;if(i.startsWith(`{`)){let e=o.indexOf(`{`,r.openParen),t=yi(o,e);if(t==null)n(`options must be a static object literal`);else{a=t.value;let e=t.end;for(;e<o.length&&/\s/.test(o[e]??``);)e+=1;o[e]!==`)`&&n(`options must be a static object literal`),d=e+1}}else i!==``&&n(`options must be a static object literal`);let f=await t(a);s.push({id:f.cssId,css:f.css}),u.add(f.cssId);for(let e of f.assets)c.push(e);for(let e of f.preloadUrls)l.includes(e)||l.push(e);let p=Bi(f.font);m(r.start,d,p.length-(d-r.start)),o=o.slice(0,r.start)+p+o.slice(d)}};for(let e of i.defaultNames)await h(e,async e=>{if(e==null)throw Error(`rari/font/local: options object required`);let t=vi(Mi(e),d,n),i=`Rari ${S.basename(t[0].filePaths[0],S.extname(t[0].filePaths[0]))}`;return Ii(t.map(e=>Object.assign({},e,{family:i})),r,i)});for(let e of a.names)await h(e.local,async t=>{let n=t==null?{}:Pi(t),i=gi(e.imported);return Ii(await hi(i,n,f),r,i)});let g=[...i.defaultNames,...a.names.map(e=>e.local)];for(let e of g)if(Wi(o,e).length>0)throw Error(`rari/font: failed to transform all \`${e}()\` calls; leaving imports in place`);for(let e of p.sort((e,t)=>t.start-e.start))o=o.slice(0,e.start)+o.slice(e.end);let _=[...u].map(e=>`import ${JSON.stringify(e)};`).join(`
60
- `);return _!==``&&(o=Ki(o,_)),o===e?null:{code:o,cssModules:s,assets:c,preloadUrls:l}}function Ki(e,t){let n=+(e.charCodeAt(0)===65279),r=0;for(;;){for(;n<e.length;){let t=e[n];if(t===` `||t===` `||t===`\r`||t===`
61
- `){n+=1;continue}if(t===`/`&&e[n+1]===`/`){let t=e.indexOf(`
62
- `,n+2);n=t===-1?e.length:t+1;continue}if(t===`/`&&e[n+1]===`*`){let t=e.indexOf(`*/`,n+2);n=t===-1?e.length:t+2;continue}break}let t=e[n];if(t!==`'`&&t!==`"`||!e.startsWith(`use client`,n+1)&&!e.startsWith(`use server`,n+1)||e[n+11]!==t)break;for(n+=12,e[n]===`;`&&(n+=1);n<e.length;){let t=e[n];if(t===` `||t===` `||t===`\r`||t===`
63
- `){n+=1;continue}break}r=n}return r===0?`${t}\n${e}`:`${e.slice(0,r)}${t}\n${e.slice(r)}`}function qi(){let e=process.cwd(),t=`assets`,n=S.join(e,`dist`),r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Set;return{name:`rari:font`,enforce:`pre`,configResolved(r){let i=Kt(r);e=i.projectRoot,t=i.assetsDir,n=i.outDir},resolveId(e){return e.startsWith(Oi)?e:null},load(e){return e.startsWith(Oi)?r.get(e)??null:null},async transform(n,o){let s=await Gi(n,o,e,t);if(s==null)return null;for(let e of s.cssModules)r.set(e.id,e.css);for(let e of s.assets)i.set(e.fileName,e.source);for(let e of s.preloadUrls){a.add(e);let t=S.extname(e).toLowerCase();ar(`<link rel="preload" href="${e}" as="font" type="${Pr(t===`.woff`?`woff`:t===`.ttf`?`truetype`:t===`.otf`?`opentype`:`woff2`)}" crossorigin />`)}return{code:s.code,map:null}},generateBundle(){for(let[e,t]of i)this.emitFile({type:`asset`,fileName:e,source:t})},configureServer(e){e.middlewares.use((e,t,r)=>{let a=e.url?.split(`?`)[0];if(a==null||a===``){r();return}let o;try{o=decodeURIComponent(a.replace(/^\//,``))}catch{r();return}let s=i.get(o);if(s!=null){let e=S.extname(o).toLowerCase();t.setHeader(`Content-Type`,e===`.woff`?`font/woff`:e===`.ttf`?`font/ttf`:e===`.otf`?`font/otf`:`font/woff2`),t.setHeader(`Cache-Control`,`no-cache`),t.end(s);return}let c=S.resolve(n,o),l;try{l=b.realpathSync(n)}catch{l=S.resolve(n)}let u;try{u=b.realpathSync(c)}catch{r();return}let d=S.relative(l,u);if(d.startsWith(`..`)||S.isAbsolute(d)){r();return}try{if(!b.statSync(u).isFile()||!ki.test(u)){r();return}}catch{r();return}let f=S.extname(u).toLowerCase();t.setHeader(`Content-Type`,f===`.woff`?`font/woff`:f===`.ttf`?`font/ttf`:f===`.otf`?`font/otf`:`font/woff2`),t.setHeader(`Cache-Control`,`no-cache`),b.createReadStream(u).pipe(t)})}}}var Ji=class extends Error{status;statusText;bodyPreview;constructor(e,t,n){super(`HTTP ${e}: ${t}`),this.name=`HttpError`,this.status=e,this.statusText=t,this.bodyPreview=n}};async function Yi(e){if(!e.ok){let t;try{t=await e.text()}catch{t=`<unable to read response body>`}let n=t.length>200?`${t.slice(0,200)}...`:t;throw new Ji(e.status,e.statusText,n)}}var Xi=class{errorCount=0;maxErrors;resetTimeout;resetTimer=null;lastError=null;constructor(e={}){this.maxErrors=e.maxErrors??5,this.resetTimeout=e.resetTimeout??3e4}recordError(e){this.errorCount++,this.lastError=e,this.resetTimer=Ce(this.resetTimer),this.resetTimer=setTimeout(()=>{this.reset()},this.resetTimeout),this.errorCount>=this.maxErrors&&this.handleMaxErrorsReached()}reset(){this.errorCount=0,this.lastError=null,this.resetTimer=Ce(this.resetTimer)}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}hasReachedMaxErrors(){return this.errorCount>=this.maxErrors}handleMaxErrorsReached(){console.error(`[rari] HMR: Maximum error count (${this.maxErrors}) reached. Consider restarting the dev server if issues persist.`)}dispose(){this.reset()}};function Zi(e,t,n){let r=new Set(t),i=/* @__PURE__ */ new Set,a=[...t];for(;a.length>0;){let t=a.pop();if(t==null)break;let o=e.get(t);if(o)for(let e of o)r.has(e)||(r.add(e),a.push(e),(n==null||n(e))&&i.add(e))}return i}function Qi(e){return l(e)&&e.success===!0&&typeof e.componentId==`string`&&typeof e.filePath==`string`&&typeof e.relativePath==`string`}function $i(e){return l(e)&&e.success===!1&&typeof e.filePath==`string`&&typeof e.relativePath==`string`&&a(e.error)}function ea(e){return e===`info`||e===`success`||e===`warning`||e===`error`}var ta=class{serverComponentBuilder;rustServerUrl;pendingUpdates=/* @__PURE__ */ new Map;pendingFiles=/* @__PURE__ */ new Set;batchTimer=null;DEBOUNCE_DELAY=200;errorHandler;logBatch=[];logBatchTimer=null;LOG_BATCH_DELAY=500;constructor(e,t=qe()){this.serverComponentBuilder=e,this.rustServerUrl=`http://localhost:${t}`,this.errorHandler=new Xi({maxErrors:5,resetTimeout:3e4})}getErrorCount(){return this.errorHandler.getErrorCount()}async handleClientComponentUpdate(e,t){let n=S.relative(C.cwd(),e);try{let r=t.moduleGraph.getModuleById(e);r?(t.moduleGraph.invalidateModule(r),this.errorHandler.reset()):this.queueLog(`warning`,`Client component module not found in graph: ${n}`)}catch(e){let t=s(e,String(e));this.queueLog(`error`,`Failed to update client component: ${n} - ${t}`),this.errorHandler.recordError(u(e))}return Promise.resolve()}async rebuildAndNotifyNow(e,t){this.serverComponentBuilder.invalidateBuildCacheFor(e);let n=await this.serverComponentBuilder.rebuildComponent(e);if(!n.success)throw Error(n.error!=null&&n.error!==``?n.error:`Build failed`);return await this.notifyRustServer(n.componentId,n.bundlePath),t?.hot.send(`rari:server-component-updated`,{id:n.componentId,t:Date.now()}),n}async handleServerComponentUpdate(e,t){this.pendingFiles.add(e);let n=this.pendingUpdates.get(e);return n&&(clearTimeout(n),this.pendingUpdates.delete(e)),this.batchTimer&&clearTimeout(this.batchTimer),this.batchTimer=setTimeout(()=>{(async()=>{let e=[...this.pendingFiles];if(this.pendingFiles.clear(),this.batchTimer=null,e.length===0)return;let n=this.collectDependentPageComponents(e);for(let e of n)this.serverComponentBuilder.invalidateBuildCacheFor(e);let r=[...e,...n],i=await Promise.allSettled(r.map(async e=>{let t=S.relative(C.cwd(),e);try{let n=await this.serverComponentBuilder.rebuildComponent(e);if(!n.success)throw Error(n.error!=null&&n.error!==``?n.error:`Build failed`);return await this.notifyRustServer(n.componentId,n.bundlePath),{success:!0,componentId:n.componentId,filePath:e,relativePath:t}}catch(n){return{success:!1,filePath:e,relativePath:t,error:u(n)}}})),a=[],o=[];if(i.forEach(e=>{e.status===`fulfilled`&&Qi(e.value)?a.push(e.value):e.status===`fulfilled`&&$i(e.value)?o.push(e.value):e.status===`rejected`&&o.push({filePath:``,relativePath:`unknown`,error:Error(String(e.reason))})}),a.length>0){let e=Date.now();a.forEach(({componentId:n})=>{t.hot.send(`rari:server-component-updated`,{id:n,t:e})}),this.errorHandler.reset(),t.ws.send({type:`custom`,event:`rari:hmr-error-cleared`,data:{t:e}})}if(o.length>0){let e=Date.now();o.forEach(({relativePath:n,error:r})=>{let i=r.message,a=(r.stack!=null&&r.stack!==``?r.stack:``).substring(0,500);this.queueLog(`error`,`Failed to rebuild: ${n} - ${i}`),this.errorHandler.recordError(r),t.ws.send({type:`custom`,event:`rari:hmr-error`,data:{msg:i,stack:a,file:n,t:e,count:this.errorHandler.getErrorCount(),max:5}})}),this.errorHandler.hasReachedMaxErrors()&&this.queueLog(`error`,`Maximum error count reached (${this.errorHandler.getErrorCount()}). Consider restarting the dev server if issues persist.`)}})()},this.DEBOUNCE_DELAY),Promise.resolve()}async notifyRustServer(e,t){let n=y(t);if(S.isAbsolute(t)){let e=y(S.relative(this.serverComponentBuilder.getProjectRoot(),t));if(e.startsWith(`..`)||S.isAbsolute(e))throw Error(`Bundle path must be inside the project root: ${t}`);n=e}try{let t=await fetch(`${this.rustServerUrl}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`reload-component`,component_id:e,bundle_path:n})});await Yi(t);let r=await t.text(),i;try{i=JSON.parse(r)}catch(e){throw Error(`Failed to parse server response (status ${t.status}): ${s(e,String(e))}. Response body: ${r.substring(0,200)}${r.length>200?`...`:``}`)}if(!l(i))throw Error(`Invalid server response (status ${t.status}): expected object, got ${typeof i}. Response body: ${r.substring(0,200)}${r.length>200?`...`:``}`);if(i.success!==!0){let e=typeof i.message==`string`&&i.message!==``?i.message:typeof i.error==`string`&&i.error!==``?i.error:`Component reload failed`;throw Error(e)}}catch(e){throw console.error(`[rari] HMR: Failed to notify Rust server:`,e),e}}collectDependentPageComponents(e){return[...Zi(this.serverComponentBuilder.getImportGraph(),e,e=>e.includes(`/app/`)||e.includes(`\\app\\`))]}detectComponentType(e){try{return this.serverComponentBuilder.getModuleAnalysis(e).topLevelUseClient?`client`:`server`}catch{return`unknown`}}queueLog(e,t){this.logBatch.push({type:e,message:t,timestamp:Date.now()}),this.logBatchTimer&&clearTimeout(this.logBatchTimer),this.logBatchTimer=setTimeout(()=>{this.flushLogs()},this.LOG_BATCH_DELAY)}flushLogs(){if(this.logBatch.length===0)return;let e=this.logBatch.reduce((e,t)=>(e[t.type]??=[],e[t.type].push(t),e),{});for(let[t,n]of Object.entries(e))if(ea(t)){if(n.length===1){let e=n[0];this.outputLog(t,e.message)}else{let e=n.map(e=>e.message).join(`
64
- • `);this.outputLog(t,`${n.length} updates:\n • ${e}`)}}this.logBatch=[],this.logBatchTimer=null}outputLog(e,t){let n=`[rari] HMR:`;switch(e){case`success`:console.warn(`\x1B[32m${n}\x1B[0m ${t}`);break;case`warning`:console.warn(`\x1B[33m${n}\x1B[0m ${t}`);break;case`error`:console.error(`\x1B[31m${n}\x1B[0m ${t}`);break;default:console.warn(`${n} ${t}`)}}dispose(){this.logBatchTimer&&(clearTimeout(this.logBatchTimer),this.flushLogs()),this.batchTimer&&=(clearTimeout(this.batchTimer),null);for(let e of this.pendingUpdates.values())clearTimeout(e);this.pendingUpdates.clear(),this.pendingFiles.clear(),this.errorHandler.dispose()}};function na(e,t){return e.readUInt16BE(t)}function ra(e,t){return e.readUInt32BE(t)}function ia(e,t){return e.readUInt32LE(t)}function aa(e){return e.length<24||e.toString(`ascii`,1,4)!==`PNG`?null:{width:ra(e,16),height:ra(e,20)}}function oa(e){if(e.length<10)return null;let t=e.toString(`ascii`,0,6);return t!==`GIF87a`&&t!==`GIF89a`?null:{width:e.readUInt16LE(6),height:e.readUInt16LE(8)}}function sa(e){if(e.length<4||e[0]!==255||e[1]!==216)return null;let t=2;for(;t+9<=e.length;){if(e[t]!==255){t+=1;continue}if(t+1>=e.length)return null;let n=e[t+1];if(t+=2,n>=192&&n<=195||n>=197&&n<=199||n>=201&&n<=203||n>=205&&n<=207){if(t+7>=e.length)return null;let n=na(e,t),r=e[t+7]??0,i=8+3*r;if(r<1||n<i||t+n>e.length)return null;let a=na(e,t+3),o=na(e,t+5);return o===0||a===0?null:{height:a,width:o}}if(n===217||n===218||t+1>=e.length)return null;let r=na(e,t);if(r<2)return null;t+=r}return null}function ca(e,t){return(e[t]??0)|(e[t+1]??0)<<8|(e[t+2]??0)<<16}function la(e){if(e.length<20||e.toString(`ascii`,0,4)!==`RIFF`||e.toString(`ascii`,8,12)!==`WEBP`)return null;let t=e.toString(`ascii`,12,16);if(t===`VP8X`&&e.length>=30)return{width:ca(e,24)+1,height:ca(e,27)+1};if(t===`VP8 `&&e.length>=30)return{width:e.readUInt16LE(26)&16383,height:e.readUInt16LE(28)&16383};if(t===`VP8L`&&e.length>=25){if(e[20]!==47)return null;let t=ia(e,21);return{width:(t&16383)+1,height:(t>>14&16383)+1}}return null}function ua(e,t,n){if(t+8>n)return null;let r=ra(e,t),i=e.toString(`ascii`,t+4,t+8),a=8;if(r===1){if(t+16>n)return null;r=Number(e.readBigUInt64BE(t+8)),a=16}else r===0&&(r=n-t);let o=t+r;return r<a||o>n?null:{type:i,headerSize:a,start:t,end:o}}function*da(e,t,n){let r=t;for(;r+8<=n;){let t=ua(e,r,n);if(t==null)return;yield t,r=t.end}}function fa(e,t){let n=t.start+t.headerSize;return n+4>t.end?null:{version:e[n]??0,flags:(e[n+1]??0)<<16|(e[n+2]??0)<<8|(e[n+3]??0),dataOffset:n+4}}function pa(e,t){let n=fa(e,t);return n==null||n.dataOffset+8>t.end?null:{width:ra(e,n.dataOffset),height:ra(e,n.dataOffset+4)}}function ma(e,t){let n=fa(e,t);return n==null?null:n.version===0?n.dataOffset+2>t.end?null:na(e,n.dataOffset):n.dataOffset+4>t.end?null:ra(e,n.dataOffset)}function ha(e,t){let n=fa(e,t);if(n==null||n.dataOffset+4>t.end)return null;let r=ra(e,n.dataOffset),i=n.dataOffset+4,a=/* @__PURE__ */ new Map,o=!!(n.flags&1);for(let s=0;s<r;s+=1){let r;if(n.version<1){if(i+2>t.end)return null;r=na(e,i),i+=2}else{if(i+4>t.end)return null;r=ra(e,i),i+=4}if(i+1>t.end)return null;let s=e[i]??0;i+=1;let c=[];for(let n=0;n<s;n+=1)if(o){if(i+2>t.end)return null;let n=na(e,i);i+=2,c.push(n&32767)}else{if(i+1>t.end)return null;let n=e[i]??0;i+=1,c.push(n&127)}a.set(r,c)}return a}function ga(e){for(let t of da(e,0,e.length))if(t.type===`meta`)return t;return null}function _a(e){if(e.length<12||e.toString(`ascii`,4,8)!==`ftyp`)return null;let t=ga(e);if(t==null)return null;let n=t.start+t.headerSize+4;if(n>t.end)return null;let r=null,i=/* @__PURE__ */ new Map,a=null,o=null;for(let s of da(e,n,t.end)){if(s.type===`pitm`){r=ma(e,s);continue}if(s.type===`iprp`)for(let t of da(e,s.start+s.headerSize,s.end))if(t.type===`ipco`){let n=1;for(let r of da(e,t.start+t.headerSize,t.end)){if(r.type===`ispe`){let t=pa(e,r);t!=null&&(i.set(n,t),o??=t)}n+=1}}else t.type===`ipma`&&(a=ha(e,t))}if(r!=null&&a!=null){let e=a.get(r);if(e!=null)for(let t of e){let e=i.get(t);if(e!=null)return e}}return o}function va(e){return e.length<4?null:e[0]===137&&e.toString(`ascii`,1,4)===`PNG`?aa(e):e[0]===255&&e[1]===216?sa(e):e.toString(`ascii`,0,3)===`GIF`?oa(e):e.toString(`ascii`,0,4)===`RIFF`?la(e):_a(e)}const ya=/\.(?:avif|gif|jpe?g|png|webp)$/i,ba=`\0rari-static-image:`,xa=/* @__PURE__ */ new Set([`raw`,`url`,`inline`,`no-inline`]);function Sa(e){let t=e.indexOf(`?`);return t===-1?[]:e.slice(t+1).split(`&`).map(e=>e.split(`=`)[0]??``).filter(Boolean)}function Ca(e){return Sa(e).includes(`rari-static-bypass`)}function wa(e){return Sa(e).some(e=>xa.has(e))}function Ta(e,t,n){return vr(e,t,n,{encodeBase:!0})}function Ea(e,t,n){return _r(e,t,n)}function Da(e,t,n){return`const src = ${JSON.stringify(e)};\nexport default {\n src,\n width: ${t},\n height: ${n},\n};\n`}function Oa(e){return ya.test(ue(e))&&!Ca(e)&&!wa(e)}function ka(e,t=`assets`){let n=b.readFileSync(e),r=qt(n),i=Ta(e,r,t),a=Ea(e,r,t),o=va(n);if(o==null)throw Error(`[rari] Unable to read dimensions for static image import: ${e}. Pass explicit width/height to <Image>, or convert the file to png/jpeg/webp/gif/avif.`);return{code:Da(i,o.width,o.height),publicPath:i,source:n,fileName:a}}const Aa=/* @__PURE__ */ new Map,ja=/* @__PURE__ */ new Map;function Ma(e,t){let n=Aa.get(e);if(n!=null)return n;let r=/* @__PURE__ */ new Map;if(b.existsSync(t))try{let e=d(b.readFileSync(t,`utf8`));if(e!=null)for(let[t,n]of Object.entries(e))typeof n==`string`&&r.set(t,n)}catch{}return Aa.set(e,r),r}function Na(e,t,n){for(let[r,i]of e)i===n&&r!==t&&e.delete(r);e.set(t,n)}function Pa(e,t){let n=new Set(t.values());for(let[r,i]of e){if(!b.existsSync(i)){e.delete(r);continue}n.has(i)&&t.get(r)!==i&&e.delete(r)}}function Fa(e){return S.join(e,`server`,`static-image-sources.json`)}function Ia(e,t){let r=Fa(e);if(t.size===0){try{b.unlinkSync(r)}catch(e){if(n(e)!==`ENOENT`)throw e}return}b.mkdirSync(S.dirname(r),{recursive:!0});let i=Object.fromEntries(t);b.writeFileSync(r,`${JSON.stringify(i,null,2)}\n`)}function La(e){ja.has(e)||ja.set(e,/* @__PURE__ */ new Map)}function Ra(e){let t=ja.get(e);if(t==null)return;let n=Ma(e,Fa(e));n.clear();for(let[e,r]of t)b.existsSync(r)&&n.set(e,r);Ia(e,n),ja.delete(e)}function za(e,t){let n=Ma(e,Fa(e));for(let[e,r]of t)n.set(e,r);let r=ja.get(e);if(r!=null){for(let[e,n]of t)Na(r,e,n);return}Pa(n,t),Ia(e,n)}function Ba(e,t){let n=!1;for(let[r,i]of e)i===t&&(e.delete(r),n=!0);return n}function Va(){let e=process.cwd(),t=S.join(e,`dist`),n=`assets`,r=!1,i=/* @__PURE__ */ new Map;return{name:`rari:static-image`,enforce:`pre`,configResolved(i){let a=Kt(i);e=a.projectRoot,t=a.outDir,n=a.assetsDir,r=i.command===`build`},buildStart(){r&&La(t)},async resolveId(e,t){if(t==null||t===``||!Oa(e))return null;let n=await this.resolve(e,t,{skipSelf:!0});if(n==null||n.id===``)return null;let r=ue(n.id);return b.existsSync(r)?ba+r:null},load(e){if(!e.startsWith(ba))return null;let r=e.slice(19),a=ka(r,n);return Na(i,a.publicPath,r),za(t,i),this.emitFile({type:`asset`,fileName:a.fileName,source:a.source}),a.code},watchChange(e,n){if(n.event!==`delete`)return;let r=ue(e);if(!Ba(i,r))return;let a=ja.get(t);a!=null&&Ba(a,r),za(t,i)},configureServer(e){e.middlewares.use((e,t,n)=>{let r=e.url?.split(`?`)[0];if(r==null||r===``){n();return}let a=r;try{a=decodeURIComponent(r)}catch{a=r}let o=i.get(r)??i.get(a);if(o==null||o===``){n();return}let s=S.extname(o).toLowerCase(),c=s===`.png`?`image/png`:s===`.gif`?`image/gif`:s===`.webp`?`image/webp`:s===`.avif`?`image/avif`:s===`.svg`?`image/svg+xml`:`image/jpeg`;t.setHeader(`Content-Type`,c),t.setHeader(`Cache-Control`,`no-cache`),b.createReadStream(o).on(`error`,()=>{t.headersSent||(t.statusCode=404),t.end()}).pipe(t)})}}}function Ha(e){let t=y(e);return t===`rari/mdx/registry`||t.startsWith(`rari/mdx/registry?`)?!0:t.endsWith(`/mdx/registry.ts`)||t.endsWith(`/mdx/registry.mts`)||t.endsWith(`/mdx/registry.mjs`)||t.endsWith(`/mdx/registry.js`)||t.endsWith(`/mdx/registry`)?t.includes(`/node_modules/rari/`)||t.includes(`/packages/rari/`):!1}function Ua(e,t){let n=e=>{if(b.existsSync(e))for(let r of b.readdirSync(e,{withFileTypes:!0})){let i=S.join(e,r.name);if(r.isDirectory()){if(r.name===`node_modules`||r.name===`.git`||r.name===`dist`)continue;n(i)}else r.isFile()&&r.name.endsWith(`.mdx`)&&t(i)}};for(let t of e)t&&b.existsSync(t)&&n(t)}function Wa(e){let t=/* @__PURE__ */ new Set;return Ua(e,e=>{try{let n=b.readFileSync(e,`utf-8`);for(let e of we(n))t.add(e)}catch{}}),t}function Ga(e,t){try{if(t.get(e).hasDefaultExport)return S.basename(e,S.extname(e));let n=t.getSource(e).match(oe);if(n?.[1]!=null&&n[1]!==``)return n[1]}catch{}return S.basename(e,S.extname(e))}function Ka(e){let t=Wa(e.contentDirs.map(t=>S.join(e.projectRoot,t)));if(t.size===0)return[];let n=Xn(e.componentScanDirs,e.cache),r=[],i=/* @__PURE__ */ new Set;for(let a of n){let n=Ga(a,e.cache);if(n==null||n===``||!t.has(n))continue;let o=Jt(a,e.projectRoot),s=o.startsWith(`/`)?o:`/${o}`,c=n.replace(/[^\w$]/g,`_`);i.has(c)&&(c=`${c}_${r.length}`),i.add(c),r.push({name:n,binding:c,importPath:s,moduleId:o,client:!0})}return r.sort((e,t)=>e.name.localeCompare(t.name))}function qa(e){let t=Ya(e.projectRoot,e.mdxOptions),n=e.srcDir??S.join(e.projectRoot,`src`),r=$a(e.projectRoot,t.componentsDir,Hn(n,Object.values(e.alias??{})));return Ka({projectRoot:e.projectRoot,componentsDir:t.componentsDir,contentDirs:t.contentDirs,cache:e.cache,componentScanDirs:r})}function Ja(e,t={}){let n=t.importStyle??`root-absolute`,r=t.mode??`vite`;return e.length===0?`import { defineMdxComponents } from 'rari/mdx/define'
44
+ };`,`edge $$FORM_ACTION return block`)}function Rt(e,t){let n=Lt(t);return It(Ft(e,Nt,n,`browser registerBoundServerReference`))}const zt=[`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react/compiler-runtime`,`react-dom/client`];function Bt(e){return u(e)&&typeof e.find==`string`&&typeof e.replacement==`string`}function Vt(e,t=new Set(zt)){let n={},r=e.resolve?.alias;if(Array.isArray(r))for(let e of r)Bt(e)&&!t.has(e.find)&&(n[e.find]=e.replacement);else if(u(r))for(let[e,i]of Object.entries(r))typeof i==`string`&&!t.has(e)&&(n[e]=i);return n}function Ht(e){return{projectRoot:e.root,outDir:k.resolve(e.root,e.build.outDir),assetsDir:w(e.build.assetsDir)}}function F(e,t=8){return ke(`sha256`).update(e).digest(`hex`).slice(0,t)}function Ut(e,t=A.cwd()){let n=k.isAbsolute(e)?e:k.resolve(t,e),r=k.relative(t,n);return k.isAbsolute(r)?T(n):T(r)}function Wt(e){return e.replace(S,``).replace(b,`_`).replace(ee,``)}function Gt(e,t=A.cwd()){let n=Ut(e,t);return`${Wt(n)}_${F(n)}`}const Kt=/* @__PURE__ */ new Set([`return`,`throw`,`case`,`typeof`,`instanceof`,`new`,`delete`,`void`,`in`,`of`]),qt=8232,Jt=8233;function I(e){return e===32||e===9||e===13||e===10||e===qt||e===Jt||e===65279}function Yt(e){return e===13||e===10||e===qt||e===Jt}function L(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function Xt(e){return e>=97&&e<=122||e>=65&&e<=90||e===95||e===36}function Zt(e,t,n){for(;t<n&&I(e.charCodeAt(t));)t++;return t}function R(e,t,n){for(;t<n;){let r=Zt(e,t,n);if(r!==t){t=r;continue}let i=e.charCodeAt(t);if(i===47&&e.charCodeAt(t+1)===47){t=Qt(e,t,n);continue}if(i===47&&e.charCodeAt(t+1)===42){t=$t(e,t,n);continue}break}return t}function Qt(e,t,n){for(;t<n&&!Yt(e.charCodeAt(t));)t++;return t}function $t(e,t,n){for(t+=2;t<n-1&&(e.charCodeAt(t)!==42||e.charCodeAt(t+1)!==47);)t++;return t+2}function z(e,t,n,r){for(t++;t<n;){let n=e.charCodeAt(t);if(n===92){t+=2;continue}if(n===r)return t+1;t++}return t}function en(e,t,n){for(;t<n;){let n=e.charCodeAt(t);if(L(n)||n===46||n===45)t++;else break}return t}function tn(e,t,n){t++;let r=1;for(;t<n&&r>0;){let i=e.charCodeAt(t);if(i===39||i===34||i===96){t=z(e,t,n,i);continue}i===123&&r++,i===125&&r--,t++}return t}function nn(e,t,n,r){let i=e.charCodeAt(t+1);if(i!==47&&i!==46&&i!==62&&!Xt(i))return{i:t+1,depth:r};let a=r;return i===47?(a--,t++):i!==33&&a++,t++,{i:en(e,t,n),depth:a}}function rn(e,t,n,r,i){let a=e.charCodeAt(t);return a===39||a===34||a===96?{i:z(e,t,n,a),depth:r}:a===123?{i:tn(e,t,n),depth:r}:a===47&&e.charCodeAt(t+1)===62?{i:t+2,depth:r-1}:a===62?{i:t+1,depth:i?r-1:r}:a===60?nn(e,t,n,r):{i:t+1,depth:r}}function an(e,t,n){t++;let r=e.charCodeAt(t)===47;r&&t++,t=en(e,t,n);let i=+!r;for(;t<n&&i>0;)({i:t,depth:i}=rn(e,t,n,i,r));return t}function on(e,t,n){for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;return!0}function B(e,t,n){if(t+n.length>e.length)return!1;for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;let r=t>0?e.charCodeAt(t-1):-1,i=t+n.length,a=i<e.length?e.charCodeAt(i):-1;return!(r!==-1&&L(r)||a!==-1&&L(a))}function sn(e,t,n){let r=R(e,t,n);if(r>=n)return null;let i=e.charCodeAt(r);if(i!==39&&i!==34)return null;let a=r+1,o=z(e,r,n,i);return o<=a?null:{source:e.slice(a,o-1),end:o}}function cn(e,t,n){for(t++;t<n&&L(e.charCodeAt(t));)t++;for(;t<n&&e.charCodeAt(t)===46;)for(t++;t<n&&L(e.charCodeAt(t));)t++;return t}function ln(e,t){return e===123||e===40||e===91?t+1:e===125||e===41||e===93?Math.max(0,t-1):t}function un(e,t,n){let r=0;for(;t<n&&(t=R(e,t,n),!(t>=n));){let i=e.charCodeAt(t);if(r===0&&B(e,t,`from`)){let r=sn(e,t+4,n);if(r)return{sources:[r.source],end:r.end};break}if(i===39||i===34||i===96){t=z(e,t,n,i);continue}r=ln(i,r),t++}return{sources:[],end:t}}function dn(e,t,n){if(!B(e,t,`import`))return{sources:[],end:t+6};let r=R(e,t+6,n);if(B(e,r,`type`)&&(r=R(e,r+4,n)),e.charCodeAt(r)===46)return{sources:[],end:cn(e,r,n)};if(e.charCodeAt(r)===40){r++;let t=sn(e,r,n);return t?{sources:[t.source],end:t.end}:{sources:[],end:r}}let i=sn(e,r,n);return i?{sources:[i.source],end:i.end}:un(e,r,n)}function fn(e,t){return e.charCodeAt(t)===101&&e.charCodeAt(t+1)===120&&e.charCodeAt(t+2)===112&&e.charCodeAt(t+3)===111&&e.charCodeAt(t+4)===114&&e.charCodeAt(t+5)===116}function pn(e,t){return e.charCodeAt(t)===100&&e.charCodeAt(t+1)===101&&e.charCodeAt(t+2)===102&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===117&&e.charCodeAt(t+5)===108&&e.charCodeAt(t+6)===116}function mn(e,t,n){e.sawFirstDirective||(e.sawFirstDirective=!0,e.topLevelUseClient=t,e.topLevelUseServer=n),t&&(e.directives.hasUseClient=!0),n&&(e.directives.hasUseServer=!0)}function hn(e,t,n){let r=t;for(;r<n;){let t=e.charCodeAt(r);if(I(t)&&!Yt(t)){r++;continue}if(Yt(t)||t===59)return{stillDirective:!0,nextI:r+1,endDirectivesPhase:!1};if(t===47&&e.charCodeAt(r+1)===47){r=Qt(e,r,n);continue}if(t===47&&e.charCodeAt(r+1)===42){r=$t(e,r,n);continue}return{stillDirective:!1,nextI:r,endDirectivesPhase:!0}}return{stillDirective:!1,nextI:r,endDirectivesPhase:r>=n}}function gn(e,t,n,r){if(!r.directivesPhase)return null;let i=e.charCodeAt(t);if(i!==39&&i!==34)return null;let a=t+1,o=z(e,t,n,i);if(o<=a)return r.directivesPhase=!1,t+1;let s=o-1-a;mn(r,s===10&&on(e,a,`use client`),s===10&&on(e,a,`use server`));let c=hn(e,o,n);return c.stillDirective?c.nextI:(c.endDirectivesPhase&&(r.directivesPhase=!1),r.directivesPhase?o:c.nextI)}function _n(e,t,n){if(t>=n)return!1;let r=e.charCodeAt(t);return I(r)||r===123?!0:r===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42)}function vn(e){e.hasDefaultExportResult=!0,e.hasComponentExportResult=!0}function yn(e,t,n,r){if(e.charCodeAt(t)!==97||e.charCodeAt(t+1)!==115)return{k:t,hasAlias:!1};let i=t+2;if(i>=n||L(e.charCodeAt(i)))return{k:t,hasAlias:!0};t=R(e,i,n);let a=t;for(;t<n&&L(e.charCodeAt(t));)t++;return t-a===7&&pn(e,a)&&vn(r),{k:t,hasAlias:!0}}function bn(e,t,n,r){let i=t;for(;t<n&&L(e.charCodeAt(t));)t++;let a=t-i;if(a===0)return null;t=R(e,t,n);let o=yn(e,t,n,r);return t=o.k,!o.hasAlias&&a===7&&pn(e,i)&&vn(r),e.charCodeAt(t)===44?t+1:e.charCodeAt(t)===125?t:t+1}function xn(e,t,n,r){let i=t+1;for(;i<n&&(i=R(e,i,n),e.charCodeAt(i)!==125);){let t=bn(e,i,n,r);if(t===null)break;i=t}}function Sn(e,t,n,r){if(!fn(e,t))return null;let i=t+6;if(!_n(e,i,n))return null;let a=R(e,i,n);if(pn(e,a)){vn(r);let t=a+7;if(t>=n||!L(e.charCodeAt(t)))return i}return e.charCodeAt(a)===123?(xn(e,a,n,r),null):((B(e,a,`async`)||B(e,a,`function`)||B(e,a,`class`))&&(r.hasComponentExportResult=!0),null)}function Cn(e,t,n,r){let i=gn(e,t,n,r);if(i!==null)return i;let a=U(e,t,n);if(a!==-1)return r.directivesPhase&&!nr(e,t)&&(r.directivesPhase=!1),a;if(r.directivesPhase=!1,B(e,t,`import`)){let i=dn(e,t,n);for(let e of i.sources)r.importSources.push(e);return i.end}let o=Sn(e,t,n,r);return o===null?t+1:o}function V(e){let t={directives:{hasUseClient:!1,hasUseServer:!1},topLevelUseClient:!1,topLevelUseServer:!1,hasDefaultExportResult:!1,hasComponentExportResult:!1,importSources:[],directivesPhase:!0,sawFirstDirective:!1},n=0,r=e.length;for(;n<r;)n=Cn(e,n,r,t);return{directives:t.directives,topLevelUseClient:t.topLevelUseClient,topLevelUseServer:t.topLevelUseServer,hasDefaultExport:t.hasDefaultExportResult,hasComponentExport:t.hasComponentExportResult,importSources:[...new Set(t.importSources)]}}function H(e,t,n){if(t>=n||!Xt(e.charCodeAt(t)))return null;let r=t+1;for(;r<n&&L(e.charCodeAt(r));)r++;return{name:e.slice(t,r),end:r}}function wn(e,t,n){let r=t;for(;r<n;){let t=e.charCodeAt(r);if(t===32||t===9){r++;continue}if(t===59)return r+1;break}return t}function Tn(e,t,n){if(!B(e,t,`type`))return null;let r=R(e,t+4,n),i=e.charCodeAt(r);return(i===39||i===34||H(e,r,n)!==null)&&!B(e,r,`as`)?r:null}function En(e,t,n){let r=e.charCodeAt(t);if(r===39||r===34){let i=z(e,t,n,r);return{imported:e.slice(t+1,i-1),end:i}}let i=H(e,t,n);return i?{imported:i.name,end:i.end}:null}function Dn(e,t,n){let r=Tn(e,t,n),i=r!==null;r!==null&&(t=r);let a=En(e,t,n);if(!a)return null;let o=a.imported;t=R(e,a.end,n);let s=o;if(B(e,t,`as`)){t=R(e,t+2,n);let r=H(e,t,n);if(!r)return null;s=r.name,t=R(e,r.end,n)}return{specifier:{imported:o,local:s,typeOnly:i},end:t}}function On(e,t,n){let r=[],i=t+1;for(;;){if(i=R(e,i,n),i>=n)return null;if(e.charCodeAt(i)===125)return{named:r,end:i+1};let t=Dn(e,i,n);if(!t)return null;r.push(t.specifier),i=t.end;let a=e.charCodeAt(i);if(a===44){i++;continue}return a===125?{named:r,end:i+1}:null}}function kn(e,t,n,r){let i=e.charCodeAt(n);if(i!==39&&i!==34)return null;let a=sn(e,n,r);return a?{start:t,end:wn(e,a.end,r),source:a.source,typeOnly:!1,sideEffectOnly:!0,defaultBinding:null,namespaceBinding:null,named:[]}:null}function An(e,t,n){if(!B(e,t,`type`))return{typeOnly:!1,pos:t};let r=R(e,t+4,n);return!B(e,r,`from`)&&e.charCodeAt(r)!==44?{typeOnly:!0,pos:r}:{typeOnly:!1,pos:t}}function jn(e,t,n){let r=null,i=null,a=[],o=e.charCodeAt(t);if(o!==123&&o!==42){let i=H(e,t,n);if(!i)return null;r=i.name,t=R(e,i.end,n),e.charCodeAt(t)===44?(t=R(e,t+1,n),o=e.charCodeAt(t)):o=-1}if(o===42){if(t=R(e,t+1,n),!B(e,t,`as`))return null;t=R(e,t+2,n);let r=H(e,t,n);if(!r)return null;i=r.name,t=r.end}else if(o===123){let r=On(e,t,n);if(!r)return null;a=r.named,t=r.end}return{defaultBinding:r,namespaceBinding:i,named:a,pos:t}}function Mn(e,t,n){let r=R(e,t+6,n);if(r>=n)return null;let i=e.charCodeAt(r);if(i===40||i===46)return null;let a=kn(e,t,r,n);if(a)return a;let o=An(e,r,n);r=o.pos;let s=jn(e,r,n);if(!s||(r=R(e,s.pos,n),!B(e,r,`from`)))return null;let c=sn(e,r+4,n);return c?{start:t,end:wn(e,c.end,n),source:c.source,typeOnly:o.typeOnly,sideEffectOnly:!1,defaultBinding:s.defaultBinding,namespaceBinding:s.namespaceBinding,named:s.named}:null}function Nn(e){let t=[],n=0,r=e.length;for(;n<r;){let i=U(e,n,r);if(i!==-1){n=i;continue}if(B(e,n,`import`)){let i=Mn(e,n,r);if(i){t.push(i),n=i.end;continue}n+=6;continue}n++}return t}function Pn(e,t,n,r){let i=R(e,t+1,n);if(B(e,i,`as`)){i=R(e,i+2,n);let t=H(e,i,n);return t&&r.add(t.name),t?.end??i+1}return t+1}function Fn(e,t,n,r){let i=Bn(e,t,n),a=e.slice(t+1,i-1);for(let e of a.split(`,`)){let t=e.trim();if(!t||t.startsWith(`type `)||t.startsWith(`typeof `))continue;let n=(t.split(/\s+as\s+/).at(-1)??``).trim();n!==``&&n!==`type`&&r.add(n)}return i}function In(e,t){return B(e,t,`function`)?8:B(e,t,`class`)||B(e,t,`const`)?5:3}function Ln(e,t,n,r){if(B(e,t,`async`)&&(t=R(e,t+5,n)),!B(e,t,`function`)&&!B(e,t,`class`)&&!B(e,t,`const`)&&!B(e,t,`let`)&&!B(e,t,`var`))return null;let i=In(e,t),a=R(e,t+i,n);e.charCodeAt(a)===42&&(a=R(e,a+1,n));let o=H(e,a,n);return o&&r.add(o.name),o?.end??a+1}function Rn(e,t,n,r){let i=R(e,t+6,n);if(B(e,i,`type`)||B(e,i,`interface`))return i+1;if(e.charCodeAt(i)===42)return Pn(e,i,n,r);if(B(e,i,`default`))return r.add(`default`),i+7;if(e.charCodeAt(i)===123)return Fn(e,i,n,r);let a=Ln(e,i,n,r);return a===null?t+1:a}function zn(e){let t=/* @__PURE__ */ new Set,n=0,r=e.length;for(;n<r;){let i=U(e,n,r);if(i!==-1){n=i;continue}if(!B(e,n,`export`)){n++;continue}n=Rn(e,n,r,t)}return[...t]}function Bn(e,t,n){let r=t,i=0;for(;r<n;){let t=Vn(e,r,n);if(t!=null){r=t;continue}let a=e.charCodeAt(r);if(a===123){i++,r++;continue}if(a===125){if(i--,r++,i===0)return r;continue}r++}return r}function Vn(e,t,n){let r=e.charCodeAt(t);return r===39||r===34||r===96?z(e,t,n,r):r===47&&e.charCodeAt(t+1)===47?Qt(e,t,n):r===47&&e.charCodeAt(t+1)===42?$t(e,t,n):null}function Hn(e){return V(e).topLevelUseServer}function Un(e){return V(e).hasDefaultExport}function Wn(e){return e===40||e===91||e===123||e===44||e===59||e===61||e===58||e===63||e===33||e===43||e===45||e===42||e===37||e===38||e===124||e===94||e===126||e===60||e===62}function Gn(e,t){for(t-=2;t>=1;){if(e.charCodeAt(t)===42&&e.charCodeAt(t-1)===47)return t-2;t--}return-1}function Kn(e,t){let n=t;for(;n>=0&&e.charCodeAt(n)!==10&&e.charCodeAt(n)!==13;)n--;let r=n+1;for(;r<t&&(e.charCodeAt(r)===32||e.charCodeAt(r)===9);)r++;return r<t&&e.charCodeAt(r)===47&&e.charCodeAt(r+1)===47?r-1:null}function qn(e,t){let n=e.charCodeAt(t);return I(n)?t-1:t>=1&&n===47&&e.charCodeAt(t-1)===42?Gn(e,t):t>=1&&n===47&&e.charCodeAt(t-1)===47?t-2:Kn(e,t)}function Jn(e,t){let n=t-1;for(;n>=0;){let t=qn(e,n);if(t!==null){if(n=t,n<0)return;continue}break}if(n<0||!L(e.charCodeAt(n)))return;let r=n;for(;n>=0&&L(e.charCodeAt(n));)n--;return e.slice(n+1,r+1)}function Yn(e,t){let n=t-1;for(;n>=0;){let t=qn(e,n);if(t!==null){if(n=t,n<0)return-1;continue}return e.charCodeAt(n)}return-1}function Xn(e,t){let n=Yn(e,t);if(n===-1||Wn(n))return!0;let r=Jn(e,t);return r!=null&&r!==``&&Kt.has(r)}const Zn=/* @__PURE__ */ new Set([`return`,`throw`,`case`,`default`,`else`,`do`,`typeof`,`void`,`yield`,`await`,`delete`]);function Qn(e,t){let n=Yn(e,t);if(n===-1)return!0;if(L(n)||n>=48&&n<=57){let n=Jn(e,t);return n!=null&&n!==``&&Zn.has(n)}return n!==41&&n!==93&&n!==125}function $n(e,t,n){if(!Qn(e,t))return-1;let r=e.charCodeAt(t+1);if(r!==47&&r!==46&&r!==62&&!Xt(r))return-1;let i=an(e,t,n);return i<n&&e.charCodeAt(i)===62&&i++,i>t&&e.charCodeAt(i-1)===62?i:-1}function er(e,t,n,r){let i=e.charCodeAt(t);if(i===92)return{i:t+2,inCharClass:r,done:!1};if(r)return{i:t+1,inCharClass:i!==93,done:!1};if(i===91)return{i:t+1,inCharClass:!0,done:!1};if(i===47){for(t++;t<n&&L(e.charCodeAt(t));)t++;return{i:t,inCharClass:r,done:!0}}return Yt(i)?{i:t,inCharClass:r,done:!0}:{i:t+1,inCharClass:r,done:!1}}function tr(e,t,n){t++;let r=!1;for(;t<n;){let i=er(e,t,n,r);if(t=i.i,r=i.inCharClass,i.done)return t}return t}function U(e,t,n){if(t>=n)return-1;let r=e.charCodeAt(t);if(I(r))return t+1;if(r===47&&e.charCodeAt(t+1)===47)return Qt(e,t,n);if(r===47&&e.charCodeAt(t+1)===42)return $t(e,t,n);if(r===39||r===34||r===96)return z(e,t,n,r);if(r===47&&e.charCodeAt(t+1)!==47&&e.charCodeAt(t+1)!==42&&Xn(e,t))return tr(e,t,n);if(r===60){let r=$n(e,t,n);if(r!==-1)return r}return-1}function nr(e,t){let n=e.charCodeAt(t);return I(n)?!0:n===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42)}function rr(e,t,n){let r=t;if(B(e,r,`async`)){let t=R(e,r+5,n);B(e,t,`function`)&&(r=t)}if(!B(e,r,`function`)&&!B(e,r,`class`))return null;let i=B(e,r,`function`)?8:5,a=R(e,r+i,n);e.charCodeAt(a)===42&&(a=R(e,a+1,n));let o=H(e,a,n);return o?o.name:null}function ir(e){let t=e.length,n=0;for(;n<t;){let r=U(e,n,t);if(r!==-1){n=r;continue}if(!B(e,n,`export`)){n++;continue}let i=R(e,n+6,t);if(!B(e,i,`default`)){n++;continue}let a=R(e,i+7,t),o=rr(e,a,t),s=mr(e,a,t);return{exportStart:n,valueStart:a,valueEnd:s,statementEnd:wn(e,s,t),bindingName:o}}return null}function ar(e,t,n){if(t>=n)return!1;let r=e.charCodeAt(t),i=t+1<n?e.charCodeAt(t+1):-1;return r===46||r===63&&i===46||r===40||r===91||r===96||r===61&&i===62||r===43||r===45||r===42||r===47||r===37||r===38||r===124||r===94||r===60||r===62||r===61||r===33||r===63||r===58||r===44||r===126||B(e,t,`instanceof`)||B(e,t,`in`)||B(e,t,`of`)||B(e,t,`as`)}const or=/* @__PURE__ */ new Set([`typeof`,`void`,`delete`,`await`,`yield`,`new`]);function sr(e,t,n){let r=e.charCodeAt(t.i);return r===39||r===34||r===96?(t.i=z(e,t.i,n,r),t.lastCanTerminate=!0,!0):r===47&&e.charCodeAt(t.i+1)===47?(t.i=Qt(e,t.i,n),!0):r===47&&e.charCodeAt(t.i+1)===42?(t.i=$t(e,t.i,n),!0):r===47&&e.charCodeAt(t.i+1)!==47&&e.charCodeAt(t.i+1)!==42&&Xn(e,t.i)?(t.i=tr(e,t.i,n),t.lastCanTerminate=!0,!0):!1}function cr(e,t,n){if(e.charCodeAt(t.i)!==60||t.paren!==0||t.brace!==0||t.bracket!==0)return!1;let r=$n(e,t.i,n);return r!==-1&&(t.i=r,t.lastCanTerminate=!0,!0)}function lr(e,t){return e===40?(t.paren++,t.lastCanTerminate=!1,t.i++,!1):e===41?(t.paren=Math.max(0,t.paren-1),t.lastCanTerminate=!0,t.i++,!1):e===123?(t.brace++,t.lastCanTerminate=!1,t.i++,!1):e===125?(t.brace=Math.max(0,t.brace-1),t.lastCanTerminate=!0,t.i++,t.paren===0&&t.brace===0&&t.bracket===0):e===91?(t.bracket++,t.lastCanTerminate=!1,t.i++,!1):e===93?(t.bracket=Math.max(0,t.bracket-1),t.lastCanTerminate=!0,t.i++,!1):null}function ur(e,t,n,r){if(t.paren!==0||t.brace!==0||t.bracket!==0)return null;if(r===59)return t.i;if(!Yt(r))return null;let i=R(e,t.i+1,n);return!t.lastCanTerminate||ar(e,i,n)?(t.i++,-1):t.i}function dr(e,t,n){for(t++;t<n;){let n=e.charCodeAt(t);if(n>=48&&n<=57||n===46||n===110||n===101||n===69){t++;continue}break}return t}function fr(e){return e===46||e===44||e===58||e===63||e===61||e===43||e===45||e===42||e===47||e===37||e===38||e===124||e===94||e===33||e===126||e===60||e===62}function pr(e,t,n){let r=e.charCodeAt(t.i);if(Xt(r)){let r=H(e,t.i,n);if(r){t.lastCanTerminate=!or.has(r.name),t.i=r.end;return}}if(r>=48&&r<=57){t.lastCanTerminate=!0,t.i=dr(e,t.i,n);return}if(r===61&&e.charCodeAt(t.i+1)===62){t.lastCanTerminate=!1,t.i+=2;return}if(fr(r)){t.lastCanTerminate=!1,t.i++;return}t.i++}function mr(e,t,n){let r={i:t,paren:0,brace:0,bracket:0,lastCanTerminate:!1};for(;r.i<n;){if(sr(e,r,n)||cr(e,r,n))continue;let t=e.charCodeAt(r.i),i=lr(t,r);if(i===!0)return r.i;if(i===!1)continue;let a=ur(e,r,n,t);if(a!==-1){if(a!==null)return a;pr(e,r,n)}}return r.i}function hr(e,t){let n=ir(e);if(n==null||n.bindingName!=null)return null;let r=`const ${t} = ${e.slice(n.valueStart,n.valueEnd).trimEnd()};\nexport default ${t}${e.slice(n.statementEnd)}`;return e.slice(0,n.exportStart)+r}const gr=/* @__PURE__ */ new Set([`node_modules`,`.git`,`.cache`,`dist`]);function _r(e,t){let n=/* @__PURE__ */ new Set,r=e=>{if(!D.existsSync(e))return;let i=D.readdirSync(e,{withFileTypes:!0});for(let a of i){let i=k.join(e,a.name);if(a.isDirectory()){if(gr.has(a.name))continue;r(i)}else if(a.isFile()&&S.test(a.name)){if(n.has(i))continue;n.add(i),t(i)}}};for(let t of e)t&&D.existsSync(t)&&r(t)}function vr(e){let t=[];return _r(e,e=>{t.push(e)}),t}function yr(e,t=[]){let n=[e],r=k.resolve(e);for(let e of t){if(!e)continue;let t=k.resolve(e);if(t===r)continue;let i=k.relative(r,t);if(i!==``&&(i.startsWith(`..`)||k.isAbsolute(i)))try{D.statSync(e).isDirectory()&&n.push(e)}catch{}}return n}const br=new Set(Se);function xr(e){return br.has(e)}function Sr(e){for(let t of e.importSources)if(t.startsWith(`node:`)||xr(t))return!0;return!1}function Cr(e,t=br){let n=[];for(let r of e)!r.startsWith(`.`)&&!r.startsWith(`/`)&&!r.startsWith(`@/`)&&!r.startsWith(`node:`)&&!t.has(r)&&n.push(r);return[...new Set(n)]}function wr(e){let t=[];for(let n of e)(n.startsWith(`./`)||n.startsWith(`../`)||n.startsWith(`@/`))&&t.push(n);return t}function W(e){try{return D.realpathSync(e)}catch{return k.resolve(e)}}function Tr(e,t){e.delete(t);try{e.delete(D.realpathSync(t))}catch{e.delete(k.resolve(t))}}function Er(e,t){let n=[];for(let r of vr(e))try{t.get(r).directives.hasUseClient&&n.push(r)}catch{}return n}var Dr=class{cache=/* @__PURE__ */ new Map;get(e,t){let n=W(e),r=this.cache.get(n);if(t!==void 0){if(r?.source===t)return r.analysis}else if(r){let e=this.readMtimeMs(n);if(e>=0&&r.mtimeMs===e)return r.analysis}t??=D.readFileSync(n,`utf-8`);let i=this.readMtimeMs(n),a=V(t);return this.cache.set(n,{mtimeMs:i,source:t,analysis:a}),a}getSource(e){return this.get(e),this.cache.get(W(e)).source}invalidate(e){Tr(this.cache,e)}clear(){this.cache.clear()}readMtimeMs(e){try{return D.statSync(e).mtimeMs}catch{return-1}}};function Or(e){return e.code===`MODULE_LEVEL_DIRECTIVE`&&(e.message?.includes(`use client`)===!0||e.message?.includes(`use server`)===!0)}function kr(){return{name:`rari:silence-react-directive-logs`,onLog(e,t){return!Or(t)&&void 0}}}const Ar=`virtual:rari-entry-client`,jr=/^layout\.(?:tsx|ts|jsx|js)$/,Mr=/\.css(?:\?.*)?$/,Nr=/* @__PURE__ */ new Set;function Pr(){Nr.clear()}function Fr(e){let t=e.trim();t!==``&&Nr.add(t)}function Ir(){return[...Nr]}function Lr(e,t,n,r){let i=e.replace(/[?#].*$/,``);if(!Mr.test(i))return null;if(i.startsWith(`./`)||i.startsWith(`../`)){let e=k.resolve(k.dirname(t),i);return!D.existsSync(e)||!D.statSync(e).isFile()?null:e}let a=E(i,r,n);return a!=null&&a!==``&&D.existsSync(a)&&D.statSync(a).isFile()?a:i}function Rr(e,t,n,r){if(D.existsSync(e))for(let i of D.readdirSync(e,{withFileTypes:!0})){let a=k.join(e,i.name);if(i.isDirectory()){Rr(a,t,n,r);continue}if(!i.isFile()||!jr.test(i.name))continue;let o=D.readFileSync(a,`utf-8`);for(let e of Nn(o)){let i=Lr(e.source,a,t,n);i!=null&&r.add(i)}}}function zr(e,t={}){let n=/* @__PURE__ */ new Set;return Rr(k.join(e,`src`,`app`),e,t,n),n}function Br(e,t){if(!k.isAbsolute(e))return e.startsWith(`/`)?e:`/${e}`;let n=T(k.relative(t,e));return n.startsWith(`..`)||k.isAbsolute(n)?`/@fs/${e}`:`/${n}`}function Vr(e,t={}){return[...zr(e,t)].sort().map(t=>Br(t,e))}function Hr(e,t){if(!k.isAbsolute(e))return e;let n=T(k.relative(t,e));return n.startsWith(`..`)||k.isAbsolute(n)?e:`/${n}`}function Ur(e,t={}){return[...zr(e,t)].sort().map(t=>`import ${JSON.stringify(Hr(t,e))};`).join(`
45
+ `)}function Wr(e){return e.startsWith(`/`)?e:`/${e}`}function Gr(e){let t=[...Ir()],n=new Set(t),r=e=>{n.has(e)||(n.add(e),t.push(e))};return Kr(e,r)||qr(e,r),t.length>0?`${t.join(`
46
+ `)}\n`:``}function Kr(e,t){let n=!1;for(let[r,i]of Object.entries(e)){if(i.type!==`chunk`||i.isEntry!==!0)continue;let e=i.viteMetadata?.importedCss;if(e){let r=[...e];r.length>0&&(n=!0);for(let e of r)t(`<link rel="stylesheet" href="${Wr(e)}" />`)}t(`<script type="module" src="${Wr(r)}"><\/script>`)}return n}function qr(e,t){for(let[n,r]of Object.entries(e))r.type===`asset`&&n.endsWith(`.css`)&&!n.includes(`/server/`)&&t(`<link rel="stylesheet" href="${Wr(n)}" />`)}function Jr(e){let t=e<0?(-e<<1)+1:e<<1,n=``;do{let e=t&31;t>>>=5,t>0&&(e|=32),n+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`[e]}while(t>0);return n}function Yr(e){let t=[],n=0;for(let r of e){if(r==null){t.push(``);continue}let e=r-n;n=r,t.push(`${Jr(0)}${Jr(0)}${Jr(e)}${Jr(0)}`)}return t.join(`;`)}function Xr(e,t){let n=Math.max(1,t.split(`
47
+ `).length),r=Array.from({length:n},(e,t)=>t);return{version:3,file:e,sources:[e],sourcesContent:[t],names:[],mappings:Yr(r)}}function Zr(e,t){let n=e.length,r=t.length,i=Array.from({length:r}).fill(null);if(r===0||n===0)return i;if($r(t,e)){let e=r-n;for(let t=0;t<n;t+=1)i[e+t]=t;return i}if(ei(t,e)){for(let e=0;e<n;e+=1)i[e]=e;return i}return n*r>2e6?ti(e,t):Qr(e,t)}function Qr(e,t){let n=e.length,r=t.length,i=Array.from({length:r}).fill(null),a=Array.from({length:n+1},()=>new Uint32Array(r+1));for(let i=1;i<=n;i+=1){let n=e[i-1],o=a[i],s=a[i-1];for(let e=1;e<=r;e+=1)o[e]=n===t[e-1]?s[e-1]+1:Math.max(s[e],o[e-1])}let o=n,s=r;for(;o>0&&s>0;)e[o-1]===t[s-1]?(i[s-1]=o-1,--o,--s):a[o-1][s]>=a[o][s-1]?--o:--s;return i}function $r(e,t){if(t.length>e.length)return!1;let n=e.length-t.length;for(let r=0;r<t.length;r+=1)if(e[n+r]!==t[r])return!1;return!0}function ei(e,t){if(t.length>e.length)return!1;for(let n=0;n<t.length;n+=1)if(e[n]!==t[n])return!1;return!0}function ti(e,t){let n=Array.from({length:t.length}).fill(null),r=0,i=0;for(;r<e.length&&i<t.length;)if(e[r]===t[i])n[i]=r,r+=1,i+=1;else{if(i+1<t.length&&e[r]===t[i+1]){i+=1;continue}if(r+1<e.length&&e[r+1]===t[i]){r+=1;continue}i+=1,r+=1}return n}function ni(e,t,n){let r=Zr(t.split(`
48
+ `),n.split(`
49
+ `));return{version:3,file:e,sources:[e],sourcesContent:[t],names:[],mappings:Yr(r)}}function ri(e,t,n){return e===t?null:{code:e,map:ni(n,t,e)}}const ii=/\.(?:[cm]?[jt]sx?|vue|svelte|mdx?)$/i;function ai(e,t,n){return e.startsWith(`//`)||/^[a-z][a-z\d+.-]*:/i.test(e)?e:e===``||e===t?`${n}${t}`:e.startsWith(`/`)?`${n}${e}`:`${n}${k.posix.normalize(`${k.posix.dirname(t)}/${e}`)}`}function oi(e){if(!(`sourceRoot`in e))return;let t=Reflect.get(e,`sourceRoot`);return typeof t==`string`&&t!==``?t:void 0}function si(e){return e.startsWith(`//`)||/^[a-z][a-z\d+.-]*:/i.test(e)}function ci(e,t){if(t==null||si(e)||e.startsWith(`/`))return e;if(si(t))try{if(t.startsWith(`//`)){let n=new URL(e,`https:${t}`);return`//${n.host}${n.pathname}${n.search}${n.hash}`}return new URL(e,t).href}catch{let n=t.lastIndexOf(`/`);return`${n>=0?t.slice(0,n+1):`${t}/`}${e}`}let n=t.endsWith(`/`)?`${t}${e}`:`${t}/${e}`;return k.posix.normalize(n)}function li(e){if(!(`sources`in e))return;let t=Reflect.get(e,`sources`);if(Array.isArray(t))return t.every(e=>e===null||typeof e==`string`)?t:void 0}function ui(e,t,n,r){return e==null?null:ai(ci(e,r),t,n)}function di(e,t,n){let r=li(e);if(r==null)return e;let i=oi(e),a={...e,sources:r.map(e=>ui(e,t,n,i))};return delete a.sourceRoot,a}function fi(e,t,n,r){if(t.startsWith(`file://`))return pi(e,t,r);let i=e.config.base.endsWith(`/`)?e.config.base.slice(0,-1):e.config.base,a=n===`Server`||n===`rsc`,o=n===`Client`||n===`client`;if(a)return mi(e,t,i);if(o)return hi(e,t,i)}function pi(e,t,n){let r;try{r=T(j(t))}catch{return}if(!se(r,n)||!Ae(e.config,r)||!ii.test(r)||!D.existsSync(r))return;let i=D.statSync(r);if(!i.isFile()||i.size>1048576)return;let a=D.readFileSync(r,`utf-8`);return Xr(r,a)}function mi(e,t,n){let r=e.environments.rsc.moduleGraph,i=r.getModuleById(t)??(t.startsWith(`/`)?r.urlToModuleMap.get(t):void 0),a=i?.transformResult?.map;if(i!=null&&a!=null)return di(a,i.url,n)}function hi(e,t,n){try{let r=new URL(t,`http://localhost`).pathname,i=n!==``&&r.startsWith(n)?r.slice(n.length):r,a=e.environments.client.moduleGraph.urlToModuleMap.get(i),o=a?.transformResult?.map;return a==null||o==null?void 0:di(o,a.url,n)}catch{return}}function gi(e){let t=k.resolve(e);return{name:`rari:find-source-map-url`,apply:`serve`,configureServer(e){e.middlewares.use((n,r,i)=>{if(oe(n.url??``)!==`/__rari_findSourceMapURL`){i();return}let a=new URL(n.url??``,`http://localhost`),o=a.searchParams.get(`filename`),s=a.searchParams.get(`environmentName`)??`Server`;if(o==null||o===``){r.statusCode=400,r.end(`{}`);return}try{let n=fi(e,o,s,t);r.statusCode=n==null?404:200,r.setHeader(`Content-Type`,`application/json`),r.setHeader(`Cache-Control`,`no-store`),r.end(JSON.stringify(n??{}))}catch(e){i(e)}})}}}function _i(e,t={}){let n=k.extname(e),r=n.toLowerCase(),i=r===``?t.defaultExt??``:r,a=k.basename(e,n);return t.sanitizeBase&&(a=a.replaceAll(/[?#]/g,`_`)),t.encodeBase&&(a=encodeURIComponent(a)),{base:a,ext:i}}function vi(e,t,n,r={}){let{base:i,ext:a}=_i(e,r);return`${w(n)}/${i}-${t}${a}`}function yi(e,t,n,r={}){return`/${vi(e,t,n,r)}`}function bi(e){return`/${e.split(k.sep).join(`/`)}`}function xi(e,t,n){return vi(e,t,n,{defaultExt:`.woff2`,sanitizeBase:!0})}function Si(e){return bi(e)}function Ci(e){D.mkdirSync(e,{recursive:!0})}function wi(e,t){return`${e}_${t}`}function Ti(e){return`${(e*100).toFixed(2)}%`}function Ei(e,t){if(!Number.isFinite(e.unitsPerEm)||e.unitsPerEm===0||!Number.isFinite(e.xWidthAvg))return null;let n=t===`Times New Roman`?Me:M;if(!Number.isFinite(n.unitsPerEm)||n.unitsPerEm===0||!Number.isFinite(n.xWidthAvg))return null;let r=e.xWidthAvg/e.unitsPerEm,i=n.xWidthAvg/n.unitsPerEm;if(!Number.isFinite(i)||i===0)return null;let a=r/i;return!Number.isFinite(a)||a===0?null:{fallbackFont:t,sizeAdjust:Ti(a),ascentOverride:Ti(e.ascent/e.unitsPerEm/a),descentOverride:Ti(Math.abs(e.descent)/e.unitsPerEm/a),lineGapOverride:Ti(e.lineGap/e.unitsPerEm/a)}}async function Di(e){let t=e.replaceAll(/\s+/g,``).replace(/^(.)/,e=>e.toLowerCase());try{let e=await import(`@capsizecss/metrics/${t}`);if(typeof e!=`object`||!e||!(`default`in e))return null;let n=e.default;return typeof n!=`object`||!n||!(`ascent`in n)||!(`descent`in n)||!(`lineGap`in n)||!(`unitsPerEm`in n)||!(`xWidthAvg`in n)||typeof n.ascent!=`number`||typeof n.descent!=`number`||typeof n.lineGap!=`number`||typeof n.unitsPerEm!=`number`||typeof n.xWidthAvg!=`number`?null:{ascent:n.ascent,descent:n.descent,lineGap:n.lineGap,unitsPerEm:n.unitsPerEm,xWidthAvg:n.xWidthAvg,category:`category`in n&&typeof n.category==`string`?n.category:void 0}}catch{return null}}function Oi(e){return e===`serif`?`Times New Roman`:`Arial`}const ki=/* @__PURE__ */ new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`]);function Ai(e){return e===`serif`?`serif`:e===`monospace`?`monospace`:`sans-serif`}function ji(e){return(e??[]).some(e=>ki.has(e))}function Mi(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}function Ni(e,t){return`url("${Mi(e)}") format("${t}")`}function Pi(e){let t=e.toLowerCase();return t.endsWith(`.woff2`)?`woff2`:t.endsWith(`.woff`)?`woff`:t.endsWith(`.ttf`)?`truetype`:t.endsWith(`.otf`)?`opentype`:`woff2`}function Fi(e){return e===`woff`?`font/woff`:e===`truetype`?`font/ttf`:e===`opentype`?`font/otf`:`font/woff2`}function Ii(e){let t=e.src.map(e=>Ni(e.url,e.format)).join(`, `),n=(e.declarations??[]).map(e=>` ${e.prop}: ${e.value};`).join(`
50
+ `),r=`@font-face {\n font-family: "${Mi(e.family)}";\n src: ${t};\n font-display: ${e.display};\n font-weight: ${e.weight};\n font-style: ${e.style};\n`;return e.unicodeRange!=null&&e.unicodeRange!==``&&(r+=` unicode-range: ${e.unicodeRange};\n`),n!==``&&(r+=`${n}\n`),r+=`}
51
+ `,r}function Li(e,t,n,r=`sans-serif`){let i=[`"${Mi(e)}"`];n&&i.push(`"${Mi(`${e} Fallback`)}"`);for(let e of t??[])i.push(e.includes(` `)?`"${Mi(e)}"`:e);return ji(t)||i.push(r),i.join(`, `)}function Ri(e){return e??`swap`}function zi(e){return e==null?`400`:String(e)}function Bi(e){return e??`normal`}const Vi=/* @__PURE__ */ new Map,Hi=/* @__PURE__ */ new Map;function Ui(e){return!u(e)||!Array.isArray(e.familyMetadataList)?!1:e.familyMetadataList.every(e=>u(e)&&typeof e.family==`string`&&e.family!==``)}function Wi(e){let t=e.replace(/^\)\]\}'\n?/,``);return JSON.parse(t)}function Gi(e){return[...new Set(e)].sort((e,t)=>e.localeCompare(t))}function Ki(e){let t=Gi((e.subsets??[]).filter(e=>e!==`menu`&&e!==``)),n=(e.axes??[]).filter(e=>typeof e.tag==`string`&&e.tag!==``&&typeof e.min==`number`&&typeof e.max==`number`).map(e=>({tag:e.tag,min:e.min,max:e.max})).sort((e,t)=>e.tag.localeCompare(t.tag));return{family:e.family,subsets:t,axisRanges:n}}function qi(e){if(!Ui(e))throw Error(`Unexpected fonts.google.com/metadata/fonts shape`);let t=/* @__PURE__ */ new Map;for(let n of e.familyMetadataList){let e=Ki(n);t.set(e.family,e)}return t}async function Ji(e){let t=Vi.get(e);if(t!=null)return t;let n=Hi.get(e);if(n!=null)return n;let r=Promise.resolve().then(async()=>{let t=k.join(e,`google-fonts-metadata.json`);if(D.existsSync(t))try{let n=qi(Wi(D.readFileSync(t,`utf8`)));return Vi.set(e,n),n}catch{try{D.unlinkSync(t)}catch{}}let n=await fetch(`https://fonts.google.com/metadata/fonts`,{headers:{"User-Agent":`rari-google-font-meta`},signal:AbortSignal.timeout(3e4)});if(!n.ok)throw Error(`Failed to fetch Google font metadata: ${n.status} ${n.statusText}`);let r=await n.text(),i=qi(Wi(r));return Ci(e),D.writeFileSync(t,r.replace(/^\)\]\}'\n?/,``)),Vi.set(e,i),i});return Hi.set(e,r),r.finally(()=>{Hi.get(e)===r&&Hi.delete(e)})}async function Yi(e,t){try{return(await Ji(e)).get(t)??null}catch(e){return console.warn(`[rari/font] Failed to load Google font metadata for ${t}:`,e),null}}function Xi(e,t,n){let r=t.subsets!=null&&t.subsets.length>0,i=r?t.preload!==!1:t.preload===!0,a=t.subsets;if(i&&!r&&console.warn(`[rari/font] ${e}: \`preload\` is true but no \`subsets\` were specified. Specify subsets to avoid downloading unused glyphs, or set \`preload: false\`.`),a==null||a.length===0||n==null||n.length===0)return;let o=new Set(n.map(e=>e.toLowerCase())),s=[...new Set(a.map(e=>e.toLowerCase())).difference(o)];s.length!==0&&console.warn(`[rari/font] ${e}: unknown subset(s) ${s.map(e=>JSON.stringify(e)).join(`, `)}. Available: ${n.join(`, `)}`)}const Zi=1e4,Qi=/* @__PURE__ */ new Set([`fonts.gstatic.com`]);function $i(e){let t=URL.parse(e);if(t==null)throw Error(`Invalid Google font URL: ${e}`);if(t.protocol!==`https:`)throw Error(`Google font URL must use HTTPS: ${e}`);if(!Qi.has(t.hostname))throw Error(`Google font URL host not allowlisted (${t.hostname}): ${e}. Allowed: ${[...Qi].join(`, `)}`);return t}function ea(e){return e.subsets!=null&&e.subsets.length>0?e.preload!==!1:e.preload===!0}function ta(e){return e.trim().replaceAll(` `,`+`)}function na(e){if(e==null)return[`400`];if(Array.isArray(e)){let t=e.map(String);return t.length>0?t:[`400`]}return[String(e)]}const ra=/^(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)$/;function ia(e){return ra.test(e.trim())}function aa(e){return e===`variable`||typeof e==`string`&&ia(e)?!0:Array.isArray(e)?e.some(e=>e===`variable`||typeof e==`string`&&ia(e)):!1}function oa(e){if(typeof e==`string`){let t=ra.exec(e.trim());if(t!=null)return`${t[1]}..${t[2]}`}if(Array.isArray(e))for(let t of e){if(typeof t!=`string`)continue;let e=ra.exec(t.trim());if(e!=null)return`${e[1]}..${e[2]}`}return`100..900`}function sa(e,t){if(e==null)return null;let n=e.find(e=>e.tag===t);return n==null?null:`${n.min}..${n.max}`}function ca(e,t){if(aa(e))return la(e,t);if(e!=null){let t=na(e);if(t.length===1)return`${t[0]}..${t[0]}`}return sa(t,`wght`)??`100..900`}function la(e,t){if(typeof e==`string`&&ia(e))return oa(e);if(Array.isArray(e)){for(let t of e)if(typeof t==`string`&&ia(t))return oa(t)}return sa(t,`wght`)??oa(e)}function ua(e){if(e==null)return[`normal`];if(typeof e==`string`)return[e];let t=e.filter(e=>e!==``);return t.length>0?[...t]:[`normal`]}function da(e){let t=(e.axes??[]).map(e=>e.trim()).filter(Boolean),n=[];for(let e of t)n.includes(e)||n.push(e);return n}function fa(e){return e==null||aa(e)?null:na(e)}function pa(e,t,n){let r=ta(e),i=Ri(t.display),a=ua(t.style),o=a.includes(`italic`),s=a.includes(`normal`)||!o,c=da(t);return`https://fonts.googleapis.com/css2?family=${r}:${aa(t.weight)||c.length>0?ma(t,n,c,o,s):_a(t.weight,o,s)}&display=${i}`}function ma(e,t,n,r,i){let a=[`wght`,...n.filter(e=>e!==`wght`&&e!==`ital`)].sort((e,t)=>e.localeCompare(t)),o=fa(e.weight),s=(e,n)=>e===`wght`?n:sa(t,e)??`1..1000`;if(o!=null)return ha(a,o,s,r,i);let c=ca(e.weight,t);return ga(a,a.map(e=>s(e,c)),r,i)}function ha(e,t,n,r,i){let a=t.map(t=>e.map(e=>n(e,t)).join(`,`));return r&&i?`ital,${e.join(`,`)}@${[...a.map(e=>`0,${e}`),...a.map(e=>`1,${e}`)].join(`;`)}`:r?`ital,${e.join(`,`)}@${a.map(e=>`1,${e}`).join(`;`)}`:e.length===1&&e[0]===`wght`?`wght@${t.join(`;`)}`:`${e.join(`,`)}@${a.join(`;`)}`}function ga(e,t,n,r){return n&&r?`ital,${e.join(`,`)}@0,${t.join(`,`)};1,${t.join(`,`)}`:n?`ital,${e.join(`,`)}@1,${t.join(`,`)}`:e.length===1&&e[0]===`wght`?`wght@${t[0]}`:`${e.join(`,`)}@${t.join(`,`)}`}function _a(e,t,n){let r=na(e);return t&&n?`ital,wght@${[...r.map(e=>`0,${e}`),...r.map(e=>`1,${e}`)].join(`;`)}`:t?`ital,wght@${r.map(e=>`1,${e}`).join(`;`)}`:`wght@${r.join(`;`)}`}function va(e){let t=[],n=e.split(`@font-face`);for(let e=1;e<n.length;e+=1){let r=n[e-1]??``,i=n[e]??``,a=i.indexOf(`{`),o=i.indexOf(`}`,a);if(a===-1||o===-1)continue;let s=i.slice(a+1,o),c=/\/\*\s*([\w-]+)\s*\*\/\s*$/.exec(r)?.[1]??null,l=/font-family:\s*'([^']+)'/.exec(s)?.[1]??/font-family:\s*"([^"]+)"/.exec(s)?.[1],u=/font-style:\s*([^;\s]+)\s*;/.exec(s)?.[1]??`normal`,d=/font-weight:([^;]+);/.exec(s)?.[1]?.trim()??`400`,f=/src:\s*url\(([^)]+)\)/.exec(s)?.[1]?.replaceAll(/['"]/g,``),p=/unicode-range:([^;]+);/.exec(s)?.[1]?.trim()??null;l!=null&&f!=null&&f!==``&&t.push({family:l,style:u,weight:d,url:f,subset:c,unicodeRange:p})}return t}function ya(e,t){if(t==null||t.length===0)return[...e];let n=new Set(t.map(e=>e.toLowerCase()));return e.filter(e=>e.subset!=null&&n.has(e.subset.toLowerCase()))}async function ba(e,t){if(D.existsSync(t))return D.readFileSync(t);let n=$i(e).href,r=null;for(let e=0;e<=3;e+=1){let e=await fetch(n,{signal:AbortSignal.timeout(Zi),redirect:`manual`});if(e.status>=300&&e.status<400){let t=e.headers.get(`location`);if(t==null||t===``)throw Error(`Font download redirect missing Location from ${n}`);n=$i(new URL(t,n).href).href;continue}r=e;break}if(r==null)throw Error(`Too many redirects downloading font ${e}`);if(!r.ok)throw Error(`Failed to download font ${e}: ${r.status} ${r.statusText}`);let i=Buffer.from(await r.arrayBuffer());return Ci(k.dirname(t)),D.writeFileSync(t,i),i}async function xa(e,t,n){let r=await Yi(n,e);Xi(e,t,r?.subsets);let i=pa(e,t,r?.axisRanges),a=k.join(n,`${F(i)}.css`),o;if(D.existsSync(a))o=D.readFileSync(a,`utf8`);else{let t=await fetch(i,{headers:{"User-Agent":`Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36`},signal:AbortSignal.timeout(Zi)});if(!t.ok)throw Error(`Failed to fetch Google Font CSS for ${e}: ${t.status} ${t.statusText}`);o=await t.text(),Ci(n),D.writeFileSync(a,o)}let s=ya(va(o),t.subsets);if(s.length===0)throw Error(`No @font-face rules returned for Google font "${e}"`);let c=Ri(t.display),l=ea(t),u=[];for(let r of s){let i=$i(r.url),a=F(r.url),o=k.extname(i.pathname)||`.woff2`,s=`${e.replaceAll(/\s+/g,``)}-${r.weight}-${r.style}-${a}${o}`,d=k.join(n,s);await ba(r.url,d),u.push({family:r.family,style:Bi(r.style),weight:zi(r.weight),display:c,src:[{url:``,format:Pi(d)}],preload:l,variable:t.variable,fallback:t.fallback,adjustFontFallback:t.adjustFontFallback!==!1&&void 0,unicodeRange:r.unicodeRange??void 0,filePaths:[d]})}return u}function Sa(e){return e.replaceAll(`_`,` `)}function Ca(e){return typeof e==`string`?[{path:e}]:e.map(e=>({...e}))}function wa(e,t,n){let r=Ri(e.display),i=e.preload!==!1,a=Ca(e.src);if(a.length===0)throw Error("rari/font/local: `src` must include at least one font file");let o=a.map(r=>{let i=k.isAbsolute(r.path)?r.path:k.resolve(t,r.path);if(!D.existsSync(i))throw Error(`rari/font/local: font file not found: ${r.path} (from ${t})`);let a=k.relative(n,i);if(a.startsWith(`..`)||k.isAbsolute(a))throw Error(`rari/font/local: font file must be inside the project: ${r.path}`);return{absolute:i,weight:zi(r.weight??e.weight),style:Bi(r.style??e.style),familyBase:k.basename(i,k.extname(i))}}),s=o[0].familyBase;return o.map(t=>({family:s,style:t.style,weight:t.weight,display:r,src:[{url:``,format:Pi(t.absolute)}],preload:i,variable:e.variable,fallback:e.fallback,adjustFontFallback:e.adjustFontFallback,declarations:e.declarations,filePaths:[t.absolute]}))}function Ta(e,t){if(e[t]!==`{`)return null;try{let{json:n,end:r}=Ea(e,t);return typeof n!=`object`||!n||Array.isArray(n)?null:{value:n,end:r}}catch{return null}}function G(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]??``);)n+=1;return n}function Ea(e,t){let n=G(e,t),r=e[n];if(r===`{`)return Aa(e,n);if(r===`[`)return ka(e,n);if(r===`'`||r===`"`)return Da(e,n);if(r===`-`||r>=`0`&&r<=`9`)return Oa(e,n);if(e.startsWith(`true`,n))return{json:!0,end:n+4};if(e.startsWith(`false`,n))return{json:!1,end:n+5};if(e.startsWith(`null`,n))return{json:null,end:n+4};throw Error(`Unsupported token at ${n}`)}function Da(e,t){let n=e[t],r=t+1,i=``;for(;r<e.length;){let t=e[r];if(t===`\\`){if(r+1>=e.length)throw Error(`Unterminated string escape`);i+=e[r+1],r+=2;continue}if(t===n)return{json:i,end:r+1};i+=t,r+=1}throw Error(`Unterminated string`)}function Oa(e,t){let n=/^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?/i.exec(e.slice(t));if(n==null)throw Error(`Invalid number`);return{json:Number(n[0]),end:t+n[0].length}}function ka(e,t){let n=[],r=G(e,t+1);if(e[r]===`]`)return{json:n,end:r+1};for(;r<e.length;){let t=Ea(e,r);if(n.push(t.json),r=G(e,t.end),e[r]===`,`){if(r=G(e,r+1),e[r]===`]`)return{json:n,end:r+1};continue}if(e[r]===`]`)return{json:n,end:r+1};throw Error(`Expected comma or ]`)}throw Error(`Unterminated array`)}function Aa(e,t){let n={},r=G(e,t+1);if(e[r]===`}`)return{json:n,end:r+1};for(;r<e.length;){let t=ja(e,r),i=t.key;if(r=t.end,e[r]!==`:`)throw Error(`Expected :`);let a=Ea(e,r+1);if(n[i]=a.json,r=G(e,a.end),e[r]===`,`){if(r=G(e,r+1),e[r]===`}`)return{json:n,end:r+1};continue}if(e[r]===`}`)return{json:n,end:r+1};throw Error(`Expected comma or }`)}throw Error(`Unterminated object`)}function ja(e,t){let n=t;if(e[n]===`'`||e[n]===`"`){let t=Da(e,n);return{key:t.json,end:G(e,t.end)}}let r=/^[A-Z_$][\w$]*/i.exec(e.slice(n));if(r==null)throw Error(`Expected property name`);return{key:r[0],end:G(e,n+r[0].length)}}const Ma=`rari/font/local`,Na=`rari/font/google`,Pa=`\0rari-font-css:`,Fa=/\.(?:woff2?|ttf|otf)$/i;function Ia(e){if(e!=null){if(typeof e==`string`)return[e];if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}}function La(e){if(e===`auto`||e===`block`||e===`swap`||e===`fallback`||e===`optional`)return e}function Ra(e){let t=e.src,n;if(typeof t==`string`)n=t;else if(Array.isArray(t))n=t.map(e=>{if(typeof e==`string`)return{path:e};if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`rari/font/local: invalid src entry`);let t=e.path;if(typeof t!=`string`)throw Error(`rari/font/local: src.path must be a string`);return{path:t,weight:typeof e.weight==`string`||typeof e.weight==`number`?e.weight:void 0,style:typeof e.style==`string`?e.style:void 0}});else throw TypeError("rari/font/local: `src` is required");return{src:n,display:La(e.display),weight:typeof e.weight==`string`||typeof e.weight==`number`?e.weight:void 0,style:typeof e.style==`string`?e.style:void 0,variable:typeof e.variable==`string`?e.variable:void 0,preload:typeof e.preload==`boolean`?e.preload:void 0,fallback:Ia(e.fallback),adjustFontFallback:e.adjustFontFallback===!1?!1:e.adjustFontFallback===`Arial`||e.adjustFontFallback===`Times New Roman`?e.adjustFontFallback:void 0,declarations:za(e.declarations)}}function za(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(typeof n!=`object`||!n||Array.isArray(n))continue;let e=n.prop,r=n.value;typeof e==`string`&&typeof r==`string`&&t.push({prop:e,value:r})}return t.length>0?t:void 0}function Ba(e){let t=e.weight,n=e.style;return{weight:typeof t==`string`||typeof t==`number`?t:Array.isArray(t)?t.filter(e=>typeof e==`string`||typeof e==`number`):void 0,style:typeof n==`string`?n:Array.isArray(n)?n.filter(e=>typeof e==`string`):void 0,subsets:Ia(e.subsets),display:La(e.display),variable:typeof e.variable==`string`?e.variable:void 0,preload:typeof e.preload==`boolean`?e.preload:void 0,fallback:Ia(e.fallback),adjustFontFallback:typeof e.adjustFontFallback==`boolean`?e.adjustFontFallback:void 0,axes:Ia(e.axes)}}function Va(e,t){let n=0;for(let r=t;r<e.length;r+=1){let t=e[r];if(t===`(`)n+=1;else if(t===`)`&&(--n,n===0))return r}return-1}async function Ha(e){try{let t=await je(D.readFileSync(e));return{ascent:t.ascent,descent:t.descent,lineGap:t.lineGap,unitsPerEm:t.unitsPerEm,xWidthAvg:t.xWidthAvg}}catch{return null}}async function Ua(e,t){let n=await Di(t);if(e.adjustFontFallback===!1)return{overrides:null,metrics:n};let r=e.adjustFontFallback===`Arial`||e.adjustFontFallback===`Times New Roman`?e.adjustFontFallback:null;return n??=await Ha(e.filePaths[0]),n==null?{overrides:null,metrics:n}:(r??=Oi(n.category),{overrides:Ei(n,r),metrics:n})}function Wa(e,t){return t==null?``:`@font-face {\n font-family: "${e} Fallback";\n src: local("${t.fallbackFont}");\n ascent-override: ${t.ascentOverride};\n descent-override: ${t.descentOverride};\n line-gap-override: ${t.lineGapOverride};\n size-adjust: ${t.sizeAdjust};\n}\n`}async function Ga(e,t,n){let r=[],i=[],a=[];for(let o of e){if(o.filePaths.length===0)continue;let e=o.filePaths[0],s=D.readFileSync(e),c=F(s);a.push(c);let l=xi(e,c,t);r.push({fileName:l,source:s}),i.push({...o,family:n,src:[{url:Si(l),format:o.src[0]?.format??`woff2`}]})}if(i.length===0)throw Error(`rari/font: no font files resolved`);let o=i[0],s=JSON.stringify({display:o.display,weight:i.map(e=>e.weight),style:i.map(e=>e.style),fallback:o.fallback??null,adjustFontFallback:o.adjustFontFallback??null,declarations:o.declarations??null,unicodeRange:i.map(e=>e.unicodeRange??null),variable:o.variable??null}),c=F(`${a.join(`|`)}|${n}|${s}`),l=wi(`rari_font`,c),u=o.variable==null?null:wi(`rari_font_var`,c),d=await Ua(o,n),f=d.overrides,p=d.metrics,m=``;for(let e of i)m+=Ii(e);m+=Wa(n,f);let h=Li(n,o.fallback,f!=null,Ai(p?.category));m+=`.${l} {\n font-family: ${h};\n}\n`,o.variable!=null&&u!=null&&(m+=`.${u} {\n ${o.variable}: ${h};\n}\n`);let g=Number(o.weight),_={className:l,style:{fontFamily:h,fontWeight:Number.isFinite(g)?g:o.weight,fontStyle:o.style===`normal`?void 0:o.style},variable:u??void 0},v=i.filter(e=>e.preload).flatMap(e=>e.src.map(e=>e.url)).filter(e=>e!==``);return{font:_,css:m,cssId:`${Pa}${c}.css`,assets:r,preloadUrls:v}}function Ka(e){let t=[];for(let n=0;n<e.length;n+=1)t.push(!0);let n=(e,n)=>{for(let r=e;r<n;r+=1)t[r]=!1},r=0;for(;r<e.length;){let t=qa(e,r);if(t!=null){n(r,t),r=t;continue}r+=1}return t}function qa(e,t){let n=e.charCodeAt(t);if(n===47&&e.charCodeAt(t+1)===47){let n=e.indexOf(`
52
+ `,t+2);return n===-1?e.length:n}if(n===47&&e.charCodeAt(t+1)===42){let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2}return n===34||n===39||n===96?io(e,t):null}function Ja(e,t){let n=Ka(e),r=t.replaceAll(`/`,`\\/`),i=RegExp(`import\\s+(\\w+)\\s*,\\s*\\{([^}]+)\\}\\s*from\\s*['"]${r}['"]`,`g`),a=RegExp(`import\\s*\\{([^}]+)\\}\\s*from\\s*['"]${r}['"]`,`g`),o=RegExp(`import\\s+(\\w+)\\s*from\\s*['"]${r}['"]`,`g`),s=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.split(/\s+as\s+/),n=t[0]?.trim()??``;return{imported:n,local:t[1]?.trim()??n}}).filter(e=>e.imported!==``&&e.local!==``),c=[],l=[],u=[],d=e=>u.some(t=>e>=t.start&&e<t.end);for(let t of e.matchAll(i))n[t.index]&&!d(t.index)&&(u.push({start:t.index,end:t.index+t[0].length}),l.push(t[1]),c.push(...s(t[2])));for(let t of e.matchAll(a))n[t.index]&&!d(t.index)&&(u.push({start:t.index,end:t.index+t[0].length}),c.push(...s(t[1])));for(let t of e.matchAll(o))n[t.index]&&!d(t.index)&&(u.push({start:t.index,end:t.index+t[0].length}),l.push(t[1]));return{names:c.filter(e=>e.imported!==``),defaultNames:l.filter(e=>e!==``),statements:u}}function Ya(e,t){let n=Ka(e),r=t.replaceAll(`/`,`\\/`),i=RegExp(`import\\s+\\*\\s+as\\s+\\w+\\s+from\\s*['"]${r}['"]`,`g`),a=RegExp(`import\\s*['"]${r}['"]`,`g`);for(let t of e.matchAll(i))if(n[t.index])return!0;for(let t of e.matchAll(a))if(n[t.index])return!0;return!1}function Xa(e){let t=[`fontFamily: ${JSON.stringify(e.style.fontFamily)}`,e.style.fontWeight==null?null:`fontWeight: ${JSON.stringify(e.style.fontWeight)}`,e.style.fontStyle==null?null:`fontStyle: ${JSON.stringify(e.style.fontStyle)}`].filter(Boolean),n=e.variable==null?``:` variable: ${JSON.stringify(e.variable)},\n`;return`{\n className: ${JSON.stringify(e.className)},\n style: { ${t.join(`, `)} },\n${n}}`}function Za(e){return e>=65&&e<=90||e>=97&&e<=122||e===36||e===95||e>=128}function Qa(e){return Za(e)||e>=48&&e<=57}function $a(e,t){let n=e.indexOf(`
53
+ `,t+2);return n===-1?e.length:n+1}function eo(e,t){let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2}function to(e,t){let n=t,r=1;for(;n<e.length&&r>0;){let t=e.charCodeAt(n);if(t===34||t===39||t===96){n=io(e,n);continue}if(t===47&&e.charCodeAt(n+1)===47){n=$a(e,n);continue}if(t===47&&e.charCodeAt(n+1)===42){n=eo(e,n);continue}t===123?r+=1:t===125&&--r,n+=1}return n}function no(e,t,n){let r=t+1;for(;r<e.length;){let t=e.charCodeAt(r);if(t===92){r+=2;continue}if(t===n)return r+1;r+=1}return r}function ro(e,t){let n=t+1;for(;n<e.length;){let t=e.charCodeAt(n);if(t===92){n+=2;continue}if(t===96)return n+1;if(t===36&&e.charCodeAt(n+1)===123){n=to(e,n+2);continue}n+=1}return n}function io(e,t){let n=e.charCodeAt(t);return n===96?ro(e,t):no(e,t,n)}function ao(e,t){let n=e.charCodeAt(t);return n===47&&e.charCodeAt(t+1)===47?$a(e,t):n===47&&e.charCodeAt(t+1)===42?eo(e,t):n===34||n===39||n===96?io(e,t):null}function oo(e,t,n){if(!Za(e.charCodeAt(n))||!e.startsWith(t,n))return null;let r=n+t.length,i=n===0?0:e.charCodeAt(n-1);if(n!==0&&Qa(i)||r<e.length&&Qa(e.charCodeAt(r)))return null;let a=r;for(;a<e.length&&(e[a]===` `||e[a]===` `||e[a]===`
54
+ `||e[a]===`\r`);)a+=1;return e[a]===`(`?{start:n,openParen:a}:null}function so(e,t){let n=[],r=0;for(;r<e.length;){let i=ao(e,r);if(i!=null){r=i;continue}let a=oo(e,t,r);if(a!=null){n.push(a),r=a.openParen+1;continue}r+=1}return n}async function co(e,t,n,r){if(!e.includes(`rari/font/`))return null;let i=Ja(e,Ma),a=Ja(e,Na);if(Ya(e,Ma)||Ya(e,Na))throw Error("rari/font only supports default imports from `rari/font/local` and named imports from `rari/font/google` (optionally with `as`). Namespace and side-effect imports are not supported.");if(i.statements.length===0&&a.statements.length===0)return null;let o=e,s=[],c=[],l=[],u=/* @__PURE__ */ new Set,d=k.dirname(t),f=k.join(n,`node_modules`,`.cache`,`rari-fonts`),p=[...i.statements,...a.statements].map(e=>({start:e.start,end:e.end})),m=(e,t,n)=>{for(let e of p)e.start>=t&&(e.start+=n,e.end+=n)},h=async(e,t)=>{let n=t=>{throw Error(`rari/font: failed to transform \`${e}()\` call: ${t}`)};for(let r of so(o,e).sort((e,t)=>t.start-e.start)){let e=Va(o,r.openParen);e===-1&&n(`unbalanced parentheses`);let i=lo(o,r.openParen,e,n),a=await t(i.optionsLiteral);s.push({id:a.cssId,css:a.css}),u.add(a.cssId);for(let e of a.assets)c.push(e);for(let e of a.preloadUrls)l.includes(e)||l.push(e);let d=Xa(a.font);m(r.start,i.spliceEnd,d.length-(i.spliceEnd-r.start)),o=o.slice(0,r.start)+d+o.slice(i.spliceEnd)}};for(let e of i.defaultNames)await h(e,async e=>{if(e==null)throw Error(`rari/font/local: options object required`);let t=wa(Ra(e),d,n),i=`Rari ${k.basename(t[0].filePaths[0],k.extname(t[0].filePaths[0]))}`;return Ga(t.map(e=>Object.assign({},e,{family:i})),r,i)});for(let e of a.names)await h(e.local,async t=>{let n=t==null?{}:Ba(t),i=Sa(e.imported);return Ga(await xa(i,n,f),r,i)});let g=[...i.defaultNames,...a.names.map(e=>e.local)];for(let e of g)if(so(o,e).length>0)throw Error(`rari/font: failed to transform all \`${e}()\` calls; leaving imports in place`);for(let e of p.sort((e,t)=>t.start-e.start))o=o.slice(0,e.start)+o.slice(e.end);let _=[...u].map(e=>`import ${JSON.stringify(e)};`).join(`
55
+ `);return _!==``&&(o=po(o,_)),o===e?null:{code:o,cssModules:s,assets:c,preloadUrls:l}}function lo(e,t,n,r){let i=e.slice(t+1,n).trim();if(i===``)return{optionsLiteral:null,spliceEnd:n+1};i.startsWith(`{`)||r(`options must be a static object literal`);let a=Ta(e,e.indexOf(`{`,t));a??r(`options must be a static object literal`);let o=a.end;for(;o<e.length&&/\s/.test(e[o]??``);)o+=1;return e[o]!==`)`&&r(`options must be a static object literal`),{optionsLiteral:a.value,spliceEnd:o+1}}function uo(e,t){let n=t;for(;n<e.length;){let t=e[n];if(t===` `||t===` `||t===`\r`||t===`
56
+ `){n+=1;continue}if(t===`/`&&e[n+1]===`/`){n=$a(e,n);continue}if(t===`/`&&e[n+1]===`*`){n=eo(e,n);continue}break}return n}function fo(e,t){let n=e[t];if(n!==`'`&&n!==`"`||!e.startsWith(`use client`,t+1)&&!e.startsWith(`use server`,t+1)||e[t+11]!==n)return null;let r=t+12;return e[r]===`;`&&(r+=1),uo(e,r)}function po(e,t){let n=+(e.charCodeAt(0)===65279),r=0;for(;;){n=uo(e,n);let t=fo(e,n);if(t==null)break;n=t,r=n}return r===0?`${t}\n${e}`:`${e.slice(0,r)}${t}\n${e.slice(r)}`}function mo(e){return e===`.woff`?`font/woff`:e===`.ttf`?`font/ttf`:e===`.otf`?`font/otf`:`font/woff2`}function ho(e){return e===`.woff`?`woff`:e===`.ttf`?`truetype`:e===`.otf`?`opentype`:`woff2`}function go(e,t){let n=k.resolve(e,t),r;try{r=D.realpathSync(e)}catch{r=k.resolve(e)}let i;try{i=D.realpathSync(n)}catch{return null}let a=k.relative(r,i);if(a.startsWith(`..`)||k.isAbsolute(a))return null;try{if(!D.statSync(i).isFile()||!Fa.test(i))return null}catch{return null}return i}function _o(){let e=process.cwd(),t=`assets`,n=k.join(e,`dist`,`client`),r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map;return{name:`rari:font`,enforce:`pre`,configResolved(r){let i=Ht(r);e=i.projectRoot,t=i.assetsDir,n=i.outDir},resolveId(e){return e.startsWith(Pa)?e:null},load(e){return e.startsWith(Pa)?r.get(e)??null:null},async transform(n,a){let o=await co(n,a,e,t);if(o==null)return null;for(let e of o.cssModules)r.set(e.id,e.css);for(let e of o.assets)i.set(e.fileName,e.source);for(let e of o.preloadUrls)Fr(`<link rel="preload" href="${e}" as="font" type="${Fi(ho(k.extname(e).toLowerCase()))}" crossorigin />`);return{code:o.code,map:null}},generateBundle(){for(let[e,t]of i)this.emitFile({type:`asset`,fileName:e,source:t})},configureServer(e){e.middlewares.use((e,t,r)=>{let a=e.url?.split(`?`)[0];if(a==null||a===``){r();return}let o;try{o=decodeURIComponent(a.replace(/^\//,``))}catch{r();return}let s=i.get(o);if(s!=null){t.setHeader(`Content-Type`,mo(k.extname(o).toLowerCase())),t.setHeader(`Cache-Control`,`no-cache`),t.end(s);return}let c=go(n,o);if(c==null){r();return}t.setHeader(`Content-Type`,mo(k.extname(c).toLowerCase())),t.setHeader(`Cache-Control`,`no-cache`),D.createReadStream(c).pipe(t)})}}}var vo=class extends Error{status;statusText;bodyPreview;constructor(e,t,n){super(`HTTP ${e}: ${t}`),this.name=`HttpError`,this.status=e,this.statusText=t,this.bodyPreview=n}};async function yo(e){if(!e.ok){let t;try{t=await e.text()}catch{t=`<unable to read response body>`}let n=t.length>200?`${t.slice(0,200)}...`:t;throw new vo(e.status,e.statusText,n)}}var bo=class{errorCount=0;maxErrors;resetTimeout;resetTimer=null;lastError=null;constructor(e={}){this.maxErrors=e.maxErrors??5,this.resetTimeout=e.resetTimeout??3e4}recordError(e){this.errorCount++,this.lastError=e,this.resetTimer=ge(this.resetTimer),this.resetTimer=setTimeout(()=>{this.reset()},this.resetTimeout),this.errorCount>=this.maxErrors&&this.handleMaxErrorsReached()}reset(){this.errorCount=0,this.lastError=null,this.resetTimer=ge(this.resetTimer)}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}hasReachedMaxErrors(){return this.errorCount>=this.maxErrors}handleMaxErrorsReached(){console.error(`[rari] HMR: Maximum error count (${this.maxErrors}) reached. Consider restarting the dev server if issues persist.`)}dispose(){this.reset()}};function xo(e,t,n){let r=new Set(t),i=/* @__PURE__ */ new Set,a=[...t];for(;a.length>0;){let t=a.pop();if(t==null)break;let o=e.get(t);if(o)for(let e of o)r.has(e)||(r.add(e),a.push(e),(n==null||n(e))&&i.add(e))}return i}function So(e){return u(e)&&e.success===!0&&typeof e.componentId==`string`&&typeof e.filePath==`string`&&typeof e.relativePath==`string`}function Co(e){return u(e)&&e.success===!1&&typeof e.filePath==`string`&&typeof e.relativePath==`string`&&o(e.error)}function wo(e){return e===`info`||e===`success`||e===`warning`||e===`error`}var To=class{serverComponentBuilder;rustServerUrl;pendingUpdates=/* @__PURE__ */ new Map;pendingFiles=/* @__PURE__ */ new Set;batchTimer=null;DEBOUNCE_DELAY=200;errorHandler;logBatch=[];logBatchTimer=null;LOG_BATCH_DELAY=500;constructor(e,t=N()){this.serverComponentBuilder=e,this.rustServerUrl=`http://localhost:${t}`,this.errorHandler=new bo({maxErrors:5,resetTimeout:3e4})}getErrorCount(){return this.errorHandler.getErrorCount()}async handleClientComponentUpdate(e,t){let n=k.relative(A.cwd(),e);try{let r=t.moduleGraph.getModuleById(e);r?(t.moduleGraph.invalidateModule(r),this.errorHandler.reset()):this.queueLog(`warning`,`Client component module not found in graph: ${n}`)}catch(e){let t=c(e,String(e));this.queueLog(`error`,`Failed to update client component: ${n} - ${t}`),this.errorHandler.recordError(d(e))}return Promise.resolve()}async rebuildAndNotifyNow(e,t){this.serverComponentBuilder.invalidateBuildCacheFor(e);let n=await this.serverComponentBuilder.rebuildComponent(e);if(!n.success)throw Error(n.error!=null&&n.error!==``?n.error:`Build failed`);return await this.notifyRustServer(n.componentId,n.bundlePath),t?.hot.send(`rari:server-component-updated`,{id:n.componentId,t:Date.now()}),n}async handleServerComponentUpdate(e,t){this.pendingFiles.add(e);let n=this.pendingUpdates.get(e);return n&&(clearTimeout(n),this.pendingUpdates.delete(e)),this.batchTimer&&clearTimeout(this.batchTimer),this.batchTimer=setTimeout(()=>{(async()=>{let e=[...this.pendingFiles];if(this.pendingFiles.clear(),this.batchTimer=null,e.length===0)return;let n=this.collectDependentPageComponents(e);for(let e of n)this.serverComponentBuilder.invalidateBuildCacheFor(e);let r=[...e,...n],i=await Promise.allSettled(r.map(async e=>{let t=k.relative(A.cwd(),e);try{let n=await this.serverComponentBuilder.rebuildComponent(e);if(!n.success)throw Error(n.error!=null&&n.error!==``?n.error:`Build failed`);return await this.notifyRustServer(n.componentId,n.bundlePath),{success:!0,componentId:n.componentId,filePath:e,relativePath:t}}catch(n){return{success:!1,filePath:e,relativePath:t,error:d(n)}}})),a=[],o=[];if(i.forEach(e=>{e.status===`fulfilled`&&So(e.value)?a.push(e.value):e.status===`fulfilled`&&Co(e.value)?o.push(e.value):e.status===`rejected`&&o.push({filePath:``,relativePath:`unknown`,error:Error(String(e.reason))})}),a.length>0){let e=Date.now();a.forEach(({componentId:n})=>{t.hot.send(`rari:server-component-updated`,{id:n,t:e})}),this.errorHandler.reset(),t.ws.send({type:`custom`,event:`rari:hmr-error-cleared`,data:{t:e}})}if(o.length>0){let e=Date.now();o.forEach(({relativePath:n,error:r})=>{let i=r.message,a=(r.stack!=null&&r.stack!==``?r.stack:``).substring(0,500);this.queueLog(`error`,`Failed to rebuild: ${n} - ${i}`),this.errorHandler.recordError(r),t.ws.send({type:`custom`,event:`rari:hmr-error`,data:{msg:i,stack:a,file:n,t:e,count:this.errorHandler.getErrorCount(),max:5}})}),this.errorHandler.hasReachedMaxErrors()&&this.queueLog(`error`,`Maximum error count reached (${this.errorHandler.getErrorCount()}). Consider restarting the dev server if issues persist.`)}})()},this.DEBOUNCE_DELAY),Promise.resolve()}relativeBundlePathInsideProject(e){let t=T(e);if(!k.isAbsolute(e))return t;let n=T(k.relative(this.serverComponentBuilder.getProjectRoot(),e));if(n.startsWith(`..`)||k.isAbsolute(n))throw Error(`Bundle path must be inside the project root: ${e}`);return n}assertSuccessfulHmrResponse(e,t,n){if(!u(e))throw Error(`Invalid server response (status ${n}): expected object, got ${typeof e}. Response body: ${t.substring(0,200)}${t.length>200?`...`:``}`);if(e.success===!0)return;let r=typeof e.message==`string`&&e.message!==``?e.message:typeof e.error==`string`&&e.error!==``?e.error:`Component reload failed`;throw Error(r)}async notifyRustServer(e,t){let n=this.relativeBundlePathInsideProject(t);try{let t=await fetch(`${this.rustServerUrl}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`reload-component`,component_id:e,bundle_path:n})});await yo(t);let r=await t.text(),i;try{i=JSON.parse(r)}catch(e){throw Error(`Failed to parse server response (status ${t.status}): ${c(e,String(e))}. Response body: ${r.substring(0,200)}${r.length>200?`...`:``}`)}this.assertSuccessfulHmrResponse(i,r,t.status)}catch(e){throw console.error(`[rari] HMR: Failed to notify Rust server:`,e),e}}collectDependentPageComponents(e){return[...xo(this.serverComponentBuilder.getImportGraph(),e,e=>e.includes(`/app/`)||e.includes(`\\app\\`))]}detectComponentType(e){try{return this.serverComponentBuilder.getModuleAnalysis(e).topLevelUseClient?`client`:`server`}catch{return`unknown`}}queueLog(e,t){this.logBatch.push({type:e,message:t,timestamp:Date.now()}),this.logBatchTimer&&clearTimeout(this.logBatchTimer),this.logBatchTimer=setTimeout(()=>{this.flushLogs()},this.LOG_BATCH_DELAY)}flushLogs(){if(this.logBatch.length===0)return;let e=this.logBatch.reduce((e,t)=>(e[t.type]??=[],e[t.type].push(t),e),{});for(let[t,n]of Object.entries(e))if(wo(t)){if(n.length===1){let e=n[0];this.outputLog(t,e.message)}else{let e=n.map(e=>e.message).join(`
57
+ • `);this.outputLog(t,`${n.length} updates:\n • ${e}`)}}this.logBatch=[],this.logBatchTimer=null}outputLog(e,t){let n=`[rari] HMR:`;switch(e){case`success`:console.warn(`\x1B[32m${n}\x1B[0m ${t}`);break;case`warning`:console.warn(`\x1B[33m${n}\x1B[0m ${t}`);break;case`error`:console.error(`\x1B[31m${n}\x1B[0m ${t}`);break;default:console.warn(`${n} ${t}`)}}dispose(){this.logBatchTimer&&(clearTimeout(this.logBatchTimer),this.flushLogs()),this.batchTimer&&=(clearTimeout(this.batchTimer),null);for(let e of this.pendingUpdates.values())clearTimeout(e);this.pendingUpdates.clear(),this.pendingFiles.clear(),this.errorHandler.dispose()}};function K(e,t){return e.readUInt16BE(t)}function q(e,t){return e.readUInt32BE(t)}function Eo(e,t){return e.readUInt32LE(t)}function Do(e){return e.length<24||e.toString(`ascii`,1,4)!==`PNG`?null:{width:q(e,16),height:q(e,20)}}function Oo(e){if(e.length<10)return null;let t=e.toString(`ascii`,0,6);return t!==`GIF87a`&&t!==`GIF89a`?null:{width:e.readUInt16LE(6),height:e.readUInt16LE(8)}}function ko(e){return e>=192&&e<=195||e>=197&&e<=199||e>=201&&e<=203||e>=205&&e<=207}function Ao(e,t){if(t+7>=e.length)return null;let n=K(e,t),r=e[t+7]??0,i=8+3*r;if(r<1||n<i||t+n>e.length)return null;let a=K(e,t+3),o=K(e,t+5);return o===0||a===0?null:{height:a,width:o}}function jo(e,t){if(t+1>=e.length)return null;let n=K(e,t);return n<2?null:t+n}function Mo(e){if(e.length<4||e[0]!==255||e[1]!==216)return null;let t=2;for(;t+9<=e.length;){if(e[t]!==255){t+=1;continue}if(t+1>=e.length)return null;let n=e[t+1];if(t+=2,ko(n))return Ao(e,t);if(n===217||n===218)return null;let r=jo(e,t);if(r==null)return null;t=r}return null}function No(e,t){return(e[t]??0)|(e[t+1]??0)<<8|(e[t+2]??0)<<16}function Po(e){if(e.length<20||e.toString(`ascii`,0,4)!==`RIFF`||e.toString(`ascii`,8,12)!==`WEBP`)return null;let t=e.toString(`ascii`,12,16);if(t===`VP8X`&&e.length>=30)return{width:No(e,24)+1,height:No(e,27)+1};if(t===`VP8 `&&e.length>=30)return{width:e.readUInt16LE(26)&16383,height:e.readUInt16LE(28)&16383};if(t===`VP8L`&&e.length>=25){if(e[20]!==47)return null;let t=Eo(e,21);return{width:(t&16383)+1,height:(t>>14&16383)+1}}return null}function Fo(e,t,n){if(t+8>n)return null;let r=q(e,t),i=e.toString(`ascii`,t+4,t+8),a=8;if(r===1){if(t+16>n)return null;r=Number(e.readBigUInt64BE(t+8)),a=16}else r===0&&(r=n-t);let o=t+r;return r<a||o>n?null:{type:i,headerSize:a,start:t,end:o}}function*Io(e,t,n){let r=t;for(;r+8<=n;){let t=Fo(e,r,n);if(t==null)return;yield t,r=t.end}}function Lo(e,t){let n=t.start+t.headerSize;return n+4>t.end?null:{version:e[n]??0,flags:(e[n+1]??0)<<16|(e[n+2]??0)<<8|(e[n+3]??0),dataOffset:n+4}}function Ro(e,t){let n=Lo(e,t);return n==null||n.dataOffset+8>t.end?null:{width:q(e,n.dataOffset),height:q(e,n.dataOffset+4)}}function zo(e,t){let n=Lo(e,t);return n==null?null:n.version===0?n.dataOffset+2>t.end?null:K(e,n.dataOffset):n.dataOffset+4>t.end?null:q(e,n.dataOffset)}function Bo(e,t,n,r){return r<1?t+2>n?null:{itemId:K(e,t),nextOffset:t+2}:t+4>n?null:{itemId:q(e,t),nextOffset:t+4}}function Vo(e,t,n,r,i){let a=t,o=[];for(let t=0;t<r;t+=1)if(i){if(a+2>n)return null;let t=K(e,a);a+=2,o.push(t&32767)}else{if(a+1>n)return null;let t=e[a]??0;a+=1,o.push(t&127)}return{propertyIndexes:o,nextOffset:a}}function Ho(e,t){let n=Lo(e,t);if(n==null||n.dataOffset+4>t.end)return null;let r=q(e,n.dataOffset),i=n.dataOffset+4,a=/* @__PURE__ */ new Map,o=!!(n.flags&1);for(let s=0;s<r;s+=1){let r=Bo(e,i,t.end,n.version);if(r==null||(i=r.nextOffset,i+1>t.end))return null;let s=e[i]??0;i+=1;let c=Vo(e,i,t.end,s,o);if(c==null)return null;i=c.nextOffset,a.set(r.itemId,c.propertyIndexes)}return a}function Uo(e){for(let t of Io(e,0,e.length))if(t.type===`meta`)return t;return null}function Wo(e,t,n){let r=1,i=null;for(let a of Io(e,t.start+t.headerSize,t.end)){if(a.type===`ispe`){let t=Ro(e,a);t!=null&&(n.set(r,t),i??=t)}r+=1}return i}function Go(e,t){let n=/* @__PURE__ */ new Map,r=null,i=null;for(let a of Io(e,t.start+t.headerSize,t.end))if(a.type===`ipco`){let t=Wo(e,a,n);i??=t}else a.type===`ipma`&&(r=Ho(e,a));return{ispeByIndex:n,associations:r,firstIspe:i}}function Ko(e,t,n){if(e==null||t==null)return null;let r=t.get(e);if(r==null)return null;for(let e of r){let t=n.get(e);if(t!=null)return t}return null}function qo(e){if(e.length<12||e.toString(`ascii`,4,8)!==`ftyp`)return null;let t=Uo(e);if(t==null)return null;let n=t.start+t.headerSize+4;if(n>t.end)return null;let r=null,i=/* @__PURE__ */ new Map,a=null,o=null;for(let s of Io(e,n,t.end)){if(s.type===`pitm`){r=zo(e,s);continue}if(s.type!==`iprp`)continue;let t=Go(e,s);i=t.ispeByIndex,a=t.associations,o??=t.firstIspe}return Ko(r,a,i)??o}function Jo(e){return e.length<4?null:e[0]===137&&e.toString(`ascii`,1,4)===`PNG`?Do(e):e[0]===255&&e[1]===216?Mo(e):e.toString(`ascii`,0,3)===`GIF`?Oo(e):e.toString(`ascii`,0,4)===`RIFF`?Po(e):qo(e)}const Yo=/\.(?:avif|gif|jpe?g|png|webp)$/i,Xo=`\0rari-static-image:`,Zo=/* @__PURE__ */ new Set([`raw`,`url`,`inline`,`no-inline`]);function Qo(e){let t=e.indexOf(`?`);return t===-1?[]:e.slice(t+1).split(`&`).map(e=>e.split(`=`)[0]??``).filter(Boolean)}function $o(e){return Qo(e).includes(`rari-static-bypass`)}function es(e){return Qo(e).some(e=>Zo.has(e))}function ts(e,t,n){return yi(e,t,n,{encodeBase:!0})}function ns(e,t,n){return`const src = ${JSON.stringify(e)};\nexport default {\n src,\n width: ${t},\n height: ${n},\n};\n`}function rs(e){return Yo.test(C(e))&&!$o(e)&&!es(e)}function is(e,t=`assets`){let n=D.readFileSync(e),r=F(n),i=ts(e,r,t),a=vi(e,r,t),o=Jo(n);if(o==null)throw Error(`[rari] Unable to read dimensions for static image import: ${e}. Pass explicit width/height to <Image>, or convert the file to png/jpeg/webp/gif/avif.`);return{code:ns(i,o.width,o.height),publicPath:i,source:n,fileName:a}}const as=/* @__PURE__ */ new Map,os=/* @__PURE__ */ new Map;function ss(e,t){let n=as.get(e);if(n!=null)return n;let r=/* @__PURE__ */ new Map;if(D.existsSync(t))try{let e=f(D.readFileSync(t,`utf8`));if(e!=null)for(let[t,n]of Object.entries(e))typeof n==`string`&&r.set(t,n)}catch{}return as.set(e,r),r}function cs(e,t,n){for(let[r,i]of e)i===n&&r!==t&&e.delete(r);e.set(t,n)}function ls(e,t){let n=new Set(t.values());for(let[r,i]of e){if(!D.existsSync(i)){e.delete(r);continue}n.has(i)&&t.get(r)!==i&&e.delete(r)}}function us(e){return k.basename(e)===`client`?k.dirname(e):e}function ds(e){return k.join(us(e),`server`,`static-image-sources.json`)}function fs(e,t){let n=us(e),i=ds(e);if(t.size===0){try{D.unlinkSync(i)}catch(e){if(r(e)!==`ENOENT`)throw e}as.delete(n);return}D.mkdirSync(k.dirname(i),{recursive:!0});let a=Object.fromEntries(t);D.writeFileSync(i,`${JSON.stringify(a,null,2)}\n`)}function ps(e){let t=us(e);os.has(t)||os.set(t,/* @__PURE__ */ new Map)}function ms(e){let t=us(e),n=os.get(t);if(n==null)return;let r=ss(t,ds(e));r.clear();for(let[e,t]of n)D.existsSync(t)&&r.set(e,t);fs(e,r),os.delete(t)}function hs(e,t){let n=us(e),r=ss(n,ds(e));for(let[e,n]of t)r.set(e,n);let i=os.get(n);if(i!=null){for(let[e,n]of t)cs(i,e,n);return}ls(r,t),fs(e,r)}function gs(e,t){let n=!1;for(let[r,i]of e)i===t&&(e.delete(r),n=!0);return n}function _s(e){switch(e){case`.png`:return`image/png`;case`.gif`:return`image/gif`;case`.webp`:return`image/webp`;case`.avif`:return`image/avif`;case`.svg`:return`image/svg+xml`;default:return`image/jpeg`}}function vs(e){try{return decodeURIComponent(e)}catch{return e}}function ys(e,t,n,r){let i=t?.split(`?`)[0];if(i==null||i===``){r();return}let a=vs(i),o=e.get(i)??e.get(a);if(o==null||o===``){r();return}n.setHeader(`Content-Type`,_s(k.extname(o).toLowerCase())),n.setHeader(`Cache-Control`,`no-cache`),D.createReadStream(o).on(`error`,()=>{n.headersSent||(n.statusCode=404),n.end()}).pipe(n)}function bs(){let e=process.cwd(),t=k.join(e,`dist`,`client`),n=`assets`,r=!1,i=/* @__PURE__ */ new Map;return{name:`rari:static-image`,enforce:`pre`,configResolved(i){let a=Ht(i);e=a.projectRoot,t=a.outDir,n=a.assetsDir,r=i.command===`build`},buildStart(){r&&ps(t)},async resolveId(e,t){if(t==null||t===``||!rs(e))return null;let n=await this.resolve(e,t,{skipSelf:!0});if(n==null||n.id===``)return null;let r=C(n.id);return D.existsSync(r)?Xo+r:null},load(e){if(!e.startsWith(Xo))return null;let r=e.slice(19),a=is(r,n);return cs(i,a.publicPath,r),hs(t,i),this.emitFile({type:`asset`,fileName:a.fileName,source:a.source}),a.code},watchChange(e,n){if(n.event!==`delete`)return;let r=C(e);if(!gs(i,r))return;let a=os.get(us(t));a!=null&&gs(a,r),hs(t,i)},configureServer(e){e.middlewares.use((e,t,n)=>{ys(i,e.url,t,n)})}}}function xs(e){let t=T(e);return t===`rari/mdx/registry`||t.startsWith(`rari/mdx/registry?`)?!0:t.endsWith(`/mdx/registry.ts`)||t.endsWith(`/mdx/registry.mts`)||t.endsWith(`/mdx/registry.mjs`)||t.endsWith(`/mdx/registry.js`)||t.endsWith(`/mdx/registry`)?t.includes(`/node_modules/rari/`)||t.includes(`/packages/rari/`):!1}function Ss(e,t){let n=e=>{if(D.existsSync(e))for(let r of D.readdirSync(e,{withFileTypes:!0})){let i=k.join(e,r.name);if(r.isDirectory()){if(r.name===`node_modules`||r.name===`.git`||r.name===`dist`)continue;n(i)}else r.isFile()&&r.name.endsWith(`.mdx`)&&t(i)}};for(let t of e)t&&D.existsSync(t)&&n(t)}function Cs(e){let t=/* @__PURE__ */ new Set;return Ss(e,e=>{try{let n=D.readFileSync(e,`utf-8`);for(let e of _e(n))t.add(e)}catch{}}),t}function ws(e,t){try{if(t.get(e).hasDefaultExport)return k.basename(e,k.extname(e));let n=t.getSource(e).match(x);if(n?.[1]!=null&&n[1]!==``)return n[1]}catch{}return k.basename(e,k.extname(e))}function Ts(e){let t=Cs(e.contentDirs.map(t=>k.join(e.projectRoot,t)));if(t.size===0)return[];let n=Er(e.componentScanDirs,e.cache),r=[],i=/* @__PURE__ */ new Set;for(let a of n){let n=ws(a,e.cache);if(n==null||n===``||!t.has(n))continue;let o=Ut(a,e.projectRoot),s=o.startsWith(`/`)?o:`/${o}`,c=n.replace(/[^\w$]/g,`_`);i.has(c)&&(c=`${c}_${r.length}`),i.add(c),r.push({name:n,binding:c,importPath:s,moduleId:o,client:!0})}return r.sort((e,t)=>e.name.localeCompare(t.name))}function Es(e){let t=Os(e.projectRoot,e.mdxOptions),n=e.srcDir??k.join(e.projectRoot,`src`),r=Ms(e.projectRoot,t.componentsDir,yr(n,Object.values(e.alias??{})));return Ts({projectRoot:e.projectRoot,componentsDir:t.componentsDir,contentDirs:t.contentDirs,cache:e.cache,componentScanDirs:r})}function Ds(e,t={}){let n=t.importStyle??`root-absolute`,r=t.mode??`vite`;return e.length===0?`import { defineMdxComponents } from 'rari/mdx/define'
65
58
 
66
59
  export const getMDXComponents = defineMdxComponents([])
67
60
  `:r===`production`?`import { defineMdxComponents } from 'rari/mdx/define'
@@ -78,92 +71,25 @@ export const getMDXComponents = defineMdxComponents([
78
71
  ${e.map(e=>` { name: ${JSON.stringify(e.name)}, component: ${e.binding}, id: ${JSON.stringify(e.moduleId)}, client: ${e.client} }`).join(`,
79
72
  `)},
80
73
  ])
81
- `}function Ya(e,t){return{componentsDir:t?.componentsDir??`src/components`,contentDirs:t?.contentDirs??[`src/content`,`content`,`public/content`]}}function Xa(e,t){return t.map(t=>S.join(e,t)).filter(e=>b.existsSync(e))}function Za(e){let t=[],n=r=>{if(b.existsSync(r))for(let i of b.readdirSync(r,{withFileTypes:!0})){let a=S.join(r,i.name);i.isDirectory()?n(a):i.isFile()&&t.push(y(S.relative(e,a)))}};return n(e),t}function Qa(e,t){for(let n of e)for(let e of Za(n)){let r=S.join(n,e),i=S.join(t,e);if(b.existsSync(i)){console.warn(`[rari] Skipping MDX content conflict: ${e} already copied from an earlier content dir`);continue}b.mkdirSync(S.dirname(i),{recursive:!0}),b.copyFileSync(r,i)}}function $a(e,t,n){let r=S.join(e,t),i=new Set(n);return b.existsSync(r)&&i.add(r),[...i]}const eo=/\.cookies\b|\.headers\b|\.searchParams\b|\.geo\b|\.ip\b|\bwaitUntil\b|\bfetch\s*\(|RariResponse\.json\b|\.startsWith\s*\(|\.includes\s*\(|\.endsWith\s*\(|\bawait\b|`[^`]*\$\{/,to=/RariResponse\.(?:redirect|rewrite)\s*\(/,no=/if\s*\(([^)]+)\)(?:\s*\{)?\s+return\s+RariResponse\.(redirect|rewrite)\(\s*new\s+URL\(\s*(['"`])([^'"`]+)\3\s*,[^)]+\)(?:\s*,\s*(\d+))?\s*\)/g,ro=/^(?:(request\.rariUrl\.pathname|pathname|normalizedPath)\s*(?:===|==)\s*(['"`])([^'"`]+)\2|(['"`])([^'"`]+)\4\s*(?:===|==)\s*(request\.rariUrl\.pathname|pathname|normalizedPath))$/,io=/export\s+const\s+config\s*=/,ao=/export\s+const\s+config\s*=\s*\{/,oo=/matcher\s*:\s*\{/,so=/matcher\s*:\s*(['"`])([^'"`]+)\1/,co=/matcher\s*:\s*\[([^\]]*)\]/,lo=/(['"`])matcher\1\s*:\s*\{/,uo=/(['"`])matcher\1\s*:\s*(['"`])([^'"`]+)\2/,fo=/(['"`])matcher\1\s*:\s*\[([^\]]*)\]/,po=/(['"`])matcher\1\s*:/,mo=/(['"`])([^'"`]+)\1/g,ho=/(?:^|[{,]\s*)matcher\s*[,}]/;function go(e){return e===301||e===308}const _o=/* @__PURE__ */ new Set([`return`,`throw`,`case`,`else`,`do`,`typeof`,`delete`,`void`,`await`,`yield`,`new`,`in`,`of`,`instanceof`]);function vo(e){return e===`
82
- `||e===`\r`||e===`\u2028`||e===`\u2029`}function yo(e,t){let n=t-1;for(;n>=0;){for(;n>=0&&/\s/.test(e.charAt(n));)--n;if(n<0)return!0;if(e.charAt(n)===`/`&&n>0&&e.charAt(n-1)===`*`){for(n-=2;n>=1;){if(e.charAt(n-1)===`/`&&e.charAt(n)===`*`){n-=2;break}--n}continue}let t=n;for(;t>0&&!vo(e.charAt(t-1));)--t;let r=-1;for(let i=t;i<n;i++){if(e.charAt(i)===`/`&&e.charAt(i+1)===`/`){r=i;break}if(e.charAt(i)===`/`&&e.charAt(i+1)===`*`){for(i+=2;i<n&&(e.charAt(i)!==`*`||e.charAt(i+1)!==`/`);)i+=1;i+=1}}if(r!==-1){n=r-1;continue}break}if(n<0)return!0;let r=e.charAt(n);if(/[)}\]]/.test(r))return!1;if(!/[\w$]/.test(r))return!0;let i=n;for(;i>=0&&/[\w$]/.test(e.charAt(i));)--i;let a=e.slice(i+1,n+1);return _o.has(a)}function bo(e){return e===`
83
- `||e===`\r`||e===`\u2028`||e===`\u2029`}function xo(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e.charAt(r);if(t==="`"&&i===`$`&&e.charAt(r+1)===`{`)return null;if(i!==`\\`){n+=i;continue}if(r+=1,r>=e.length)return null;let a=e.charAt(r);if(bo(a)){a===`\r`&&e.charAt(r+1)===`
84
- `&&(r+=1);continue}switch(a){case`n`:n+=`
85
- `;break;case`r`:n+=`\r`;break;case`t`:n+=` `;break;case`b`:n+=`\b`;break;case`f`:n+=`\f`;break;case`v`:n+=`\v`;break;case`0`:n+=`\0`;break;case`\\`:case`'`:case`"`:case"`":case`/`:n+=a;break;case`x`:{let t=e.slice(r+1,r+3);if(!/^[\da-f]{2}$/i.test(t))return null;n+=String.fromCharCode(Number.parseInt(t,16)),r+=2;break}case`u`:{if(e.charAt(r+1)===`{`){let t=e.indexOf(`}`,r+2);if(t===-1)return null;let i=e.slice(r+2,t);if(!/^[\da-f]+$/i.test(i))return null;n+=String.fromCodePoint(Number.parseInt(i,16)),r=t;break}let t=e.slice(r+1,r+5);if(!/^[\da-f]{4}$/i.test(t))return null;n+=String.fromCharCode(Number.parseInt(t,16)),r+=4;break}default:n+=a}}return n}function So(e,t,n){for(let r=t+1;r<e.length;r++){let t=e[r];if(t===`\\`){r+=1;continue}if(n==="`"&&t===`$`&&e[r+1]===`{`)return null;if(t===n)return r+1}return null}function Co(e,t){let n=[{kind:`code`,braceDepth:0}];for(let r=t;r<e.length;){let i=n.at(-1);if(i===void 0)return null;let a=e[r],o=e[r+1];if(i.kind===`line-comment`){a===`
86
- `&&n.pop(),r+=1;continue}if(i.kind===`block-comment`){a===`*`&&o===`/`?(n.pop(),r+=2):r+=1;continue}if(i.kind===`single`||i.kind===`double`){if(a===`\\`){r+=2;continue}(i.kind===`single`&&a===`'`||i.kind===`double`&&a===`"`)&&n.pop(),r+=1;continue}if(i.kind===`template`){if(a===`\\`){r+=2;continue}if(a==="`"){n.pop(),r+=1;continue}if(a===`$`&&o===`{`){n.push({kind:`code`,braceDepth:1}),r+=2;continue}r+=1;continue}if(i.kind===`regex`){if(a===`\\`){r+=2;continue}if(a===`[`){n.push({kind:`regex-class`}),r+=1;continue}if(a===`/`){for(n.pop(),r+=1;r<e.length&&/[a-z]/i.test(e.charAt(r));)r+=1;continue}r+=1;continue}if(i.kind===`regex-class`){if(a===`\\`){r+=2;continue}if(a===`]`){n.pop(),r+=1;continue}r+=1;continue}if(a===`/`&&o===`/`){n.push({kind:`line-comment`}),r+=2;continue}if(a===`/`&&o===`*`){n.push({kind:`block-comment`}),r+=2;continue}if(a===`/`&&yo(e,r)){n.push({kind:`regex`}),r+=1;continue}if(a===`'`){n.push({kind:`single`}),r+=1;continue}if(a===`"`){n.push({kind:`double`}),r+=1;continue}if(a==="`"){n.push({kind:`template`}),r+=1;continue}if(a===`{`){i.braceDepth+=1,r+=1;continue}if(a===`}`){if(--i.braceDepth,r+=1,i.braceDepth===0){if(n.length===1)return e.slice(t,r);n.pop()}continue}r+=1}return null}function wo(e,t){let n=t+1;for(;n<e.length&&/\s/.test(e[n]);)n+=1;if(n>=e.length)return null;let r=e[n];if(r===`'`||r===`"`||r==="`"){if(r==="`"&&So(e,n,"`")==null)return{forceRuntime:!0,endIndex:e.length};let t=So(e,n,r);if(t==null)return{forceRuntime:!0,endIndex:e.length};let i=e.slice(n+1,t-1);if(r==="`"&&i.includes("${"))return{forceRuntime:!0,endIndex:t};let a=xo(i,r);return a==null||a===``?{forceRuntime:!0,endIndex:t}:{matcher:a,forceRuntime:!1,endIndex:t}}if(r===`[`){let t=n+1,r=1,i=t,a=[{kind:`code`,braceDepth:0}];for(;i<e.length&&r>0;){let t=a.at(-1);if(t===void 0)return{forceRuntime:!0,endIndex:e.length};let n=e[i],o=e[i+1];if(t.kind===`line-comment`){n===`
87
- `&&a.pop(),i+=1;continue}if(t.kind===`block-comment`){n===`*`&&o===`/`?(a.pop(),i+=2):i+=1;continue}if(t.kind===`single`||t.kind===`double`||t.kind===`template`){if(n===`\\`){i+=2;continue}if(t.kind===`template`&&n===`$`&&o===`{`)return{forceRuntime:!0,endIndex:e.length};(t.kind===`single`&&n===`'`||t.kind===`double`&&n===`"`||t.kind===`template`&&n==="`")&&a.pop(),i+=1;continue}if(n===`/`&&o===`/`){a.push({kind:`line-comment`}),i+=2;continue}if(n===`/`&&o===`*`){a.push({kind:`block-comment`}),i+=2;continue}if(n===`'`){a.push({kind:`single`}),i+=1;continue}if(n===`"`){a.push({kind:`double`}),i+=1;continue}if(n==="`"){a.push({kind:`template`}),i+=1;continue}if(n===`[`){r+=1,i+=1;continue}if(n===`]`){--r,i+=1;continue}if(n===`{`)return{forceRuntime:!0,endIndex:i};i+=1}return r===0?{...ko(e.slice(t,i-1)),endIndex:i}:{forceRuntime:!0,endIndex:e.length}}return{forceRuntime:!0,endIndex:n+1}}function To(e){let t=[{kind:`code`,braceDepth:0}],n=[];for(let r=0;r<e.length;){let i=t.at(-1);if(i===void 0)return{forceRuntime:!0};let a=e[r],o=e[r+1];if(i.kind===`line-comment`){a===`
88
- `&&t.pop(),r+=1;continue}if(i.kind===`block-comment`){a===`*`&&o===`/`?(t.pop(),r+=2):r+=1;continue}if(i.kind===`single`||i.kind===`double`){if(a===`\\`){r+=2;continue}(i.kind===`single`&&a===`'`||i.kind===`double`&&a===`"`)&&t.pop(),r+=1;continue}if(i.kind===`template`){if(a===`\\`){r+=2;continue}if(a==="`"){t.pop(),r+=1;continue}if(a===`$`&&o===`{`){t.push({kind:`code`,braceDepth:1}),r+=2;continue}r+=1;continue}if(i.kind===`regex`){if(a===`\\`){r+=2;continue}if(a===`[`){t.push({kind:`regex-class`}),r+=1;continue}if(a===`/`){for(t.pop(),r+=1;r<e.length&&/[a-z]/i.test(e.charAt(r));)r+=1;continue}r+=1;continue}if(i.kind===`regex-class`){if(a===`\\`){r+=2;continue}if(a===`]`){t.pop(),r+=1;continue}r+=1;continue}if(a===`/`&&o===`/`){t.push({kind:`line-comment`}),r+=2;continue}if(a===`/`&&o===`*`){t.push({kind:`block-comment`}),r+=2;continue}if(a===`/`&&yo(e,r)){t.push({kind:`regex`}),r+=1;continue}if(a===`'`){t.push({kind:`single`}),r+=1;continue}if(a===`"`){t.push({kind:`double`}),r+=1;continue}if(a==="`"){t.push({kind:`template`}),r+=1;continue}if(a===`{`){i.braceDepth+=1,r+=1;continue}if(a===`}`){--i.braceDepth,r+=1,i.braceDepth===0&&t.length>1&&t.pop();continue}let s=r===0?``:e.charAt(r-1),c=r===0||/[\s;{}]/.test(s);if(i.braceDepth===0&&t.length===1&&c&&e.startsWith(`const matcher`,r)){let t=r+13;if(t<e.length&&/[\w$]/.test(e.charAt(t))){r+=1;continue}let i=t;for(;i<e.length&&/\s/.test(e.charAt(i));)i+=1;if(e.charAt(i)!==`=`){r+=1;continue}let a=wo(e,i);if(a==null||a.forceRuntime)return{forceRuntime:!0};n.push({matcher:a.matcher,forceRuntime:!1}),r=a.endIndex;continue}if(i.braceDepth===0&&t.length===1&&c&&(e.startsWith(`let matcher`,r)||e.startsWith(`var matcher`,r)))return{forceRuntime:!0};r+=1}return n.length===0?null:n.length>1?{forceRuntime:!0}:n[0]??null}function Eo(e){let t=e.trim();if(t===``||t.includes(`&&`))return null;let n=t.split(/\|\|/),r=[],i;for(let e of n){let t=ro.exec(e.trim());if(t==null)return null;let n=t[1]||t[6]||``,a=t[3]||t[5]||``;if(n===``||a===``)return null;if(i==null)i=n;else if(i!==n)return null;r.push(a)}return r.length>0?r:null}function Do(e){let t=[];no.lastIndex=0;for(let n of e.matchAll(no)){let e=n[1],r=n[2],i=n[4],a=Number.parseInt(n[5],10),o=Number.isFinite(a)?a:void 0;if(e===``||i===``||r!==`redirect`&&r!==`rewrite`)continue;let s=Eo(e);if(s==null)return[];for(let e of s)t.push({source:e,type:r,destination:i,...r===`redirect`?{permanent:go(o)}:{}})}return t}function Oo(e){let t=ao.exec(e);return t==null?null:Co(e,t.index+t[0].length-1)}function ko(e){if(e.includes(`{`))return{forceRuntime:!0};let t=[];mo.lastIndex=0;for(let n of e.matchAll(mo)){let e=n[1],r=n[2];if(r===``||e!==`'`&&e!==`"`&&e!=="`")continue;let i=xo(r,e);if(i==null)return{forceRuntime:!0};i!==``&&t.push(i)}return e.replace(mo,``).replace(/[\s,]/g,``)===``&&t.length>0?{matcher:t,forceRuntime:!1}:{forceRuntime:!0}}function Ao(e,t){let n=[{kind:`code`,braceDepth:0}];for(let r=0;r<t;){let i=n.at(-1);if(i===void 0)return null;let a=e.charAt(r),o=e.charAt(r+1);if(i.kind===`line-comment`){a===`
89
- `&&n.pop(),r+=1;continue}if(i.kind===`block-comment`){a===`*`&&o===`/`?(n.pop(),r+=2):r+=1;continue}if(i.kind===`single`||i.kind===`double`){if(a===`\\`){r+=2;continue}(i.kind===`single`&&a===`'`||i.kind===`double`&&a===`"`)&&n.pop(),r+=1;continue}if(i.kind===`template`){if(a===`\\`){r+=2;continue}if(a==="`"){n.pop(),r+=1;continue}if(a===`$`&&o===`{`){n.push({kind:`code`,braceDepth:1}),r+=2;continue}r+=1;continue}if(i.kind===`regex`){if(a===`\\`){r+=2;continue}if(a===`[`){n.push({kind:`regex-class`}),r+=1;continue}if(a===`/`){for(n.pop(),r+=1;r<t&&/[a-z]/i.test(e.charAt(r));)r+=1;continue}r+=1;continue}if(i.kind===`regex-class`){if(a===`\\`){r+=2;continue}if(a===`]`){n.pop(),r+=1;continue}r+=1;continue}if(a===`/`&&o===`/`){n.push({kind:`line-comment`}),r+=2;continue}if(a===`/`&&o===`*`){n.push({kind:`block-comment`}),r+=2;continue}if(a===`/`&&yo(e,r)){n.push({kind:`regex`}),r+=1;continue}if(a===`'`){n.push({kind:`single`}),r+=1;continue}if(a===`"`){n.push({kind:`double`}),r+=1;continue}if(a==="`"){n.push({kind:`template`}),r+=1;continue}if(a===`{`){i.braceDepth+=1,r+=1;continue}if(a===`}`){--i.braceDepth,r+=1,i.braceDepth===0&&n.length>1&&n.pop();continue}r+=1}let r=n.at(-1);return r?.kind===`code`?r.braceDepth:null}function jo(e,t){return Ao(e,t)===1}function Mo(e){return e.startsWith(`'`)||e.startsWith(`"`)||e.startsWith("`")}function No(e,t){let n=new RegExp(t.source,t.flags.includes(`g`)?t.flags:`${t.flags}g`);for(let t of e.matchAll(n)){let n=Mo(t[0])?t.index:t.index+t[0].indexOf(`matcher`);if(n>=t.index&&jo(e,n))return t}return null}function Po(e,t){let n=t;for(;n<e.length;){let t=e.charAt(n),r=e.charAt(n+1);if(/\s/.test(t)){n+=1;continue}if(t===`/`&&r===`/`){for(n+=2;n<e.length&&!vo(e.charAt(n));)n+=1;continue}if(t===`/`&&r===`*`){for(n+=2;n+1<e.length&&(e.charAt(n)!==`*`||e.charAt(n+1)!==`/`);)n+=1;n+=2;continue}return t===`,`||t===`}`}return!0}function Fo(e,t){let n=t;for(;n<e.length;){let t=e.charAt(n),r=e.charAt(n+1);if(/\s/.test(t)){n+=1;continue}if(t===`/`&&r===`/`){for(n+=2;n<e.length&&!vo(e.charAt(n));)n+=1;continue}if(t===`/`&&r===`*`){for(n+=2;n+1<e.length&&(e.charAt(n)!==`*`||e.charAt(n+1)!==`/`);)n+=1;n+=2;continue}break}return n}function Io(e,t){if(e.charAt(t)!==`[`)return null;let n=Fo(e,t+1);if(n>=e.length)return{endIndex:e.length,forceRuntime:!0};let r=e.charAt(n);if(r===`'`||r===`"`||r==="`"){let t=So(e,n,r);if(t==null)return{endIndex:e.length,forceRuntime:!0};let i=e.slice(n+1,t-1);if(r==="`"&&i.includes("${"))return{endIndex:t,forceRuntime:!0};let a=xo(i,r);return n=Fo(e,t),e.charAt(n)===`]`?{endIndex:n+1,forceRuntime:a===`matcher`}:{endIndex:n,forceRuntime:!0}}return{endIndex:t+1,forceRuntime:!0}}function Lo(e){let t=[{kind:`code`,braceDepth:0}],n=!1;for(let r=0;r<e.length;){let i=t.at(-1);if(i===void 0)return!1;let a=e.charAt(r),o=e.charAt(r+1);if(i.kind===`line-comment`){a===`
90
- `&&t.pop(),r+=1;continue}if(i.kind===`block-comment`){a===`*`&&o===`/`?(t.pop(),r+=2):r+=1;continue}if(i.kind===`single`||i.kind===`double`){if(a===`\\`){r+=2;continue}(i.kind===`single`&&a===`'`||i.kind===`double`&&a===`"`)&&t.pop(),r+=1;continue}if(i.kind===`template`){if(a===`\\`){r+=2;continue}if(a==="`"){t.pop(),r+=1;continue}if(a===`$`&&o===`{`){t.push({kind:`code`,braceDepth:1}),r+=2;continue}r+=1;continue}if(i.kind===`regex`){if(a===`\\`){r+=2;continue}if(a===`[`){t.push({kind:`regex-class`}),r+=1;continue}if(a===`/`){for(t.pop(),r+=1;r<e.length&&/[a-z]/i.test(e.charAt(r));)r+=1;continue}r+=1;continue}if(i.kind===`regex-class`){if(a===`\\`){r+=2;continue}if(a===`]`){t.pop(),r+=1;continue}r+=1;continue}if(a===`/`&&o===`/`){t.push({kind:`line-comment`}),r+=2;continue}if(a===`/`&&o===`*`){t.push({kind:`block-comment`}),r+=2;continue}if(a===`/`&&yo(e,r)){t.push({kind:`regex`}),r+=1;continue}if(a===`'`){n&&i.braceDepth===1&&(n=!1),t.push({kind:`single`}),r+=1;continue}if(a===`"`){n&&i.braceDepth===1&&(n=!1),t.push({kind:`double`}),r+=1;continue}if(a==="`"){n&&i.braceDepth===1&&(n=!1),t.push({kind:`template`}),r+=1;continue}if(a===`{`){i.braceDepth+=1,i.braceDepth===1&&(n=!0),r+=1;continue}if(a===`}`){--i.braceDepth,n=!1,r+=1,i.braceDepth===0&&t.length>1&&t.pop();continue}if(a===`,`&&i.braceDepth===1){n=!0,r+=1;continue}if(a===`:`&&i.braceDepth===1){n=!1,r+=1;continue}if(n&&i.braceDepth===1&&!/\s/.test(a)){if(a===`.`&&o===`.`&&e.charAt(r+2)===`.`)return!0;if(a===`[`){let t=Io(e,r);if(t?.forceRuntime===!0)return!0;if(t!=null){n=!1,r=t.endIndex;continue}return!0}n=!1}r+=1}return!1}function Ro(e){if(!io.test(e)||!ao.test(e))return{forceRuntime:!1};let t=Oo(e);if(t==null||Lo(t)||No(t,oo)!=null||No(t,lo)!=null)return{forceRuntime:!0};let n=No(t,so)??No(t,uo);if(n!=null){let e=Mo(n[0]),r=e?n[2]:n[1],i=e?n[3]:n[2];if(r===`'`||r===`"`||r==="`"){if(r==="`"&&i.includes("${")||!Po(t,n.index+n[0].length))return{forceRuntime:!0};let e=xo(i,r);return e==null||e===``?{forceRuntime:!0}:{matcher:e,forceRuntime:!1}}}let r=No(t,co)??No(t,fo);return r==null?No(t,ho)==null?No(t,/matcher\s*:/)!=null||No(t,po)!=null?{forceRuntime:!0}:{forceRuntime:!1}:To(e)??{forceRuntime:!0}:Po(t,r.index+r[0].length)?ko(Mo(r[0])?r[2]:r[1]):{forceRuntime:!0}}function zo(e){let{matcher:t,forceRuntime:n}=Ro(e);if(n||eo.test(e))return{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}};let r=to.test(e),i=Do(e);return r&&i.length===0?{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}}:{requiresRuntime:!1,rules:i,...t==null?{}:{matcher:t}}}function Bo(e){let t=zo(e.code),n=t.requiresRuntime;return{proxyFile:e.proxyFile,enabled:!0,generated:e.generated??(/* @__PURE__ */ new Date()).toISOString(),rules:t.rules,requiresRuntime:n,...n&&e.bundlePath!=null&&e.bundlePath!==``?{bundlePath:e.bundlePath}:{},...t.matcher==null?{}:{matcher:t.matcher}}}const Vo=/@import\s+(?:url\(\s*)?['"](?![a-zA-Z][a-zA-Z0-9+.-]*:|\/\/|\.\/|\.\.\/|\/)[^'"]+['"][^;]*(?:;|$)/g,Ho=/@import\s+(?:url\(\s*((?:\.\/|\.\.\/)[^)\s]+)\s*\)|url\(\s*['"]((?:\.\/|\.\.\/)[^'"]+)['"]\s*\)|['"]((?:\.\/|\.\.\/)[^'"]+)['"])([^;]*)(?:;|$)/g,Uo=/\.css(?:\?.*)?$/,Wo=/\.module\.css(?:\?.*)?$/i;function Go(e){return Wo.test(e.replace(/[?#].*$/,``))}function Ko(e){return e.replace(Vo,``).trim()}function qo(e){let t=e.trim().replace(/^\)\s*/,``),n=null,r=null;if(/^layer\s*\(/i.exec(t)){let e=t.indexOf(`(`),r=t.indexOf(`)`,e);r!==-1&&(n=t.slice(e+1,r).trim(),t=t.slice(r+1).trim())}else/^layer(?:\s|$)/i.test(t)&&(n=``,t=t.replace(/^layer\s*/i,``));if(/^supports\s*\(/i.test(t)){let e=t.indexOf(`(`),n=0,i=-1;for(let r=e;r<t.length;r++){let e=t[r];if(e===`(`)n++;else if(e===`)`&&(n--,n===0)){i=r;break}}i!==-1&&(r=t.slice(e+1,i).trim(),t=t.slice(i+1).trim())}let i=t.trim()===``?null:t.trim();return{layerName:n,supportsCondition:r,mediaQuery:i}}function Jo(e,t){let n=e.trim();return n===``?``:(t.layerName!==null&&(n=t.layerName===``?`@layer {\n${n}\n}`:`@layer ${t.layerName} {\n${n}\n}`),t.supportsCondition!=null&&t.supportsCondition!==``&&(n=`@supports (${t.supportsCondition}) {\n${n}\n}`),t.mediaQuery!=null&&t.mediaQuery!==``&&(n=`@media ${t.mediaQuery} {\n${n}\n}`),n)}function Yo(e,t,n=/* @__PURE__ */ new Set){let r=S.resolve(e);return n.has(r)?``:(n.add(r),t.replace(Ho,(e,t,i,a,o)=>{let s=t??i??a;if(s==null||s===``)return e;let c=S.resolve(S.dirname(r),s);try{return!b.existsSync(c)||!b.statSync(c).isFile()?e:Jo(Xo(c,b.readFileSync(c,`utf-8`),new Set(n)),qo(o))}catch{return e}}).trim())}function Xo(e,t,n=/* @__PURE__ */ new Set){return Yo(e,Ko(t),n)}function Zo(e,t){let n=/* @__PURE__ */ new Set;for(let r of lr(e,t)){if(S.isAbsolute(r)){n.add(S.resolve(r));continue}try{n.add(Ee(S.join(e,`package.json`)).resolve(r))}catch{}}return n}function Qo(e,t,n,r){let i=e.replace(/[?#].*$/,``);if(!Uo.test(i))return null;if(S.isAbsolute(i))return b.existsSync(i)&&b.statSync(i).isFile()?i:null;if(i.startsWith(`./`)||i.startsWith(`../`)){let e=S.resolve(S.dirname(t),i);return b.existsSync(e)&&b.statSync(e).isFile()?e:null}let a=xe(i,r,n);if(a!=null&&a!==``&&b.existsSync(a)&&b.statSync(a).isFile())return a;let o=[t,S.join(n,`package.json`)];for(let e of o)try{let t=Ee(e).resolve(i);if(b.existsSync(t)&&b.statSync(t).isFile())return t}catch{try{let t=w(import.meta.resolve(i,Me(e).href));if(b.existsSync(t)&&b.statSync(t).isFile())return t}catch{}}return null}function $o(e){let t=[];for(let n of yn(e.code)){if(!Uo.test(n.source)||Go(n.source))continue;let r=n.source.includes(`?`)?n.source.slice(n.source.indexOf(`?`)):``;if(/(?:\?|&)raw(?:&|$)/.test(r)||/(?:\?|&)url(?:&|$)/.test(r))continue;let i=Qo(n.source,e.filePath,e.projectRoot,e.aliases);if(i!=null&&!Go(i)&&!e.layoutCssSkip.has(S.resolve(i)))try{let e=Xo(i,b.readFileSync(i,`utf-8`));e!==``&&t.push(e)}catch{}}return t}const es=/^proxy\.(?:tsx?|jsx?|mts|mjs)$/,ts=/^(?:robots|sitemap|feed)\.(?:tsx?|jsx?)$/,ns=/^(?:favicon|icon\d*|apple-icon\d*)\.(?:ico|png|jpe?g|svg)$/i,rs=/^layout\.(?:tsx|ts|jsx|js)$/,is=[{componentId:`rari/image`,devSourceSegments:[`src`,`image`,`image.tsx`],publishedExport:`rari/image`,exports:[`Image`]}],as=S.dirname(w(import.meta.url)),os=S.dirname(as);function ss(e){return e.startsWith(os)}function cs(){let e=S.join(os,`src`,`runtime`,`boundaries`,`error-boundary-wrapper.tsx`);if(b.existsSync(e))return e;try{let e=w(import.meta.resolve(`rari/runtime/ErrorBoundaryWrapper`));if(b.existsSync(e))return e}catch{}return null}function ls(e){let t=y(e);return t.includes(`ErrorBoundaryWrapper`)||t.includes(`/boundaries/error-boundary-wrapper`)||t.endsWith(`/error-boundary-wrapper.tsx`)}function us(e){return l(e)&&l(e.components)}function ds(e,t){if(ls(e))return`virtual:error-boundary-wrapper.tsx`;let n=y(S.relative(t,e));return n.startsWith(`..`)||S.isAbsolute(n)?y(e):n}function fs(e,t){if(ls(e))return`error_boundary_wrapper_${qt(`virtual:error-boundary-wrapper.tsx`)}`;if(ss(e)){let t=y(S.relative(os,e));return`${Yt(t)}_${qt(t)}`}return Xt(e,t)}function ps(e,t){return!e.includes(`node_modules`)&&!t.directives.hasUseClient&&!t.directives.hasUseServer}var ms=class{serverComponents=/* @__PURE__ */ new Map;serverActions=/* @__PURE__ */ new Map;options;projectRoot;buildCache=/* @__PURE__ */ new Map;useCacheBuildId=null;fileImporters=/* @__PURE__ */ new Map;moduleAnalysisCache;discoveredExternalClientComponents=/* @__PURE__ */ new Set;clientComponentFiles=/* @__PURE__ */ new Map;layoutCssSkipSet=null;viteBuilder=null;envEmitLock=Promise.resolve();getLayoutCssSkipSet(){return this.layoutCssSkipSet??=Zo(this.projectRoot,this.options.alias),this.layoutCssSkipSet}resolveServerCssSources(e,t){return $o({filePath:e,code:t,projectRoot:this.projectRoot,aliases:this.options.alias,layoutCssSkip:this.getLayoutCssSkipSet()})}resolveExtraFileOutPath(e){let t=y(e);return t===this.options.assetsDir||t.startsWith(`${this.options.assetsDir}/`)?S.join(this.options.outDir,t):S.join(this.options.outDir,this.options.rscDir,t)}setViteBuilder(e){this.viteBuilder=e}getProjectRoot(){return this.projectRoot}async getEmitBuilder(){return this.viteBuilder??=await me({root:this.projectRoot,logLevel:`error`}),this.viteBuilder}async withEnvEmitLock(e){let t=this.envEmitLock,n;this.envEmitLock=new Promise(e=>{n=e}),await t;try{return await e()}finally{n()}}async emitRscEntries(e,t){return this.withEnvEmitLock(async()=>{let n=await this.getEmitBuilder(),r=await ve({viteBuilder:n,entries:e,minify:t?.minify??this.options.minify,codeSplitting:t?.codeSplitting});if(r==null)throw Error(`Vite RSC environment build failed`);return r})}recordClientComponent(e,t){this.clientComponentFiles.set(e,t)}getClientComponentFiles(){return[...this.clientComponentFiles.entries()].map(([e,t])=>({filePath:e,code:t}))}getClientComponentPaths(){return[...this.clientComponentFiles.keys()]}getModuleAnalysisCache(){return this.moduleAnalysisCache}clearClientComponentFiles(){this.clientComponentFiles.clear()}getComponentCount(){return this.serverComponents.size+this.serverActions.size}hasComponent(e){return this.serverComponents.has(e)||this.serverActions.has(e)}removeComponent(e){this.serverComponents.delete(e),this.serverActions.delete(e),this.moduleAnalysisCache.invalidate(e)}getImportGraph(){let e=/* @__PURE__ */ new Map;for(let[t,n]of this.fileImporters)e.set(t,new Set(n));return e}async writeComponentCssAsset(e,t){if(t.length===0)return[];let n=S.join(this.options.outDir,`assets`,`server`);await b.promises.mkdir(n,{recursive:!0});let r=`${t.join(`
91
- `)}\n`,i=`${qt(e+r,12)}.css`,a=S.join(n,i);return await b.promises.writeFile(a,r,`utf-8`),[`/assets/server/${i}`]}getComponentIdFromRouteManifestPath(e){return this.getComponentId(S.join(this.projectRoot,`src`,`app`,e))}getComponentReferenceId(e){return this.getReadableComponentId(this.getProjectRelativePath(e))}async writeRouteCssEntries(e){let t=S.join(this.options.outDir,this.options.rscDir,`routes.json`);if(!b.existsSync(t))return;let n=await b.promises.readFile(t,`utf-8`),r=JSON.parse(n);if(!l(r))return;let i=r,a=t=>{if(Array.isArray(t))for(let n of t){if(!l(n))continue;let t=n.filePath;if(typeof t!=`string`||t===``)continue;let r=this.getComponentIdFromRouteManifestPath(t);n.componentId=r;let i=e.components[r]?.css??[];i.length?n.css=i:delete n.css}};a(i.routes),a(i.layouts),a(i.loading),a(i.errors),a(i.notFound),a(i.templates);let o=i.apiRoutes;if(Array.isArray(o))for(let e of o){if(!l(e))continue;let t=e.filePath;typeof t==`string`&&t!==``&&(e.componentId=this.getComponentIdFromRouteManifestPath(t))}await b.promises.writeFile(t,JSON.stringify(i),`utf-8`)}constructor(e,t={}){this.projectRoot=S.resolve(e),this.moduleAnalysisCache=t.moduleAnalysisCache??new Zn;let n=t.rscDir!=null&&t.rscDir!==``?t.rscDir:`server`,r=t.outDir!=null&&t.outDir!==``?t.outDir:S.join(this.projectRoot,`dist`);this.options={outDir:S.isAbsolute(r)?r:S.resolve(this.projectRoot,r),rscDir:n,manifestPath:t.manifestPath!=null&&t.manifestPath!==``?t.manifestPath:S.join(n,`manifest.json`),serverConfigPath:t.serverConfigPath!=null&&t.serverConfigPath!==``?t.serverConfigPath:S.join(n,`config.json`),minify:t.minify??C.env.NODE_ENV===`production`,alias:t.alias??{},assetsDir:t.assetsDir!=null&&t.assetsDir!==``?fe(t.assetsDir):`assets`,define:t.define,csp:t.csp,cacheControl:t.cacheControl,cache:t.cache,action:t.action,jsPoolSize:t.jsPoolSize,origin:t.origin,htmlLimitedBots:t.htmlLimitedBots,experimental:t.experimental,mdx:t.mdx}}getModuleAnalysis(e,t){return this.moduleAnalysisCache.get(e,t)}isServerComponent(e,t){try{return ps(e,this.moduleAnalysisCache.get(e,t))}catch{return!1}}isClientComponent(e,t){try{return this.moduleAnalysisCache.get(e,t).directives.hasUseClient}catch{return!1}}resolveImportedFilePath(e,t){let n=null;if(t.startsWith(`./`)||t.startsWith(`../`)){let r=S.dirname(e);n=S.resolve(r,t)}else if(n=xe(t,this.options.alias,this.projectRoot),(n==null||n===``)&&t.startsWith(`@/`)){let e=t.slice(2);n=S.join(this.projectRoot,`src`,e)}return n==null||n===``?null:Se(n,[``,`.ts`,`.tsx`,`.js`,`.jsx`])}populateImportGraphFromFiles(e){this.fileImporters.clear();for(let{filePath:t,analysis:n}of e)for(let e of qn(n.importSources)){let n=this.resolveImportedFilePath(t,e);n!=null&&n!==``&&(this.fileImporters.has(n)||this.fileImporters.set(n,/* @__PURE__ */ new Set),this.fileImporters.get(n).add(t))}}buildImportGraph(e){let t=hs(this,[e]);this.populateImportGraphFromFiles(t)}isOnlyImportedByClientComponents(e){let t=this.fileImporters.get(e);if(!t||t.size===0)return!1;for(let e of t)if(!this.isClientComponent(e)&&!this.isOnlyImportedByClientComponents(e))return!1;return!0}addServerComponent(e,t,n){let r=t??b.readFileSync(e,`utf-8`),i=n??this.moduleAnalysisCache.get(e,r),a=Kn(i.importSources),o=Gn(i);if(i.directives.hasUseServer){this.serverActions.set(e,{filePath:e,originalCode:r,dependencies:a,hasNodeImports:o});return}ps(e,i)&&this.serverComponents.set(e,{filePath:e,originalCode:r,dependencies:a,hasNodeImports:o})}isServerAction(e,t){return t!=null&&t!==``?this.moduleAnalysisCache.get(t,e).directives.hasUseServer:mn(e).directives.hasUseServer}extractDependencies(e,t){return Kn((t!=null&&t!==``?this.moduleAnalysisCache.get(t,e):mn(e)).importSources)}hasNodeImports(e,t){return Gn(t!=null&&t!==``?this.moduleAnalysisCache.get(t,e):mn(e))}async getTransformedComponentsForDevelopment(e){let t=[];for(let[n]of this.serverComponents)(!e||e(n))&&t.push({componentId:this.getComponentId(n),filePath:n,isAction:!1});for(let[n]of this.serverActions)(!e||e(n))&&t.push({componentId:this.getComponentId(n),filePath:n,isAction:!0});if(t.length===0)return[];let n=await this.emitRscEntries(t.map(({componentId:e,filePath:t})=>({componentId:e,filePath:t})),{minify:this.options.minify,codeSplitting:!1});for(let e of n.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await b.promises.mkdir(S.dirname(t),{recursive:!0}),await b.promises.writeFile(t,e.code)}return t.map(e=>{let t=n.outputs.get(e.componentId);if(t==null)throw Error(`Vite RSC environment build missed entry: ${e.componentId}`);return{id:e.componentId,code:t.code,isAction:e.isAction}})}async emitProxyManifest(e){let t=S.join(e,`proxy.json`),r=[...this.serverComponents.entries()].filter(([e])=>es.test(S.basename(e)));if(r.length===0){try{await b.promises.unlink(t)}catch(e){n(e)!==`ENOENT`&&console.warn(`Failed to remove proxy manifest file:`,e)}return}let[i,a]=r[0],o=y(this.getProjectRelativePath(i)),s=this.getComponentId(o),c=y(S.join(this.options.rscDir,`${s}.js`)),l=Bo({proxyFile:o,code:a.originalCode,bundlePath:c});l.requiresRuntime||this.serverComponents.delete(i),await b.promises.writeFile(t,JSON.stringify(l),`utf-8`)}async buildServerComponents(){let e=S.join(this.options.outDir,this.options.rscDir);await b.promises.mkdir(e,{recursive:!0}),await this.emitProxyManifest(e);let t={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},r=this.options.experimental?.useCache===!0||this.options.experimental?.useCacheRemote!=null,i=[...this.serverComponents.entries(),...this.serverActions.entries()],a=await this.buildRscEntriesWithVite(i);for(let e of a.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await b.promises.mkdir(S.dirname(t),{recursive:!0}),await b.promises.writeFile(t,e.code)}for(let[e,n]of a.entries){let r=S.relative(this.projectRoot,e),i=this.getComponentId(e),a=ye(this.options.rscDir,i),o=S.join(this.options.outDir,a);await b.promises.mkdir(S.dirname(o),{recursive:!0}),await b.promises.writeFile(o,n.code,`utf-8`);let s=this.serverComponents.get(e)??this.serverActions.get(e),c=this.resolveServerCssSources(e,s?.originalCode??await b.promises.readFile(e,`utf-8`)),l=[...await this.writeComponentCssAsset(i,n.cssAssetSources.length>0?[...n.cssAssetSources]:c)];t.components[i]={id:i,filePath:e,relativePath:r,bundlePath:a,moduleSpecifier:Me(S.resolve(this.projectRoot,o)).href,dependencies:[...s?.dependencies??[]],hasNodeImports:s?.hasNodeImports??!1,css:l}}r&&(this.useCacheBuildId=qt(JSON.stringify(t.components),16),t.useCacheBuildId=this.useCacheBuildId);let o=S.join(this.options.outDir,this.options.manifestPath);await b.promises.writeFile(o,JSON.stringify(t),`utf-8`),await this.writeRouteCssEntries(t);let s={};this.options.csp&&(s.csp=this.options.csp),this.options.cacheControl&&(s.cacheControl=this.options.cacheControl),this.options.cache&&(s.cache=this.options.cache),this.options.action&&(s.action=this.options.action),this.options.jsPoolSize!=null&&(s.jsPoolSize=this.options.jsPoolSize);let c=this.options.origin?.trim().replace(/\/+$/,``);c!=null&&c!==``&&(s.origin=c),this.options.htmlLimitedBots!=null&&(s.htmlLimitedBots=this.options.htmlLimitedBots),(this.options.experimental?.useCacheRemote!=null||this.useCacheBuildId!=null&&this.useCacheBuildId!==``)&&(s.useCache={...this.options.experimental?.useCacheRemote?{remote:this.options.experimental.useCacheRemote}:{},...this.useCacheBuildId!=null&&this.useCacheBuildId!==``?{buildId:this.useCacheBuildId}:{}},!this.options.experimental?.useCache&&this.options.experimental?.useCacheRemote&&console.warn(`[server-build] experimental.useCacheRemote is set without experimental.useCache; the 'use cache' transform will still run because useCacheRemote is configured.`));let l=S.join(this.options.outDir,this.options.serverConfigPath);if(Object.keys(s).length===0)try{await b.promises.unlink(l)}catch(e){n(e)!==`ENOENT`&&console.warn(`Failed to remove server config file:`,e)}else await b.promises.writeFile(l,JSON.stringify(s),`utf-8`);return t}async buildRscEntriesWithVite(e){let t={entries:/* @__PURE__ */ new Map,extraFiles:[]};if(e.length===0)return t;if(this.viteBuilder==null)throw Error(`Vite builder is required for RSC environment emit`);let n=this.viteBuilder;return this.withEnvEmitLock(async()=>{let t=e.map(([e])=>({componentId:this.getComponentId(e),filePath:e})),r=await ve({viteBuilder:n,entries:t,minify:this.options.minify});if(r==null)throw Error(`Vite RSC environment build failed`);let i=/* @__PURE__ */ new Map;for(let[t]of e){let e=this.getComponentId(t),n=r.outputs.get(e);if(n==null)throw Error(`Vite RSC environment build missed entry: ${e}`);i.set(t,n)}return{entries:i,extraFiles:[...r.extraFiles]}})}async buildMdxRegistry(e){let t=qa({projectRoot:this.projectRoot,mdxOptions:e,alias:this.options.alias,cache:this.moduleAnalysisCache}),n=S.join(this.options.outDir,this.options.manifestPath),r;if(b.existsSync(n)){let e=await b.promises.readFile(n,`utf-8`),t=d(e);r=t&&us(t)?t:{components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()}}else r={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()};r.mdxRegistry=t.map(e=>({name:e.name,id:e.moduleId,client:e.client})),await b.promises.writeFile(n,JSON.stringify(r),`utf-8`)}async buildSSRClientComponents(){let e=S.join(this.options.outDir,`ssr`);await b.promises.mkdir(e,{recursive:!0});let t=[...this.getClientComponentFiles()];for(let e of this.discoveredExternalClientComponents)if(!t.some(t=>t.filePath===e))try{let n=b.readFileSync(e,`utf-8`);t.push({filePath:e,code:n})}catch{}try{let e=cs();if(e!=null&&e!==``){let n=b.readFileSync(e,`utf-8`);t.push({filePath:e,code:n})}}catch{}let n=[];for(let{componentId:e,devSourceSegments:t,publishedExport:r,exports:i}of is){let a=this.resolveExternalClientSourcePath(t,r);if(a!=null&&a!==``)try{let t=b.readFileSync(a,`utf-8`);n.push({componentId:e,filePath:a,code:t,exports:[...i],bundleName:`external_${qt(e)}`})}catch{}}let r={},i=await this.buildSsrEntriesWithVite(t,n);for(let t of i.extraFiles){let n=y(t.fileName),r=n===this.options.assetsDir||n.startsWith(`${this.options.assetsDir}/`)?S.join(this.options.outDir,n):S.join(e,n);await b.promises.mkdir(S.dirname(r),{recursive:!0}),await b.promises.writeFile(r,t.code)}for(let[e,a]of i.entries){let i=n.find(t=>t.filePath===e),o=i?.componentId??ds(e,this.projectRoot),s=`ssr/${i?.bundleName??fs(e,this.projectRoot)}.js`,c=S.join(this.options.outDir,s);await b.promises.mkdir(S.dirname(c),{recursive:!0}),await b.promises.writeFile(c,a.code,`utf-8`);let l=i?.code??t.find(t=>t.filePath===e)?.code??b.readFileSync(e,`utf-8`);r[o]={id:o,filePath:e,bundlePath:s,exports:i?.exports??this.extractExportNames(l)}}await this.writeClientReferenceManifest(e,r)}async buildSsrEntriesWithVite(e,t=[]){let n={entries:/* @__PURE__ */ new Map,extraFiles:[]},r=[...e.map(({filePath:e})=>({entryName:fs(e,this.projectRoot),filePath:e})),...t.map(e=>({entryName:e.bundleName,filePath:e.filePath}))];if(r.length===0)return n;if(this.viteBuilder==null)throw Error(`Vite builder is required for SSR environment emit`);let i=this.viteBuilder;return this.withEnvEmitLock(async()=>{let e=await be({viteBuilder:i,entries:r,minify:this.options.minify});if(e==null)throw Error(`Vite SSR environment build failed`);let t=/* @__PURE__ */ new Map;for(let n of r){let r=e.outputs.get(n.entryName);if(r==null)throw Error(`Vite SSR environment build missed entry: ${n.entryName}`);t.set(n.filePath,{code:r.code})}return{entries:t,extraFiles:[...e.extraFiles]}})}async writeClientReferenceManifest(e,t){let n=S.join(e,`manifest.json`);await b.promises.writeFile(n,JSON.stringify(t),`utf-8`);let r={};for(let[e,n]of Object.entries(t))for(let t of n.exports){let i=`${e}#${t}`;r[i]={id:i,chunks:`/${n.bundlePath}`,name:t}}let i=S.join(this.options.outDir,`server`);await b.promises.mkdir(i,{recursive:!0});let a=S.join(i,`client-reference-manifest.json`);await b.promises.writeFile(a,JSON.stringify(r),`utf-8`)}resolveExternalClientSourcePath(e,t){let n=S.join(os,...e);if(b.existsSync(n))return n;try{let e=w(import.meta.resolve(t));if(b.existsSync(e))return e}catch{}return null}extractExportNames(e){return bn(e)}getProjectRelativePath(e){return Jt(e,this.projectRoot)}getReadableComponentId(e){return Yt(e)}getComponentId(e){return Xt(e,this.projectRoot)}async rebuildComponent(e){rs.test(S.basename(e))&&(this.layoutCssSkipSet=null);let t=this.getComponentId(e),n=await b.promises.readFile(e,`utf-8`),r=this.extractDependencies(n,e),i={filePath:e,originalCode:n,dependencies:r,hasNodeImports:this.hasNodeImports(n,e)};this.isServerAction(n,e)?(this.serverActions.set(e,i),this.serverComponents.delete(e)):(this.serverComponents.set(e,i),this.serverActions.delete(e));let a=S.join(this.options.rscDir,`${t}.js`),o=S.join(this.options.outDir,a),s=this.buildCache.get(e),c=(await b.promises.stat(e)).mtimeMs;if(s&&s.timestamp>=c&&JSON.stringify(s.sourceDependencies)===JSON.stringify(r)){let n=this.serverActions.get(e)??this.serverComponents.get(e);return n&&s.bundledDependencies.length>0&&(n.dependencies=s.bundledDependencies),await b.promises.writeFile(o,s.code,`utf-8`),await this.updateManifestForComponent(t,e,a,s.css),{componentId:t,bundlePath:this.bundlePathForRuntime(o),success:!0}}let l=S.dirname(o);await b.promises.mkdir(l,{recursive:!0});let u=await this.emitRscEntries([{componentId:t,filePath:e}],{minify:this.options.minify}),d=u.outputs.get(t);if(d==null)throw Error(`Vite RSC environment build missed entry: ${t}`);await b.promises.writeFile(o,d.code,`utf-8`);let f=this.resolveServerCssSources(e,n),p=[...await this.writeComponentCssAsset(t,d.cssAssetSources.length>0?[...d.cssAssetSources]:f)];for(let e of u.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await b.promises.mkdir(S.dirname(t),{recursive:!0}),await b.promises.writeFile(t,e.code)}let m=this.serverActions.get(e)??this.serverComponents.get(e);return this.buildCache.set(e,{code:d.code,css:p,timestamp:Date.now(),sourceDependencies:r,bundledDependencies:m?.dependencies??r}),await this.updateManifestForComponent(t,e,a,p),{componentId:t,bundlePath:this.bundlePathForRuntime(o),success:!0}}bundlePathForRuntime(e){return y(S.relative(this.projectRoot,e))}manifestCache=null;async updateManifestForComponent(e,t,n,r=[]){let i=S.join(this.options.outDir,this.options.manifestPath),a;if(this.manifestCache)a=this.manifestCache;else if(b.existsSync(i)){let e=await b.promises.readFile(i,`utf-8`),t=d(e);t&&us(t)?(a=t,this.manifestCache=a):(a={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},this.manifestCache=a)}else a={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},this.manifestCache=a;let o=this.serverComponents.get(t)??this.serverActions.get(t),s=S.join(this.options.outDir,n),c=Me(S.resolve(this.projectRoot,s)).href;if(o)a.components[e]={id:e,filePath:t,relativePath:S.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:[...o.dependencies],hasNodeImports:o.hasNodeImports,css:r};else{let i=await b.promises.readFile(t,`utf-8`);a.components[e]={id:e,filePath:t,relativePath:S.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:this.extractDependencies(i,t),hasNodeImports:this.hasNodeImports(i,t),css:r}}a.buildTime=(/* @__PURE__ */ new Date()).toISOString(),await b.promises.writeFile(i,JSON.stringify(a),`utf-8`),await this.writeRouteCssEntries(a),this.manifestCache=a}clearCache(){this.buildCache.clear(),this.manifestCache=null}invalidateBuildCacheFor(e){this.buildCache.delete(e)}};function hs(e,t){let n=[];for(let r of Vn(t))try{let t=Jn(r),i=b.readFileSync(r,`utf-8`),a=e.getModuleAnalysis(r,i);n.push({filePath:r,cacheKey:t,code:i,analysis:a})}catch(e){console.warn(`[server-build] Error reading ${r}:`,s(e,String(e)))}return n}function gs(e,t){return(t??mn(e)).hasComponentExport||_.test(e)||ne.test(e)||ce.test(e)}function _s(e,t,n,r){let i=S.basename(e);if(ts.test(i)||ns.test(i)||i.endsWith(`.d.ts`))return!1;let a=r??n.getModuleAnalysis(e,t);return a.directives.hasUseClient?!1:a.directives.hasUseServer?!0:!n.isOnlyImportedByClientComponents(e)&&ps(e,a)&&gs(t,a)}function vs(e,t,n=[]){let r=hs(t,Hn(e,n));t.clearClientComponentFiles(),t.populateImportGraphFromFiles(r);let i=[],a=[];for(let{filePath:e,code:n,analysis:o}of r)o.directives.hasUseClient&&(a.push(e),t.recordClientComponent(e,n)),_s(e,n,t,o)&&(t.addServerComponent(e,n,o),i.push(e));return{serverComponentPaths:i,clientComponentPaths:a}}function ys(e={}){let t=null,n,r,i={},a=!1;async function o(){if(t){try{await t.buildMdxRegistry(e.mdx)}catch(e){console.warn(`[rari] Failed to build MDX component registry:`,e)}try{let{generateRobotsFile:e}=await import(`./robots-B1bFAd4J.mjs`);await e({appDir:S.join(n,`src`,`app`),outDir:r,aliases:i})}catch(e){console.warn(`[rari] Failed to generate robots.txt:`,e)}try{let{generateSitemapFiles:e}=await import(`./sitemap-DJY3OiJ0.mjs`);await e({appDir:S.join(n,`src`,`app`),outDir:r,aliases:i})}catch(e){console.warn(`[rari] Failed to generate sitemap:`,e)}try{let{generateFeedFile:e}=await import(`./feed-uUGeOZmR.mjs`);await e({appDir:S.join(n,`src`,`app`),outDir:r,aliases:i})}catch(e){console.warn(`[rari] Failed to generate feed:`,e)}try{let e=S.join(r,`server`,`routes.json`);if(b.existsSync(e)){let t=ft(b.readFileSync(e,`utf-8`));t.length>0&&await ut({appDir:S.join(n,`src`,`app`),outDir:r,icons:t})}}catch(e){console.warn(`[rari] Failed to copy app icons:`,e)}try{let t=Ya(n,e.mdx),i=Xa(n,t.contentDirs).filter(e=>{let t=y(S.relative(n,e));return!(t===`public/content`||t.startsWith(`public/content/`)||t===`dist/content`||t.startsWith(`dist/content/`))});i.length>0&&Qa(i,S.join(r,`content`))}catch(e){console.warn(`[rari] Failed to copy MDX content:`,e)}Ra(r)}}return{name:`rari-server-build`,sharedDuringBuild:!0,configResolved(o){n=o.root,r=S.resolve(o.root,o.build.outDir),a=!1;let s=Gt(o);i=s;let c=typeof o.build.assetsDir==`string`&&o.build.assetsDir!==``?fe(o.build.assetsDir):`assets`;t=new ms(n,{...e,alias:s,assetsDir:c,outDir:r,minify:e.minify??o.mode===`production`})},buildStart(){if(!t)return;let e=C.env.NODE_ENV===`production`,r=[S.join(n,`dist`,`cache`,`og`),S.join(n,`dist`,`cache`,`images`)];e&&r.push(`/tmp/rari-og-cache`,`/tmp/rari-image-cache`);for(let e of r)try{b.existsSync(e)&&b.rmSync(e,{recursive:!0,force:!0})}catch(t){console.warn(`[rari] Failed to clear cache ${e}:`,t)}let a=S.join(n,`src`);b.existsSync(a)&&vs(a,t,Object.values(i))},async buildApp(e){if(!t||a)return;let n=e.environments.client;n.isBuilt||await e.build(n);let r=e.environments.rsc,i=e.environments.ssr;await r.init(),await i.init(),t.setViteBuilder(e),await t.buildServerComponents(),await t.buildSSRClientComponents(),a=!0,await o()}}}function bs(e,t,n){if(n.length===0)return e;let r=yn(e).find(e=>e.source===t&&!e.typeOnly&&!e.sideEffectOnly),i=/* @__PURE__ */ new Map;if(r!=null)for(let e of r.named)e.typeOnly||i.set(e.imported,e.local);for(let e of n)i.has(e)||i.set(e,e);let a=[...i.entries()].map(([e,t])=>e===t?e:`${e} as ${t}`);if(r?.namespaceBinding!=null||r?.named.some(e=>e.typeOnly)){let i=n.filter(e=>!r.named.some(t=>!t.typeOnly&&t.imported===e));return i.length===0?e:`${`import { ${[...new Set(i)].join(`, `)} } from ${JSON.stringify(t)};`}\n${e}`}let o=`import ${r?.defaultBinding==null?``:`${r.defaultBinding}, `}{ ${a.join(`, `)} } from ${JSON.stringify(t)};`;return r==null?`${o}\n\n${e}`:e.slice(0,r.start)+o+e.slice(r.end)}function xs(e,t){return`const ${e} = createClientModuleProxy(${JSON.stringify(t)});`}function Ss(e,t,n){return`const ${e} = registerClientReference(
74
+ `}function Os(e,t){return{componentsDir:t?.componentsDir??`src/components`,contentDirs:t?.contentDirs??[`src/content`,`content`,`public/content`]}}function ks(e,t){return t.map(t=>k.join(e,t)).filter(e=>D.existsSync(e))}function As(e){let t=[],n=r=>{if(D.existsSync(r))for(let i of D.readdirSync(r,{withFileTypes:!0})){let a=k.join(r,i.name);i.isDirectory()?n(a):i.isFile()&&t.push(T(k.relative(e,a)))}};return n(e),t}function js(e,t){for(let n of e)for(let e of As(n)){let r=k.join(n,e),i=k.join(t,e);if(D.existsSync(i)){console.warn(`[rari] Skipping MDX content conflict: ${e} already copied from an earlier content dir`);continue}D.mkdirSync(k.dirname(i),{recursive:!0}),D.copyFileSync(r,i)}}function Ms(e,t,n){let r=k.join(e,t),i=new Set(n);return D.existsSync(r)&&i.add(r),[...i]}const Ns=/\.cookies\b|\.headers\b|\.searchParams\b|\.geo\b|\.ip\b|\bwaitUntil\b|\bfetch\s*\(|RariResponse\.json\b|\.startsWith\s*\(|\.includes\s*\(|\.endsWith\s*\(|\bawait\b|`[^`]*\$\{/,Ps=/RariResponse\.(?:redirect|rewrite)\s*\(/,Fs=/if\s*\(([^)]+)\)(?:\s*\{)?\s+return\s+RariResponse\.(redirect|rewrite)\(\s*new\s+URL\(\s*(['"`])([^'"`]+)\3\s*,[^)]+\)(?:\s*,\s*(\d+))?\s*\)/g,Is=/^(?:(request\.rariUrl\.pathname|pathname|normalizedPath)\s*(?:===|==)\s*(['"`])([^'"`]+)\2|(['"`])([^'"`]+)\4\s*(?:===|==)\s*(request\.rariUrl\.pathname|pathname|normalizedPath))$/,Ls=/export\s+const\s+config\s*=/,Rs=/export\s+const\s+config\s*=\s*\{/,zs=/matcher\s*:\s*\{/,Bs=/matcher\s*:\s*(['"`])([^'"`]+)\1/,Vs=/matcher\s*:\s*\[([^\]]*)\]/,Hs=/(['"`])matcher\1\s*:\s*\{/,Us=/(['"`])matcher\1\s*:\s*(['"`])([^'"`]+)\2/,Ws=/(['"`])matcher\1\s*:\s*\[([^\]]*)\]/,Gs=/(['"`])matcher\1\s*:/,Ks=/(['"`])([^'"`]+)\1/g,qs=/(?:^|[{,]\s*)matcher\s*[,}]/;function Js(e){return e===301||e===308}const Ys=/* @__PURE__ */ new Set([`return`,`throw`,`case`,`else`,`do`,`typeof`,`delete`,`void`,`await`,`yield`,`new`,`in`,`of`,`instanceof`]);function Xs(e){return e===`
75
+ `||e===`\r`||e===`\u2028`||e===`\u2029`}function Zs(e,t){for(t-=2;t>=1;){if(e.charAt(t-1)===`/`&&e.charAt(t)===`*`)return t-2;--t}return t}function Qs(e,t,n){for(let r=t;r<n;r++){if(e.charAt(r)===`/`&&e.charAt(r+1)===`/`)return r;if(e.charAt(r)===`/`&&e.charAt(r+1)===`*`){for(r+=2;r<n&&(e.charAt(r)!==`*`||e.charAt(r+1)!==`/`);)r+=1;r+=1}}return-1}function $s(e,t){let n=t-1;for(;n>=0;){for(;n>=0&&/\s/.test(e.charAt(n));)--n;if(n<0)return n;if(e.charAt(n)===`/`&&n>0&&e.charAt(n-1)===`*`){n=Zs(e,n);continue}let t=n;for(;t>0&&!Xs(e.charAt(t-1));)--t;let r=Qs(e,t,n);if(r!==-1){n=r-1;continue}break}return n}function ec(e,t){let n=$s(e,t);if(n<0)return!0;let r=e.charAt(n);if(/[)}\]]/.test(r))return!1;if(!/[\w$]/.test(r))return!0;let i=n;for(;i>=0&&/[\w$]/.test(e.charAt(i));)--i;return Ys.has(e.slice(i+1,n+1))}function tc(e){return e===`
76
+ `||e===`\r`||e===`\u2028`||e===`\u2029`}function nc(e){switch(e){case`n`:return`
77
+ `;case`r`:return`\r`;case`t`:return` `;case`b`:return`\b`;case`f`:return`\f`;case`v`:return`\v`;case`0`:return`\0`;case`\\`:case`'`:case`"`:case"`":case`/`:return e;default:return null}}function rc(e,t,n){if(n===`x`){let n=e.slice(t+1,t+3);return/^[\da-f]{2}$/i.test(n)?{char:String.fromCharCode(Number.parseInt(n,16)),end:t+2}:null}if(n!==`u`)return null;if(e.charAt(t+1)===`{`){let n=e.indexOf(`}`,t+2);if(n===-1)return null;let r=e.slice(t+2,n);return/^[\da-f]+$/i.test(r)?{char:String.fromCodePoint(Number.parseInt(r,16)),end:n}:null}let r=e.slice(t+1,t+5);return/^[\da-f]{4}$/i.test(r)?{char:String.fromCharCode(Number.parseInt(r,16)),end:t+4}:null}function ic(e,t,n,r){if(tc(n)){let i=t;return n===`\r`&&e.charAt(t+1)===`
78
+ `&&(i=t+1),{out:r,i}}let i=nc(n);if(i!=null)return{out:r+i,i:t};let a=rc(e,t,n);return a==null?n===`x`||n===`u`?null:{out:r+n,i:t}:{out:r+a.char,i:a.end}}function ac(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e.charAt(r);if(t==="`"&&i===`$`&&e.charAt(r+1)===`{`)return null;if(i!==`\\`){n+=i;continue}if(r+=1,r>=e.length)return null;let a=ic(e,r,e.charAt(r),n);if(a==null)return null;n=a.out,r=a.i}return n}function oc(e,t,n){for(let r=t+1;r<e.length;r++){let t=e[r];if(t===`\\`){r+=1;continue}if(n==="`"&&t===`$`&&e[r+1]===`{`)return null;if(t===n)return r+1}return null}function sc(e,t,n,r){return n===`\\`?r+2:((t===`single`&&n===`'`||t===`double`&&n===`"`)&&e.pop(),r+1)}function cc(e,t,n,r){return t===`\\`?r+2:t==="`"?(e.pop(),r+1):t===`$`&&n===`{`?(e.push({kind:`code`,braceDepth:1}),r+2):r+1}function lc(e,t,n,r,i){if(n===`\\`)return r+2;if(n===`[`)return e.push({kind:`regex-class`}),r+1;if(n===`/`){e.pop();let n=r+1;for(;n<i&&/[a-z]/i.test(t.charAt(n));)n+=1;return n}return r+1}function uc(e,t,n){return t===`\\`?n+2:(t===`]`&&e.pop(),n+1)}function dc(e,t,n,r=t.length){let i=e.at(-1);if(i===void 0||i.kind===`code`)return null;let a=t.charAt(n),o=t.charAt(n+1);return i.kind===`line-comment`?(a===`
79
+ `&&e.pop(),n+1):i.kind===`block-comment`?a===`*`&&o===`/`?(e.pop(),n+2):n+1:i.kind===`single`||i.kind===`double`?sc(e,i.kind,a,n):i.kind===`template`?cc(e,a,o,n):i.kind===`regex`?lc(e,t,a,n,r):uc(e,a,n)}function fc(e,t,n){let r=t.charAt(n),i=t.charAt(n+1);return r===`/`&&i===`/`?(e.push({kind:`line-comment`}),n+2):r===`/`&&i===`*`?(e.push({kind:`block-comment`}),n+2):r===`/`&&ec(t,n)?(e.push({kind:`regex`}),n+1):r===`'`?(e.push({kind:`single`}),n+1):r===`"`?(e.push({kind:`double`}),n+1):r==="`"?(e.push({kind:`template`}),n+1):null}function pc(e,t,n){return n===`{`?(e.braceDepth+=1,!0):n===`}`&&(--e.braceDepth,e.braceDepth===0&&t.length>1&&t.pop(),!0)}function mc(e,t,n,r,i){--e.braceDepth;let a=i+1;return e.braceDepth===0?t.length===1?{i:a,done:n.slice(r,a)}:(t.pop(),{i:a,done:null}):{i:a,done:null}}function hc(e,t,n,r){let i=e.at(-1);if(i===void 0)return null;let a=dc(e,t,n);if(a!=null)return{i:a,done:null};if(i.kind!==`code`)return null;let o=fc(e,t,n);if(o!=null)return{i:o,done:null};let s=t.charAt(n);return s===`{`?(i.braceDepth+=1,{i:n+1,done:null}):s===`}`?mc(i,e,t,r,n):{i:n+1,done:null}}function gc(e,t){let n=[{kind:`code`,braceDepth:0}];for(let r=t;r<e.length;){let i=hc(n,e,r,t);if(i==null)return null;if(i.done!=null)return i.done;r=i.i}return null}function _c(e,t,n){if(n==="`"&&oc(e,t,"`")==null)return{forceRuntime:!0,endIndex:e.length};let r=oc(e,t,n);if(r==null)return{forceRuntime:!0,endIndex:e.length};let i=e.slice(t+1,r-1);if(n==="`"&&i.includes("${"))return{forceRuntime:!0,endIndex:r};let a=ac(i,n);return a==null||a===``?{forceRuntime:!0,endIndex:r}:{matcher:a,forceRuntime:!1,endIndex:r}}function vc(e,t,n,r){let i=n[r],a=n[r+1];return i===`\\`?{j:r+2}:t.kind===`template`&&i===`$`&&a===`{`?{j:r,forceRuntime:!0}:((t.kind===`single`&&i===`'`||t.kind===`double`&&i===`"`||t.kind===`template`&&i==="`")&&e.pop(),{j:r+1})}function yc(e,t,n){let r=e.at(-1);return r===void 0?{j:n,forceRuntime:!0}:r.kind===`line-comment`?(t[n]===`
80
+ `&&e.pop(),{j:n+1}):r.kind===`block-comment`?t[n]===`*`&&t[n+1]===`/`?(e.pop(),{j:n+2}):{j:n+1}:r.kind===`single`||r.kind===`double`||r.kind===`template`?vc(e,r,t,n):null}function bc(e,t,n){let r=t[n],i=t[n+1];return r===`/`&&i===`/`?(e.push({kind:`line-comment`}),n+2):r===`/`&&i===`*`?(e.push({kind:`block-comment`}),n+2):r===`'`?(e.push({kind:`single`}),n+1):r===`"`?(e.push({kind:`double`}),n+1):r==="`"?(e.push({kind:`template`}),n+1):null}function xc(e,t,n){let r=e[t];return r===`[`?{j:t+1,depth:n+1}:r===`]`?{j:t+1,depth:n-1}:r===`{`?{j:t,depth:n,forceRuntime:!0}:{j:t+1,depth:n}}function Sc(e,t){let n=t+1,r=1,i=n,a=[{kind:`code`,braceDepth:0}];for(;i<e.length&&r>0;){let t=yc(a,e,i);if(t!=null){if(t.forceRuntime)return{forceRuntime:!0,endIndex:e.length};i=t.j;continue}let n=bc(a,e,i);if(n!=null){i=n;continue}let o=xc(e,i,r);if(o.forceRuntime)return{forceRuntime:!0,endIndex:o.j};i=o.j,r=o.depth}return r===0?{...Ac(e.slice(n,i-1)),endIndex:i}:{forceRuntime:!0,endIndex:e.length}}function Cc(e,t){let n=t+1;for(;n<e.length&&/\s/.test(e[n]);)n+=1;if(n>=e.length)return null;let r=e[n];return r===`'`||r===`"`||r==="`"?_c(e,n,r):r===`[`?Sc(e,n):{forceRuntime:!0,endIndex:n+1}}function wc(e,t,n,r){let i=t===0?``:e.charAt(t-1),a=t===0||/[\s;{}]/.test(i);if(n.braceDepth!==0||r.length!==1||!a)return null;if(e.startsWith(`let matcher`,t)||e.startsWith(`var matcher`,t))return{nextI:t,forceRuntime:!0};if(!e.startsWith(`const matcher`,t))return null;let o=t+13;if(o<e.length&&/[\w$]/.test(e.charAt(o)))return{nextI:t+1};let s=o;for(;s<e.length&&/\s/.test(e.charAt(s));)s+=1;if(e.charAt(s)!==`=`)return{nextI:t+1};let c=Cc(e,s);return c==null||c.forceRuntime?{nextI:t,forceRuntime:!0}:{nextI:c.endIndex,binding:{matcher:c.matcher,forceRuntime:!1}}}function Tc(e,t,n,r){let i=e.at(-1);if(i===void 0)return{nextI:n,forceRuntime:!0};let a=dc(e,t,n);if(a!=null)return{nextI:a};if(i.kind!==`code`)return{nextI:n,forceRuntime:!0};let o=fc(e,t,n);if(o!=null)return{nextI:o};if(pc(i,e,t.charAt(n)))return{nextI:n+1};let s=wc(t,n,i,e);return s==null?{nextI:n+1}:s.forceRuntime?{nextI:n,forceRuntime:!0}:(s.binding&&r.push(s.binding),{nextI:s.nextI})}function Ec(e){let t=[{kind:`code`,braceDepth:0}],n=[];for(let r=0;r<e.length;){let i=Tc(t,e,r,n);if(i==null||i.forceRuntime)return{forceRuntime:!0};r=i.nextI}return n.length===0?null:n.length>1?{forceRuntime:!0}:n[0]??null}function Dc(e){let t=e.trim();if(t===``||t.includes(`&&`))return null;let n=t.split(/\|\|/),r=[],i;for(let e of n){let t=Is.exec(e.trim());if(t==null)return null;let n=t[1]||t[6]||``,a=t[3]||t[5]||``;if(n===``||a===``)return null;if(i==null)i=n;else if(i!==n)return null;r.push(a)}return r.length>0?r:null}function Oc(e){let t=[];Fs.lastIndex=0;for(let n of e.matchAll(Fs)){let e=n[1],r=n[2],i=n[4],a=Number.parseInt(n[5],10),o=Number.isFinite(a)?a:void 0;if(e===``||i===``||r!==`redirect`&&r!==`rewrite`)continue;let s=Dc(e);if(s==null)return[];for(let e of s)t.push({source:e,type:r,destination:i,...r===`redirect`?{permanent:Js(o)}:{}})}return t}function kc(e){let t=Rs.exec(e);return t==null?null:gc(e,t.index+t[0].length-1)}function Ac(e){if(e.includes(`{`))return{forceRuntime:!0};let t=[];Ks.lastIndex=0;for(let n of e.matchAll(Ks)){let e=n[1],r=n[2];if(r===``||e!==`'`&&e!==`"`&&e!=="`")continue;let i=ac(r,e);if(i==null)return{forceRuntime:!0};i!==``&&t.push(i)}return e.replace(Ks,``).replace(/[\s,]/g,``)===``&&t.length>0?{matcher:t,forceRuntime:!1}:{forceRuntime:!0}}function jc(e,t){let n=[{kind:`code`,braceDepth:0}];for(let r=0;r<t;){let i=n.at(-1);if(i===void 0)return null;let a=dc(n,e,r,t);if(a!=null){r=a;continue}if(i.kind!==`code`)return null;let o=fc(n,e,r);if(o!=null){r=o;continue}if(pc(i,n,e.charAt(r))){r+=1;continue}r+=1}let r=n.at(-1);return r?.kind===`code`?r.braceDepth:null}function Mc(e,t){return jc(e,t)===1}function Nc(e){return e.startsWith(`'`)||e.startsWith(`"`)||e.startsWith("`")}function J(e,t){let n=new RegExp(t.source,t.flags.includes(`g`)?t.flags:`${t.flags}g`);for(let t of e.matchAll(n)){let n=Nc(t[0])?t.index:t.index+t[0].indexOf(`matcher`);if(n>=t.index&&Mc(e,n))return t}return null}function Pc(e,t){let n=t;for(;n<e.length;){let t=Ic(e,n);if(t!=null){n=t;continue}let r=e.charAt(n);return r===`,`||r===`}`}return!0}function Fc(e,t){let n=t;for(;n<e.length;){let t=Ic(e,n);if(t==null)break;n=t}return n}function Ic(e,t){let n=e.charAt(t),r=e.charAt(t+1);if(/\s/.test(n))return t+1;if(n===`/`&&r===`/`){let n=t+2;for(;n<e.length&&!Xs(e.charAt(n));)n+=1;return n}if(n===`/`&&r===`*`){let n=t+2;for(;n+1<e.length&&(e.charAt(n)!==`*`||e.charAt(n+1)!==`/`);)n+=1;return n+2}return null}function Lc(e,t){if(e.charAt(t)!==`[`)return null;let n=Fc(e,t+1);if(n>=e.length)return{endIndex:e.length,forceRuntime:!0};let r=e.charAt(n);if(r===`'`||r===`"`||r==="`"){let t=oc(e,n,r);if(t==null)return{endIndex:e.length,forceRuntime:!0};let i=e.slice(n+1,t-1);if(r==="`"&&i.includes("${"))return{endIndex:t,forceRuntime:!0};let a=ac(i,r);return n=Fc(e,t),e.charAt(n)===`]`?{endIndex:n+1,forceRuntime:a===`matcher`}:{endIndex:n,forceRuntime:!0}}return{endIndex:t+1,forceRuntime:!0}}function Rc(e,t,n,r){return n===`'`||n===`"`||n==="`"?{entered:!0,expectPropertyKey:r&&t.braceDepth===1?!1:r}:{entered:!1,expectPropertyKey:r}}function zc(e,t,n,r){return n===`{`?(e.braceDepth+=1,{handled:!0,expectPropertyKey:e.braceDepth===1||r}):n===`}`?(--e.braceDepth,e.braceDepth===0&&t.length>1&&t.pop(),{handled:!0,expectPropertyKey:!1}):n===`,`&&e.braceDepth===1?{handled:!0,expectPropertyKey:!0}:n===`:`&&e.braceDepth===1?{handled:!0,expectPropertyKey:!1}:{handled:!1,expectPropertyKey:r}}function Bc(e,t,n,r,i,a){if(!r||n.braceDepth!==1||/\s/.test(i))return null;if(i===`.`&&a===`.`&&e.charAt(t+2)===`.`)return{unsafe:!0};if(i===`[`){let n=Lc(e,t);return n?.forceRuntime===!0||n==null?{unsafe:!0}:{unsafe:!1,nextI:n.endIndex,clearExpect:!0}}return{unsafe:!1,clearExpect:!0}}function Vc(e,t,n,r){let i=e.at(-1);if(i===void 0)return null;let a=dc(e,t,n);if(a!=null)return{nextI:a,expectPropertyKey:r};if(i.kind!==`code`)return null;let o=t.charAt(n),s=t.charAt(n+1),c=Rc(e,i,o,r);if(c.entered)return{nextI:fc(e,t,n)??n+1,expectPropertyKey:c.expectPropertyKey};let l=fc(e,t,n);if(l!=null)return{nextI:l,expectPropertyKey:r};let u=zc(i,e,o,r);if(u.handled)return{nextI:n+1,expectPropertyKey:u.expectPropertyKey};let d=Bc(t,n,i,r,o,s);return d==null?{nextI:n+1,expectPropertyKey:r}:d.unsafe?{nextI:n,expectPropertyKey:r,unsafe:!0}:{nextI:d.nextI??n+1,expectPropertyKey:!d.clearExpect&&r}}function Hc(e){let t=[{kind:`code`,braceDepth:0}],n=!1;for(let r=0;r<e.length;){let i=Vc(t,e,r,n);if(i==null)return!1;if(i.unsafe)return!0;n=i.expectPropertyKey,r=i.nextI}return!1}function Uc(e,t){let n=Nc(t[0]),r=n?t[2]:t[1],i=n?t[3]:t[2];if(r!==`'`&&r!==`"`&&r!=="`")return null;if(r==="`"&&i.includes("${")||!Pc(e,t.index+t[0].length))return{forceRuntime:!0};let a=ac(i,r);return a==null||a===``?{forceRuntime:!0}:{matcher:a,forceRuntime:!1}}function Wc(e){if(!Ls.test(e)||!Rs.test(e))return{forceRuntime:!1};let t=kc(e);if(t==null||Hc(t)||J(t,zs)!=null||J(t,Hs)!=null)return{forceRuntime:!0};let n=J(t,Bs)??J(t,Us);if(n!=null)return Uc(t,n)??{forceRuntime:!1};let r=J(t,Vs)??J(t,Ws);return r==null?J(t,qs)==null?J(t,/matcher\s*:/)!=null||J(t,Gs)!=null?{forceRuntime:!0}:{forceRuntime:!1}:Ec(e)??{forceRuntime:!0}:Pc(t,r.index+r[0].length)?Ac(Nc(r[0])?r[2]:r[1]):{forceRuntime:!0}}function Gc(e){let{matcher:t,forceRuntime:n}=Wc(e);if(n||Ns.test(e))return{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}};let r=Ps.test(e),i=Oc(e);return r&&i.length===0?{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}}:{requiresRuntime:!1,rules:i,...t==null?{}:{matcher:t}}}function Kc(e){let t=Gc(e.code),n=t.requiresRuntime;return{proxyFile:e.proxyFile,enabled:!0,generated:e.generated??(/* @__PURE__ */ new Date()).toISOString(),rules:t.rules,requiresRuntime:n,...n&&e.bundlePath!=null&&e.bundlePath!==``?{bundlePath:e.bundlePath}:{},...t.matcher==null?{}:{matcher:t.matcher}}}const qc=/@import\s+(?:url\(\s*)?['"](?![a-zA-Z][a-zA-Z0-9+.-]*:|\/\/|\.\/|\.\.\/|\/)[^'"]+['"][^;]*(?:;|$)/g,Jc=/@import\s+(?:url\(\s*((?:\.\/|\.\.\/)[^)\s]+)\s*\)|url\(\s*['"]((?:\.\/|\.\.\/)[^'"]+)['"]\s*\)|['"]((?:\.\/|\.\.\/)[^'"]+)['"])([^;]*)(?:;|$)/g,Yc=/\.css(?:\?.*)?$/,Xc=/\.module\.css(?:\?.*)?$/i;function Zc(e){return Xc.test(e.replace(/[?#].*$/,``))}function Qc(e){return e.replace(qc,``).trim()}function $c(e){if(!/^supports\s*\(/i.test(e))return{supportsCondition:null,rest:e};let t=e.indexOf(`(`),n=0,r=-1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`(`)n++;else if(t===`)`&&(n--,n===0)){r=i;break}}return r===-1?{supportsCondition:null,rest:e}:{supportsCondition:e.slice(t+1,r).trim(),rest:e.slice(r+1).trim()}}function el(e){if(/^layer\s*\(/i.exec(e)){let t=e.indexOf(`(`),n=e.indexOf(`)`,t);return n===-1?{layerName:null,rest:e}:{layerName:e.slice(t+1,n).trim(),rest:e.slice(n+1).trim()}}return/^layer(?:\s|$)/i.test(e)?{layerName:``,rest:e.replace(/^layer\s*/i,``)}:{layerName:null,rest:e}}function tl(e){let t=e.trim().replace(/^\)\s*/,``),n=el(t);t=n.rest;let r=$c(t);t=r.rest;let i=t.trim()===``?null:t.trim();return{layerName:n.layerName,supportsCondition:r.supportsCondition,mediaQuery:i}}function nl(e,t){let n=e.trim();return n===``?``:(t.layerName!==null&&(n=t.layerName===``?`@layer {\n${n}\n}`:`@layer ${t.layerName} {\n${n}\n}`),t.supportsCondition!=null&&t.supportsCondition!==``&&(n=`@supports (${t.supportsCondition}) {\n${n}\n}`),t.mediaQuery!=null&&t.mediaQuery!==``&&(n=`@media ${t.mediaQuery} {\n${n}\n}`),n)}function rl(e,t,n=/* @__PURE__ */ new Set){let r=k.resolve(e);return n.has(r)?``:(n.add(r),t.replace(Jc,(e,t,i,a,o)=>{let s=t??i??a;if(s==null||s===``)return e;let c=k.resolve(k.dirname(r),s);try{return!D.existsSync(c)||!D.statSync(c).isFile()?e:nl(il(c,D.readFileSync(c,`utf-8`),new Set(n)),tl(o))}catch{return e}}).trim())}function il(e,t,n=/* @__PURE__ */ new Set){return rl(e,Qc(t),n)}function al(e,t){let n=/* @__PURE__ */ new Set;for(let r of zr(e,t)){if(k.isAbsolute(r)){n.add(k.resolve(r));continue}try{n.add(Ce(k.join(e,`package.json`)).resolve(r))}catch{}}return n}function ol(e){return D.existsSync(e)&&D.statSync(e).isFile()?e:null}function sl(e,t,n){let r=[t,k.join(n,`package.json`)];for(let t of r)try{let n=ol(Ce(t).resolve(e));if(n!=null)return n}catch{try{let n=ol(j(import.meta.resolve(e,Oe(t).href)));if(n!=null)return n}catch{}}return null}function cl(e,t,n,r){let i=e.replace(/[?#].*$/,``);if(!Yc.test(i))return null;if(k.isAbsolute(i))return ol(i);if(i.startsWith(`./`)||i.startsWith(`../`))return ol(k.resolve(k.dirname(t),i));let a=E(i,r,n);if(a!=null&&a!==``){let e=ol(a);if(e!=null)return e}return sl(i,t,n)}function ll(e){let t=e.includes(`?`)?e.slice(e.indexOf(`?`)):``;return/(?:\?|&)raw(?:&|$)/.test(t)||/(?:\?|&)url(?:&|$)/.test(t)}function ul(e,t){if(Zc(e)||t.has(k.resolve(e)))return null;try{let t=il(e,D.readFileSync(e,`utf-8`));return t===``?null:t}catch{return null}}function dl(e){let t=[];for(let n of Nn(e.code)){if(!Yc.test(n.source)||Zc(n.source)||ll(n.source))continue;let r=cl(n.source,e.filePath,e.projectRoot,e.aliases);if(r==null)continue;let i=ul(r,e.layoutCssSkip);i!=null&&t.push(i)}return t}const fl=/^proxy\.(?:tsx?|jsx?|mts|mjs)$/,pl=/^(?:robots|sitemap|feed)\.(?:tsx?|jsx?)$/,ml=/^(?:favicon|icon\d*|apple-icon\d*)\.(?:ico|png|jpe?g|svg)$/i,hl=/^layout\.(?:tsx|ts|jsx|js)$/,gl=[{componentId:`rari/image`,devSourceSegments:[`src`,`image`,`image.tsx`],publishedExport:`rari/image`,exports:[`Image`]}],_l=k.dirname(j(import.meta.url)),vl=k.dirname(_l);function yl(e){return e.startsWith(vl)}function bl(){let e=k.join(vl,`src`,`runtime`,`boundaries`,`error-boundary-wrapper.tsx`);if(D.existsSync(e))return e;try{let e=j(import.meta.resolve(`rari/runtime/ErrorBoundaryWrapper`));if(D.existsSync(e))return e}catch{}return null}function xl(e){let t=T(e);return t.includes(`ErrorBoundaryWrapper`)||t.includes(`/boundaries/error-boundary-wrapper`)||t.endsWith(`/error-boundary-wrapper.tsx`)}function Sl(e){return u(e)&&u(e.components)}function Cl(e,t){if(xl(e))return`virtual:error-boundary-wrapper.tsx`;let n=T(k.relative(t,e));return n.startsWith(`..`)||k.isAbsolute(n)?T(e):n}function wl(e,t){if(xl(e))return`error_boundary_wrapper_${F(`virtual:error-boundary-wrapper.tsx`)}`;if(yl(e)){let t=T(k.relative(vl,e));return`${Wt(t)}_${F(t)}`}return Gt(e,t)}function Tl(e,t){return!e.includes(`node_modules`)&&!t.directives.hasUseClient&&!t.directives.hasUseServer}var El=class{serverComponents=/* @__PURE__ */ new Map;serverActions=/* @__PURE__ */ new Map;options;projectRoot;buildCache=/* @__PURE__ */ new Map;useCacheBuildId=null;fileImporters=/* @__PURE__ */ new Map;moduleAnalysisCache;discoveredExternalClientComponents=/* @__PURE__ */ new Set;clientComponentFiles=/* @__PURE__ */ new Map;layoutCssSkipSet=null;viteBuilder=null;envEmitLock=Promise.resolve();getLayoutCssSkipSet(){return this.layoutCssSkipSet??=al(this.projectRoot,this.options.alias),this.layoutCssSkipSet}resolveServerCssSources(e,t){return dl({filePath:e,code:t,projectRoot:this.projectRoot,aliases:this.options.alias,layoutCssSkip:this.getLayoutCssSkipSet()})}resolveExtraFileOutPath(e){let t=T(e);return t===this.options.assetsDir||t.startsWith(`${this.options.assetsDir}/`)?k.join(this.options.clientOutDir,t):k.join(this.options.outDir,this.options.rscDir,t)}setViteBuilder(e){this.viteBuilder=e}getProjectRoot(){return this.projectRoot}async getEmitBuilder(){return this.viteBuilder??=await ce({root:this.projectRoot,logLevel:`error`}),this.viteBuilder}async withEnvEmitLock(e){let t=this.envEmitLock,n;this.envEmitLock=new Promise(e=>{n=e}),await t;try{return await e()}finally{n()}}async emitRscEntries(e,t){return this.withEnvEmitLock(async()=>{let n=await this.getEmitBuilder(),r=await fe({viteBuilder:n,entries:e,minify:t?.minify??this.options.minify,codeSplitting:t?.codeSplitting});if(r==null)throw Error(`Vite RSC environment build failed`);return r})}recordClientComponent(e,t){this.clientComponentFiles.set(e,t)}getClientComponentFiles(){return[...this.clientComponentFiles.entries()].map(([e,t])=>({filePath:e,code:t}))}getClientComponentPaths(){return[...this.clientComponentFiles.keys()]}getModuleAnalysisCache(){return this.moduleAnalysisCache}clearClientComponentFiles(){this.clientComponentFiles.clear()}getComponentCount(){return this.serverComponents.size+this.serverActions.size}hasComponent(e){return this.serverComponents.has(e)||this.serverActions.has(e)}removeComponent(e){this.serverComponents.delete(e),this.serverActions.delete(e),this.moduleAnalysisCache.invalidate(e)}getImportGraph(){let e=/* @__PURE__ */ new Map;for(let[t,n]of this.fileImporters)e.set(t,new Set(n));return e}async writeComponentCssAsset(e,t){if(t.length===0)return[];let n=k.join(this.options.clientOutDir,`assets`,`server`);await D.promises.mkdir(n,{recursive:!0});let r=`${t.join(`
81
+ `)}\n`,i=`${F(e+r,12)}.css`,a=k.join(n,i);return await D.promises.writeFile(a,r,`utf-8`),[`/assets/server/${i}`]}getComponentIdFromRouteManifestPath(e){return this.getComponentId(k.join(this.projectRoot,`src`,`app`,e))}getComponentReferenceId(e){return this.getReadableComponentId(this.getProjectRelativePath(e))}async writeRouteCssEntries(e){let t=k.join(this.options.outDir,this.options.rscDir,`routes.json`);if(!D.existsSync(t))return;let n=await D.promises.readFile(t,`utf-8`),r=JSON.parse(n);if(!u(r))return;let i=r,a=t=>{if(Array.isArray(t))for(let n of t){if(!u(n))continue;let t=n.filePath;if(typeof t!=`string`||t===``)continue;let r=this.getComponentIdFromRouteManifestPath(t);n.componentId=r;let i=e.components[r]?.css??[];i.length?n.css=i:delete n.css}};a(i.routes),a(i.layouts),a(i.loading),a(i.errors),a(i.notFound),a(i.templates);let o=i.apiRoutes;if(Array.isArray(o))for(let e of o){if(!u(e))continue;let t=e.filePath;typeof t==`string`&&t!==``&&(e.componentId=this.getComponentIdFromRouteManifestPath(t))}await D.promises.writeFile(t,JSON.stringify(i),`utf-8`)}constructor(e,t={}){this.projectRoot=k.resolve(e),this.moduleAnalysisCache=t.moduleAnalysisCache??new Dr;let n=t.rscDir!=null&&t.rscDir!==``?t.rscDir:`server`,r=t.outDir!=null&&t.outDir!==``?t.outDir:be,i=xe(this.projectRoot,r),a=t.clientOutDir!=null&&t.clientOutDir!==``?xe(this.projectRoot,t.clientOutDir):k.join(i,`client`);this.options={outDir:i,clientOutDir:a,rscDir:n,manifestPath:t.manifestPath!=null&&t.manifestPath!==``?t.manifestPath:k.join(n,`manifest.json`),serverConfigPath:t.serverConfigPath!=null&&t.serverConfigPath!==``?t.serverConfigPath:k.join(n,`config.json`),minify:t.minify??A.env.NODE_ENV===`production`,alias:t.alias??{},assetsDir:t.assetsDir!=null&&t.assetsDir!==``?w(t.assetsDir):`assets`,define:t.define,csp:t.csp,cacheControl:t.cacheControl,cache:t.cache,action:t.action,jsPoolSize:t.jsPoolSize,origin:t.origin,htmlLimitedBots:t.htmlLimitedBots,experimental:t.experimental,mdx:t.mdx}}getModuleAnalysis(e,t){return this.moduleAnalysisCache.get(e,t)}isServerComponent(e,t){try{return Tl(e,this.moduleAnalysisCache.get(e,t))}catch{return!1}}isClientComponent(e,t){try{return this.moduleAnalysisCache.get(e,t).directives.hasUseClient}catch{return!1}}resolveImportedFilePath(e,t){let n=null;if(t.startsWith(`./`)||t.startsWith(`../`)){let r=k.dirname(e);n=k.resolve(r,t)}else if(n=E(t,this.options.alias,this.projectRoot),(n==null||n===``)&&t.startsWith(`@/`)){let e=t.slice(2);n=k.join(this.projectRoot,`src`,e)}return n==null||n===``?null:he(n,[``,`.ts`,`.tsx`,`.js`,`.jsx`])}populateImportGraphFromFiles(e){this.fileImporters.clear();for(let{filePath:t,analysis:n}of e)for(let e of wr(n.importSources)){let n=this.resolveImportedFilePath(t,e);n!=null&&n!==``&&(this.fileImporters.has(n)||this.fileImporters.set(n,/* @__PURE__ */ new Set),this.fileImporters.get(n).add(t))}}buildImportGraph(e){let t=Dl(this,[e]);this.populateImportGraphFromFiles(t)}isOnlyImportedByClientComponents(e){let t=this.fileImporters.get(e);if(!t||t.size===0)return!1;for(let e of t)if(!this.isClientComponent(e)&&!this.isOnlyImportedByClientComponents(e))return!1;return!0}addServerComponent(e,t,n){let r=t??D.readFileSync(e,`utf-8`),i=n??this.moduleAnalysisCache.get(e,r),a=Cr(i.importSources),o=Sr(i);if(i.directives.hasUseServer){this.serverActions.set(e,{filePath:e,originalCode:r,dependencies:a,hasNodeImports:o});return}Tl(e,i)&&this.serverComponents.set(e,{filePath:e,originalCode:r,dependencies:a,hasNodeImports:o})}isServerAction(e,t){return t!=null&&t!==``?this.moduleAnalysisCache.get(t,e).directives.hasUseServer:V(e).directives.hasUseServer}extractDependencies(e,t){return Cr((t!=null&&t!==``?this.moduleAnalysisCache.get(t,e):V(e)).importSources)}hasNodeImports(e,t){return Sr(t!=null&&t!==``?this.moduleAnalysisCache.get(t,e):V(e))}async getTransformedComponentsForDevelopment(e){let t=[];for(let[n]of this.serverComponents)(!e||e(n))&&t.push({componentId:this.getComponentId(n),filePath:n,isAction:!1});for(let[n]of this.serverActions)(!e||e(n))&&t.push({componentId:this.getComponentId(n),filePath:n,isAction:!0});if(t.length===0)return[];let n=await this.emitRscEntries(t.map(({componentId:e,filePath:t})=>({componentId:e,filePath:t})),{minify:this.options.minify,codeSplitting:!1});for(let e of n.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await D.promises.mkdir(k.dirname(t),{recursive:!0}),await D.promises.writeFile(t,e.code)}return t.map(e=>{let t=n.outputs.get(e.componentId);if(t==null)throw Error(`Vite RSC environment build missed entry: ${e.componentId}`);return{id:e.componentId,code:t.code,isAction:e.isAction}})}async emitProxyManifest(e){let t=k.join(e,`proxy.json`),n=[...this.serverComponents.entries()].filter(([e])=>fl.test(k.basename(e)));if(n.length===0){try{await D.promises.unlink(t)}catch(e){r(e)!==`ENOENT`&&console.warn(`Failed to remove proxy manifest file:`,e)}return}let[i,a]=n[0],o=T(this.getProjectRelativePath(i)),s=this.getComponentId(o),c=T(k.join(this.options.rscDir,`${s}.js`)),l=Kc({proxyFile:o,code:a.originalCode,bundlePath:c});l.requiresRuntime||this.serverComponents.delete(i),await D.promises.writeFile(t,JSON.stringify(l),`utf-8`)}async buildServerComponents(){let e=k.join(this.options.outDir,this.options.rscDir);await D.promises.mkdir(e,{recursive:!0}),await this.emitProxyManifest(e);let t={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},n=this.options.experimental?.useCache===!0||this.options.experimental?.useCacheRemote!=null,r=[...this.serverComponents.entries(),...this.serverActions.entries()],i=await this.buildRscEntriesWithVite(r);await this.writeViteBuiltRscEntries(t,i),n&&(this.useCacheBuildId=F(JSON.stringify(t.components),16),t.useCacheBuildId=this.useCacheBuildId);let a=k.join(this.options.outDir,this.options.manifestPath);await D.promises.writeFile(a,JSON.stringify(t),`utf-8`),await this.writeRouteCssEntries(t);let o=this.buildServerConfigObject();return await this.persistServerConfig(o),t}buildServerConfigObject(){let e={};this.options.csp&&(e.csp=this.options.csp),this.options.cacheControl&&(e.cacheControl=this.options.cacheControl),this.options.cache&&(e.cache=this.options.cache),this.options.action&&(e.action=this.options.action),this.options.jsPoolSize!=null&&(e.jsPoolSize=this.options.jsPoolSize);let t=this.options.origin?.trim().replace(/\/+$/,``);return t!=null&&t!==``&&(e.origin=t),this.options.htmlLimitedBots!=null&&(e.htmlLimitedBots=this.options.htmlLimitedBots),this.applyUseCacheServerConfig(e),e}applyUseCacheServerConfig(e){(this.options.experimental?.useCacheRemote!=null||this.useCacheBuildId!=null&&this.useCacheBuildId!==``)&&(e.useCache={...this.options.experimental?.useCacheRemote?{remote:this.options.experimental.useCacheRemote}:{},...this.useCacheBuildId!=null&&this.useCacheBuildId!==``?{buildId:this.useCacheBuildId}:{}},!this.options.experimental?.useCache&&this.options.experimental?.useCacheRemote&&console.warn(`[server-build] experimental.useCacheRemote is set without experimental.useCache; the 'use cache' transform will still run because useCacheRemote is configured.`))}async persistServerConfig(e){let t=k.join(this.options.outDir,this.options.serverConfigPath);if(Object.keys(e).length===0){try{await D.promises.unlink(t)}catch(e){r(e)!==`ENOENT`&&console.warn(`Failed to remove server config file:`,e)}return}await D.promises.writeFile(t,JSON.stringify(e),`utf-8`)}async writeViteBuiltRscEntries(e,t){for(let e of t.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await D.promises.mkdir(k.dirname(t),{recursive:!0}),await D.promises.writeFile(t,e.code)}for(let[n,r]of t.entries){let t=k.relative(this.projectRoot,n),i=this.getComponentId(n),a=pe(this.options.rscDir,i),o=k.join(this.options.outDir,a);await D.promises.mkdir(k.dirname(o),{recursive:!0}),await D.promises.writeFile(o,r.code,`utf-8`);let s=this.serverComponents.get(n)??this.serverActions.get(n),c=this.resolveServerCssSources(n,s?.originalCode??await D.promises.readFile(n,`utf-8`)),l=[...await this.writeComponentCssAsset(i,r.cssAssetSources.length>0?[...r.cssAssetSources]:c)];e.components[i]={id:i,filePath:n,relativePath:t,bundlePath:a,moduleSpecifier:Oe(k.resolve(this.projectRoot,o)).href,dependencies:[...s?.dependencies??[]],hasNodeImports:s?.hasNodeImports??!1,css:l}}}async buildRscEntriesWithVite(e){let t={entries:/* @__PURE__ */ new Map,extraFiles:[]};if(e.length===0)return t;if(this.viteBuilder==null)throw Error(`Vite builder is required for RSC environment emit`);let n=this.viteBuilder;return this.withEnvEmitLock(async()=>{let t=e.map(([e])=>({componentId:this.getComponentId(e),filePath:e})),r=await fe({viteBuilder:n,entries:t,minify:this.options.minify});if(r==null)throw Error(`Vite RSC environment build failed`);let i=/* @__PURE__ */ new Map;for(let[t]of e){let e=this.getComponentId(t),n=r.outputs.get(e);if(n==null)throw Error(`Vite RSC environment build missed entry: ${e}`);i.set(t,n)}return{entries:i,extraFiles:[...r.extraFiles]}})}async buildMdxRegistry(e){let t=Es({projectRoot:this.projectRoot,mdxOptions:e,alias:this.options.alias,cache:this.moduleAnalysisCache}),n=k.join(this.options.outDir,this.options.manifestPath),r;if(D.existsSync(n)){let e=await D.promises.readFile(n,`utf-8`),t=f(e);r=t&&Sl(t)?t:{components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()}}else r={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()};r.mdxRegistry=t.map(e=>({name:e.name,id:e.moduleId,client:e.client})),await D.promises.writeFile(n,JSON.stringify(r),`utf-8`)}collectSsrClientFiles(){let e=[...this.getClientComponentFiles()];for(let t of this.discoveredExternalClientComponents)if(!e.some(e=>e.filePath===t))try{let n=D.readFileSync(t,`utf-8`);e.push({filePath:t,code:n})}catch{}try{let t=bl();if(t!=null&&t!==``){let n=D.readFileSync(t,`utf-8`);e.push({filePath:t,code:n})}}catch{}return e}collectExternalSsrSources(){let e=[];for(let{componentId:t,devSourceSegments:n,publishedExport:r,exports:i}of gl){let a=this.resolveExternalClientSourcePath(n,r);if(a!=null&&a!==``)try{let n=D.readFileSync(a,`utf-8`);e.push({componentId:t,filePath:a,code:n,exports:[...i],bundleName:`external_${F(t)}`})}catch{}}return e}async buildSSRClientComponents(){let e=k.join(this.options.outDir,`ssr`);await D.promises.mkdir(e,{recursive:!0});let t=this.collectSsrClientFiles(),n=this.collectExternalSsrSources(),r={},i=await this.buildSsrEntriesWithVite(t,n);for(let t of i.extraFiles){let n=T(t.fileName),r=n===this.options.assetsDir||n.startsWith(`${this.options.assetsDir}/`)?k.join(this.options.clientOutDir,n):k.join(e,n);await D.promises.mkdir(k.dirname(r),{recursive:!0}),await D.promises.writeFile(r,t.code)}for(let[e,a]of i.entries){let i=n.find(t=>t.filePath===e),o=i?.componentId??Cl(e,this.projectRoot),s=`ssr/${i?.bundleName??wl(e,this.projectRoot)}.js`,c=k.join(this.options.outDir,s);await D.promises.mkdir(k.dirname(c),{recursive:!0}),await D.promises.writeFile(c,a.code,`utf-8`);let l=i?.code??t.find(t=>t.filePath===e)?.code??D.readFileSync(e,`utf-8`);r[o]={id:o,filePath:e,bundlePath:s,exports:i?.exports??this.extractExportNames(l)}}await this.writeClientReferenceManifest(e,r)}async buildSsrEntriesWithVite(e,t=[]){let n={entries:/* @__PURE__ */ new Map,extraFiles:[]},r=[...e.map(({filePath:e})=>({entryName:wl(e,this.projectRoot),filePath:e})),...t.map(e=>({entryName:e.bundleName,filePath:e.filePath}))];if(r.length===0)return n;if(this.viteBuilder==null)throw Error(`Vite builder is required for SSR environment emit`);let i=this.viteBuilder;return this.withEnvEmitLock(async()=>{let e=await me({viteBuilder:i,entries:r,minify:this.options.minify});if(e==null)throw Error(`Vite SSR environment build failed`);let t=/* @__PURE__ */ new Map;for(let n of r){let r=e.outputs.get(n.entryName);if(r==null)throw Error(`Vite SSR environment build missed entry: ${n.entryName}`);t.set(n.filePath,{code:r.code})}return{entries:t,extraFiles:[...e.extraFiles]}})}async writeClientReferenceManifest(e,t){let n=k.join(e,`manifest.json`);await D.promises.writeFile(n,JSON.stringify(t),`utf-8`);let r={};for(let[e,n]of Object.entries(t))for(let t of n.exports){let i=`${e}#${t}`;r[i]={id:i,chunks:`/${n.bundlePath}`,name:t}}let i=k.join(this.options.outDir,`server`);await D.promises.mkdir(i,{recursive:!0});let a=k.join(i,`client-reference-manifest.json`);await D.promises.writeFile(a,JSON.stringify(r),`utf-8`)}resolveExternalClientSourcePath(e,t){let n=k.join(vl,...e);if(D.existsSync(n))return n;try{let e=j(import.meta.resolve(t));if(D.existsSync(e))return e}catch{}return null}extractExportNames(e){return zn(e)}getProjectRelativePath(e){return Ut(e,this.projectRoot)}getReadableComponentId(e){return Wt(e)}getComponentId(e){return Gt(e,this.projectRoot)}async rebuildComponent(e){hl.test(k.basename(e))&&(this.layoutCssSkipSet=null);let t=this.getComponentId(e),n=await D.promises.readFile(e,`utf-8`),r=this.extractDependencies(n,e),i={filePath:e,originalCode:n,dependencies:r,hasNodeImports:this.hasNodeImports(n,e)};this.isServerAction(n,e)?(this.serverActions.set(e,i),this.serverComponents.delete(e)):(this.serverComponents.set(e,i),this.serverActions.delete(e));let a=k.join(this.options.rscDir,`${t}.js`),o=k.join(this.options.outDir,a),s=this.buildCache.get(e),c=(await D.promises.stat(e)).mtimeMs;if(s&&s.timestamp>=c&&JSON.stringify(s.sourceDependencies)===JSON.stringify(r)){let n=this.serverActions.get(e)??this.serverComponents.get(e);return n&&s.bundledDependencies.length>0&&(n.dependencies=s.bundledDependencies),await D.promises.writeFile(o,s.code,`utf-8`),await this.updateManifestForComponent(t,e,a,s.css),{componentId:t,bundlePath:this.bundlePathForRuntime(o),success:!0}}let l=k.dirname(o);await D.promises.mkdir(l,{recursive:!0});let u=await this.emitRscEntries([{componentId:t,filePath:e}],{minify:this.options.minify}),d=u.outputs.get(t);if(d==null)throw Error(`Vite RSC environment build missed entry: ${t}`);await D.promises.writeFile(o,d.code,`utf-8`);let f=this.resolveServerCssSources(e,n),p=[...await this.writeComponentCssAsset(t,d.cssAssetSources.length>0?[...d.cssAssetSources]:f)];for(let e of u.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await D.promises.mkdir(k.dirname(t),{recursive:!0}),await D.promises.writeFile(t,e.code)}let m=this.serverActions.get(e)??this.serverComponents.get(e);return this.buildCache.set(e,{code:d.code,css:p,timestamp:Date.now(),sourceDependencies:r,bundledDependencies:m?.dependencies??r}),await this.updateManifestForComponent(t,e,a,p),{componentId:t,bundlePath:this.bundlePathForRuntime(o),success:!0}}bundlePathForRuntime(e){return T(k.relative(this.projectRoot,e))}manifestCache=null;async updateManifestForComponent(e,t,n,r=[]){let i=k.join(this.options.outDir,this.options.manifestPath),a;if(this.manifestCache)a=this.manifestCache;else if(D.existsSync(i)){let e=await D.promises.readFile(i,`utf-8`),t=f(e);t&&Sl(t)?(a=t,this.manifestCache=a):(a={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},this.manifestCache=a)}else a={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},this.manifestCache=a;let o=this.serverComponents.get(t)??this.serverActions.get(t),s=k.join(this.options.outDir,n),c=Oe(k.resolve(this.projectRoot,s)).href;if(o)a.components[e]={id:e,filePath:t,relativePath:k.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:[...o.dependencies],hasNodeImports:o.hasNodeImports,css:r};else{let i=await D.promises.readFile(t,`utf-8`);a.components[e]={id:e,filePath:t,relativePath:k.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:this.extractDependencies(i,t),hasNodeImports:this.hasNodeImports(i,t),css:r}}a.buildTime=(/* @__PURE__ */ new Date()).toISOString(),await D.promises.writeFile(i,JSON.stringify(a),`utf-8`),await this.writeRouteCssEntries(a),this.manifestCache=a}clearCache(){this.buildCache.clear(),this.manifestCache=null}invalidateBuildCacheFor(e){this.buildCache.delete(e)}};function Dl(e,t){let n=[];for(let r of vr(t))try{let t=W(r),i=D.readFileSync(r,`utf-8`),a=e.getModuleAnalysis(r,i);n.push({filePath:r,cacheKey:t,code:i,analysis:a})}catch(e){console.warn(`[server-build] Error reading ${r}:`,c(e,String(e)))}return n}function Ol(e,t){return(t??V(e)).hasComponentExport||v.test(e)||te.test(e)||re.test(e)}function kl(e,t,n,r){let i=k.basename(e);if(pl.test(i)||ml.test(i)||i.endsWith(`.d.ts`))return!1;let a=r??n.getModuleAnalysis(e,t);return a.directives.hasUseClient?!1:a.directives.hasUseServer?!0:!n.isOnlyImportedByClientComponents(e)&&Tl(e,a)&&Ol(t,a)}function Al(e,t,n=[]){let r=Dl(t,yr(e,n));t.clearClientComponentFiles(),t.populateImportGraphFromFiles(r);let i=[],a=[];for(let{filePath:e,code:n,analysis:o}of r)o.directives.hasUseClient&&(a.push(e),t.recordClientComponent(e,n)),kl(e,n,t,o)&&(t.addServerComponent(e,n,o),i.push(e));return{serverComponentPaths:i,clientComponentPaths:a}}function jl(e={}){let t=null,n,r,i,a={},o=!1;async function s(){if(t){try{await t.buildMdxRegistry(e.mdx)}catch(e){console.warn(`[rari] Failed to build MDX component registry:`,e)}try{let{generateRobotsFile:e}=await import(`./robots-BOPIkPcN.mjs`);await e({appDir:k.join(n,`src`,`app`),outDir:r,aliases:a})}catch(e){console.warn(`[rari] Failed to generate robots.txt:`,e)}try{let{generateSitemapFiles:e}=await import(`./sitemap--bdIkWl5.mjs`);await e({appDir:k.join(n,`src`,`app`),outDir:r,aliases:a})}catch(e){console.warn(`[rari] Failed to generate sitemap:`,e)}try{let{generateFeedFile:e}=await import(`./feed-NrJzjZyg.mjs`);await e({appDir:k.join(n,`src`,`app`),outDir:r,aliases:a})}catch(e){console.warn(`[rari] Failed to generate feed:`,e)}try{let e=k.join(i,`server`,`routes.json`);if(D.existsSync(e)){let t=it(D.readFileSync(e,`utf-8`));t.length>0&&await nt({appDir:k.join(n,`src`,`app`),outDir:r,icons:t})}}catch(e){console.warn(`[rari] Failed to copy app icons:`,e)}try{let t=Os(n,e.mdx),a=[`public/content`,T(k.relative(n,k.join(i,`content`))),T(k.relative(n,k.join(r,`content`)))].filter(e=>e!==``&&!e.startsWith(`..`)&&!k.isAbsolute(e)),o=ks(n,t.contentDirs).filter(e=>{let t=T(k.relative(n,e));return!a.some(e=>t===e||t.startsWith(`${e}/`))});o.length>0&&js(o,k.join(i,`content`))}catch(e){console.warn(`[rari] Failed to copy MDX content:`,e)}ms(r)}}return{name:`rari-server-build`,sharedDuringBuild:!0,configResolved(s){n=s.root,r=ye(s.root,s.build.outDir),i=ve(r),o=!1;let c=Vt(s);a=c;let l=typeof s.build.assetsDir==`string`&&s.build.assetsDir!==``?w(s.build.assetsDir):`assets`;t=new El(n,{...e,alias:c,assetsDir:l,outDir:i,clientOutDir:r,minify:e.minify??s.mode===`production`})},buildStart(){if(!t)return;let e=k.join(n,`src`);D.existsSync(e)&&Al(e,t,Object.values(a))},async buildApp(e){if(!t||o)return;let n=e.environments.client;n.isBuilt||await e.build(n);let r=e.environments.rsc,i=e.environments.ssr;await r.init(),await i.init(),t.setViteBuilder(e),await t.buildServerComponents(),await t.buildSSRClientComponents(),o=!0,await s()}}}function Ml(e,t,n){if(n.length===0)return e;let r=Nn(e).find(e=>e.source===t&&!e.typeOnly&&!e.sideEffectOnly),i=/* @__PURE__ */ new Map;if(r!=null)for(let e of r.named)e.typeOnly||i.set(e.imported,e.local);for(let e of n)i.has(e)||i.set(e,e);let a=[...i.entries()].map(([e,t])=>e===t?e:`${e} as ${t}`);if(r?.namespaceBinding!=null||r?.named.some(e=>e.typeOnly)){let i=n.filter(e=>!r.named.some(t=>!t.typeOnly&&t.imported===e));return i.length===0?e:`${`import { ${[...new Set(i)].join(`, `)} } from ${JSON.stringify(t)};`}\n${e}`}let o=`import ${r?.defaultBinding==null?``:`${r.defaultBinding}, `}{ ${a.join(`, `)} } from ${JSON.stringify(t)};`;return r==null?`${o}\n\n${e}`:e.slice(0,r.start)+o+e.slice(r.end)}function Nl(e,t){return`const ${e} = createClientModuleProxy(${JSON.stringify(t)});`}function Pl(e,t,n){return`const ${e} = registerClientReference(
92
82
  function() {
93
83
  throw new Error("Attempted to call ${e} from the server but it's on the client. It can only be rendered as a Component or passed to props of a Client Component.");
94
84
  },
95
85
  ${JSON.stringify(t)},
96
86
  ${JSON.stringify(n)}
97
- );`}function Cs(e,t){let n=[],r=/* @__PURE__ */ new Set;e.namespaceBinding!=null&&(r.add(`createClientModuleProxy`),n.push(xs(e.namespaceBinding,t))),e.defaultBinding!=null&&(r.add(`registerClientReference`),n.push(Ss(e.defaultBinding,t,`default`)));for(let i of e.named)i.typeOnly||(r.add(`registerClientReference`),n.push(Ss(i.local,t,i.imported)));return n.length===0?{code:``,helpers:[]}:{code:n.join(`
98
- `),helpers:[...r]}}const ws=/(?:^|[\n\r;])\s*import\s*\{[^}]*\bregisterServerReference\b[^}]*\}\s*from\s*["'][^"'\n]+["']/;function Ts(e){return ws.test(e)}const Es=/* @__PURE__ */ new Set(/* @__PURE__ */ `undefined.NaN.Infinity.arguments.Object.Array.String.Number.Boolean.Symbol.BigInt.Math.Date.JSON.Promise.Error.TypeError.RangeError.Map.Set.WeakMap.WeakSet.RegExp.Proxy.Reflect.Function.console.fetch.process.Buffer.globalThis.global.window.document.navigator.location.crypto.TextEncoder.TextDecoder.URL.URLSearchParams.FormData.Headers.Request.Response.AbortController.AbortSignal.setTimeout.clearTimeout.setInterval.clearInterval.queueMicrotask.structuredClone.atob.btoa.React.jsx.jsxs.Fragment`.split(`.`)),Ds=/* @__PURE__ */ new Set(/* @__PURE__ */ `await.return.throw.if.else.for.while.do.switch.case.break.continue.new.typeof.instanceof.void.delete.yield.class.extends.super.this.try.catch.finally.with.debugger.default.of.in.from.as.import.export.async.function.const.let.var.true.false.null.static.get.set.typeof`.split(`.`));function Os(e){return e>=97&&e<=122||e>=65&&e<=90||e===95||e===36}function ks(e){return Os(e)||e>=48&&e<=57}function O(e,t){let n=e.length;for(;t<n;){let r=e.charCodeAt(t);if(r===32||r===9||r===10||r===13||r===65279){t++;continue}if(r===47&&e.charCodeAt(t+1)===47){for(t+=2;t<n&&e.charCodeAt(t)!==10&&e.charCodeAt(t)!==13;)t++;continue}if(r===47&&e.charCodeAt(t+1)===42){for(t+=2;t<n-1&&(e.charCodeAt(t)!==42||e.charCodeAt(t+1)!==47);)t++;t+=2;continue}break}return t}function As(e,t,n){t++;let r=e.length;for(;t<r;){let r=e.charCodeAt(t);if(r===92){t+=2;continue}if(r===n)return t+1;t++}return t}function js(e,t,n,r){let i=t,a=0,o=e.length;for(;i<o;){let t=Mn(e,i,o);if(t!==-1){i=t;continue}let s=e.charCodeAt(i);if(s===n)a++;else if(s===r&&(a--,a===0))return i+1;i++}return i}function Ms(e,t,n){for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;return!0}function Ns(e,t,n){let r=O(e,t+1);if(r>=n)return!1;let i=e.charCodeAt(r);if(i!==39&&i!==34)return!1;let a=r+1,o=As(e,r,i);if(o-1-a!=10||!Ms(e,a,`use server`))return!1;for(r=o;r<n;){let t=e.charCodeAt(r);if(t===32||t===9){r++;continue}return t===59||t===10||t===13||t===47&&e.charCodeAt(r+1)===47||t===47&&e.charCodeAt(r+1)===42}return!0}function Ps(e,t,n){let r=O(e,t+1),i=e.charCodeAt(r);return i!==39&&i!==34?e.slice(t+1,n):(r=O(e,As(e,r,i)),e.charCodeAt(r)===59&&r++,r=O(e,r),e.slice(r,n))}function Fs(e,t){if(!Os(e.charCodeAt(t)))return null;let n=t+1;for(;n<e.length&&ks(e.charCodeAt(n));)n++;return{name:e.slice(t,n),end:n}}function Is(e,t,n){if(!Ms(e,t,n))return!1;let r=t>0?e.charCodeAt(t-1):-1,i=t+n.length<e.length?e.charCodeAt(t+n.length):-1;return!(r!==-1&&ks(r)||i!==-1&&ks(i))}function Ls(e){let t=/* @__PURE__ */ new Set,n=0,r=e.length;for(;n<r&&(n=O(e,n),!(n>=r));){let r=e.charCodeAt(n);if(r===123||r===91){let i=js(e,n,r,r===123?125:93);for(let r of e.slice(n,i).matchAll(/[a-z_$][\w$]*/gi))r[0]!==`as`&&t.add(r[0]);n=i;continue}if(r===46&&e.charCodeAt(n+1)===46&&e.charCodeAt(n+2)===46){n+=3,n=O(e,n);let r=Fs(e,n);r&&(t.add(r.name),n=r.end);continue}let i=Fs(e,n);if(i){t.add(i.name),n=i.end;continue}n++}return t}function Rs(e){let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(/\b(?:const|let|var|function|class|async\s+function)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);return t}function zs(e){let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(/\b(?:import|export)\s+(?:type\s+)?(?:\{([^}]+)\}|(\*\s+as\s+[A-Za-z_$][\w$]*)|([A-Za-z_$][\w$]*))/g)){if(n[1])for(let e of n[1].split(`,`)){let n=e.trim();if(!n||n.startsWith(`type `))continue;let r=(n.split(/\s+as\s+/).at(-1)??``).trim();r&&t.add(r)}if(n[2]){let e=/as\s+([A-Za-z_$][\w$]*)/.exec(n[2]);e&&t.add(e[1])}n[3]&&n[3]!==`type`&&n[3]!==`async`&&n[3]!==`function`&&n[3]!==`class`&&t.add(n[3])}for(let n of e.matchAll(/(?:^|\n)\s*(?:export\s+)?(?:async\s+)?(?:function|class|const|let|var)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);return t}function Bs(e,t,n){let r=/* @__PURE__ */ new Set([...Ls(t),...Rs(e),...n,...Es,...Ds]),i=/* @__PURE__ */ new Set,a=0,o=e.length;for(;a<o;){let t=Mn(e,a,o);if(t!==-1){a=t;continue}if(!Os(e.charCodeAt(a))){a++;continue}let n=Fs(e,a);if(n==null){a++;continue}if(a>0&&e.charCodeAt(a-1)===46){a=n.end;continue}if(Us(e,a,n.end)){a=n.end;continue}r.has(n.name)||i.add(n.name),a=n.end}return[...i]}function Vs(e,t){for(;t>0;){let n=e.charCodeAt(t-1);if(n===32||n===9||n===10||n===13||n===65279)t--;else break}return t}function Hs(e,t,n){let r=t-n.length;return r<0||!Is(e,r,n)?null:r}function Us(e,t,n){let r=O(e,n);if(e.charCodeAt(r)!==58)return!1;let i=Vs(e,t);if(i===0)return!1;let a=e.charCodeAt(i-1);return a===123||a===44}function Ws(e,t){let n=Vs(e,t),r=Hs(e,n,`default`);if(r!=null){n=Vs(e,r);let t=Hs(e,n,`export`);if(t!=null)return{start:t,exportKind:`default`,bindingName:null}}if(n>0&&e.charCodeAt(n-1)===61){let r=Vs(e,n-1),i=r;for(;i>0&&ks(e.charCodeAt(i-1));)i--;if(i<r&&Os(e.charCodeAt(i))){let n=e.slice(i,r),a=Vs(e,i),o=Hs(e,a,`const`)??Hs(e,a,`let`)??Hs(e,a,`var`);if(o!=null)return Hs(e,Vs(e,o),`export`)==null?{start:t,exportKind:null,bindingName:n}:{start:t,exportKind:`named`,bindingName:n}}}let i=Hs(e,n,`export`);return i==null?{start:t,exportKind:null,bindingName:null}:{start:i,exportKind:`named`,bindingName:null}}function Gs(e){let t=[],n=e.length,r=0;for(;r<n;){let n=e.charCodeAt(r);if(n===39||n===34||n===96){r=As(e,r,n);continue}if(n===47&&(e.charCodeAt(r+1)===47||e.charCodeAt(r+1)===42)){r=O(e,r);continue}if(Is(e,r,`async`)||Is(e,r,`function`)){let n=r,i=r,a=!1;if(Is(e,i,`async`)&&(a=!0,i=O(e,i+5)),Is(e,i,`function`)){i=O(e,i+8),e.charCodeAt(i)===42&&(i=O(e,i+1));let o=null,s=Fs(e,i);if(s&&(o=s.name,i=O(e,s.end)),e.charCodeAt(i)!==40){r++;continue}let c=js(e,i,40,41),l=e.slice(i+1,c-1);if(i=O(e,c),e.charCodeAt(i)!==123){r++;continue}let u=js(e,i,123,125)-1;Ns(e,i,u)?(t.push({start:n,end:u+1,bodyOpen:i,bodyClose:u,paramsRaw:l,isAsync:a,name:o,kind:o==null?`expression`:`declaration`}),r=u+1):r=i+1;continue}if(a&&e.charCodeAt(i)===40){let a=js(e,i,40,41),o=e.slice(i+1,a-1),s=O(e,a);if(e.charCodeAt(s)===61&&e.charCodeAt(s+1)===62&&(s=O(e,s+2),e.charCodeAt(s)===123)){let i=js(e,s,123,125)-1;Ns(e,s,i)?(t.push({start:n,end:i+1,bodyOpen:s,bodyClose:i,paramsRaw:o,isAsync:!0,name:null,kind:`arrow`}),r=i+1):r=s+1;continue}}}if(e.charCodeAt(r)===40){let n=js(e,r,40,41),i=O(e,n);if(e.charCodeAt(i)===61&&e.charCodeAt(i+1)===62&&(i=O(e,i+2),e.charCodeAt(i)===123)){let a=js(e,i,123,125)-1;Ns(e,i,a)?(t.push({start:r,end:a+1,bodyOpen:i,bodyClose:a,paramsRaw:e.slice(r+1,n-1),isAsync:!1,name:null,kind:`arrow`}),r=a+1):r=i+1;continue}}r++}return t}function Ks(e,t){let n=Gs(e);if(n.length===0)return null;let r=zs(e),i=[],a=[],o=e,s=[],c=!1,l=[...n].sort((e,t)=>t.start-e.start),u=n.length-1;for(let e of l){let n=e.name??`anonymous_server_function`,l=`$$ACTION_${u}_${n.replace(/\W/g,`_`)}`;u--,i.unshift(l);let d=Ps(o,e.bodyOpen,e.bodyClose),f=Bs(d,e.paramsRaw,r),p=[...f,e.paramsRaw.trim()].filter(e=>e!==``).join(`, `),m=e.isAsync?`async `:``,h=f.length>0?`${l}.bind(null, ${f.join(`, `)})`:l,{start:g,exportKind:_,bindingName:ee}=Ws(o,e.start),te=h,v=null;_==="default"?(v=`default`,te=`export default registerServerReference(${h}, ${JSON.stringify(t)}, "default")`):_===`named`&&e.name!=null?(v=e.name,te=`export const ${e.name} = registerServerReference(${h}, ${JSON.stringify(t)}, ${JSON.stringify(e.name)})`):_===`named`&&ee!=null?(v=ee,te=`registerServerReference(${h}, ${JSON.stringify(t)}, ${JSON.stringify(ee)})`):e.kind===`declaration`&&e.name!=null&&(te=`const ${e.name} = ${h}`),v==null?s.unshift(`${m}function ${l}(${p}) {\n${d}\n}`,`registerServerReference(${l}, ${JSON.stringify(t)}, ${JSON.stringify(l)});`):(s.unshift(`${m}function ${l}(${p}) {\n${d}\n}`),a.unshift(v)),c=!0,o=o.slice(0,g)+te+o.slice(e.end)}let d=c?`import { registerServerReference } from ${JSON.stringify(`react-server-dom-rari/server`)};\n`:``;return{code:`${c&&!Ts(o)?d:``}${o}\n\n${s.join(`
99
- `)}\n`,actionNames:i,rewrittenExportNames:a}}const qs=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g,Js=/import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g,Ys=/import\s+(\w+)\s*,\s*\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g,Xs=/defineMdxComponents\s*\(\s*\{([\s\S]*?)\}\s*\)/;function Zs(e,t,n){for(let r of t.split(`,`)){let t=r.trim();if(!t||(t=t.replace(/^type\s+/i,``).trim(),!t))continue;let i=t.split(/\s+as\s+/i),a=(i[1]??i[0]).trim();a&&n.set(a,e)}}function Qs(e){let t=/* @__PURE__ */ new Map;for(let n of e.matchAll(Ys))t.set(n[1],n[3]),Zs(n[3],n[2],t);for(let n of e.matchAll(qs))t.set(n[1],n[2]);for(let n of e.matchAll(Js))Zs(n[2],n[1],t);return t}function $s(e){let t=[];for(let n of e.split(`,`)){let e=n.trim();if(!e)continue;let r=e.indexOf(`:`);if(r===-1){t.push({name:e,binding:e});continue}let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();i&&a&&t.push({name:i,binding:a})}return t}function ec(e){try{return mn(b.readFileSync(e,`utf-8`)).topLevelUseClient}catch{return!1}}function tc(e){let{code:t,id:n,projectRoot:r,resolvedAlias:i}=e;if(!t.includes(`defineMdxComponents`)||t.includes(`__RARI_MDX_RESOLVED__`))return null;let a=Xs.exec(t);if(!a)return null;let o=Qs(t),s=$s(a[1]);if(s.length===0)return null;let c=`defineMdxComponents(/* __RARI_MDX_RESOLVED__ */[\n${s.map(({name:e,binding:t})=>{let a=o.get(t);if(a==null||a===``)throw Error(`[rari/mdx] Could not resolve import for MDX component "${e}" (binding "${t}") in ${n}`);let s=_e(a,n,i),c=Jt(s,r),l=ec(s);return` { name: ${JSON.stringify(e)}, component: ${t}, id: ${JSON.stringify(c)}, client: ${l} }`}).join(`,
100
- `)},\n])`;return t.replace(Xs,c)}const nc=/forwardRef|memo|\b(?:[A-Z]|use[A-Z0-9])/,rc=/\.[cm]?[jt]sx?$/,ic=/['"]use memo['"]/;function ac(e){return{...e===!0?{}:e,target:`19`}}function oc(e,t){return t.compilationMode===`annotation`?ic.test(e):nc.test(e)}function sc(e){if(e.startsWith(`\0`)||e.includes(`virtual:`))return!1;let t=ue(e);return/\.d\.[cm]?ts$/.test(t)||t.includes(`/dist/`)?!1:rc.test(t)&&!t.includes(`/node_modules/`)}function cc(e){return Sn(e)}const lc=/\.[jt]sx$/;function uc(e,t=`app`){let n=ac(e),r,i=!0,a=!1,s=!1,c=async e=>{if(r)return r;try{return r=await import(`oxc-transform-react`),r}catch(t){let n=o(t);return e(`React Compiler requires the optional \`oxc-transform-react\` package. Install it before enabling \`rari({ compiler: true })\`.${n==null?``:`\n${n.message}`}`)}};return{name:t===`library`?`rari:react-compiler-library`:`rari:react-compiler`,enforce:`pre`,async config(e,{command:n}){return await c(e=>this.error(e)),t===`library`?(s=!1,a=!1,{}):(s=n===`serve`,{oxc:{jsx:{refresh:!1}},optimizeDeps:{include:[`react/compiler-runtime`]}})},configResolved(e){if(t===`library`){i=e.build.sourcemap!==!1,a=!1,s=!1;return}i=e.command!==`build`||e.build.sourcemap!==!1,a=!e.isProduction,s=!e.isProduction&&e.command===`serve`&&e.server.hmr!==!1},async transform(e,o){if(!sc(o))return null;let l=ue(o);if(t===`library`&&!lc.test(l)||cc(e)||t===`app`&&this.environment.config.consumer===`server`)return null;let{transform:u}=r??await c(e=>this.error(e)),d=oc(e,n),f=await u(l,e,{jsx:{runtime:`automatic`,development:a,importSource:`react`,refresh:s},reactCompiler:d?n:!1,sourcemap:i}),p=f.errors.map(e=>{let t=e.codeframe;return t!=null&&t!==``?`${e.message}\n${t}`:e.message});if(f.fatal){let e=p.join(`
101
-
102
- `);this.error(e===``?`React Compiler transform failed.`:e)}for(let e of p)this.warn(e);return{code:f.code,map:f.map}}}}var dc=Object.create,fc=Object.defineProperty,pc=Object.getOwnPropertyDescriptor,mc=Object.getOwnPropertyNames,hc=Object.getPrototypeOf,gc=Object.prototype.hasOwnProperty,_c=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),vc=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=mc(t),a=0,o=i.length,s;a<o;a++)s=i[a],!gc.call(e,s)&&s!==n&&fc(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=pc(t,s))||r.enumerable});return e},yc=(e,t,n)=>(n=e==null?{}:dc(hc(e)),vc(t||!e||!e.__esModule||!gc.call(e,`default`)?fc(n,`default`,{value:e,enumerable:!0}):n,e)),k=/* @__PURE__ */ Ee(import.meta.url),bc=/* @__PURE__ */ _c(((e,t)=>{let n=k(`node:fs`),r=k(`node:child_process`),i=JSON.parse(n.readFileSync(k.resolve(`rolldown/package.json`),`utf-8`)).version,a=`/tmp/rolldown-${i}`,o=`${a}/node_modules/@rolldown/binding-wasm32-wasi/rolldown-binding.wasi.cjs`;if(!n.existsSync(o)){let e=`@rolldown/binding-wasm32-wasi@${i}`;n.rmSync(a,{recursive:!0,force:!0}),n.mkdirSync(a,{recursive:!0}),console.log(`[rolldown] Downloading ${e} on WebContainer...`),r.execFileSync(`pnpm`,[`i`,e],{cwd:a,stdio:`inherit`})}t.exports=k(o)})),xc=/* @__PURE__ */ _c(((e,t)=>{let{readFileSync:n}=k(`fs`),r=null,i=`native`,a=[],o=()=>{let e=!1;return process.platform===`linux`&&(e=c(),e===null&&(e=l()),e===null&&(e=u())),e},s=e=>e.includes(`libc.musl-`)||e.includes(`ld-musl-`),c=()=>{try{return n(`/usr/bin/ldd`,`utf-8`).includes(`musl`)}catch{return null}},l=()=>{let e=null;return process.report&&typeof process.report.getReport==`function`&&(process.report.excludeNetwork=!0,e=process.report.getReport()),e?e.header&&e.header.glibcVersionRuntime?!1:!!(Array.isArray(e.sharedObjects)&&e.sharedObjects.some(s)):null},u=()=>{try{return k(`child_process`).execSync(`ldd --version`,{encoding:`utf8`}).includes(`musl`)}catch{return!1}};function d(){if(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)try{let e=k(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);return i=e&&typeof e.__napiBindingTarget==`string`?e.__napiBindingTarget:`native`,e}catch(e){a.push(e)}else if(process.platform===`android`){if(process.arch===`arm64`){try{return k(`./rolldown-binding.android-arm64.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-android-arm64`),t=k(`@rolldown/binding-android-arm64/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else if(process.arch===`arm`){try{return k(`./rolldown-binding.android-arm-eabi.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-android-arm-eabi`),t=k(`@rolldown/binding-android-arm-eabi/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else a.push(/* @__PURE__ */ Error(`Unsupported architecture on Android ${process.arch}`))}else if(process.platform===`win32`){if(process.arch===`x64`){if(process.config&&process.config.variables&&process.config.variables.shlib_suffix===`dll.a`||process.config&&process.config.variables&&process.config.variables.node_target_type===`shared_library`){try{return k(`./rolldown-binding.win32-x64-gnu.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-win32-x64-gnu`),t=k(`@rolldown/binding-win32-x64-gnu/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else{try{return k(`./rolldown-binding.win32-x64-msvc.node`)}catch(e){a.push(e)}try{let e=k(`@voidzero-dev/vite-plus-win32-x64-msvc`),t=k(`@voidzero-dev/vite-plus-win32-x64-msvc/package.json`).version;if(t!==`0.3.3`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 0.3.3 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}}else if(process.arch===`ia32`){try{return k(`./rolldown-binding.win32-ia32-msvc.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-win32-ia32-msvc`),t=k(`@rolldown/binding-win32-ia32-msvc/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else if(process.arch===`arm64`){try{return k(`./rolldown-binding.win32-arm64-msvc.node`)}catch(e){a.push(e)}try{let e=k(`@voidzero-dev/vite-plus-win32-arm64-msvc`),t=k(`@voidzero-dev/vite-plus-win32-arm64-msvc/package.json`).version;if(t!==`0.3.3`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 0.3.3 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else a.push(/* @__PURE__ */ Error(`Unsupported architecture on Windows: ${process.arch}`))}else if(process.platform===`darwin`){try{return k(`./rolldown-binding.darwin-universal.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-darwin-universal`),t=k(`@rolldown/binding-darwin-universal/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}if(process.arch===`x64`){try{return k(`./rolldown-binding.darwin-x64.node`)}catch(e){a.push(e)}try{let e=k(`@voidzero-dev/vite-plus-darwin-x64`),t=k(`@voidzero-dev/vite-plus-darwin-x64/package.json`).version;if(t!==`0.3.3`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 0.3.3 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else if(process.arch===`arm64`){try{return k(`./rolldown-binding.darwin-arm64.node`)}catch(e){a.push(e)}try{let e=k(`@voidzero-dev/vite-plus-darwin-arm64`),t=k(`@voidzero-dev/vite-plus-darwin-arm64/package.json`).version;if(t!==`0.3.3`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 0.3.3 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else a.push(/* @__PURE__ */ Error(`Unsupported architecture on macOS: ${process.arch}`))}else if(process.platform===`freebsd`){if(process.arch===`x64`){try{return k(`./rolldown-binding.freebsd-x64.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-freebsd-x64`),t=k(`@rolldown/binding-freebsd-x64/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else if(process.arch===`arm64`){try{return k(`./rolldown-binding.freebsd-arm64.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-freebsd-arm64`),t=k(`@rolldown/binding-freebsd-arm64/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else a.push(/* @__PURE__ */ Error(`Unsupported architecture on FreeBSD: ${process.arch}`))}else if(process.platform===`linux`){if(process.arch===`x64`){if(o()){try{return k(`./rolldown-binding.linux-x64-musl.node`)}catch(e){a.push(e)}try{let e=k(`@voidzero-dev/vite-plus-linux-x64-musl`),t=k(`@voidzero-dev/vite-plus-linux-x64-musl/package.json`).version;if(t!==`0.3.3`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 0.3.3 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else{try{return k(`../rolldown-binding.linux-x64-gnu.node`)}catch(e){a.push(e)}try{let e=k(`@voidzero-dev/vite-plus-linux-x64-gnu`),t=k(`@voidzero-dev/vite-plus-linux-x64-gnu/package.json`).version;if(t!==`0.3.3`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 0.3.3 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}}else if(process.arch===`arm64`){if(o()){try{return k(`./rolldown-binding.linux-arm64-musl.node`)}catch(e){a.push(e)}try{let e=k(`@voidzero-dev/vite-plus-linux-arm64-musl`),t=k(`@voidzero-dev/vite-plus-linux-arm64-musl/package.json`).version;if(t!==`0.3.3`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 0.3.3 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else{try{return k(`./rolldown-binding.linux-arm64-gnu.node`)}catch(e){a.push(e)}try{let e=k(`@voidzero-dev/vite-plus-linux-arm64-gnu`),t=k(`@voidzero-dev/vite-plus-linux-arm64-gnu/package.json`).version;if(t!==`0.3.3`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 0.3.3 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}}else if(process.arch===`arm`){if(o()){try{return k(`./rolldown-binding.linux-arm-musleabihf.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-linux-arm-musleabihf`),t=k(`@rolldown/binding-linux-arm-musleabihf/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else{try{return k(`./rolldown-binding.linux-arm-gnueabihf.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-linux-arm-gnueabihf`),t=k(`@rolldown/binding-linux-arm-gnueabihf/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}}else if(process.arch===`loong64`){if(o()){try{return k(`./rolldown-binding.linux-loong64-musl.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-linux-loong64-musl`),t=k(`@rolldown/binding-linux-loong64-musl/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else{try{return k(`./rolldown-binding.linux-loong64-gnu.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-linux-loong64-gnu`),t=k(`@rolldown/binding-linux-loong64-gnu/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}}else if(process.arch===`riscv64`){if(o()){try{return k(`./rolldown-binding.linux-riscv64-musl.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-linux-riscv64-musl`),t=k(`@rolldown/binding-linux-riscv64-musl/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else{try{return k(`./rolldown-binding.linux-riscv64-gnu.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-linux-riscv64-gnu`),t=k(`@rolldown/binding-linux-riscv64-gnu/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}}else if(process.arch===`ppc64`){try{return k(`./rolldown-binding.linux-ppc64-gnu.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-linux-ppc64-gnu`),t=k(`@rolldown/binding-linux-ppc64-gnu/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else if(process.arch===`s390x`){try{return k(`./rolldown-binding.linux-s390x-gnu.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-linux-s390x-gnu`),t=k(`@rolldown/binding-linux-s390x-gnu/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else a.push(/* @__PURE__ */ Error(`Unsupported architecture on Linux: ${process.arch}`))}else if(process.platform===`openharmony`){if(process.arch===`arm64`){try{return k(`./rolldown-binding.openharmony-arm64.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-openharmony-arm64`),t=k(`@rolldown/binding-openharmony-arm64/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else if(process.arch===`x64`){try{return k(`./rolldown-binding.openharmony-x64.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-openharmony-x64`),t=k(`@rolldown/binding-openharmony-x64/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else if(process.arch===`arm`){try{return k(`./rolldown-binding.openharmony-arm.node`)}catch(e){a.push(e)}try{let e=k(`@rolldown/binding-openharmony-arm`),t=k(`@rolldown/binding-openharmony-arm/package.json`).version;if(t!==`1.2.9`&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`)throw Error(`Native binding package version mismatch, expected 1.2.9 but got ${t}. You can reinstall dependencies to fix this issue.`);return e}catch(e){a.push(e)}}else a.push(/* @__PURE__ */ Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))}else a.push(/* @__PURE__ */ Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))}function f(e){return e.reduce((e,t)=>{let n;try{n=t&&typeof t.message==`string`?t.message:String(t)}catch{n=`Unknown error`}let r=Error(n);return r.cause=e,r},null)}let p=[`wasm32-wasi`],m=process.env.NAPI_RS_WASI_FLAVOR,h=typeof m==`string`&&m.length>0;if(h&&p.indexOf(m)===-1)throw Error(`Unsupported WASI flavor "`+m+`". Available flavors: `+p.join(`, `));let g=process.env.NAPI_RS_FORCE_WASI===`error`,_=process.env.NAPI_RS_FORCE_WASI===`true`||g||h;if(_||(r=d()),!r||_){let e=null,t=!1,n=[],o=(e,t,n)=>{try{k.resolve(e)}catch(n){if(!n||n.code!==`MODULE_NOT_FOUND`)throw n;if(t){try{k.resolve(e+`/package.json`)}catch(e){if(e&&e.code===`MODULE_NOT_FOUND`)return n;throw n}throw n}return n}if(n){let e=null;for(let t=0;t<n.length;t++)try{return k.resolve(n[t]),null}catch(t){if(!t||t.code!==`MODULE_NOT_FOUND`)throw t;e=t}return e}return null};if(!t&&(!h||m===`wasm32-wasi`)){let s=null,c=!1;try{s=o(`./rolldown-binding.wasi.cjs`,!1,[`./rolldown-binding.wasm32-wasi.debug.wasm`,`./rolldown-binding.wasm32-wasi.wasm`]),c=s!==null,c||(e=k(`../rolldown-binding.wasi.cjs`),r=e,i=`wasm32-wasi`,t=!0)}catch(e){s=e,c=!0}c&&(n.push(s),a.push(s))}if(!t&&(!h||m===`wasm32-wasi`)){let s=null,c=!1;try{if(s=o(`@rolldown/binding-wasm32-wasi`,!0,void 0),c=s!==null,!c){if(process.env.NAPI_RS_ENFORCE_VERSION_CHECK&&process.env.NAPI_RS_ENFORCE_VERSION_CHECK!==`0`){let e=k(`@rolldown/binding-wasm32-wasi/package.json`).version;if(e!==`1.2.9`)throw Error(`WASI binding package version mismatch, expected 1.2.9 but got ${e}. You can reinstall dependencies to fix this issue.`)}e=k(`@rolldown/binding-wasm32-wasi`),r=e,i=`wasm32-wasi`,t=!0}}catch(e){s=e,c=!0}c&&(n.push(s),a.push(s))}if(!t&&_&&!g&&!h&&(r=d()),(g||h)&&!t){let e=/* @__PURE__ */ Error(h?`WASI binding for flavor "`+m+`" not found`:`WASI binding not found and NAPI_RS_FORCE_WASI is set to error`);throw e.cause=f(n),e}}if(!r&&globalThis.process?.versions?.webcontainer)try{r=bc()}catch(e){a.push(e)}if(!r){if(a.length>0){let e=/* @__PURE__ */ Error("Cannot find native binding. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.");throw e.cause=f(a),e}throw Error(`Failed to load native binding`)}function ee(e,t){if(Object.prototype.hasOwnProperty.call(e,`__napiBindingTarget`)){if(e.__napiBindingTarget===t)return t;let n=/* @__PURE__ */ Error('`__napiBindingTarget` is reserved by the generated binding loader, but the loaded binding already exports it. Rename the export, e.g. #[napi(js_name = "...")].');throw n.code=`ERR_NAPI_BINDING_TARGET_CONFLICT`,n}if(!Object.isExtensible(e))return t;try{Object.defineProperty(e,"__napiBindingTarget",{configurable:!0,enumerable:!0,value:t,writable:!0})}catch{}return t}t.exports.__napiBindingTarget=ee(r,i),t.exports=r,t.exports.LegalCommentsMode=r.LegalCommentsMode,t.exports.minify=r.minify,t.exports.minifySync=r.minifySync,t.exports.Severity=r.Severity,t.exports.ParseResult=r.ParseResult,t.exports.ExportExportNameKind=r.ExportExportNameKind,t.exports.ExportImportNameKind=r.ExportImportNameKind,t.exports.ExportLocalNameKind=r.ExportLocalNameKind,t.exports.ImportNameKind=r.ImportNameKind,t.exports.parse=r.parse,t.exports.parseSync=r.parseSync,t.exports.rawTransferSupported=r.rawTransferSupported,t.exports.ResolverFactory=r.ResolverFactory,t.exports.EnforceExtension=r.EnforceExtension,t.exports.ModuleType=r.ModuleType,t.exports.sync=r.sync,t.exports.HelperMode=r.HelperMode,t.exports.isolatedDeclaration=r.isolatedDeclaration,t.exports.isolatedDeclarationSync=r.isolatedDeclarationSync,t.exports.moduleRunnerTransform=r.moduleRunnerTransform,t.exports.moduleRunnerTransformSync=r.moduleRunnerTransformSync,t.exports.transform=r.transform,t.exports.transformSync=r.transformSync,t.exports.BindingBundleEndEventData=r.BindingBundleEndEventData,t.exports.BindingBundleErrorEventData=r.BindingBundleErrorEventData,t.exports.BindingBundler=r.BindingBundler,t.exports.BindingCallableBuiltinPlugin=r.BindingCallableBuiltinPlugin,t.exports.BindingChunkingContext=r.BindingChunkingContext,t.exports.BindingDecodedMap=r.BindingDecodedMap,t.exports.BindingDevEngine=r.BindingDevEngine,t.exports.BindingLoadPluginContext=r.BindingLoadPluginContext,t.exports.BindingMagicString=r.BindingMagicString,t.exports.BindingModuleInfo=r.BindingModuleInfo,t.exports.BindingNormalizedOptions=r.BindingNormalizedOptions,t.exports.BindingOutputAsset=r.BindingOutputAsset,t.exports.BindingOutputChunk=r.BindingOutputChunk,t.exports.BindingPluginContext=r.BindingPluginContext,t.exports.BindingRenderedChunk=r.BindingRenderedChunk,t.exports.BindingRenderedChunkMeta=r.BindingRenderedChunkMeta,t.exports.BindingRenderedModule=r.BindingRenderedModule,t.exports.BindingSourceMap=r.BindingSourceMap,t.exports.BindingTransformPluginContext=r.BindingTransformPluginContext,t.exports.BindingWatcher=r.BindingWatcher,t.exports.BindingWatcherBundler=r.BindingWatcherBundler,t.exports.BindingWatcherChangeData=r.BindingWatcherChangeData,t.exports.BindingWatcherEvent=r.BindingWatcherEvent,t.exports.ParallelJsPluginRegistry=r.ParallelJsPluginRegistry,t.exports.TraceSubscriberGuard=r.TraceSubscriberGuard,t.exports.TsconfigCache=r.TsconfigCache,t.exports.__internalForcePanic=r.__internalForcePanic,t.exports.BindingAttachDebugInfo=r.BindingAttachDebugInfo,t.exports.BindingBuiltinPluginName=r.BindingBuiltinPluginName,t.exports.BindingChunkModuleOrderBy=r.BindingChunkModuleOrderBy,t.exports.BindingErrorStage=r.BindingErrorStage,t.exports.BindingLogLevel=r.BindingLogLevel,t.exports.BindingPluginOrder=r.BindingPluginOrder,t.exports.BindingPropertyReadSideEffects=r.BindingPropertyReadSideEffects,t.exports.BindingPropertyWriteSideEffects=r.BindingPropertyWriteSideEffects,t.exports.BindingRebuildStrategy=r.BindingRebuildStrategy,t.exports.collapseSourcemaps=r.collapseSourcemaps,t.exports.enhancedTransform=r.enhancedTransform,t.exports.enhancedTransformSync=r.enhancedTransformSync,t.exports.FilterTokenKind=r.FilterTokenKind,t.exports.getNativeMemoryStats=r.getNativeMemoryStats,t.exports.initTraceSubscriber=r.initTraceSubscriber,t.exports.registerPlugins=r.registerPlugins,t.exports.resetNativeMemoryStats=r.resetNativeMemoryStats,t.exports.resolveTsconfig=r.resolveTsconfig,t.exports.shutdownAsyncRuntime=r.shutdownAsyncRuntime,t.exports.startAsyncRuntime=r.startAsyncRuntime}));function Sc(e,t,{hook:n,id:r}={}){try{let i=e.code;!e.pluginCode&&i!=null&&(typeof i!=`string`||!i.startsWith(`PLUGIN_`))&&(e.pluginCode=i),e.code=`PLUGIN_ERROR`,e.plugin=t,n&&(e.hook=n),r&&(e.id=r)}catch{}finally{return e}}function Cc(e){throw e instanceof Error||(e=Object.assign(Error(e.message),e),Object.defineProperty(e,"name",{value:`RolldownError`,writable:!0})),e}var wc=/* @__PURE__ */ yc(xc(),1),Tc=class{name;_options;enforce;constructor(e,t){this.name=e,this._options=t}};function Ec(e){let t=new wc.BindingCallableBuiltinPlugin(Dc(e)),n=e;for(let r in t){let i=async function(...i){try{return await t[r](...i)}catch(t){return t instanceof Error&&!t.stack?.includes(`at `)&&Error.captureStackTrace(t,n[r]),Cc(Sc(t,e.name,{hook:r,id:r===`transform`?i[2]:void 0}))}},a=t.getOrder(r);n[r]=a==null?i:{handler:i,order:a}}return n}function Dc(e){return{__name:e.name,options:e._options}}function Oc(e){if(e)return kc(e)?e:[e]}function kc(e){return Array.isArray(e)}xc(),xc();var A=/* @__PURE__ */ yc(xc(),1);const Ac=Symbol(`__lazy_fields__`);var jc=class{constructor(){Mc(this)}};function Mc(e){let t=e.constructor[Ac];if(t)for(let[n,r]of t.entries()){let t,i=!1;Object.defineProperty(e,n,{get(){return i||=(t=r.call(this),!0),t},enumerable:!0,configurable:!0})}}function Nc(e){let t=e.constructor[Ac];return t?new Set(t.keys()):/* @__PURE__ */ new Set}function j(e,t,n){e.constructor[Ac]||(e.constructor[Ac]=/* @__PURE__ */ new Map);let r=n.get;return e.constructor[Ac].set(t,r),{enumerable:!1,configurable:!0}}function Pc(e){return e.inner}function M(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var Fc=class extends jc{bindingAsset;type=`asset`;constructor(e){super(),this.bindingAsset=e}get fileName(){return this.bindingAsset.getFileName()}get originalFileName(){return this.bindingAsset.getOriginalFileName()||null}get originalFileNames(){return this.bindingAsset.getOriginalFileNames()}get name(){return this.bindingAsset.getName()??void 0}get names(){return this.bindingAsset.getNames()}get source(){return Pc(this.bindingAsset.getSource())}__rolldown_external_memory_handle__(e){return e&&this.#e(),this.bindingAsset.dropInner()}#e(){for(let e of Nc(this))this[e]}};M([j],Fc.prototype,`fileName`,null),M([j],Fc.prototype,`originalFileName`,null),M([j],Fc.prototype,`originalFileNames`,null),M([j],Fc.prototype,`name`,null),M([j],Fc.prototype,`names`,null),M([j],Fc.prototype,`source`,null);function Ic(e){return{get code(){return e.code},get renderedLength(){return e.code?.length||0},get renderedExports(){return e.renderedExports}}}function Lc(e){let t={};for(let n=0;n<e.values.length;n++){let r=e.keys[n],i=e.values[n];t[r]=Ic(i)}return t}var N=class extends jc{bindingChunk;type=`chunk`;constructor(e){super(),this.bindingChunk=e}get fileName(){return this.bindingChunk.getFileName()}get name(){return this.bindingChunk.getName()}get exports(){return this.bindingChunk.getExports()}get isEntry(){return this.bindingChunk.getIsEntry()}get facadeModuleId(){return this.bindingChunk.getFacadeModuleId()||null}get isDynamicEntry(){return this.bindingChunk.getIsDynamicEntry()}get sourcemapFileName(){return this.bindingChunk.getSourcemapFileName()||null}get preliminaryFileName(){return this.bindingChunk.getPreliminaryFileName()}get code(){return this.bindingChunk.getCode()}get modules(){return Lc(this.bindingChunk.getModules())}get imports(){return this.bindingChunk.getImports()}get dynamicImports(){return this.bindingChunk.getDynamicImports()}get moduleIds(){return this.bindingChunk.getModuleIds()}get map(){let e=this.bindingChunk.getMap();return e?Rc(e):null}__rolldown_external_memory_handle__(e){return e&&this.#e(),this.bindingChunk.dropInner()}#e(){for(let e of Nc(this))this[e]}};M([j],N.prototype,`fileName`,null),M([j],N.prototype,`name`,null),M([j],N.prototype,`exports`,null),M([j],N.prototype,`isEntry`,null),M([j],N.prototype,`facadeModuleId`,null),M([j],N.prototype,`isDynamicEntry`,null),M([j],N.prototype,`sourcemapFileName`,null),M([j],N.prototype,`preliminaryFileName`,null),M([j],N.prototype,`code`,null),M([j],N.prototype,`modules`,null),M([j],N.prototype,`imports`,null),M([j],N.prototype,`dynamicImports`,null),M([j],N.prototype,`moduleIds`,null),M([j],N.prototype,`map`,null);function Rc(e){let t={...JSON.parse(e),toString(){return JSON.stringify(t)},toUrl(){return`data:application/json;charset=utf-8;base64,${Buffer.from(t.toString(),`utf-8`).toString(`base64`)}`}};return t}var zc=class extends jc{onLog;inputPlugins;inner;constructor(e,t,n){super(),this.onLog=t,this.inputPlugins=n,this.inner=e}get shimMissingExports(){return this.inner.shimMissingExports}get input(){return this.inner.input}get cwd(){return this.inner.cwd}get platform(){return this.inner.platform}get context(){return this.inner.context}get plugins(){return this.inputPlugins}};M([j],zc.prototype,`shimMissingExports`,null),M([j],zc.prototype,`input`,null),M([j],zc.prototype,`cwd`,null),M([j],zc.prototype,`platform`,null),M([j],zc.prototype,`context`,null);var P=class extends jc{inner;outputOptions;normalizedOutputPlugins;constructor(e,t,n){super(),this.inner=e,this.outputOptions=t,this.normalizedOutputPlugins=n}get dir(){return this.inner.dir??void 0}get entryFileNames(){return this.inner.entryFilenames||this.outputOptions.entryFileNames}get chunkFileNames(){return this.inner.chunkFilenames||this.outputOptions.chunkFileNames}get assetFileNames(){return this.inner.assetFilenames||this.outputOptions.assetFileNames}get format(){return this.inner.format}get exports(){return this.inner.exports}get sourcemap(){return this.inner.sourcemap}get sourcemapFileNames(){return this.inner.sourcemapFilenames||this.outputOptions.sourcemapFileNames}get sourcemapBaseUrl(){return this.inner.sourcemapBaseUrl??void 0}get shimMissingExports(){return this.inner.shimMissingExports}get name(){return this.inner.name??void 0}get file(){return this.inner.file??void 0}get codeSplitting(){return this.inner.codeSplitting}get inlineDynamicImports(){return!this.inner.codeSplitting}get dynamicImportInCjs(){return this.inner.dynamicImportInCjs}get externalLiveBindings(){return this.inner.externalLiveBindings}get banner(){return Bc(this.outputOptions.banner)}get footer(){return Bc(this.outputOptions.footer)}get postBanner(){return Bc(this.outputOptions.postBanner)}get postFooter(){return Bc(this.outputOptions.postFooter)}get intro(){return Bc(this.outputOptions.intro)}get outro(){return Bc(this.outputOptions.outro)}get esModule(){return this.inner.esModule}get extend(){return this.inner.extend}get globals(){return this.inner.globals||this.outputOptions.globals}get paths(){return this.outputOptions.paths}get hashCharacters(){return this.inner.hashCharacters}get sourcemapDebugIds(){return this.inner.sourcemapDebugIds}get sourcemapExcludeSources(){return this.inner.sourcemapExcludeSources}get sourcemapIgnoreList(){return this.outputOptions.sourcemapIgnoreList}get sourcemapPathTransform(){return this.outputOptions.sourcemapPathTransform}get minify(){let e=this.inner.minify;return typeof e==`object`&&e&&(delete e.codegen,delete e.module,delete e.sourcemap),e}get legalComments(){return this.inner.legalComments}get comments(){let e=this.inner.comments;return{legal:e.legal??!0,annotation:e.annotation??!0,jsdoc:e.jsdoc??!0}}get polyfillRequire(){return this.inner.polyfillRequire}get plugins(){return this.normalizedOutputPlugins}get preserveModules(){return this.inner.preserveModules}get preserveModulesRoot(){return this.inner.preserveModulesRoot}get virtualDirname(){return this.inner.virtualDirname}get topLevelVar(){return this.inner.topLevelVar??!1}get minifyInternalExports(){return this.inner.minifyInternalExports??!1}};M([j],P.prototype,`dir`,null),M([j],P.prototype,`entryFileNames`,null),M([j],P.prototype,`chunkFileNames`,null),M([j],P.prototype,`assetFileNames`,null),M([j],P.prototype,`format`,null),M([j],P.prototype,`exports`,null),M([j],P.prototype,`sourcemap`,null),M([j],P.prototype,`sourcemapFileNames`,null),M([j],P.prototype,`sourcemapBaseUrl`,null),M([j],P.prototype,`shimMissingExports`,null),M([j],P.prototype,`name`,null),M([j],P.prototype,`file`,null),M([j],P.prototype,`codeSplitting`,null),M([j],P.prototype,`inlineDynamicImports`,null),M([j],P.prototype,`dynamicImportInCjs`,null),M([j],P.prototype,`externalLiveBindings`,null),M([j],P.prototype,`banner`,null),M([j],P.prototype,`footer`,null),M([j],P.prototype,`postBanner`,null),M([j],P.prototype,`postFooter`,null),M([j],P.prototype,`intro`,null),M([j],P.prototype,`outro`,null),M([j],P.prototype,`esModule`,null),M([j],P.prototype,`extend`,null),M([j],P.prototype,`globals`,null),M([j],P.prototype,`paths`,null),M([j],P.prototype,`hashCharacters`,null),M([j],P.prototype,`sourcemapDebugIds`,null),M([j],P.prototype,`sourcemapExcludeSources`,null),M([j],P.prototype,`sourcemapIgnoreList`,null),M([j],P.prototype,`sourcemapPathTransform`,null),M([j],P.prototype,`minify`,null),M([j],P.prototype,`legalComments`,null),M([j],P.prototype,`comments`,null),M([j],P.prototype,`polyfillRequire`,null),M([j],P.prototype,`plugins`,null),M([j],P.prototype,`preserveModules`,null),M([j],P.prototype,`preserveModulesRoot`,null),M([j],P.prototype,`virtualDirname`,null),M([j],P.prototype,`topLevelVar`,null),M([j],P.prototype,`minifyInternalExports`,null);function Bc(e){return typeof e==`function`?e:()=>e||``}Object.defineProperty(A.BindingMagicString.prototype,"isRolldownMagicString",{value:!0,writable:!1,configurable:!1});function Vc(e,t){if(typeof e!=`string`)throw TypeError(t)}const Hc=A.BindingMagicString.prototype.append,Uc=A.BindingMagicString.prototype.prepend,Wc=A.BindingMagicString.prototype.appendLeft,Gc=A.BindingMagicString.prototype.appendRight,Kc=A.BindingMagicString.prototype.prependLeft,qc=A.BindingMagicString.prototype.prependRight,Jc=A.BindingMagicString.prototype.overwrite,Yc=A.BindingMagicString.prototype.update;A.BindingMagicString.prototype.append=function(e){return Vc(e,`outro content must be a string`),Hc.call(this,e)},A.BindingMagicString.prototype.prepend=function(e){return Vc(e,`outro content must be a string`),Uc.call(this,e)},A.BindingMagicString.prototype.appendLeft=function(e,t){return Vc(t,`inserted content must be a string`),Wc.call(this,e,t)},A.BindingMagicString.prototype.appendRight=function(e,t){return Vc(t,`inserted content must be a string`),Gc.call(this,e,t)},A.BindingMagicString.prototype.prependLeft=function(e,t){return Vc(t,`inserted content must be a string`),Kc.call(this,e,t)},A.BindingMagicString.prototype.prependRight=function(e,t){return Vc(t,`inserted content must be a string`),qc.call(this,e,t)},A.BindingMagicString.prototype.overwrite=function(e,t,n,r){return Vc(n,`replacement content must be a string`),Jc.call(this,e,t,n,r)},A.BindingMagicString.prototype.update=function(e,t,n,r){return Vc(n,`replacement content must be a string`),Yc.call(this,e,t,n,r)};const Xc=A.BindingMagicString.prototype.replace,Zc=A.BindingMagicString.prototype.replaceAll;A.BindingMagicString.prototype.replace=function(e,t){if(typeof e==`string`)return Xc.call(this,e,t);e.global&&(e.lastIndex=0);let n=this.replaceRegex(e,t);return e.global?e.lastIndex=0:e.sticky&&(e.lastIndex=n===-1?0:n),this},A.BindingMagicString.prototype.replaceAll=function(e,t){if(typeof e==`string`)return Zc.call(this,e,t);if(!e.global)throw TypeError(`MagicString.prototype.replaceAll called with a non-global RegExp argument`);return e.lastIndex=0,this.replaceRegex(e,t),e.lastIndex=0,this},A.BindingMagicString,Le.appendFile,Le.copyFile,Le.mkdir,Le.mkdtemp,Le.readdir,Le.readFile,Le.realpath,Le.rename,Le.rmdir,Le.stat,Le.lstat,Le.unlink,Le.writeFile;const Qc=[`options`,`buildStart`,`resolveId`,`load`,`transform`,`moduleParsed`,`buildEnd`,`onLog`,`resolveDynamicImport`,`closeBundle`,`closeWatcher`,`watchChange`],$c=[`augmentChunkHash`,`outputOptions`,`renderChunk`,`renderStart`,`renderError`,`writeBundle`,`generateBundle`,`resolveFileUrl`],F=[...Qc,...$c,`footer`,`banner`,`intro`,`outro`];F[0],F[0],F[1],F[1],F[2],F[2],F[3],F[3],F[4],F[4],F[5],F[5],F[6],F[6],F[7],F[7],F[8],F[8],F[9],F[9],F[10],F[10],F[11],F[11],F[12],F[12],F[13],F[13],F[14],F[14],F[15],F[15],F[16],F[16],F[17],F[17],F[18],F[18],F[19],F[19],F[20],F[20],F[21],F[21],F[22],F[22],F[23],F[23];const el={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};/* @__NO_SIDE_EFFECTS__ */
103
- function tl(e){return e?{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}:el}/* @__NO_SIDE_EFFECTS__ */
104
- function nl(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function I(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??/* @__PURE__ */ nl(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??(e.reference,c.lang,void 0)??(l?(c.lang,void 0):null)??r.message??(c.lang,void 0);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}/* @__NO_SIDE_EFFECTS__ */
105
- function rl(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}/* @__NO_SIDE_EFFECTS__ */
106
- function il(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}/* @__NO_SIDE_EFFECTS__ */
107
- function al(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}function L(e){return e[`~standard`]={version:1,vendor:`valibot`,validate:t=>e[`~run`]({value:t},/* @__PURE__ */ tl())},e}var ol=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};/* @__NO_SIDE_EFFECTS__ */
108
- function R(e){return{kind:`transformation`,type:`args`,reference:R,async:!1,schema:e,"~run"(e,t){let n=e.value;return e.value=(...e)=>{let r=this.schema[`~run`]({value:e},t);if(r.issues)throw new ol(r.issues);return n(...r.value)},e}}}/* @__NO_SIDE_EFFECTS__ */
109
- function sl(){return{kind:`transformation`,type:`await`,reference:sl,async:!0,async"~run"(e){return e.value=await e.value,e}}}/* @__NO_SIDE_EFFECTS__ */
110
- function z(e){return{kind:`metadata`,type:`description`,reference:z,description:e}}/* @__NO_SIDE_EFFECTS__ */
111
- function cl(e){return{kind:`transformation`,type:`returns`,reference:cl,async:!1,schema:e,"~run"(e,t){let n=e.value;return e.value=(...e)=>{let r=this.schema[`~run`]({value:n(...e)},t);if(r.issues)throw new ol(r.issues);return r.value},e}}}/* @__NO_SIDE_EFFECTS__ */
112
- function ll(e){return{kind:`transformation`,type:`returns`,reference:ll,async:!1,schema:e,"~run"(e,t){let n=e.value;return e.value=async(...e)=>{let r=await this.schema[`~run`]({value:await n(...e)},t);if(r.issues)throw new ol(r.issues);return r.value},e}}}const ul={abortEarly:!0};/* @__NO_SIDE_EFFECTS__ */
113
- function dl(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}/* @__NO_SIDE_EFFECTS__ */
114
- function fl(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}/* @__NO_SIDE_EFFECTS__ */
115
- function pl(e,t){return!e[`~run`]({value:t},ul).issues}/* @__NO_SIDE_EFFECTS__ */
116
- function ml(){return L({kind:`schema`,type:`any`,reference:ml,expects:`any`,async:!1,"~run"(e){return e.typed=!0,e}})}/* @__NO_SIDE_EFFECTS__ */
117
- function B(e,t){return L({kind:`schema`,type:`array`,reference:B,expects:`Array`,async:!1,item:e,message:t,"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else I(this,`type`,e,t);return e}})}/* @__NO_SIDE_EFFECTS__ */
118
- function V(e){return L({kind:`schema`,type:`boolean`,reference:V,expects:`boolean`,async:!1,message:e,"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:I(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */
119
- function hl(e,t){return L({kind:`schema`,type:`custom`,reference:hl,expects:`unknown`,async:!1,check:e,message:t,"~run"(e,t){return this.check(e.value)?e.typed=!0:I(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */
120
- function gl(e){return L({kind:`schema`,type:`function`,reference:gl,expects:`Function`,async:!1,message:e,"~run"(e,t){return typeof e.value==`function`?e.typed=!0:I(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */
121
- function _l(e,t){return L({kind:`schema`,type:`instance`,reference:_l,expects:e.name,async:!1,class:e,message:t,"~run"(e,t){return e.value instanceof this.class?e.typed=!0:I(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */
122
- function H(e,t){return L({kind:`schema`,type:`literal`,reference:H,expects:/* @__PURE__ */ nl(e),async:!1,literal:e,message:t,"~run"(e,t){return/* @__PURE__ */ rl(e.value,this.literal)?e.typed=!0:I(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */
123
- function vl(e){return L({kind:`schema`,type:`never`,reference:vl,expects:`never`,async:!1,message:e,"~run"(e,t){return I(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */
124
- function yl(e,t){return L({kind:`schema`,type:`nullish`,reference:yl,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,"~run"(e,t){return(e.value===null||e.value===void 0)&&(this.default!==void 0&&(e.value=/* @__PURE__ */ fl(this,e,t)),e.value===null||e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}})}/* @__NO_SIDE_EFFECTS__ */
125
- function U(e){return L({kind:`schema`,type:`number`,reference:U,expects:`number`,async:!1,message:e,"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:I(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */
126
- function bl(e,t){return L({kind:`schema`,type:`object`,reference:bl,expects:`Object`,async:!1,entries:e,message:t,"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:/* @__PURE__ */ fl(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=/* @__PURE__ */ dl(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(I(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}}else I(this,`type`,e,t);return e}})}/* @__NO_SIDE_EFFECTS__ */
127
- function W(e,t){return L({kind:`schema`,type:`optional`,reference:W,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=/* @__PURE__ */ fl(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}})}/* @__NO_SIDE_EFFECTS__ */
128
- function xl(e){return L({kind:`schema`,type:`promise`,reference:xl,expects:`Promise`,async:!1,message:e,"~run"(e,t){return e.value instanceof Promise?e.typed=!0:I(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */
129
- function Sl(e,t,n){return L({kind:`schema`,type:`record`,reference:Sl,expects:`Object`,async:!1,key:e,value:t,message:n,"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in n)if(/* @__PURE__ */ il(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else I(this,`type`,e,t);return e}})}/* @__NO_SIDE_EFFECTS__ */
130
- function G(e,t){return L({kind:`schema`,type:`strict_object`,reference:G,expects:`Object`,async:!1,entries:e,message:t,"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:/* @__PURE__ */ fl(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=/* @__PURE__ */ dl(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(I(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly){for(let r in n)if(!Object.prototype.hasOwnProperty.call(this.entries,r)){I(this,`key`,e,t,{input:r,expected:`never`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]});break}}}else I(this,`type`,e,t);return e}})}/* @__NO_SIDE_EFFECTS__ */
131
- function K(e){return L({kind:`schema`,type:`string`,reference:K,expects:`string`,async:!1,message:e,"~run"(e,t){return typeof e.value==`string`?e.typed=!0:I(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */
132
- function q(e,t){return L({kind:`schema`,type:`tuple`,reference:q,expects:`Array`,async:!1,items:e,message:t,"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<this.items.length;r++){let i=n[r],a=this.items[r][`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else I(this,`type`,e,t);return e}})}/* @__NO_SIDE_EFFECTS__ */
133
- function Cl(e){return L({kind:`schema`,type:`undefined`,reference:Cl,expects:`undefined`,async:!1,message:e,"~run"(e,t){return e.value===void 0?e.typed=!0:I(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */
134
- function wl(e){let t;if(e)for(let n of e)if(t)for(let e of n.issues)t.push(e);else t=n.issues;return t}/* @__NO_SIDE_EFFECTS__ */
135
- function J(e,t){return L({kind:`schema`,type:`union`,reference:J,expects:/* @__PURE__ */ al(e.map(e=>e.expects),`|`),async:!1,options:e,message:t,"~run"(e,t){let n,r,i;for(let a of this.options){let o=a[`~run`]({value:e.value},t);if(o.typed){if(o.issues)r?r.push(o):r=[o];else{n=o;break}}else i?i.push(o):i=[o]}if(n)return n;if(r){if(r.length===1)return r[0];I(this,`type`,e,t,{issues:/* @__PURE__ */ wl(r)}),e.typed=!0}else if(i?.length===1)return i[0];else I(this,`type`,e,t,{issues:/* @__PURE__ */ wl(i)});return e}})}/* @__NO_SIDE_EFFECTS__ */
136
- function Tl(e,t){return L({kind:`schema`,type:`union`,reference:Tl,expects:/* @__PURE__ */ al(e.map(e=>e.expects),`|`),async:!0,options:e,message:t,async"~run"(e,t){let n,r,i;for(let a of this.options){let o=await a[`~run`]({value:e.value},t);if(o.typed){if(o.issues)r?r.push(o):r=[o];else{n=o;break}}else i?i.push(o):i=[o]}if(n)return n;if(r){if(r.length===1)return r[0];I(this,`type`,e,t,{issues:/* @__PURE__ */ wl(r)}),e.typed=!0}else if(i?.length===1)return i[0];else I(this,`type`,e,t,{issues:/* @__PURE__ */ wl(i)});return e}})}/* @__NO_SIDE_EFFECTS__ */
137
- function El(e){return L({kind:`schema`,type:`void`,reference:El,expects:`void`,async:!1,message:e,"~run"(e,t){return e.value===void 0?e.typed=!0:I(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */
138
- function Dl(e,t){let n={...e.entries};for(let e of t)delete n[e];return L({...e,entries:n})}/* @__NO_SIDE_EFFECTS__ */
139
- function Ol(e,t){let n={};for(let r in e.entries)n[r]=!t||t.includes(r)?/* @__PURE__ */ W(e.entries[r]):e.entries[r];return L({...e,entries:n})}/* @__NO_SIDE_EFFECTS__ */
140
- function Y(...e){return L({...e[0],pipe:e,"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}})}/* @__NO_SIDE_EFFECTS__ */
141
- function kl(...e){return L({...e[0],pipe:e,async:!0,async"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=await r[`~run`](t,n))}return t}})}function Al(...e){return ze(...e)}const jl=/* @__PURE__ */ J([/* @__PURE__ */ K(),/* @__PURE__ */ _l(RegExp)]);function X(){return/* @__PURE__ */ gl()}const Ml=/* @__PURE__ */ J([/* @__PURE__ */ H(`debug`),/* @__PURE__ */ H(`info`),/* @__PURE__ */ H(`warn`)]),Nl=/* @__PURE__ */ J([Ml,/* @__PURE__ */ H(`silent`)]),Pl=/* @__PURE__ */ J([Ml,/* @__PURE__ */ H(`error`)]),Fl=/* @__PURE__ */ ml(),Il=/* @__PURE__ */ J([Fl,/* @__PURE__ */ K()]),Ll=/* @__PURE__ */ J([/* @__PURE__ */ K(),/* @__PURE__ */ B(/* @__PURE__ */ K()),/* @__PURE__ */ Sl(/* @__PURE__ */ K(),/* @__PURE__ */ K())]),Rl=/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([/* @__PURE__ */ K(),/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ V()])),/* @__PURE__ */ cl(/* @__PURE__ */ yl(/* @__PURE__ */ V()))),zl=/* @__PURE__ */ J([jl,/* @__PURE__ */ B(jl),Rl]),Bl=/* @__PURE__ */ Sl(/* @__PURE__ */ K(),/* @__PURE__ */ J([/* @__PURE__ */ H(`asset`),/* @__PURE__ */ H(`base64`),/* @__PURE__ */ H(`binary`),/* @__PURE__ */ H(`copy`),/* @__PURE__ */ H(`css`),/* @__PURE__ */ H(`dataurl`),/* @__PURE__ */ H(`empty`),/* @__PURE__ */ H(`js`),/* @__PURE__ */ H(`json`),/* @__PURE__ */ H(`jsx`),/* @__PURE__ */ H(`text`),/* @__PURE__ */ H(`ts`),/* @__PURE__ */ H(`tsx`)])),Vl=/* @__PURE__ */ bl({assumptions:/* @__PURE__ */ W(/* @__PURE__ */ bl({ignoreFunctionLength:/* @__PURE__ */ W(/* @__PURE__ */ V()),noDocumentAll:/* @__PURE__ */ W(/* @__PURE__ */ V()),objectRestNoSymbols:/* @__PURE__ */ W(/* @__PURE__ */ V()),pureGetters:/* @__PURE__ */ W(/* @__PURE__ */ V()),setPublicClassFields:/* @__PURE__ */ W(/* @__PURE__ */ V())})),typescript:/* @__PURE__ */ W(/* @__PURE__ */ bl({jsxPragma:/* @__PURE__ */ W(/* @__PURE__ */ K()),jsxPragmaFrag:/* @__PURE__ */ W(/* @__PURE__ */ K()),onlyRemoveTypeImports:/* @__PURE__ */ W(/* @__PURE__ */ V()),allowNamespaces:/* @__PURE__ */ W(/* @__PURE__ */ V()),allowDeclareFields:/* @__PURE__ */ W(/* @__PURE__ */ V()),removeClassFieldsWithoutInitializer:/* @__PURE__ */ W(/* @__PURE__ */ V()),optimizeConstEnums:/* @__PURE__ */ W(/* @__PURE__ */ V()),optimizeEnums:/* @__PURE__ */ W(/* @__PURE__ */ V()),declaration:/* @__PURE__ */ W(/* @__PURE__ */ bl({stripInternal:/* @__PURE__ */ W(/* @__PURE__ */ V()),sourcemap:/* @__PURE__ */ W(/* @__PURE__ */ V())})),rewriteImportExtensions:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(`rewrite`),/* @__PURE__ */ H(`remove`),/* @__PURE__ */ V()]))})),helpers:/* @__PURE__ */ W(/* @__PURE__ */ bl({mode:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(`Runtime`),/* @__PURE__ */ H(`External`)]))})),decorator:/* @__PURE__ */ W(/* @__PURE__ */ bl({legacy:/* @__PURE__ */ W(/* @__PURE__ */ V()),emitDecoratorMetadata:/* @__PURE__ */ W(/* @__PURE__ */ V()),strictNullChecks:/* @__PURE__ */ W(/* @__PURE__ */ V())})),jsx:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(!1),/* @__PURE__ */ H(`preserve`),/* @__PURE__ */ H(`react`),/* @__PURE__ */ H(`react-jsx`),/* @__PURE__ */ G({runtime:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(`classic`),/* @__PURE__ */ H(`automatic`)])),/* @__PURE__ */ z(`Which runtime to use`)),development:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Development specific information`)),throwIfNamespace:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Toggles whether to throw an error when a tag name uses an XML namespace`)),pure:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Mark JSX elements and top-level React method calls as pure for tree shaking.`)),importSource:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(`Import the factory of element and fragment if mode is classic`)),pragma:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(`Jsx element transformation`)),pragmaFrag:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(`Jsx fragment transformation`)),refresh:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ ml()])),/* @__PURE__ */ z(`Enable react fast refresh`))})])),target:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ K(),/* @__PURE__ */ B(/* @__PURE__ */ K())])),/* @__PURE__ */ z(`The JavaScript target environment`)),define:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ Sl(/* @__PURE__ */ K(),/* @__PURE__ */ K())),/* @__PURE__ */ z(`Define global variables (syntax: key:value,key2:value2)`)),inject:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ Sl(/* @__PURE__ */ K(),/* @__PURE__ */ J([/* @__PURE__ */ K(),/* @__PURE__ */ q([/* @__PURE__ */ K(),/* @__PURE__ */ K()])]))),/* @__PURE__ */ z(`Inject import statements on demand`)),dropLabels:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ K())),/* @__PURE__ */ z(`Remove labeled statements with these label names`)),plugins:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ bl({styledComponents:/* @__PURE__ */ W(/* @__PURE__ */ ml()),taggedTemplateEscape:/* @__PURE__ */ W(/* @__PURE__ */ V())})),/* @__PURE__ */ z(`Third-party plugins to use`))}),Hl=/* @__PURE__ */ G({usePolling:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Use polling-based file watching instead of native OS events`)),pollInterval:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ U()),/* @__PURE__ */ z(`Poll interval in milliseconds (only used when usePolling is true)`)),compareContentsForPolling:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Compare file contents for poll-based watchers (only used when usePolling is true)`)),useDebounce:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Use debounced event delivery at the filesystem level`)),debounceDelay:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ U()),/* @__PURE__ */ z(`Debounce delay in milliseconds (only used when useDebounce is true)`)),debounceTickRate:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ U()),/* @__PURE__ */ z(`Tick rate in milliseconds for debouncer (only used when useDebounce is true)`))}),Ul=/* @__PURE__ */ G({chokidar:/* @__PURE__ */ W(/* @__PURE__ */ vl(`The "watch.chokidar" option is deprecated, please use "watch.watcher" instead of it`)),exclude:/* @__PURE__ */ W(/* @__PURE__ */ J([jl,/* @__PURE__ */ B(jl)])),include:/* @__PURE__ */ W(/* @__PURE__ */ J([jl,/* @__PURE__ */ B(jl)])),watcher:/* @__PURE__ */ W(Hl),notify:/* @__PURE__ */ W(Hl),skipWrite:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Skip the bundle.write() step`)),buildDelay:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ U()),/* @__PURE__ */ z(`Throttle watch rebuilds`)),clearScreen:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to clear the screen when a rebuild is triggered`)),onInvalidate:/* @__PURE__ */ Y(/* @__PURE__ */ W(X()),/* @__PURE__ */ z(`An optional function that will be called immediately every time a module changes that is part of the build.`))}),Wl=/* @__PURE__ */ G({circularDependency:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when detecting circular dependency`)),eval:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z("Whether to emit warnings when detecting uses of direct `eval`s")),missingGlobalName:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z("Whether to emit warnings when the `output.globals` option is missing when needed")),missingNameOptionForIifeExport:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z("Whether to emit warnings when the `output.name` option is missing when needed")),invalidAnnotation:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z("Whether to emit warnings when a `#__PURE__` / `@__PURE__` annotation has no effect due to its position")),mixedExports:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when the way to export values is ambiguous`)),unresolvedEntry:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when an entrypoint cannot be resolved`)),unresolvedImport:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when an import cannot be resolved`)),filenameConflict:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when files generated have the same name with different contents`)),moduleLevelDirective:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z("Whether to emit warnings for module-level directives other than `use strict`")),commonJsVariableInEsm:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when a CommonJS variable is used in an ES module`)),importIsUndefined:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when an imported variable is not exported`)),emptyImportMeta:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z("Whether to emit warnings when `import.meta` is not supported with the output format and is replaced with an empty object (`{}`)")),toleratedTransform:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when detecting tolerated transform`)),cannotCallNamespace:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when a namespace is called as a function`)),configurationFieldConflict:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when a config value is overridden by another config value with a higher priority`)),preferBuiltinFeature:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when a plugin that is covered by a built-in feature is used`)),couldNotCleanDirectory:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when Rolldown could not clean the output directory`)),pluginTimings:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when plugins take significant time during the build process`)),duplicateShebang:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when both the code and postBanner contain shebang`)),unsupportedTsconfigOption:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when a tsconfig option or combination of options is not supported`)),ineffectiveDynamicImport:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when a module is dynamically imported but also statically imported, making the dynamic import ineffective for code splitting`)),largeBarrelModules:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit info logs when a barrel module has a very large number of re-exports (more than 5000)`)),sourcemapBroken:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when a plugin transforms code without generating a sourcemap`)),namespaceConflict:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to emit warnings when multiple star re-exports provide the same name from different modules`))}),Gl=/* @__PURE__ */ G({compress:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ G({target:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ K(),/* @__PURE__ */ B(/* @__PURE__ */ K())])),dropConsole:/* @__PURE__ */ W(/* @__PURE__ */ V()),dropDebugger:/* @__PURE__ */ W(/* @__PURE__ */ V()),keepNames:/* @__PURE__ */ W(/* @__PURE__ */ G({function:/* @__PURE__ */ V(),class:/* @__PURE__ */ V()})),unused:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ H(`keep_assign`)])),joinVars:/* @__PURE__ */ W(/* @__PURE__ */ V()),sequences:/* @__PURE__ */ W(/* @__PURE__ */ V()),dropLabels:/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ K())),maxIterations:/* @__PURE__ */ W(/* @__PURE__ */ U()),treeshake:/* @__PURE__ */ W(/* @__PURE__ */ G({annotations:/* @__PURE__ */ W(/* @__PURE__ */ V()),manualPureFunctions:/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ K())),propertyReadSideEffects:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ H(`always`)])),propertyWriteSideEffects:/* @__PURE__ */ W(/* @__PURE__ */ V()),unknownGlobalSideEffects:/* @__PURE__ */ W(/* @__PURE__ */ V()),invalidImportSideEffects:/* @__PURE__ */ W(/* @__PURE__ */ V())}))})])),mangle:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ G({toplevel:/* @__PURE__ */ W(/* @__PURE__ */ V()),keepNames:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ G({function:/* @__PURE__ */ V(),class:/* @__PURE__ */ V()})])),reserved:/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ K())),debug:/* @__PURE__ */ W(/* @__PURE__ */ V())})])),mangleProps:/* @__PURE__ */ W(/* @__PURE__ */ G({include:/* @__PURE__ */ _l(RegExp),exclude:/* @__PURE__ */ W(/* @__PURE__ */ _l(RegExp)),reserved:/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ K())),quoted:/* @__PURE__ */ W(/* @__PURE__ */ V()),debug:/* @__PURE__ */ W(/* @__PURE__ */ V()),cache:/* @__PURE__ */ W(/* @__PURE__ */ Sl(/* @__PURE__ */ K(),/* @__PURE__ */ J([/* @__PURE__ */ K(),/* @__PURE__ */ H(!1)])))})),codegen:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ G({removeWhitespace:/* @__PURE__ */ W(/* @__PURE__ */ V()),asciiOnly:/* @__PURE__ */ W(/* @__PURE__ */ V()),legalComments:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(`none`),/* @__PURE__ */ H(`inline`),/* @__PURE__ */ H(`eof`),/* @__PURE__ */ H(`external`),/* @__PURE__ */ G({linked:/* @__PURE__ */ K()})]))})]))}),Kl=/* @__PURE__ */ G({alias:/* @__PURE__ */ W(/* @__PURE__ */ Sl(/* @__PURE__ */ K(),/* @__PURE__ */ J([/* @__PURE__ */ H(!1),/* @__PURE__ */ K(),/* @__PURE__ */ B(/* @__PURE__ */ K())]))),aliasFields:/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ B(/* @__PURE__ */ K()))),conditionNames:/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ K())),extensionAlias:/* @__PURE__ */ W(/* @__PURE__ */ Sl(/* @__PURE__ */ K(),/* @__PURE__ */ B(/* @__PURE__ */ K()))),exportsFields:/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ B(/* @__PURE__ */ K()))),extensions:/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ K())),mainFields:/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ K())),mainFiles:/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ K())),modules:/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ K())),symlinks:/* @__PURE__ */ W(/* @__PURE__ */ V()),tsconfigFilename:/* @__PURE__ */ W(/* @__PURE__ */ K())}),ql=/* @__PURE__ */ G({moduleSideEffects:/* @__PURE__ */ W(/* @__PURE__ */ ml()),annotations:/* @__PURE__ */ W(/* @__PURE__ */ V()),manualPureFunctions:/* @__PURE__ */ W(/* @__PURE__ */ hl(e=>/* @__PURE__ */ pl(/* @__PURE__ */ B(/* @__PURE__ */ K()),e),`string array`)),unknownGlobalSideEffects:/* @__PURE__ */ W(/* @__PURE__ */ V()),invalidImportSideEffects:/* @__PURE__ */ W(/* @__PURE__ */ V()),commonjs:/* @__PURE__ */ W(/* @__PURE__ */ V()),propertyReadSideEffects:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(!1),/* @__PURE__ */ H(`always`)])),propertyWriteSideEffects:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(!1),/* @__PURE__ */ H(`always`)]))}),Jl=/* @__PURE__ */ G({inlineConst:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ G({mode:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(`all`),/* @__PURE__ */ H(`smart`)])),pass:/* @__PURE__ */ W(/* @__PURE__ */ U())})])),/* @__PURE__ */ z(`Enable crossmodule constant inlining`)),pifeForModuleWrappers:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Use PIFE pattern for module wrappers`))}),Yl=/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([Pl,Il]))),Xl=/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([Ml,Fl,Yl]))),Zl=/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([Fl,/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([/* @__PURE__ */ J([Il,/* @__PURE__ */ Y(X(),/* @__PURE__ */ cl(Il))])])))]))),Ql=/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ G({port:/* @__PURE__ */ W(/* @__PURE__ */ U()),host:/* @__PURE__ */ W(/* @__PURE__ */ K()),implement:/* @__PURE__ */ W(/* @__PURE__ */ K()),skipCommonRuntimeInjection:/* @__PURE__ */ W(/* @__PURE__ */ V()),lazy:/* @__PURE__ */ W(/* @__PURE__ */ V())})]),$l=/* @__PURE__ */ G({input:/* @__PURE__ */ W(Ll),plugins:/* @__PURE__ */ W(/* @__PURE__ */ hl(()=>!0)),external:/* @__PURE__ */ W(zl),makeAbsoluteExternalsRelative:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ H(`ifRelativeSource`)])),resolve:/* @__PURE__ */ W(Kl),cwd:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(`Current working directory`)),platform:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(`browser`),/* @__PURE__ */ H(`neutral`),/* @__PURE__ */ H(`node`)])),/* @__PURE__ */ z(`Platform for which the code should be generated (node, ${Al(`underline`,`browser`)}, neutral)`)),shimMissingExports:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Create shim variables for missing exports`)),treeshake:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),ql])),optimization:/* @__PURE__ */ W(Jl),logLevel:/* @__PURE__ */ Y(/* @__PURE__ */ W(Nl),/* @__PURE__ */ z(`Log level (${Al(`dim`,`silent`)}, ${Al([`underline`,`gray`],`info`)}, debug, ${Al(`yellow`,`warn`)})`)),onLog:/* @__PURE__ */ W(Xl),onwarn:/* @__PURE__ */ W(Zl),moduleTypes:/* @__PURE__ */ Y(/* @__PURE__ */ W(Bl),/* @__PURE__ */ z(`Module types for customized extensions`)),experimental:/* @__PURE__ */ W(/* @__PURE__ */ G({viteMode:/* @__PURE__ */ W(/* @__PURE__ */ V()),resolveNewUrlToAsset:/* @__PURE__ */ W(/* @__PURE__ */ V()),devMode:/* @__PURE__ */ W(Ql),chunkModulesOrder:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(`module-id`),/* @__PURE__ */ H(`exec-order`)])),attachDebugInfo:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(`none`),/* @__PURE__ */ H(`simple`),/* @__PURE__ */ H(`full`)])),chunkImportMap:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ bl({baseUrl:/* @__PURE__ */ W(/* @__PURE__ */ K()),fileName:/* @__PURE__ */ W(/* @__PURE__ */ K())})])),onDemandWrapping:/* @__PURE__ */ W(/* @__PURE__ */ V()),incrementalBuild:/* @__PURE__ */ W(/* @__PURE__ */ V()),nativeMagicString:/* @__PURE__ */ W(/* @__PURE__ */ V()),chunkOptimization:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ G({mergeCommonChunks:/* @__PURE__ */ W(/* @__PURE__ */ V()),avoidRedundantChunkLoads:/* @__PURE__ */ W(/* @__PURE__ */ V())})])),lazyBarrel:/* @__PURE__ */ W(/* @__PURE__ */ V())})),transform:/* @__PURE__ */ W(Vl),watch:/* @__PURE__ */ W(/* @__PURE__ */ J([Ul,/* @__PURE__ */ H(!1)])),checks:/* @__PURE__ */ W(Wl),devtools:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ bl({sessionId:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(`Used to name the build.`))})),/* @__PURE__ */ z(`Enable debug mode. Emit debug information to disk. This might slow down the build process significantly.`)),preserveEntrySignatures:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(`strict`),/* @__PURE__ */ H(`allow-extension`),/* @__PURE__ */ H(`exports-only`),/* @__PURE__ */ H(!1)]))),context:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z("The value of `this` at the top level of each module.")),tsconfig:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ K()])),/* @__PURE__ */ z(`Path to the tsconfig.json file.`))}),eu=/* @__PURE__ */ G({input:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ K())),/* @__PURE__ */ z(`Entry file`)),external:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ K())),/* @__PURE__ */ z("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),treeshake:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`enable treeshaking`)),makeAbsoluteExternalsRelative:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Prevent normalization of external imports`)),preserveEntrySignatures:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ H(!1)),/* @__PURE__ */ z(`Avoid facade chunks for entry points`)),context:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z("The entity top-level `this` represents."))}),tu=/* @__PURE__ */ Dl(/* @__PURE__ */ G({...$l.entries,...eu.entries}),[`plugins`,`onwarn`,`onLog`,`resolve`,`experimental`,`watch`]),nu=/* @__PURE__ */ J([/* @__PURE__ */ H(`es`),/* @__PURE__ */ H(`cjs`),/* @__PURE__ */ H(`esm`),/* @__PURE__ */ H(`module`),/* @__PURE__ */ H(`commonjs`),/* @__PURE__ */ H(`iife`),/* @__PURE__ */ H(`umd`)]),ru=/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([/* @__PURE__ */ hl(()=>!0)])),/* @__PURE__ */ ll(/* @__PURE__ */ Tl([/* @__PURE__ */ K(),/* @__PURE__ */ kl(/* @__PURE__ */ xl(),/* @__PURE__ */ sl(),/* @__PURE__ */ K())]))),iu=/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([/* @__PURE__ */ hl(()=>!0)])),/* @__PURE__ */ cl(/* @__PURE__ */ K())),au=/* @__PURE__ */ J([/* @__PURE__ */ K(),iu]),ou=/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([/* @__PURE__ */ hl(()=>!0)])),/* @__PURE__ */ cl(/* @__PURE__ */ K())),su=/* @__PURE__ */ J([/* @__PURE__ */ K(),ou]),cu=/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([/* @__PURE__ */ K()])),/* @__PURE__ */ cl(/* @__PURE__ */ K())),lu=/* @__PURE__ */ J([/* @__PURE__ */ V(),cu]),uu=/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([/* @__PURE__ */ K()])),/* @__PURE__ */ cl(/* @__PURE__ */ K())),du=/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([/* @__PURE__ */ K()])),/* @__PURE__ */ cl(/* @__PURE__ */ K())),fu=/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([/* @__PURE__ */ K(),/* @__PURE__ */ bl({})])),/* @__PURE__ */ cl(/* @__PURE__ */ yl(/* @__PURE__ */ K()))),pu=/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([/* @__PURE__ */ K(),/* @__PURE__ */ bl({})])),/* @__PURE__ */ cl(/* @__PURE__ */ yl(/* @__PURE__ */ K()))),mu=/* @__PURE__ */ Y(X(),/* @__PURE__ */ R(/* @__PURE__ */ q([/* @__PURE__ */ K()])),/* @__PURE__ */ cl(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ El(),/* @__PURE__ */ Cl()]))),hu=/* @__PURE__ */ G({includeDependenciesRecursively:/* @__PURE__ */ W(/* @__PURE__ */ V()),minSize:/* @__PURE__ */ W(/* @__PURE__ */ U()),maxSize:/* @__PURE__ */ W(/* @__PURE__ */ U()),minModuleSize:/* @__PURE__ */ W(/* @__PURE__ */ U()),maxModuleSize:/* @__PURE__ */ W(/* @__PURE__ */ U()),minShareCount:/* @__PURE__ */ W(/* @__PURE__ */ U()),groups:/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ G({name:/* @__PURE__ */ J([/* @__PURE__ */ K(),pu]),test:/* @__PURE__ */ W(/* @__PURE__ */ J([jl,mu])),priority:/* @__PURE__ */ W(/* @__PURE__ */ U()),minSize:/* @__PURE__ */ W(/* @__PURE__ */ U()),minShareCount:/* @__PURE__ */ W(/* @__PURE__ */ U()),maxSize:/* @__PURE__ */ W(/* @__PURE__ */ U()),minModuleSize:/* @__PURE__ */ W(/* @__PURE__ */ U()),maxModuleSize:/* @__PURE__ */ W(/* @__PURE__ */ U()),entriesAware:/* @__PURE__ */ W(/* @__PURE__ */ V()),entriesAwareMergeThreshold:/* @__PURE__ */ W(/* @__PURE__ */ U()),includeDependenciesRecursively:/* @__PURE__ */ W(/* @__PURE__ */ V()),tags:/* @__PURE__ */ W(/* @__PURE__ */ B(/* @__PURE__ */ K()))})))}),gu=/* @__PURE__ */ G({symbols:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to use Symbol.toStringTag for namespace objects`)),preset:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(`es5`),/* @__PURE__ */ H(`es2015`)])),profilerNames:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Whether to add readable names to internal variables for profiling purposes`))}),_u=/* @__PURE__ */ G({dir:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z("Output directory, defaults to `dist` if `file` is not set")),file:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(`Single output file`)),exports:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(`auto`),/* @__PURE__ */ H(`named`),/* @__PURE__ */ H(`default`),/* @__PURE__ */ H(`none`)])),/* @__PURE__ */ z(`Specify a export mode (${Al(`underline`,`auto`)}, named, default, none)`)),hashCharacters:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(`base64`),/* @__PURE__ */ H(`base36`),/* @__PURE__ */ H(`hex`)])),/* @__PURE__ */ z(`Use the specified character set for file hashes`)),format:/* @__PURE__ */ Y(/* @__PURE__ */ W(nu),/* @__PURE__ */ z(`Output format of the generated bundle (supports ${Al(`underline`,`esm`)}, cjs, and iife)`)),sourcemap:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ H(`inline`),/* @__PURE__ */ H(`hidden`)])),/* @__PURE__ */ z("Generate sourcemap (`-s inline` for inline, or `-s` for `.map` file)")),sourcemapBaseUrl:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(`Base URL used to prefix sourcemap paths`)),sourcemapFileNames:/* @__PURE__ */ Y(/* @__PURE__ */ W(au),/* @__PURE__ */ z(`Name pattern for emitted sourcemaps`)),sourcemapDebugIds:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Inject sourcemap debug IDs`)),sourcemapExcludeSources:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Exclude source content from sourcemaps`)),sourcemapIgnoreList:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ hl(()=>!0),jl])),sourcemapPathTransform:/* @__PURE__ */ W(/* @__PURE__ */ hl(()=>!0)),banner:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ K(),ru])),footer:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ K(),ru])),postBanner:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ K(),ru])),postFooter:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ K(),ru])),intro:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ K(),ru])),outro:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ K(),ru])),extend:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Extend global variable defined by name in IIFE / UMD formats`)),esModule:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ H(`if-default-prop`)])),assetFileNames:/* @__PURE__ */ W(su),entryFileNames:/* @__PURE__ */ W(au),chunkFileNames:/* @__PURE__ */ W(au),sanitizeFileName:/* @__PURE__ */ W(lu),minify:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ H(`dce-only`),Gl])),/* @__PURE__ */ z(`Minify the bundled file`)),name:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(`Name for UMD / IIFE format outputs`)),globals:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ Sl(/* @__PURE__ */ K(),/* @__PURE__ */ K()),uu])),/* @__PURE__ */ z("Global variable of UMD / IIFE dependencies (syntax: `key:value`)")),paths:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ Sl(/* @__PURE__ */ K(),/* @__PURE__ */ K()),du])),/* @__PURE__ */ z(`Maps external module IDs to paths`)),generatedCode:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ Ol(gu)),/* @__PURE__ */ z(`Generated code options`)),externalLiveBindings:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`external live bindings`)),inlineDynamicImports:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Inline dynamic imports`)),dynamicImportInCjs:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Dynamic import in CJS output`)),manualChunks:/* @__PURE__ */ W(fu),codeSplitting:/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),hu])),advancedChunks:/* @__PURE__ */ W(hu),legalComments:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ H(`none`),/* @__PURE__ */ H(`inline`)])),/* @__PURE__ */ z(`Control legal comments in the output`)),comments:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ G({legal:/* @__PURE__ */ W(/* @__PURE__ */ V()),annotation:/* @__PURE__ */ W(/* @__PURE__ */ V()),jsdoc:/* @__PURE__ */ W(/* @__PURE__ */ V())})])),/* @__PURE__ */ z(`Control comments in the output`)),plugins:/* @__PURE__ */ W(/* @__PURE__ */ hl(()=>!0)),polyfillRequire:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Disable require polyfill injection`)),hoistTransitiveImports:/* @__PURE__ */ W(/* @__PURE__ */ H(!1)),preserveModules:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Preserve module structure`)),preserveModulesRoot:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(`Put preserved modules under this path at root level`)),virtualDirname:/* @__PURE__ */ W(/* @__PURE__ */ K()),minifyInternalExports:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Minify internal exports`)),topLevelVar:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z("Rewrite top-level declarations to use `var`.")),cleanDir:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Clean output directory before emitting output`)),keepNames:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Keep function and class names after bundling`)),strictExecutionOrder:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Preserve source module execution order across generated chunks.`)),strict:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ H(`auto`)])),/* @__PURE__ */ z('Whether to always output `"use strict"` directive in non-ES module outputs.'))}),vu=(e,t)=>`Code to insert the ${Al(`bold`,e)} of the bundled file (${Al(`bold`,t)} the wrapper function)`,yu=/* @__PURE__ */ G({assetFileNames:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(`Name pattern for asset files`)),entryFileNames:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(`Name pattern for emitted entry chunks`)),chunkFileNames:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(`Name pattern for emitted secondary chunks`)),sanitizeFileName:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Sanitize file name`)),banner:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(vu(`top`,`outside`))),footer:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(vu(`bottom`,`outside`))),postBanner:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z("A string to prepend to the top of each chunk. Applied after the `renderChunk` hook and minification")),postFooter:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z("A string to append to the bottom of each chunk. Applied after the `renderChunk` hook and minification")),intro:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(vu(`top`,`inside`))),outro:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ K()),/* @__PURE__ */ z(vu(`bottom`,`inside`))),esModule:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)")),globals:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ Sl(/* @__PURE__ */ K(),/* @__PURE__ */ K())),/* @__PURE__ */ z("Global variable of UMD / IIFE dependencies (syntax: `key:value`)")),codeSplitting:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ J([/* @__PURE__ */ V(),/* @__PURE__ */ G({minSize:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ U()),/* @__PURE__ */ z(`Minimum size of the chunk`)),minShareCount:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ U()),/* @__PURE__ */ z(`Minimum share count of the chunk`))})])),/* @__PURE__ */ z("Code splitting options. Enabled by default; use `--no-codeSplitting` to disable, or `--codeSplitting.minSize` / `--codeSplitting.minShareCount` to configure")),advancedChunks:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ G({minSize:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ U()),/* @__PURE__ */ z(`Minimum size of the chunk`)),minShareCount:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ U()),/* @__PURE__ */ z(`Minimum share count of the chunk`))})),/* @__PURE__ */ z(`Deprecated: use codeSplitting instead`)),minify:/* @__PURE__ */ Y(/* @__PURE__ */ W(/* @__PURE__ */ V()),/* @__PURE__ */ z(`Minify the bundled file`))}),bu=/* @__PURE__ */ Dl(/* @__PURE__ */ G({..._u.entries,...yu.entries}),[`sourcemapIgnoreList`,`sourcemapPathTransform`,`plugins`,`hoistTransitiveImports`]);({...tu.entries,...bu.entries});const Z={silent:-1/0,fatal:0,error:0,warn:1,log:2,info:3,success:3,fail:3,ready:3,start:3,box:3,debug:4,trace:5,verbose:1/0},xu={silent:{level:-1},fatal:{level:Z.fatal},error:{level:Z.error},warn:{level:Z.warn},log:{level:Z.log},info:{level:Z.info},success:{level:Z.success},fail:{level:Z.fail},ready:{level:Z.info},start:{level:Z.info},box:{level:Z.info},debug:{level:Z.debug},trace:{level:Z.trace},verbose:{level:Z.verbose}};function Su(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function Cu(e,t,n=`.`,r){if(!Su(t))return Cu(e,{},n,r);let i=Object.assign({},t);for(let t in e){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:Su(a)&&Su(i[t])?Cu(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function wu(e){return(...t)=>t.reduce((t,n)=>Cu(t,n,``,e),{})}const Tu=wu();function Eu(e){return Object.prototype.toString.call(e)===`[object Object]`}function Du(e){return!(!Eu(e)||!e.message&&!e.args||e.stack)}let Ou=!1;const ku=[];var Q=class e{options;_lastLog;_mockFn;constructor(e={}){let t=e.types||xu;this.options=Tu({...e,defaults:{...e.defaults},level:Au(e.level,t),reporters:[...e.reporters||[]]},{types:xu,throttle:1e3,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}});for(let e in t){let n={type:e,...this.options.defaults,...t[e]};this[e]=this._wrapLogFn(n),this[e].raw=this._wrapLogFn(n,!0)}this.options.mockFn&&this.mockTypes(),this._lastLog={}}get level(){return this.options.level}set level(e){this.options.level=Au(e,this.options.types,this.options.level)}prompt(e,t){if(!this.options.prompt)throw Error(`prompt is not supported!`);return this.options.prompt(e,t)}create(t){let n=new e({...this.options,...t});return this._mockFn&&n.mockTypes(this._mockFn),n}withDefaults(e){return this.create({...this.options,defaults:{...this.options.defaults,...e}})}withTag(e){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+`:`+e:e})}addReporter(e){return this.options.reporters.push(e),this}removeReporter(e){if(e){let t=this.options.reporters.indexOf(e);if(t!==-1)return this.options.reporters.splice(t,1)}else this.options.reporters.splice(0);return this}setReporters(e){return this.options.reporters=Array.isArray(e)?e:[e],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(let e in this.options.types)console[`__`+e]||(console[`__`+e]=console[e]),console[e]=this[e].raw}restoreConsole(){for(let e in this.options.types)console[`__`+e]&&(console[e]=console[`__`+e],delete console[`__`+e])}wrapStd(){this._wrapStream(this.options.stdout,`log`),this._wrapStream(this.options.stderr,`log`)}_wrapStream(e,t){e&&(e.__write||=e.write,e.write=e=>{this[t].raw(String(e).trim())})}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(e){e&&e.__write&&(e.write=e.__write,delete e.__write)}pauseLogs(){Ou=!0}resumeLogs(){Ou=!1;let e=ku.splice(0);for(let t of e)t[0]._logFn(t[1],t[2])}mockTypes(e){let t=e||this.options.mockFn;if(this._mockFn=t,typeof t==`function`)for(let e in this.options.types)this[e]=t(e,this.options.types[e])||this[e],this[e].raw=this[e]}_wrapLogFn(e,t){return(...n)=>{if(Ou){ku.push([this,e,n,t]);return}return this._logFn(e,n,t)}}_logFn(e,t,n){if((e.level||0)>this.level)return!1;let r={date:/* @__PURE__ */ new Date,args:[],...e,level:Au(e.level,this.options.types)};!n&&t.length===1&&Du(t[0])?Object.assign(r,t[0]):r.args=[...t],r.message&&(r.args.unshift(r.message),delete r.message),r.additional&&(Array.isArray(r.additional)||(r.additional=r.additional.split(`
142
- `)),r.args.push(`
143
- `+r.additional.join(`
144
- `)),delete r.additional),r.type=typeof r.type==`string`?r.type.toLowerCase():`log`,r.tag=typeof r.tag==`string`?r.tag:``;let i=(e=!1)=>{let t=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&t>0){let e=[...this._lastLog.object.args];t>1&&e.push(`(repeated ${t} times)`),this._log({...this._lastLog.object,args:e}),this._lastLog.count=1}e&&(this._lastLog.object=r,this._log(r))};clearTimeout(this._lastLog.timeout);let a=this._lastLog.time&&r.date?r.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=r.date,a<this.options.throttle)try{let e=JSON.stringify([r.type,r.tag,r.args]),t=this._lastLog.serialized===e;if(this._lastLog.serialized=e,t&&(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin)){this._lastLog.timeout=setTimeout(i,this.options.throttle);return}}catch{}i(!0)}_log(e){for(let t of this.options.reporters)t.log(e,{options:this.options})}};function Au(e,t={},n=3){return e===void 0?n:typeof e==`number`?e:t[e]&&t[e].level!==void 0?t[e].level:n}Q.prototype.add=Q.prototype.addReporter,Q.prototype.remove=Q.prototype.removeReporter,Q.prototype.clear=Q.prototype.removeReporter,Q.prototype.withScope=Q.prototype.withTag,Q.prototype.mock=Q.prototype.mockTypes,Q.prototype.pause=Q.prototype.pauseLogs,Q.prototype.resume=Q.prototype.resumeLogs;function ju(e={}){return new Q(e)}function Mu(e,t){let n=process.cwd()+Ae;return e.split(`
145
- `).splice(t.split(`
146
- `).length).map(e=>e.trim().replace(`file://`,``).replace(n,``))}function Nu(e,t){return(t.__write||t.write).call(t,e)}const Pu=e=>e?`[${e}]`:``;var Fu=class{formatStack(e,t,n){let r=` `.repeat((n?.errorLevel||0)+1);return r+Mu(e,t).join(`
147
- ${r}`)}formatError(e,t){let n=e.message??Re(t,e),r=e.stack?this.formatStack(e.stack,n,t):``,i=t?.errorLevel||0,a=i>0?`${` `.repeat(i)}[cause]: `:``,o=e.cause?`
148
-
149
- `+this.formatError(e.cause,{...t,errorLevel:i+1}):``;return a+n+`
150
- `+r+o}formatArgs(e,t){let n=e.map(e=>e&&typeof e.stack==`string`?this.formatError(e,t):e);return Re(t,...n)}formatDate(e,t){return t.date?e.toLocaleTimeString():``}filterAndJoin(e){return e.filter(Boolean).join(` `)}formatLogObj(e,t){let n=this.formatArgs(e.args,t);return e.type===`box`?`
151
- `+[Pu(e.tag),e.title&&e.title,...n.split(`
152
- `)].filter(Boolean).map(e=>` > `+e).join(`
153
- `)+`
154
- `:this.filterAndJoin([Pu(e.type),Pu(e.tag),n])}log(e,t){return Nu(this.formatLogObj(e,{columns:t.options.stdout.columns||0,...t.options.formatOptions})+`
155
- `,e.level<2?t.options.stderr||process.stderr:t.options.stdout||process.stdout)}};const{env:Iu={},argv:Lu=[],platform:Ru=``}=typeof process>`u`?{}:process,zu=`NO_COLOR`in Iu||Lu.includes(`--no-color`),Bu=`FORCE_COLOR`in Iu||Lu.includes(`--color`),Vu=Ru===`win32`,Hu=Iu.TERM===`dumb`,Uu=Be&&Be.isatty&&Be.isatty(1)&&Iu.TERM&&!Hu,Wu=`CI`in Iu&&(`GITHUB_ACTIONS`in Iu||`GITLAB_CI`in Iu||`CIRCLECI`in Iu),Gu=!zu&&(Bu||Vu&&!Hu||Uu||Wu);function Ku(e,t,n,r,i=t.slice(0,Math.max(0,e))+r,a=t.slice(Math.max(0,e+n.length)),o=a.indexOf(n)){return i+(o<0?a:Ku(o,a,n,r))}function qu(e,t,n,r,i){return e<0?n+t+r:n+Ku(e,t,r,i)+r}function Ju(e,t,n=e,r=e.length+1){return i=>i||i!==``&&i!==void 0?qu((``+i).indexOf(t,r),i,e,t,n):``}function $(e,t,n){return Ju(`\x1B[${e}m`,`\x1B[${t}m`,n)}const Yu={reset:$(0,0),bold:$(1,22,`\x1B[22m\x1B[1m`),dim:$(2,22,`\x1B[22m\x1B[2m`),italic:$(3,23),underline:$(4,24),inverse:$(7,27),hidden:$(8,28),strikethrough:$(9,29),black:$(30,39),red:$(31,39),green:$(32,39),yellow:$(33,39),blue:$(34,39),magenta:$(35,39),cyan:$(36,39),white:$(37,39),gray:$(90,39),bgBlack:$(40,49),bgRed:$(41,49),bgGreen:$(42,49),bgYellow:$(43,49),bgBlue:$(44,49),bgMagenta:$(45,49),bgCyan:$(46,49),bgWhite:$(47,49),blackBright:$(90,39),redBright:$(91,39),greenBright:$(92,39),yellowBright:$(93,39),blueBright:$(94,39),magentaBright:$(95,39),cyanBright:$(96,39),whiteBright:$(97,39),bgBlackBright:$(100,49),bgRedBright:$(101,49),bgGreenBright:$(102,49),bgYellowBright:$(103,49),bgBlueBright:$(104,49),bgMagentaBright:$(105,49),bgCyanBright:$(106,49),bgWhiteBright:$(107,49)};function Xu(e=Gu){return e?Yu:Object.fromEntries(Object.keys(Yu).map(e=>[e,String]))}const Zu=Xu();function Qu(e,t=`reset`){return Zu[e]||Zu[t]}const $u=[String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);function ed(e){return e.replace(new RegExp($u,`g`),``)}const td={solid:{tl:`┌`,tr:`┐`,bl:`└`,br:`┘`,h:`─`,v:`│`},double:{tl:`╔`,tr:`╗`,bl:`╚`,br:`╝`,h:`═`,v:`║`},doubleSingle:{tl:`╓`,tr:`╖`,bl:`╙`,br:`╜`,h:`─`,v:`║`},doubleSingleRounded:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`,h:`─`,v:`║`},singleThick:{tl:`┏`,tr:`┓`,bl:`┗`,br:`┛`,h:`━`,v:`┃`},singleDouble:{tl:`╒`,tr:`╕`,bl:`╘`,br:`╛`,h:`═`,v:`│`},singleDoubleRounded:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`,h:`═`,v:`│`},rounded:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`,h:`─`,v:`│`}},nd={borderColor:`white`,borderStyle:`rounded`,valign:`center`,padding:2,marginLeft:1,marginTop:1,marginBottom:1};function rd(e,t={}){let n={...t,style:{...nd,...t.style}},r=e.split(`
156
- `),i=[],a=Qu(n.style.borderColor),o={...typeof n.style.borderStyle==`string`?td[n.style.borderStyle]||td.solid:n.style.borderStyle};if(a)for(let e in o)o[e]=a(o[e]);let s=n.style.padding%2==0?n.style.padding:n.style.padding+1,c=r.length+s,l=Math.max(...r.map(e=>ed(e).length),n.title?ed(n.title).length:0)+s,u=l+s,d=n.style.marginLeft>0?` `.repeat(n.style.marginLeft):``;if(n.style.marginTop>0&&i.push(``.repeat(n.style.marginTop)),n.title){let e=a?a(n.title):n.title,t=o.h.repeat(Math.floor((l-ed(n.title).length)/2)),r=o.h.repeat(l-ed(n.title).length-ed(t).length+s);i.push(`${d}${o.tl}${t}${e}${r}${o.tr}`)}else i.push(`${d}${o.tl}${o.h.repeat(u)}${o.tr}`);let f=n.style.valign===`center`?Math.floor((c-r.length)/2):n.style.valign===`top`?c-r.length-s:c-r.length;for(let e=0;e<c;e++)if(e<f||e>=f+r.length)i.push(`${d}${o.v}${` `.repeat(u)}${o.v}`);else{let t=r[e-f],n=` `.repeat(s),a=` `.repeat(l-ed(t).length);i.push(`${d}${o.v}${n}${t}${a}${o.v}`)}return i.push(`${d}${o.bl}${o.h.repeat(u)}${o.br}`),n.style.marginBottom>0&&i.push(``.repeat(n.style.marginBottom)),i.join(`
157
- `)}const id=Object.create(null),ad=e=>globalThis.process?.env||import.meta.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?id:globalThis),od=new Proxy(id,{get(e,t){return ad()[t]??id[t]},has(e,t){return t in ad()||t in id},set(e,t,n){let r=ad(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=ad(!0);return delete n[t],!0},ownKeys(){let e=ad(!0);return Object.keys(e)}}),sd=typeof process<`u`&&process.env&&process.env.NODE_ENV||``,cd=[[`APPVEYOR`],[`AWS_AMPLIFY`,`AWS_APP_ID`,{ci:!0}],[`AZURE_PIPELINES`,`SYSTEM_TEAMFOUNDATIONCOLLECTIONURI`],[`AZURE_STATIC`,`INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN`],[`APPCIRCLE`,`AC_APPCIRCLE`],[`BAMBOO`,`bamboo_planKey`],[`BITBUCKET`,`BITBUCKET_COMMIT`],[`BITRISE`,`BITRISE_IO`],[`BUDDY`,`BUDDY_WORKSPACE_ID`],[`BUILDKITE`],[`CIRCLE`,`CIRCLECI`],[`CIRRUS`,`CIRRUS_CI`],[`CLOUDFLARE_PAGES`,`CF_PAGES`,{ci:!0}],[`CODEBUILD`,`CODEBUILD_BUILD_ARN`],[`CODEFRESH`,`CF_BUILD_ID`],[`DRONE`],[`DRONE`,`DRONE_BUILD_EVENT`],[`DSARI`],[`GITHUB_ACTIONS`],[`GITLAB`,`GITLAB_CI`],[`GITLAB`,`CI_MERGE_REQUEST_ID`],[`GOCD`,`GO_PIPELINE_LABEL`],[`LAYERCI`],[`HUDSON`,`HUDSON_URL`],[`JENKINS`,`JENKINS_URL`],[`MAGNUM`],[`NETLIFY`],[`NETLIFY`,`NETLIFY_LOCAL`,{ci:!1}],[`NEVERCODE`],[`RENDER`],[`SAIL`,`SAILCI`],[`SEMAPHORE`],[`SCREWDRIVER`],[`SHIPPABLE`],[`SOLANO`,`TDDIUM`],[`STRIDER`],[`TEAMCITY`,`TEAMCITY_VERSION`],[`TRAVIS`],[`VERCEL`,`NOW_BUILDER`],[`VERCEL`,`VERCEL`,{ci:!1}],[`VERCEL`,`VERCEL_ENV`,{ci:!1}],[`APPCENTER`,`APPCENTER_BUILD_ID`],[`CODESANDBOX`,`CODESANDBOX_SSE`,{ci:!1}],[`CODESANDBOX`,`CODESANDBOX_HOST`,{ci:!1}],[`STACKBLITZ`],[`STORMKIT`],[`CLEAVR`],[`ZEABUR`],[`CODESPHERE`,`CODESPHERE_APP_ID`,{ci:!0}],[`RAILWAY`,`RAILWAY_PROJECT_ID`],[`RAILWAY`,`RAILWAY_SERVICE_ID`],[`DENO-DEPLOY`,`DENO_DEPLOYMENT_ID`],[`FIREBASE_APP_HOSTING`,`FIREBASE_APP_HOSTING`,{ci:!0}]];function ld(){if(globalThis.process?.env)for(let e of cd){let t=e[1]||e[0];if(globalThis.process?.env[t])return{name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL===`/bin/jsh`&&globalThis.process?.versions?.webcontainer?{name:`stackblitz`,ci:!1}:{name:``,ci:!1}}const ud=ld();ud.name;function dd(e){return e?e!==`false`:!1}const fd=globalThis.process?.platform||``,pd=dd(od.CI)||ud.ci!==!1,md=dd(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY),hd=dd(od.DEBUG),gd=sd===`test`||dd(od.TEST);od.MINIMAL;const _d=/^win/i.test(fd);!dd(od.NO_COLOR)&&(dd(od.FORCE_COLOR)||(md||_d)&&od.TERM);const vd=(globalThis.process?.versions?.node||``).replace(/^v/,``)||null;Number(vd?.split(`.`)[0]);const yd=globalThis.process||Object.create(null),bd={versions:{}};new Proxy(yd,{get(e,t){if(t===`env`)return od;if(t in e)return e[t];if(t in bd)return bd[t]}});const xd=globalThis.process?.release?.name===`node`,Sd=!!globalThis.Bun||!!globalThis.process?.versions?.bun,Cd=!!globalThis.Deno,wd=!!globalThis.fastly,Td=!!globalThis.Netlify,Ed=!!globalThis.EdgeRuntime,Dd=globalThis.navigator?.userAgent===`Cloudflare-Workers`,Od=[[Td,`netlify`],[Ed,`edge-light`],[Dd,`workerd`],[wd,`fastly`],[Cd,`deno`],[Sd,`bun`],[xd,`node`]];function kd(){let e=Od.find(e=>e[0]);if(e)return{name:e[1]}}kd()?.name;function Ad({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}const jd=Ad();function Md(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(jd,``)}function Nd(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}function Pd(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function Fd(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101631&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129673||e>=129679&&e<=129734||e>=129742&&e<=129756||e>=129759&&e<=129769||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}function Id(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Ld(e,{ambiguousAsWide:t=!1}={}){return Id(e),Pd(e)||Fd(e)||t&&Nd(e)?2:1}const Rd=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,zd=globalThis.Intl?.Segmenter?new Intl.Segmenter:{segment:e=>e.split(``)},Bd=/^\p{Default_Ignorable_Code_Point}$/u;function Vd(e,t={}){if(typeof e!=`string`||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t;if(r||(e=Md(e)),e.length===0)return 0;let i=0,a={ambiguousAsWide:!n};for(let{segment:t}of zd.segment(e)){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159)&&!(e>=8203&&e<=8207||e===65279)&&!(e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071)&&!(e>=55296&&e<=57343)&&!(e>=65024&&e<=65039)&&!Bd.test(t)){if(Rd().test(t)){i+=2;continue}i+=Ld(e,a)}}return i}function Hd(){let{env:e}=C,{TERM:t,TERM_PROGRAM:n}=e;return C.platform===`win32`?!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask===`{cmd::Cmder}`||n===`Terminus-Sublime`||n===`vscode`||t===`xterm-256color`||t===`alacritty`||t===`rxvt-unicode`||t===`rxvt-unicode-256color`||e.TERMINAL_EMULATOR===`JetBrains-JediTerm`:t!==`linux`}const Ud={info:`cyan`,fail:`red`,success:`green`,ready:`green`,start:`magenta`},Wd={0:`red`,1:`yellow`},Gd=Hd(),Kd=(e,t)=>Gd?e:t,qd={error:Kd(`✖`,`×`),fatal:Kd(`✖`,`×`),ready:Kd(`✔`,`√`),warn:Kd(`⚠`,`‼`),info:Kd(`ℹ`,`i`),success:Kd(`✔`,`√`),debug:Kd(`⚙`,`D`),trace:Kd(`→`,`→`),fail:Kd(`✖`,`×`),start:Kd(`◐`,`o`),log:``};function Jd(e){return typeof Intl!=`object`||!Intl.Segmenter?ed(e).length:Vd(e)}var Yd=class extends Fu{formatStack(e,t,n){let r=` `.repeat((n?.errorLevel||0)+1);return`
158
- ${r}`+Mu(e,t).map(e=>` `+e.replace(/^at +/,e=>Zu.gray(e)).replace(/\((.+)\)/,(e,t)=>`(${Zu.cyan(t)})`)).join(`
159
- ${r}`)}formatType(e,t,n){let r=Ud[e.type]||Wd[e.level]||`gray`;if(t)return Qd(r)(Zu.black(` ${e.type.toUpperCase()} `));let i=typeof qd[e.type]==`string`?qd[e.type]:e.icon||e.type;return i?Zd(r)(i):``}formatLogObj(e,t){let[n,...r]=this.formatArgs(e.args,t).split(`
160
- `);if(e.type===`box`)return rd(Xd(n+(r.length>0?`
161
- `+r.join(`
162
- `):``)),{title:e.title?Xd(e.title):void 0,style:e.style});let i=this.formatDate(e.date,t),a=i&&Zu.gray(i),o=e.badge??e.level<2,s=this.formatType(e,o,t),c=e.tag?Zu.gray(e.tag):``,l,u=this.filterAndJoin([s,Xd(n)]),d=this.filterAndJoin(t.columns?[c,a]:[c]),f=(t.columns||0)-Jd(u)-Jd(d)-2;if(l=f>0&&(t.columns||0)>=80?u+` `.repeat(f)+d:(d?`${Zu.gray(`[${d}]`)} `:``)+u,l+=Xd(r.length>0?`
163
- `+r.join(`
164
- `):``),e.type===`trace`){let t=/* @__PURE__ */ Error(`Trace: `+e.message);l+=this.formatStack(t.stack||``,t.message)}return o?`
165
- `+l+`
166
- `:l}};function Xd(e){return e.replace(/`([^`]+)`/gm,(e,t)=>Zu.cyan(t)).replace(/\s+_([^_]+)_\s+/gm,(e,t)=>` ${Zu.underline(t)} `)}function Zd(e=`white`){return Zu[e]||Zu.white}function Qd(e=`bgWhite`){return Zu[`bg${e[0].toUpperCase()}${e.slice(1)}`]||Zu.bgWhite}function $d(e={}){let t=ef();return process.env.CONSOLA_LEVEL&&(t=Number.parseInt(process.env.CONSOLA_LEVEL)??t),ju({level:t,defaults:{level:t},stdout:process.stdout,stderr:process.stderr,prompt:(...e)=>import(`./prompt-uaCPq0_A-BW0EkzOD.mjs`).then(t=>t.prompt(...e)),reporters:e.reporters||[e.fancy??!(pd||gd)?new Yd:new Fu],...e})}function ef(){return hd?Z.debug:gd?Z.warn:Z.info}$d(),process.env.ROLLDOWN_TEST?tf():$d({formatOptions:{date:!1}});function tf(){let e=[`silent`,`fatal`,`error`,`warn`,`log`,`info`,`success`,`fail`,`ready`,`start`,`box`,`debug`,`trace`,`verbose`],t=Object.create(null);for(let n of e)t[n]=(...e)=>console.log(...e);return t}xc();function nf(e){return e&&(e.include=Oc(e.include),e.exclude=Oc(e.exclude)),Ec(new Tc(`builtin:vite-react-refresh-wrapper`,e))}var rf=/* @__PURE__ */ yc(xc(),1);typeof process==`object`&&process.versions?.pnp,typeof process==`object`&&process.versions?.pnp,rf.TsconfigCache;var af=/* @__PURE__ */ yc(xc(),1);af.BindingRebuildStrategy,af.ResolverFactory,af.getNativeMemoryStats,af.isolatedDeclaration,af.isolatedDeclarationSync,af.moduleRunnerTransform,af.resetNativeMemoryStats;const of=/\.[cm]?[jt]sx?$/,sf=[/node_modules/,/\/dist\//];function cf(){return[{name:`rari:react-refresh-runtime`,enforce:`pre`,apply:`serve`,resolveId(e){return e===`/@react-refresh`?e:null},load(e){return e===`/@react-refresh`?`/* global window */
87
+ );`}function Fl(e,t){let n=[],r=/* @__PURE__ */ new Set;e.namespaceBinding!=null&&(r.add(`createClientModuleProxy`),n.push(Nl(e.namespaceBinding,t))),e.defaultBinding!=null&&(r.add(`registerClientReference`),n.push(Pl(e.defaultBinding,t,`default`)));for(let i of e.named)i.typeOnly||(r.add(`registerClientReference`),n.push(Pl(i.local,t,i.imported)));return n.length===0?{code:``,helpers:[]}:{code:n.join(`
88
+ `),helpers:[...r]}}const Il=/(?:^|[\n\r;])\s*import\s*\{[^}]*\bregisterServerReference\b[^}]*\}\s*from\s*["'][^"'\n]+["']/;function Ll(e){return Il.test(e)}const Rl=/* @__PURE__ */ new Set(/* @__PURE__ */ `undefined.NaN.Infinity.arguments.Object.Array.String.Number.Boolean.Symbol.BigInt.Math.Date.JSON.Promise.Error.TypeError.RangeError.Map.Set.WeakMap.WeakSet.RegExp.Proxy.Reflect.Function.console.fetch.process.Buffer.globalThis.global.window.document.navigator.location.crypto.TextEncoder.TextDecoder.URL.URLSearchParams.FormData.Headers.Request.Response.AbortController.AbortSignal.setTimeout.clearTimeout.setInterval.clearInterval.queueMicrotask.structuredClone.atob.btoa.React.jsx.jsxs.Fragment`.split(`.`)),zl=/* @__PURE__ */ new Set(/* @__PURE__ */ `await.return.throw.if.else.for.while.do.switch.case.break.continue.new.typeof.instanceof.void.delete.yield.class.extends.super.this.try.catch.finally.with.debugger.default.of.in.from.as.import.export.async.function.const.let.var.true.false.null.static.get.set.typeof`.split(`.`));function Bl(e){return e>=97&&e<=122||e>=65&&e<=90||e===95||e===36}function Vl(e){return Bl(e)||e>=48&&e<=57}function Y(e,t){let n=e.length;for(;t<n;){let r=Hl(e,t,n);if(r==null)break;t=r}return t}function Hl(e,t,n){let r=e.charCodeAt(t);if(r===32||r===9||r===10||r===13||r===65279)return t+1;if(r===47&&e.charCodeAt(t+1)===47){let r=t+2;for(;r<n&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13;)r++;return r}if(r===47&&e.charCodeAt(t+1)===42){let r=t+2;for(;r<n-1&&(e.charCodeAt(r)!==42||e.charCodeAt(r+1)!==47);)r++;return r+2}return null}function Ul(e,t,n){t++;let r=e.length;for(;t<r;){let r=e.charCodeAt(t);if(r===92){t+=2;continue}if(r===n)return t+1;t++}return t}function Wl(e,t,n,r){let i=t,a=0,o=e.length;for(;i<o;){let t=U(e,i,o);if(t!==-1){i=t;continue}let s=e.charCodeAt(i);if(s===n)a++;else if(s===r&&(a--,a===0))return i+1;i++}return i}function Gl(e,t,n){for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;return!0}function Kl(e,t,n){let r=Y(e,t+1);if(r>=n)return!1;let i=e.charCodeAt(r);if(i!==39&&i!==34)return!1;let a=r+1,o=Ul(e,r,i);return o-1-a!=10||!Gl(e,a,`use server`)?!1:ql(e,o,n)}function ql(e,t,n){let r=t;for(;r<n;){let t=e.charCodeAt(r);if(t===32||t===9){r++;continue}return t===59||t===10||t===13||t===47&&e.charCodeAt(r+1)===47||t===47&&e.charCodeAt(r+1)===42}return!0}function Jl(e,t,n){let r=Y(e,t+1),i=e.charCodeAt(r);return i!==39&&i!==34?e.slice(t+1,n):(r=Y(e,Ul(e,r,i)),e.charCodeAt(r)===59&&r++,r=Y(e,r),e.slice(r,n))}function X(e,t){if(!Bl(e.charCodeAt(t)))return null;let n=t+1;for(;n<e.length&&Vl(e.charCodeAt(n));)n++;return{name:e.slice(t,n),end:n}}function Yl(e,t,n){if(!Gl(e,t,n))return!1;let r=t>0?e.charCodeAt(t-1):-1,i=t+n.length<e.length?e.charCodeAt(t+n.length):-1;return!(r!==-1&&Vl(r)||i!==-1&&Vl(i))}function Xl(e,t,n){return e===0&&t===0&&n===0}function Zl(e,t){return e===40?(t.paren++,null):e===41?(t.paren=Math.max(0,t.paren-1),null):e===123?(t.brace++,null):e===125?Xl(t.paren,t.brace,t.bracket)?-1:(t.brace=Math.max(0,t.brace-1),null):e===91?(t.bracket++,null):e===93?Xl(t.paren,t.brace,t.bracket)?-1:(t.bracket=Math.max(0,t.bracket-1),null):e===44&&Xl(t.paren,t.brace,t.bracket)?-1:null}function Ql(e,t,n){let r=Y(e,t+1),i={paren:0,brace:0,bracket:0};for(;r<n;){let t=U(e,r,n);if(t!==-1){r=t;continue}if(Zl(e.charCodeAt(r),i)===-1)return r;r++}return r}function $l(e,t,n,r,i){let a=X(e,t);if(a==null)return t+1;let o=Y(e,a.end);if(n===123&&e.charCodeAt(o)===58)return o+1;i.add(a.name);let s=a.end,c=Y(e,s);return e.charCodeAt(c)===61&&(s=Ql(e,c,r-1)),s}function eu(e,t,n){let r=e.charCodeAt(t),i=Wl(e,t,r,r===123?125:93),a=t+1;for(;a<i-1&&(a=Y(e,a),!(a>=i-1));){let t=e.charCodeAt(a);if(t===123||t===91){a=eu(e,a,n);continue}if(t===46&&e.charCodeAt(a+1)===46&&e.charCodeAt(a+2)===46){a=tu(e,a,n);continue}a=$l(e,a,r,i,n)}return i}function tu(e,t,n){t+=3,t=Y(e,t);let r=X(e,t);return r?(n.add(r.name),r.end):t}function nu(e){let t=/* @__PURE__ */ new Set,n=0,r=e.length;for(;n<r&&(n=Y(e,n),!(n>=r));){let r=e.charCodeAt(n);if(r===123||r===91){n=eu(e,n,t);continue}if(r===46&&e.charCodeAt(n+1)===46&&e.charCodeAt(n+2)===46){n=tu(e,n,t);continue}let i=X(e,n);if(i){t.add(i.name),n=i.end;continue}n++}return t}function ru(e){let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(/\b(?:const|let|var|function|class|async\s+function)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);return t}function iu(e,t){for(let n of e.split(`,`)){let e=n.trim();if(!e||e.startsWith(`type `))continue;let r=(e.split(/\s+as\s+/).at(-1)??``).trim();r&&t.add(r)}}function au(e){let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(/\b(?:import|export)\s+(?:type\s+)?(?:\{([^}]+)\}|(\*\s+as\s+[A-Za-z_$][\w$]*)|([A-Za-z_$][\w$]*))/g)){if(n[1]&&iu(n[1],t),n[2]){let e=/as\s+([A-Za-z_$][\w$]*)/.exec(n[2]);e&&t.add(e[1])}n[3]&&n[3]!==`type`&&n[3]!==`async`&&n[3]!==`function`&&n[3]!==`class`&&t.add(n[3])}for(let n of e.matchAll(/(?:^|\n)\s*(?:export\s+)?(?:async\s+)?(?:function|class|const|let|var)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);return t}function ou(e,t){return t<=0||e.charCodeAt(t-1)!==46?!1:t<2||e.charCodeAt(t-2)!==46}function su(e,t,n,r,i){let a=t;for(;a<n;){let t=U(e,a,n);if(t!==-1){a=t;continue}if(!Bl(e.charCodeAt(a))){a++;continue}let o=X(e,a);if(o==null){a++;continue}if(ou(e,a)){a=o.end;continue}if(hu(e,a,o.end)){a=o.end;continue}r.has(o.name)||i.add(o.name),a=o.end}}function cu(e,t,n){let r=0,i=e.length;for(;r<i;){let a=U(e,r,i);if(a!==-1){r=a;continue}if(e.charCodeAt(r)===61){let a=e.charCodeAt(r+1);if(a===62||a===61){r++;continue}let o=Ql(e,r,i);su(e,r+1,o,t,n),r=o;continue}r++}}function lu(e,t,n,r){let i=/* @__PURE__ */ new Set([...nu(t),...ru(e),...n,...Rl,...zl]);r!=null&&r!==``&&i.add(r);let a=/* @__PURE__ */ new Set;return su(e,0,e.length,i,a),cu(t,i,a),[...a]}function uu(e,t,n){if(t===n)return e;let r=``,i=0,a=0,o=e.length;for(;i<o;){let s=U(e,i,o);if(s!==-1){i=s;continue}if(!Bl(e.charCodeAt(i))){i++;continue}let c=X(e,i);if(c==null){i++;continue}c.name===t&&!ou(e,i)&&!hu(e,i,c.end)&&(r+=e.slice(a,i)+n,a=c.end),i=c.end}return r+e.slice(a)}function du(e){return e===32||e===9||e===10||e===13||e===65279}function fu(e,t){if(t<2||e.charCodeAt(t-1)!==47||e.charCodeAt(t-2)!==42)return null;let n=-1,r=t-3;for(;r>=0;){let t=e.charCodeAt(r),i=e.charCodeAt(r+1);if(t===47&&i===42){n=r,r--;continue}if(t===42&&i===47){if(r>0&&e.charCodeAt(r-1)===47){r--;continue}break}r--}return n>=0?n:null}function Z(e,t){for(;t>0;){if(du(e.charCodeAt(t-1))){t--;continue}let n=fu(e,t);if(n==null)break;t=n}return t}function Q(e,t,n){let r=t-n.length;return r<0||!Yl(e,r,n)?null:r}const pu=/* @__PURE__ */ new Set([40,91,44,61,58,63,46,43,45,42,47,37,38,124,94,33,126,60,62]);function mu(e,t){let n=Z(e,t);if(n<=0)return!0;let r=Q(e,n,`default`);if(r!=null)return Q(e,Z(e,r),`export`)!=null;if(Q(e,n,`export`)!=null)return!0;let i=e.charCodeAt(n-1);if(i===59||i===125)return!0;if(i===123){let t=Z(e,n-1);return t<=0||e.charCodeAt(t-1)!==61}let a=!1;for(let r=n;r<t;r++){let t=e.charCodeAt(r);if(t===10||t===13){a=!0;break}}return a?!pu.has(i):!1}function hu(e,t,n){let r=Y(e,n);if(e.charCodeAt(r)!==58)return!1;let i=Z(e,t);if(i===0)return!1;let a=e.charCodeAt(i-1);return a===123||a===44}function gu(e,t,n){if(t<=0||e.charCodeAt(t-1)!==61)return null;let r=Z(e,t-1),i=r;for(;i>0&&Vl(e.charCodeAt(i-1));)i--;if(i>=r||!Bl(e.charCodeAt(i)))return null;let a=e.slice(i,r),o=Z(e,i),s=Q(e,o,`const`)??Q(e,o,`let`)??Q(e,o,`var`);return s==null?null:Q(e,Z(e,s),`export`)==null?{start:n,exportKind:null,bindingName:a}:{start:n,exportKind:`named`,bindingName:a}}function _u(e,t){let n=Z(e,t),r=Q(e,n,`default`);if(r!=null){n=Z(e,r);let t=Q(e,n,`export`);if(t!=null)return{start:t,exportKind:`default`,bindingName:null}}let i=gu(e,n,t);if(i!=null)return i;let a=Q(e,n,`export`);return a==null?{start:t,exportKind:null,bindingName:null}:{start:a,exportKind:`named`,bindingName:null}}function vu(e,t,n,r){if(!Yl(e,n,`function`))return null;n=Y(e,n+8),e.charCodeAt(n)===42&&(n=Y(e,n+1));let i=null,a=X(e,n);if(a&&(i=a.name,n=Y(e,a.end)),e.charCodeAt(n)!==40)return{action:null,nextI:t+1};let o=Wl(e,n,40,41),s=e.slice(n+1,o-1);if(n=Y(e,o),e.charCodeAt(n)!==123)return{action:null,nextI:t+1};let c=Wl(e,n,123,125)-1;if(!Kl(e,n,c))return{action:null,nextI:n+1};let l=i!=null&&mu(e,t);return{action:{start:t,end:c+1,bodyOpen:n,bodyClose:c,paramsRaw:s,isAsync:r,name:i,kind:l?`declaration`:`expression`},nextI:c+1}}function yu(e,t,n,r){let i,a;if(e.charCodeAt(n)===40)i=Wl(e,n,40,41),a=e.slice(n+1,i-1);else{let t=X(e,n);if(t==null)return null;i=t.end,a=t.name}let o=Y(e,i);if(e.charCodeAt(o)!==61||e.charCodeAt(o+1)!==62||(o=Y(e,o+2),e.charCodeAt(o)!==123))return null;let s=Wl(e,o,123,125)-1;return Kl(e,o,s)?{action:{start:t,end:s+1,bodyOpen:o,bodyClose:s,paramsRaw:a,isAsync:r,name:null,kind:`arrow`},nextI:s+1}:{action:null,nextI:o+1}}function bu(e,t,n){if(!Yl(e,t,`async`)&&!Yl(e,t,`function`))return null;let r=t,i=t,a=!1;Yl(e,i,`async`)&&(a=!0,i=Y(e,i+5));let o=vu(e,r,i,a);if(o!=null)return o.action!=null&&n.push(o.action),o.nextI;if(!a)return null;let s=yu(e,r,i,!0);return s==null?null:(s.action!=null&&n.push(s.action),s.nextI)}function xu(e,t,n){let r=e.charCodeAt(t);if(r===39||r===34||r===96)return Ul(e,t,r);if(r===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42))return Y(e,t);let i=bu(e,t,n);if(i!=null)return i;let a=yu(e,t,t,!1);return a==null?t+1:(a.action!=null&&n.push(a.action),a.nextI)}function Su(e){let t=[],n=e.length,r=0;for(;r<n;)r=xu(e,r,t);return t}function Cu(e,t,n,r,i){return r==="default"?{rewrittenExport:`default`,replacement:`export default registerServerReference(${t}, ${JSON.stringify(n)}, "default")`}:r===`named`&&e.name!=null&&e.kind===`declaration`?{rewrittenExport:e.name,replacement:`export const ${e.name} = registerServerReference(${t}, ${JSON.stringify(n)}, ${JSON.stringify(e.name)})`}:r===`named`&&i!=null?{rewrittenExport:i,replacement:`registerServerReference(${t}, ${JSON.stringify(n)}, ${JSON.stringify(i)})`}:e.kind===`declaration`&&e.name!=null?{replacement:`const ${e.name} = ${t}`,rewrittenExport:null}:{replacement:t,rewrittenExport:null}}function wu(e,t,n,r,i,a,o,s){if(s==null){e.unshift(`${n}function ${r}(${i}) {\n${a}\n}`,`registerServerReference(${r}, ${JSON.stringify(o)}, ${JSON.stringify(r)});`);return}e.unshift(`${n}function ${r}(${i}) {\n${a}\n}`),t.unshift(s)}function Tu(e,t){let n=Su(e);if(n.length===0)return null;let r=au(e),i=[],a=[],o=e,s=[],c=!1,l=[...n].sort((e,t)=>t.start-e.start),u=n.length-1;for(let e of l){let n=e.name??`anonymous_server_function`,l=`$$ACTION_${u}_${n.replace(/\W/g,`_`)}`;u--,i.unshift(l);let d=Jl(o,e.bodyOpen,e.bodyClose),f=e.kind===`expression`&&e.name!=null?e.name:null,p=lu(d,e.paramsRaw,r,f),m=f==null?d:uu(d,f,l),h=[...p,e.paramsRaw.trim()].filter(e=>e!==``).join(`, `),g=e.isAsync?`async `:``,_=p.length>0?`${l}.bind(null, ${p.join(`, `)})`:l,{start:v,exportKind:y,bindingName:ee}=_u(o,e.start),{replacement:te,rewrittenExport:ne}=Cu(e,_,t,y,ee);wu(s,a,g,l,h,m,t,ne),c=!0,o=o.slice(0,v)+te+o.slice(e.end)}let d=c?`import { registerServerReference } from ${JSON.stringify(`react-server-dom-rari/server`)};\n`:``;return{code:`${c&&!Ll(o)?d:``}${o}\n\n${s.join(`
89
+ `)}\n`,actionNames:i,rewrittenExportNames:a}}const Eu=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g,Du=/import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g,Ou=/import\s+(\w+)\s*,\s*\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g,ku=/defineMdxComponents\s*\(\s*\{([\s\S]*?)\}\s*\)/;function Au(e,t,n){for(let r of t.split(`,`)){let t=r.trim();if(!t||(t=t.replace(/^type\s+/i,``).trim(),!t))continue;let i=t.split(/\s+as\s+/i),a=(i[1]??i[0]).trim();a&&n.set(a,e)}}function ju(e){let t=/* @__PURE__ */ new Map;for(let n of e.matchAll(Ou))t.set(n[1],n[3]),Au(n[3],n[2],t);for(let n of e.matchAll(Eu))t.set(n[1],n[2]);for(let n of e.matchAll(Du))Au(n[2],n[1],t);return t}function Mu(e){let t=[];for(let n of e.split(`,`)){let e=n.trim();if(!e)continue;let r=e.indexOf(`:`);if(r===-1){t.push({name:e,binding:e});continue}let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();i&&a&&t.push({name:i,binding:a})}return t}function Nu(e){try{return V(D.readFileSync(e,`utf-8`)).topLevelUseClient}catch{return!1}}function Pu(e){let{code:t,id:n,projectRoot:r,resolvedAlias:i}=e;if(!t.includes(`defineMdxComponents`)||t.includes(`__RARI_MDX_RESOLVED__`))return null;let a=ku.exec(t);if(!a)return null;let o=ju(t),s=Mu(a[1]);if(s.length===0)return null;let c=`defineMdxComponents(/* __RARI_MDX_RESOLVED__ */[\n${s.map(({name:e,binding:t})=>{let a=o.get(t);if(a==null||a===``)throw Error(`[rari/mdx] Could not resolve import for MDX component "${e}" (binding "${t}") in ${n}`);let s=de(a,n,i),c=Ut(s,r),l=Nu(s);return` { name: ${JSON.stringify(e)}, component: ${t}, id: ${JSON.stringify(c)}, client: ${l} }`}).join(`,
90
+ `)},\n])`;return t.replace(ku,c)}const Fu=/forwardRef|memo|\b(?:[A-Z]|use[A-Z0-9])/,Iu=/\.[cm]?[jt]sx?$/,Lu=/['"]use memo['"]/;function Ru(e){return{...e===!0?{}:e,target:`19`}}function zu(e,t){return t.compilationMode===`annotation`?Lu.test(e):Fu.test(e)}function Bu(e){if(e.startsWith(`\0`)||e.includes(`virtual:`))return!1;let t=C(e);return/\.d\.[cm]?ts$/.test(t)||t.includes(`/dist/`)?!1:Iu.test(t)&&!t.includes(`/node_modules/`)}const Vu=/\.[jt]sx$/;function Hu(e,t=`app`){let n=Ru(e),r,i=!0,a=!1,o=!1,c=async e=>{if(r)return r;try{return r=await import(`oxc-transform-react`),r}catch(t){let n=s(t);return e(`React Compiler requires the optional \`oxc-transform-react\` package. Install it before enabling \`rari({ compiler: true })\`.${n==null?``:`\n${n.message}`}`)}};return{name:t===`library`?`rari:react-compiler-library`:`rari:react-compiler`,enforce:`pre`,async config(e,{command:n}){return await c(e=>this.error(e)),t===`library`?(o=!1,a=!1,{}):(o=n===`serve`,{oxc:{jsx:{refresh:!1}},optimizeDeps:{include:[`react/compiler-runtime`]}})},configResolved(e){if(t===`library`){i=e.build.sourcemap!==!1,a=!1,o=!1;return}i=e.command!==`build`||e.build.sourcemap!==!1,a=!e.isProduction,o=!e.isProduction&&e.command===`serve`&&e.server.hmr!==!1},async transform(e,s){if(!Bu(s))return null;let l=C(s);if(t===`library`&&!Vu.test(l)||Hn(e)||t===`app`&&this.environment.config.consumer===`server`)return null;let{transform:u}=r??await c(e=>this.error(e)),d=zu(e,n),f=await u(l,e,{jsx:{runtime:`automatic`,development:a,importSource:`react`,refresh:o},reactCompiler:d?n:!1,sourcemap:i}),p=f.errors.map(e=>{let t=e.codeframe;return t!=null&&t!==``?`${e.message}\n${t}`:e.message});if(f.fatal){let e=p.join(`
91
+
92
+ `);this.error(e===``?`React Compiler transform failed.`:e)}for(let e of p)this.warn(e);return{code:f.code,map:f.map}}}}const Uu=/\.[cm]?[jt]sx?$/,Wu=[/node_modules/,/\/dist\//];function Gu(){return[{name:`rari:react-refresh-runtime`,enforce:`pre`,apply:`serve`,resolveId(e){return e===`/@react-refresh`?e:null},load(e){return e===`/@react-refresh`?`/* global window */
167
93
  /* eslint-disable eqeqeq, prefer-const, @typescript-eslint/no-empty-function */
168
94
 
169
95
  /*! Copyright (c) Meta Platforms, Inc. and affiliates. **/
@@ -849,88 +775,108 @@ export const __hmr_import = (module) => import(/* @vite-ignore */ module)
849
775
 
850
776
  // For backwards compatibility with @vitejs/plugin-react.
851
777
  export default { injectIntoGlobalHook }
852
- `:null}},{name:`rari:react-refresh-wrapper`,apply:`serve`,applyToEnvironment(e){return e.config.consumer===`client`&&nf({cwd:process.cwd(),include:[of],exclude:sf,jsxImportSource:`react`,reactRefreshHost:``})}}]}let lf;async function uf(){return lf??=(async()=>{try{let e=(await import(`@rari/use-cache`)).transformUseCacheModule;return typeof e==`function`?e:null}catch(e){let t=e instanceof Error&&e.message!==``?` ${e.message}`:``;throw Error(`\`experimental.useCache\` / \`experimental.useCacheRemote\` requires the optional \`@rari/use-cache\` package. Install it before enabling the option.${t}`)}})(),lf}function df(e){return l(e)}function ff(e){return l(e)}async function pf(e){let t=await import(
778
+ `:null}},{name:`rari:react-refresh-wrapper`,apply:`serve`,applyToEnvironment(e){return e.config.consumer===`client`&&Ne({cwd:process.cwd(),include:[Uu],exclude:Wu,jsxImportSource:`react`,reactRefreshHost:``})}}]}let Ku;async function qu(){return Ku??=(async()=>{try{let e=(await import(`@rari/use-cache`)).transformUseCacheModule;return typeof e==`function`?e:null}catch(e){let t=e instanceof Error&&e.message!==``?` ${e.message}`:``;throw Error(`\`experimental.useCache\` / \`experimental.useCacheRemote\` requires the optional \`@rari/use-cache\` package. Install it before enabling the option.${t}`)}})(),Ku}async function Ju(e){let t=await import(
853
779
  /* @vite-ignore */
854
- e);return df(t)?t:{}}function mf(e,t){e&&(e.notFound&&(t.notFound=!0),e.redirect!=null&&(t.redirect=typeof e.redirect==`string`?e.redirect:e.redirect.destination),e.revalidate!==void 0&&(t.revalidate=e.revalidate),e.props&&(t.props={...t.props,...e.props}))}async function hf(e,t,n,r){typeof e.getData==`function`&&mf(await e.getData({params:t,searchParams:n}),r)}async function gf(e,t,n,r){typeof e.getServerSideProps==`function`&&mf(await e.getServerSideProps({params:t,searchParams:n}),r)}async function _f(e,t,n){typeof e.getStaticProps==`function`&&mf(await e.getStaticProps({params:t}),n)}
780
+ e);return u(t)?t:{}}function Yu(e,t){e&&(e.notFound&&(t.notFound=!0),e.redirect!=null&&(t.redirect=typeof e.redirect==`string`?e.redirect:e.redirect.destination),e.revalidate!==void 0&&(t.revalidate=e.revalidate),e.props&&(t.props={...t.props,...e.props}))}async function Xu(t,n){try{Yu(await t(),n)}catch(t){if(e(t)){n.notFound=!0;return}throw t}}async function Zu(e,t,n,r){let i=e.getData;typeof i==`function`&&await Xu(async()=>i({params:t,searchParams:n}),r)}async function Qu(e,t,n,r){let i=e.getServerSideProps;typeof i==`function`&&await Xu(async()=>i({params:t,searchParams:n}),r)}async function $u(e,t,n){let r=e.getStaticProps;typeof r==`function`&&await Xu(async()=>r({params:t}),n)}
855
781
  /* v8 ignore start - requires dynamic imports, better tested in integration/e2e */
856
- async function vf(e,t,n){try{let r=await pf(e),i={props:{}};return await hf(r,t,n,i),await gf(r,t,n,i),await _f(r,t,i),i}catch(t){return console.error(`[rari] Router: Failed to extract server props from ${e}:`,t),{props:{}}}}
782
+ async function ed(e,t,n){try{let r=await Ju(e),i={props:{}};return await Zu(r,t,n,i),await Qu(r,t,n,i),await $u(r,t,i),i}catch(t){return console.error(`[rari] Router: Failed to extract server props from ${e}:`,t),{props:{}}}}
857
783
  /* v8 ignore stop */
858
784
  /* v8 ignore start - requires dynamic imports, better tested in integration/e2e */
859
- async function yf(e,t,n){try{let r=await pf(e);if(typeof r.generateMetadata==`function`){let e=await r.generateMetadata({params:t,searchParams:n});if(ff(e))return e}return ff(r.metadata)?r.metadata:{}}catch(t){return console.error(`[rari] Router: Failed to extract metadata from ${e}:`,t),{}}}
785
+ async function td(e,t,n){try{let r=await Ju(e);if(typeof r.generateMetadata==`function`){let e=await r.generateMetadata({params:t,searchParams:n});if(u(e))return e}return u(r.metadata)?r.metadata:{}}catch(t){return console.error(`[rari] Router: Failed to extract metadata from ${e}:`,t),{}}}
860
786
  /* v8 ignore start - requires dynamic imports, better tested in integration/e2e */
861
- async function bf(e){try{let n=await Xe(e);return n==null?[]:f(n)?n:(t(e),[])}catch(t){return console.error(`[rari] Router: Failed to extract static params from ${e}:`,t),[]}}
787
+ async function nd(e){try{let t=await He(e);return t==null?[]:p(t)?t:(n(e),[])}catch(t){return console.error(`[rari] Router: Failed to extract static params from ${e}:`,t),[]}}
862
788
  /* v8 ignore stop */
863
789
  /* v8 ignore start - requires dynamic imports, better tested in integration/e2e */
864
- async function xf(e){try{let t=await pf(e);return!!(t.getData??t.getServerSideProps??t.getStaticProps??t.generateMetadata??t.generateStaticParams)}catch{return!1}}
790
+ async function rd(e){try{let t=await Ju(e);return!!(t.getData??t.getServerSideProps??t.getStaticProps??t.generateMetadata??t.generateStaticParams)}catch{return!1}}
865
791
  /* v8 ignore stop */
866
- const Sf=/* @__PURE__ */ new Map;
792
+ const id=/* @__PURE__ */ new Map;
867
793
  /* v8 ignore start - depends on extractServerProps which requires dynamic imports */
868
- async function Cf(e,t,n,r=6e4){let i=`${e}:${JSON.stringify(t)}:${JSON.stringify(n)}`,a=Sf.get(i);if(a&&Date.now()-a.timestamp<r)return a.result;let o=await vf(e,t,n);return Sf.set(i,{result:o,timestamp:Date.now()}),o}
794
+ async function ad(e,t,n,r=6e4){let i=`${e}:${JSON.stringify(t)}:${JSON.stringify(n)}`,a=id.get(i);if(a&&Date.now()-a.timestamp<r)return a.result;let o=await ed(e,t,n);return id.set(i,{result:o,timestamp:Date.now()}),o}
869
795
  /* v8 ignore stop */
870
- function wf(){Sf.clear()}
796
+ function od(){id.clear()}
871
797
  /* v8 ignore start - cache clearing logic, difficult to test without populating cache via dynamic imports */
872
- function Tf(e){for(let t of Sf.keys())t.startsWith(e)&&Sf.delete(t)}
798
+ function sd(e){for(let t of id.keys())t.startsWith(e)&&id.delete(t)}
873
799
  /* v8 ignore stop */
874
- const Ef="[rari] Runtime dist not built. Run `pnpm build` in the rari package first.",Df=/\.(?:js|mjs|cjs|ts|tsx|jsx|css|map|json|svg|png|jpe?g|gif|webp|avif|ico|woff2?|ttf|eot|txt|xml|html|wasm)$/i;async function Of(e,t){let n=[],r=0;for await(let i of e){let a=Uint8Array.from(De.from(i));if(r+=a.byteLength,r>t)throw e.destroy(),Object.assign(/* @__PURE__ */ Error(`Request body too large`),{statusCode:413});n.push(a)}let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.byteLength;return new Blob([i])}function kf(e){let t=e.slice(e.lastIndexOf(`/`)+1);return Df.test(t)}function Af(e,t){return e===t||e.startsWith(`${t}/`)}const jf=/import\s+type\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,Mf=/import\s+type\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,Nf=/import\s+type\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,Pf=/import\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,Ff=/import\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,If=/import\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,Lf=/import\s+["']\.\.?\/([^"']+)["'];?/g,Rf=/export\s+default\s+(?:async\s+)?function\s+(\w+)/,zf=/^['"]use client['"];?\s*$/gm,Bf=/^[./@~#]/;function Vf(e,t){for(let n of Object.keys(t))if(e===n||e.startsWith(`${n}/`))return!0;return!1}function Hf(e){let t=n(e);return t===`ENOENT`||t===`ERR_PACKAGE_PATH_NOT_EXPORTED`||t===`ERR_MODULE_NOT_FOUND`}function Uf(e){return e===`react`||e instanceof RegExp&&e.source===`^react$`&&e.flags===``}const Wf=/import\s+\{[^}]*\}\s+from\s+['"]react['"]/,Gf=/import\s+[^,\s]+\s*,\s*\{[^}]*\}\s+from\s+['"]react['"]/,Kf=/import React(,\s*\{([^}]*)\})?\s+from\s+['"]react['"];?/,qf=/from(\s*)(['"])(?:\.\/vendor\/react-flight-client\/index|rari\/runtime\/vendor\/react-flight-client\/index)\.mjs\2/g,Jf=/\bJSX\b/,Yf=/\{([^}]*)\}/,Xf=/^['"]use client['"];?\s*\n/,Zf={remotePatterns:[],localPatterns:[],deviceSizes:g,imageSizes:h,formats:m,qualityAllowlist:p,minimumCacheTTL:60};function Qf(e){return[{pathname:`/${fe(e)}/**`}]}function $f(e,t){let n=[...e??[]];for(let e of Qf(t))n.some(t=>t.pathname===e.pathname)||n.push({...e});return n}const ep=/* @__PURE__ */ new Map;async function tp(e){let t=ep.get(e);if(t!=null&&t!==``)return t;let r=import.meta.url,i=w(r),a=S.dirname(i),o=[S.join(a,`runtime`,e),S.join(a,`../runtime`,e)];for(let t of o)try{let n=await b.promises.readFile(t,`utf-8`);return t.endsWith(`.ts`)&&(n=n.replace(jf,(e,t,n)=>`import type ${t} from "rari/${n}";`),n=n.replace(Mf,(e,t,n)=>`import type ${t} from "rari/${n}";`),n=n.replace(Nf,(e,t,n)=>`import type ${t} from "rari/${n}";`),n=n.replace(Pf,(e,t,n)=>`import ${t} from "rari/${n}";`),n=n.replace(Ff,(e,t,n)=>`import ${t} from "rari/${n}";`),n=n.replace(If,(e,t,n)=>`import ${t} from "rari/${n}";`),n=n.replace(Lf,(e,t)=>`import "rari/${t}";`)),ep.set(e,n),n}catch(e){let r=n(e);r!==`ENOENT`&&r!==`EISDIR`&&console.warn(`[rari] Unexpected error reading ${t}:`,e)}throw Error(`Could not find ${e}. Tried: ${o.join(`, `)}`)}const np=S.dirname(w(import.meta.url)),rp=S.dirname(np);function ip(e){let t=[S.join(np,`runtime`,e),S.join(np,`../runtime`,e)];for(let e of t)if(b.existsSync(e))return e;return null}function ap(e){return e.startsWith(rp)}async function op(){return tp(`rsc-client-runtime.mjs`)}async function sp(e,t,n=``){let r=(await tp(`entry-client.mjs`)).replace(`/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */`,e).replace(`/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */`,t);return n===``?r:`${n}\n${r}`}async function cp(){return tp(`rsc-references.mjs`)}async function lp(e,t,n=`assets`,i){let a=S.join(e,`src`),{getBinaryPath:o}=await import(`./platform.mjs`),c=o(),l=ke(c,[`scan-images`,`--src`,a],{encoding:`utf8`,cwd:e,shell:!1,timeout:6e4});if(l.error)throw Error(`Failed to scan for image usage: ${l.error.message}`);if(l.signal)throw Error(`Failed to scan for image usage: process terminated by signal ${l.signal}`);if(l.status!==0)throw Error(`Failed to scan for image usage: ${l.stderr||l.stdout||`exit code ${l.status}`}`);let u;try{u={images:r(l.stdout,`images`)??[]}}catch(e){let t=e instanceof SyntaxError?e.message:s(e,String(e)),n=(l.stdout||l.stderr||`(empty)`).slice(0,500);throw Error(`Failed to parse image scanner output as JSON: ${t}. Scanner output: ${n}`,{cause:e})}let d=fe(n),f=(()=>{let n=i??t.serverBuild?.outDir??S.join(e,`dist`);return S.isAbsolute(n)?n:S.resolve(e,n)})(),p=y(S.relative(e,f))||`dist`,m={...Zf,...t.images,assetsDir:d,outDir:p,localPatterns:$f(t.images?.localPatterns,d),preoptimizeManifest:u.images},h=S.join(f,`server`);b.existsSync(h)||b.mkdirSync(h,{recursive:!0});let g=S.join(h,`image.json`);b.writeFileSync(g,JSON.stringify(m))}function up(e){return e}function dp(e={}){if(e.jsPoolSize!=null){let t=e.jsPoolSize;if(!Number.isInteger(t)||t<1||!Number.isFinite(t))throw Error(`jsPoolSize must be a finite positive integer; received ${String(t)}`)}let t=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set,a=new Zn,o=null,u=null,f=null,p={},m=`assets`,h=S.join(C.cwd(),`dist`),g=null;function _(){g=null}function ee(){return g!=null&&g!==``||(g=Ja(qa({projectRoot:e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:C.cwd(),mdxOptions:e.mdx,alias:p,cache:a}))),g}function ne(e){return t.get(Jn(e))}function ie(t){let n=e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:C.cwd(),r=y(S.relative(n,t));return r.startsWith(`..`)||S.isAbsolute(r)?y(t):r}function ae(e,n){t.set(Jn(e),n)}function se(e){Yn(t,e)}function ce(e){r.add(Jn(e))}function ue(e){return r.has(Jn(e))}function fe(e){r.delete(e);try{r.delete(b.realpathSync(e))}catch{r.delete(S.resolve(e))}}function ve(){let e=new Set(r);if(o)for(let t of o.getClientComponentPaths())e.add(t);return e}function ye(e){if(e.includes(`node_modules`)||ap(e))return!1;let t=Jn(e);try{return ps(t,a.get(e))}catch{return!1}}function be(e,t){try{let n=new Set(bn(e));return(t?.hasDefaultExport??Cn(e))&&n.add(`default`),[...n]}catch{return[]}}function xe(t,n,r){let i=Xt(n,e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:C.cwd()),a=Ks(t,i),o=a?.code??t;if(!r.topLevelUseServer)return a==null?t:(o+=`
800
+ const cd=/\.(?:js|mjs|cjs|ts|tsx|jsx|css|map|json|svg|png|jpe?g|gif|webp|avif|ico|woff2?|ttf|eot|txt|xml|html|wasm)$/i;async function ld(e,t){let n=[],r=0;for await(let i of e){let a=Uint8Array.from(we.from(i));if(r+=a.byteLength,r>t)throw e.destroy(),Object.assign(/* @__PURE__ */ Error(`Request body too large`),{statusCode:413});n.push(a)}let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.byteLength;return new Blob([i])}function ud(e){let t=e.slice(e.lastIndexOf(`/`)+1);return cd.test(t)}function $(e,t){return e===t||e.startsWith(`${t}/`)}const dd=/import\s+type\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,fd=/import\s+type\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,pd=/import\s+type\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,md=/import\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,hd=/import\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,gd=/import\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,_d=/import\s+["']\.\.?\/([^"']+)["'];?/g,vd=/export\s+default\s+(?:async\s+)?function\s+(\w+)/,yd=/^['"]use client['"];?\s*$/gm,bd=/^[./@~#]/;function xd(e,t){for(let n of Object.keys(t))if(e===n||e.startsWith(`${n}/`))return!0;return!1}function Sd(e){let t=r(e);return t===`ENOENT`||t===`ERR_PACKAGE_PATH_NOT_EXPORTED`||t===`ERR_MODULE_NOT_FOUND`}function Cd(e){return e===`react`||e instanceof RegExp&&e.source===`^react$`&&e.flags===``}const wd=/import\s+\{[^}]*\}\s+from\s+['"]react['"]/,Td=/import\s+[^,\s]+\s*,\s*\{[^}]*\}\s+from\s+['"]react['"]/,Ed=/import React(,\s*\{([^}]*)\})?\s+from\s+['"]react['"];?/,Dd=/from(\s*)(['"])(?:\.\/vendor\/react-flight-client\/index|rari\/runtime\/vendor\/react-flight-client\/index)\.mjs\2/g,Od=/\bJSX\b/,kd=/\{([^}]*)\}/,Ad=/^['"]use client['"];?\s*\n/,jd={remotePatterns:[],localPatterns:[],deviceSizes:g,imageSizes:m,formats:h,qualityAllowlist:_,minimumCacheTTL:60};function Md(e){return[{pathname:`/${w(e)}/**`}]}function Nd(e,t,n=!0){let r=[...e??[]];if(!n)return r;for(let e of Md(t))r.some(t=>t.pathname===e.pathname)||r.push({...e});return r}const Pd=/* @__PURE__ */ new Map;async function Fd(e){let t=Pd.get(e);if(t!=null&&t!==``)return t;let n=import.meta.url,i=j(n),a=k.dirname(i),o=[k.join(a,`runtime`,e),k.join(a,`../runtime`,e)];for(let t of o)try{let n=await D.promises.readFile(t,`utf-8`);return t.endsWith(`.ts`)&&(n=n.replace(dd,(e,t,n)=>`import type ${t} from "rari/${n}";`),n=n.replace(fd,(e,t,n)=>`import type ${t} from "rari/${n}";`),n=n.replace(pd,(e,t,n)=>`import type ${t} from "rari/${n}";`),n=n.replace(md,(e,t,n)=>`import ${t} from "rari/${n}";`),n=n.replace(hd,(e,t,n)=>`import ${t} from "rari/${n}";`),n=n.replace(gd,(e,t,n)=>`import ${t} from "rari/${n}";`),n=n.replace(_d,(e,t)=>`import "rari/${t}";`)),Pd.set(e,n),n}catch(e){let n=r(e);n!==`ENOENT`&&n!==`EISDIR`&&console.warn(`[rari] Unexpected error reading ${t}:`,e)}throw Error(`Could not find ${e}. Tried: ${o.join(`, `)}`)}const Id=k.dirname(j(import.meta.url)),Ld=k.dirname(Id);function Rd(e){let t=[k.join(Id,`runtime`,e),k.join(Id,`../runtime`,e)];for(let e of t)if(D.existsSync(e))return e;return null}function zd(e){return e.startsWith(Ld)}async function Bd(){return Fd(`rsc-client-runtime.mjs`)}async function Vd(e,t,n=``){let r=(await Fd(`entry-client.mjs`)).replace(`/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */`,e).replace(`/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */`,t);return n===``?r:`${n}\n${r}`}async function Hd(){return Fd(`rsc-references.mjs`)}async function Ud(e,t,n=`assets`,r){let a=k.join(e,`src`),{getBinaryPath:o}=await import(`./platform.mjs`),s=o(),l=Ee(s,[`scan-images`,`--src`,a],{encoding:`utf8`,cwd:e,shell:!1,timeout:6e4});if(l.error)throw Error(`Failed to scan for image usage: ${l.error.message}`);if(l.signal)throw Error(`Failed to scan for image usage: process terminated by signal ${l.signal}`);if(l.status!==0)throw Error(`Failed to scan for image usage: ${l.stderr||l.stdout||`exit code ${l.status}`}`);let u;try{u={images:i(l.stdout,`images`)??[]}}catch(e){let t=e instanceof SyntaxError?e.message:c(e,String(e)),n=(l.stdout||l.stderr||`(empty)`).slice(0,500);throw Error(`Failed to parse image scanner output as JSON: ${t}. Scanner output: ${n}`,{cause:e})}let d=w(n),f=(()=>{let n=r??t.serverBuild?.clientOutDir??t.serverBuild?.outDir;return n!=null&&n!==``?k.isAbsolute(n)?n:k.resolve(e,n):k.join(e,`dist`,`client`)})(),p=k.basename(f)===`client`?k.dirname(f):f,m=T(k.relative(e,f))||`dist/client`,h={...jd,...t.images,assetsDir:d,outDir:m,localPatterns:Nd(t.images?.localPatterns,d,t.images?.includeBundledAssets!==!1),preoptimizeManifest:u.images},g=k.join(p,`server`);D.existsSync(g)||D.mkdirSync(g,{recursive:!0});let _=k.join(g,`image.json`);D.writeFileSync(_,JSON.stringify(h))}function Wd(e,t,n){try{let r=j(import.meta.resolve(n));t.has(n)||e.push({find:n,replacement:r})}catch(e){Sd(e)||console.warn(`[rari] Unexpected error resolving ${n}:`,e)}}function Gd(e,t){let n=j(import.meta.resolve(`react`)),r=j(import.meta.resolve(`react-dom/client`)),i=j(import.meta.resolve(`react/jsx-runtime`)),a=[];return e.has(`react/jsx-runtime`)||a.push({find:`react/jsx-runtime`,replacement:i}),Wd(a,e,`react/jsx-dev-runtime`),Wd(a,e,`react/compiler-runtime`),t||a.push({find:/^react$/,replacement:n}),e.has(`react-dom/client`)||a.push({find:`react-dom/client`,replacement:r}),a}function Kd(e){let t=Rd(e);if(t!=null&&t!==``)return D.readFileSync(t,`utf-8`);throw Error("[rari] Runtime dist not built. Run `pnpm build` in the rari package first.")}function qd(e){if(e.includes(`import React`)||e.includes(`from "react"`)||e.includes(`from 'react'`))return e;let t=Ad.exec(e);if(t){let n=t[0];return`\n${n}import * as React from 'react';\n${e.slice(n.length)}`}return`\nimport * as React from 'react';\n${e}`}function Jd(e){let t=`react-server-dom-webpack-client.browser.${e}.js`,n=`react-server-dom-webpack-client.edge.${e}.js`;try{let e=k.dirname(j(import.meta.resolve(`react-server-dom-webpack/package.json`)));return{browserClientPath:k.join(e,`cjs`,t),edgeClientPath:k.join(e,`cjs`,n)}}catch{let e=k.dirname(j(import.meta.url)),r=k.resolve(e,`../../node_modules`);return{browserClientPath:k.join(r,`react-server-dom-webpack/cjs`,t),edgeClientPath:k.join(r,`react-server-dom-webpack/cjs`,n)}}}function Yd(e,t,n,r){return!e&&!t||n===``||$(r,`/api`)||$(r,`/rsc`)}function Xd(e){let{browserClientPath:t,edgeClientPath:n}=Jd(e),r=Rt(D.readFileSync(t,`utf-8`),D.readFileSync(n,`utf-8`));return{code:`
801
+ import * as React from 'react';
802
+ import * as ReactDOM from 'react-dom';
803
+ import { callServer as rariCallServer } from 'rari/runtime/call-server';
875
804
 
876
- if (import.meta.hot) {
877
- import.meta.hot.accept(() => {
878
- });
879
- }`,o);let s=be(o,r);if(s.length===0&&a==null)return t;let c=JSON.stringify(i);Ts(o)?o+=`
880
- `:o+=`
805
+ const module = { exports: {} };
806
+ const exports = module.exports;
807
+ (function(module, exports, require) {
808
+ ${e===`development`?r.replace(`"production" !== process.env.NODE_ENV &&`,`true &&`):r}
809
+ })(module, module.exports, function require(id) {
810
+ if (id === 'react') return React;
811
+ if (id === 'react-dom') return ReactDOM;
812
+ throw new Error('Cannot require "' + id + '" from react-server-dom-webpack client bundle');
813
+ });
881
814
 
882
- import {registerServerReference} from "react-server-dom-rari/server";
883
- `;for(let e of s)if(e==="default"){let t=Rf.exec(o);if(t){let n=t[1];o+=`
884
- // Register server reference for default export
885
- `,o+=`registerServerReference(${n}, ${c}, ${JSON.stringify(e)});\n`}else{let t=`__default_export__`,n=Rn(o,t);n!=null&&(o=n,o+=`
886
- // Register server reference for default export
887
- `,o+=`if (typeof ${t} === "function") {\n`,o+=` registerServerReference(${t}, ${c}, ${JSON.stringify(e)});\n`,o+=`}
888
- `)}}else if(a?.rewrittenExportNames.includes(e))continue;else o+=`\n// Register server reference for ${e}\n`,o+=`if (typeof ${e} === "function") {\n`,o+=` registerServerReference(${e}, ${c}, ${JSON.stringify(e)});\n`,o+=`}
889
- `;return o+=`
815
+ const rariFindSourceMapURL = import.meta.env.DEV
816
+ ? function rariFindSourceMapURL(filename, environmentName) {
817
+ const url = new URL('/__rari_findSourceMapURL', window.location.origin);
818
+ url.searchParams.set('filename', filename);
819
+ url.searchParams.set('environmentName', environmentName ?? 'Server');
820
+ return url.href;
821
+ }
822
+ : undefined;
890
823
 
891
- if (import.meta.hot) {
892
- import.meta.hot.accept(() => {
824
+ export function createFromFetch(promise, options) {
825
+ return module.exports.createFromFetch(promise, {
826
+ ...options,
827
+ callServer: options?.callServer ?? rariCallServer,
828
+ findSourceMapURL: options?.findSourceMapURL ?? rariFindSourceMapURL,
893
829
  });
894
- }`,o}function Se(t,n,r){let i=e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:C.cwd(),a=ye(n);if(r.topLevelUseServer){let e=be(t,r);if(e.length===0)return``;let a=Xt(n,i),o=`import { createServerReference } from "virtual:react-flight-client";
895
- `;o+=`import { callServer } from "rari/runtime/call-server";
896
- `;for(let t of e){let e=`${a}#${t}`,n=JSON.stringify(e);o+=t==="default"?`export default createServerReference(${n}, callServer);\n`:`export const ${t} = createServerReference(${n}, callServer);\n`}return o}if(a)return console.warn(`[rari] Server component ${n} should not be imported in client bundle`),``;if(!r.topLevelUseClient)return t;let o=be(t,r);if(o.length===0)return``;let s=JSON.stringify(n),c=`import {registerClientReference} from "react-server-dom-rari/server";
897
- `;for(let e of o){if(e==="default"){let e=`Attempted to call the default export of ${n} from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;c+=`export default `,c+=`registerClientReference(function() {`,c+=`throw new Error(${JSON.stringify(e)});`}else{let t=`Attempted to call ${e}() from the server but ${e} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;c+=`export const ${e} = `,c+=`registerClientReference(function() {`,c+=`throw new Error(${JSON.stringify(t)});`}c+=`},`,c+=`${s},`,c+=`${JSON.stringify(e)});\n`}return c}function Ce(e,t,n){return!n.topLevelUseClient||be(e,n).length===0?e:e.replace(zf,``)}let we=!1;async function Te(){let e=`http://localhost:${qe()}`;try{let t=(await fetch(`${e}/_rari/health`,{signal:AbortSignal.timeout(1e3)})).ok;return we=t,t}catch{return we=!1,!1}}let Ee=null;async function ke(e){return await Te()?!0:(Ee??=(async()=>{try{let t=Date.now()+e,n=50;for(;Date.now()<t;){if(await new Promise(e=>{setTimeout(e,Math.min(n,t-Date.now()))}),await Te())return!0;n=Math.min(n*2,500)}return!1}finally{Ee=null}})(),Ee)}let x={name:`rari`,config(e,{command:t}){if(e.appType=`custom`,e.define??={},t===`serve`||C.env.RARI_SERVER_URL!=null&&C.env.RARI_SERVER_URL!==``||C.env.RARI_HOST!=null&&C.env.RARI_HOST!==``){let t=qe(),n;if(C.env.RARI_SERVER_URL!=null&&C.env.RARI_SERVER_URL!==``)n=C.env.RARI_SERVER_URL;else if(C.env.RARI_HOST!=null&&C.env.RARI_HOST!==``){let e=C.env.RARI_HOST.startsWith(`http`)?C.env.RARI_HOST:`http://${C.env.RARI_HOST}`;n=e.replace(re,``).includes(`:`)?e:`${e}:${t}`}else n=`http://localhost:${t}`;e.define[`import.meta.env.RARI_SERVER_URL`]=JSON.stringify(n)}let n=typeof e.css?.modules==`object`?e.css.modules:{};e.css={...e.css,transformer:e.css?.transformer??`lightningcss`,modules:{...n,pattern:`[hash]_[local]`}},e.resolve??={};let r=e.resolve,a=Array.isArray(r.dedupe)?r.dedupe:[];r.dedupe=[...new Set(a).union(/* @__PURE__ */ new Set([`react`,`react-dom`]))];let o=[];i(r.alias)?o=r.alias:l(r.alias)&&(o=c(r.alias)),o=o.map(e=>e.find===`react`?{find:/^react$/,replacement:e.replacement}:e);let s=new Set(o.map(e=>String(e.find))),u=o.some(e=>Uf(e.find));try{let e=w(import.meta.resolve(`react`)),t=w(import.meta.resolve(`react-dom/client`)),n=w(import.meta.resolve(`react/jsx-runtime`)),i=[];s.has(`react/jsx-runtime`)||i.push({find:`react/jsx-runtime`,replacement:n});try{let e=w(import.meta.resolve(`react/jsx-dev-runtime`));s.has(`react/jsx-dev-runtime`)||i.push({find:`react/jsx-dev-runtime`,replacement:e})}catch(e){Hf(e)||console.warn(`[rari] Unexpected error resolving react/jsx-dev-runtime:`,e)}try{let e=w(import.meta.resolve(`react/compiler-runtime`));s.has(`react/compiler-runtime`)||i.push({find:`react/compiler-runtime`,replacement:e})}catch(e){Hf(e)||console.warn(`[rari] Unexpected error resolving react/compiler-runtime:`,e)}u||i.push({find:/^react$/,replacement:e}),s.has(`react-dom/client`)||i.push({find:`react-dom/client`,replacement:t}),r.alias=[...o,...i]}catch(e){Hf(e)||console.warn(`[rari] Unexpected error configuring React aliases:`,e)}e.environments??={},e.environments.rsc={consumer:`server`,resolve:{conditions:[`react-server`,`node`,`import`]},build:{outDir:`dist/server`,write:!1,copyPublicDir:!1,emitAssets:!0},...e.environments.rsc},e.environments.ssr={consumer:`server`,resolve:{conditions:[`node`,`import`]},build:{outDir:`dist/ssr`,write:!1,copyPublicDir:!1,emitAssets:!0},...e.environments.ssr},e.environments.client={consumer:`client`,resolve:{conditions:[`browser`,`import`]},...e.environments.client},e.builder??={},e.builder.sharedPlugins=!0,e.builder.sharedConfigBuild=!1,e.optimizeDeps??={},e.optimizeDeps.include??=[];for(let t of[`react`,`react-dom`,`react-dom/client`,`react-dom/server`,`react/jsx-runtime`,`react/jsx-dev-runtime`])e.optimizeDeps.include.includes(t)||e.optimizeDeps.include.push(t);if(e.optimizeDeps.exclude??=[],e.optimizeDeps.exclude.includes(`rari`)||e.optimizeDeps.exclude.push(`rari`),t===`build`)for(let t of[`rsc`,`ssr`,`client`]){let n=e.environments[t];n.build!=null&&(n.build.rolldownOptions??={})}e.server??={},e.server.proxy??={};let d=qe();if(e.server.proxy[`/api`]={target:`http://localhost:${d}`,changeOrigin:!0,secure:!1,ws:!0},e.server.proxy[`/_rari`]={target:`http://localhost:${d}`,changeOrigin:!0,secure:!1,ws:!0},t===`build`){e.build??={},e.build.rolldownOptions??={},e.build.rolldownOptions.input={main:er},e.build.rolldownOptions.output??={};let t=Array.isArray(e.build.rolldownOptions.output)?e.build.rolldownOptions.output:[e.build.rolldownOptions.output];for(let e of t)if(e.codeSplitting!==!1&&typeof e.codeSplitting!=`object`&&(e.codeSplitting={}),typeof e.codeSplitting==`object`){e.codeSplitting.groups??=[];let t=e.codeSplitting.groups;e.codeSplitting.groups.push({name(e){if(e.includes(`node_modules`)){for(let n of t)if(n.test!=null){let t=!1;if(typeof n.test==`function`?t=!!n.test(e):n.test instanceof RegExp?t=n.test.test(e):typeof n.test==`string`&&(t=e.includes(n.test)),t)return null}return e.includes(`node_modules/react-dom`)?`react-dom`:e.includes(`node_modules/react`)?`react`:`vendor`}return null}})}}e.environments.client.build??={},e.environments.client.build.rolldownOptions??={},e.environments.client.build.rolldownOptions.input={main:er},e.environments.client.build.rolldownOptions.external??=[];let f=e.environments.client.build.rolldownOptions.external;if(Array.isArray(f)){let e=f.indexOf(`react-server-dom-webpack/client`);e!==-1&&f.splice(e,1)}return e},async buildStart(){if(ir(),e.experimental?.useCache||e.experimental?.useCacheRemote)try{await uf()}catch(e){this.error(e instanceof Error?e:Error(String(e)))}},configResolved(e){let t=Kt(e);m=t.assetsDir,h=t.outDir,Object.assign(p,Gt(e))},async transform(t,n){if(n.endsWith(`.mdx`)&&_(),/\.(?:tsx?|jsx?|mts|mjs)$/.test(n)&&t.includes(`defineMdxComponents`)){let r=tc({code:t,id:n,projectRoot:e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:C.cwd(),resolvedAlias:p});if(r!=null&&r!==``)return{code:r,map:null}}if(!v.test(n))return null;let r=!1;if(e.experimental?.useCache||e.experimental?.useCacheRemote){let e=await uf();if(e){let i=e(t,n);i!=null&&i!==``&&(t=i,r=!0)}}let i=this.environment,o=n.startsWith(`\0`)||n.includes(`virtual:`)?mn(t):(()=>{try{return a.get(n)}catch{return mn(t)}})();if(o.topLevelUseServer)return ae(n,`server`),i.name===`rsc`?xe(t,n,o):Se(t,n,o);if(o.topLevelUseClient){ae(n,`client`),ce(n);for(let e of o.importSources){if(!Bf.test(e)&&!Vf(e,p))continue;let t=_e(e,n,p);b.existsSync(t)&&(a.get(t).topLevelUseServer||(ae(t,`client`),ce(t)))}return Ce(t,n,o)}if(i.name!==`rsc`&&i.name!==`ssr`&&(ne(n)===`client`||ue(n)))return Ce(t,n,o);function s(e){if(!b.existsSync(e))return!1;try{return a.get(e).topLevelUseClient}catch{return!1}}function c(e,t){let n=e,r=[],i=/* @__PURE__ */ new Set;for(let e of yn(n)){if(e.typeOnly||e.sideEffectOnly||!Bf.test(e.source)&&!Vf(e.source,p))continue;let n=_e(e.source,t,p);if(!s(n))continue;ae(n,`client`),ce(n);let a=Cs(e,ie(n));if(a.code!==``){for(let e of a.helpers)i.add(e);r.push({start:e.start,end:e.end,replacement:a.code})}}if(r.length===0)return n;for(let{start:e,end:t,replacement:i}of[...r].sort((e,t)=>t.start-e.start))n=n.slice(0,e)+i+n.slice(t);return i.size>0&&(n=bs(n,`react-server-dom-rari/server`,[...i])),n}if(ye(n)){if(ae(n,`server`),i.name===`rsc`||i.name===`ssr`)return c(xe(t,n,o),n);{let e=Se(t,n,o);return e=`// HMR acceptance for server component
898
- if (import.meta.hot) {
899
- import.meta.hot.accept();
900
- if (typeof globalThis !== 'undefined') {
901
- if (!globalThis['~rari']) globalThis['~rari'] = {};
902
- globalThis['~rari'].serverComponents = globalThis['~rari'].serverComponents || new Set();
903
- globalThis['~rari'].serverComponents.add(${JSON.stringify(n)});
904
- }
905
830
  }
906
831
 
907
- ${e}`,e}}let l=ne(n);if(l===`server`)return i.name===`rsc`||i.name===`ssr`?c(xe(t,n,o),n):Se(t,n,o);if(l===`client`)return Ce(t,n,o);ae(n,`unknown`);let u=t,d=!1,f=!1,m=n.includes(`entry-client`),h=[],g=/* @__PURE__ */ new Set;for(let e of yn(t)){if(e.typeOnly||e.sideEffectOnly||!Bf.test(e.source)&&!Vf(e.source,p))continue;let t=_e(e.source,n,p),r=s(t);if(r&&(ae(t,`client`),ce(t)),!r||m||i.name!==`rsc`&&i.name!==`ssr`)continue;let a=Cs(e,ie(t));if(a.code!==``){for(let e of a.helpers)g.add(e);h.push({start:e.start,end:e.end,replacement:a.code}),d=!0,f=!0}}for(let{start:e,end:t,replacement:n}of[...h].sort((e,t)=>t.start-e.start))u=u.slice(0,e)+n+u.slice(t);if(g.size>0&&(u=bs(u,`react-server-dom-rari/server`,[...g])),d){let e=u.includes(`import React`)||Wf.test(u)||Gf.test(u),t=``;if(f&&!e&&(t+=`import React from 'react';
908
- `),t&&(u=t+u),!u.includes(`Suspense`)){let e=Kf.exec(u);e&&(e[1]&&!e[2].includes(`Suspense`)?u=u.replace(e[0],e[0].replace(Yf,`{ Suspense, $1 }`)):e[1]||(u=u.replace(e[0],`import React, { Suspense } from 'react';`)))}let r=C.env.NODE_ENV!==`production`;return(u.includes(`</`)||u.includes(`/>`)||Jf.test(u))&&r&&(u=`'use client';\n\n${u}`,ae(n,`client`)),u}return r?t:null},async configureServer(t){let n=S.resolve(e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:C.cwd()),r=S.join(n,`src`);await lp(n,e,m,h);let i=async()=>{try{let i=new ms(n,{outDir:h,rscDir:`server`,manifestPath:`server/manifest.json`,serverConfigPath:`server/config.json`,alias:p,assetsDir:m,csp:e.csp,cacheControl:e.cacheControl,cache:e.cache,action:e.action,jsPoolSize:e.jsPoolSize,origin:e.origin,htmlLimitedBots:e.htmlLimitedBots,experimental:e.experimental,moduleAnalysisCache:a});if(i.setViteBuilder(await me({root:n,configFile:t.config.configFile,logLevel:`error`})),o=i,f??=new ta(i,qe()),b.existsSync(r)){let e=vs(r,i,Object.values(p));e.serverComponentPaths.length>0&&t.ws.send({type:`custom`,event:`rari:server-components-registry`,data:{serverComponents:e.serverComponentPaths}})}let c=await i.getTransformedComponentsForDevelopment(),l=`http://localhost:${qe()}`;await Promise.all(c.map(async e=>{try{if(e.id.startsWith(`app/`)||e.isAction)return;let t=await fetch(`${l}/_rari/register`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:e.id,component_code:e.code})});if(!t.ok){let e=await t.text();throw Error(`HTTP ${t.status}: ${e}`)}}catch(t){console.error(`[rari] Runtime: Failed to register component ${e.id}:`,s(t,String(t)))}}))}catch(e){console.error(`[rari] Runtime: Component discovery failed:`,s(e,String(e)))}},c=async()=>{try{let e=`http://localhost:${qe()}`,t=ve();await Promise.all([...t].map(async t=>{let n=S.relative(C.cwd(),t),r=S.basename(t).replace(le,``);try{await fetch(`${e}/_rari/register-client`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:r,file_path:n,export_name:`default`})})}catch(e){console.error(`[rari] Runtime: Failed to pre-register client component ${r}:`,e)}}))}catch(e){console.error(`[rari] Runtime: Failed to pre-register client components:`,e)}},g=async()=>{if(u)return;let{getBinaryPath:r,getInstallationInstructions:a}=await import(`./platform.mjs`),o;try{o=r()}catch(e){console.error(`rari binary not found`),console.error(` ${s(e,String(e))}`),console.error(a());return}let l=qe(),d=C.env.NODE_ENV===`production`?`production`:`development`,f=t.config.server.port,m=e.origin?.trim().replace(/\/+$/,``),h=C.env.RARI_ORIGIN?.trim().replace(/\/+$/,``),g=dr(n,p),_=[`--mode`,d,`--port`,l.toString(),`--host`,`127.0.0.1`];u=Oe(o,_,{stdio:[`ignore`,`pipe`,`pipe`],cwd:n,env:{...C.env,RUST_LOG:C.env.RUST_LOG!=null&&C.env.RUST_LOG!==``?C.env.RUST_LOG:`error`,RARI_VITE_PORT:f.toString(),...g.length>0?{RARI_DEV_LAYOUT_CSS:g.join(`,`)}:{},...e.jsPoolSize!=null&&(C.env.RARI_JS_POOL_SIZE==null||C.env.RARI_JS_POOL_SIZE===``)?{RARI_JS_POOL_SIZE:String(e.jsPoolSize)}:{},...m!=null&&m!==``&&(h==null||h===``)?{RARI_ORIGIN:m}:{},...e.htmlLimitedBots!=null&&(C.env.RARI_HTML_LIMITED_BOTS==null||C.env.RARI_HTML_LIMITED_BOTS===``)?{RARI_HTML_LIMITED_BOTS:e.htmlLimitedBots}:{}}}),u.stdout?.on(`data`,e=>{let t=e.toString().trim();t&&console.error(t)}),u.stderr?.on(`data`,e=>{let t=e.toString().trim();t&&!t.includes(`warning`)&&console.error(t)}),u.on(`error`,e=>{we=!1,console.error(`Failed to start rari server:`,e.message),e.message.includes(`ENOENT`)&&console.error(` Binary not found. Please ensure rari is properly installed.`)}),u.on(`exit`,(e,t)=>{u=null,we=!1,t?console.error(`rari server stopped by signal ${t}`):e===0?console.error(`rari server stopped successfully`):e&&console.error(`rari server exited with code ${e}`)}),await ke(1e4)?(await i(),await c()):console.error(`Server failed to become ready for component registration`)},_=async e=>{try{if(!ye(e))return;o??await i();let t=o;if(t==null)return;let n=a.getSource(e);t.addServerComponent(e,n);let r=Zi(t.getImportGraph(),[e]);r.add(e);let c=await t.getTransformedComponentsForDevelopment(e=>r.has(e));if(c.length===0)return;let l=`http://localhost:${qe()}`;await Promise.all(c.map(async e=>{try{let t=await fetch(`${l}/_rari/register`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:e.id,component_code:e.code})});if(!t.ok){let e=await t.text();throw Error(`HTTP ${t.status}: ${e}`)}}catch(t){console.error(`[rari] Failed to register component`,`${e.id}:`,s(t,String(t)))}}))}catch(t){console.error(`[rari] Targeted HMR failed for`,`${e}:`,s(t,String(t)))}};g().catch(e=>{console.error(`[rari] Failed to start Rust server:`,e)}),t.middlewares.use((e,t,n)=>{(async()=>{let r=e.headers.accept,i=e.method??`GET`,a=e.url??``,o=de(a),s=r!=null&&r!==``&&r.includes(`text/x-component`),c=(i===`GET`||i===`HEAD`)&&r?.includes(`text/html`)&&!o.startsWith(`/@`)&&!Af(o,`/node_modules`)&&!Af(o,`/api`)&&!Af(o,`/_rari`)&&!Af(o,`/vite-server`)&&!kf(o);if((s||c)&&a!==``&&!Af(o,`/api`)&&!Af(o,`/rsc`)){if(!we&&!await ke(1e4)){console.error(`[rari] Rust server not ready, cannot proxy ${s?`RSC`:`HTML`} request`),t.headersSent||(t.statusCode=503,t.end(`Server not ready`));return}let n=qe(),r=`http://localhost:${n}${a}`;try{let a={};for(let[t,n]of Object.entries(e.headers))typeof n==`string`?a[t]=n:Array.isArray(n)&&(a[t]=n.join(`,`));a.host=`localhost:${n}`,a[`accept-encoding`]=`identity`;let o=i!==`GET`&&i!==`HEAD`?await Of(e,10485760):void 0,s=await fetch(r,{method:i,headers:a,...o==null?{}:{body:o}});if(t.statusCode=s.status,s.headers.forEach((e,n)=>{n.toLowerCase()!==`content-encoding`&&t.setHeader(n,e)}),i===`HEAD`||!s.body){t.end();return}let c=s.body.getReader();try{let e=!1;for(;!e;){let{done:n,value:r}=await c.read();e=n,!e&&r!=null&&t.write(De.from(r))}t.end()}catch(e){console.error(`[rari] Stream error:`,e),t.headersSent||(t.statusCode=500),t.end()}return}catch(e){if((l(e)&&typeof e.statusCode==`number`?e.statusCode:void 0)===413){t.headersSent||(t.statusCode=413,t.end(`Request Entity Too Large`));return}console.error(`[rari] Failed to proxy ${s?`RSC`:`HTML`} request:`,e),t.headersSent||(t.statusCode=500,t.end(`Internal Server Error`));return}}n()})()}),t.watcher.on(`change`,e=>{(async()=>{v.test(e)&&(se(e),fe(e),a.invalidate(e)),v.test(e)&&pe(e,r)&&ye(e)&&(t.ws.send({type:`custom`,event:`rari:register-server-component`,data:{filePath:e}}),await _(e))})()}),t.middlewares.use(`/api/vite/hmr-transform`,(e,t)=>{if(e.method!==`POST`){t.statusCode=405,t.end(`Method Not Allowed`);return}(async()=>{try{let n=await je(e),r=d(n),i=r&&typeof r.filePath==`string`?r.filePath:void 0;if(i==null||i===``){t.statusCode=400,t.end(JSON.stringify({error:`filePath is required`}));return}await _(i),t.statusCode=200,t.setHeader(`Content-Type`,`application/json`),t.end(JSON.stringify({success:!0,filePath:i,message:`Component transformation completed`}))}catch(e){t.statusCode=500,t.setHeader(`Content-Type`,`application/json`),t.end(JSON.stringify({success:!1,error:s(e,String(e))}))}})()}),t.httpServer?.on(`close`,()=>{if(ge(n),o!=null&&(o.setViteBuilder(null),o=null),f&&=(f.dispose(),null),u){let e=u;u=null,we=!1;let t=!1,n=setTimeout(()=>{t||e.kill(`SIGKILL`)},5e3);n.unref(),e.once(`exit`,()=>{t=!0,clearTimeout(n)}),e.kill(`SIGTERM`);return}we=!1})},resolveId(e,t){if(e===`virtual:rsc-integration`||e===`virtual:rsc-integration.ts`)return`virtual:rsc-integration.ts`;if(e===`virtual:rari-entry-client`||e===`virtual:rari-entry-client.ts`)return`virtual:rari-entry-client.ts`;if(e===`virtual:react-flight-client`||e===`virtual:react-flight-client.ts`)return`virtual:react-flight-client.ts`;if(e===`virtual:app-router-provider`||e===`virtual:app-router-provider.tsx`)return`virtual:app-router-provider.tsx`;if(e===`virtual:client-router`||e===`virtual:client-router.tsx`)return`virtual:client-router.tsx`;if(e===`virtual:error-boundary-wrapper`||e===`virtual:error-boundary-wrapper.tsx`)return`virtual:error-boundary-wrapper.tsx`;if(Ha(e)||e===`virtual:rari-mdx-components`||e===`virtual:rari-mdx-components.ts`)return`virtual:rari-mdx-components.ts`;if(e===`react-server-dom-webpack/client`||e===`react-server-dom-webpack/client.browser`)return`virtual:react-flight-client.ts`;if(e===`./LoadingErrorBoundary`||e===`./LoadingErrorBoundary.tsx`)return`virtual:loading-error-boundary.tsx`;if(e===`react-server-dom-rari/server`)return e;if(t!=null&&t!==``&&t.startsWith(`virtual:`)&&e.startsWith(`./`)){let t=ip(S.basename(e));if(t!=null&&t!==``)return t}if(t!=null&&t!==``&&t.startsWith(`virtual:`)&&e.startsWith(`../`)){let n=import.meta.url,r=w(n),i=S.dirname(r),a=null,o=[S.join(i,`runtime`),S.join(i,`../runtime`)];for(let e of o)if(b.existsSync(e)){a=e;break}if(a!=null&&a!==``){let t=S.join(a,e);if(b.existsSync(t))return t;let n=S.join(a,`../dist`,S.basename(e));if(b.existsSync(n))return n}else console.warn(`[rari] Runtime directory not found, attempting fallback resolution for virtual import.\n Importer: ${t}\n ID: ${e}\n Current Dir: ${i}\n Hint: Runtime lookup failed, trying currentDir as fallback`);let s=S.join(i,e);if(b.existsSync(s))return s;let c=S.join(i,`../dist`,S.basename(e));if(b.existsSync(c))return c}if(C.env.NODE_ENV===`production`)try{let t=S.resolve(e);if(b.existsSync(t)&&ye(t))return{id:e,external:!0}}catch(t){n(t)!==`ENOENT`&&console.warn(`[rari] Unexpected error resolving server component:`,e,t)}return null},async load(t){if(v.test(t)&&this.environment.name===`client`)try{let e=a.get(t);if(e.topLevelUseServer)return Se(a.getSource(t),t,e)}catch{}if(t===`virtual:rari-mdx-components.ts`)return ee();if(t===`virtual:rari-entry-client.ts`){let t=e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:C.cwd(),r=Xn(Hn(S.join(t,`src`),Object.values(p)),a),i=ve().union(new Set(r)),o=[{path:`rari/image`,exports:[`Image`]},{path:`virtual:error-boundary-wrapper.tsx`,exports:[`ErrorBoundaryWrapper`]}],s=[...i].filter(e=>{try{return a.get(e).topLevelUseClient}catch{return!1}}).map(e=>{let t=y(S.relative(C.cwd(),e)),r=t.replace(v,``),i=t.startsWith(`..`)?y(e):t,o=!1,s=``;try{if(!a.get(e).hasDefaultExport){let t=a.getSource(e).match(oe);t&&(o=!0,s=t[1])}}catch(t){n(t)!==`ENOENT`&&console.warn(`[rari] Unexpected error reading component for export detection:`,e,t)}let c=o?s:`default`,l=o?s:S.basename(e,S.extname(e)),u=y(i),d=u.startsWith(`/`)||te.test(u)?u:`/${u}`;return` "${i}": {
832
+ export function createFromReadableStream(stream, options) {
833
+ return module.exports.createFromReadableStream(stream, {
834
+ ...options,
835
+ callServer: options?.callServer ?? rariCallServer,
836
+ findSourceMapURL: options?.findSourceMapURL ?? rariFindSourceMapURL,
837
+ });
838
+ }
839
+
840
+ export function createServerReference(id, callServer, encodeFormAction, findSourceMapURL, functionName) {
841
+ return module.exports.createServerReference(
842
+ id,
843
+ callServer ?? rariCallServer,
844
+ encodeFormAction,
845
+ findSourceMapURL ?? rariFindSourceMapURL,
846
+ functionName,
847
+ );
848
+ }
849
+
850
+ export const encodeReply = module.exports.encodeReply;
851
+ export const createTemporaryReferenceSet = module.exports.createTemporaryReferenceSet;
852
+ `}}function Zd(e,t){let n=k.relative(t,e),r=!n.startsWith(`..`)&&!k.isAbsolute(n),i=e.includes(`${k.sep}node_modules${k.sep}`),a=e.includes(`${k.sep}packages${k.sep}rari${k.sep}`)||e.includes(`${k.sep}packages${k.sep}use-cache${k.sep}`)||e.includes(`${k.sep}node_modules${k.sep}rari${k.sep}`)||e.includes(`${k.sep}node_modules${k.sep}@rari${k.sep}use-cache${k.sep}`);return r||i||a}function Qd(e,t){if(!e.endsWith(`.mjs`)||!D.existsSync(e))return null;try{return Zd(D.realpathSync(e),t)?D.readFileSync(e,`utf-8`):(console.warn(`[rari] Refusing to load .mjs file outside project root and node_modules: ${e}`),null)}catch(t){return console.warn(`[rari] Error validating .mjs file path: ${e}`,t),null}}const $d=/* @__PURE__ */ new Map([[`virtual:app-router-provider.tsx`,`AppRouterProvider.mjs`],[`virtual:client-router.tsx`,`ClientRouter.mjs`]]);async function ef(e,t){if(e===`virtual:rari-mdx-components.ts`)return t.buildMdxRegistryModule();if(e===`virtual:rari-entry-client.ts`)return mf(t.resolveProjectRoot(),t.resolvedAlias,t.moduleAnalysisCache,t.getKnownClientComponentPaths);if(e===`react-server-dom-rari/server`)return Hd();let n=$d.get(e);if(n!=null)return Kd(n);if(e===`virtual:error-boundary-wrapper.tsx`)return qd(Kd(`ErrorBoundaryWrapper.mjs`));if(e===`virtual:rsc-integration.ts`)return(await Bd()).replace(Dd,(e,t,n)=>`from${t}${n}virtual:react-flight-client.ts${n}`);if(e===`virtual:react-flight-client.ts`)return Xd(t.environmentMode===`dev`?`development`:`production`)}function tf(e,t){if(A.env.NODE_ENV!==`production`)return null;try{let n=k.resolve(e);if(D.existsSync(n)&&t(n))return{id:e,external:!0}}catch(t){r(t)!==`ENOENT`&&console.warn(`[rari] Unexpected error resolving server component:`,e,t)}return null}function nf(e,t){if(!e.includes(`node_modules`))return null;for(let n of t){if(n.test==null)continue;let t=!1;if(typeof n.test==`function`){let r=n.test;t=!!r(e)}else n.test instanceof RegExp?t=n.test.test(e):typeof n.test==`string`&&(t=e.includes(n.test));if(t)return null}return e.includes(`node_modules/react-dom`)?`react-dom`:e.includes(`node_modules/react`)?`react`:`vendor`}function rf(e,t,n){return(e===`GET`||e===`HEAD`)&&(t?.includes(`text/html`)??!1)&&!n.startsWith(`/@`)&&!$(n,`/node_modules`)&&!$(n,`/api`)&&!$(n,`/_rari`)&&!$(n,`/assets`)&&!$(n,`/vite-server`)&&!ud(n)}function af(e,t){let n={};for(let[t,r]of Object.entries(e))typeof r==`string`?n[t]=r:Array.isArray(r)&&(n[t]=r.join(`,`));return n.host=`localhost:${t}`,n[`accept-encoding`]=`identity`,n}async function of(e,t,n){if(n===`HEAD`||!e.body){t.end();return}let r=e.body.getReader();try{let e=!1;for(;!e;){let{done:n,value:i}=await r.read();e=n,!e&&i!=null&&t.write(we.from(i))}t.end()}catch(e){console.error(`[rari] Stream error:`,e),t.headersSent||(t.statusCode=500),t.end()}}const sf=/* @__PURE__ */ new Map([[`virtual:rsc-integration`,`virtual:rsc-integration.ts`],[`virtual:rsc-integration.ts`,`virtual:rsc-integration.ts`],[`virtual:rari-entry-client`,`virtual:rari-entry-client.ts`],[`virtual:rari-entry-client.ts`,`virtual:rari-entry-client.ts`],[`virtual:react-flight-client`,`virtual:react-flight-client.ts`],[`virtual:react-flight-client.ts`,`virtual:react-flight-client.ts`],[`virtual:app-router-provider`,`virtual:app-router-provider.tsx`],[`virtual:app-router-provider.tsx`,`virtual:app-router-provider.tsx`],[`virtual:client-router`,`virtual:client-router.tsx`],[`virtual:client-router.tsx`,`virtual:client-router.tsx`],[`virtual:error-boundary-wrapper`,`virtual:error-boundary-wrapper.tsx`],[`virtual:error-boundary-wrapper.tsx`,`virtual:error-boundary-wrapper.tsx`],[`virtual:rari-mdx-components`,`virtual:rari-mdx-components.ts`],[`virtual:rari-mdx-components.ts`,`virtual:rari-mdx-components.ts`]]);function cf(e){return xs(e)?`virtual:rari-mdx-components.ts`:sf.get(e)??null}function lf(e){for(let t of e)if(D.existsSync(t))return t;return null}function uf(e,t){if(e.startsWith(`./`)){let t=Rd(k.basename(e));return t!=null&&t!==``?t:null}if(!e.startsWith(`../`))return null;let n=k.dirname(j(import.meta.url)),r=lf([k.join(n,`runtime`),k.join(n,`../runtime`)]);if(r!=null){let t=lf([k.join(r,e),k.join(r,`../dist`,k.basename(e))]);if(t!=null)return t}else console.warn(`[rari] Runtime directory not found, attempting fallback resolution for virtual import.\n Importer: ${t}\n ID: ${e}\n Current Dir: ${n}\n Hint: Runtime lookup failed, trying currentDir as fallback`);return lf([k.join(n,e),k.join(n,`../dist`,k.basename(e))])}function df(e,t){let n=!1,i=``;try{if(!t.get(e).hasDefaultExport){let r=t.getSource(e).match(x);r&&(n=!0,i=r[1])}}catch(t){r(t)!==`ENOENT`&&console.warn(`[rari] Unexpected error reading component for export detection:`,e,t)}return{exportName:n?i:`default`,displayName:n?i:k.basename(e,k.extname(e))}}function ff(e,t){let n=T(k.relative(A.cwd(),e)),r=n.replace(S,``),i=n.startsWith(`..`)?T(e):n,{exportName:a,displayName:o}=df(e,t),s=T(i),c=s.startsWith(`/`)||ne.test(s)?s:`/${s}`;return` "${i}": {
909
853
  id: "${r}",
910
854
  path: "${i}",
911
- exportName: "${c}",
912
- displayName: "${l}",
855
+ exportName: "${a}",
856
+ displayName: "${o}",
913
857
  type: "client",
914
- loader: () => ${`import(${JSON.stringify(d)})`},
858
+ loader: () => import(${JSON.stringify(c)}),
915
859
  component: null,
916
860
  loading: false,
917
861
  registered: false
918
- }`}).join(`,
919
- `),c=o.map((e,t)=>`import * as ExternalModule${t} from '${e.path}';`).join(`
920
- `),l=o.flatMap((e,t)=>e.exports.map(n=>`
862
+ }`}function pf(e){return{imports:e.map((e,t)=>`import * as ExternalModule${t} from '${e.path}';`).join(`
863
+ `),registrations:e.flatMap((e,t)=>e.exports.map(n=>{let r=`${e.path}#${n}`;return`
921
864
  globalThis['~clientComponents'] = globalThis['~clientComponents'] || {};
922
- globalThis['~clientComponents']["${`${e.path}#${n}`}"] = {
923
- id: "${n}",
924
- path: "${e.path}",
925
- type: "client",
926
- component: ExternalModule${t},
927
- registered: true
928
- };
929
- globalThis['~clientComponents']["${e.path}"] = globalThis['~clientComponents']["${e.path}"] || {};
930
- globalThis['~clientComponents']["${e.path}"].component = ExternalModule${t};
865
+ {
866
+ const entry = {
867
+ id: "${n}",
868
+ path: "${e.path}",
869
+ type: "client",
870
+ component: ExternalModule${t},
871
+ registered: true
872
+ };
873
+ globalThis['~clientComponents']["${r}"] = entry;
874
+ globalThis['~clientComponents']["${e.path}"] = entry;
875
+ }
931
876
  globalThis['~clientComponentPaths'] = globalThis['~clientComponentPaths'] || {};
932
- globalThis['~clientComponentPaths']["${e.path}"] = "${n}";`)).join(`
933
- `);return sp(c,[`
877
+ globalThis['~clientComponentPaths']["${e.path}"] = "${n}";`})).join(`
878
+ `)}}async function mf(e,t,n,r){let i=Er(yr(k.join(e,`src`),Object.values(t)),n),a=r().union(new Set(i)),o=[{path:`rari/image`,exports:[`Image`]},{path:`virtual:error-boundary-wrapper.tsx`,exports:[`ErrorBoundaryWrapper`]}],s=[...a].filter(e=>{try{return n.get(e).topLevelUseClient}catch{return!1}}).map(e=>ff(e,n)).join(`,
879
+ `),c=pf(o),l=[`
934
880
  const lazyComponentRegistry = {
935
881
  ${s}
936
882
  };
@@ -942,36 +888,34 @@ for (const [path, config] of Object.entries(lazyComponentRegistry)) {
942
888
  globalThis['~clientComponents'][fullId] = config;
943
889
  globalThis['~clientComponentPaths'][path] = config.id;
944
890
  }
945
- `,l].filter(Boolean).join(`
946
- `),pr(t,p))}if(t===`react-server-dom-rari/server`)return cp();if(t===`virtual:app-router-provider.tsx`){let e=ip(`AppRouterProvider.mjs`);if(e!=null&&e!==``)return b.readFileSync(e,`utf-8`);throw Error(Ef)}if(t===`virtual:client-router.tsx`){let e=ip(`ClientRouter.mjs`);if(e!=null&&e!==``)return b.readFileSync(e,`utf-8`);throw Error(Ef)}if(t===`virtual:loading-error-boundary.tsx`){let e=ip(`LoadingErrorBoundary.mjs`);if(e!=null&&e!==``)return b.readFileSync(e,`utf-8`);throw Error(Ef)}if(t===`virtual:error-boundary-wrapper.tsx`){let e=ip(`ErrorBoundaryWrapper.mjs`);if(e!=null&&e!==``){let t=b.readFileSync(e,`utf-8`);if(!t.includes(`import React`)&&!t.includes(`from "react"`)&&!t.includes(`from 'react'`)){let e=Xf.exec(t);if(e){let n=e[0];return`
947
- ${n}import * as React from 'react';\n${t.slice(n.length)}`}return`
948
- import * as React from 'react';\n${t}`}return t}throw Error(Ef)}if(t===`virtual:rsc-integration.ts`)return(await op()).replace(qf,(e,t,n)=>`from${t}${n}virtual:react-flight-client.ts${n}`);if(t===`virtual:react-flight-client.ts`){let e,t;try{let n=S.dirname(w(import.meta.resolve(`react-server-dom-webpack/package.json`)));e=S.join(n,`cjs/react-server-dom-webpack-client.browser.production.js`),t=S.join(n,`cjs/react-server-dom-webpack-client.edge.production.js`)}catch{let n=S.dirname(w(import.meta.url)),r=S.resolve(n,`../../node_modules`);e=S.join(r,`react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.js`),t=S.join(r,`react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.js`)}return{code:`
949
- import * as React from 'react';
950
- import * as ReactDOM from 'react-dom';
951
- import { callServer as rariCallServer } from 'rari/runtime/call-server';
891
+ `,c.registrations].filter(Boolean).join(`
892
+ `),u=Ur(e,t);return Vd(c.imports,l,u)}function hf(e){e.build??={},e.build.outDir??=`dist/client`,e.environments??={},e.environments.rsc={consumer:`server`,resolve:{conditions:[`react-server`,`node`,`import`]},build:{outDir:`dist/server`,write:!1,copyPublicDir:!1,emitAssets:!0},...e.environments.rsc},e.environments.ssr={consumer:`server`,resolve:{conditions:[`node`,`import`]},build:{outDir:`dist/ssr`,write:!1,copyPublicDir:!1,emitAssets:!0},...e.environments.ssr},e.environments.client={consumer:`client`,resolve:{conditions:[`browser`,`import`]},build:{outDir:e.build.outDir,copyPublicDir:!0},...e.environments.client}}function gf(e){e.optimizeDeps??={},e.optimizeDeps.include??=[];for(let t of[`react`,`react-dom`,`react-dom/client`,`react-dom/server`,`react/jsx-runtime`,`react/jsx-dev-runtime`])e.optimizeDeps.include.includes(t)||e.optimizeDeps.include.push(t);e.optimizeDeps.exclude??=[],e.optimizeDeps.exclude.includes(`rari`)||e.optimizeDeps.exclude.push(`rari`)}function _f(e){e.server??={},e.server.proxy??={};let t={target:`http://localhost:${N()}`,changeOrigin:!0,secure:!1};e.server.proxy[`/api`]={...t,ws:!0},e.server.proxy[`/_rari`]={...t,ws:!0},e.server.proxy[`/assets`]=t}const vf=/* @__PURE__ */ new WeakMap;function yf(e){let t=!1;for(let n=e.length-1;n>=0;n--){let r=e[n];if(vf.has(r)){if(vf.get(r)===e){t=!0;continue}e.splice(n,1)}}if(t)return;let n={debugName:`rari-vendor`,name(t){return nf(t,e)}};vf.set(n,e),e.push(n)}function bf(e){e.build??={},e.build.rolldownOptions??={},e.build.rolldownOptions.input={main:Ar},e.build.rolldownOptions.output??={};let t=Array.isArray(e.build.rolldownOptions.output)?e.build.rolldownOptions.output:[e.build.rolldownOptions.output];for(let e of t)e.codeSplitting!==!1&&typeof e.codeSplitting!=`object`&&(e.codeSplitting={}),typeof e.codeSplitting==`object`&&(e.codeSplitting.groups??=[],yf(e.codeSplitting.groups))}function xf(e){e.environments.client.build??={},e.environments.client.build.rolldownOptions??={},e.environments.client.build.rolldownOptions.input={main:Ar},e.environments.client.build.rolldownOptions.external??=[];let t=e.environments.client.build.rolldownOptions.external;if(Array.isArray(t)){let e=t.indexOf(`react-server-dom-webpack/client`);e!==-1&&t.splice(e,1)}}function Sf(e){let t=[];return a(e.alias)?t=e.alias:u(e.alias)&&(t=l(e.alias)),t.map(e=>e.find===`react`?{find:/^react$/,replacement:e.replacement}:e)}function Cf(e,t,n){if((u(e)&&typeof e.statusCode==`number`?e.statusCode:void 0)===413){t.headersSent||(t.statusCode=413,t.end(`Request Entity Too Large`));return}console.error(`[rari] Failed to proxy ${n?`RSC`:`HTML`} request:`,e),t.headersSent||(t.statusCode=500,t.end(`Internal Server Error`))}function wf(e){return e}function Tf(e={}){if(e.jsPoolSize!=null){let t=e.jsPoolSize;if(!Number.isInteger(t)||t<1||!Number.isFinite(t))throw Error(`jsPoolSize must be a finite positive integer; received ${String(t)}`)}let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r=new Dr,i=null,a=null,o=null,s={},l=`assets`,u=k.join(A.cwd(),`dist`),d=null;function p(){d=null}function m(){return d!=null&&d!==``||(d=Ds(Es({projectRoot:e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:A.cwd(),mdxOptions:e.mdx,alias:s,cache:r}))),d}function h(e){return t.get(W(e))}function g(t){let n=e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:A.cwd(),r=T(k.relative(n,t));return r.startsWith(`..`)||k.isAbsolute(r)?T(t):r}function _(e,n){t.set(W(e),n)}function v(e){Tr(t,e)}function y(e){n.add(W(e))}function ee(e){return n.has(W(e))}function te(e){n.delete(e);try{n.delete(D.realpathSync(e))}catch{n.delete(k.resolve(e))}}function ne(){let e=new Set(n);if(i)for(let t of i.getClientComponentPaths())e.add(t);return e}function b(e){if(e.includes(`node_modules`)||zd(e))return!1;let t=W(e);try{return Tl(t,r.get(e))}catch{return!1}}function x(e,t){try{let n=new Set(zn(e));return(t?.hasDefaultExport??Un(e))&&n.add(`default`),[...n]}catch{return[]}}function re(e){return`${e}
952
893
 
953
- const module = { exports: {} };
954
- const exports = module.exports;
955
- (function(module, exports, require) {
956
- ${Ht(b.readFileSync(e,`utf-8`),b.readFileSync(t,`utf-8`))}
957
- })(module, module.exports, function require(id) {
958
- if (id === 'react') return React;
959
- if (id === 'react-dom') return ReactDOM;
960
- throw new Error('Cannot require "' + id + '" from react-server-dom-webpack client bundle');
961
- });
962
- export function createFromFetch(promise, options) {
963
- return module.exports.createFromFetch(promise, {
964
- ...options,
965
- callServer: options?.callServer ?? rariCallServer,
966
- });
967
- }
968
- export function createFromReadableStream(stream, options) {
969
- return module.exports.createFromReadableStream(stream, {
970
- ...options,
971
- callServer: options?.callServer ?? rariCallServer,
894
+ if (import.meta.hot) {
895
+ import.meta.hot.accept(() => {
972
896
  });
897
+ }`}function ae(e,t){let n=vd.exec(e);if(n){let r=n[1];return e+=`
898
+ // Register server reference for default export
899
+ `,e+=`registerServerReference(${r}, ${t}, ${JSON.stringify(`default`)});\n`,e}let r=`__default_export__`,i=hr(e,r);return i==null?e:(e=i,e+=`
900
+ // Register server reference for default export
901
+ `,e+=`if (typeof ${r} === "function") {\n`,e+=` registerServerReference(${r}, ${t}, ${JSON.stringify(`default`)});\n`,e+=`}
902
+ `,e)}function C(e,t,n){return e+=`\n// Register server reference for ${t}\n`,e+=`if (typeof ${t} === "function") {\n`,e+=` registerServerReference(${t}, ${n}, ${JSON.stringify(t)});\n`,e+=`}
903
+ `,e}function w(t,n,r){let i=Gt(n,e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:A.cwd()),a=Tu(t,i),o=a?.code??t;if(!r.topLevelUseServer)return a==null?t:re(o);let s=x(o,r);if(s.length===0&&a==null)return t;let c=JSON.stringify(i);Ll(o)?o+=`
904
+ `:o+=`
905
+
906
+ import {registerServerReference} from "react-server-dom-rari/server";
907
+ `;for(let e of s)if(e==="default")o=ae(o,c);else if(a?.rewrittenExportNames.includes(e))continue;else o=C(o,e,c);return re(o)}function fe(e,t,n,r){let i=x(e,n);if(i.length===0)return``;let a=Gt(t,r),o=`import { createServerReference } from "virtual:react-flight-client";
908
+ `;o+=`import { callServer } from "rari/runtime/call-server";
909
+ `;for(let e of i){let t=`${a}#${e}`,n=JSON.stringify(t);o+=e==="default"?`export default createServerReference(${n}, callServer);\n`:`export const ${e} = createServerReference(${n}, callServer);\n`}return o}function pe(t,n,r){let i=e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:A.cwd(),a=b(n);if(r.topLevelUseServer)return fe(t,n,r,i);if(a)return console.warn(`[rari] Server component ${n} should not be imported in client bundle`),``;if(!r.topLevelUseClient)return t;let o=x(t,r);if(o.length===0)return``;let s=JSON.stringify(n),c=`import {registerClientReference} from "react-server-dom-rari/server";
910
+ `;for(let e of o){if(e==="default"){let e=`Attempted to call the default export of ${n} from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;c+=`export default `,c+=`registerClientReference(function() {`,c+=`throw new Error(${JSON.stringify(e)});`}else{let t=`Attempted to call ${e}() from the server but ${e} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;c+=`export const ${e} = `,c+=`registerClientReference(function() {`,c+=`throw new Error(${JSON.stringify(t)});`}c+=`},`,c+=`${s},`,c+=`${JSON.stringify(e)});\n`}return c}function me(e,t,n){return!n.topLevelUseClient||x(e,n).length===0?e:e.replace(yd,``)}let E=!1;async function he(){let e=`http://localhost:${N()}`;try{let t=(await fetch(`${e}/_rari/health`,{signal:AbortSignal.timeout(1e3)})).ok;return E=t,t}catch{return E=!1,!1}}let ge=null;async function _e(e){return await he()?!0:(ge??=(async()=>{try{let t=Date.now()+e,n=50;for(;Date.now()<t;){if(await new Promise(e=>{setTimeout(e,Math.min(n,t-Date.now()))}),await he())return!0;n=Math.min(n*2,500)}return!1}finally{ge=null}})(),ge)}function ve(e){if(!D.existsSync(e))return!1;try{return r.get(e).topLevelUseClient}catch{return!1}}function ye(e,t){let n=e,r=[],i=/* @__PURE__ */ new Set;for(let e of Nn(n)){if(e.typeOnly||e.sideEffectOnly||!bd.test(e.source)&&!xd(e.source,s))continue;let n=de(e.source,t,s);if(!ve(n))continue;_(n,`client`),y(n);let a=Fl(e,g(n));if(a.code!==``){for(let e of a.helpers)i.add(e);r.push({start:e.start,end:e.end,replacement:a.code})}}if(r.length===0)return n;for(let{start:e,end:t,replacement:i}of[...r].sort((e,t)=>t.start-e.start))n=n.slice(0,e)+i+n.slice(t);return i.size>0&&(n=Ml(n,`react-server-dom-rari/server`,[...i])),n}function be(e,t){for(let n of t.importSources){if(!bd.test(n)&&!xd(n,s))continue;let t=de(n,e,s);D.existsSync(t)&&(r.get(t).topLevelUseServer||(_(t,`client`),y(t)))}}function xe(e){if(e.includes(`Suspense`))return e;let t=Ed.exec(e);return t?t[1]&&!t[2].includes(`Suspense`)?e.replace(t[0],t[0].replace(kd,`{ Suspense, $1 }`)):t[1]?e:e.replace(t[0],`import React, { Suspense } from 'react';`):e}function Se(e,t,n){return e&&!t&&(n===`rsc`||n===`ssr`)}function Ce(e,t,n){let r=t.includes(`entry-client`),i=[],a=/* @__PURE__ */ new Set,o=!1;for(let c of Nn(e)){if(c.typeOnly||c.sideEffectOnly||!bd.test(c.source)&&!xd(c.source,s))continue;let e=de(c.source,t,s),l=ve(e);if(l&&(_(e,`client`),y(e)),!Se(l,r,n))continue;let u=Fl(c,g(e));if(u.code!==``){for(let e of u.helpers)a.add(e);i.push({start:c.start,end:c.end,replacement:u.code}),o=!0}}return i.length===0?null:{replacements:i,clientRefHelpers:a,needsReactImport:o}}function we(e,t,n){let r=Ce(e,t,n);if(r==null)return null;let i=e;for(let{start:e,end:t,replacement:n}of[...r.replacements].sort((e,t)=>t.start-e.start))i=i.slice(0,e)+n+i.slice(t);r.clientRefHelpers.size>0&&(i=Ml(i,`react-server-dom-rari/server`,[...r.clientRefHelpers]));let a=i.includes(`import React`)||wd.test(i)||Td.test(i);r.needsReactImport&&!a&&(i=`import React from 'react';\n${i}`),i=xe(i);let o=A.env.NODE_ENV!==`production`;return(i.includes(`</`)||i.includes(`/>`)||Od.test(i))&&o&&(i=`'use client';\n\n${i}`,_(t,`client`)),i}function Ee(e,t,n,r){if(r===`rsc`||r===`ssr`)return ye(w(e,t,n),t);let i=pe(e,t,n);return`// HMR acceptance for server component
911
+ if (import.meta.hot) {
912
+ import.meta.hot.accept();
913
+ if (typeof globalThis !== 'undefined') {
914
+ if (!globalThis['~rari']) globalThis['~rari'] = {};
915
+ globalThis['~rari'].serverComponents = globalThis['~rari'].serverComponents || new Set();
916
+ globalThis['~rari'].serverComponents.add(${JSON.stringify(t)});
917
+ }
973
918
  }
974
- export const createServerReference = module.exports.createServerReference;
975
- export const encodeReply = module.exports.encodeReply;
976
- export const createTemporaryReferenceSet = module.exports.createTemporaryReferenceSet;
977
- `}}if(t.endsWith(`.mjs`)&&b.existsSync(t))try{let n=e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:C.cwd(),r=b.realpathSync(t),i=S.relative(n,r),a=!i.startsWith(`..`)&&!S.isAbsolute(i),o=r.includes(`${S.sep}node_modules${S.sep}`),s=r.includes(`${S.sep}packages${S.sep}rari${S.sep}`)||r.includes(`${S.sep}packages${S.sep}use-cache${S.sep}`)||r.includes(`${S.sep}node_modules${S.sep}rari${S.sep}`)||r.includes(`${S.sep}node_modules${S.sep}@rari${S.sep}use-cache${S.sep}`);return a||o||s?b.readFileSync(t,`utf-8`):(console.warn(`[rari] Refusing to load .mjs file outside project root and node_modules: ${t}`),null)}catch(e){return console.warn(`[rari] Error validating .mjs file path: ${t}`,e),null}},async handleHotUpdate({file:e,server:t}){if(he(),e.endsWith(`.mdx`)&&_(),!v.test(e))return;if(se(e),fe(e),a.invalidate(e),_(),e.includes(`/dist/`)||e.includes(`\\dist\\`))return[];let n=f?.detectComponentType(e)??`unknown`,r=e.includes(`/app/`)||e.includes(`\\app\\`),i=(e,t)=>e.endsWith(`${t}.tsx`)||e.endsWith(`${t}.jsx`)||e.endsWith(`${t}.ts`)||e.endsWith(`${t}.js`),o=[`page`,`layout`,`template`,`loading`,`error`,`not-found`].some(t=>i(e,t));if(r&&o){if(f)try{await f.rebuildAndNotifyNow(e,t)}catch(t){console.error(`[rari] HMR: Failed to rebuild app router file`,`${e}:`,s(t,String(t)))}return}if(n!==`client`&&n===`server`)return f&&await f.handleServerComponentUpdate(e,t),[]},generateBundle(e,t){if(this.environment.name!==`client`)return;let n=hr(t);this.emitFile({type:`asset`,fileName:`rari-client-head.html`,source:n})},async writeBundle(){await lp(e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:C.cwd(),e,m,h)}},Ae=ys({...e.serverBuild,csp:e.csp,cacheControl:e.cacheControl,cache:e.cache,action:e.action,jsPoolSize:e.jsPoolSize,origin:e.origin,htmlLimitedBots:e.htmlLimitedBots,experimental:e.experimental,moduleAnalysisCache:a,mdx:e.mdx}),Me={name:`rari:patch-react-server-dom-webpack`,transform(e){if(!e.includes(`__webpack_require__`)&&!e.includes(`__webpack_chunk_load__`))return null;let t=e;return t.includes(`__webpack_chunk_load__`)&&(t=t.replaceAll(`__webpack_chunk_load__`,`__rari_chunk_load__`)),t.includes(`__webpack_require__.u`)&&(t=t.replaceAll(`__webpack_require__.u`,`({}).u`)),t.includes(`__webpack_require__`)&&(t=t.replaceAll(`__webpack_require__`,`__rari_rsc_require__`)),t===e?null:{code:t,map:null}}},Ne=[...cf()];return e.compiler!=null&&e.compiler!==!1&&Ne.push(uc(e.compiler)),Ne.push(x,$n(),Va(),qi(),Me,Ae),e.proxy!==!1&&Ne.push(Ge(e.proxy??{})),e.router!==!1&&Ne.push(Bt(e.router??{})),Ve(Ne)}function fp(e){return{...e,plugins:[dp(),...e.plugins??[]]}}export{e as ApiResponse,wf as clearPropsCache,Tf as clearPropsCacheForComponent,fp as defineRariConfig,up as defineRariOptions,yf as extractMetadata,vf as extractServerProps,Cf as extractServerPropsWithCache,bf as extractStaticParams,Et as generateAppRouteManifest,xf as hasServerSideDataFetching,dp as rari,Ge as rariProxy,Bt as rariRouter};
919
+
920
+ ${i}`}function O(e,t){if(t.startsWith(`\0`)||t.includes(`virtual:`))return V(e);try{return r.get(t)}catch{return V(e)}}async function j(t,n){if(!e.experimental?.useCache&&!e.experimental?.useCacheRemote)return{code:t,wasTransformed:!1};let r=await qu();if(!r)return{code:t,wasTransformed:!1};let i=r(t,n);return i==null||i===``?{code:t,wasTransformed:!1}:{code:i,wasTransformed:!0}}function Oe(e,t,n,r){if(n.topLevelUseServer)return _(t,`server`),r===`rsc`?w(e,t,n):pe(e,t,n);if(n.topLevelUseClient)return _(t,`client`),y(t),be(t,n),me(e,t,n);if(r!==`rsc`&&r!==`ssr`&&(h(t)===`client`||ee(t)))return me(e,t,n);if(b(t))return _(t,`server`),Ee(e,t,n,r);let i=h(t);return i===`server`?r===`rsc`||r===`ssr`?ye(w(e,t,n),t):pe(e,t,n):i===`client`?me(e,t,n):(_(t,`unknown`),we(e,t,r))}let ke={name:`rari`,config(e,{command:t}){e.appType=`custom`,e.define??={};let n=typeof e.css?.modules==`object`?e.css.modules:{};e.css={...e.css,transformer:e.css?.transformer??`lightningcss`,modules:{...n,pattern:`[hash]_[local]`}},e.resolve??={};let r=e.resolve,i=Array.isArray(r.dedupe)?r.dedupe:[];r.dedupe=[...new Set(i).union(/* @__PURE__ */ new Set([`react`,`react-dom`]))];let a=Sf(r),o=new Set(a.map(e=>String(e.find))),s=a.some(e=>Cd(e.find));try{r.alias=[...a,...Gd(o,s)]}catch(e){Sd(e)||console.warn(`[rari] Unexpected error configuring React aliases:`,e)}if(hf(e),e.builder??={},e.builder.sharedPlugins=!0,e.builder.sharedConfigBuild=!1,gf(e),t===`build`)for(let t of[`rsc`,`ssr`,`client`]){let n=e.environments[t];n.build!=null&&(n.build.rolldownOptions??={})}return _f(e),t===`build`&&bf(e),xf(e),e},async buildStart(){if(Pr(),e.experimental?.useCache||e.experimental?.useCacheRemote)try{await qu()}catch(e){this.error(e instanceof Error?e:Error(String(e)))}},configResolved(e){let t=Ht(e);l=t.assetsDir,u=t.outDir,Object.assign(s,Vt(e))},async transform(t,n){if(n.endsWith(`.mdx`)&&p(),/\.(?:tsx?|jsx?|mts|mjs)$/.test(n)&&t.includes(`defineMdxComponents`)){let r=Pu({code:t,id:n,projectRoot:e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:A.cwd(),resolvedAlias:s});if(r!=null&&r!==``)return ri(r,t,n)}if(!S.test(n))return null;let r=t,i=await j(t,n);t=i.code;let a=Oe(t,n,O(t,n),this.environment.name);return a==null?i.wasTransformed?ri(t,r,n):null:ri(a,r,n)},async configureServer(t){let n=k.resolve(e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:A.cwd()),d=k.join(n,`src`);await Ud(n,e,l,u);let p=/* @__PURE__ */ new Map([[`/installHook.js.map`,`installHook.js`],[`/react_devtools_backend_compact.js.map`,`react_devtools_backend_compact.js`],[`/installHook.js`,null],[`/react_devtools_backend_compact.js`,null]]);t.middlewares.use((e,t,n)=>{let r=oe(e.url??``);if(!p.has(r)){n();return}let i=p.get(r);if(t.statusCode=200,t.setHeader(`Cache-Control`,`no-store`),i!=null){t.setHeader(`Content-Type`,`application/json`),t.end(JSON.stringify({version:3,file:i,sources:[i],sourcesContent:[`/* react-devtools extension stub */`],names:[],mappings:`AAAA`}));return}t.setHeader(`Content-Type`,`application/javascript; charset=utf-8`),t.end(`/* react-devtools extension stub */
921
+ `)});let m=async()=>{try{let a=new El(n,{outDir:u,rscDir:`server`,manifestPath:`server/manifest.json`,serverConfigPath:`server/config.json`,alias:s,assetsDir:l,csp:e.csp,cacheControl:e.cacheControl,cache:e.cache,action:e.action,jsPoolSize:e.jsPoolSize,origin:e.origin,htmlLimitedBots:e.htmlLimitedBots,experimental:e.experimental,moduleAnalysisCache:r});if(a.setViteBuilder(await ce({root:n,configFile:t.config.configFile,logLevel:`error`})),i=a,o??=new To(a,N()),D.existsSync(d)){let e=Al(d,a,Object.values(s));e.serverComponentPaths.length>0&&t.ws.send({type:`custom`,event:`rari:server-components-registry`,data:{serverComponents:e.serverComponentPaths}})}let f=await a.getTransformedComponentsForDevelopment(),p=`http://localhost:${N()}`;await Promise.all(f.map(async e=>{try{if(e.id.startsWith(`app/`)||e.isAction)return;let t=await fetch(`${p}/_rari/register`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:e.id,component_code:e.code})});if(!t.ok){let e=await t.text();throw Error(`HTTP ${t.status}: ${e}`)}}catch(t){console.error(`[rari] Runtime: Failed to register component ${e.id}:`,c(t,String(t)))}}))}catch(e){console.error(`[rari] Runtime: Component discovery failed:`,c(e,String(e)))}},h=async()=>{try{let e=`http://localhost:${N()}`,t=ne();await Promise.all([...t].map(async t=>{let n=k.relative(A.cwd(),t),r=k.basename(t).replace(ie,``);try{await fetch(`${e}/_rari/register-client`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:r,file_path:n,export_name:`default`})})}catch(e){console.error(`[rari] Runtime: Failed to pre-register client component ${r}:`,e)}}))}catch(e){console.error(`[rari] Runtime: Failed to pre-register client components:`,e)}},g=async()=>{if(a)return;let{getBinaryPath:r,getInstallationInstructions:i}=await import(`./platform.mjs`),o;try{o=r()}catch(e){console.error(`rari binary not found`),console.error(` ${c(e,String(e))}`),console.error(i());return}let l=N(),u=A.env.NODE_ENV===`production`?`production`:`development`,d=t.config.server.port,f=e.origin?.trim().replace(/\/+$/,``),p=A.env.RARI_ORIGIN?.trim().replace(/\/+$/,``),g=Vr(n,s),_=[`--mode`,u,`--port`,l.toString(),`--host`,`127.0.0.1`];a=Te(o,_,{stdio:[`ignore`,`pipe`,`pipe`],cwd:n,env:{...A.env,RUST_LOG:A.env.RUST_LOG!=null&&A.env.RUST_LOG!==``?A.env.RUST_LOG:`error`,RARI_VITE_PORT:d.toString(),...g.length>0?{RARI_DEV_LAYOUT_CSS:g.join(`,`)}:{},...e.jsPoolSize!=null&&(A.env.RARI_JS_POOL_SIZE==null||A.env.RARI_JS_POOL_SIZE===``)?{RARI_JS_POOL_SIZE:String(e.jsPoolSize)}:{},...f!=null&&f!==``&&(p==null||p===``)?{RARI_ORIGIN:f}:{},...e.htmlLimitedBots!=null&&(A.env.RARI_HTML_LIMITED_BOTS==null||A.env.RARI_HTML_LIMITED_BOTS===``)?{RARI_HTML_LIMITED_BOTS:e.htmlLimitedBots}:{}}}),a.stdout?.on(`data`,e=>{let t=e.toString().trim();t&&console.error(t)}),a.stderr?.on(`data`,e=>{let t=e.toString().trim();t&&!t.includes(`warning`)&&console.error(t)}),a.on(`error`,e=>{E=!1,console.error(`Failed to start rari server:`,e.message),e.message.includes(`ENOENT`)&&console.error(` Binary not found. Please ensure rari is properly installed.`)}),a.on(`exit`,(e,t)=>{a=null,E=!1,t?console.error(`rari server stopped by signal ${t}`):e===0?console.error(`rari server stopped successfully`):e&&console.error(`rari server exited with code ${e}`)}),await _e(1e4)?(await m(),await h()):console.error(`Server failed to become ready for component registration`)},_=async e=>{try{if(!b(e))return;i??await m();let t=i;if(t==null)return;let n=r.getSource(e);t.addServerComponent(e,n);let a=xo(t.getImportGraph(),[e]);a.add(e);let o=await t.getTransformedComponentsForDevelopment(e=>a.has(e));if(o.length===0)return;let s=`http://localhost:${N()}`;await Promise.all(o.map(async e=>{try{let t=await fetch(`${s}/_rari/register`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:e.id,component_code:e.code})});if(!t.ok){let e=await t.text();throw Error(`HTTP ${t.status}: ${e}`)}}catch(t){console.error(`[rari] Failed to register component`,`${e.id}:`,c(t,String(t)))}}))}catch(t){console.error(`[rari] Targeted HMR failed for`,`${e}:`,c(t,String(t)))}};g().catch(e=>{console.error(`[rari] Failed to start Rust server:`,e)}),t.middlewares.use((e,t,n)=>{(async()=>{let r=e.headers.accept,i=e.method??`GET`,a=e.url??``,o=oe(a),s=r!=null&&r!==``&&r.includes(`text/x-component`);if(Yd(s,rf(i,r,o),a,o)){n();return}if(!E&&!await _e(1e4)){console.error(`[rari] Rust server not ready, cannot proxy ${s?`RSC`:`HTML`} request`),t.headersSent||(t.statusCode=503,t.end(`Server not ready`));return}let c=N();try{let n=af(e.headers,c),r=i!==`GET`&&i!==`HEAD`?await ld(e,10485760):void 0,o=await fetch(`http://localhost:${c}${a}`,{method:i,headers:n,...r==null?{}:{body:r}});t.statusCode=o.status,o.headers.forEach((e,n)=>{n.toLowerCase()!==`content-encoding`&&t.setHeader(n,e)}),await of(o,t,i)}catch(e){Cf(e,t,s)}})()}),t.watcher.on(`change`,e=>{(async()=>{S.test(e)&&(v(e),te(e),r.invalidate(e)),S.test(e)&&se(e,d)&&b(e)&&(t.ws.send({type:`custom`,event:`rari:register-server-component`,data:{filePath:e}}),await _(e))})()}),t.middlewares.use(`/api/vite/hmr-transform`,(e,t)=>{if(e.method!==`POST`){t.statusCode=405,t.end(`Method Not Allowed`);return}(async()=>{try{let n=await De(e),r=f(n),i=r&&typeof r.filePath==`string`?r.filePath:void 0;if(i==null||i===``){t.statusCode=400,t.end(JSON.stringify({error:`filePath is required`}));return}await _(i),t.statusCode=200,t.setHeader(`Content-Type`,`application/json`),t.end(JSON.stringify({success:!0,filePath:i,message:`Component transformation completed`}))}catch(e){t.statusCode=500,t.setHeader(`Content-Type`,`application/json`),t.end(JSON.stringify({success:!1,error:c(e,String(e))}))}})()}),t.httpServer?.on(`close`,()=>{if(ue(n),i!=null&&(i.setViteBuilder(null),i=null),o&&=(o.dispose(),null),a){let e=a;a=null,E=!1;let t=!1,n=setTimeout(()=>{t||e.kill(`SIGKILL`)},5e3);n.unref(),e.once(`exit`,()=>{t=!0,clearTimeout(n)}),e.kill(`SIGTERM`);return}E=!1})},resolveId(e,t){let n=cf(e);if(n!=null)return n;if(e===`react-server-dom-webpack/client`||e===`react-server-dom-webpack/client.browser`)return`virtual:react-flight-client.ts`;if(e===`react-server-dom-rari/server`)return e;if(t!=null&&t!==``&&t.startsWith(`virtual:`)){let n=uf(e,t);if(n!=null)return n}return tf(e,b)},async load(t){if(S.test(t)&&this.environment.name===`client`)try{let e=r.get(t);if(e.topLevelUseServer)return pe(r.getSource(t),t,e)}catch{}let n=await ef(t,{buildMdxRegistryModule:m,resolveProjectRoot:()=>e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:A.cwd(),resolvedAlias:s,moduleAnalysisCache:r,getKnownClientComponentPaths:ne,environmentMode:this.environment.mode});return n===void 0?Qd(t,e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:A.cwd())??void 0:n},async handleHotUpdate({file:e,server:t}){if(le(),e.endsWith(`.mdx`)&&p(),!S.test(e))return;if(v(e),te(e),r.invalidate(e),p(),e.includes(`/dist/`)||e.includes(`\\dist\\`))return[];let n=o?.detectComponentType(e)??`unknown`,i=e.includes(`/app/`)||e.includes(`\\app\\`),a=(e,t)=>e.endsWith(`${t}.tsx`)||e.endsWith(`${t}.jsx`)||e.endsWith(`${t}.ts`)||e.endsWith(`${t}.js`),s=[`page`,`layout`,`template`,`loading`,`error`,`not-found`].some(t=>a(e,t));if(i&&s){if(o)try{await o.rebuildAndNotifyNow(e,t)}catch(t){console.error(`[rari] HMR: Failed to rebuild app router file`,`${e}:`,c(t,String(t)))}return}if(n!==`client`&&n===`server`)return o&&await o.handleServerComponentUpdate(e,t),[]},generateBundle(e,t){if(this.environment.name!==`client`)return;let n=Gr(t);this.emitFile({type:`asset`,fileName:`rari-client-head.html`,source:n})},async writeBundle(){await Ud(e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:A.cwd(),e,l,u)}},Ae=jl({...e.serverBuild,csp:e.csp,cacheControl:e.cacheControl,cache:e.cache,action:e.action,jsPoolSize:e.jsPoolSize,origin:e.origin,htmlLimitedBots:e.htmlLimitedBots,experimental:e.experimental,moduleAnalysisCache:r,mdx:e.mdx}),je={name:`rari:patch-react-server-dom-webpack`,transform(e){if(!e.includes(`__webpack_require__`)&&!e.includes(`__webpack_chunk_load__`)&&!e.includes(`__webpack_get_script_filename__`))return null;let t=e;return t.includes(`__webpack_chunk_load__`)&&(t=t.replaceAll(`__webpack_chunk_load__`,`__rari_chunk_load__`)),t.includes(`__webpack_get_script_filename__`)&&(t=t.replaceAll(`__webpack_get_script_filename__`,`__rari_get_script_filename__`)),t.includes(`__webpack_require__.u`)&&(t=t.replaceAll(`__webpack_require__.u`,`({}).u`)),t.includes(`__webpack_require__`)&&(t=t.replaceAll(`__webpack_require__`,`__rari_rsc_require__`)),t===e?null:{code:t,map:null}}},M=[...Gu()];return e.compiler!=null&&e.compiler!==!1&&M.push(Hu(e.compiler)),M.push(ke,kr(),bs(),_o(),je,Ae,gi(e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:A.cwd())),e.proxy!==!1&&M.push(Re(e.proxy??{})),e.router!==!1&&M.push(jt(e.router??{})),Pe(M)}function Ef(e){return{...e,plugins:[Tf(),...e.plugins??[]]}}export{t as ApiResponse,od as clearPropsCache,sd as clearPropsCacheForComponent,Ef as defineRariConfig,wf as defineRariOptions,td as extractMetadata,ed as extractServerProps,ad as extractServerPropsWithCache,nd as extractStaticParams,_t as generateAppRouteManifest,rd as hasServerSideDataFetching,Tf as rari,Re as rariProxy,jt as rariRouter};