"use strict";exports.id=7300,exports.ids=[7300],exports.modules={47300:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{actionBundlePath:()=>A,buildUtility:()=>n,rebuildUtility:()=>y,uiBundlePath:()=>z});var e=c(71152),f=c(73024),g=c(76760),h=c.n(g),i=c(77598),j=c.n(i),k=c(36306),l=c(85933),m=a([k]);k=(m.then?(await m)():m)[0];let B="esm.sh",C="react,react-dom,react-dom/client",D=["@host/ui","@host/api"],E=[],F=["react","react/jsx-runtime","react/jsx-dev-runtime","react-dom","react-dom/client","react-markdown","remark-gfm","mermaid"];async function n(a){let{manifest:b,dir:c}=a,d=h().join(c,b.ui),g=h().join(c,"bundle.js"),i=b.dependencies??{},j=h().join(c,"dist",".esm-cache");await p(d,"ui");let k="./"+h().basename(b.ui).replace(/\.(tsx?|jsx?)$/,""),l=`import * as __user from ${JSON.stringify(k)};
import { createElement } from "react";
import { createRoot } from "react-dom/client";
const __root = typeof document !== "undefined"
  ? document.getElementById("root")
  : null;
const __Component = (__user && typeof __user === "object")
  ? (__user["default"] ?? __user["App"])
  : null;
if (__root && typeof __Component === "function") {
  createRoot(__root).render(createElement(__Component));
}
`,m=await e.build({stdin:{contents:l,resolveDir:c,sourcefile:"_reflex-bootstrap.tsx",loader:"tsx"},outfile:g,bundle:!0,format:"esm",platform:"browser",target:"es2022",jsx:"automatic",minify:!1,write:!0,sourcemap:"inline",external:D,plugins:[v({deps:i,cacheDir:j,target:"browser"}),x([...D,...F])],logLevel:"silent"});o(m,"UI bundle");let n=await f.promises.stat(g);if(n.size>0x2800000)throw Error(`UI bundle too large: ${n.size} bytes (cap 41943040)`);await q(a);let r=[];if(b.serverActions.length>0){let a=h().join(c,"dist","actions");for(let d of(await f.promises.mkdir(a,{recursive:!0}),b.serverActions)){let b=h().join(c,d.entry);await p(b,`action ${d.name}`);let g=h().join(a,`${d.name}.js`),k=await e.build({entryPoints:[b],outfile:g,bundle:!0,format:"esm",platform:"node",target:"es2022",minify:!1,write:!0,sourcemap:"inline",external:E,plugins:[{name:"reflex-host-api-virtual",setup(a){a.onResolve({filter:/^@host\/api$/},a=>({path:a.path,namespace:"reflex-host-api"})),a.onLoad({filter:/.*/,namespace:"reflex-host-api"},()=>({contents:"const h = globalThis.__reflexHost;\nif (!h) throw new Error('@host/api not available — worker not bootstrapped?');\nexport const reflex = h;\nexport const llm = h.llm;\nexport const kb = h.kb;\nexport const fs = h.fs;\nexport const web = h.web;\nexport const audit = h.audit;\nexport const actions = h.actions;\nexport const mcp = h.mcp;\nexport const secrets = h.secrets;\nexport const agent = h.agent;\nexport const workflow = h.workflow;\nexport const cards = h.cards;\nexport default h;\n",loader:"js"}))}},v({deps:i,cacheDir:j,target:"node"}),x([...E,"@host/api"])],logLevel:"silent"});o(k,`action ${d.name}`);let l=await f.promises.stat(g);if(l.size>0x2800000)throw Error(`action ${d.name} bundle too large: ${l.size}`);r.push({name:d.name,size:l.size})}}return{uiBundleSize:n.size,actionBundles:r}}function o(a,b){if(a.errors&&a.errors.length>0){let c=a.errors.map(a=>`${a.location?.file}:${a.location?.line??"?"}: ${a.text}`).join("\n");throw Error(`esbuild failed for ${b}:
${c}`)}}async function p(a,b){try{await f.promises.access(a)}catch{throw Error(`${b} entry not found: ${a}`)}}async function q(a){let{dir:b}=a,c=await r(b),d=new Set;for(let a of c){let b=await f.promises.readFile(a,"utf8");for(let a of s(b))d.add(a)}for(let a of s(l.g))d.add(a);let e=(await (0,k.compile)(`@import "tailwindcss";
`,{base:process.cwd(),onDependency:()=>{}})).build([...d]);await f.promises.writeFile(h().join(b,"style.css"),e,"utf8")}async function r(a){let b=[],c=async a=>{for(let d of(await f.promises.readdir(a,{withFileTypes:!0}))){let e=h().join(a,d.name);if(d.isDirectory()){if("data"===d.name||"dist"===d.name||"node_modules"===d.name)continue;await c(e)}else/\.(tsx?|jsx?|html|css|md)$/.test(d.name)&&b.push(e)}};return await c(a),b}function s(a){return a.split(/[\s"'`{}();,<>=]+/).filter(a=>a.length>0&&/^[a-zA-Z@!-]/.test(a))}let G={mermaid:"dist/mermaid.esm.min.mjs"};function t(a){let b,c=a.split("/"),d=a.startsWith("@")?c.slice(0,2).join("/"):c[0],e=a.startsWith("@")?c.slice(2):c.slice(1),g=e.length>0?"./"+e.join("/"):".",i=h().join(process.cwd(),"node_modules",d);if("."===g&&d&&G[d]){let a=h().join(i,G[d]);if((0,f.existsSync)(a))return a}let j=h().join(i,"package.json");if(!(0,f.existsSync)(j))return null;try{b=JSON.parse((0,f.readFileSync)(j,"utf8"))}catch{return null}let k=function(a,b){if(null==a)return null;if("string"==typeof a)return"."===b?a:null;if("object"!=typeof a)return null;if(Object.keys(a).some(a=>a.startsWith("."))){let c=a[b];return void 0!==c?u(c):null}return"."===b?u(a):null}(b.exports,g);if(null!==k){let a=h().join(i,k);return(0,f.existsSync)(a)?a:null}if("."===g){let a=b.module??b.main??"index.js",c=h().join(i,a);return(0,f.existsSync)(c)?c:null}for(let a of["",".js",".mjs",".cjs"]){let b=h().join(i,g.slice(2)+a);if((0,f.existsSync)(b))return b}return null}function u(a){if(null==a)return null;if("string"==typeof a)return a;if("object"!=typeof a)return null;for(let b of["browser","import","module","default","require"])if(b in a){let c=u(a[b]);if(c)return c}return null}function v(a){let{deps:b,cacheDir:c,target:d}=a,e=new Set(F);return{name:"reflex-esm-cdn",setup(a){a.onResolve({filter:/.*/},a=>{if(/^https?:\/\//.test(a.path)){let b;try{b=new URL(a.path).host}catch{return null}return b!==B?{errors:[{text:`refusing non-esm.sh URL import: ${a.path}`}]}:{path:a.path,namespace:"esm-cdn"}}if("esm-cdn"===a.namespace){if(a.path.startsWith(".")||a.path.startsWith("/"))return{path:new URL(a.path,a.importer).href,namespace:"esm-cdn"};if(e.has(a.path)){let b=t(a.path);if(b)return{path:b}}return{path:`https://${B}/${a.path}?external=${C}${"node"===d?"&target=node":""}`,namespace:"esm-cdn"}}if(!a.path.startsWith(".")&&!a.path.startsWith("/")&&!h().isAbsolute(a.path)&&!a.path.startsWith("@host/")&&!a.path.startsWith("node:")){let c=(a=>{let c=a.split("/"),e=a.startsWith("@")?c.slice(0,2).join("/"):c[0],f=b[e];if(!f)return null;let g=a.slice(e.length);return`https://${B}/${e}@${f}${g}?external=${C}${"node"===d?"&target=node":""}`})(a.path);if(c)return{path:c,namespace:"esm-cdn"}}return null}),a.onLoad({filter:/.*/,namespace:"esm-cdn"},async a=>({contents:await w(a.path,c),loader:"js",resolveDir:c}))}}}async function w(a,b){let c,d=j().createHash("sha256").update(a).digest("hex").slice(0,32),e=h().join(b,`${d}.js`);try{return await f.promises.readFile(e,"utf8")}catch{}try{c=await fetch(a,{signal:AbortSignal.timeout(2e4)})}catch(b){throw Error(`couldn't fetch dependency from ${a}: ${b instanceof Error?b.message:String(b)}`)}if(!c.ok)throw Error(`couldn't fetch dependency from ${a}: HTTP ${c.status}`);let g=await c.text();return await f.promises.mkdir(b,{recursive:!0}),await f.promises.writeFile(e,g,"utf8"),g}function x(a){let b=new Set(a),c=new Set(F),d=h().join(process.cwd(),"node_modules");return{name:"reflex-import-whitelist",setup(a){a.onResolve({filter:/.*/},a=>{if(a.importer.startsWith(d+h().sep)||a.importer.includes(h().sep+"node_modules"+h().sep)||a.path.startsWith(".")||a.path.startsWith("/")||h().isAbsolute(a.path))return null;if(a.path.startsWith("node:"))return{errors:[{text:`import "${a.path}" is not allowed in utility code`}]};if(!b.has(a.path))return{errors:[{text:`import "${a.path}" is not in the allowed list: ${Array.from(b).join(", ")}`}]};if(a.path.startsWith("@host/"))return{path:a.path,external:!0};if(c.has(a.path)){let b=t(a.path);return b?{path:b}:{errors:[{text:`could not resolve "${a.path}" from Reflex node_modules`}]}}return null})}}}async function y(a){return n(a)}function z(a){return h().join(a,"bundle.js")}function A(a,b){return h().join(a,"dist","actions",`${b}.js`)}d()}catch(a){d(a)}})},85933:(a,b,c)=>{c.d(b,{g:()=>d});let d=String.raw`import { createElement, forwardRef, useState, useCallback } from "react";

function cls(...parts) {
  return parts.filter(Boolean).join(" ");
}

export const Button = forwardRef(function Button(
  { variant = "default", size = "default", className, ...props },
  ref,
) {
  const v = {
    default: "bg-slate-900 text-white hover:bg-slate-800",
    secondary: "bg-slate-100 text-slate-900 hover:bg-slate-200",
    outline: "border border-slate-300 bg-white hover:bg-slate-50",
    destructive: "bg-red-600 text-white hover:bg-red-700",
    ghost: "hover:bg-slate-100",
  }[variant] ?? "";
  const s = {
    default: "h-9 px-4 py-2 text-sm",
    sm: "h-8 px-3 text-xs",
    lg: "h-11 px-6 text-base",
    icon: "h-9 w-9 p-0",
  }[size] ?? "";
  return createElement("button", {
    ref,
    className: cls(
      "inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-400 disabled:opacity-50 disabled:pointer-events-none",
      v, s, className,
    ),
    ...props,
  });
});

export const Input = forwardRef(function Input({ className, ...props }, ref) {
  return createElement("input", {
    ref,
    className: cls(
      "flex h-9 w-full rounded-md border border-slate-300 bg-white px-3 py-1 text-sm placeholder:text-slate-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-400 disabled:opacity-50",
      className,
    ),
    ...props,
  });
});

export const Textarea = forwardRef(function Textarea({ className, ...props }, ref) {
  return createElement("textarea", {
    ref,
    className: cls(
      "flex min-h-[80px] w-full rounded-md border border-slate-300 bg-white px-3 py-2 text-sm placeholder:text-slate-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-400 disabled:opacity-50",
      className,
    ),
    ...props,
  });
});

export function Label({ className, ...props }) {
  return createElement("label", {
    className: cls("text-xs font-medium text-slate-600", className),
    ...props,
  });
}

export function Card({ className, ...props }) {
  return createElement("div", {
    className: cls(
      "rounded-lg border border-slate-200 bg-white shadow-sm",
      className,
    ),
    ...props,
  });
}

export function CardContent({ className, ...props }) {
  return createElement("div", {
    className: cls("p-4", className),
    ...props,
  });
}

export function CardHeader({ className, ...props }) {
  return createElement("div", {
    className: cls("p-4 border-b border-slate-100", className),
    ...props,
  });
}

export function CardTitle({ className, ...props }) {
  return createElement("h3", {
    className: cls("text-base font-semibold", className),
    ...props,
  });
}

export function Badge({ variant = "default", className, ...props }) {
  const v = {
    default: "bg-slate-900 text-white",
    secondary: "bg-slate-100 text-slate-900",
    outline: "border border-slate-300 text-slate-700",
  }[variant] ?? "";
  return createElement("span", {
    className: cls(
      "inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium",
      v, className,
    ),
    ...props,
  });
}

export function ScrollArea({ className, children }) {
  return createElement("div", {
    className: cls("overflow-y-auto", className),
  }, children);
}

// --- Routing --------------------------------------------------------------
// In-memory router for multi-view utilities. The iframe has no address
// bar, so navigation is a state stack, not a URL. Use either the hook
// (manual control) or <RouterView> (renders the active view component).

export function useReflexRoute(initial) {
  const start = typeof initial === "string"
    ? { route: initial, params: {} }
    : (initial && initial.route ? { route: initial.route, params: initial.params || {} } : { route: "", params: {} });
  const [stack, setStack] = useState([start]);
  const current = stack[stack.length - 1];
  const navigate = useCallback((route, params) => {
    setStack((s) => [...s, { route, params: params || {} }]);
  }, []);
  const back = useCallback(() => {
    setStack((s) => (s.length > 1 ? s.slice(0, -1) : s));
  }, []);
  const replace = useCallback((route, params) => {
    setStack((s) => [...s.slice(0, -1), { route, params: params || {} }]);
  }, []);
  return {
    route: current.route,
    params: current.params,
    canBack: stack.length > 1,
    navigate,
    back,
    replace,
  };
}

// <RouterView routes={{ board: BoardView, detail: DetailView }} initial="board" />
// Each view receives { params, navigate, back, replace, route, canBack }.
export function RouterView({ routes, initial }) {
  const r = useReflexRoute(initial);
  const Comp = routes ? routes[r.route] : null;
  if (typeof Comp !== "function") {
    return createElement(
      "div",
      { className: "p-4 text-sm text-slate-500" },
      "No view for route: " + String(r.route),
    );
  }
  return createElement(Comp, {
    params: r.params,
    navigate: r.navigate,
    back: r.back,
    replace: r.replace,
    route: r.route,
    canBack: r.canBack,
  });
}
`}};