morpheus-cli 0.9.13 → 0.9.22

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 (102) hide show
  1. package/README.md +48 -17
  2. package/dist/channels/discord.js +93 -6
  3. package/dist/channels/telegram.js +109 -9
  4. package/dist/cli/commands/start.js +15 -0
  5. package/dist/config/manager.js +20 -1
  6. package/dist/config/paths.js +4 -0
  7. package/dist/config/schemas.js +15 -0
  8. package/dist/http/api.js +5 -1
  9. package/dist/http/middleware/auth.js +2 -1
  10. package/dist/http/routers/danger.js +4 -5
  11. package/dist/http/routers/display.js +33 -0
  12. package/dist/http/routers/link.js +2 -2
  13. package/dist/runtime/__tests__/telephonist-tts.test.js +84 -0
  14. package/dist/runtime/adapters/AuditRepositoryAdapter.js +6 -0
  15. package/dist/runtime/adapters/ChannelNotifierAdapter.js +9 -0
  16. package/dist/runtime/adapters/LangChainProviderAdapter.js +9 -0
  17. package/dist/runtime/adapters/SQLiteChatHistoryAdapter.js +15 -0
  18. package/dist/runtime/adapters/SQLiteTaskEnqueuerAdapter.js +6 -0
  19. package/dist/runtime/adapters/index.js +5 -0
  20. package/dist/runtime/audit/repository.js +6 -2
  21. package/dist/runtime/chronos/repository.js +2 -2
  22. package/dist/runtime/container.js +50 -0
  23. package/dist/runtime/display.js +17 -2
  24. package/dist/runtime/hot-reload.js +6 -9
  25. package/dist/runtime/memory/backfill-embeddings.js +2 -3
  26. package/dist/runtime/memory/sati/repository.js +3 -3
  27. package/dist/runtime/memory/sqlite.js +3 -3
  28. package/dist/runtime/memory/trinity-db.js +2 -2
  29. package/dist/runtime/ports/IAuditEmitter.js +1 -0
  30. package/dist/runtime/ports/IChatHistory.js +1 -0
  31. package/dist/runtime/ports/ILLMProviderFactory.js +1 -0
  32. package/dist/runtime/ports/INotifier.js +1 -0
  33. package/dist/runtime/ports/ITaskEnqueuer.js +1 -0
  34. package/dist/runtime/ports/index.js +1 -0
  35. package/dist/runtime/providers/factory.js +8 -52
  36. package/dist/runtime/providers/strategies.js +66 -0
  37. package/dist/runtime/setup/repository.js +2 -2
  38. package/dist/runtime/subagents/apoc.js +2 -2
  39. package/dist/runtime/subagents/link/link.js +2 -2
  40. package/dist/runtime/subagents/link/repository.js +2 -2
  41. package/dist/runtime/subagents/link/worker.js +3 -3
  42. package/dist/runtime/subagents/neo.js +2 -2
  43. package/dist/runtime/subagents/trinity/trinity.js +2 -2
  44. package/dist/runtime/tasks/repository.js +2 -2
  45. package/dist/runtime/telephonist.js +160 -0
  46. package/dist/runtime/tools/delegation-utils.js +5 -7
  47. package/dist/runtime/tools/morpheus-tools.js +6 -7
  48. package/dist/runtime/tools/smith-tool.js +5 -7
  49. package/dist/runtime/webhooks/repository.js +2 -2
  50. package/dist/types/config.js +6 -0
  51. package/dist/ui/assets/AuditDashboard-z3OBbJ8I.js +1 -0
  52. package/dist/ui/assets/{Chat-UVoDlqqM.js → Chat-aFz9FjrD.js} +7 -7
  53. package/dist/ui/assets/{Chronos-Dfs_pOsc.js → Chronos-MP_NCj2A.js} +1 -1
  54. package/dist/ui/assets/{ConfirmationModal-BBIjVef7.js → ConfirmationModal-B3gHIVKY.js} +1 -1
  55. package/dist/ui/assets/Dashboard-OyZXnj44.js +4120 -0
  56. package/dist/ui/assets/{DeleteConfirmationModal-Du85q5u2.js → DeleteConfirmationModal-D8QsQzwP.js} +1 -1
  57. package/dist/ui/assets/{Documents-DguILrI8.js → Documents-B8g_yv4f.js} +1 -1
  58. package/dist/ui/assets/{Logs-BDup2FET.js → Logs-BWufAtHa.js} +1 -1
  59. package/dist/ui/assets/{MCPManager-WBdh1rum.js → MCPManager-lLoGEyBy.js} +1 -1
  60. package/dist/ui/assets/ModelPricing-CuYIUwXt.js +1 -0
  61. package/dist/ui/assets/Notifications-nI--fmYx.js +1 -0
  62. package/dist/ui/assets/{Pagination-BHZKk42X.js → Pagination-D4ShqUKO.js} +1 -1
  63. package/dist/ui/assets/SatiMemories-DO3JDQBi.js +1 -0
  64. package/dist/ui/assets/{SelectInput-KVLsnfra.js → SelectInput-BPDcd3y7.js} +1 -1
  65. package/dist/ui/assets/SessionAudit-BWtJRkj1.js +9 -0
  66. package/dist/ui/assets/Settings-CblauAVd.js +49 -0
  67. package/dist/ui/assets/Skills-Dw6G5c8W.js +7 -0
  68. package/dist/ui/assets/Smiths-B6-CnRMv.js +1 -0
  69. package/dist/ui/assets/Switch-C7TxLq0E.js +1 -0
  70. package/dist/ui/assets/Tasks-DzUyw5z3.js +1 -0
  71. package/dist/ui/assets/{TrinityDatabases-DYHJunk7.js → TrinityDatabases-DCjdwnLH.js} +1 -1
  72. package/dist/ui/assets/{UsageStats-BpGXaHgW.js → UsageStats-VajzjndO.js} +1 -1
  73. package/dist/ui/assets/{WebhookManager-D2muhYy9.js → WebhookManager-BbfMCiy-.js} +2 -2
  74. package/dist/ui/assets/{agents-CgqJea9n.js → agents-CN_AKX_I.js} +1 -1
  75. package/dist/ui/assets/{audit-Dc3YW0-4.js → audit-M-5UGwoK.js} +1 -1
  76. package/dist/ui/assets/{chronos-CZvGhZQB.js → chronos-mZ0RIvh4.js} +1 -1
  77. package/dist/ui/assets/config-7LGRnJ26.js +1 -0
  78. package/dist/ui/assets/index-Bko2TlZY.css +1 -0
  79. package/dist/ui/assets/{index-Bta9YXEm.js → index-Db1XEN8v.js} +3 -3
  80. package/dist/ui/assets/{mcp-vIffcwd6.js → mcp-YiYC-9IH.js} +1 -1
  81. package/dist/ui/assets/{skills-wANsorUj.js → skills-dc6Xqqhb.js} +1 -1
  82. package/dist/ui/assets/{stats-xnlA4NwX.js → stats-BzqxCDuj.js} +1 -1
  83. package/dist/ui/assets/useCurrency-CEc5edm2.js +1 -0
  84. package/dist/ui/assets/vendor-icons-DE7PWdkN.js +1 -0
  85. package/dist/ui/assets/vendor-utils-BIYveU_1.js +39 -0
  86. package/dist/ui/index.html +4 -4
  87. package/dist/ui/sw.js +1 -1
  88. package/package.json +1 -1
  89. package/dist/ui/assets/AuditDashboard-BVyKnpVm.js +0 -1
  90. package/dist/ui/assets/Dashboard-BdSQDB14.js +0 -1
  91. package/dist/ui/assets/ModelPricing-BQPw0r6z.js +0 -1
  92. package/dist/ui/assets/Notifications-BslO2Ect.js +0 -1
  93. package/dist/ui/assets/SatiMemories-DzaLaZ6M.js +0 -1
  94. package/dist/ui/assets/SessionAudit-CBDThjBi.js +0 -9
  95. package/dist/ui/assets/Settings-JPTCA7C7.js +0 -49
  96. package/dist/ui/assets/Skills-BnDg1HCb.js +0 -7
  97. package/dist/ui/assets/Smiths-DR6g_o3D.js +0 -1
  98. package/dist/ui/assets/Tasks-BuoNCvI-.js +0 -1
  99. package/dist/ui/assets/config-pKL8Y4V9.js +0 -1
  100. package/dist/ui/assets/index-Cjli-AD7.css +0 -1
  101. package/dist/ui/assets/vendor-icons-NHF9HNeN.js +0 -1
  102. package/dist/ui/assets/vendor-utils-D4NnWbOU.js +0 -39
@@ -1 +0,0 @@
1
- import{j as e,m}from"./vendor-motion-C3CZ8ZlO.js";import{r as o}from"./vendor-react-DikRIOlj.js";import{u as M}from"./vendor-utils-D4NnWbOU.js";import{h as u,D as j,d as z,e as v,j as N}from"./index-Bta9YXEm.js";import{i as F,a6 as E,w as I,z as R}from"./vendor-icons-NHF9HNeN.js";const g={list:()=>u.get("/model-pricing"),upsert:a=>u.post("/model-pricing",a),update:(a,s,p)=>u.put(`/model-pricing/${encodeURIComponent(a)}/${encodeURIComponent(s)}`,p),delete:(a,s)=>u.delete(`/model-pricing/${encodeURIComponent(a)}/${encodeURIComponent(s)}`)},T={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},_={hidden:{opacity:0,y:10},show:{opacity:1,y:0}},A=["anthropic","openai","google","openrouter","ollama","other"],w=()=>({provider:"",model:"",input_price_per_1m:0,output_price_per_1m:0,audio_cost_per_second:null}),V=()=>{const{data:a=[],mutate:s}=M("/api/model-pricing",()=>g.list()),[p,n]=o.useState(!1),[l,b]=o.useState(null),[t,i]=o.useState(w()),[d,c]=o.useState(null),[h,y]=o.useState(null),[k,f]=o.useState(!1),x=(r,D)=>{y({type:r,message:D}),setTimeout(()=>y(null),3e3)},C=()=>{b(null),i(w()),n(!0)},$=r=>{b(r),i({...r}),n(!0)},S=async()=>{if(!(!t.provider.trim()||!t.model.trim())){f(!0);try{await g.upsert(t),await s(),n(!1),x("success",l?"Pricing updated.":"Pricing created.")}catch{x("error","Failed to save pricing entry.")}finally{f(!1)}}},P=async()=>{if(d)try{await g.delete(d.provider,d.model),await s(),c(null),x("success","Pricing entry deleted.")}catch{x("error","Failed to delete pricing entry.")}};return e.jsxs(m.div,{variants:T,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(m.div,{variants:_,className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(F,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Model Pricing"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:"Manage per-model pricing to estimate LLM costs in Usage Stats."})]})]}),e.jsxs("button",{onClick:C,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-matrix-highlight text-sm font-medium hover:opacity-90 transition-opacity",children:[e.jsx(E,{className:"w-4 h-4"})," Add Pricing"]})]}),h&&e.jsx(m.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:`px-4 py-3 rounded-lg text-sm font-medium border ${h.type==="success"?"bg-green-50 dark:bg-green-900/20 border-green-300 dark:border-green-700 text-green-800 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 border-red-300 dark:border-red-700 text-red-800 dark:text-red-400"}`,children:h.message}),e.jsx(m.div,{variants:_,className:"rounded-lg border border-azure-border dark:border-matrix-primary overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-azure-surface dark:bg-zinc-900 border-b border-azure-border dark:border-matrix-primary",children:e.jsx("tr",{children:["Provider","Model","Input ($/1M tokens)","Output ($/1M tokens)","Audio ($/s)","Actions"].map(r=>e.jsx("th",{className:"px-4 py-3 text-left font-semibold text-azure-text-secondary dark:text-matrix-secondary",children:r},r))})}),e.jsx("tbody",{children:a.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-8 text-center text-azure-text-secondary dark:text-matrix-secondary",children:'No pricing entries. Click "Add Pricing" to get started.'})}):a.map(r=>e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 hover:bg-azure-surface/50 dark:hover:bg-zinc-800/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 text-azure-text-primary dark:text-matrix-text capitalize",children:r.provider}),e.jsx("td",{className:"px-4 py-3 font-mono text-azure-text-primary dark:text-matrix-highlight text-xs",children:r.model}),e.jsxs("td",{className:"px-4 py-3 text-azure-text-primary dark:text-matrix-text",children:["$",r.input_price_per_1m.toFixed(4)]}),e.jsxs("td",{className:"px-4 py-3 text-azure-text-primary dark:text-matrix-text",children:["$",r.output_price_per_1m.toFixed(4)]}),e.jsx("td",{className:"px-4 py-3 text-azure-text-primary dark:text-matrix-text",children:r.audio_cost_per_second!=null?`$${r.audio_cost_per_second.toFixed(6)}`:e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-secondary/40",children:"—"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>$(r),className:"p-1.5 rounded hover:bg-azure-border dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",title:"Edit",children:e.jsx(I,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>c(r),className:"p-1.5 rounded hover:bg-red-50 dark:hover:bg-red-900/20 text-azure-text-secondary dark:text-matrix-secondary hover:text-red-600 dark:hover:text-red-400 transition-colors",title:"Delete",children:e.jsx(R,{className:"w-4 h-4"})})]})})]},`${r.provider}/${r.model}`))})]})}),e.jsx(j,{open:p,onOpenChange:n,children:e.jsxs(z,{children:[e.jsx(v,{children:e.jsx(N,{children:l?"Edit Pricing":"Add Pricing"})}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:"Provider"}),l?e.jsx("p",{className:"px-3 py-2 rounded-lg bg-azure-bg dark:bg-zinc-900 text-azure-text-primary dark:text-matrix-secondary text-sm capitalize",children:t.provider}):e.jsxs("select",{value:t.provider,onChange:r=>i({...t,provider:r.target.value}),className:"w-full px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight",children:[e.jsx("option",{value:"",children:"Select provider..."}),A.map(r=>e.jsx("option",{value:r,children:r},r))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:"Model"}),l?e.jsx("p",{className:"px-3 py-2 rounded-lg bg-azure-bg dark:bg-zinc-900 text-azure-text-primary dark:text-matrix-secondary text-sm font-mono",children:t.model}):e.jsx("input",{type:"text",value:t.model,onChange:r=>i({...t,model:r.target.value}),placeholder:"e.g. gpt-4o",className:"w-full px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:"Input price / 1M tokens ($)"}),e.jsx("input",{type:"number",min:0,step:.001,value:t.input_price_per_1m,onChange:r=>i({...t,input_price_per_1m:parseFloat(r.target.value)||0}),className:"w-full px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:"Output price / 1M tokens ($)"}),e.jsx("input",{type:"number",min:0,step:.001,value:t.output_price_per_1m,onChange:r=>i({...t,output_price_per_1m:parseFloat(r.target.value)||0}),className:"w-full px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:["Audio price / second ($)",e.jsx("span",{className:"ml-2 text-[11px] font-normal text-azure-text-secondary/60 dark:text-matrix-secondary/40",children:"for Whisper/audio-only models · leave blank for token-based"})]}),e.jsx("input",{type:"number",min:0,step:1e-6,placeholder:"e.g. 0.0001 (Whisper = $0.006/min)",value:t.audio_cost_per_second??"",onChange:r=>i({...t,audio_cost_per_second:r.target.value===""?null:parseFloat(r.target.value)}),className:"w-full px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight placeholder-azure-text-secondary/40 dark:placeholder-matrix-secondary/30"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:()=>n(!1),className:"px-4 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary text-sm hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:S,disabled:k||!t.provider.trim()||!t.model.trim(),className:"px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-matrix-highlight text-sm font-medium hover:opacity-90 disabled:opacity-50 transition-opacity",children:k?"Saving...":"Save"})]})]})]})}),e.jsx(j,{open:!!d,onOpenChange:r=>!r&&c(null),children:e.jsxs(z,{children:[e.jsx(v,{children:e.jsx(N,{children:"Delete Pricing Entry"})}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("p",{className:"text-sm text-azure-text-primary dark:text-matrix-text",children:["Are you sure you want to delete the pricing for"," ",e.jsxs("span",{className:"font-mono font-semibold text-azure-primary dark:text-matrix-highlight",children:[d?.provider,"/",d?.model]}),"? This cannot be undone."]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>c(null),className:"px-4 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary text-sm hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:P,className:"px-4 py-2 rounded-lg bg-red-600 text-white text-sm font-medium hover:bg-red-700 transition-colors",children:"Delete"})]})]})]})})]})};export{V as ModelPricing};
@@ -1 +0,0 @@
1
- import{j as e,m as n}from"./vendor-motion-C3CZ8ZlO.js";import{r as i,L as P}from"./vendor-react-DikRIOlj.js";import{u as S}from"./vendor-utils-D4NnWbOU.js";import{w as y,D as _,e as D,j as R}from"./index-Bta9YXEm.js";import{P as O}from"./Pagination-BHZKk42X.js";import{B as k,a8 as A,a9 as F,aa as B,_ as L,p as W,q as E,g as J}from"./vendor-icons-NHF9HNeN.js";const M={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},g={hidden:{opacity:0,y:10},show:{opacity:1,y:0}},j=({status:r})=>r==="completed"?e.jsxs("div",{className:"flex items-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(W,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs",children:"Completed"})]}):r==="failed"?e.jsxs("div",{className:"flex items-center gap-1.5 text-red-600 dark:text-red-400",children:[e.jsx(E,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs",children:"Failed"})]}):e.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-600 dark:text-yellow-400",children:[e.jsx(J,{className:"w-4 h-4 animate-pulse"}),e.jsx("span",{className:"text-xs",children:"Pending"})]}),x=r=>new Date(r).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),U=r=>{try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}},X=()=>{const[r,f]=i.useState(!1),[c,N]=i.useState("all"),[m,d]=i.useState(1),[h,v]=i.useState(20),[a,u]=i.useState(null),{data:s,mutate:z}=S(["/webhooks/notifications",r,c,m,h],()=>y.listNotifications({unreadOnly:r,status:c,page:m,per_page:h}),{refreshInterval:5e3}),o=s?.data??[],l=o.filter(t=>!t.read).length,b=async t=>{t.length!==0&&(await y.markRead(t),await z())},w=()=>{const t=o.filter(p=>!p.read).map(p=>p.id);b(t)},C=async t=>{u(t),t.read||await b([t.id])};return e.jsxs(n.div,{variants:M,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(n.div,{variants:g,className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:[e.jsx(k,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"}),l>0&&e.jsx("span",{className:"absolute -top-1.5 -right-1.5 bg-red-500 text-white text-[10px] font-bold rounded-full w-4 h-4 flex items-center justify-center leading-none",children:l>9?"9+":l})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Notifications"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:"Webhook execution results from the Oracle agent."})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs(P,{to:"/webhooks",className:"flex items-center gap-2 text-sm text-azure-text-secondary dark:text-matrix-dim hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",children:[e.jsx(A,{className:"w-4 h-4"}),"Back to Webhooks"]}),e.jsxs("select",{value:c,onChange:t=>{N(t.target.value),d(1)},className:"px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black text-azure-text-secondary dark:text-matrix-dim text-sm focus:outline-none focus:border-azure-primary dark:focus:border-matrix-highlight",children:[e.jsx("option",{value:"all",children:"All statuses"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"failed",children:"Failed"}),e.jsx("option",{value:"pending",children:"Pending"})]}),e.jsxs("button",{onClick:()=>{f(!r),d(1)},className:`flex items-center gap-2 px-3 py-2 rounded-lg border text-sm transition-colors ${r?"border-azure-primary dark:border-matrix-highlight bg-azure-active dark:bg-matrix-primary/20 text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-dim hover:bg-azure-surface dark:hover:bg-zinc-800"}`,children:[e.jsx(F,{className:"w-4 h-4"}),"Unread only"]}),l>0&&e.jsxs("button",{onClick:w,className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-sm text-azure-text-secondary dark:text-matrix-dim hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:[e.jsx(B,{className:"w-4 h-4"}),"Mark all read"]})]})]}),e.jsx(n.div,{variants:g,className:"rounded-lg border border-azure-border dark:border-matrix-primary overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-azure-surface dark:bg-zinc-900 border-b border-azure-border dark:border-matrix-primary",children:e.jsx("tr",{children:["","Webhook","Status","Created","Completed","Actions"].map(t=>e.jsx("th",{className:"px-4 py-3 text-left font-semibold text-azure-text-secondary dark:text-matrix-dim",children:t},t))})}),e.jsx("tbody",{children:o.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-10 text-center text-azure-text-secondary dark:text-matrix-dim",children:r?"No unread notifications.":"No notifications yet."})}):o.map(t=>e.jsxs("tr",{className:`border-b border-azure-border dark:border-matrix-primary/30 hover:bg-azure-surface/50 dark:hover:bg-zinc-800/50 transition-colors ${t.read?"":"bg-blue-50/40 dark:bg-blue-900/10"}`,children:[e.jsx("td",{className:"px-4 py-3 w-6",children:!t.read&&e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-blue-500 dark:bg-matrix-highlight"})}),e.jsx("td",{className:"px-4 py-3 font-mono font-medium text-azure-text-primary dark:text-matrix-text",children:t.webhook_name}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(j,{status:t.status})}),e.jsx("td",{className:"px-4 py-3 text-xs text-azure-text-secondary dark:text-matrix-dim whitespace-nowrap",children:x(t.created_at)}),e.jsx("td",{className:"px-4 py-3 text-xs text-azure-text-secondary dark:text-matrix-dim whitespace-nowrap",children:t.completed_at?x(t.completed_at):"—"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>C(t),title:"View details",className:"p-1.5 rounded hover:bg-azure-border dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-dim hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",children:e.jsx(L,{className:"w-4 h-4"})})})]},t.id))})]})})}),s&&s.total_pages>1&&e.jsx(n.div,{variants:g,children:e.jsx("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black",children:e.jsx(O,{page:m,totalPages:s.total_pages,perPage:h,total:s.total,onPageChange:d,onPerPageChange:t=>{v(t),d(1)}})})}),e.jsxs(_,{open:!!a,onOpenChange:t=>!t&&u(null),children:[e.jsx(D,{children:e.jsxs(R,{className:"text-azure-text-primary dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(k,{className:"w-4 h-4"}),a?.webhook_name]})}),a&&e.jsxs("div",{className:"p-6 space-y-4 overflow-y-auto max-h-[65vh]",children:[e.jsxs("div",{className:"flex items-center gap-4 text-xs text-azure-text-secondary dark:text-matrix-dim",children:[e.jsx(j,{status:a.status}),e.jsx("span",{children:x(a.created_at)}),a.completed_at&&e.jsxs("span",{children:["→ ",x(a.completed_at)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-azure-text-secondary dark:text-matrix-dim mb-1.5",children:"Received Payload"}),e.jsx("pre",{className:"bg-azure-bg dark:bg-zinc-950 rounded-lg p-3 text-xs font-mono overflow-auto max-h-44 text-azure-text-primary dark:text-matrix-text border border-azure-border dark:border-matrix-primary/30 whitespace-pre-wrap",children:U(a.payload)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-azure-text-secondary dark:text-matrix-dim mb-1.5",children:"Agent Result"}),e.jsx("div",{className:"bg-azure-bg dark:bg-zinc-950 rounded-lg p-3 text-xs font-mono overflow-auto max-h-64 text-azure-text-primary dark:text-matrix-text border border-azure-border dark:border-matrix-primary/30 whitespace-pre-wrap",children:a.result??e.jsx("span",{className:"text-yellow-600 dark:text-yellow-400 animate-pulse",children:"Processing…"})})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx("button",{onClick:()=>u(null),className:"px-4 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-dim text-sm hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:"Close"})})]})]})]})};export{X as Notifications};
@@ -1 +0,0 @@
1
- import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as i}from"./vendor-react-DikRIOlj.js";import{B as j,h as N}from"./index-Bta9YXEm.js";import{M as de,D as oe}from"./DeleteConfirmationModal-Du85q5u2.js";import{V as xe,Y as me,Z as H,g as ue,_ as O,$ as he,a0 as ge,A as pe,z as B,a1 as fe}from"./vendor-icons-NHF9HNeN.js";import{P as je}from"./Pagination-BHZKk42X.js";import"./vendor-utils-D4NnWbOU.js";const ye=({className:r,...a})=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{className:`w-full caption-bottom text-sm ${r}`,...a})}),be=({...r})=>e.jsx("thead",{...r}),ke=({...r})=>e.jsx("tbody",{...r}),M=({...r})=>e.jsx("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 transition-colors hover:bg-azure-hover/50 dark:hover:bg-matrix-primary/10",...r}),f=({className:r,...a})=>e.jsx("th",{className:`h-12 px-4 text-left align-middle font-medium text-azure-text-secondary dark:text-matrix-secondary/70 [&:has([role=checkbox])]:pr-0 ${r}`,...a}),g=({className:r,...a})=>e.jsx("td",{className:`p-4 align-middle [&:has([role=checkbox])]:pr-0 ${r}`,...a}),F=({checked:r,onCheckedChange:a,className:s,...n})=>{const l=x=>{a&&a(x.target.checked),n.onChange&&n.onChange(x)};return e.jsx("input",{type:"checkbox",checked:r,onChange:l,className:`h-4 w-4 rounded border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-primary dark:text-matrix-highlight focus:ring-azure-primary dark:focus:ring-matrix-highlight ${s||""}`,...n})},v=({className:r,variant:a="default",...s})=>{const l=`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-zinc-950 focus:ring-offset-2 dark:focus:ring-zinc-300 ${a==="destructive"?"border-transparent bg-red-500 text-zinc-50 dark:bg-red-900 dark:text-zinc-50":a==="secondary"?"border-transparent bg-azure-surface dark:bg-zinc-800 text-azure-text-secondary dark:text-matrix-secondary":a==="outline"?"text-azure-text-primary dark:text-matrix-secondary border-azure-border dark:border-matrix-primary":"border-transparent bg-azure-primary dark:bg-matrix-highlight text-azure-text-inverse dark:text-black"} ${r||""}`;return e.jsx("div",{className:l,...s})},T=({className:r,...a})=>e.jsx("div",{className:`rounded-lg border border-azure-border dark:border-matrix-primary/30 bg-azure-surface dark:bg-zinc-900 text-azure-text-primary dark:text-matrix-secondary shadow-sm ${r||""}`,...a}),I=({className:r,...a})=>e.jsx("div",{className:`flex flex-col space-y-1.5 p-6 ${r||""}`,...a}),Ne=({className:r,...a})=>e.jsx("h3",{className:`text-2xl font-semibold leading-none tracking-tight ${r||""}`,...a}),A=({className:r,...a})=>e.jsx("div",{className:`p-6 pt-0 ${r||""}`,...a}),ve=({className:r,variant:a="default",...s})=>{const l=`relative w-full rounded-lg border p-4 ${a==="destructive"?"border-red-500/50 text-red-700 dark:border-red-900/50 dark:text-red-300":"border-azure-border dark:border-matrix-primary"} ${r||""}`;return e.jsx("div",{className:l,...s})},ze=({className:r,...a})=>e.jsx("div",{className:`text-sm [&_p]:leading-relaxed ${r||""}`,...a}),we=({isOpen:r,onClose:a,memory:s})=>s?e.jsx(de,{isOpen:r,onClose:a,title:"Memory Details",size:"lg",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Category"})]}),e.jsx("div",{children:e.jsx(v,{variant:"outline",children:s.category})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Importance"})]}),e.jsx("div",{children:e.jsx(v,{variant:s.importance==="critical"?"destructive":s.importance==="high"?"default":s.importance==="medium"?"secondary":"outline",children:s.importance})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Created"})]}),e.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:new Date(s.created_at).toLocaleString()}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Updated"})]}),e.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:new Date(s.updated_at).toLocaleString()}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Access Count"})]}),e.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:s.access_count}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Hash"})]}),e.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary break-all text-sm",children:s.hash}),s.source&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Source"})]}),e.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:s.source})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm mb-2",children:"Summary"}),e.jsx("p",{className:"text-azure-text-primary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 p-3 rounded-md",children:s.summary})]}),s.details&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm mb-2",children:"Details"}),e.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 p-3 rounded-md whitespace-pre-wrap",children:s.details})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(j,{onClick:a,children:"Close"})})]})}):null,Ce=()=>{const[r,a]=i.useState(!1),[s,n]=i.useState(null),l=i.useCallback(o=>(a(!0),n(null),N.get(o).then(c=>c).catch(c=>{throw n(c.message||"An error occurred"),c}).finally(()=>{a(!1)})),[]),x=i.useCallback((o,c)=>(a(!0),n(null),N.post(o,c).then(d=>d).catch(d=>{throw n(d.message||"An error occurred"),d}).finally(()=>{a(!1)})),[]),m=i.useCallback((o,c)=>(a(!0),n(null),N.post(o,c).then(d=>d).catch(d=>{throw n(d.message||"An error occurred"),d}).finally(()=>{a(!1)})),[]),z=i.useCallback(o=>(a(!0),n(null),N.delete(o).then(c=>c).catch(c=>{throw n(c.message||"An error occurred"),c}).finally(()=>{a(!1)})),[]);return{get:l,post:x,put:m,del:z,loading:r,error:s}},_e=()=>{const[r,a]=i.useState([]),[s,n]=i.useState(!0),[l,x]=i.useState([]),[m,z]=i.useState(""),[o,c]=i.useState("all"),[d,R]=i.useState("all"),[u,y]=i.useState(1),[h,U]=i.useState(20),[V,q]=i.useState(0),[$,Y]=i.useState(1),[P,b]=i.useState(null),[Z,w]=i.useState(!1),[G,J]=i.useState(null),[K,_]=i.useState(!1),[E,L]=i.useState(null),[Q,C]=i.useState(!1),{get:W,del:X,post:ee}=Ce(),S=i.useCallback(async(t=u,D=h)=>{try{n(!0);const p=new URLSearchParams({page:String(t),per_page:String(D)});o!=="all"&&p.set("category",o),d!=="all"&&p.set("importance",d),m.trim()&&p.set("search",m.trim());const k=await W(`/sati/memories?${p}`);a(k.data??k),q(k.total??0),Y(k.total_pages??1),b(null)}catch(p){b("Failed to load memories. Please try again."),console.error("Error fetching memories:",p)}finally{n(!1)}},[u,h,o,d,m]);i.useEffect(()=>{S(u,h)},[u,h,o,d,m]);const te=()=>{l.length===r.length?x([]):x(r.map(t=>t.id))},re=t=>{l.includes(t)?x(l.filter(D=>D!==t)):x([...l,t])},ae=async()=>{if(l.length!==0)try{await ee("/sati/memories/bulk-delete",{ids:l}),await S(u,h),x([]),w(!1)}catch(t){b("Failed to delete memories. Please try again."),console.error("Error deleting memories:",t)}},se=t=>{L(t),C(!0)},ie=async()=>{if(E)try{await X(`/sati/memories/${E}`),await S(u,h)}catch(t){b("Failed to delete memory. Please try again."),console.error("Error deleting memory:",t)}finally{L(null),C(!1)}},le=t=>{J(t),_(!0)},ne=["preference","project","identity","constraint","context","personal_data","languages","favorite_things","relationships","pets","naming","professional_profile"],ce=["low","medium","high"];return s&&r.length===0?e.jsx(T,{className:"w-full",children:e.jsx(A,{className:"flex justify-center items-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-azure-primary dark:border-matrix-highlight"})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(pe,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Sati Memories"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"View and manage long-term memories stored by Sati."})]})]}),l.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm text-azure-text-muted dark:text-matrix-secondary",children:[l.length," selected"]}),e.jsxs(j,{variant:"destructive",size:"sm",onClick:()=>w(!0),disabled:l.length===0,children:[e.jsx(B,{className:"w-4 h-4 mr-1"}),"Delete Selected"]})]})]}),P&&e.jsx(ve,{variant:"destructive",children:e.jsx(ze,{children:P})}),e.jsxs(T,{children:[e.jsx(I,{className:"border-b border-azure-border dark:border-matrix-primary",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[e.jsxs("div",{className:"flex flex-col relative w-full",children:[e.jsx(fe,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-azure-text-secondary dark:text-matrix-secondary w-4 h-4"}),e.jsx("input",{type:"text",placeholder:"Search memories...",value:m,onChange:t=>{z(t.target.value),y(1)},className:"w-full pl-10 pr-4 py-2 bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded-md text-azure-text-primary dark:text-matrix-secondary focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full",children:[e.jsxs("select",{value:o,onChange:t=>{c(t.target.value),y(1)},className:"px-3 py-2 bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded-md text-azure-text-primary dark:text-matrix-secondary focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight flex-grow",children:[e.jsx("option",{value:"all",children:"All Categories"}),ne.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsxs("select",{value:d,onChange:t=>{R(t.target.value),y(1)},className:"px-3 py-2 bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded-md text-azure-text-primary dark:text-matrix-secondary focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight flex-grow",children:[e.jsx("option",{value:"all",children:"All Importance"}),ce.map(t=>e.jsx("option",{value:t,children:t},t))]})]})]})}),e.jsx(A,{className:"p-0",children:e.jsxs(ye,{children:[e.jsx(be,{children:e.jsxs(M,{className:"hover:bg-transparent",children:[e.jsx(f,{className:"w-12",children:e.jsx(F,{checked:r.length>0&&l.length===r.length,onCheckedChange:te})}),e.jsx(f,{children:"Summary"}),e.jsx(f,{children:"Category"}),e.jsx(f,{children:"Importance"}),e.jsx(f,{children:"Created"}),e.jsx(f,{className:"w-32",children:"Actions"})]})}),e.jsx(ke,{children:r.length===0?e.jsx(M,{children:e.jsx(g,{colSpan:6,className:"text-center py-8 text-azure-text-secondary dark:text-matrix-secondary",children:s?"Loading memories...":"No memories found"})}):r.map(t=>e.jsxs(M,{children:[e.jsx(g,{children:e.jsx(F,{checked:l.includes(t.id),onCheckedChange:()=>re(t.id)})}),e.jsx(g,{className:"font-medium max-w-xs truncate",children:t.summary}),e.jsx(g,{children:e.jsx(v,{variant:"outline",children:t.category})}),e.jsx(g,{children:e.jsx(v,{variant:t.importance==="critical"?"destructive":t.importance==="high"?"default":t.importance==="medium"?"secondary":"outline",children:t.importance})}),e.jsx(g,{children:e.jsxs("div",{className:"flex items-center gap-1 text-azure-text-secondary dark:text-matrix-secondary",children:[e.jsx(H,{className:"w-4 h-4"}),new Date(t.created_at).toLocaleDateString()]})}),e.jsx(g,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>le(t),className:"text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:e.jsx(O,{className:"w-4 h-4"})}),e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>se(t.id),className:"text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:e.jsx(B,{className:"w-4 h-4"})})]})})]},t.id))})]})}),$>1&&e.jsx(je,{page:u,totalPages:$,perPage:h,total:V,onPageChange:y,onPerPageChange:t=>{U(t),y(1)}})]}),Z&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs(T,{className:"w-full max-w-md mx-4",children:[e.jsx(I,{children:e.jsx(Ne,{children:"Delete Memories"})}),e.jsxs(A,{children:[e.jsxs("p",{className:"mb-4",children:["Are you sure you want to delete ",l.length," ","memory(ies)? This action cannot be undone."]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(j,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(j,{variant:"destructive",onClick:ae,children:"Delete"})]})]})]})}),e.jsx(we,{isOpen:K,onClose:()=>_(!1),memory:G}),e.jsx(oe,{isOpen:Q,onClose:()=>C(!1),onConfirm:ie,title:"Confirm Memory Deletion",message:"Are you sure you want to delete this memory? This action cannot be undone.",confirmButtonText:"Delete Memory",cancelButtonText:"Cancel"})]})};export{_e as SatiMemories};
@@ -1,9 +0,0 @@
1
- import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as u,f as F,c as I}from"./vendor-react-DikRIOlj.js";import{u as P}from"./audit-Dc3YW0-4.js";import{u as J}from"./agents-CgqJea9n.js";import{E as N,q as D,G as E,K as A,m as $,g as R,J as V,ai as W,as as T,I as B,o as M,a6 as G,w as K,y as Z,aj as q,i as H,at as X,au as Q,F as Y,a8 as ee,av as te,r as re,a2 as se}from"./vendor-icons-NHF9HNeN.js";import"./vendor-utils-D4NnWbOU.js";import"./index-Bta9YXEm.js";const ae={llm_call:e.jsx(T,{size:16}),tool_call:e.jsx(N,{size:16}),mcp_tool:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M3.49994 11.7501L11.6717 3.57855C12.7762 2.47398 14.5672 2.47398 15.6717 3.57855C16.7762 4.68312 16.7762 6.47398 15.6717 7.57855M15.6717 7.57855L9.49994 13.7501M15.6717 7.57855C16.7762 6.47398 18.5672 6.47398 19.6717 7.57855C20.7762 8.68312 20.7762 10.474 19.6717 11.5785L12.7072 18.543C12.3167 18.9335 12.3167 19.5667 12.7072 19.9572L13.9999 21.2499",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M17.4999 9.74921L11.3282 15.921C10.2237 17.0255 8.43272 17.0255 7.32823 15.921C6.22373 14.8164 6.22373 13.0255 7.32823 11.921L13.4999 5.74939",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),task_created:e.jsx(W,{size:16}),task_completed:e.jsx(E,{size:16}),skill_loaded:e.jsx(V,{size:16}),chronos_job:e.jsx(R,{size:16}),memory_recovery:e.jsx($,{size:16}),memory_persist:e.jsx($,{size:16}),telephonist:e.jsx(A,{size:16})},ne={llm_call:"text-blue-400 dark:text-blue-400",tool_call:"text-amber-500 dark:text-amber-400",mcp_tool:"text-orange-500 dark:text-orange-400",task_created:"text-gray-500 dark:text-matrix-secondary",task_completed:"text-green-600 dark:text-matrix-highlight",skill_loaded:"text-teal-600 dark:text-teal-400",chronos_job:"text-orange-500 dark:text-orange-400",memory_recovery:"text-emerald-600 dark:text-emerald-400",memory_persist:"text-violet-600 dark:text-violet-400",telephonist:"text-rose-500 dark:text-rose-400"},oe={llm_call:"border-blue-300 dark:border-blue-500/40",tool_call:"border-amber-300 dark:border-amber-500/40",mcp_tool:"border-purple-300 dark:border-purple-500/40",task_created:"border-gray-300 dark:border-matrix-primary/40",task_completed:"border-green-300 dark:border-matrix-highlight/40",skill_loaded:"border-teal-300 dark:border-teal-500/40",chronos_job:"border-orange-300 dark:border-orange-500/40",memory_recovery:"border-emerald-300 dark:border-emerald-500/40",memory_persist:"border-violet-300 dark:border-violet-500/40",telephonist:"border-rose-300 dark:border-rose-500/40"};function ie(t){return t==null?"—":t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function le(t){return t==null||t===0?"—":t<1e-4?"<$0.0001":`$${t.toFixed(4)}`}function de(t,r){if(t==null&&r==null)return"";const d=t??0,i=r??0;return`↑${d.toLocaleString()} ↓${i.toLocaleString()}`}function L(t){return typeof t=="string"?t:JSON.stringify(t,null,2)}function xe({parsedMeta:t,eventType:r}){const d=r==="tool_call"||r==="mcp_tool",{args:i,result:n,...c}=t;if(r==="memory_persist"){const m=Array.isArray(t.inclusions)?t.inclusions:[],x=Array.isArray(t.edits)?t.edits:[],s=Array.isArray(t.deletions)?t.deletions:[];return m.length===0&&x.length===0&&s.length===0?e.jsx("p",{className:"text-[11px] text-gray-400 dark:text-matrix-secondary/50 italic",children:"No memory changes recorded."}):e.jsxs("div",{className:"space-y-2.5",children:[m.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1 flex items-center gap-1",children:[e.jsx(G,{size:10,className:"text-green-500 dark:text-green-400"})," new memories (",m.length,")"]}),e.jsx("div",{className:"space-y-1",children:m.map((a,l)=>e.jsxs("div",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded px-2 py-1.5 flex items-start gap-2",children:[e.jsx("span",{className:"flex-shrink-0 text-[10px] uppercase font-bold text-violet-500 dark:text-violet-400 bg-violet-50 dark:bg-violet-900/30 px-1 rounded",children:a.category??"?"}),e.jsx("span",{className:"flex-1 break-words",children:a.summary??"—"}),a.importance!=null&&e.jsxs("span",{className:"flex-shrink-0 text-[10px] text-gray-400 dark:text-matrix-secondary/50",children:["imp:",a.importance]})]},l))})]}),x.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1 flex items-center gap-1",children:[e.jsx(K,{size:10,className:"text-amber-500 dark:text-amber-400"})," edited memories (",x.length,")"]}),e.jsx("div",{className:"space-y-1",children:x.map((a,l)=>e.jsxs("div",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded px-2 py-1.5",children:[a.id&&e.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/50 mr-2",children:["#",a.id]}),a.summary&&e.jsx("span",{className:"break-words",children:a.summary}),a.reason&&e.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/50 ml-2",children:["— ",a.reason]})]},l))})]}),s.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1 flex items-center gap-1",children:[e.jsx(Z,{size:10,className:"text-red-500 dark:text-red-400"})," archived memories (",s.length,")"]}),e.jsx("div",{className:"space-y-1",children:s.map((a,l)=>e.jsxs("div",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded px-2 py-1.5",children:[a.id&&e.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/50 mr-2",children:["#",a.id]}),a.reason&&e.jsx("span",{className:"break-words",children:a.reason})]},l))})]})]})}return d&&(i!==void 0||n!==void 0)?e.jsxs("div",{className:"space-y-2",children:[i!==void 0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1",children:"args"}),e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:L(i)})]}),n!==void 0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1",children:"result"}),e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:L(n)})]}),Object.keys(c).length>0&&e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words",children:JSON.stringify(c,null,2)})]}):e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:JSON.stringify(t,null,2)})}const S=({event:t})=>{const[r,d]=u.useState(!1),{getByKey:i}=J(),n=ae[t.event_type]??e.jsx(N,{size:14}),c=ne[t.event_type]??"text-gray-500",m=oe[t.event_type]??"border-gray-300 dark:border-matrix-primary/40",x=t.agent?i(t.agent):null,s=x?.badgeClass??null,a=x?`${t.agent?.toUpperCase()} ${x.emoji}`:t.agent?.toUpperCase()||null,l=(()=>{try{return t.metadata?typeof t.metadata=="object"?t.metadata:JSON.parse(t.metadata):null}catch{return null}})(),o=l!==null&&Object.keys(l).length>0,h=t.event_type==="memory_recovery"?`${l?.memories_count??0} memories retrieved`:t.event_type==="memory_persist"?(()=>{const g=l?.inclusions_count??0,p=l?.edits_count??0,k=l?.deletions_count??0,y=[];return g&&y.push(`+${g} new`),p&&y.push(`~${p} edited`),k&&y.push(`-${k} archived`),y.length>0?y.join(", "):"memory persisted"})():t.event_type==="telephonist"?(()=>{const g=l?.audio_duration_seconds,p=l?.text_preview,k=g!=null?`${g}s`:"",y=typeof p=="string"&&p?`"${p.length>60?p.slice(0,60)+"…":p}"`:"";return[k,y].filter(Boolean).join(" · ")||"audio transcription"})():t.tool_name??t.model??t.event_type,U=t.event_type==="telephonist",v=l?.audio_duration_seconds,b=U?v!=null?`🎵 ${v}s audio`:"":de(t.input_tokens,t.output_tokens),f=le(t.estimated_cost_usd),_=ie(t.duration_ms),w=t.status==="error"?e.jsx(D,{size:14,className:"text-red-500 flex-shrink-0"}):t.status==="success"?e.jsx(E,{size:14,className:"text-green-500 dark:text-matrix-highlight flex-shrink-0"}):null,C=e.jsx("span",{className:`flex-shrink-0 w-3.5 flex items-center justify-center transition-colors ${o?"text-gray-300 dark:text-matrix-secondary/30 hover:text-gray-500 dark:hover:text-matrix-secondary cursor-pointer":"text-transparent pointer-events-none"}`,children:r?e.jsx(B,{size:12}):e.jsx(M,{size:12})}),z=()=>{o&&d(g=>!g)};return e.jsxs("div",{className:"py-2 px-3 rounded-lg hover:bg-gray-50 dark:hover:bg-zinc-900/60 transition-colors border-b border-gray-100 dark:border-matrix-primary/20 last:border-0",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 md:hidden",children:[e.jsxs("div",{className:`flex items-center gap-2 min-w-0 ${o?"cursor-pointer":""}`,onClick:z,children:[C,e.jsx("span",{className:`flex-shrink-0 ${c}`,children:n}),s&&e.jsx("span",{className:`flex-shrink-0 text-xs font-semibold px-1.5 py-0.5 rounded ${s}`,children:a}),e.jsx("span",{className:"flex-1 text-sm text-gray-700 dark:text-matrix-secondary font-mono break-all leading-snug",children:h}),w]}),e.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-0 pl-5 text-[11px] text-gray-400 dark:text-matrix-secondary/60 font-mono",children:[b&&e.jsx("span",{children:b}),e.jsx("span",{children:_}),f!=="—"&&e.jsx("span",{className:"text-gray-600 dark:text-matrix-secondary",children:f})]})]}),e.jsxs("div",{className:`hidden md:flex items-center gap-3 ${o?"cursor-pointer":""}`,onClick:z,children:[C,e.jsx("span",{className:`flex-shrink-0 ${c}`,children:n}),s&&e.jsx("span",{className:`flex-shrink-0 text-xs font-semibold px-1.5 py-0.5 rounded ${s}`,children:a}),e.jsx("span",{className:"flex-1 text-sm truncate text-gray-700 dark:text-matrix-secondary font-mono",children:h}),b&&e.jsx("span",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60 font-mono whitespace-nowrap",children:b}),e.jsx("span",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60 font-mono w-16 text-right whitespace-nowrap",children:_}),w,e.jsx("span",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60 font-mono w-20 text-right whitespace-nowrap",children:f})]}),r&&o&&l&&e.jsx("div",{className:`mt-1.5 ml-5 pl-3 border-l-2 ${m}`,children:e.jsx(xe,{parsedMeta:l,eventType:t.event_type})})]})},ce=({events:t,page:r,pageSize:d,totalCount:i,onPageChange:n})=>{const c=Math.ceil(i/d),m=r*d+1,x=Math.min(r*d+t.length,i);if(t.length===0)return e.jsx("div",{className:"flex items-center justify-center h-40 text-gray-400 dark:text-matrix-secondary/50 text-sm",children:"No audit events for this session."});const s=[],a=new Map;for(const o of t)if(o.task_id){const h=a.get(o.task_id)??[];h.push(o),a.set(o.task_id,h)}const l=new Set;for(const o of t)o.task_id?l.has(o.task_id)||(l.add(o.task_id),s.push({taskId:o.task_id,events:a.get(o.task_id)})):s.push({taskId:null,events:[o]});return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"hidden md:flex items-center gap-3 px-3 py-1 text-xs text-gray-400 dark:text-matrix-secondary/60 border-b border-gray-200 dark:border-matrix-primary/30 font-mono",children:[e.jsx("span",{className:"w-4"}),e.jsx("span",{className:"w-14 flex-shrink-0",children:"agent"}),e.jsx("span",{className:"flex-1",children:"event / tool / model"}),e.jsx("span",{className:"w-28 text-right",children:"tokens ↑↓"}),e.jsx("span",{className:"w-16 text-right",children:"duration"}),e.jsx("span",{className:"w-4"}),e.jsx("span",{className:"w-20 text-right",children:"cost"})]}),e.jsx("div",{className:"flex flex-col",children:s.map(o=>o.taskId?e.jsxs("div",{className:"mb-1",children:[e.jsxs("div",{className:"px-3 py-1 text-xs text-gray-400 dark:text-matrix-secondary/50 font-mono border-l-2 border-blue-300 dark:border-matrix-primary/60 ml-1 mb-0.5",children:["task: ",o.taskId.slice(0,8),"…"]}),e.jsx("div",{className:"pl-4",children:o.events.map(h=>e.jsx(S,{event:h},h.id))})]},o.taskId):e.jsx(S,{event:o.events[0]},o.events[0].id))}),c>1&&e.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-gray-200 dark:border-matrix-primary/30 mt-2",children:[e.jsxs("span",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60",children:[m,"–",x," of ",i," events"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>n(r-1),disabled:r===0,className:"p-1 rounded text-gray-400 dark:text-matrix-secondary hover:text-gray-700 dark:hover:text-matrix-highlight disabled:opacity-30 transition-colors",children:e.jsx(q,{size:16})}),e.jsxs("span",{className:"text-xs self-center text-gray-500 dark:text-matrix-secondary font-mono px-2",children:[r+1," / ",c]}),e.jsx("button",{onClick:()=>n(r+1),disabled:r>=c-1,className:"p-1 rounded text-gray-400 dark:text-matrix-secondary hover:text-gray-700 dark:hover:text-matrix-highlight disabled:opacity-30 transition-colors",children:e.jsx(M,{size:16})})]})]})]})};function j(t){return t===0?"$0.00":t<1e-4?"<$0.0001":`$${t.toFixed(4)}`}function me(t){return t<1e3?`${t}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${(t/6e4).toFixed(1)}m`}const he=({summary:t})=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-matrix-primary p-4 bg-white dark:bg-black",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-700 dark:text-matrix-highlight mb-3 flex items-center gap-2",children:[e.jsx(H,{size:14})," Total Cost"]}),e.jsx("div",{className:"text-2xl font-bold text-gray-900 dark:text-matrix-highlight font-mono",children:j(t.totalCostUsd)}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs text-gray-500 dark:text-matrix-secondary",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{size:12,className:"text-blue-400"}),e.jsxs("span",{children:[t.llmCallCount," LLM calls"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(N,{size:12,className:"text-amber-400"}),e.jsxs("span",{children:[t.toolCallCount," tool calls"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[e.jsx(R,{size:12,className:"text-gray-400"}),e.jsxs("span",{children:[me(t.totalDurationMs)," total duration"]})]}),t.totalAudioSeconds>0&&e.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[e.jsx(A,{size:12,className:"text-rose-400"}),e.jsxs("span",{children:[t.totalAudioSeconds.toFixed(1),"s audio"]})]})]})]}),t.byAgent.length>0&&e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-matrix-primary p-4 bg-white dark:bg-black",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-matrix-highlight mb-3",children:"By Agent"}),e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-gray-400 dark:text-matrix-secondary/60 border-b border-gray-100 dark:border-matrix-primary/30",children:[e.jsx("th",{className:"text-left pb-1.5",children:"Agent"}),e.jsx("th",{className:"text-right pb-1.5",children:"Calls"}),e.jsx("th",{className:"text-right pb-1.5",children:"Tokens"}),e.jsx("th",{className:"text-right pb-1.5",children:"Cost"})]})}),e.jsx("tbody",{children:t.byAgent.map(r=>e.jsxs("tr",{className:"border-b border-gray-50 dark:border-matrix-primary/10 last:border-0",children:[e.jsx("td",{className:"py-1.5 text-gray-700 dark:text-matrix-secondary font-semibold",children:r.agent}),e.jsx("td",{className:"py-1.5 text-right text-gray-500 dark:text-matrix-secondary/70 font-mono",children:r.llmCalls}),e.jsx("td",{className:"py-1.5 text-right text-gray-500 dark:text-matrix-secondary/70 font-mono",children:(r.inputTokens+r.outputTokens).toLocaleString()}),e.jsx("td",{className:"py-1.5 text-right text-gray-700 dark:text-matrix-highlight font-mono",children:j(r.estimatedCostUsd)})]},r.agent))})]})]}),t.byModel.length>0&&e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-matrix-primary p-4 bg-white dark:bg-black",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-matrix-highlight mb-3",children:"By Model"}),e.jsx("div",{className:"flex flex-col gap-2",children:t.byModel.map(r=>e.jsxs("div",{className:"border-b border-gray-50 dark:border-matrix-primary/10 last:border-0 pb-2 last:pb-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-0.5",children:[e.jsx("span",{className:"text-xs font-mono text-gray-700 dark:text-matrix-secondary break-all leading-snug",children:r.model}),e.jsx("span",{className:"text-xs font-mono text-gray-700 dark:text-matrix-highlight whitespace-nowrap shrink-0",children:j(r.estimatedCostUsd)})]}),e.jsxs("div",{className:"text-[11px] text-gray-400 dark:text-matrix-secondary/60 font-mono flex flex-wrap gap-x-3",children:[e.jsxs("span",{children:[r.calls," calls"]}),e.jsxs("span",{children:["in ",r.inputTokens.toLocaleString()]}),e.jsxs("span",{children:["out ",r.outputTokens.toLocaleString()]})]})]},`${r.provider}/${r.model}`))})]})]});function pe(t,r){const d=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),i=URL.createObjectURL(d),n=document.createElement("a");n.href=i,n.download=`audit-${t.slice(0,8)}.json`,n.click(),URL.revokeObjectURL(i)}function ge(t,r){const d=["id","created_at","event_type","agent","tool_name","provider","model","input_tokens","output_tokens","duration_ms","status","estimated_cost_usd"],i=r.events.map(s=>[s.id,new Date(s.created_at).toISOString(),s.event_type,s.agent??"",s.tool_name??"",s.provider??"",s.model??"",s.input_tokens??"",s.output_tokens??"",s.duration_ms??"",s.status??"",s.estimated_cost_usd??""].map(a=>`"${String(a).replace(/"/g,'""')}"`).join(",")),n=[d.join(","),...i].join(`
2
- `),c=new Blob([n],{type:"text/csv"}),m=URL.createObjectURL(c),x=document.createElement("a");x.href=m,x.download=`audit-${t.slice(0,8)}.csv`,x.click(),URL.revokeObjectURL(m)}const ye=({sessionId:t,data:r})=>{const[d,i]=u.useState(!1);return r?e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>i(!d),className:"flex items-center gap-1.5 text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-matrix-primary text-gray-600 dark:text-matrix-secondary hover:text-gray-900 dark:hover:text-matrix-highlight hover:border-gray-300 dark:hover:border-matrix-highlight transition-colors",children:[e.jsx(X,{size:14}),"Export",e.jsx(B,{size:12})]}),d&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-white dark:bg-black border border-gray-200 dark:border-matrix-primary rounded-lg shadow-xl min-w-[140px] py-1",children:[e.jsxs("button",{onClick:()=>{pe(t,r),i(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-matrix-secondary hover:bg-gray-50 dark:hover:bg-zinc-900 transition-colors",children:[e.jsx(Q,{size:14,className:"text-blue-500"}),"Export JSON"]}),e.jsxs("button",{onClick:()=>{ge(t,r),i(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-matrix-secondary hover:bg-gray-50 dark:hover:bg-zinc-900 transition-colors",children:[e.jsx(Y,{size:14,className:"text-green-500"}),"Export CSV"]})]})]})]}):null},O=100,_e=()=>{const{id:t}=F(),r=I(),[d,i]=u.useState(0),{data:n,error:c,isLoading:m}=P(t??null,d,O),x=u.useRef(null),[s,a]=u.useState(()=>typeof window<"u"?window.innerWidth>=768:!0);return u.useEffect(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[n]),e.jsxs("div",{className:"flex flex-col h-full bg-gray-50 dark:bg-black",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-matrix-primary bg-white dark:bg-black flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>r(-1),className:"p-1.5 rounded-lg text-gray-400 dark:text-matrix-secondary hover:text-gray-700 dark:hover:text-matrix-highlight hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors",children:e.jsx(ee,{size:18})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 dark:text-matrix-highlight",children:"Session Audit"}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60 font-mono",children:t})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>a(l=>!l),className:"p-1.5 rounded-lg text-gray-400 dark:text-matrix-secondary hover:text-gray-700 dark:hover:text-matrix-highlight hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors md:hidden",title:"Toggle summary panel",children:e.jsx(te,{size:18})}),e.jsx(ye,{sessionId:t??"",data:n})]})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden relative",children:[s&&e.jsx("div",{className:"fixed inset-0 bg-black/40 z-20 md:hidden",onClick:()=>a(!1)}),e.jsxs("div",{ref:x,className:"flex-[6] overflow-y-auto p-6 custom-scrollbar",children:[m&&e.jsxs("div",{className:"flex items-center justify-center h-40 gap-2 text-gray-400 dark:text-matrix-secondary",children:[e.jsx(re,{size:18,className:"animate-spin"}),"Loading audit events…"]}),c&&e.jsxs("div",{className:"flex items-center gap-2 text-red-500 dark:text-red-400 p-4 rounded-lg border border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-900/20",children:[e.jsx(se,{size:16}),"Failed to load audit events: ",c.message]}),n&&e.jsx(ce,{events:n.events,page:d,pageSize:O,totalCount:n.summary.llmCallCount+n.summary.toolCallCount,onPageChange:i})]}),e.jsx("div",{className:`
3
- fixed top-16 bottom-0 right-0 z-40 w-72
4
- md:relative md:inset-auto md:z-auto md:w-auto md:flex-[4] md:translate-x-0
5
- transition-transform duration-300 ease-out
6
- overflow-y-auto p-6 border-l border-gray-200 dark:border-matrix-primary
7
- bg-white dark:bg-black custom-scrollbar
8
- ${s?"translate-x-0":"translate-x-full"}
9
- `,children:n?e.jsx(he,{summary:n.summary}):!m&&e.jsx("div",{className:"text-sm text-gray-400 dark:text-matrix-secondary/50 text-center mt-10",children:"No summary available."})})]})]})};export{_e as SessionAudit};
@@ -1,49 +0,0 @@
1
- import{j as s}from"./vendor-motion-C3CZ8ZlO.js";import{r as E}from"./vendor-react-DikRIOlj.js";import{t as wr,u as ce,Z as zr,m as ue}from"./vendor-utils-D4NnWbOU.js";import{u as jr,c as Sr}from"./chronos-CZvGhZQB.js";import{T as w,S as K}from"./SelectInput-KVLsnfra.js";import{c as q,N as C,S as re}from"./config-pKL8Y4V9.js";import{h as qe}from"./index-Bta9YXEm.js";import{C as Nr}from"./ConfirmationModal-BBIjVef7.js";import{d as Or,X as Cr,O as $r}from"./vendor-icons-NHF9HNeN.js";function F({title:e,description:t,children:r}){return s.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg p-6 bg-azure-surface/50 dark:bg-matrix-base/50",children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h3",{className:"text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:e}),t&&s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mt-1",children:t})]}),s.jsx("div",{className:"space-y-4",children:r})]})}function ct({label:e,error:t,helperText:r,className:n,...o}){return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-secondary",children:e}),s.jsx("textarea",{className:wr("bg-azure-bg dark:bg-black border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-secondary placeholder-azure-text-secondary/50 dark:placeholder-matrix-secondary/50 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight transition-colors resize-y min-h-[80px]",t&&"border-red-500 focus:border-red-500 focus:ring-red-500",n),rows:10,...o}),r&&!t&&s.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:r}),t&&s.jsx("p",{className:"text-xs text-red-500",children:t})]})}function m(e,t,r){function n(c,d){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:d,constr:a,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,d);const p=a.prototype,f=Object.keys(p);for(let h=0;h<f.length;h++){const u=f[h];u in c||(c[u]=p[u].bind(c))}}const o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(c){var d;const p=r?.Parent?new i:this;n(p,c),(d=p._zod).deferred??(d.deferred=[]);for(const f of p._zod.deferred)f();return p}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}class ke extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Tt extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Et={};function de(e){return Et}function It(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Ye(e,t){return typeof t=="bigint"?t.toString():t}function Je(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Qe(e){return e==null}function et(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Zr(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let o=(n.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(n)){const d=n.match(/\d?e-(\d?)/);d?.[1]&&(o=Number.parseInt(d[1]))}const i=r>o?r:o,a=Number.parseInt(e.toFixed(i).replace(".","")),c=Number.parseInt(t.toFixed(i).replace(".",""));return a%c/10**i}const ut=Symbol("evaluating");function j(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==ut)return n===void 0&&(n=ut,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function ge(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function pe(...e){const t={};for(const r of e){const n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function dt(e){return JSON.stringify(e)}function Ar(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Pt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ze(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Tr=Je(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function we(e){if(Ze(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(Ze(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Rt(e){return we(e)?{...e}:Array.isArray(e)?[...e]:e}const Er=new Set(["string","number","symbol"]);function ze(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fe(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function g(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Ir(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Pr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Rr(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=pe(e._zod.def,{get shape(){const a={};for(const c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(a[c]=r.shape[c])}return ge(this,"shape",a),a},checks:[]});return fe(e,i)}function Dr(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=pe(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete a[c]}return ge(this,"shape",a),a},checks:[]});return fe(e,i)}function Mr(e,t){if(!we(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const i=e._zod.def.shape;for(const a in t)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=pe(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return ge(this,"shape",i),i}});return fe(e,o)}function Lr(e,t){if(!we(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=pe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return ge(this,"shape",n),n}});return fe(e,r)}function Jr(e,t){const r=pe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return ge(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return fe(e,r)}function Ur(e,t,r){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=pe(t._zod.def,{get shape(){const c=t._zod.def.shape,d={...c};if(r)for(const p in r){if(!(p in c))throw new Error(`Unrecognized key: "${p}"`);r[p]&&(d[p]=e?new e({type:"optional",innerType:c[p]}):c[p])}else for(const p in c)d[p]=e?new e({type:"optional",innerType:c[p]}):c[p];return ge(this,"shape",d),d},checks:[]});return fe(t,a)}function Fr(e,t,r){const n=pe(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(r)for(const a in r){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=new e({type:"nonoptional",innerType:o[a]}))}else for(const a in o)i[a]=new e({type:"nonoptional",innerType:o[a]});return ge(this,"shape",i),i}});return fe(t,n)}function ye(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function _e(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ee(e){return typeof e=="string"?e:e?.message}function me(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const o=Ee(e.inst?._zod.def?.error?.(e))??Ee(t?.error?.(e))??Ee(r.customError?.(e))??Ee(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function tt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ae(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const Dt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ye,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Mt=m("$ZodError",Dt),Lt=m("$ZodError",Dt,{Parent:Error});function Br(e,t=r=>r.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Kr(e,t=r=>r.message){const r={_errors:[]},n=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)r._errors.push(t(i));else{let a=r,c=0;for(;c<i.path.length;){const d=i.path[c];c===i.path.length-1?(a[d]=a[d]||{_errors:[]},a[d]._errors.push(t(i))):a[d]=a[d]||{_errors:[]},a=a[d],c++}}};return n(e),r}const rt=e=>(t,r,n,o)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new ke;if(a.issues.length){const c=new(o?.Err??e)(a.issues.map(d=>me(d,i,de())));throw Pt(c,o?.callee),c}return a.value},nt=e=>async(t,r,n,o)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const c=new(o?.Err??e)(a.issues.map(d=>me(d,i,de())));throw Pt(c,o?.callee),c}return a.value},Ue=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new ke;return i.issues.length?{success:!1,error:new(e??Mt)(i.issues.map(a=>me(a,o,de())))}:{success:!0,data:i.value}},Vr=Ue(Lt),Fe=e=>async(t,r,n)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>me(a,o,de())))}:{success:!0,data:i.value}},Wr=Fe(Lt),Gr=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return rt(e)(t,r,o)},qr=e=>(t,r,n)=>rt(e)(t,r,n),Yr=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return nt(e)(t,r,o)},Hr=e=>async(t,r,n)=>nt(e)(t,r,n),Xr=e=>(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ue(e)(t,r,o)},Qr=e=>(t,r,n)=>Ue(e)(t,r,n),en=e=>async(t,r,n)=>{const o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Fe(e)(t,r,o)},tn=e=>async(t,r,n)=>Fe(e)(t,r,n),rn=/^[cC][^\s-]{8,}$/,nn=/^[0-9a-z]+$/,on=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,an=/^[0-9a-vA-V]{20}$/,sn=/^[A-Za-z0-9]{27}$/,ln=/^[a-zA-Z0-9_-]{21}$/,cn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,un=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,mt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,dn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,mn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function pn(){return new RegExp(mn,"u")}const fn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,hn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,gn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,bn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,vn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Jt=/^[A-Za-z0-9_-]*$/,xn=/^\+[1-9]\d{6,14}$/,Ut="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",yn=new RegExp(`^${Ut}$`);function Ft(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function _n(e){return new RegExp(`^${Ft(e)}$`)}function kn(e){const t=Ft({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Ut}T(?:${n})$`)}const wn=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},zn=/^-?\d+$/,Bt=/^-?\d+(?:\.\d+)?$/,jn=/^(?:true|false)$/i,Sn=/^[^A-Z]*$/,Nn=/^[^a-z]*$/,W=m("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Kt={number:"number",bigint:"bigint",object:"date"},Vt=m("$ZodCheckLessThan",(e,t)=>{W.init(e,t);const r=Kt[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Wt=m("$ZodCheckGreaterThan",(e,t)=>{W.init(e,t);const r=Kt[typeof t.value];e._zod.onattach.push(n=>{const o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),On=m("$ZodCheckMultipleOf",(e,t)=>{W.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Zr(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Cn=m("$ZodCheckNumberFormat",(e,t)=>{W.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[o,i]=Pr[t.format];e._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=o,c.maximum=i,r&&(c.pattern=zn)}),e._zod.check=a=>{const c=a.value;if(r){if(!Number.isInteger(c)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<o&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>i&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),$n=m("$ZodCheckMaxLength",(e,t)=>{var r;W.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Qe(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const o=n.value;if(o.length<=t.maximum)return;const a=tt(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Zn=m("$ZodCheckMinLength",(e,t)=>{var r;W.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Qe(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const o=n.value;if(o.length>=t.minimum)return;const a=tt(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),An=m("$ZodCheckLengthEquals",(e,t)=>{var r;W.init(e,t),(r=e._zod.def).when??(r.when=n=>{const o=n.value;return!Qe(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{const o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{const o=n.value,i=o.length;if(i===t.length)return;const a=tt(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Be=m("$ZodCheckStringFormat",(e,t)=>{var r,n;W.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Tn=m("$ZodCheckRegex",(e,t)=>{Be.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),En=m("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Sn),Be.init(e,t)}),In=m("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Nn),Be.init(e,t)}),Pn=m("$ZodCheckIncludes",(e,t)=>{W.init(e,t);const r=ze(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Rn=m("$ZodCheckStartsWith",(e,t)=>{W.init(e,t);const r=new RegExp(`^${ze(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Dn=m("$ZodCheckEndsWith",(e,t)=>{W.init(e,t);const r=new RegExp(`.*${ze(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Mn=m("$ZodCheckOverwrite",(e,t)=>{W.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class Ln{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
2
- `).filter(a=>a),o=Math.min(...n.map(a=>a.length-a.trimStart().length)),i=n.map(a=>a.slice(o)).map(a=>" ".repeat(this.indent*2)+a);for(const a of i)this.content.push(a)}compile(){const t=Function,r=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...r,o.join(`
3
- `))}}const Jn={major:4,minor:3,patch:6},I=m("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Jn;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const o of n)for(const i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,c,d)=>{let p=ye(a),f;for(const h of c){if(h._zod.def.when){if(!h._zod.def.when(a))continue}else if(p)continue;const u=a.issues.length,b=h._zod.check(a);if(b instanceof Promise&&d?.async===!1)throw new ke;if(f||b instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await b,a.issues.length!==u&&(p||(p=ye(a,u)))});else{if(a.issues.length===u)continue;p||(p=ye(a,u))}}return f?f.then(()=>a):a},i=(a,c,d)=>{if(ye(a))return a.aborted=!0,a;const p=o(c,n,d);if(p instanceof Promise){if(d.async===!1)throw new ke;return p.then(f=>e._zod.parse(f,d))}return e._zod.parse(p,d)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const p=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return p instanceof Promise?p.then(f=>i(f,a,c)):i(p,a,c)}const d=e._zod.parse(a,c);if(d instanceof Promise){if(c.async===!1)throw new ke;return d.then(p=>o(p,n,c))}return o(d,n,c)}}j(e,"~standard",()=>({validate:o=>{try{const i=Vr(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Wr(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),ot=m("$ZodString",(e,t)=>{I.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??wn(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),A=m("$ZodStringFormat",(e,t)=>{Be.init(e,t),ot.init(e,t)}),Un=m("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=un),A.init(e,t)}),Fn=m("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=mt(n))}else t.pattern??(t.pattern=mt());A.init(e,t)}),Bn=m("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=dn),A.init(e,t)}),Kn=m("$ZodURL",(e,t)=>{A.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Vn=m("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=pn()),A.init(e,t)}),Wn=m("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ln),A.init(e,t)}),Gn=m("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=rn),A.init(e,t)}),qn=m("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=nn),A.init(e,t)}),Yn=m("$ZodULID",(e,t)=>{t.pattern??(t.pattern=on),A.init(e,t)}),Hn=m("$ZodXID",(e,t)=>{t.pattern??(t.pattern=an),A.init(e,t)}),Xn=m("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=sn),A.init(e,t)}),Qn=m("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=kn(t)),A.init(e,t)}),eo=m("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=yn),A.init(e,t)}),to=m("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=_n(t)),A.init(e,t)}),ro=m("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=cn),A.init(e,t)}),no=m("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=fn),A.init(e,t),e._zod.bag.format="ipv4"}),oo=m("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=hn),A.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),ao=m("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=gn),A.init(e,t)}),io=m("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=bn),A.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[o,i]=n;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Gt(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const so=m("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=vn),A.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Gt(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function lo(e){if(!Jt.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Gt(r)}const co=m("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Jt),A.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{lo(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),uo=m("$ZodE164",(e,t)=>{t.pattern??(t.pattern=xn),A.init(e,t)});function mo(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const po=m("$ZodJWT",(e,t)=>{A.init(e,t),e._zod.check=r=>{mo(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),qt=m("$ZodNumber",(e,t)=>{I.init(e,t),e._zod.pattern=e._zod.bag.pattern??Bt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),fo=m("$ZodNumberFormat",(e,t)=>{Cn.init(e,t),qt.init(e,t)}),ho=m("$ZodBoolean",(e,t)=>{I.init(e,t),e._zod.pattern=jn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),go=m("$ZodUnknown",(e,t)=>{I.init(e,t),e._zod.parse=r=>r}),bo=m("$ZodNever",(e,t)=>{I.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function pt(e,t,r){e.issues.length&&t.issues.push(..._e(r,e.issues)),t.value[r]=e.value}const vo=m("$ZodArray",(e,t)=>{I.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);const i=[];for(let a=0;a<o.length;a++){const c=o[a],d=t.element._zod.run({value:c,issues:[]},n);d instanceof Promise?i.push(d.then(p=>pt(p,r,a))):pt(d,r,a)}return i.length?Promise.all(i).then(()=>r):r}});function De(e,t,r,n,o){if(e.issues.length){if(o&&!(r in n))return;t.issues.push(..._e(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Yt(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=Ir(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Ht(e,t,r,n,o,i){const a=[],c=o.keySet,d=o.catchall._zod,p=d.def.type,f=d.optout==="optional";for(const h in t){if(c.has(h))continue;if(p==="never"){a.push(h);continue}const u=d.run({value:t[h],issues:[]},n);u instanceof Promise?e.push(u.then(b=>De(b,r,h,t,f))):De(u,r,h,t,f)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}const xo=m("$ZodObject",(e,t)=>{if(I.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const d={...c};return Object.defineProperty(t,"shape",{value:d}),d}})}const n=Je(()=>Yt(t));j(e._zod,"propValues",()=>{const c=t.shape,d={};for(const p in c){const f=c[p]._zod;if(f.values){d[p]??(d[p]=new Set);for(const h of f.values)d[p].add(h)}}return d});const o=Ze,i=t.catchall;let a;e._zod.parse=(c,d)=>{a??(a=n.value);const p=c.value;if(!o(p))return c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c;c.value={};const f=[],h=a.shape;for(const u of a.keys){const b=h[u],v=b._zod.optout==="optional",D=b._zod.run({value:p[u],issues:[]},d);D instanceof Promise?f.push(D.then(N=>De(N,c,u,p,v))):De(D,c,u,p,v)}return i?Ht(f,p,c,d,n.value,e):f.length?Promise.all(f).then(()=>c):c}}),yo=m("$ZodObjectJIT",(e,t)=>{xo.init(e,t);const r=e._zod.parse,n=Je(()=>Yt(t)),o=u=>{const b=new Ln(["shape","payload","ctx"]),v=n.value,D=B=>{const y=dt(B);return`shape[${y}]._zod.run({ value: input[${y}], issues: [] }, ctx)`};b.write("const input = payload.value;");const N=Object.create(null);let be=0;for(const B of v.keys)N[B]=`key_${be++}`;b.write("const newResult = {};");for(const B of v.keys){const y=N[B],U=dt(B),Ne=u[B]?._zod?.optout==="optional";b.write(`const ${y} = ${D(B)};`),Ne?b.write(`
4
- if (${y}.issues.length) {
5
- if (${U} in input) {
6
- payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
7
- ...iss,
8
- path: iss.path ? [${U}, ...iss.path] : [${U}]
9
- })));
10
- }
11
- }
12
-
13
- if (${y}.value === undefined) {
14
- if (${U} in input) {
15
- newResult[${U}] = undefined;
16
- }
17
- } else {
18
- newResult[${U}] = ${y}.value;
19
- }
20
-
21
- `):b.write(`
22
- if (${y}.issues.length) {
23
- payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
24
- ...iss,
25
- path: iss.path ? [${U}, ...iss.path] : [${U}]
26
- })));
27
- }
28
-
29
- if (${y}.value === undefined) {
30
- if (${U} in input) {
31
- newResult[${U}] = undefined;
32
- }
33
- } else {
34
- newResult[${U}] = ${y}.value;
35
- }
36
-
37
- `)}b.write("payload.value = newResult;"),b.write("return payload;");const T=b.compile();return(B,y)=>T(u,B,y)};let i;const a=Ze,c=!Et.jitless,p=c&&Tr.value,f=t.catchall;let h;e._zod.parse=(u,b)=>{h??(h=n.value);const v=u.value;return a(v)?c&&p&&b?.async===!1&&b.jitless!==!0?(i||(i=o(t.shape)),u=i(u,b),f?Ht([],v,u,b,h,e):u):r(u,b):(u.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),u)}});function ft(e,t,r,n){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!ye(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>me(a,n,de())))}),t)}const Xt=m("$ZodUnion",(e,t)=>{I.init(e,t),j(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),j(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),j(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),j(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>et(i.source)).join("|")})$`)}});const r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let a=!1;const c=[];for(const d of t.options){const p=d._zod.run({value:o.value,issues:[]},i);if(p instanceof Promise)c.push(p),a=!0;else{if(p.issues.length===0)return p;c.push(p)}}return a?Promise.all(c).then(d=>ft(d,o,e,i)):ft(c,o,e,i)}}),_o=m("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Xt.init(e,t);const r=e._zod.parse;j(e._zod,"propValues",()=>{const o={};for(const i of t.options){const a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[c,d]of Object.entries(a)){o[c]||(o[c]=new Set);for(const p of d)o[c].add(p)}}return o});const n=Je(()=>{const o=t.options,i=new Map;for(const a of o){const c=a._zod.propValues?.[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const d of c){if(i.has(d))throw new Error(`Duplicate discriminator value "${String(d)}"`);i.set(d,a)}}return i});e._zod.parse=(o,i)=>{const a=o.value;if(!Ze(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const c=n.value.get(a?.[t.discriminator]);return c?c._zod.run(o,i):t.unionFallback?r(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),o)}}),ko=m("$ZodIntersection",(e,t)=>{I.init(e,t),e._zod.parse=(r,n)=>{const o=r.value,i=t.left._zod.run({value:o,issues:[]},n),a=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([d,p])=>ht(r,d,p)):ht(r,i,a)}});function He(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(we(e)&&we(t)){const r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),o={...e,...t};for(const i of n){const a=He(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const o=e[n],i=t[n],a=He(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function ht(e,t,r){const n=new Map;let o;for(const c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(const d of c.keys)n.has(d)||n.set(d,{}),n.get(d).l=!0}else e.issues.push(c);for(const c of r.issues)if(c.code==="unrecognized_keys")for(const d of c.keys)n.has(d)||n.set(d,{}),n.get(d).r=!0;else e.issues.push(c);const i=[...n].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(i.length&&o&&e.issues.push({...o,keys:i}),ye(e))return e;const a=He(t.value,r.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}const wo=m("$ZodRecord",(e,t)=>{I.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!we(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;const i=[],a=t.keyType._zod.values;if(a){r.value={};const c=new Set;for(const p of a)if(typeof p=="string"||typeof p=="number"||typeof p=="symbol"){c.add(typeof p=="number"?p.toString():p);const f=t.valueType._zod.run({value:o[p],issues:[]},n);f instanceof Promise?i.push(f.then(h=>{h.issues.length&&r.issues.push(..._e(p,h.issues)),r.value[p]=h.value})):(f.issues.length&&r.issues.push(..._e(p,f.issues)),r.value[p]=f.value)}let d;for(const p in o)c.has(p)||(d=d??[],d.push(p));d&&d.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:d})}else{r.value={};for(const c of Reflect.ownKeys(o)){if(c==="__proto__")continue;let d=t.keyType._zod.run({value:c,issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&Bt.test(c)&&d.issues.length){const h=t.keyType._zod.run({value:Number(c),issues:[]},n);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(d=h)}if(d.issues.length){t.mode==="loose"?r.value[c]=o[c]:r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>me(h,n,de())),input:c,path:[c],inst:e});continue}const f=t.valueType._zod.run({value:o[c],issues:[]},n);f instanceof Promise?i.push(f.then(h=>{h.issues.length&&r.issues.push(..._e(c,h.issues)),r.value[d.value]=h.value})):(f.issues.length&&r.issues.push(..._e(c,f.issues)),r.value[d.value]=f.value)}}return i.length?Promise.all(i).then(()=>r):r}}),zo=m("$ZodEnum",(e,t)=>{I.init(e,t);const r=It(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Er.has(typeof o)).map(o=>typeof o=="string"?ze(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const a=o.value;return n.has(a)||o.issues.push({code:"invalid_value",values:r,input:a,inst:e}),o}}),jo=m("$ZodLiteral",(e,t)=>{if(I.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?ze(n):n?ze(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{const i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}}),So=m("$ZodTransform",(e,t)=>{I.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Tt(e.constructor.name);const o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(r.value=a,r));if(o instanceof Promise)throw new ke;return r.value=o,r}});function gt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Qt=m("$ZodOptional",(e,t)=>{I.init(e,t),e._zod.optin="optional",e._zod.optout="optional",j(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),j(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${et(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>gt(i,r.value)):gt(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),No=m("$ZodExactOptional",(e,t)=>{Qt.init(e,t),j(e._zod,"values",()=>t.innerType._zod.values),j(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Oo=m("$ZodNullable",(e,t)=>{I.init(e,t),j(e._zod,"optin",()=>t.innerType._zod.optin),j(e._zod,"optout",()=>t.innerType._zod.optout),j(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${et(r.source)}|null)$`):void 0}),j(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Co=m("$ZodDefault",(e,t)=>{I.init(e,t),e._zod.optin="optional",j(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>bt(i,t)):bt(o,t)}});function bt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const $o=m("$ZodPrefault",(e,t)=>{I.init(e,t),e._zod.optin="optional",j(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Zo=m("$ZodNonOptional",(e,t)=>{I.init(e,t),j(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>vt(i,e)):vt(o,e)}});function vt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Ao=m("$ZodCatch",(e,t)=>{I.init(e,t),j(e._zod,"optin",()=>t.innerType._zod.optin),j(e._zod,"optout",()=>t.innerType._zod.optout),j(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(a=>me(a,n,de()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(i=>me(i,n,de()))},input:r.value}),r.issues=[]),r)}}),To=m("$ZodPipe",(e,t)=>{I.init(e,t),j(e._zod,"values",()=>t.in._zod.values),j(e._zod,"optin",()=>t.in._zod.optin),j(e._zod,"optout",()=>t.out._zod.optout),j(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=t.out._zod.run(r,n);return i instanceof Promise?i.then(a=>Ie(a,t.in,n)):Ie(i,t.in,n)}const o=t.in._zod.run(r,n);return o instanceof Promise?o.then(i=>Ie(i,t.out,n)):Ie(o,t.out,n)}});function Ie(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const Eo=m("$ZodReadonly",(e,t)=>{I.init(e,t),j(e._zod,"propValues",()=>t.innerType._zod.propValues),j(e._zod,"values",()=>t.innerType._zod.values),j(e._zod,"optin",()=>t.innerType?._zod?.optin),j(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(xt):xt(o)}});function xt(e){return e.value=Object.freeze(e.value),e}const Io=m("$ZodCustom",(e,t)=>{W.init(e,t),I.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(i=>yt(i,r,n,e));yt(o,r,n,e)}});function yt(e,t,r,n){if(!e){const o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Ae(o))}}var _t;class Po{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Ro(){return new Po}(_t=globalThis).__zod_globalRegistry??(_t.__zod_globalRegistry=Ro());const $e=globalThis.__zod_globalRegistry;function Do(e,t){return new e({type:"string",...g(t)})}function Mo(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function kt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function Lo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function Jo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function Uo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function Fo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function Bo(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function Ko(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function Vo(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function Wo(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function Go(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function qo(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function Yo(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function Ho(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function Xo(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function Qo(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function ea(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function ta(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function ra(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function na(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function oa(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function aa(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function ia(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function sa(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function la(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function ca(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function ua(e,t){return new e({type:"number",checks:[],...g(t)})}function da(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function ma(e,t){return new e({type:"boolean",...g(t)})}function pa(e){return new e({type:"unknown"})}function fa(e,t){return new e({type:"never",...g(t)})}function wt(e,t){return new Vt({check:"less_than",...g(t),value:e,inclusive:!1})}function We(e,t){return new Vt({check:"less_than",...g(t),value:e,inclusive:!0})}function zt(e,t){return new Wt({check:"greater_than",...g(t),value:e,inclusive:!1})}function Ge(e,t){return new Wt({check:"greater_than",...g(t),value:e,inclusive:!0})}function jt(e,t){return new On({check:"multiple_of",...g(t),value:e})}function er(e,t){return new $n({check:"max_length",...g(t),maximum:e})}function Me(e,t){return new Zn({check:"min_length",...g(t),minimum:e})}function tr(e,t){return new An({check:"length_equals",...g(t),length:e})}function ha(e,t){return new Tn({check:"string_format",format:"regex",...g(t),pattern:e})}function ga(e){return new En({check:"string_format",format:"lowercase",...g(e)})}function ba(e){return new In({check:"string_format",format:"uppercase",...g(e)})}function va(e,t){return new Pn({check:"string_format",format:"includes",...g(t),includes:e})}function xa(e,t){return new Rn({check:"string_format",format:"starts_with",...g(t),prefix:e})}function ya(e,t){return new Dn({check:"string_format",format:"ends_with",...g(t),suffix:e})}function je(e){return new Mn({check:"overwrite",tx:e})}function _a(e){return je(t=>t.normalize(e))}function ka(){return je(e=>e.trim())}function wa(){return je(e=>e.toLowerCase())}function za(){return je(e=>e.toUpperCase())}function ja(){return je(e=>Ar(e))}function Sa(e,t,r){return new e({type:"array",element:t,...g(r)})}function Na(e,t,r){return new e({type:"custom",check:"custom",fn:t,...g(r)})}function Oa(e){const t=Ca(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Ae(n,r.value,t._zod.def));else{const o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(Ae(o))}},e(r.value,r)));return t}function Ca(e,t){const r=new W({check:"custom",...g(t)});return r._zod.check=e,r}function rr(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??$e,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function L(e,t,r={path:[],schemaPath:[]}){var n;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);const c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{const f={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,f);else{const u=a.schema,b=t.processors[o.type];if(!b)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);b(e,t,u,f)}const h=e._zod.parent;h&&(a.ref||(a.ref=h),L(h,t,f),t.seen.get(h).isParent=!0)}const d=t.metadataRegistry.get(e);return d&&Object.assign(a.schema,d),t.io==="input"&&V(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function nr(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const a of e.seen.entries()){const c=e.metadataRegistry.get(a[0])?.id;if(c){const d=n.get(c);if(d&&d!==a[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(c,a[0])}}const o=a=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const h=e.external.registry.get(a[0])?.id,u=e.external.uri??(v=>v);if(h)return{ref:u(h)};const b=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=b,{defId:b,ref:`${u("__shared")}#/${c}/${b}`}}if(a[1]===r)return{ref:"#"};const p=`#/${c}/`,f=a[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:p+f}},i=a=>{if(a[1].schema.$ref)return;const c=a[1],{ref:d,defId:p}=o(a);c.def={...c.schema},p&&(c.defId=p);const f=c.schema;for(const h in f)delete f[h];f.$ref=d};if(e.cycles==="throw")for(const a of e.seen.entries()){const c=a[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
38
-
39
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const a of e.seen.entries()){const c=a[1];if(t===a[0]){i(a);continue}if(e.external){const p=e.external.registry.get(a[0])?.id;if(t!==a[0]&&p){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(c.cycle){i(a);continue}if(c.count>1&&e.reused==="ref"){i(a);continue}}}function or(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=a=>{const c=e.seen.get(a);if(c.ref===null)return;const d=c.def??c.schema,p={...d},f=c.ref;if(c.ref=null,f){n(f);const u=e.seen.get(f),b=u.schema;if(b.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(b)):Object.assign(d,b),Object.assign(d,p),a._zod.parent===f)for(const D in d)D==="$ref"||D==="allOf"||D in p||delete d[D];if(b.$ref&&u.def)for(const D in d)D==="$ref"||D==="allOf"||D in u.def&&JSON.stringify(d[D])===JSON.stringify(u.def[D])&&delete d[D]}const h=a._zod.parent;if(h&&h!==f){n(h);const u=e.seen.get(h);if(u?.schema.$ref&&(d.$ref=u.schema.$ref,u.def))for(const b in d)b==="$ref"||b==="allOf"||b in u.def&&JSON.stringify(d[b])===JSON.stringify(u.def[b])&&delete d[b]}e.override({zodSchema:a,jsonSchema:d,path:c.path??[]})};for(const a of[...e.seen.entries()].reverse())n(a[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,r.def??r.schema);const i=e.external?.defs??{};for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(i[c.defId]=c.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Le(t,"input",e.processors),output:Le(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function V(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return V(n.element,r);if(n.type==="set")return V(n.valueType,r);if(n.type==="lazy")return V(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return V(n.innerType,r);if(n.type==="intersection")return V(n.left,r)||V(n.right,r);if(n.type==="record"||n.type==="map")return V(n.keyType,r)||V(n.valueType,r);if(n.type==="pipe")return V(n.in,r)||V(n.out,r);if(n.type==="object"){for(const o in n.shape)if(V(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(const o of n.options)if(V(o,r))return!0;return!1}if(n.type==="tuple"){for(const o of n.items)if(V(o,r))return!0;return!!(n.rest&&V(n.rest,r))}return!1}const $a=(e,t={})=>r=>{const n=rr({...r,processors:t});return L(e,n),nr(n,e),or(n,e)},Le=(e,t,r={})=>n=>{const{libraryOptions:o,target:i}=n??{},a=rr({...o??{},target:i,io:t,processors:r});return L(e,a),nr(a,e),or(a,e)},Za={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Aa=(e,t,r,n)=>{const o=r;o.type="string";const{minimum:i,maximum:a,format:c,patterns:d,contentEncoding:p}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),c&&(o.format=Za[c]??c,o.format===""&&delete o.format,c==="time"&&delete o.format),p&&(o.contentEncoding=p),d&&d.size>0){const f=[...d];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},Ta=(e,t,r,n)=>{const o=r,{minimum:i,maximum:a,format:c,multipleOf:d,exclusiveMaximum:p,exclusiveMinimum:f}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f),typeof i=="number"&&(o.minimum=i,typeof f=="number"&&t.target!=="draft-04"&&(f>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=p,o.exclusiveMaximum=!0):o.exclusiveMaximum=p),typeof a=="number"&&(o.maximum=a,typeof p=="number"&&t.target!=="draft-04"&&(p<=a?delete o.maximum:delete o.exclusiveMaximum)),typeof d=="number"&&(o.multipleOf=d)},Ea=(e,t,r,n)=>{r.type="boolean"},Ia=(e,t,r,n)=>{r.not={}},Pa=(e,t,r,n)=>{},Ra=(e,t,r,n)=>{const o=e._zod.def,i=It(o.entries);i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},Da=(e,t,r,n)=>{const o=e._zod.def,i=[];for(const a of o.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){const a=i[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),i.every(a=>typeof a=="boolean")&&(r.type="boolean"),i.every(a=>a===null)&&(r.type="null"),r.enum=i},Ma=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},La=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ja=(e,t,r,n)=>{const o=r,i=e._zod.def,{minimum:a,maximum:c}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=L(i.element,t,{...n,path:[...n.path,"items"]})},Ua=(e,t,r,n)=>{const o=r,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const p in a)o.properties[p]=L(a[p],t,{...n,path:[...n.path,"properties",p]});const c=new Set(Object.keys(a)),d=new Set([...c].filter(p=>{const f=i.shape[p]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));d.size>0&&(o.required=Array.from(d)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=L(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Fa=(e,t,r,n)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((c,d)=>L(c,t,{...n,path:[...n.path,i?"oneOf":"anyOf",d]}));i?r.oneOf=a:r.anyOf=a},Ba=(e,t,r,n)=>{const o=e._zod.def,i=L(o.left,t,{...n,path:[...n.path,"allOf",0]}),a=L(o.right,t,{...n,path:[...n.path,"allOf",1]}),c=p=>"allOf"in p&&Object.keys(p).length===1,d=[...c(i)?i.allOf:[i],...c(a)?a.allOf:[a]];r.allOf=d},Ka=(e,t,r,n)=>{const o=r,i=e._zod.def;o.type="object";const a=i.keyType,d=a._zod.bag?.patterns;if(i.mode==="loose"&&d&&d.size>0){const f=L(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(const h of d)o.patternProperties[h.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=L(i.keyType,t,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=L(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const p=a._zod.values;if(p){const f=[...p].filter(h=>typeof h=="string"||typeof h=="number");f.length>0&&(o.required=f)}},Va=(e,t,r,n)=>{const o=e._zod.def,i=L(o.innerType,t,n),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Wa=(e,t,r,n)=>{const o=e._zod.def;L(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},Ga=(e,t,r,n)=>{const o=e._zod.def;L(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},qa=(e,t,r,n)=>{const o=e._zod.def;L(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Ya=(e,t,r,n)=>{const o=e._zod.def;L(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},Ha=(e,t,r,n)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;L(i,t,n);const a=t.seen.get(e);a.ref=i},Xa=(e,t,r,n)=>{const o=e._zod.def;L(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0},ar=(e,t,r,n)=>{const o=e._zod.def;L(o.innerType,t,n);const i=t.seen.get(e);i.ref=o.innerType},Qa=m("ZodISODateTime",(e,t)=>{Qn.init(e,t),R.init(e,t)});function ei(e){return ia(Qa,e)}const ti=m("ZodISODate",(e,t)=>{eo.init(e,t),R.init(e,t)});function ri(e){return sa(ti,e)}const ni=m("ZodISOTime",(e,t)=>{to.init(e,t),R.init(e,t)});function oi(e){return la(ni,e)}const ai=m("ZodISODuration",(e,t)=>{ro.init(e,t),R.init(e,t)});function ii(e){return ca(ai,e)}const si=(e,t)=>{Mt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Kr(e,r)},flatten:{value:r=>Br(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,Ye,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,Ye,2)}},isEmpty:{get(){return e.issues.length===0}}})},Y=m("ZodError",si,{Parent:Error}),li=rt(Y),ci=nt(Y),ui=Ue(Y),di=Fe(Y),mi=Gr(Y),pi=qr(Y),fi=Yr(Y),hi=Hr(Y),gi=Xr(Y),bi=Qr(Y),vi=en(Y),xi=tn(Y),P=m("ZodType",(e,t)=>(I.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Le(e,"input"),output:Le(e,"output")}}),e.toJSONSchema=$a(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(pe(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>fe(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>li(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>ui(e,r,n),e.parseAsync=async(r,n)=>ci(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>di(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>mi(e,r,n),e.decode=(r,n)=>pi(e,r,n),e.encodeAsync=async(r,n)=>fi(e,r,n),e.decodeAsync=async(r,n)=>hi(e,r,n),e.safeEncode=(r,n)=>gi(e,r,n),e.safeDecode=(r,n)=>bi(e,r,n),e.safeEncodeAsync=async(r,n)=>vi(e,r,n),e.safeDecodeAsync=async(r,n)=>xi(e,r,n),e.refine=(r,n)=>e.check(ps(r,n)),e.superRefine=r=>e.check(fs(r)),e.overwrite=r=>e.check(je(r)),e.optional=()=>$t(e),e.exactOptional=()=>es(e),e.nullable=()=>Zt(e),e.nullish=()=>$t(Zt(e)),e.nonoptional=r=>is(e,r),e.array=()=>ne(e),e.or=r=>cr([e,r]),e.and=r=>Gi(e,r),e.transform=r=>At(e,Xi(r)),e.default=r=>ns(e,r),e.prefault=r=>as(e,r),e.catch=r=>ls(e,r),e.pipe=r=>At(e,r),e.readonly=()=>ds(e),e.describe=r=>{const n=e.clone();return $e.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return $e.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return $e.get(e);const n=e.clone();return $e.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),ir=m("_ZodString",(e,t)=>{ot.init(e,t),P.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Aa(e,n,o);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(ha(...n)),e.includes=(...n)=>e.check(va(...n)),e.startsWith=(...n)=>e.check(xa(...n)),e.endsWith=(...n)=>e.check(ya(...n)),e.min=(...n)=>e.check(Me(...n)),e.max=(...n)=>e.check(er(...n)),e.length=(...n)=>e.check(tr(...n)),e.nonempty=(...n)=>e.check(Me(1,...n)),e.lowercase=n=>e.check(ga(n)),e.uppercase=n=>e.check(ba(n)),e.trim=()=>e.check(ka()),e.normalize=(...n)=>e.check(_a(...n)),e.toLowerCase=()=>e.check(wa()),e.toUpperCase=()=>e.check(za()),e.slugify=()=>e.check(ja())}),yi=m("ZodString",(e,t)=>{ot.init(e,t),ir.init(e,t),e.email=r=>e.check(Mo(_i,r)),e.url=r=>e.check(Bo(ki,r)),e.jwt=r=>e.check(aa(Ri,r)),e.emoji=r=>e.check(Ko(wi,r)),e.guid=r=>e.check(kt(St,r)),e.uuid=r=>e.check(Lo(Pe,r)),e.uuidv4=r=>e.check(Jo(Pe,r)),e.uuidv6=r=>e.check(Uo(Pe,r)),e.uuidv7=r=>e.check(Fo(Pe,r)),e.nanoid=r=>e.check(Vo(zi,r)),e.guid=r=>e.check(kt(St,r)),e.cuid=r=>e.check(Wo(ji,r)),e.cuid2=r=>e.check(Go(Si,r)),e.ulid=r=>e.check(qo(Ni,r)),e.base64=r=>e.check(ra(Ei,r)),e.base64url=r=>e.check(na(Ii,r)),e.xid=r=>e.check(Yo(Oi,r)),e.ksuid=r=>e.check(Ho(Ci,r)),e.ipv4=r=>e.check(Xo($i,r)),e.ipv6=r=>e.check(Qo(Zi,r)),e.cidrv4=r=>e.check(ea(Ai,r)),e.cidrv6=r=>e.check(ta(Ti,r)),e.e164=r=>e.check(oa(Pi,r)),e.datetime=r=>e.check(ei(r)),e.date=r=>e.check(ri(r)),e.time=r=>e.check(oi(r)),e.duration=r=>e.check(ii(r))});function x(e){return Do(yi,e)}const R=m("ZodStringFormat",(e,t)=>{A.init(e,t),ir.init(e,t)}),_i=m("ZodEmail",(e,t)=>{Bn.init(e,t),R.init(e,t)}),St=m("ZodGUID",(e,t)=>{Un.init(e,t),R.init(e,t)}),Pe=m("ZodUUID",(e,t)=>{Fn.init(e,t),R.init(e,t)}),ki=m("ZodURL",(e,t)=>{Kn.init(e,t),R.init(e,t)}),wi=m("ZodEmoji",(e,t)=>{Vn.init(e,t),R.init(e,t)}),zi=m("ZodNanoID",(e,t)=>{Wn.init(e,t),R.init(e,t)}),ji=m("ZodCUID",(e,t)=>{Gn.init(e,t),R.init(e,t)}),Si=m("ZodCUID2",(e,t)=>{qn.init(e,t),R.init(e,t)}),Ni=m("ZodULID",(e,t)=>{Yn.init(e,t),R.init(e,t)}),Oi=m("ZodXID",(e,t)=>{Hn.init(e,t),R.init(e,t)}),Ci=m("ZodKSUID",(e,t)=>{Xn.init(e,t),R.init(e,t)}),$i=m("ZodIPv4",(e,t)=>{no.init(e,t),R.init(e,t)}),Zi=m("ZodIPv6",(e,t)=>{oo.init(e,t),R.init(e,t)}),Ai=m("ZodCIDRv4",(e,t)=>{ao.init(e,t),R.init(e,t)}),Ti=m("ZodCIDRv6",(e,t)=>{io.init(e,t),R.init(e,t)}),Ei=m("ZodBase64",(e,t)=>{so.init(e,t),R.init(e,t)}),Ii=m("ZodBase64URL",(e,t)=>{co.init(e,t),R.init(e,t)}),Pi=m("ZodE164",(e,t)=>{uo.init(e,t),R.init(e,t)}),Ri=m("ZodJWT",(e,t)=>{po.init(e,t),R.init(e,t)}),sr=m("ZodNumber",(e,t)=>{qt.init(e,t),P.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Ta(e,n,o),e.gt=(n,o)=>e.check(zt(n,o)),e.gte=(n,o)=>e.check(Ge(n,o)),e.min=(n,o)=>e.check(Ge(n,o)),e.lt=(n,o)=>e.check(wt(n,o)),e.lte=(n,o)=>e.check(We(n,o)),e.max=(n,o)=>e.check(We(n,o)),e.int=n=>e.check(Nt(n)),e.safe=n=>e.check(Nt(n)),e.positive=n=>e.check(zt(0,n)),e.nonnegative=n=>e.check(Ge(0,n)),e.negative=n=>e.check(wt(0,n)),e.nonpositive=n=>e.check(We(0,n)),e.multipleOf=(n,o)=>e.check(jt(n,o)),e.step=(n,o)=>e.check(jt(n,o)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function Z(e){return ua(sr,e)}const Di=m("ZodNumberFormat",(e,t)=>{fo.init(e,t),sr.init(e,t)});function Nt(e){return da(Di,e)}const Mi=m("ZodBoolean",(e,t)=>{ho.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ea(e,r,n)});function J(e){return ma(Mi,e)}const Li=m("ZodUnknown",(e,t)=>{go.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pa()});function Ot(){return pa(Li)}const Ji=m("ZodNever",(e,t)=>{bo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ia(e,r,n)});function Ui(e){return fa(Ji,e)}const Fi=m("ZodArray",(e,t)=>{vo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ja(e,r,n,o),e.element=t.element,e.min=(r,n)=>e.check(Me(r,n)),e.nonempty=r=>e.check(Me(1,r)),e.max=(r,n)=>e.check(er(r,n)),e.length=(r,n)=>e.check(tr(r,n)),e.unwrap=()=>e.element});function ne(e,t){return Sa(Fi,e,t)}const Bi=m("ZodObject",(e,t)=>{yo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ua(e,r,n,o),j(e,"shape",()=>t.shape),e.keyof=()=>ae(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ot()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ot()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ui()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>Mr(e,r),e.safeExtend=r=>Lr(e,r),e.merge=r=>Jr(e,r),e.pick=r=>Rr(e,r),e.omit=r=>Dr(e,r),e.partial=(...r)=>Ur(ur,e,r[0]),e.required=(...r)=>Fr(dr,e,r[0])});function M(e,t){const r={type:"object",shape:e??{},...g(t)};return new Bi(r)}const lr=m("ZodUnion",(e,t)=>{Xt.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fa(e,r,n,o),e.options=t.options});function cr(e,t){return new lr({type:"union",options:e,...g(t)})}const Ki=m("ZodDiscriminatedUnion",(e,t)=>{lr.init(e,t),_o.init(e,t)});function Vi(e,t,r){return new Ki({type:"union",options:t,discriminator:e,...g(r)})}const Wi=m("ZodIntersection",(e,t)=>{ko.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ba(e,r,n,o)});function Gi(e,t){return new Wi({type:"intersection",left:e,right:t})}const qi=m("ZodRecord",(e,t)=>{wo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ka(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function Re(e,t,r){return new qi({type:"record",keyType:e,valueType:t,...g(r)})}const Xe=m("ZodEnum",(e,t)=>{zo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Ra(e,n,o),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{const i={};for(const a of n)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Xe({...t,checks:[],...g(o),entries:i})},e.exclude=(n,o)=>{const i={...t.entries};for(const a of n)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new Xe({...t,checks:[],...g(o),entries:i})}});function ae(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Xe({type:"enum",entries:r,...g(t)})}const Yi=m("ZodLiteral",(e,t)=>{jo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Da(e,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ct(e,t){return new Yi({type:"literal",values:Array.isArray(e)?e:[e],...g(t)})}const Hi=m("ZodTransform",(e,t)=>{So.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>La(e,r),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Tt(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(Ae(i,r.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push(Ae(a))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(i=>(r.value=i,r)):(r.value=o,r)}});function Xi(e){return new Hi({type:"transform",transform:e})}const ur=m("ZodOptional",(e,t)=>{Qt.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ar(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function $t(e){return new ur({type:"optional",innerType:e})}const Qi=m("ZodExactOptional",(e,t)=>{No.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ar(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function es(e){return new Qi({type:"optional",innerType:e})}const ts=m("ZodNullable",(e,t)=>{Oo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Va(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Zt(e){return new ts({type:"nullable",innerType:e})}const rs=m("ZodDefault",(e,t)=>{Co.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ga(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ns(e,t){return new rs({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Rt(t)}})}const os=m("ZodPrefault",(e,t)=>{$o.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function as(e,t){return new os({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Rt(t)}})}const dr=m("ZodNonOptional",(e,t)=>{Zo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function is(e,t){return new dr({type:"nonoptional",innerType:e,...g(t)})}const ss=m("ZodCatch",(e,t)=>{Ao.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ya(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ls(e,t){return new ss({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const cs=m("ZodPipe",(e,t)=>{To.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ha(e,r,n,o),e.in=t.in,e.out=t.out});function At(e,t){return new cs({type:"pipe",in:e,out:t})}const us=m("ZodReadonly",(e,t)=>{Eo.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ds(e){return new us({type:"readonly",innerType:e})}const ms=m("ZodCustom",(e,t)=>{Io.init(e,t),P.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ma(e,r)});function ps(e,t={}){return Na(ms,e,t)}function fs(e){return Oa(e)}const O={agent:{name:"morpheus",personality:"helpful_dev"},logging:{enabled:!0,level:"info",retention:"14d"},audio:{provider:"google",model:"gemini-2.5-flash-lite",enabled:!0,maxDurationSeconds:300,supportedMimeTypes:["audio/ogg","audio/mp3","audio/mpeg","audio/wav"]},memory:{limit:100},runtime:{async_tasks:{enabled:!0}},llm:{provider:"openai",model:"gpt-4",temperature:.7,context_window:100},channels:{telegram:{enabled:!1,allowedUsers:[]},discord:{enabled:!1,allowedUsers:[]}},ui:{enabled:!0,port:3333}},hs=M({provider:ae(["google","openai","openrouter","ollama"]).default(O.audio.provider),model:x().min(1).default(O.audio.model),enabled:J().default(O.audio.enabled),apiKey:x().optional(),base_url:x().optional(),maxDurationSeconds:Z().default(O.audio.maxDurationSeconds),supportedMimeTypes:ne(x()).default(O.audio.supportedMimeTypes)}),Se=M({provider:ae(["openai","anthropic","openrouter","ollama","gemini"]).default(O.llm.provider),model:x().min(1).default(O.llm.model),temperature:Z().min(0).max(1).default(O.llm.temperature),max_tokens:Z().int().positive().optional(),api_key:x().optional(),base_url:x().optional(),context_window:Z().int().positive().optional()}),gs=Se.extend({memory_limit:Z().int().positive().optional(),enabled_archived_sessions:J().default(!0),similarity_threshold:Z().min(0).max(1).default(.9),evaluation_interval:Z().int().min(1).default(1)}),bs=Se.extend({working_dir:x().optional(),timeout_ms:Z().int().positive().optional(),execution_mode:ae(["sync","async"]).default("async")}),vs=Se.extend({execution_mode:ae(["sync","async"]).default("async")}),xs=Se.extend({execution_mode:ae(["sync","async"]).default("async")}),ys=Se.extend({personality:x().optional(),chunk_size:Z().int().positive().default(500),score_threshold:Z().min(0).max(1).default(.5),max_results:Z().int().positive().default(10),execution_mode:ae(["sync","async"]).default("async"),scan_interval_ms:Z().int().min(5e3).default(3e4),max_file_size_mb:Z().int().positive().default(50),vector_weight:Z().min(0).max(1).default(.8),bm25_weight:Z().min(0).max(1).default(.2)}),_s=M({telegram_notify_all:J().optional()}).optional(),ks=M({timezone:x().default("UTC"),check_interval_ms:Z().min(6e4).default(6e4),max_active_jobs:Z().min(1).max(1e3).default(100)}),ws=M({sandbox_dir:x().optional(),readonly_mode:J().default(!1),allowed_shell_commands:ne(x()).default([]),allowed_paths:ne(x()).default([]),enable_filesystem:J().default(!0),enable_shell:J().default(!0),enable_git:J().default(!0),enable_network:J().default(!0),timeout_ms:Z().int().positive().default(3e4)}),zs=M({name:x().min(1).max(64).regex(/^[a-z0-9][a-z0-9_-]*$/,"Smith name must be lowercase alphanumeric with hyphens/underscores"),host:x().min(1),port:Z().int().min(1).max(65535).default(7900),auth_token:x().min(1),tls:J().default(!1)}),js=M({enabled:J().default(!0),fields:ne(x()).default(["name","timezone","preferred_language"])}),Ss=M({enabled:J().default(!1),execution_mode:ae(["sync","async"]).default("async"),heartbeat_interval_ms:Z().int().min(5e3).default(3e4),connection_timeout_ms:Z().int().min(1e3).default(1e4),task_timeout_ms:Z().int().min(1e3).default(6e4),entries:ne(zs).default([])}),Ns=M({agent:M({name:x().default(O.agent.name),personality:x().default(O.agent.personality)}).default(O.agent),llm:Se.default(O.llm),sati:gs.optional(),neo:vs.optional(),apoc:bs.optional(),trinity:xs.optional(),link:ys.optional(),webhooks:_s,audio:hs.default(O.audio),memory:M({limit:Z().int().positive().optional()}).default(O.memory),runtime:M({async_tasks:M({enabled:J().default(O.runtime?.async_tasks.enabled)}).default(O.runtime?.async_tasks??{enabled:!0})}).optional(),chronos:ks.optional(),devkit:ws.optional(),smiths:Ss.optional(),setup:js.optional(),verbose_mode:J().default(!0),channels:M({telegram:M({enabled:J().default(!1),token:x().optional(),allowedUsers:ne(x()).default([])}).default(O.channels.telegram),discord:M({enabled:J().default(!1),token:x().optional(),allowedUsers:ne(x()).default([])}).default(O.channels.discord)}).default(O.channels),ui:M({enabled:J().default(O.ui.enabled),port:Z().default(O.ui.port)}).default(O.ui),logging:M({enabled:J().default(O.logging.enabled),level:ae(["debug","info","warn","error"]).default(O.logging.level),retention:x().default(O.logging.retention)}).default(O.logging)}),Os=Vi("transport",[M({transport:Ct("stdio"),command:x().min(1,"Command is required for stdio transport"),args:ne(x()).optional().default([]),env:Re(x(),x()).optional().default({}),_comment:x().optional()}),M({transport:Ct("http"),url:x().url("Valid URL is required for http transport"),headers:Re(x(),x()).optional().default({}),args:ne(x()).optional().default([]),env:Re(x(),x()).optional().default({}),_comment:x().optional()})]);Re(x(),cr([Os,x()]));const Cs={resetData:async e=>qe.delete("/danger/reset",{categories:e})},$s=[{id:"general",label:"General"},{id:"agents",label:"Agents"},{id:"devkit",label:"DevKit"},{id:"audio",label:"Audio"},{id:"channels",label:"Channels"},{id:"chronos",label:"Chronos"},{id:"danger",label:"Danger Zone"}],Zs=[{id:"oracle",label:"Oracle"},{id:"sati",label:"Sati"},{id:"neo",label:"Neo"},{id:"apoc",label:"Apoc"},{id:"trinity",label:"Trinity"},{id:"link",label:"Link"}],Ce=[{label:"OpenAI",value:"openai"},{label:"Anthropic",value:"anthropic"},{label:"OpenRouter",value:"openrouter"},{label:"Ollama",value:"ollama"},{label:"Google Gemini",value:"gemini"}];function Us(){const{data:e,error:t}=ce("/api/config",q.fetchConfig),{data:r}=ce("/api/config/sati",q.getSatiConfig),{data:n}=ce("/api/config/apoc",q.getApocConfig),{data:o}=ce("/api/config/neo",q.getNeoConfig),{data:i}=ce("/api/config/trinity",q.getTrinityConfig),{data:a}=ce("/api/link/config",()=>qe.get("/link/config")),{data:c}=ce("/api/config/encryption-status",()=>q.getEncryptionStatus()),{data:d}=ce("/api/config/env-overrides",()=>q.getEnvOverrides()),{data:p}=jr(),[f,h]=E.useState(null),[u,b]=E.useState(null),[v,D]=E.useState(null),[N,be]=E.useState(null),[T,B]=E.useState(null),[y,U]=E.useState(null),[$,Ne]=E.useState(null),[X,mr]=E.useState("general"),[he,pr]=E.useState("oracle"),[at,it]=E.useState(!1),[Q,Te]=E.useState({}),[Ke,Oe]=E.useState(null);E.useEffect(()=>{e&&!u&&b(e)},[e]),E.useEffect(()=>{r&&!v&&D(r)},[r]),E.useEffect(()=>{n&&!T?B(n):!n&&!T&&u&&B({...u.apoc??u.llm,temperature:u.apoc?.temperature??.2,timeout_ms:u.apoc?.timeout_ms??3e4})},[n,u]),E.useEffect(()=>{o&&!N?be(o):!o&&!N&&u&&be({...u.neo??u.llm,temperature:u.neo?.temperature??.2})},[o,u]),E.useEffect(()=>{i&&!y?U(i):!i&&!y&&u&&U({...u.trinity??u.llm,temperature:u.trinity?.temperature??.2})},[i,u]),E.useEffect(()=>{p&&!f&&h(p)},[p]),E.useEffect(()=>{a&&!$&&Ne(a)},[a]);const st=JSON.stringify(e)!==JSON.stringify(u)||JSON.stringify(r)!==JSON.stringify(v)||JSON.stringify(o)!==JSON.stringify(N)||JSON.stringify(n)!==JSON.stringify(T)||JSON.stringify(i)!==JSON.stringify(y)||JSON.stringify(p)!==JSON.stringify(f)||JSON.stringify(a)!==JSON.stringify($),fr={general:JSON.stringify(e?.agent)!==JSON.stringify(u?.agent)||e?.verbose_mode!==u?.verbose_mode,agents:JSON.stringify(e?.llm)!==JSON.stringify(u?.llm)||JSON.stringify(r)!==JSON.stringify(v)||JSON.stringify(o)!==JSON.stringify(N)||JSON.stringify(n)!==JSON.stringify(T)||JSON.stringify(i)!==JSON.stringify(y)||JSON.stringify(a)!==JSON.stringify($),devkit:JSON.stringify(e?.devkit)!==JSON.stringify(u?.devkit),audio:JSON.stringify(e?.audio)!==JSON.stringify(u?.audio),channels:JSON.stringify(e?.channels?.telegram)!==JSON.stringify(u?.channels?.telegram)||JSON.stringify(e?.channels?.discord)!==JSON.stringify(u?.channels?.discord)||JSON.stringify(e?.webhooks)!==JSON.stringify(u?.webhooks),ui:JSON.stringify(e?.ui)!==JSON.stringify(u?.ui),logging:JSON.stringify(e?.logging)!==JSON.stringify(u?.logging),chronos:JSON.stringify(p)!==JSON.stringify(f)},ve=(l,z)=>{if(!c?.apiKeysEncrypted)return null;const{morpheusSecretSet:ee,apiKeysEncrypted:te}=c,H=te[l];return!z?s.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-azure-surface border border-azure-border text-azure-text-secondary dark:bg-matrix-primary/10 dark:border-matrix-primary dark:text-matrix-tertiary",children:"No API key"}):d&&d[hr(l)]?null:ee?H?s.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-emerald-100 border border-emerald-300 text-emerald-800 dark:bg-emerald-900/30 dark:border-emerald-700 dark:text-emerald-400",title:"API key encrypted with AES-256-GCM",children:"🔒 Encrypted"}):s.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-amber-100 border border-amber-300 text-amber-800 dark:bg-amber-900/30 dark:border-amber-700 dark:text-amber-400",title:"Re-save this configuration to encrypt the API key",children:"⚠️ Re-save to encrypt"}):s.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-amber-100 border border-amber-300 text-amber-800 dark:bg-amber-900/30 dark:border-amber-700 dark:text-amber-400",title:"Set MORPHEUS_SECRET to enable encryption",children:"⚠️ Plaintext"})},hr=l=>({oracle:"llm.api_key",sati:"sati.api_key",neo:"neo.api_key",apoc:"apoc.api_key",trinity:"trinity.api_key",audio:"audio.apiKey"})[l],S=l=>!d||!d[l]?null:s.jsx("span",{className:"inline-flex items-center px-2 py-1 text-xs rounded bg-blue-100 border border-blue-300 text-blue-800 dark:bg-blue-900/30 dark:border-blue-700 dark:text-blue-400",title:"This field is set by an environment variable and cannot be edited",children:"🔒 Env Var"}),k=l=>!!(d&&d[l]),_=(l,z)=>{if(!u)return;const ee=JSON.parse(JSON.stringify(u));let te=ee;for(let H=0;H<l.length-1;H++)(te[l[H]]===void 0||te[l[H]]===null)&&(te[l[H]]={}),te=te[l[H]];te[l[l.length-1]]=z,b(ee);try{Ns.parse(ee),Te({})}catch(H){if(H instanceof zr){const Ve={};H.errors.forEach(lt=>{const kr=lt.path.join(".");Ve[kr]=lt.message}),Te(Ve)}}},ie=(l,z)=>{v&&D({...v,[l]:z})},se=(l,z)=>{T&&B({...T,[l]:z})},oe=(l,z)=>{N&&be({...N,[l]:z})},le=(l,z)=>{y&&U({...y,[l]:z})},gr=()=>{!u||!y||U({...y,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},br=()=>{!u||!v||D({...v,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},vr=()=>{!u||!T||B({...T,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},xr=()=>{!u||!N||be({...N,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},G=(l,z)=>{$&&Ne({...$,[l]:z})},yr=()=>{!u||!$||Ne({...$,provider:u.llm.provider,model:u.llm.model,api_key:u.llm.api_key})},_r=async()=>{if(u){it(!0),Oe(null);try{const l=await q.updateConfig(u);v&&await q.updateSatiConfig(v),N&&await q.updateNeoConfig(N),T&&await q.updateApocConfig(T),y&&await q.updateTrinityConfig(y),f&&await Sr.updateConfig(f),$&&await qe.post("/link/config",$),ue("/api/config"),ue("/api/config/sati"),ue("/api/config/neo"),ue("/api/config/apoc"),ue("/api/config/trinity"),ue("/api/config/chronos"),ue("/api/link/config"),Te({});const z=l._restartRequired||[],ee=z.length>0?`Settings saved and applied. Some changes require restart: ${z.join(", ")}`:"Settings saved and applied successfully.";Oe({type:"success",message:ee}),setTimeout(()=>Oe(null),5e3)}catch(l){if(Oe({type:"error",message:l.message}),l.details&&Array.isArray(l.details)){const z={};l.details.forEach(ee=>{const te=ee.path.join(".");z[te]=ee.message}),Te(z)}}finally{it(!1)}}};return t?s.jsx("div",{className:"p-8 text-red-500",children:"Failed to load configuration"}):u?s.jsxs("div",{className:"max-w-4xl mx-auto p-0 md:p-6 space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center flex-wrap gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:s.jsx(Or,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Zaion Settings"}),s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Configure agents, models, channels, and runtime behavior."})]})]}),s.jsx("button",{onClick:_r,disabled:!st||Object.keys(Q).length>0||at,className:`px-4 py-2 rounded font-medium transition-colors ${st&&Object.keys(Q).length===0?"bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90":"bg-azure-border text-azure-text-secondary cursor-not-allowed dark:bg-matrix-primary/50 dark:text-matrix-highlight/50"}`,children:at?"Saving...":"Save Changes"})]}),Ke&&s.jsxs("div",{className:`flex items-start justify-between gap-3 p-4 rounded border ${Ke.type==="success"?"border-azure-primary text-azure-primary bg-azure-primary/10 dark:border-matrix-highlight dark:text-matrix-highlight dark:bg-matrix-highlight/10":"border-red-500 text-red-500 bg-red-900/10"}`,children:[s.jsx("span",{className:"text-sm",children:Ke.message}),s.jsx("button",{type:"button",onClick:()=>Oe(null),className:"shrink-0 opacity-60 hover:opacity-100 transition-opacity","aria-label":"Dismiss",children:s.jsx(Cr,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"overflow-x-auto py-1 hide-scrollbar",children:s.jsx("div",{className:"flex space-x-1 border-b border-azure-border dark:border-matrix-primary pb-px min-w-max",children:$s.map(l=>s.jsxs("button",{onClick:()=>mr(l.id),className:`px-4 py-2 text-sm font-medium rounded-t-md transition-colors flex-shrink-0 flex items-center gap-1.5 ${X===l.id?"bg-azure-surface/50 text-azure-primary border-t border-x border-azure-border dark:bg-matrix-primary/20 dark:text-matrix-highlight dark:border-t dark:border-x dark:border-matrix-primary":"text-azure-text-secondary hover:text-azure-primary dark:text-matrix-secondary dark:hover:text-matrix-highlight"}`,children:[l.label,fr[l.id]&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 shrink-0"})]},l.id))})}),s.jsxs("div",{className:"space-y-6",children:[X==="general"&&s.jsxs(F,{title:"Agent Identity",children:[s.jsx(w,{label:"Agent Name",value:u.agent.name,onChange:l=>_(["agent","name"],l.target.value),error:Q["agent.name"]}),s.jsx(ct,{label:"Personality",value:u.agent.personality,onChange:l=>_(["agent","personality"],l.target.value),error:Q["agent.personality"],placeholder:"Describe the agent's personality or description..."}),s.jsx(K,{label:"Verbose Mode",value:u.verbose_mode!==!1?"true":"false",onChange:l=>_(["verbose_mode"],l.target.value==="true"),options:[{value:"true",label:"Enabled (notify tool execution on channels)"},{value:"false",label:"Disabled"}],helperText:"When enabled, channels like Telegram/Discord show which tools are being executed in real-time."})]}),X==="agents"&&s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex space-x-1 border-b border-azure-border dark:border-matrix-primary pb-px",children:Zs.map(l=>s.jsx("button",{onClick:()=>pr(l.id),className:`px-4 py-2 text-sm font-medium rounded-t-md transition-colors ${he===l.id?"bg-azure-primary/10 text-azure-primary border-b-2 border-azure-primary dark:bg-matrix-highlight/10 dark:text-matrix-highlight dark:border-matrix-highlight":"text-azure-text-secondary hover:text-azure-primary dark:text-matrix-secondary dark:hover:text-matrix-highlight"}`,children:l.label},l.id))}),he==="oracle"&&s.jsxs(F,{title:"Oracle Agent",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Main orchestration agent — handles user requests and delegates to subagents"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("llm.provider")]}),s.jsx(K,{label:"",value:u.llm.provider,onChange:l=>_(["llm","provider"],l.target.value),options:Ce,error:Q["llm.provider"],disabled:k("llm.provider")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),S("llm.model")]}),s.jsx(w,{label:"",value:u.llm.model,onChange:l=>_(["llm","model"],l.target.value),disabled:k("llm.model")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),S("llm.temperature")]}),s.jsx(C,{label:"",value:u.llm.temperature,onChange:l=>_(["llm","temperature"],parseFloat(l.target.value)),step:.1,min:0,max:1,error:Q["llm.temperature"],disabled:k("llm.temperature")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Tokens"}),S("llm.max_tokens")]}),s.jsx(C,{label:"",value:u.llm.max_tokens??"",onChange:l=>_(["llm","max_tokens"],l.target.value?parseInt(l.target.value):void 0),min:1,error:Q["llm.max_tokens"],helperText:"Maximum tokens per response. Leave empty for model default.",disabled:k("llm.max_tokens")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Context Window (Messages)"}),S("llm.context_window")]}),s.jsx(C,{label:"",value:u.llm.context_window??100,onChange:l=>_(["llm","context_window"],parseInt(l.target.value)),min:1,step:1,error:Q["llm.context_window"],helperText:"Number of past interactions to load into LLM context (e.g., 100).",disabled:k("llm.context_window")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),s.jsxs("div",{className:"flex items-center gap-2",children:[S("llm.api_key"),ve("oracle",u.llm.api_key)]})]}),s.jsx(w,{label:"",type:"password",value:u.llm.api_key||"",onChange:l=>_(["llm","api_key"],l.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:k("llm.api_key")}),u.llm.provider==="openrouter"&&s.jsx(w,{label:"Base URL",value:u.llm.base_url||"https://openrouter.ai/api/v1",onChange:l=>_(["llm","base_url"],l.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]}),he==="sati"&&s.jsxs(F,{title:"Sati Agent",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Background memory consolidation agent — evaluates conversations and persists important context"}),s.jsxs("div",{className:"mb-4",children:[s.jsx("button",{type:"button",onClick:br,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),s.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),v&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("sati.provider")]}),s.jsx(K,{label:"",value:v.provider,onChange:l=>ie("provider",l.target.value),options:Ce,disabled:k("sati.provider")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),S("sati.model")]}),s.jsx(w,{label:"",value:v.model,onChange:l=>ie("model",l.target.value),disabled:k("sati.model")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),s.jsxs("div",{className:"flex items-center gap-2",children:[S("sati.api_key"),ve("sati",v.api_key)]})]}),s.jsx(w,{label:"",type:"password",value:v.api_key||"",onChange:l=>ie("api_key",l.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:k("sati.api_key")}),v.provider==="openrouter"&&s.jsx(w,{label:"Base URL",value:v.base_url||"https://openrouter.ai/api/v1",onChange:l=>ie("base_url",l.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"}),s.jsx(C,{label:"Memory Limit",value:v.memory_limit??10,onChange:l=>ie("memory_limit",parseInt(l.target.value)),min:1,step:1,helperText:"Number of memory items to retrieve from long-term storage."}),s.jsx(C,{label:"Evaluation Interval",value:v.evaluation_interval??1,onChange:l=>ie("evaluation_interval",parseInt(l.target.value)),min:1,step:1,helperText:"Oracle turns between memory evaluations. Default: 1 (every turn). *If Evaluation interval is more than context window, this value will be ignored."}),s.jsx(re,{label:"Enable Archived Sessions in Memory Retrieval",checked:v.enabled_archived_sessions??!0,onChange:l=>ie("enabled_archived_sessions",l)}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Similarity Threshold"}),s.jsx("span",{className:"text-sm font-mono text-azure-text-primary dark:text-matrix-highlight",children:(v.similarity_threshold??.9).toFixed(2)})]}),s.jsx("input",{type:"range",min:0,max:1,step:.01,value:v.similarity_threshold??.9,onChange:l=>ie("similarity_threshold",parseFloat(l.target.value)),className:`w-full h-1.5 rounded-full appearance-none cursor-pointer
40
- bg-gray-200 dark:bg-matrix-primary/30
41
- accent-azure-primary dark:accent-matrix-highlight`}),s.jsx("p",{className:"mt-1.5 text-xs text-gray-400 dark:text-matrix-secondary",children:"Minimum cosine similarity to consider a memory relevant (0–1). Lower values retrieve more memories, but may increase token consumption."})]})]})]}),he==="neo"&&s.jsxs(F,{title:"Neo Agent",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"MCP + internal tools subagent — executes analytical and operational tasks delegated by Oracle"}),s.jsxs("div",{className:"mb-4",children:[s.jsx("button",{type:"button",onClick:xr,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),s.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),N&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("neo.provider")]}),s.jsx(K,{label:"",value:N.provider,onChange:l=>oe("provider",l.target.value),options:Ce,disabled:k("neo.provider")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),S("neo.model")]}),s.jsx(w,{label:"",value:N.model,onChange:l=>oe("model",l.target.value),disabled:k("neo.model")}),s.jsx(w,{label:"Personality",value:N.personality||"analytical_engineer",onChange:l=>oe("personality",l.target.value),placeholder:"analytical_engineer",helperText:"e.g., analytical_engineer, meticulous_auditor, systems_thinker"}),s.jsx(K,{label:"Execution Mode",value:N.execution_mode||"async",onChange:l=>oe("execution_mode",l.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),S("neo.temperature")]}),s.jsx(C,{label:"",value:N.temperature,onChange:l=>oe("temperature",parseFloat(l.target.value)),step:.1,min:0,max:1,disabled:k("neo.temperature")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Tokens"}),S("neo.max_tokens")]}),s.jsx(C,{label:"",value:N.max_tokens??"",onChange:l=>oe("max_tokens",l.target.value?parseInt(l.target.value):void 0),min:1,helperText:"Maximum tokens per response. Leave empty for model default.",disabled:k("neo.max_tokens")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Context Window (Messages)"}),S("neo.context_window")]}),s.jsx(C,{label:"",value:N.context_window??100,onChange:l=>oe("context_window",parseInt(l.target.value)),min:1,step:1,disabled:k("neo.context_window")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),s.jsxs("div",{className:"flex items-center gap-2",children:[S("neo.api_key"),ve("neo",N.api_key)]})]}),s.jsx(w,{label:"",type:"password",value:N.api_key||"",onChange:l=>oe("api_key",l.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:k("neo.api_key")}),N.provider==="openrouter"&&s.jsx(w,{label:"Base URL",value:N.base_url||"https://openrouter.ai/api/v1",onChange:l=>oe("base_url",l.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]})]}),he==="trinity"&&s.jsxs(F,{title:"Trinity Agent",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Database subagent — interprets natural language queries and executes them against registered databases (PostgreSQL, MySQL, SQLite, MongoDB)"}),s.jsxs("div",{className:"mb-4",children:[s.jsx("button",{type:"button",onClick:gr,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),s.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),y&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("trinity.provider")]}),s.jsx(K,{label:"",value:y.provider,onChange:l=>le("provider",l.target.value),options:Ce,disabled:k("trinity.provider")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),S("trinity.model")]}),s.jsx(w,{label:"",value:y.model,onChange:l=>le("model",l.target.value),disabled:k("trinity.model")}),s.jsx(w,{label:"Personality",value:y.personality||"data_specialist",onChange:l=>le("personality",l.target.value),placeholder:"data_specialist",helperText:"e.g., data_specialist, query_optimizer, db_architect"}),s.jsx(K,{label:"Execution Mode",value:y.execution_mode||"async",onChange:l=>le("execution_mode",l.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),S("trinity.temperature")]}),s.jsx(C,{label:"",value:y.temperature,onChange:l=>le("temperature",parseFloat(l.target.value)),step:.1,min:0,max:1,disabled:k("trinity.temperature")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Tokens"}),S("trinity.max_tokens")]}),s.jsx(C,{label:"",value:y.max_tokens??"",onChange:l=>le("max_tokens",l.target.value?parseInt(l.target.value):void 0),min:1,helperText:"Maximum tokens per response. Leave empty for model default.",disabled:k("trinity.max_tokens")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),s.jsxs("div",{className:"flex items-center gap-2",children:[S("trinity.api_key"),ve("trinity",y.api_key)]})]}),s.jsx(w,{label:"",type:"password",value:y.api_key||"",onChange:l=>le("api_key",l.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:k("trinity.api_key")}),y.provider==="openrouter"&&s.jsx(w,{label:"Base URL",value:y.base_url||"https://openrouter.ai/api/v1",onChange:l=>le("base_url",l.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"})]})]}),he==="link"&&s.jsxs(F,{title:"Link Agent",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Documentation specialist — indexes documents from ~/.morpheus/docs, uses an LLM to reason over search results and synthesize intelligent answers"}),$&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mb-4",children:s.jsx("button",{type:"button",onClick:yr,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"})}),s.jsx(K,{label:"Provider",value:$.provider||"openai",onChange:l=>G("provider",l.target.value),options:[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"openrouter",label:"OpenRouter"},{value:"ollama",label:"Ollama"},{value:"gemini",label:"Gemini"}]}),s.jsx(w,{label:"Model Name",value:$.model||"",onChange:l=>G("model",l.target.value),placeholder:"e.g., gpt-4"}),s.jsx(w,{label:"Personality",value:$.personality||"",onChange:l=>G("personality",l.target.value),placeholder:"documentation_specialist"}),s.jsx(K,{label:"Execution Mode",value:$.execution_mode||"async",onChange:l=>G("execution_mode",l.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),s.jsx(C,{label:"Temperature",value:$.temperature??.2,onChange:l=>G("temperature",parseFloat(l.target.value)),step:.1,min:0,max:1}),s.jsx(w,{label:"API Key (optional — falls back to Oracle)",value:$.api_key||"",onChange:l=>G("api_key",l.target.value||void 0),type:"password",placeholder:"Leave empty to use Oracle's API key"}),s.jsx("h4",{className:"text-sm font-medium text-azure-text dark:text-matrix-highlight mt-6 mb-3",children:"RAG Settings"}),s.jsx(C,{label:"Chunk Size",value:$.chunk_size,onChange:l=>G("chunk_size",parseInt(l.target.value)||500),min:100,max:2e3,helperText:"Character count per document chunk (default: 500)"}),s.jsx(C,{label:"Score Threshold",value:$.score_threshold,onChange:l=>G("score_threshold",parseFloat(l.target.value)||.5),step:.1,min:0,max:1,helperText:"Minimum similarity score to include in results (0-1, default: 0.5)"}),s.jsx(C,{label:"Max Results",value:$.max_results,onChange:l=>G("max_results",parseInt(l.target.value)||10),min:1,max:50,helperText:"Maximum number of chunks to return per search (default: 10)"}),s.jsx(C,{label:"Scan Interval (ms)",value:$.scan_interval_ms,onChange:l=>G("scan_interval_ms",parseInt(l.target.value)||3e4),min:5e3,max:3e5,helperText:"How often to scan docs folder for changes (default: 30000ms = 30s)"}),s.jsx(C,{label:"Max File Size (MB)",value:$.max_file_size_mb,onChange:l=>G("max_file_size_mb",parseInt(l.target.value)||50),min:1,max:100,helperText:"Maximum file size to process (default: 50MB)"}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(C,{label:"Vector Weight",value:$.vector_weight,onChange:l=>G("vector_weight",parseFloat(l.target.value)||.8),step:.1,min:0,max:1,helperText:"Weight for vector similarity (default: 0.8)"}),s.jsx(C,{label:"BM25 Weight",value:$.bm25_weight,onChange:l=>G("bm25_weight",parseFloat(l.target.value)||.2),step:.1,min:0,max:1,helperText:"Weight for keyword matching (default: 0.2)"})]}),s.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-2",children:"Note: Vector weight + BM25 weight should equal 1.0 for balanced results"})]})]}),he==="apoc"&&s.jsxs(F,{title:"Apoc Agent",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"DevTools subagent — executes file, shell, git, network, and system operations on behalf of Oracle"}),s.jsxs("div",{className:"mb-4",children:[s.jsx("button",{type:"button",onClick:vr,className:"px-3 py-1.5 text-sm bg-azure-surface border border-azure-border rounded hover:bg-azure-primary/10 dark:bg-matrix-primary/20 dark:border-matrix-primary dark:hover:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight transition-colors",children:"Copy from Oracle Agent"}),s.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Copy Provider, Model, and API Key from Oracle Agent configuration"})]}),T&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("apoc.provider")]}),s.jsx(K,{label:"",value:T.provider,onChange:l=>se("provider",l.target.value),options:Ce,disabled:k("apoc.provider")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model Name"}),S("apoc.model")]}),s.jsx(w,{label:"",value:T.model,onChange:l=>se("model",l.target.value),disabled:k("apoc.model")}),s.jsx(w,{label:"Personality",value:T.personality||"pragmatic_dev",onChange:l=>se("personality",l.target.value),placeholder:"pragmatic_dev",helperText:"e.g., pragmatic_dev, cautious_admin, automation_specialist"}),s.jsx(K,{label:"Execution Mode",value:T.execution_mode||"async",onChange:l=>se("execution_mode",l.target.value),options:[{value:"async",label:"Async (background task)"},{value:"sync",label:"Sync (inline response)"}]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Temperature"}),S("apoc.temperature")]}),s.jsx(C,{label:"",value:T.temperature,onChange:l=>se("temperature",parseFloat(l.target.value)),step:.1,min:0,max:1,disabled:k("apoc.temperature")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),s.jsxs("div",{className:"flex items-center gap-2",children:[S("apoc.api_key"),ve("apoc",T.api_key)]})]}),s.jsx(w,{label:"",type:"password",value:T.api_key||"",onChange:l=>se("api_key",l.target.value),placeholder:"sk-...",helperText:"Stored locally.",disabled:k("apoc.api_key")}),T.provider==="openrouter"&&s.jsx(w,{label:"Base URL",value:T.base_url||"https://openrouter.ai/api/v1",onChange:l=>se("base_url",l.target.value),placeholder:"https://openrouter.ai/api/v1",helperText:"Base URL for OpenRouter API"}),s.jsx(C,{label:"Timeout (ms)",value:T.timeout_ms??3e4,onChange:l=>se("timeout_ms",parseInt(l.target.value)),min:1e3,step:1e3,helperText:"Maximum execution time for shell and system operations in milliseconds."})]})]})]}),X==="devkit"&&s.jsxs(s.Fragment,{children:[s.jsxs(F,{title:"DevKit Security",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Shared security configuration for DevKit tools used by Apoc. Controls path sandboxing, shell command restrictions, and tool category access."}),s.jsx(w,{label:"Sandbox Directory",value:u.devkit?.sandbox_dir||"",onChange:l=>_(["devkit","sandbox_dir"],l.target.value),placeholder:typeof window<"u"?"(defaults to process.cwd())":"",helperText:"Root directory for all DevKit operations. All file, shell, and git paths are confined here.",disabled:k("devkit.sandbox_dir")}),s.jsx(ct,{label:"Allowed Paths",value:u.devkit?.allowed_paths?.join(`
42
- `)||"",onChange:l=>_(["devkit","allowed_paths"],l.target.value.split(`
43
- `).map(z=>z.trim()).filter(Boolean)),placeholder:"~/.morpheus/docs",helperText:"Additional paths outside sandbox_dir that DevKit can access (one per line).",rows:4}),s.jsx(K,{label:"Read-Only Mode",value:u.devkit?.readonly_mode?"true":"false",onChange:l=>_(["devkit","readonly_mode"],l.target.value==="true"),options:[{value:"false",label:"Disabled (read + write)"},{value:"true",label:"Enabled (read-only, blocks writes/deletes)"}],helperText:"When enabled, blocks all write, delete, and create operations on the filesystem.",disabled:k("devkit.readonly_mode")}),s.jsx(C,{label:"Timeout (ms)",value:u.devkit?.timeout_ms??3e4,onChange:l=>_(["devkit","timeout_ms"],parseInt(l.target.value)),min:1e3,step:1e3,helperText:"Default timeout for shell and system operations in milliseconds.",disabled:k("devkit.timeout_ms")})]}),s.jsxs(F,{title:"Tool Categories",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Enable or disable entire categories of DevKit tools."}),s.jsx(re,{label:"Filesystem (read, write, list, copy, move, delete files)",checked:u.devkit?.enable_filesystem!==!1,onChange:l=>_(["devkit","enable_filesystem"],l)}),s.jsx(re,{label:"Shell (run_command, run_script, which)",checked:u.devkit?.enable_shell!==!1,onChange:l=>_(["devkit","enable_shell"],l)}),s.jsx(re,{label:"Git (status, diff, commit, push, pull, clone, branch)",checked:u.devkit?.enable_git!==!1,onChange:l=>_(["devkit","enable_git"],l)}),s.jsx(re,{label:"Network (http_request, ping, dns_lookup, download_file)",checked:u.devkit?.enable_network!==!1,onChange:l=>_(["devkit","enable_network"],l)})]}),s.jsxs(F,{title:"Shell Command Allowlist",children:[s.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary mb-4",children:"Restrict which shell commands Apoc can execute. Leave empty to allow all commands (default)."}),s.jsx(w,{label:"Allowed Commands",value:(u.devkit?.allowed_shell_commands||[]).join(", "),onChange:l=>_(["devkit","allowed_shell_commands"],l.target.value.split(",").map(z=>z.trim()).filter(Boolean)),placeholder:"e.g. node, npm, git, python, cargo",helperText:"Comma-separated list of allowed binary names. Empty = all commands allowed.",disabled:k("devkit.allowed_shell_commands")})]})]}),X==="audio"&&s.jsxs(F,{title:"Audio Transcription",children:[s.jsx(re,{label:"Enable Audio",checked:u.audio.enabled,onChange:l=>_(["audio","enabled"],l)}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Provider"}),S("audio.provider")]}),s.jsx(K,{label:"",value:u.audio.provider||"google",onChange:l=>_(["audio","provider"],l.target.value),options:[{label:"Google Gemini",value:"google"},{label:"OpenAI (Whisper)",value:"openai"},{label:"OpenRouter (multimodal)",value:"openrouter"},{label:"Ollama (Whisper local)",value:"ollama"}],error:Q["audio.provider"],disabled:k("audio.provider")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Model"}),S("audio.model")]}),s.jsx(w,{label:"",value:u.audio.model,onChange:l=>_(["audio","model"],l.target.value),placeholder:"e.g. whisper-1, gemini-2.5-flash-lite...",helperText:"Model to use for audio transcription.",error:Q["audio.model"],disabled:k("audio.model")}),u.audio.provider==="ollama"&&s.jsx(w,{label:"Base URL",value:u.audio.base_url||"",onChange:l=>_(["audio","base_url"],l.target.value),placeholder:"http://localhost:11434",helperText:"Ollama base URL. Requires a Whisper model loaded (ollama pull whisper)."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"API Key"}),s.jsxs("div",{className:"flex items-center gap-2",children:[S("audio.apiKey"),ve("audio",u.audio.apiKey)]})]}),s.jsx(w,{label:"",type:"password",value:u.audio.apiKey||"",onChange:l=>_(["audio","apiKey"],l.target.value),placeholder:"If different from LLM key...",helperText:"Leave empty to use LLM API key if using the same provider.",disabled:k("audio.apiKey")}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"block text-sm font-medium text-azure-text-primary dark:text-matrix-secondary",children:"Max Duration (Seconds)"}),S("audio.maxDurationSeconds")]}),s.jsx(C,{label:"",value:u.audio.maxDurationSeconds,onChange:l=>_(["audio","maxDurationSeconds"],parseInt(l.target.value)),min:1,disabled:k("audio.maxDurationSeconds")}),s.jsx(w,{label:"Supported Mime Types",value:u.audio.supportedMimeTypes.join(", "),onChange:l=>_(["audio","supportedMimeTypes"],l.target.value.split(",").map(z=>z.trim()).filter(Boolean)),helperText:"Comma separated list (e.g. audio/ogg, audio/mp3)"})]}),X==="channels"&&s.jsxs(s.Fragment,{children:[s.jsxs(F,{title:"Telegram",children:[s.jsx(re,{label:"Enable Telegram",checked:u.channels.telegram.enabled,onChange:l=>_(["channels","telegram","enabled"],l)}),u.channels.telegram.enabled&&s.jsxs("div",{className:"space-y-4 mt-4 pl-4 border-l border-matrix-primary",children:[s.jsx(w,{label:"Bot Token",type:"password",value:u.channels.telegram.token||"",onChange:l=>_(["channels","telegram","token"],l.target.value)}),s.jsx(w,{label:"Allowed Users (comma separated)",value:u.channels.telegram.allowedUsers.join(", "),onChange:l=>_(["channels","telegram","allowedUsers"],l.target.value.split(",").map(z=>z.trim()).filter(Boolean)),helperText:"User IDs allowed to interact with the bot"})]})]}),s.jsxs(F,{title:"Discord",children:[s.jsx(re,{label:"Enable Discord",checked:u.channels.discord.enabled,onChange:l=>_(["channels","discord","enabled"],l)}),u.channels.discord.enabled&&s.jsxs("div",{className:"space-y-4 mt-4 pl-4 border-l border-matrix-primary",children:[s.jsx(w,{label:"Bot Token",type:"password",value:u.channels.discord.token||"",onChange:l=>_(["channels","discord","token"],l.target.value)}),s.jsx(w,{label:"Allowed Users (comma separated)",value:(u.channels.discord.allowedUsers??[]).join(", "),onChange:l=>_(["channels","discord","allowedUsers"],l.target.value.split(",").map(z=>z.trim()).filter(Boolean)),helperText:"Discord user IDs allowed to interact with the bot"})]})]})]}),X==="ui"&&s.jsxs(F,{title:"Dashboard",children:[s.jsx(re,{label:"Enable Web UI",checked:u.ui.enabled,onChange:l=>_(["ui","enabled"],l)}),s.jsx(C,{label:"Port",value:u.ui.port,onChange:l=>_(["ui","port"],parseInt(l.target.value)),disabled:!0,helperText:"Port changes require daemon restart."})]}),X==="logging"&&s.jsxs(F,{title:"Logging",children:[s.jsx(re,{label:"Enable Logging",checked:u.logging.enabled,onChange:l=>_(["logging","enabled"],l)}),s.jsx(K,{label:"Log Level",value:u.logging.level,onChange:l=>_(["logging","level"],l.target.value),options:[{label:"Debug",value:"debug"},{label:"Info",value:"info"},{label:"Warning",value:"warn"},{label:"Error",value:"error"}]})]}),X==="chronos"&&f&&s.jsxs(F,{title:"Chronos — Temporal Intent Engine",children:[s.jsx(K,{label:"Timezone",value:f.timezone,onChange:l=>h({...f,timezone:l.target.value}),options:[{label:"UTC",value:"UTC"},{label:"America/New_York",value:"America/New_York"},{label:"America/Chicago",value:"America/Chicago"},{label:"America/Denver",value:"America/Denver"},{label:"America/Los_Angeles",value:"America/Los_Angeles"},{label:"America/Sao_Paulo",value:"America/Sao_Paulo"},{label:"America/Buenos_Aires",value:"America/Buenos_Aires"},{label:"America/Bogota",value:"America/Bogota"},{label:"America/Lima",value:"America/Lima"},{label:"America/Santiago",value:"America/Santiago"},{label:"America/Mexico_City",value:"America/Mexico_City"},{label:"America/Toronto",value:"America/Toronto"},{label:"America/Vancouver",value:"America/Vancouver"},{label:"Europe/London",value:"Europe/London"},{label:"Europe/Paris",value:"Europe/Paris"},{label:"Europe/Berlin",value:"Europe/Berlin"},{label:"Europe/Madrid",value:"Europe/Madrid"},{label:"Europe/Rome",value:"Europe/Rome"},{label:"Europe/Amsterdam",value:"Europe/Amsterdam"},{label:"Europe/Brussels",value:"Europe/Brussels"},{label:"Europe/Zurich",value:"Europe/Zurich"},{label:"Europe/Lisbon",value:"Europe/Lisbon"},{label:"Europe/Warsaw",value:"Europe/Warsaw"},{label:"Europe/Stockholm",value:"Europe/Stockholm"},{label:"Europe/Helsinki",value:"Europe/Helsinki"},{label:"Europe/Moscow",value:"Europe/Moscow"},{label:"Asia/Dubai",value:"Asia/Dubai"},{label:"Asia/Kolkata",value:"Asia/Kolkata"},{label:"Asia/Bangkok",value:"Asia/Bangkok"},{label:"Asia/Singapore",value:"Asia/Singapore"},{label:"Asia/Hong_Kong",value:"Asia/Hong_Kong"},{label:"Asia/Shanghai",value:"Asia/Shanghai"},{label:"Asia/Tokyo",value:"Asia/Tokyo"},{label:"Asia/Seoul",value:"Asia/Seoul"},{label:"Australia/Sydney",value:"Australia/Sydney"},{label:"Australia/Melbourne",value:"Australia/Melbourne"},{label:"Pacific/Auckland",value:"Pacific/Auckland"},{label:"Africa/Cairo",value:"Africa/Cairo"},{label:"Africa/Johannesburg",value:"Africa/Johannesburg"}]}),s.jsx(C,{label:"Check Interval (seconds)",value:Math.round(f.check_interval_ms/1e3),onChange:l=>h({...f,check_interval_ms:Number(l.target.value)*1e3}),min:60}),s.jsx(C,{label:"Max Active Jobs",value:f.max_active_jobs,onChange:l=>h({...f,max_active_jobs:Number(l.target.value)}),min:1,max:1e3})]}),X==="danger"&&s.jsx(As,{})]})]}):s.jsx("div",{className:"p-8 text-azure-primary dark:text-matrix-highlight",children:"Loading settings..."})}const xe=[{id:"sessions",label:"Sessions & Messages",description:"All chat sessions and their messages"},{id:"memories",label:"Long-term Memories",description:"Sati knowledge base, embeddings, and archived session chunks"},{id:"tasks",label:"Tasks",description:"Background task queue and execution results"},{id:"audit",label:"Audit Logs",description:"All agent and tool audit events"},{id:"chronos",label:"Chronos Jobs",description:"Scheduled jobs and their execution history"},{id:"webhooks",label:"Webhooks",description:"Webhook definitions and notification history"}];function As(){const[e,t]=E.useState(new Set),[r,n]=E.useState(!1),[o,i]=E.useState(!1),[a,c]=E.useState(null),d=u=>{t(b=>{const v=new Set(b);return v.has(u)?v.delete(u):v.add(u),v})},p=()=>{e.size===xe.length?t(new Set):t(new Set(xe.map(u=>u.id)))},f=async()=>{if(e.size!==0){i(!0),c(null);try{const u=await Cs.resetData([...e]);c({success:!0,message:u.message}),t(new Set),ue(()=>!0,void 0,{revalidate:!0})}catch(u){c({success:!1,message:u instanceof Error?u.message:"Failed to reset data"})}finally{i(!1)}}},h=xe.filter(u=>e.has(u.id)).map(u=>u.label);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg border-2 border-red-300 dark:border-red-900 bg-red-50 dark:bg-red-950/20 p-6 space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($r,{className:"w-6 h-6 text-red-500 dark:text-red-400 shrink-0"}),s.jsx("h3",{className:"text-lg font-semibold text-red-700 dark:text-red-400",children:"Danger Zone"})]}),s.jsxs("p",{className:"text-sm text-red-600 dark:text-red-300/80",children:["Select the data you want to permanently delete. These actions are ",s.jsx("strong",{children:"irreversible"}),"."]}),s.jsxs("div",{className:"rounded-md border border-red-200 dark:border-red-900/60 bg-white dark:bg-black p-4 space-y-3",children:[s.jsxs("label",{className:"flex items-center gap-3 pb-2 border-b border-red-100 dark:border-red-900/40 cursor-pointer select-none",children:[s.jsx("input",{type:"checkbox",checked:e.size===xe.length,onChange:p,className:`w-4 h-4 rounded border-red-300 text-red-600 focus:ring-red-500
44
- dark:border-red-800 dark:bg-black dark:checked:bg-red-600`}),s.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-400",children:"Select all"})]}),xe.map(u=>s.jsxs("label",{className:"flex items-start gap-3 cursor-pointer select-none",children:[s.jsx("input",{type:"checkbox",checked:e.has(u.id),onChange:()=>d(u.id),className:`w-4 h-4 mt-0.5 rounded border-red-300 text-red-600 focus:ring-red-500
45
- dark:border-red-800 dark:bg-black dark:checked:bg-red-600`}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:u.label}),s.jsx("p",{className:"text-xs text-red-500 dark:text-red-300/60",children:u.description})]})]},u.id))]}),s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("p",{className:"text-xs text-red-500 dark:text-red-300/50",children:e.size===0?"No categories selected":`${e.size} of ${xe.length} selected`}),s.jsx("button",{onClick:()=>n(!0),disabled:o||e.size===0,className:`shrink-0 px-4 py-2 text-sm font-medium rounded-md
46
- bg-red-600 text-white hover:bg-red-700
47
- dark:bg-red-900/50 dark:text-red-200 dark:hover:bg-red-800/60
48
- disabled:opacity-50 disabled:cursor-not-allowed
49
- transition-colors`,children:o?"Resetting...":"Reset selected data"})]}),a&&s.jsx("div",{className:`rounded-md p-3 text-sm ${a.success?"bg-green-50 text-green-700 dark:bg-green-950/30 dark:text-green-400 border border-green-200 dark:border-green-900":"bg-red-100 text-red-700 dark:bg-red-950/40 dark:text-red-300 border border-red-300 dark:border-red-800"}`,children:a.message})]}),s.jsx(Nr,{isOpen:r,onClose:()=>n(!1),onConfirm:f,title:"Reset selected data?",description:`This will permanently delete: ${h.join(", ")}. This action cannot be undone.`,confirmJson:"Yes, delete permanently",variant:"destructive"})]})}export{Us as default};
@@ -1,7 +0,0 @@
1
- import{j as e,m as n}from"./vendor-motion-C3CZ8ZlO.js";import{r as s}from"./vendor-react-DikRIOlj.js";import{u as Z}from"./vendor-utils-D4NnWbOU.js";import{s as l}from"./skills-wANsorUj.js";import{D as K,e as O,j as V}from"./index-Bta9YXEm.js";import{W as y,ak as u,Q as b,a2 as W,G as F,V as L,U as I,_ as q,a3 as A,a4 as B,X as G,al as H}from"./vendor-icons-NHF9HNeN.js";const U={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},g={hidden:{opacity:0,y:8},show:{opacity:1,y:0}};function M({skill:r,onToggle:i,onView:d}){return e.jsxs(n.div,{variants:g,className:`rounded-lg border flex flex-col transition-all ${r.enabled?"border-azure-primary/50 dark:border-matrix-primary bg-white dark:bg-zinc-900 shadow-sm":"border-azure-border dark:border-matrix-primary/30 bg-azure-surface/50 dark:bg-zinc-900 shadow-sm"}`,children:[e.jsxs("div",{className:"p-4 flex items-start gap-3 flex-1",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${r.enabled?"bg-azure-primary/10 dark:bg-matrix-highlight/10":"bg-azure-surface dark:bg-zinc-900"}`,children:e.jsx(y,{className:`w-4 h-4 ${r.enabled?"text-azure-primary dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:`font-semibold truncate ${r.enabled?"text-azure-text dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary"}`,children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]}),!r.enabled&&e.jsx("span",{className:"text-[10px] font-medium text-zinc-400 dark:text-zinc-500 bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-700 rounded px-1.5 py-0.5 shrink-0",children:"disabled"})]}),e.jsx("p",{className:`text-sm mt-1.5 line-clamp-2 leading-relaxed ${r.enabled?"text-azure-text-secondary dark:text-matrix-secondary":"text-azure-text-secondary/70 dark:text-matrix-tertiary"}`,children:r.description}),r.tags&&r.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]})]}),e.jsxs("div",{className:"px-4 py-3 border-t border-azure-border dark:border-matrix-primary/30 flex items-center justify-between gap-2",children:[r.author?e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary min-w-0",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),e.jsx("span",{className:"truncate",children:r.author})]}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:d,className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary/50 text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"View details",children:e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:i,className:`p-1.5 rounded border transition-colors ${r.enabled?"border-emerald-300 dark:border-emerald-700/60 text-emerald-500 dark:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-900/20":"border-azure-border dark:border-matrix-primary/40 text-zinc-400 dark:text-zinc-600 hover:text-azure-text dark:hover:text-matrix-secondary hover:border-azure-border dark:hover:border-matrix-primary"}`,title:r.enabled?"Disable skill":"Enable skill",children:r.enabled?e.jsx(A,{className:"w-4 h-4"}):e.jsx(B,{className:"w-4 h-4"})})]})]})]})}function Q({skill:r,open:i,onOpenChange:d}){return!i||!r?null:e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>d(!1)}),e.jsxs("div",{className:"relative bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-b border-azure-border dark:border-matrix-primary shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 flex items-center justify-center shrink-0",children:e.jsx(y,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight truncate",children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]})]}),r.author&&e.jsxs("div",{className:"flex items-center gap-1 mt-0.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),r.author]})]})]}),e.jsx("button",{onClick:()=>d(!1),className:"p-1.5 rounded text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight hover:bg-azure-surface dark:hover:bg-zinc-900 transition-colors shrink-0",children:e.jsx(G,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"overflow-y-auto flex-1 p-5 space-y-5",children:[r.description&&e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary leading-relaxed",children:r.description}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsxs("div",{className:"flex items-start gap-2 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(H,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{className:"break-all font-mono text-azure-text dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-2 py-0.5",children:r.path})]})}),r.tags&&r.tags.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]}),r.examples&&r.examples.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Examples"}),e.jsx("ul",{className:"space-y-1.5",children:r.examples.map((t,x)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-azure-text-secondary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/30 rounded px-3 py-2",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary font-mono text-xs mt-0.5 shrink-0",children:[x+1,"."]}),t]},x))})]}),r.content&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"SKILL.md"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-72 whitespace-pre-wrap leading-relaxed font-mono",children:r.content})]})]})]})]})}function ae(){const[r,i]=s.useState(null),[d,t]=s.useState(!1),[x,N]=s.useState(!1),[o,v]=s.useState(!1),[c,k]=s.useState(null),[w,f]=s.useState(null),j=s.useRef(null),{data:S,mutate:z,isLoading:D}=Z("/skills",()=>l.fetchSkills(),{refreshInterval:1e4}),m=S?.skills??[],E=S?.enabled??0,R=async()=>{await l.reloadSkills(),z()},T=async a=>{a.enabled?await l.disableSkill(a.name):await l.enableSkill(a.name),z()},$=async a=>{t(!0);try{const p=await l.fetchSkill(a.name);i(p)}finally{t(!1)}},P=async a=>{const p=a.target.files?.[0];if(p){k(null),f(null),v(!0);try{const h=await l.uploadSkill(p);f(`Skill "${h.skill.name}" uploaded successfully!`),z(),j.current&&(j.current.value="")}catch(h){k({error:h.message||"Upload failed",details:h.details})}finally{v(!1)}}},C=()=>{k(null),f(null),N(!0)};return e.jsxs(n.div,{variants:U,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(n.div,{variants:g,className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(y,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Skills"}),e.jsxs("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:[m.length," skill",m.length!==1?"s":"",", ",E," enabled"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:C,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-azure-primary dark:border-matrix-primary text-azure-primary dark:text-matrix-primary font-medium hover:bg-azure-primary/10 dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload"]}),e.jsxs("button",{onClick:R,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(b,{className:"w-4 h-4"}),"Reload"]})]})]}),D?e.jsxs(n.div,{variants:g,className:"text-center py-12",children:[e.jsx(b,{className:"w-8 h-8 animate-spin mx-auto text-azure-text-secondary dark:text-matrix-dim"}),e.jsx("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-dim",children:"Loading skills..."})]}):m.length===0?e.jsxs(n.div,{variants:g,className:"rounded-lg border border-dashed border-azure-border dark:border-matrix-primary p-8 text-center",children:[e.jsx(y,{className:"w-12 h-12 mx-auto text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("h3",{className:"mt-4 text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:"No skills found"}),e.jsxs("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-secondary max-w-md mx-auto",children:["Upload a skill ZIP or add skills manually to"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"~/.morpheus/skills/"}),". Each skill folder must contain a"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file with frontmatter."]}),e.jsxs("button",{onClick:C,className:"mt-4 inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload Skill"]})]}):e.jsx(n.div,{variants:U,initial:"hidden",animate:"show",className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:m.map(a=>e.jsx(M,{skill:a,onToggle:()=>T(a),onView:()=>$(a)},a.name))}),e.jsx(Q,{skill:r,open:!!r,onOpenChange:a=>!a&&i(null)}),e.jsxs(K,{open:x,onOpenChange:N,children:[e.jsx(O,{children:e.jsx(V,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{className:"w-5 h-5"}),"Upload Skill"]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm",children:["Upload a ZIP file containing your skill folder. The ZIP must have exactly one folder at root level with a valid ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file."]}),e.jsxs("div",{className:"border-2 border-dashed border-azure-border dark:border-matrix-primary rounded-lg p-6",children:[e.jsx("input",{ref:j,type:"file",accept:".zip,application/zip,application/x-zip-compressed",onChange:P,disabled:o,className:"hidden",id:"skill-upload-input"}),e.jsxs("label",{htmlFor:"skill-upload-input",className:`flex flex-col items-center gap-2 cursor-pointer ${o?"opacity-50 cursor-not-allowed":""}`,children:[o?e.jsx(b,{className:"w-8 h-8 animate-spin text-azure-primary dark:text-matrix-primary"}):e.jsx(u,{className:"w-8 h-8 text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:o?"Uploading...":"Click to select ZIP file"})]})]}),c&&e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800",children:[e.jsx(W,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:c.error}),c.details&&e.jsx("p",{className:"text-xs text-red-600 dark:text-red-300 mt-1",children:c.details})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800",children:[e.jsx(F,{className:"w-5 h-5 text-green-600 dark:text-green-400"}),e.jsx("p",{className:"text-sm text-green-800 dark:text-green-200",children:w})]}),e.jsxs("div",{className:"rounded-lg bg-azure-hover dark:bg-zinc-900 p-3",children:[e.jsx("h4",{className:"text-sm font-medium text-azure-text-primary dark:text-matrix-highlight mb-2",children:"ZIP Structure Example"}),e.jsx("pre",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:`my-skill.zip
2
- └── my-skill/
3
- ├── SKILL.md (required)
4
- ├── scripts/ (optional)
5
- │ └── script.js
6
- └── examples/ (optional)
7
- └── output.txt`})]})]})]}),d&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsx(b,{className:"w-8 h-8 animate-spin text-white"})})]})}export{ae as SkillsPage};