reflex-agent 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +97 -97
  3. package/.next/app-path-routes-manifest.json +9 -9
  4. package/.next/build-manifest.json +5 -5
  5. package/.next/prerender-manifest.json +7 -7
  6. package/.next/react-loadable-manifest.json +1 -1
  7. package/.next/server/app/_not-found/page.js +2 -2
  8. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  9. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  10. package/.next/server/app/agents/[agentId]/page.js +3 -3
  11. package/.next/server/app/agents/[agentId]/page.js.nft.json +1 -1
  12. package/.next/server/app/agents/[agentId]/page_client-reference-manifest.js +1 -1
  13. package/.next/server/app/api/agents/[agentId]/respond/route.js +2 -2
  14. package/.next/server/app/api/agents/[agentId]/respond/route.js.nft.json +1 -1
  15. package/.next/server/app/api/agents/[agentId]/respond/route_client-reference-manifest.js +1 -1
  16. package/.next/server/app/api/images/[rootId]/[file]/route_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/oauth/callback/route_client-reference-manifest.js +1 -1
  18. package/.next/server/app/api/oauth/start/route_client-reference-manifest.js +1 -1
  19. package/.next/server/app/api/roots/[id]/attachments/route_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/roots/[id]/chat/[topicId]/send/route.js +2 -2
  21. package/.next/server/app/api/roots/[id]/chat/[topicId]/send/route.js.nft.json +1 -1
  22. package/.next/server/app/api/roots/[id]/chat/[topicId]/send/route_client-reference-manifest.js +1 -1
  23. package/.next/server/app/api/roots/[id]/chat/[topicId]/stop/route.js +2 -2
  24. package/.next/server/app/api/roots/[id]/chat/[topicId]/stop/route.js.nft.json +1 -1
  25. package/.next/server/app/api/roots/[id]/chat/[topicId]/stop/route_client-reference-manifest.js +1 -1
  26. package/.next/server/app/api/roots/[id]/chat/[topicId]/stream/route.js +3 -3
  27. package/.next/server/app/api/roots/[id]/chat/[topicId]/stream/route.js.nft.json +1 -1
  28. package/.next/server/app/api/roots/[id]/chat/[topicId]/stream/route_client-reference-manifest.js +1 -1
  29. package/.next/server/app/api/roots/[id]/dashboard/route.js +1 -1
  30. package/.next/server/app/api/roots/[id]/dashboard/route.js.nft.json +1 -1
  31. package/.next/server/app/api/roots/[id]/dashboard/route_client-reference-manifest.js +1 -1
  32. package/.next/server/app/api/roots/[id]/suggestions/route.js +1 -1
  33. package/.next/server/app/api/roots/[id]/suggestions/route.js.nft.json +1 -1
  34. package/.next/server/app/api/roots/[id]/suggestions/route_client-reference-manifest.js +1 -1
  35. package/.next/server/app/api/utilities/[scope]/[id]/bundle.js/route_client-reference-manifest.js +1 -1
  36. package/.next/server/app/api/utilities/[scope]/[id]/host/route.js +2 -2
  37. package/.next/server/app/api/utilities/[scope]/[id]/host/route.js.nft.json +1 -1
  38. package/.next/server/app/api/utilities/[scope]/[id]/host/route_client-reference-manifest.js +1 -1
  39. package/.next/server/app/api/utilities/[scope]/[id]/host-api.mjs/route_client-reference-manifest.js +1 -1
  40. package/.next/server/app/api/utilities/[scope]/[id]/host-ui.mjs/route_client-reference-manifest.js +1 -1
  41. package/.next/server/app/api/utilities/[scope]/[id]/iframe/route_client-reference-manifest.js +1 -1
  42. package/.next/server/app/api/utilities/[scope]/[id]/style.css/route_client-reference-manifest.js +1 -1
  43. package/.next/server/app/audit/page.js +1 -1
  44. package/.next/server/app/audit/page.js.nft.json +1 -1
  45. package/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  46. package/.next/server/app/onboarding/page.js +3 -3
  47. package/.next/server/app/onboarding/page.js.nft.json +1 -1
  48. package/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
  49. package/.next/server/app/page.js +3 -2
  50. package/.next/server/app/page.js.nft.json +1 -1
  51. package/.next/server/app/page_client-reference-manifest.js +1 -1
  52. package/.next/server/app/roots/[id]/chat/[topicId]/page.js +2 -2
  53. package/.next/server/app/roots/[id]/chat/[topicId]/page.js.nft.json +1 -1
  54. package/.next/server/app/roots/[id]/chat/[topicId]/page_client-reference-manifest.js +1 -1
  55. package/.next/server/app/roots/[id]/kb/[...slug]/page.js +2 -2
  56. package/.next/server/app/roots/[id]/kb/[...slug]/page.js.nft.json +1 -1
  57. package/.next/server/app/roots/[id]/kb/[...slug]/page_client-reference-manifest.js +1 -1
  58. package/.next/server/app/roots/[id]/page.js +11 -3
  59. package/.next/server/app/roots/[id]/page.js.nft.json +1 -1
  60. package/.next/server/app/roots/[id]/page_client-reference-manifest.js +1 -1
  61. package/.next/server/app/roots/[id]/workflows/[wfId]/page.js +2 -2
  62. package/.next/server/app/roots/[id]/workflows/[wfId]/page.js.nft.json +1 -1
  63. package/.next/server/app/roots/[id]/workflows/[wfId]/page_client-reference-manifest.js +1 -1
  64. package/.next/server/app/roots/[id]/workflows/page.js +1 -1
  65. package/.next/server/app/roots/[id]/workflows/page.js.nft.json +1 -1
  66. package/.next/server/app/roots/[id]/workflows/page_client-reference-manifest.js +1 -1
  67. package/.next/server/app/roots/new/page.js +3 -3
  68. package/.next/server/app/roots/new/page.js.nft.json +1 -1
  69. package/.next/server/app/roots/new/page_client-reference-manifest.js +1 -1
  70. package/.next/server/app/settings/page.js +5 -5
  71. package/.next/server/app/settings/page.js.nft.json +1 -1
  72. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  73. package/.next/server/app/share/[id]/file/page.js +2 -2
  74. package/.next/server/app/share/[id]/file/page.js.nft.json +1 -1
  75. package/.next/server/app/share/[id]/file/page_client-reference-manifest.js +1 -1
  76. package/.next/server/app/share/[id]/page.js +2 -2
  77. package/.next/server/app/share/[id]/page.js.nft.json +1 -1
  78. package/.next/server/app/share/[id]/page_client-reference-manifest.js +1 -1
  79. package/.next/server/app/utilities/[scope]/[id]/page.js +2 -2
  80. package/.next/server/app/utilities/[scope]/[id]/page.js.nft.json +1 -1
  81. package/.next/server/app/utilities/[scope]/[id]/page_client-reference-manifest.js +1 -1
  82. package/.next/server/app/utilities/page.js +2 -2
  83. package/.next/server/app/utilities/page.js.nft.json +1 -1
  84. package/.next/server/app/utilities/page_client-reference-manifest.js +1 -1
  85. package/.next/server/app-paths-manifest.json +9 -9
  86. package/.next/server/chunks/1105.js +1 -1
  87. package/.next/server/chunks/126.js +4 -0
  88. package/.next/server/chunks/{3152.js → 1358.js} +1 -1
  89. package/.next/server/chunks/1769.js +4 -0
  90. package/.next/server/chunks/2485.js +2 -2
  91. package/.next/server/chunks/2787.js +1 -0
  92. package/.next/server/chunks/285.js +154 -50
  93. package/.next/server/chunks/3325.js +1 -0
  94. package/.next/server/chunks/3332.js +1 -1
  95. package/.next/server/chunks/{6266.js → 3662.js} +1 -1
  96. package/.next/server/chunks/3834.js +1 -0
  97. package/.next/server/chunks/4031.js +2 -2
  98. package/.next/server/chunks/4315.js +3 -0
  99. package/.next/server/chunks/4334.js +1 -0
  100. package/.next/server/chunks/4812.js +1 -1
  101. package/.next/server/chunks/4863.js +1 -1
  102. package/.next/server/chunks/4925.js +1 -1
  103. package/.next/server/chunks/6038.js +1 -1
  104. package/.next/server/chunks/6060.js +1 -0
  105. package/.next/server/chunks/6796.js +1 -0
  106. package/.next/server/chunks/7220.js +1 -0
  107. package/.next/server/chunks/{6909.js → 7358.js} +154 -50
  108. package/.next/server/chunks/8576.js +7 -0
  109. package/.next/server/chunks/9098.js +1 -1
  110. package/.next/server/chunks/9179.js +7 -0
  111. package/.next/server/chunks/9897.js +4 -0
  112. package/.next/server/functions-config-manifest.json +2 -2
  113. package/.next/server/middleware-build-manifest.js +1 -1
  114. package/.next/server/middleware-manifest.json +5 -5
  115. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  116. package/.next/server/pages/500.html +1 -1
  117. package/.next/server/server-reference-manifest.js +1 -1
  118. package/.next/server/server-reference-manifest.json +1 -1
  119. package/.next/static/chunks/1160-65b58f7f28665195.js +1 -0
  120. package/.next/static/chunks/2658-cc99fd9ba2a00562.js +1 -0
  121. package/.next/static/chunks/4108.9f8cc28a75365b81.js +1 -0
  122. package/.next/static/chunks/5009-9a5e431b79b6d31a.js +1 -0
  123. package/.next/static/chunks/6525-6a879c1bae21d76b.js +1 -0
  124. package/.next/static/chunks/9129-2656848b2540e05d.js +1 -0
  125. package/.next/static/chunks/app/layout-ad875f9d0eb94653.js +1 -0
  126. package/.next/static/chunks/app/onboarding/{page-bbd13228685e577f.js → page-9dd30a7cc94ad562.js} +1 -1
  127. package/.next/static/chunks/app/page-28756fb2874347a0.js +1 -0
  128. package/.next/static/chunks/app/roots/[id]/chat/[topicId]/page-5cbee36c42e841cd.js +1 -0
  129. package/.next/static/chunks/app/roots/[id]/kb/[...slug]/page-4ef320e1d42925da.js +1 -0
  130. package/.next/static/chunks/app/roots/[id]/page-130496cce12e4d65.js +1 -0
  131. package/.next/static/chunks/app/roots/[id]/workflows/[wfId]/page-a7985128904fb885.js +1 -0
  132. package/.next/static/chunks/app/roots/new/page-ab8f40cf85744a4f.js +1 -0
  133. package/.next/static/chunks/app/settings/page-0e912af785eefc49.js +1 -0
  134. package/.next/static/chunks/app/share/[id]/page-aaabf42daed89c53.js +1 -0
  135. package/.next/static/chunks/app/utilities/[scope]/[id]/page-fc19e1ed2c5b6d91.js +1 -0
  136. package/.next/static/chunks/app/utilities/page-6d361b43b2b8997c.js +1 -0
  137. package/.next/static/chunks/{webpack-18930958151e32fe.js → webpack-0eaa6fc269024b97.js} +1 -1
  138. package/.next/static/css/2bc00775af31f40f.css +1 -0
  139. package/.next/trace +89 -89
  140. package/dist/lib/reflex/agents/prompts.js +105 -0
  141. package/dist/lib/reflex/agents/prompts.js.map +1 -1
  142. package/package.json +1 -1
  143. package/.next/server/chunks/1314.js +0 -1
  144. package/.next/server/chunks/5276.js +0 -3
  145. package/.next/server/chunks/5871.js +0 -1
  146. package/.next/server/chunks/62.js +0 -1
  147. package/.next/server/chunks/9249.js +0 -4
  148. package/.next/static/chunks/1000-49ad093733e70f09.js +0 -1
  149. package/.next/static/chunks/1226-fd290816f32913c2.js +0 -1
  150. package/.next/static/chunks/4108.5dbd5b779fea2993.js +0 -1
  151. package/.next/static/chunks/5771-202f27993722fa17.js +0 -1
  152. package/.next/static/chunks/7124-34b05243f6c43a12.js +0 -1
  153. package/.next/static/chunks/7529-acb1a406a593e6cf.js +0 -1
  154. package/.next/static/chunks/app/layout-f72fb9bc2ee5b6a2.js +0 -1
  155. package/.next/static/chunks/app/page-a617e1a2eaabe4af.js +0 -1
  156. package/.next/static/chunks/app/roots/[id]/chat/[topicId]/page-d6ef0d1004f68749.js +0 -1
  157. package/.next/static/chunks/app/roots/[id]/kb/[...slug]/page-abb5340574dfb7f1.js +0 -1
  158. package/.next/static/chunks/app/roots/[id]/page-b5d8b67b53874827.js +0 -1
  159. package/.next/static/chunks/app/roots/[id]/workflows/[wfId]/page-7ab7e51fa775b34e.js +0 -1
  160. package/.next/static/chunks/app/roots/new/page-8bd0f9cdda3e8174.js +0 -1
  161. package/.next/static/chunks/app/settings/page-b164636cbad34025.js +0 -1
  162. package/.next/static/chunks/app/share/[id]/page-958eed5784f7cc92.js +0 -1
  163. package/.next/static/chunks/app/utilities/[scope]/[id]/page-4383ad50c38434ad.js +0 -1
  164. package/.next/static/chunks/app/utilities/page-ff028844ad2820cd.js +0 -1
  165. package/.next/static/css/c46d970256fc7904.css +0 -1
  166. /package/.next/static/{mc0TeBBP3_H8uf7oGZRzW → MBVnqa0-K_3N0C89I_I5d}/_buildManifest.js +0 -0
  167. /package/.next/static/{mc0TeBBP3_H8uf7oGZRzW → MBVnqa0-K_3N0C89I_I5d}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1226],{3823:(e,t,a)=>{a.d(t,{h:()=>s});var r=a(7911);let s=(0,r.createServerReference)("704bacabaf84b2f058cf0aa17c123bfbb29185c855",r.callServer,void 0,r.findSourceMapURL,"generateTopicTitleAction")},8190:(e,t,a)=>{a.d(t,{CommandBar:()=>h});var r=a(4624),s=a(99356),n=a(69285),l=a(49411),i=a(95265),o=a(56221),c=a(9355),d=a(3823),u=a(63602),m=a(63514),x=a(88190);function h(e){let{rootId:t,focusFile:a}=e,h=(0,l.c)("roots"),[,p]=(0,s.useTransition)(),b=(0,n.useRouter)();return(0,r.jsx)(u.E,{label:h("commandBar.label"),children:(0,r.jsx)(x.L,{rootId:t,placeholder:h("commandBar.placeholder"),submitLabel:h("commandBar.submit"),pendingLabel:h("commandBar.submitPending"),SubmitIcon:i.A,onSubmit:async e=>{let{message:r,attachments:s}=e;return await new Promise(e=>{p(async()=>{let n=await (0,c.g)(t,r,s,a);if(!n.ok){var l;o.oR.error(null!=(l=n.error)?l:h("commandBar.startFailed")),e(!1);return}(0,m.$d)(m.Zi.topicsChanged(t)),r.trim()&&(0,d.h)(t,n.topicId,r).then(e=>{e.ok&&(0,m.$d)(m.Zi.topicsChanged(t))}),b.push("/roots/".concat(t,"/chat/").concat(n.topicId)),e(!0)})})}})})}},9355:(e,t,a)=>{a.d(t,{g:()=>s});var r=a(7911);let s=(0,r.createServerReference)("78973e33b20590eeb273db3bd81f8b711d142c9473",r.callServer,void 0,r.findSourceMapURL,"startTopicAction")},22841:(e,t,a)=>{a.d(t,{bq:()=>u,eb:()=>x,gC:()=>m,l6:()=>c,yv:()=>d});var r=a(4624);a(99356);var s=a(69709),n=a(43153),l=a(59728),i=a(85314),o=a(13506);function c(e){let{...t}=e;return(0,r.jsx)(i.Root,{"data-slot":"select",...t})}function d(e){let{...t}=e;return(0,r.jsx)(i.Value,{"data-slot":"select-value",...t})}function u(e){let{className:t,size:a="default",children:n,...l}=e;return(0,r.jsxs)(i.Trigger,{"data-slot":"select-trigger","data-size":a,className:(0,o.cn)("flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",t),...l,children:[n,(0,r.jsx)(i.Icon,{asChild:!0,children:(0,r.jsx)(s.A,{className:"size-4 opacity-50"})})]})}function m(e){let{className:t,children:a,position:s="item-aligned",align:n="center",...l}=e;return(0,r.jsx)(i.Portal,{children:(0,r.jsxs)(i.Content,{"data-slot":"select-content",className:(0,o.cn)("relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,align:n,...l,children:[(0,r.jsx)(h,{}),(0,r.jsx)(i.Viewport,{className:(0,o.cn)("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:a}),(0,r.jsx)(p,{})]})})}function x(e){let{className:t,children:a,...s}=e;return(0,r.jsxs)(i.Item,{"data-slot":"select-item",className:(0,o.cn)("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...s,children:[(0,r.jsx)("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,r.jsx)(i.ItemIndicator,{children:(0,r.jsx)(n.A,{className:"size-4"})})}),(0,r.jsx)(i.ItemText,{children:a})]})}function h(e){let{className:t,...a}=e;return(0,r.jsx)(i.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:(0,o.cn)("flex cursor-default items-center justify-center py-1",t),...a,children:(0,r.jsx)(l.A,{className:"size-4"})})}function p(e){let{className:t,...a}=e;return(0,r.jsx)(i.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:(0,o.cn)("flex cursor-default items-center justify-center py-1",t),...a,children:(0,r.jsx)(s.A,{className:"size-4"})})}},43504:(e,t,a)=>{a.d(t,{E:()=>n});var r=a(4624),s=a(13506);function n(e){let{className:t,...a}=e;return(0,r.jsx)("div",{"data-slot":"skeleton",className:(0,s.cn)("animate-pulse rounded-md bg-accent",t),...a})}},49881:(e,t,a)=>{a.d(t,{Xi:()=>d,av:()=>u,j7:()=>c,tU:()=>i});var r=a(4624);a(99356);var s=a(60621),n=a(86631),l=a(13506);function i(e){let{className:t,orientation:a="horizontal",...s}=e;return(0,r.jsx)(n.Root,{"data-slot":"tabs","data-orientation":a,orientation:a,className:(0,l.cn)("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",t),...s})}let o=(0,s.F)("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function c(e){let{className:t,variant:a="default",...s}=e;return(0,r.jsx)(n.List,{"data-slot":"tabs-list","data-variant":a,className:(0,l.cn)(o({variant:a}),t),...s})}function d(e){let{className:t,...a}=e;return(0,r.jsx)(n.Trigger,{"data-slot":"tabs-trigger",className:(0,l.cn)("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",t),...a})}function u(e){let{className:t,...a}=e;return(0,r.jsx)(n.Content,{"data-slot":"tabs-content",className:(0,l.cn)("flex-1 outline-none",t),...a})}},59346:(e,t,a)=>{a.d(t,{N:()=>s});var r=a(7911);let s=(0,r.createServerReference)("0093bcdeb3ee6e711ca66667198a40b6620e72b38a",r.callServer,void 0,r.findSourceMapURL,"getTunnelStatusAction")},62952:(e,t,a)=>{a.d(t,{InsertImageButton:()=>z});var r=a(4624),s=a(99356),n=a(69285),l=a(39160),i=a(49411),o=a(85253),c=a(13561),d=a(8096),u=a(43863),m=a(23262),x=a(56221),h=a(15523),p=a(71651),b=a(78825),g=a(22841),v=a(49881),f=a(80192),j=a(43504),y=a(7911);let w=(0,y.createServerReference)("40e42cd64c80530065e20ce320406914e49d86bba4",y.callServer,void 0,y.findSourceMapURL,"generateAction"),N=(0,y.createServerReference)("4099406915f640f56da8a84c92e197bcf705c2c11b",y.callServer,void 0,y.findSourceMapURL,"searchAction"),k=(0,y.createServerReference)("407f2c34207859c58643f0647d9010bd6670680059",y.callServer,void 0,y.findSourceMapURL,"attachAction"),S=(0,y.createServerReference)("4041ec38ee66bdff437fb7ba2b779c0e941175f97b",y.callServer,void 0,y.findSourceMapURL,"uploadAction"),R=["1:1","16:9","9:16","4:3","3:4","21:9"];function C(e){let{rootId:t,open:a,onOpenChange:n,onInsert:y}=e,C=(0,i.c)("app"),[z,A]=(0,s.useState)(""),[T,P]=(0,s.useState)("gemini"),[L,I]=(0,s.useState)("1:1"),[U,_]=(0,s.useState)(!0),[B,E]=(0,s.useState)(null),[K,$]=(0,s.useTransition)(),[M,F]=(0,s.useState)(""),[V,q]=(0,s.useState)("unsplash"),[J,X]=(0,s.useState)([]),[O,D]=(0,s.useTransition)(),[G,Z]=(0,s.useState)(null),[H,W]=(0,s.useState)(!0),[Q,Y]=(0,s.useState)(""),[ee,et]=(0,s.useState)(!0),[ea,er]=(0,s.useTransition)();if((0,s.useEffect)(()=>{if(!a)return;let e=e=>{"Escape"===e.key&&n(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,n]),!a)return null;let es=()=>{M.trim()&&(X([]),D(async()=>{let e=await N({rootId:t,query:M.trim(),provider:V,count:12});if(!e.ok)return void x.oR.error(e.error);X(e.results)}))};return(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:e=>{e.target===e.currentTarget&&n(!1)},children:[(0,r.jsx)("div",{"aria-hidden":!0,className:"absolute inset-0 bg-background/80 backdrop-blur-sm",onClick:()=>n(!1)}),(0,r.jsxs)("div",{className:"relative bg-card border rounded-lg shadow-xl w-full max-w-3xl max-h-[85vh] flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b",children:[(0,r.jsx)(l.A,{className:"h-4 w-4 text-violet-600"}),(0,r.jsx)("h2",{className:"text-sm font-medium flex-1",children:C("images.titleHeader")}),(0,r.jsx)(o.$,{type:"button",size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>n(!1),children:(0,r.jsx)(c.A,{className:"h-4 w-4"})})]}),(0,r.jsxs)(v.tU,{defaultValue:"generate",className:"flex-1 min-h-0 flex flex-col",children:[(0,r.jsxs)(v.j7,{className:"mx-4 mt-3 self-start",children:[(0,r.jsxs)(v.Xi,{value:"generate",children:[(0,r.jsx)(d.A,{className:"mr-1 h-3.5 w-3.5"})," ",C("images.tabGenerate")]}),(0,r.jsxs)(v.Xi,{value:"search",children:[(0,r.jsx)(u.A,{className:"mr-1 h-3.5 w-3.5"})," ",C("images.tabSearch")]}),(0,r.jsxs)(v.Xi,{value:"upload",children:[(0,r.jsx)(m.A,{className:"mr-1 h-3.5 w-3.5"})," ",C("images.tabUpload")]})]}),(0,r.jsxs)(f.F,{className:"flex-1 min-h-0",children:[(0,r.jsxs)(v.av,{value:"generate",className:"px-4 py-4 space-y-3",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(b.J,{htmlFor:"img-prompt",children:C("images.promptLabel")}),(0,r.jsx)(p.T,{id:"img-prompt",value:z,onChange:e=>A(e.target.value),placeholder:C("images.promptPlaceholder"),rows:4})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(b.J,{children:C("images.providerLabel")}),(0,r.jsxs)(g.l6,{value:T,onValueChange:e=>P(e),children:[(0,r.jsx)(g.bq,{children:(0,r.jsx)(g.yv,{})}),(0,r.jsxs)(g.gC,{children:[(0,r.jsx)(g.eb,{value:"gemini",children:"Gemini Nano Banana"}),(0,r.jsx)(g.eb,{value:"codex",children:"Codex $imagegen"})]})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(b.J,{children:C("images.aspectLabel")}),(0,r.jsxs)(g.l6,{value:L,onValueChange:I,children:[(0,r.jsx)(g.bq,{children:(0,r.jsx)(g.yv,{})}),(0,r.jsx)(g.gC,{children:R.map(e=>(0,r.jsx)(g.eb,{value:e,children:e},e))})]})]})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)("input",{type:"checkbox",checked:U,onChange:e=>_(e.target.checked)}),C("images.saveToKb")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(o.$,{type:"button",size:"sm",onClick:()=>{z.trim()&&(E(null),$(async()=>{let e=await w({rootId:t,prompt:z.trim(),provider:T,aspectRatio:L,attachToKb:U});if(!e.ok)return void x.oR.error(e.error);E({url:e.url,markdown:e.markdown,...e.kbRelPath?{kbRelPath:e.kbRelPath}:{}})}))},disabled:K||!z.trim(),children:K?C("images.generating"):C("images.generate")}),K&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:C("images.takesAMinute")})]}),K?(0,r.jsx)(j.E,{className:"h-64 w-full"}):B?(0,r.jsxs)("div",{className:"space-y-2 border rounded p-3",children:[(0,r.jsx)("img",{src:B.url,alt:z,className:"max-h-80 mx-auto rounded"}),(0,r.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,r.jsx)(o.$,{type:"button",size:"sm",variant:"outline",onClick:()=>E(null),children:C("images.again")}),(0,r.jsx)(o.$,{type:"button",size:"sm",onClick:()=>{B&&(null==y||y(B),x.oR.success(B.kbRelPath?C("images.savedToKb",{path:B.kbRelPath}):C("images.ready")),n(!1))},children:C("images.insert")})]})]}):null]}),(0,r.jsxs)(v.av,{value:"search",className:"px-4 py-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(h.p,{value:M,onChange:e=>F(e.target.value),placeholder:C("images.searchPlaceholder"),onKeyDown:e=>{"Enter"===e.key&&es()}}),(0,r.jsxs)(g.l6,{value:V,onValueChange:e=>q(e),children:[(0,r.jsx)(g.bq,{className:"w-36",children:(0,r.jsx)(g.yv,{})}),(0,r.jsxs)(g.gC,{children:[(0,r.jsx)(g.eb,{value:"unsplash",children:"Unsplash"}),(0,r.jsx)(g.eb,{value:"pexels",children:"Pexels"}),(0,r.jsx)(g.eb,{value:"brave",children:C("images.braveWeb")})]})]}),(0,r.jsx)(o.$,{type:"button",size:"sm",onClick:es,disabled:O||!M.trim(),children:C("images.find")})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)("input",{type:"checkbox",checked:H,onChange:e=>W(e.target.checked)}),C("images.saveToKb")]}),O&&0===J.length?(0,r.jsx)("div",{className:"grid grid-cols-3 gap-2",children:Array.from({length:6}).map((e,t)=>(0,r.jsx)(j.E,{className:"h-32 w-full"},t))}):J.length>0?(0,r.jsx)("div",{className:"grid grid-cols-3 gap-2",children:J.map(e=>(0,r.jsxs)("button",{type:"button",disabled:null!==G,onClick:()=>{Z(e.url),D(async()=>{let a=await k({rootId:t,sourceUrl:e.url,alt:M.trim()||"image",attribution:e.attribution,attachToKb:H});if(Z(null),!a.ok)return void x.oR.error(a.error);null==y||y({url:a.url,markdown:a.markdown,...a.kbRelPath?{kbRelPath:a.kbRelPath}:{}}),x.oR.success(a.kbRelPath?C("images.savedToKb",{path:a.kbRelPath}):C("images.savedToProject")),n(!1)})},className:"group relative overflow-hidden rounded border hover:border-violet-500 disabled:opacity-50",title:"".concat(e.attribution.name," \xb7 ").concat(e.provider),children:[(0,r.jsx)("img",{src:e.thumb,alt:"",className:"h-32 w-full object-cover"}),(0,r.jsx)("div",{className:"absolute bottom-0 inset-x-0 px-1.5 py-0.5 text-[10px] bg-black/60 text-white truncate",children:e.attribution.name}),G===e.url&&(0,r.jsx)("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center text-xs text-white",children:C("images.saving")})]},e.url))}):(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:C("images.noKeys")})]}),(0,r.jsxs)(v.av,{value:"upload",className:"px-4 py-4 space-y-3",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(b.J,{htmlFor:"img-alt",children:C("images.altLabel")}),(0,r.jsx)(h.p,{id:"img-alt",value:Q,onChange:e=>Y(e.target.value),placeholder:C("images.altPlaceholder")})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)("input",{type:"checkbox",checked:ee,onChange:e=>et(e.target.checked)}),C("images.saveToKb")]}),(0,r.jsx)(h.p,{type:"file",accept:"image/*",disabled:ea,onChange:e=>{var a;let r=null==(a=e.target.files)?void 0:a[0];r&&er(async()=>{let e=function(e){let t=new Uint8Array(e),a="";for(let e=0;e<t.length;e+=32768){let r=t.subarray(e,e+32768);a+=String.fromCharCode.apply(null,Array.from(r))}return btoa(a)}(await r.arrayBuffer()),a=await S({rootId:t,base64:e,mime:r.type,alt:Q||r.name.replace(/\.[^.]+$/,""),attachToKb:ee});if(!a.ok)return void x.oR.error(a.error);null==y||y({url:a.url,markdown:a.markdown,...a.kbRelPath?{kbRelPath:a.kbRelPath}:{}}),x.oR.success(a.kbRelPath?C("images.savedToKb",{path:a.kbRelPath}):C("images.uploaded")),n(!1)})}}),ea&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:C("images.uploading")})]})]})]})]})]})}function z(e){let{rootId:t,redirectToKb:a=!0}=e,[c,d]=(0,s.useState)(!1),u=(0,n.useRouter)(),m=(0,i.c)("app");return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(o.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(!0),children:[(0,r.jsx)(l.A,{className:"mr-1 h-4 w-4"})," ",m("images.button")]}),(0,r.jsx)(C,{rootId:t,open:c,onOpenChange:d,onInsert:e=>{let{kbRelPath:r}=e;if(a&&r){let e=r.split("/").map(encodeURIComponent).join("/");u.push("/roots/".concat(t,"/kb/").concat(e))}}})]})}},80192:(e,t,a)=>{a.d(t,{F:()=>l});var r=a(4624);a(99356);var s=a(14884),n=a(13506);function l(e){let{className:t,children:a,...l}=e;return(0,r.jsxs)(s.Root,{"data-slot":"scroll-area",className:(0,n.cn)("relative",t),...l,children:[(0,r.jsx)(s.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:a}),(0,r.jsx)(i,{}),(0,r.jsx)(s.Corner,{})]})}function i(e){let{className:t,orientation:a="vertical",...l}=e;return(0,r.jsx)(s.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:a,className:(0,n.cn)("flex touch-none p-px transition-colors select-none","vertical"===a&&"h-full w-2.5 border-l border-l-transparent","horizontal"===a&&"h-2.5 flex-col border-t border-t-transparent",t),...l,children:(0,r.jsx)(s.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},85682:(e,t,a)=>{a.d(t,{ShareButton:()=>p});var r=a(4624),s=a(99356),n=a(30441),l=a(43153),i=a(9598),o=a(13561),c=a(3024),d=a(56221),u=a(49411),m=a(7911);let x=(0,m.createServerReference)("40b6b8864e5ac1cd6b58294a8157fe84e517a9e866",m.callServer,void 0,m.findSourceMapURL,"createShareAction");var h=a(59346);function p(e){let t=(0,u.c)("app"),[a,m]=(0,s.useState)(!1),[p,b]=(0,s.useState)(""),[g,v]=(0,s.useTransition)(),[f,j]=(0,s.useState)(null);return a?f?(0,r.jsxs)("div",{className:"rounded border bg-card p-2 text-xs space-y-1.5 w-full max-w-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-emerald-700",children:[(0,r.jsx)(l.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{className:"font-medium",children:t("share.button.createdTitle")})]}),(0,r.jsx)("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",className:"block font-mono text-[11px] text-violet-700 hover:underline break-all",children:f.url}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(f.url).then(()=>d.oR.success(t("share.button.copied"))),className:"inline-flex items-center gap-1 rounded border px-2 py-0.5 hover:bg-accent",children:[(0,r.jsx)(i.A,{className:"h-3 w-3"}),t("share.button.copy")]}),(0,r.jsx)("button",{type:"button",onClick:()=>{j(null),m(!1),b("")},className:"text-muted-foreground hover:text-foreground",children:t("share.button.done")})]})]}):(0,r.jsxs)("div",{className:"rounded border bg-card p-2 text-xs space-y-1.5 w-full max-w-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(n.A,{className:"h-3.5 w-3.5 text-violet-600"}),(0,r.jsx)("span",{className:"font-medium",children:t("share.button.newLink")}),(0,r.jsx)("button",{type:"button",onClick:()=>m(!1),className:"ml-auto text-muted-foreground hover:text-foreground",children:(0,r.jsx)(o.A,{className:"h-3 w-3"})})]}),(0,r.jsx)("label",{className:"block text-[10px] text-muted-foreground",children:t("share.button.passwordLabel")}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(c.A,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground pointer-events-none"}),(0,r.jsx)("input",{type:"password",value:p,onChange:e=>b(e.target.value),autoFocus:!0,placeholder:t("share.button.passwordPlaceholder"),className:"w-full rounded border bg-background pl-6 pr-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-violet-400"})]}),(0,r.jsx)("button",{type:"button",onClick:()=>{v(async()=>{var a;let r=await (0,h.N)(),s=await x({kind:e.kind,...e.rootId?{rootId:e.rootId}:{},...e.utilityScope?{utilityScope:e.utilityScope}:{},...e.utilityId?{utilityId:e.utilityId}:{},...e.kbRelPath?{kbRelPath:e.kbRelPath}:{},...e.label?{label:e.label}:{},...p.trim()?{password:p.trim()}:{}});if(!s.ok)return void d.oR.error(s.error);let n=null!=(a=r.status.publicUrl)?a:window.location.origin,l=new URL("/share/".concat(s.share.id),n).toString();j({share:s.share,url:l}),navigator.clipboard.writeText(l).catch(()=>null),d.oR.success(r.status.running?t("share.button.created"):t("share.button.createdNoTunnel"))})},disabled:g,className:"w-full rounded bg-violet-600 text-white px-2 py-1 hover:bg-violet-700 disabled:opacity-50 inline-flex items-center justify-center gap-1",children:g?t("share.button.creating"):t("share.button.create")}),(0,r.jsx)("p",{className:"text-[10px] text-muted-foreground",children:t("share.button.footer")})]}):(0,r.jsxs)("button",{type:"button",onClick:()=>m(!0),className:e.iconOnly?"p-1 rounded hover:bg-accent text-muted-foreground hover:text-violet-700":"inline-flex items-center gap-1 rounded border px-2 py-1 text-xs hover:bg-accent",title:t("share.button.title"),children:[(0,r.jsx)(n.A,{className:"h-3.5 w-3.5"}),!e.iconOnly&&t("share.button.label")]})}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4108],{15341:(e,c,t)=>{t.d(c,{o:()=>r});var a=t(7911);let r=(0,a.createServerReference)("002ca983775f846952d739cd14d8a862a6ee012fea",a.callServer,void 0,a.findSourceMapURL,"listOAuthStatusesAction")},29128:(e,c,t)=>{t.d(c,{T:()=>r});var a=t(7911);let r=(0,a.createServerReference)("6066574fc3a28acb357d524a450ed11ad24a41a11c",a.callServer,void 0,a.findSourceMapURL,"beginOAuthAction")},83638:(e,c,t)=>{t.d(c,{J:()=>r});var a=t(7911);let r=(0,a.createServerReference)("406585a535c80be8995904dce662dbd23d19c86dad",a.callServer,void 0,a.findSourceMapURL,"getOAuthClientAction")},94108:(e,c,t)=>{t.d(c,{beginOAuthAction:()=>i.T,getOAuthClientAction:()=>d.J,listOAuthStatusesAction:()=>a.o,saveOAuthClientAction:()=>r.S});var a=t(15341),r=t(95865),d=t(83638),i=t(29128)},95865:(e,c,t)=>{t.d(c,{S:()=>r});var a=t(7911);let r=(0,a.createServerReference)("4023c8fb7b687f55c3361204ea4ccd1357298c7105",a.callServer,void 0,a.findSourceMapURL,"saveOAuthClientAction")}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5771],{15523:(e,r,t)=>{t.d(r,{p:()=>s});var a=t(4624);t(99356);var n=t(13506);function s(e){let{className:r,type:t,...s}=e;return(0,a.jsx)("input",{type:t,"data-slot":"input",className:(0,n.cn)("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30","focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",r),...s})}},25167:(e,r,t)=>{t.d(r,{p:()=>j});var a=t(4624),n=t(99356),s=t(49411),o=t(88365),i=t(72461),l=t(43455),c=t(13561),d=t(60532),u=t(3239),m=t(8096),p=t(94151),x=t(65714),b=t(43153),f=t(95265),h=t(56221),g=t(85253),v=t(15523),w=t(7911);let y=(0,w.createServerReference)("4037725555f6f22c06a98bd35adee6104e7ce89ec8",w.callServer,void 0,w.findSourceMapURL,"summarizeYoutubeAction");var k=t(33648);function j(e){let{source:r,onSendToChat:t,autoSummarizeYoutube:s}=e,[c,d]=(0,n.useState)(null);return(0,a.jsxs)("div",{className:"prose prose-neutral dark:prose-invert max-w-none [&_pre]:bg-muted [&_pre]:rounded-md [&_pre]:p-4 [&_pre]:overflow-x-auto [&_pre]:text-sm [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-foreground [&_:not(pre)>code]:bg-muted [&_:not(pre)>code]:px-1.5 [&_:not(pre)>code]:py-0.5 [&_:not(pre)>code]:rounded [&_:not(pre)>code]:text-[0.9em] [&_code]:font-mono [&_table]:text-sm",children:[(0,a.jsx)(o.oz,{remarkPlugins:[i.A],rehypePlugins:[[l.A,{detect:!0,ignoreMissing:!0}]],components:{a:e=>{let{href:r,children:n,...o}=e,i=r?function(e){try{let r=new URL(e),t=r.hostname.replace(/^www\./,"");if("youtu.be"===t){let e=r.pathname.slice(1).split("/")[0];return e&&/^[A-Za-z0-9_-]{6,}$/.test(e)?e:null}if("youtube.com"===t||"m.youtube.com"===t||"youtube-nocookie.com"===t){if("/watch"===r.pathname){let e=r.searchParams.get("v");return e&&/^[A-Za-z0-9_-]{6,}$/.test(e)?e:null}let e=/^\/(shorts|embed|live|v)\/([^/?#]+)/.exec(r.pathname);if(e&&/^[A-Za-z0-9_-]{6,}$/.test(e[2]))return e[2]}}catch(e){}return null}(r):null;return i&&r?(0,a.jsx)(A,{url:r,videoId:i,autoSummarize:null!=s&&s,...t?{onSendToChat:t}:{}}):(0,a.jsx)("a",{href:r,...o,children:n})},img:e=>{let{src:r,alt:t,title:n}=e;return"string"!=typeof r||0===r.length?null:(0,a.jsx)(N,{src:r,alt:"string"==typeof t?t:"",title:"string"==typeof n?n:void 0,onZoom:e=>d(e)})}},children:r}),c&&(0,a.jsx)(_,{src:c.src,alt:c.alt,onClose:()=>d(null)})]})}function N(e){var r;let{src:t,alt:n,title:o,onZoom:i}=e,l=(0,s.c)("roots");return(0,a.jsx)("img",{src:t,alt:n,title:null!=(r=null!=o?o:n)?r:l("markdown.openFullscreen"),onClick:()=>i({src:t,alt:n}),className:"cursor-zoom-in rounded-md border bg-muted/40 transition hover:opacity-90",loading:"lazy"})}function _(e){let{src:r,alt:t,onClose:o}=e,i=(0,s.c)("roots"),l=(0,n.useCallback)(e=>{"Escape"===e.key&&o()},[o]);return(0,n.useEffect)(()=>{document.addEventListener("keydown",l);let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",l),document.body.style.overflow=e}},[l]),(0,a.jsxs)("div",{className:"fixed inset-0 z-[80] flex items-center justify-center p-6 bg-background/85 backdrop-blur-sm cursor-zoom-out",onClick:o,role:"dialog","aria-label":t||i("markdown.imagePreview"),children:[(0,a.jsx)(g.$,{type:"button",size:"icon",variant:"ghost",className:"absolute top-4 right-4 h-9 w-9 bg-card/80 hover:bg-card",onClick:e=>{e.stopPropagation(),o()},"aria-label":i("markdown.closeAria"),children:(0,a.jsx)(c.A,{className:"h-5 w-5"})}),(0,a.jsx)("img",{src:r,alt:t,className:"max-h-full max-w-full object-contain rounded-lg shadow-2xl",onClick:e=>e.stopPropagation()}),t&&(0,a.jsx)("div",{className:"absolute bottom-6 inset-x-0 mx-auto max-w-3xl px-6 text-center text-sm text-foreground/80 pointer-events-none",children:t})]})}function A(e){let{url:r,videoId:t,onSendToChat:o,autoSummarize:i}=e,l=(0,s.c)("roots"),[w,j]=(0,n.useTransition)(),[N,_]=(0,n.useState)(null),[A,z]=(0,n.useState)(!1),[C,S]=(0,n.useState)(""),[R,$]=(0,n.useState)(!1),E=(0,n.useRef)(!1),L=()=>{_(null),j(async()=>{let e=await y({url:r});if(e.ok){_(e.text),z(!1);return}if(e.needsKey)return void z(!0);h.oR.error(e.error)})};(0,n.useEffect)(()=>{i&&(E.current||(E.current=!0,L()))},[i]);let P=async()=>{if(!C.trim())return void h.oR.error(l("markdown.enterKey"));$(!0);try{let e=await (0,k.A)(C.trim());if(!e.ok)return void h.oR.error(e.error);h.oR.success(l("markdown.geminiKeySaved")),S(""),z(!1),L()}finally{$(!1)}};return(0,a.jsxs)("span",{className:"not-prose my-4 block rounded-lg border bg-card overflow-hidden",children:[(0,a.jsx)("span",{className:"relative block w-full",style:{paddingTop:"56.25%"},children:(0,a.jsx)("iframe",{src:"https://www.youtube-nocookie.com/embed/".concat(t),className:"absolute inset-0 h-full w-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",referrerPolicy:"strict-origin-when-cross-origin",allowFullScreen:!0,title:"YouTube video"})}),(0,a.jsxs)("span",{className:"flex items-center gap-2 p-2 border-t bg-muted/30",children:[(0,a.jsx)(d.A,{className:"h-4 w-4 text-red-600 shrink-0"}),(0,a.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:underline truncate flex-1 min-w-0",children:r}),(0,a.jsxs)(g.$,{type:"button",size:"sm",variant:"outline",onClick:L,disabled:w,className:"gap-1 shrink-0 h-7",children:[w?(0,a.jsx)(u.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(m.A,{className:"h-3 w-3"}),l("markdown.summarize")]})]}),A&&(0,a.jsxs)("span",{className:"block border-t bg-amber-50/60 p-3 space-y-2",children:[(0,a.jsxs)("span",{className:"flex items-center gap-2 text-xs text-amber-900",children:[(0,a.jsx)(p.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{className:"font-medium",children:l("markdown.needsGeminiKey")})]}),(0,a.jsx)("span",{className:"block text-[11px] text-amber-900/80",children:l.rich("markdown.geminiKeyHelp",{link:()=>(0,a.jsx)("a",{href:"https://aistudio.google.com/apikey",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"aistudio.google.com/apikey"}),path:()=>(0,a.jsx)("code",{className:"font-mono",children:"~/.reflex/api-keys/gemini.json"}),modelsList:()=>(0,a.jsx)("code",{className:"font-mono",children:"models.list"})})}),(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)(v.p,{type:"password",value:C,onChange:e=>S(e.target.value),placeholder:"AIza…",className:"font-mono text-xs h-8 flex-1",disabled:R}),(0,a.jsxs)(g.$,{type:"button",size:"sm",onClick:()=>void P(),disabled:R||!C.trim(),className:"h-8 gap-1",children:[R?(0,a.jsx)(u.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(x.A,{className:"h-3 w-3"}),l("markdown.saveAndContinue")]}),(0,a.jsx)(g.$,{type:"button",size:"icon",variant:"ghost",onClick:()=>z(!1),className:"h-8 w-8",children:(0,a.jsx)(c.A,{className:"h-3.5 w-3.5"})})]})]}),N&&(0,a.jsxs)("span",{className:"block border-t p-3 space-y-2",children:[(0,a.jsxs)("span",{className:"flex items-center gap-2 text-[11px] uppercase tracking-wider text-muted-foreground",children:[(0,a.jsx)(b.A,{className:"h-3 w-3 text-emerald-600"}),"Gemini summary",(0,a.jsxs)(g.$,{type:"button",size:"sm",variant:"ghost",onClick:L,className:"ml-auto h-6 text-[10px] gap-1",disabled:w,children:[w?(0,a.jsx)(u.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(m.A,{className:"h-3 w-3"}),l("markdown.redo")]}),o&&(0,a.jsxs)(g.$,{type:"button",size:"sm",variant:"outline",onClick:()=>o(N,r),className:"h-6 text-[10px] gap-1",children:[(0,a.jsx)(f.A,{className:"h-3 w-3"}),l("markdown.toChat")]})]}),(0,a.jsx)("span",{className:"block",children:(0,a.jsx)("span",{className:"block text-sm whitespace-pre-wrap leading-relaxed",children:N})})]})]})}},28310:(e,r,t)=>{t.d(r,{E:()=>l});var a=t(4624);t(99356);var n=t(60621),s=t(50362),o=t(13506);let i=(0,n.F)("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function l(e){let{className:r,variant:t="default",asChild:n=!1,...l}=e,c=n?s.bL:"span";return(0,a.jsx)(c,{"data-slot":"badge","data-variant":t,className:(0,o.cn)(i({variant:t}),r),...l})}},33648:(e,r,t)=>{t.d(r,{A:()=>n});var a=t(7911);let n=(0,a.createServerReference)("409a5325a639958f74488179b2f0699516eecc8ed9",a.callServer,void 0,a.findSourceMapURL,"saveGeminiKeyAction")},78825:(e,r,t)=>{t.d(r,{J:()=>o});var a=t(4624);t(99356);var n=t(33976),s=t(13506);function o(e){let{className:r,...t}=e;return(0,a.jsx)(n.Root,{"data-slot":"label",className:(0,s.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",r),...t})}},91074:(e,r,t)=>{t.d(r,{Separator:()=>o});var a=t(4624);t(99356);var n=t(44188),s=t(13506);function o(e){let{className:r,orientation:t="horizontal",decorative:o=!0,...i}=e;return(0,a.jsx)(n.b,{"data-slot":"separator",decorative:o,orientation:t,className:(0,s.cn)("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",r),...i})}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7124],{8096:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(45804).A)("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]])},13561:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(45804).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},39783:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(45804).A)("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]])},47124:(e,t,r)=>{r.d(t,{UtilityIframe:()=>w});var s=r(4624),l=r(99356),a=r(79182),n=r(49411),i=r(39783),o=r(13561),c=r(8096),u=r(3239),d=r(95265),p=r(54400),h=r.n(p),m=r(56221),x=r(7911);let f=(0,x.createServerReference)("40cac4054756c0321f1d8c0b1cb6cb88ee2ec0632e",x.callServer,void 0,x.findSourceMapURL,"getOrCreateUtilityHelperTopicAction"),y=(0,x.createServerReference)("602e86dd9ecc1ddbfa965d85d7384bf21d56812996",x.callServer,void 0,x.findSourceMapURL,"loadHelperTranscriptAction");function v(e){let{scope:t,utilityId:r,utilityName:p,rootId:x,requestSnapshot:v,onClose:w}=e,b=(0,n.c)("app"),[j,k]=(0,l.useState)(null),[N,S]=(0,l.useState)([]),[A,M]=(0,l.useState)(""),[T,E]=(0,l.useState)(null),[R,C]=(0,l.useTransition)(),[H,L]=(0,l.useState)(!1),O=(0,l.useRef)(null),I=(0,l.useRef)(null),P=(0,l.useRef)(""),[q,z]=(0,l.useState)("");(0,l.useEffect)(()=>{if(!x)return void E(b("utilities.helper.projectOnly"));let e=!1;return(async()=>{let t=await f({rootId:x,utilityId:r,utilityName:null!=p?p:r});if(e)return;if(!t.ok)return E(t.error);k(t.topicId);let s=await y(x,t.topicId);!e&&s.ok&&S(s.messages)})(),()=>{e=!0}},[x,r,p]),(0,l.useEffect)(()=>{if(!x||!j)return;let e=new EventSource("/api/roots/".concat(x,"/chat/").concat(j,"/stream?since=").concat(Number.MAX_SAFE_INTEGER));return I.current=e,e.addEventListener("event",e=>{try{let t=JSON.parse(e.data);"assistant-delta"===t.type&&"string"==typeof t.text?(P.current+=t.text,z(P.current),L(!0)):"turn-end"===t.type||"agent-end"===t.type?(P.current="",z(""),L(!1),(async()=>{let e=await y(x,j);e.ok&&S(e.messages)})()):t.type}catch(e){}}),e.onerror=()=>{},()=>{e.close(),I.current=null}},[x,j]),(0,l.useEffect)(()=>{let e=O.current;e&&(e.scrollTop=e.scrollHeight)},[N,q]);let _=()=>{let e=A.trim();e&&x&&j&&(M(""),S(t=>[...t,{role:"user",text:e,ts:new Date().toISOString()}]),C(async()=>{let t;try{t=await Promise.race([v(),new Promise(e=>setTimeout(()=>e(void 0),600))])}catch(e){}let r=void 0!==t?function(e,t){let r;try{r="string"==typeof t?t:JSON.stringify(t,null,2)}catch(e){r=String(t)}return r.length>4e3&&(r=r.slice(0,4e3)+"\n…[truncated]"),["[Mini-app context]",r,"[/context]\n",e].join("\n")}(e,t):e;try{let e=await fetch("/api/roots/".concat(x,"/chat/").concat(j,"/send"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:r})});if(!e.ok){var s;let t=await e.json().catch(()=>({}));m.oR.error(null!=(s=t.error)?s:"HTTP ".concat(e.status))}}catch(e){m.oR.error(String(e))}}))};return(0,s.jsxs)("aside",{className:"flex h-full flex-col border-l bg-card",children:[(0,s.jsxs)("header",{className:"border-b px-3 py-2 flex items-center gap-2",children:[(0,s.jsx)(a.A,{className:"h-3.5 w-3.5 text-violet-600"}),(0,s.jsx)("span",{className:"text-sm font-medium",children:b("utilities.helper.title")}),(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground ml-1",children:b("utilities.helper.hint")}),x&&j&&(0,s.jsx)(h(),{href:"/roots/".concat(x,"/chat/").concat(j),className:"ml-auto p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground",title:b("utilities.helper.openFull"),children:(0,s.jsx)(i.A,{className:"h-3.5 w-3.5"})}),w&&(0,s.jsx)("button",{type:"button",onClick:w,className:"p-1 rounded hover:bg-accent "+(x&&j?"":"ml-auto"),title:b("utilities.helper.hide"),children:(0,s.jsx)(o.A,{className:"h-3.5 w-3.5"})})]}),(0,s.jsxs)("div",{ref:O,className:"flex-1 overflow-y-auto px-3 py-2 space-y-2 text-sm",children:[T&&(0,s.jsx)("p",{className:"text-xs text-red-600",children:T}),!T&&0===N.length&&!q&&(0,s.jsxs)("div",{className:"text-xs text-muted-foreground flex items-start gap-2",children:[(0,s.jsx)(c.A,{className:"h-3 w-3 mt-0.5 text-violet-600 shrink-0"}),(0,s.jsx)("span",{children:b("utilities.helper.welcome")})]}),N.map((e,t)=>(0,s.jsx)(g,{role:e.role,text:e.text},t)),H&&q&&(0,s.jsx)(g,{role:"assistant",text:q,streaming:!0}),R&&!H&&(0,s.jsxs)("div",{className:"mr-6 rounded-md bg-muted/40 px-2 py-1.5 text-xs text-muted-foreground inline-flex items-center gap-2",children:[(0,s.jsx)(u.A,{className:"h-3 w-3 animate-spin"}),b("utilities.helper.thinking")]})]}),(0,s.jsxs)("div",{className:"border-t px-3 py-2 flex items-end gap-1.5",children:[(0,s.jsx)("textarea",{value:A,onChange:e=>M(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),_())},rows:1,placeholder:b("utilities.helper.placeholder"),disabled:R||!!T||!j,className:"flex-1 resize-none rounded border bg-background px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-violet-400 max-h-24"}),(0,s.jsx)("button",{type:"button",onClick:_,disabled:R||!A.trim()||!!T||!j,className:"inline-flex items-center justify-center rounded bg-violet-600 px-2 py-1 text-white hover:bg-violet-700 disabled:opacity-50",children:R?(0,s.jsx)(u.A,{className:"h-3 w-3 animate-spin"}):(0,s.jsx)(d.A,{className:"h-3 w-3"})})]})]})}function g(e){let{role:t,text:r,streaming:l}=e,a=(0,n.c)("app"),i=r;return("user"===t&&(i=i.replace(/^\s*\[Mini-app context\][\s\S]*?\[\/context\]\s*/,"").trim()),i.trim())?(0,s.jsxs)("div",{className:"user"===t?"ml-6 rounded-md bg-violet-50 dark:bg-violet-950/30 px-2 py-1.5":"mr-6 rounded-md bg-muted/40 px-2 py-1.5 whitespace-pre-wrap",children:[(0,s.jsxs)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-0.5",children:[a("user"===t?"utilities.helper.you":"assistant"===t?"utilities.helper.reflex":"utilities.helper.system"),l&&(0,s.jsx)("span",{className:"ml-1 text-violet-600",children:"●"})]}),i]}):null}function w(e){let{scope:t,id:r,rootId:i,className:o,title:c,agentChat:u,utilityName:d}=e,p=(0,n.c)("app"),h=(0,l.useRef)(null),m=(0,l.useRef)(null),[x,f]=(0,l.useState)(!0),y=i?"?rootId=".concat(encodeURIComponent(i)):"",g="/api/utilities/".concat(t,"/").concat(r,"/iframe").concat(y),w="/api/utilities/".concat(t,"/").concat(r,"/host").concat(y);(0,l.useEffect)(()=>{let e=async e=>{var t,r,s,l,a,n;let i=e.data;if(!i||e.source!==(null==(t=h.current)?void 0:t.contentWindow))return;if("snapshot-payload"===i.type){let e=m.current;e&&(clearTimeout(e.timer),m.current=null,e.resolve(i.snapshot));return}if("host-rpc"!==i.type)return;let o=i.id;try{let e=await fetch(w,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:i.method,args:i.args})}),t=await e.json();null==(s=h.current)||null==(r=s.contentWindow)||r.postMessage(t.ok?{type:"host-rpc-result",id:o,ok:!0,result:t.result}:{type:"host-rpc-result",id:o,ok:!1,error:null!=(l=t.error)?l:"HTTP ".concat(e.status)},"*")}catch(e){null==(n=h.current)||null==(a=n.contentWindow)||a.postMessage({type:"host-rpc-result",id:o,ok:!1,error:e instanceof Error?e.message:String(e)},"*")}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[w]);let b=(0,s.jsx)("iframe",{ref:h,src:g,sandbox:"allow-scripts allow-forms allow-same-origin",className:null!=o?o:"h-full w-full border-0 bg-white",title:null!=c?c:"utility-".concat(r)});return u?(0,s.jsxs)("div",{className:"flex h-full w-full",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0 relative",children:[b,!x&&(0,s.jsxs)("button",{type:"button",onClick:()=>f(!0),className:"absolute right-3 bottom-3 inline-flex items-center gap-1 rounded-full bg-violet-600 px-3 py-1.5 text-xs text-white shadow-lg hover:bg-violet-700",title:p("utilities.iframe.openHelper"),children:[(0,s.jsx)(a.A,{className:"h-3.5 w-3.5"}),p("utilities.iframe.helper")]})]}),x&&(0,s.jsx)("div",{className:"w-80 shrink-0",children:(0,s.jsx)(v,{scope:t,utilityId:r,...d?{utilityName:d}:{},...i?{rootId:i}:{},requestSnapshot:()=>{var e;let t=null==(e=h.current)?void 0:e.contentWindow;return t?(m.current&&(clearTimeout(m.current.timer),m.current.resolve(void 0),m.current=null),new Promise(e=>{let r=setTimeout(()=>{var t;(null==(t=m.current)?void 0:t.resolve)===e&&(m.current=null,e(void 0))},500);m.current={resolve:e,timer:r};try{t.postMessage({type:"request-snapshot"},"*")}catch(t){clearTimeout(r),m.current=null,e(void 0)}})):Promise.resolve(void 0)},onClose:()=>f(!1)})})]}):b}},79182:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(45804).A)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},95265:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(45804).A)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7529],{13506:(e,t,r)=>{r.d(t,{cn:()=>i});var a=r(47989),n=r(55701);function i(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,n.QP)((0,a.$)(t))}},63514:(e,t,r)=>{r.d(t,{$d:()=>i,S9:()=>l,Zi:()=>n});var a=r(99356);let n={rootsChanged:"reflex:roots-changed",topicsChanged:e=>"reflex:topics-changed:".concat(e),kbChanged:e=>"reflex:kb-changed:".concat(e)};function i(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}function l(e,t){(0,a.useEffect)(()=>{let r=e=>t(e.detail);return window.addEventListener(e,r),()=>window.removeEventListener(e,r)},[e,t])}},63602:(e,t,r)=>{r.d(t,{E:()=>l});var a=r(4624),n=r(49411),i=r(8096);function l(e){let{label:t,headerRight:r,children:l}=e,s=(0,n.c)("roots"),o=null!=t?t:s("commandBarFrame.label");return(0,a.jsx)("div",{className:"border-t bg-background",children:(0,a.jsx)("div",{className:"mx-auto max-w-3xl px-6 py-5",children:(0,a.jsx)("div",{className:"reflex-gradient rounded-2xl p-[2px] shadow-[0_8px_40px_-12px_oklch(0.55_0.2_290/0.45)]",children:(0,a.jsxs)("div",{className:"rounded-[14px] bg-background/85 backdrop-blur-xl px-5 py-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,a.jsx)("span",{className:"reflex-gradient inline-flex h-6 w-6 items-center justify-center rounded-full text-white shadow-sm",children:(0,a.jsx)(i.A,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("span",{className:"text-[11px] uppercase tracking-[0.18em] text-muted-foreground",children:o}),r&&(0,a.jsx)("span",{className:"ml-auto flex items-center gap-1",children:r})]}),l]})})})})}},71651:(e,t,r)=>{r.d(t,{T:()=>i});var a=r(4624);r(99356);var n=r(13506);function i(e){let{className:t,...r}=e;return(0,a.jsx)("textarea",{"data-slot":"textarea",className:(0,n.cn)("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40",t),...r})}},85253:(e,t,r)=>{r.d(t,{$:()=>o});var a=r(4624);r(99356);var n=r(60621),i=r(50362),l=r(13506);let s=(0,n.F)("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function o(e){let{className:t,variant:r="default",size:n="default",asChild:o=!1,...c}=e,d=o?i.bL:"button";return(0,a.jsx)(d,{"data-slot":"button","data-variant":r,"data-size":n,className:(0,l.cn)(s({variant:r,size:n,className:t})),...c})}},88190:(e,t,r)=>{r.d(t,{L:()=>U});var a=r(4624),n=r(99356),i=r(49411),l=r(86515),s=r(41234),o=r(71789),c=r(53732),d=r(3606),u=r(31108),m=r(8096),p=r(46972),f=r(16213),g=r(59145),h=r(27474),x=r(39624),v=r(3239),b=r(9721),k=r(84860),w=r(7293),y=r(49623),j=r(64417),N=r(13561),A=r(69285),S=r(56221),C=r(85253),R=r(71651),D=r(13506),F=r(7911);let E=(0,F.createServerReference)("60f0e8ff4fb43e3ceae454333e5d534782f59e0d65",F.callServer,void 0,F.findSourceMapURL,"searchMentionsAction"),T=[{id:"plan",trigger:"plan",label:"/plan",description:"Show the plan first — Reflex lays out the steps and waits for approval.",kind:"agent-mode",usage:"/plan <task>",icon:"ListChecks"},{id:"goal",trigger:"goal",label:"/goal",description:"Set a goal — Reflex will work toward it on its own, without reminders.",kind:"agent-mode",usage:"/goal <what to achieve>",icon:"Target"},{id:"research",trigger:"research",label:"/research",description:"Deep research on a topic — web search + summary with sources.",kind:"agent-mode",usage:"/research <topic>",icon:"Telescope"},{id:"widget",trigger:"widget",label:"/widget",description:"Create a card on the space dashboard.",kind:"agent-mode",usage:"/widget <what to show>",icon:"LayoutGrid"},{id:"workflow",trigger:"workflow",label:"/workflow",description:"Build a recipe — linear step-based automation for the task.",kind:"agent-mode",usage:"/workflow <what to automate>",icon:"Workflow"},{id:"distill",trigger:"distill",label:"/distill",description:"Pull a URL into the KB — extract key facts, action items, and links to related notes.",kind:"agent-mode",usage:"/distill <url> [focus]",icon:"BookOpenCheck"},{id:"practice",trigger:"practice",label:"/practice",description:"Roleplay a tough conversation — Reflex plays the counterpart and coaches you between turns.",kind:"agent-mode",usage:"/practice <scenario>",icon:"MessagesSquare"},{id:"reflect",trigger:"reflect",label:"/reflect",description:"Daily check-in — three questions adapted to your recent entries, saved as a journal note.",kind:"agent-mode",usage:"/reflect",allowEmpty:!0,icon:"Sunrise"},{id:"remember",trigger:"remember",label:"/remember",description:"Save a note — straight into memory, no AI involved.",kind:"direct",usage:"/remember <what to remember>",icon:"BookmarkPlus"},{id:"mcp",trigger:"mcp",label:"/mcp",description:"Connect an external service (setup wizard opens in chat).",kind:"agent-mode",usage:"/mcp <what you need>",icon:"PackagePlus"},{id:"skill",trigger:"skill",label:"/skill",description:"Attach a role — a ready-made instruction set for this conversation.",kind:"agent-mode",usage:"/skill <role-id> [prompt]",icon:"Sparkles"},{id:"delete-topic",trigger:"delete-topic",label:"/delete-topic",description:"Delete this conversation (with confirmation).",kind:"direct",usage:"/delete-topic",requiresConfirm:!0,allowEmpty:!0,icon:"Trash2"},{id:"clear-project",trigger:"clear-project",label:"/clear-project",description:"DANGER: clear the space — all conversations, cards, memory. Double confirmation.",kind:"direct",usage:"/clear-project",requiresConfirm:!0,allowEmpty:!0,icon:"AlertOctagon"},{id:"util",trigger:"util",label:"/util",description:"Open a mini-app (by partial name or from the list).",kind:"direct",usage:"/util <partial name or id>",allowEmpty:!0,icon:"Boxes"},{id:"help",trigger:"help",label:"/help",description:"List available commands.",kind:"direct",usage:"/help",allowEmpty:!0,icon:"HelpCircle"}],I=(0,F.createServerReference)("408f4e2e0c079d2b392430a49e6430b2f4ca530308",F.callServer,void 0,F.findSourceMapURL,"listCommandArgsAction"),z=(0,F.createServerReference)("60fb3ba0913aea3d1913b2099c8bf59c80d6eae13d",F.callServer,void 0,F.findSourceMapURL,"rememberAction"),P=(0,F.createServerReference)("60372ec405c43eecb40d861c32ed53f02cc4824579",F.callServer,void 0,F.findSourceMapURL,"deleteCurrentTopicCommand"),L=(0,F.createServerReference)("609f182b2994f7240d6e02438da1d78e9a2b8098b8",F.callServer,void 0,F.findSourceMapURL,"openUtilityAction"),M=(0,F.createServerReference)("4019af5f3a53d4620d0c3fa8968e218b4a20f83e3e",F.callServer,void 0,F.findSourceMapURL,"clearProjectAction");var _=r(63514);let B={ListChecks:l.A,Target:s.A,Telescope:o.A,LayoutGrid:c.A,BookmarkPlus:d.A,PackagePlus:u.A,Sparkles:m.A,Trash2:p.A,AlertOctagon:f.A,HelpCircle:g.A,Workflow:h.A,Boxes:x.A};function U(e){let{rootId:t,topicId:r,placeholder:l,submitLabel:s,pendingLabel:o,SubmitIcon:c,disabled:d,onSubmit:u,active:m,onStop:p,clarifyLabel:f,stopLabel:g}=e,h=(0,i.c)("roots"),x=null!=f?f:h("chatInputForm.clarifyLabel"),w=null!=g?g:h("chatInputForm.stopLabel"),y=(0,A.useRouter)(),[j,N]=(0,n.useState)(""),[F,z]=(0,n.useState)([]),[P,L]=(0,n.useState)(!1),[M,_]=(0,n.useState)(!1),[B,U]=(0,n.useState)(!1),W=(0,n.useRef)(null),Z=(0,n.useRef)(null),[G,Q]=(0,n.useState)(null),[V,J]=(0,n.useState)([]),[X,Y]=(0,n.useState)(0),[ee,et]=(0,n.useState)(!1),er=(0,n.useRef)(0),[ea,en]=(0,n.useState)(null),[ei,el]=(0,n.useState)(null),es=(0,n.useRef)(0),eo=(0,n.useCallback)(()=>{let e=W.current;e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,240)+"px")},[]);(0,n.useEffect)(()=>{eo()},[j,eo]);let ec=(0,n.useCallback)((e,r)=>{let a=r;for(;a>0;){let t=e[a-1];if("@"===t){a-=1;break}if(/\s/.test(t)){a=-1;break}a-=1}if(a<0||"@"!==e[a]||a>0&&!/\s/.test(e[a-1])){Q(null),J([]);return}let n=e.slice(a+1,r);Q({start:a,end:r}),Y(0),et(!0);let i=++er.current;(async()=>{let e=await E(t,n);er.current===i&&(et(!1),J(e.ok?e.items:[]))})()},[t]),ed=(0,n.useCallback)(()=>{Q(null),J([]),er.current++},[]),eu=(0,n.useCallback)((e,r)=>{if(!e.startsWith("/")){en(null),el(null);return}let a=e.indexOf(" ");if(a<0){el(null);let t=e.slice(1).toLowerCase(),r=T.filter(e=>e.trigger.startsWith(t)||e.label.toLowerCase().includes(t)||e.description.toLowerCase().includes(t));en(r.length?{items:r,index:0}:null);return}en(null);let n=e.slice(1,a),i=T.find(e=>e.trigger===n);if(!i)return void el(null);let l=a+1,s=r>=l?r:e.length;if(e.slice(s).indexOf(" ")>=0)return void el(null);let o=e.slice(l,s),c=++es.current;el(e=>({cmd:i,items:(null==e?void 0:e.cmd.id)===i.id?e.items:[],index:0,start:l,end:s,loading:!0})),(async()=>{let e=await I({commandId:i.id,query:o,rootId:t});if(es.current===c){if(!e.ok||!e.supported||0===e.items.length)return el(null);el({cmd:i,items:e.items,index:0,start:l,end:s,loading:!1})}})()},[t]),em=(0,n.useCallback)(()=>{en(null),el(null)},[]),ep=(0,n.useCallback)(e=>{let t=W.current;el(r=>{if(!r)return null;let a=j.slice(0,r.start),n=j.slice(r.end),i="".concat(e.value," ");N(a+i+n);let l=a.length+i.length;return requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(l,l))}),null})},[j]),ef=(0,n.useCallback)(e=>{let t=W.current,r="/".concat(e.trigger).concat(e.allowEmpty&&"direct"===e.kind?"":" ");N(r),en(null),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(r.length,r.length))})},[]),eg=(0,n.useCallback)(e=>{let t=W.current;if(!t||!G)return;let r=j.slice(0,G.start),a=j.slice(G.end),n="@".concat(e.relPath," ");N(r+n+a),ed();let i=r.length+n.length;requestAnimationFrame(()=>{t.focus(),t.setSelectionRange(i,i)})},[j,G,ed]),eh=(0,n.useCallback)(async e=>{if(0!==e.length){L(!0);try{let a=new FormData;for(let t of e)a.append("files",t);let n=await fetch("/api/roots/".concat(t,"/attachments"),{method:"POST",body:a});if(!n.ok){var r;let e=await n.json().catch(()=>({}));S.oR.error(null!=(r=e.error)?r:h("chatInputForm.uploadFailed",{status:n.status}));return}let i=await n.json();z(e=>[...e,...i.files])}catch(e){S.oR.error(e instanceof Error?e.message:String(e))}finally{L(!1)}}},[t]),ex=j.trim().length>0||F.length>0,ev=m&&p?ex?"clarify":"stop":"send",eb=(0,n.useCallback)(async()=>{if(M)return;if("stop"===ev){if(!p)return;_(!0);try{await p()}finally{_(!1)}return}let e=j.trim();if(!e&&0===F.length||d&&"send"===ev)return;let a=function(e){var t,r,a;let n=e.trim();if(!n.startsWith("/"))return null;let i=/^\/([a-z][a-z0-9-]*)(?:\s+([\s\S]*))?$/.exec(n);if(!i)return null;let l=(r=i[1],null!=(a=T.find(e=>e.trigger===r))?a:null);return l?{def:l,payload:(null!=(t=i[2])?t:"").trim()}:null}(e);if(a&&"direct"===a.def.kind){_(!0);try{await $({cmd:a.def,payload:a.payload,rootId:t,topicId:r,router:y,t:h}),N("")}finally{_(!1)}return}_(!0);try{"clarify"===ev&&p&&await p(),await u({message:e,attachments:F})&&(N(""),z([]))}finally{_(!1)}},[j,F,M,d,ev,p,u,t,r,y,h]),ek=!M&&!P&&("stop"===ev||ex&&(!d||"clarify"===ev));return(0,a.jsxs)("form",{onSubmit:e=>{e.preventDefault(),eb()},onDragEnter:e=>{Array.from(e.dataTransfer.types).includes("Files")&&(e.preventDefault(),U(!0))},onDragOver:e=>{Array.from(e.dataTransfer.types).includes("Files")&&(e.preventDefault(),U(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||U(!1)},onDrop:e=>{e.preventDefault(),U(!1);let t=Array.from(e.dataTransfer.files);t.length>0&&eh(t)},className:(0,D.cn)("space-y-2 rounded-md transition-colors",B&&"ring-2 ring-ring/60 bg-accent/40"),children:[F.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:F.map((e,t)=>(0,a.jsx)(H,{attachment:e,onRemove:()=>z(t=>t.filter(t=>t!==e))},e.absPath+t))}),(0,a.jsxs)("div",{className:"flex items-end gap-2",children:[(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)(R.T,{ref:W,value:j,onChange:e=>{N(e.target.value),ec(e.target.value,e.target.selectionStart),eu(e.target.value,e.target.selectionStart)},onKeyUp:e=>{let t=e.currentTarget;ec(t.value,t.selectionStart),eu(t.value,t.selectionStart)},onClick:e=>{let t=e.currentTarget;ec(t.value,t.selectionStart),eu(t.value,t.selectionStart)},onBlur:()=>{setTimeout(()=>{ed(),em()},150)},onKeyDown:e=>{if(ea){if("ArrowDown"===e.key){e.preventDefault(),en(e=>e?{...e,index:Math.min(e.items.length-1,e.index+1)}:null);return}if("ArrowUp"===e.key){e.preventDefault(),en(e=>e?{...e,index:Math.max(0,e.index-1)}:null);return}if("Tab"===e.key){e.preventDefault();let t=ea.items[ea.index];t&&ef(t);return}if("Escape"===e.key){e.preventDefault(),em();return}}if(ei&&ei.items.length>0){if("ArrowDown"===e.key){e.preventDefault(),el(e=>e?{...e,index:Math.min(e.items.length-1,e.index+1)}:null);return}if("ArrowUp"===e.key){e.preventDefault(),el(e=>e?{...e,index:Math.max(0,e.index-1)}:null);return}if("Tab"===e.key){e.preventDefault();let t=ei.items[ei.index];t&&ep(t);return}if("Escape"===e.key){e.preventDefault(),el(null);return}}if(G&&V.length>0){if("ArrowDown"===e.key){e.preventDefault(),Y(e=>Math.min(V.length-1,e+1));return}if("ArrowUp"===e.key){e.preventDefault(),Y(e=>Math.max(0,e-1));return}if("Enter"===e.key||"Tab"===e.key){e.preventDefault();let t=V[X];t&&eg(t);return}if("Escape"===e.key){e.preventDefault(),ed();return}}"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),eb())},onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length>0&&(e.preventDefault(),eh(t))},placeholder:l,rows:1,disabled:d||M,className:"resize-none min-h-[44px] max-h-60 text-base bg-background/70 border-transparent focus-visible:border-ring py-2.5 w-full"}),G&&(0,a.jsx)(q,{items:V,index:X,loading:ee,onPick:eg,onHover:e=>Y(e)}),ea&&!G&&(0,a.jsx)(O,{items:ea.items,index:ea.index,onPick:ef,onHover:e=>en(t=>t?{...t,index:e}:null),topicAvailable:!!r}),ei&&!G&&!ea&&(0,a.jsx)(K,{cmd:ei.cmd,items:ei.items,index:ei.index,onPick:ep,onHover:e=>el(t=>t?{...t,index:e}:null)})]}),(0,a.jsx)("input",{ref:Z,type:"file",multiple:!0,className:"hidden",onChange:e=>{var t;let r=Array.from(null!=(t=e.target.files)?t:[]);r.length>0&&eh(r),e.target.value=""}}),(0,a.jsx)(C.$,{type:"button",size:"icon",variant:"ghost",onClick:()=>{var e;return null==(e=Z.current)?void 0:e.click()},disabled:P||M||d,title:h("chatInputForm.attachTitle"),className:"h-11 w-11 shrink-0",children:P?(0,a.jsx)(v.A,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(b.A,{className:"h-4 w-4"})}),(0,a.jsx)(C.$,{type:"submit",size:"lg",disabled:!ek,variant:"stop"===ev?"destructive":"default",className:"h-11 px-6 shadow-md shrink-0",children:M?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(v.A,{className:"mr-2 h-4 w-4 animate-spin"}),o]}):"stop"===ev?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(k.A,{className:"mr-2 h-4 w-4",fill:"currentColor"}),w]}):"clarify"===ev?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c,{className:"mr-2 h-4 w-4"}),x]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c,{className:"mr-2 h-4 w-4"}),s]})})]}),(0,a.jsx)("div",{className:"text-[10px] text-muted-foreground",children:h("chatInputForm.helperRow")})]})}async function $(e){var t,r,a;let{cmd:n,payload:i,rootId:l,topicId:s,router:o,t:c}=e;if("help"===n.id){let e=T.map(e=>"• ".concat(e.label," — ").concat(e.description));S.oR.info(c("chatInputForm.availableCommands",{list:e.join("\n")}),{duration:12e3});return}if("remember"===n.id){if(!i)return void S.oR.error(c("chatInputForm.rememberEmpty"));let e=await z(l,i);return void(e.ok?(S.oR.success(null!=(t=e.message)?t:c("chatInputForm.savedToKb")),(0,_.$d)(_.Zi.kbChanged(l))):S.oR.error(e.error))}if("delete-topic"===n.id){if(!s)return void S.oR.error(c("chatInputForm.topicOnlyCommand"));if(!confirm(c("chatInputForm.deleteTopicConfirm")))return;let e=await P(l,s);return void(e.ok?(S.oR.success(null!=(r=e.message)?r:c("chatInputForm.deleted")),(0,_.$d)(_.Zi.topicsChanged(l)),e.redirectTo&&o.push(e.redirectTo)):S.oR.error(e.error))}if("util"===n.id){let e=await L(l,i);if(!e.ok)return void S.oR.error(e.error);if("redirect"===e.kind)return void o.push(e.url);let t=e.items.slice(0,8).map(e=>"• ".concat(e.name," (").concat(e.scope,"/").concat(e.id,")")).join("\n");return void S.oR.message(c("chatInputForm.multipleMatches",{list:t}),{duration:12e3})}if("clear-project"===n.id){if(!confirm(c("chatInputForm.clearProjectConfirm")))return;let e=prompt(c("chatInputForm.clearProjectPrompt"));if((null==e?void 0:e.trim().toLowerCase())!==c("chatInputForm.clearProjectPhrase"))return void S.oR.message(c("chatInputForm.confirmFailed"));let t=await M(l);return void(t.ok?(S.oR.success(null!=(a=t.message)?a:c("chatInputForm.projectCleared")),(0,_.$d)(_.Zi.topicsChanged(l)),(0,_.$d)(_.Zi.kbChanged(l)),t.redirectTo&&o.push(t.redirectTo)):S.oR.error(t.error))}S.oR.error(c("chatInputForm.unknownCommand",{label:n.label}))}function O(e){let{items:t,index:r,onPick:n,onHover:l,topicAvailable:s}=e,o=(0,i.c)("roots");return(0,a.jsxs)("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50 max-h-80 overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-lg",children:[(0,a.jsx)("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground border-b",children:o("chatInputForm.commandsPaletteHeader")}),(0,a.jsx)("ul",{children:t.map((e,t)=>{var i;let c=null!=(i=B[e.icon])?i:m.A,d="delete-topic"===e.id&&!s;return(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),d||n(e)},onMouseEnter:()=>l(t),disabled:d,className:(0,D.cn)("w-full flex items-start gap-2 px-3 py-2 text-left",t===r?"bg-accent":"hover:bg-accent/60",d&&"opacity-40 cursor-not-allowed"),children:[(0,a.jsx)(c,{className:(0,D.cn)("h-3.5 w-3.5 mt-0.5 shrink-0","direct"===e.kind?"text-amber-600":"text-violet-600")}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-baseline gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"font-mono text-xs font-medium",children:e.label}),"direct"===e.kind&&(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-amber-700",children:o("chatInputForm.directAction")}),e.requiresConfirm&&(0,a.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-destructive",children:o("chatInputForm.withConfirm")})]}),(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground leading-snug mt-0.5",children:e.description}),(0,a.jsx)("p",{className:"text-[10px] text-muted-foreground/80 font-mono mt-0.5",children:e.usage})]})]})},e.id)})})]})}function q(e){let{items:t,index:r,loading:n,onPick:l,onHover:s}=e,o=(0,i.c)("roots");return(0,a.jsx)("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50 max-h-72 overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-lg",children:n&&0===t.length?(0,a.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground flex items-center gap-2",children:[(0,a.jsx)(v.A,{className:"h-3 w-3 animate-spin"})," ",o("chatInputForm.mentionSearching")]}):0===t.length?(0,a.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground italic",children:o("chatInputForm.mentionNothing")}):(0,a.jsx)("ul",{children:t.map((e,t)=>{let n="kb"===e.kind?w.A:y.A;return(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),l(e)},onMouseEnter:()=>s(t),className:(0,D.cn)("w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left",t===r?"bg-accent":"hover:bg-accent/60"),children:[(0,a.jsx)(n,{className:(0,D.cn)("h-3.5 w-3.5 shrink-0","kb"===e.kind?"text-primary":"text-muted-foreground")}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"truncate font-mono text-xs",children:e.relPath}),e.parent&&(0,a.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:e.parent})]}),(0,a.jsx)("span",{className:(0,D.cn)("text-[10px] uppercase tracking-wider shrink-0","kb"===e.kind?"text-primary":"text-muted-foreground"),children:e.kind})]})},e.absPath)})})})}function H(e){var t;let{attachment:r,onRemove:n}=e,i=r.mime.startsWith("image/")?j.A:y.A;return(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-1 text-[11px] max-w-[18rem]",children:[(0,a.jsx)(i,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"truncate",title:r.name,children:r.name}),(0,a.jsx)("span",{className:"text-muted-foreground",children:(t=r.size)<1024?"".concat(t," B"):t<1048576?"".concat((t/1024).toFixed(1)," KB"):"".concat((t/1048576).toFixed(1)," MB")}),(0,a.jsx)("button",{type:"button",onClick:n,className:"ml-0.5 text-muted-foreground hover:text-foreground",children:(0,a.jsx)(N.A,{className:"h-3 w-3"})})]})}function K(e){var t;let{cmd:r,items:n,index:i,onPick:l,onHover:s}=e,o=null!=(t=B[r.icon])?t:m.A;return(0,a.jsxs)("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50 max-h-80 overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-lg",children:[(0,a.jsxs)("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground border-b flex items-center gap-2",children:[(0,a.jsx)(o,{className:"h-3 w-3"}),(0,a.jsxs)("span",{children:[r.label," \xb7 ",r.usage.replace(/^\/\S+\s*/,"")]})]}),(0,a.jsx)("ul",{children:n.map((e,t)=>(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),l(e)},onMouseEnter:()=>s(t),className:(0,D.cn)("w-full flex items-start gap-2 px-3 py-2 text-left",t===i?"bg-accent":"hover:bg-accent/60"),children:[(0,a.jsx)(m.A,{className:"h-3.5 w-3.5 mt-0.5 shrink-0 text-violet-600"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-baseline gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"font-medium text-sm",children:e.label}),(0,a.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground",children:e.value})]}),e.description&&(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground leading-snug mt-0.5 line-clamp-2",children:e.description})]})]})},e.value))})]})}}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{13506:(e,t,s)=>{"use strict";s.d(t,{cn:()=>n});var a=s(47989),r=s(55701);function n(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,r.QP)((0,a.$)(t))}},17570:(e,t,s)=>{"use strict";s.d(t,{L:()=>r});var a=s(7911);let r=(0,a.createServerReference)("60de31e31af2e83152afdcf3e3f6f0aaa40b52a1f7",a.callServer,void 0,a.findSourceMapURL,"deleteTopicAction")},17848:(e,t,s)=>{Promise.resolve().then(s.bind(s,74417)),Promise.resolve().then(s.t.bind(s,60290,23)),Promise.resolve().then(s.bind(s,43450)),Promise.resolve().then(s.bind(s,52713))},43450:(e,t,s)=>{"use strict";s.d(t,{Toaster:()=>u});var a=s(4624),r=s(58726),n=s(42795),l=s(85924),i=s(69259),c=s(3239),o=s(41085),d=s(56221);let u=e=>{let{...t}=e,{theme:s="system"}=(0,o.D)();return(0,a.jsx)(d.l$,{theme:s,className:"toaster group",icons:{success:(0,a.jsx)(r.A,{className:"size-4"}),info:(0,a.jsx)(n.A,{className:"size-4"}),warning:(0,a.jsx)(l.A,{className:"size-4"}),error:(0,a.jsx)(i.A,{className:"size-4"}),loading:(0,a.jsx)(c.A,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...t})}},60290:()=>{},63514:(e,t,s)=>{"use strict";s.d(t,{$d:()=>n,S9:()=>l,Zi:()=>r});var a=s(99356);let r={rootsChanged:"reflex:roots-changed",topicsChanged:e=>"reflex:topics-changed:".concat(e),kbChanged:e=>"reflex:kb-changed:".concat(e)};function n(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}function l(e,t){(0,a.useEffect)(()=>{let s=e=>t(e.detail);return window.addEventListener(e,s),()=>window.removeEventListener(e,s)},[e,t])}},74417:(e,t,s)=>{"use strict";s.d(t,{AppSidebar:()=>T});var a=s(4624),r=s(99356),n=s(54400),l=s.n(n),i=s(69285),c=s(56221),o=s(49411),d=s(8096),u=s(72754),x=s(70762),h=s(69709),m=s(69205),p=s(9923),f=s(49623),g=s(3239),v=s(79182),b=s(42146),j=s(46972),N=s(17570),w=s(63514),y=s(80192),k=s(91074),A=s(85253),S=s(7911);let z=(0,S.createServerReference)("40848a54a3e35f11838a18f469862df84e127ea8c1",S.callServer,void 0,S.findSourceMapURL,"loadKbSectionsAction"),C=(0,S.createServerReference)("40711f3755e00a9752557e3c9f9fed41d2e47bc0f5",S.callServer,void 0,S.findSourceMapURL,"loadTopicsAction"),R=(0,S.createServerReference)("00626d76604665c1e29a9aa68386e76e47721272cd",S.callServer,void 0,S.findSourceMapURL,"listRootsAction"),E=(0,S.createServerReference)("40d2591fc8f50b541a522e730ef821045364adc736",S.callServer,void 0,S.findSourceMapURL,"listAgentsAction");var I=s(39624),L=s(53296),_=s(50988),P=s(63622);function T(e){let{initialRoots:t}=e,s=(0,i.usePathname)(),n=(0,o.c)("app"),[c,h]=(0,r.useState)(t),m=(0,r.useCallback)(async()=>{let e=await R();e.ok&&h(e.entries)},[]);return((0,w.S9)(w.Zi.rootsChanged,m),(null==s?void 0:s.startsWith("/share/"))||"/share"===s)?null:(0,a.jsxs)("aside",{className:"w-72 shrink-0 border-r bg-muted/30 flex flex-col",children:[(0,a.jsxs)("div",{className:"px-4 py-4 flex items-center gap-2 border-b",children:[(0,a.jsx)("span",{className:"reflex-gradient inline-flex h-7 w-7 items-center justify-center rounded-lg text-white shadow-sm",children:(0,a.jsx)(d.A,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:"leading-tight",children:[(0,a.jsx)(l(),{href:"/",className:"text-sm font-semibold tracking-tight hover:underline",children:"Reflex"}),(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"knowledge base"})]})]}),(0,a.jsx)(y.F,{className:"flex-1",children:(0,a.jsxs)("nav",{className:"px-2 pt-3 pb-6",children:[(0,a.jsx)("div",{className:"px-2 mb-1 text-[10px] uppercase tracking-wider text-muted-foreground",children:n("sidebar.spaces")}),0===c.length?(0,a.jsx)("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:n("sidebar.empty")}):(0,a.jsx)("ul",{className:"space-y-0.5",children:c.map(e=>{var t;return(0,a.jsx)($,{root:e,active:null!=(t=null==s?void 0:s.startsWith("/roots/".concat(e.id)))&&t},e.id)})}),(0,a.jsx)("div",{className:"mt-2 px-2",children:(0,a.jsx)(A.$,{asChild:!0,variant:"ghost",size:"sm",className:"h-7 w-full justify-start text-xs",children:(0,a.jsxs)(l(),{href:"/roots/new",children:[(0,a.jsx)(u.A,{className:"mr-1 h-3.5 w-3.5"})," ",n("sidebar.addSpace")]})})})]})}),(0,a.jsx)(k.Separator,{}),(0,a.jsxs)("div",{className:"px-2 py-2 space-y-0.5",children:[(0,a.jsx)(A.$,{asChild:!0,variant:"/utilities"===s||(null==s?void 0:s.startsWith("/utilities/"))?"secondary":"ghost",size:"sm",className:"w-full justify-start",children:(0,a.jsxs)(l(),{href:"/utilities",children:[(0,a.jsx)(I.A,{className:"mr-2 h-4 w-4"})," ",n("sidebar.utilities")]})}),(0,a.jsx)(A.$,{asChild:!0,variant:"/audit"===s?"secondary":"ghost",size:"sm",className:"w-full justify-start",children:(0,a.jsxs)(l(),{href:"/audit",children:[(0,a.jsx)(L.A,{className:"mr-2 h-4 w-4"})," ",n("sidebar.audit")]})}),(0,a.jsx)(A.$,{asChild:!0,variant:"/settings"===s?"secondary":"ghost",size:"sm",className:"w-full justify-start",children:(0,a.jsxs)(l(),{href:"/settings",children:[(0,a.jsx)(x.A,{className:"mr-2 h-4 w-4"})," Settings"]})})]})]})}function $(e){let{root:t,active:s}=e,n=(0,o.c)("app"),[c,d]=(0,r.useState)(s),[u,x]=(0,r.useState)(!1),[b,j]=(0,r.useState)(!1),[N,y]=(0,r.useState)(!1),[k,A]=(0,r.useState)(null),[S,R]=(0,r.useState)(null),[I,L]=(0,r.useState)(null),[P,T]=(0,r.useState)(!1),[$,U]=(0,r.useState)(!1),[Z,W]=(0,r.useState)(!1),O=(0,i.usePathname)();(0,r.useEffect)(()=>{s&&d(!0)},[s]);let V=(0,r.useCallback)(async()=>{T(!0);let e=await z(t.id);T(!1),e.ok?A(e.sections):A([])},[t.id]),K=(0,r.useCallback)(async()=>{U(!0);let e=await C(t.id);U(!1),e.ok?R(e.topics):R([])},[t.id]),Q=(0,r.useCallback)(async()=>{W(!0);let e=await E({rootId:t.id});W(!1),e.ok?L(e.agents):L([])},[t.id]);(0,w.S9)(w.Zi.kbChanged(t.id),()=>{u?V():A(null)}),(0,w.S9)(w.Zi.topicsChanged(t.id),()=>{b?K():R(null),N?Q():L(null)}),(0,r.useEffect)(()=>{if(!N)return;let e=setInterval(()=>{Q()},3e3);return()=>clearInterval(e)},[N,Q]);let q=async()=>{let e=!u;x(e),e&&null===k&&!P&&await V()},G=async()=>{let e=!b;j(e),e&&null===S&&!$&&await K()},H=async()=>{let e=!N;y(e),e&&null===I&&!Z&&await Q()},J=function(e){var t;let s=e.split("/").filter(Boolean);return null!=(t=s[s.length-1])?t:e}(t.path);return(0,a.jsxs)("li",{children:[(0,a.jsxs)("div",{className:"flex items-center group",children:[(0,a.jsx)("button",{type:"button",onClick:()=>d(e=>!e),className:"h-6 w-6 flex items-center justify-center text-muted-foreground hover:text-foreground shrink-0","aria-label":n(c?"sidebar.collapse":"sidebar.expand"),children:c?(0,a.jsx)(h.A,{className:"h-3.5 w-3.5"}):(0,a.jsx)(m.A,{className:"h-3.5 w-3.5"})}),(0,a.jsxs)(l(),{href:"/roots/".concat(t.id),className:"flex-1 min-w-0 flex items-center gap-2 px-2 py-1 rounded-md text-sm hover:bg-accent ".concat(s?"bg-accent":""),children:[(0,a.jsx)(p.A,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:J})]})]}),c&&(0,a.jsxs)("ul",{className:"ml-5 mt-0.5 space-y-0.5 border-l pl-1",children:[(0,a.jsxs)("li",{children:[(0,a.jsxs)("button",{type:"button",onClick:q,className:"w-full flex items-center gap-1 px-2 py-1 rounded-md text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[u?(0,a.jsx)(h.A,{className:"h-3 w-3 shrink-0"}):(0,a.jsx)(m.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)(f.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:n("sidebar.kb")}),P&&(0,a.jsx)(g.A,{className:"ml-auto h-3 w-3 animate-spin shrink-0"})]}),u&&null!==k&&(0,a.jsx)(F,{rootId:t.id,sections:k,pathname:O})]}),(0,a.jsxs)("li",{children:[(0,a.jsxs)("button",{type:"button",onClick:G,className:"w-full flex items-center gap-1 px-2 py-1 rounded-md text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[b?(0,a.jsx)(h.A,{className:"h-3 w-3 shrink-0"}):(0,a.jsx)(m.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)(v.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:n("sidebar.topics")}),$&&(0,a.jsx)(g.A,{className:"ml-auto h-3 w-3 animate-spin shrink-0"}),null!==S&&(0,a.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:S.length})]}),b&&null!==S&&(0,a.jsx)(B,{rootId:t.id,topics:S,pathname:O})]}),(0,a.jsxs)("li",{children:[(0,a.jsxs)("button",{type:"button",onClick:H,className:"w-full flex items-center gap-1 px-2 py-1 rounded-md text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[N?(0,a.jsx)(h.A,{className:"h-3 w-3 shrink-0"}):(0,a.jsx)(m.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)(_.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:n("sidebar.agents")}),Z&&(0,a.jsx)(g.A,{className:"ml-auto h-3 w-3 animate-spin shrink-0"}),null!==I&&!Z&&(0,a.jsxs)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:[I.filter(e=>D(e.status)).length,"/",I.length]})]}),N&&null!==I&&(0,a.jsx)(M,{agents:I,pathname:O})]})]})]})}function M(e){var t,s;let{agents:r,pathname:n}=e;if(0===r.length)return(0,a.jsx)(U,{});let l=new Map;for(let e of r){let s=e.parentId,a=null!=(t=l.get(s))?t:[];a.push(e),l.set(s,a)}let i=null!=(s=l.get(void 0))?s:[];return(0,a.jsx)("ul",{className:"ml-4 mt-0.5 space-y-0.5 border-l pl-1",children:i.map(e=>(0,a.jsx)(Z,{agent:e,byParent:l,pathname:n,depth:0},e.id))})}function U(){let e=(0,o.c)("app");return(0,a.jsx)("div",{className:"ml-4 px-3 py-1 text-[11px] italic text-muted-foreground",children:e("sidebar.noAgents")})}function Z(e){var t;let{agent:s,byParent:r,pathname:n,depth:i}=e,c=null!=(t=r.get(s.id))?t:[],o="/agents/".concat(s.id),d=n===o;return(0,a.jsxs)("li",{children:[(0,a.jsxs)(l(),{href:o,className:"flex items-center gap-1 px-2 py-1 text-[12px] rounded hover:bg-accent ".concat(d?"bg-accent":""),style:{paddingLeft:8*i+4},children:[D(s.status)?(0,a.jsx)(P.A,{className:"h-3 w-3 text-emerald-600 shrink-0 animate-pulse"}):(0,a.jsx)(_.A,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"truncate flex-1",children:s.label}),(0,a.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground shrink-0",title:"".concat(s.harness," \xb7 ").concat(s.model),children:"claude-code"===s.harness?"claude":"ollama"===s.harness?"ollama":"codex"})]}),c.length>0&&(0,a.jsx)("ul",{className:"space-y-0.5",children:c.map(e=>(0,a.jsx)(Z,{agent:e,byParent:r,pathname:n,depth:i+1},e.id))})]})}function D(e){return"starting"===e||"running"===e}function F(e){let{rootId:t,sections:s,pathname:r}=e;return 0===s.length?(0,a.jsx)(W,{}):(0,a.jsx)("ul",{className:"ml-4 mt-0.5 space-y-0.5 border-l pl-1",children:s.map(e=>e.isDir?(0,a.jsx)(O,{rootId:t,section:e,pathname:r},e.rel):(0,a.jsx)("li",{children:(0,a.jsx)(V,{rootId:t,section:e,pathname:r})},e.rel))})}function W(){let e=(0,o.c)("app");return(0,a.jsx)("div",{className:"px-3 py-1 text-[11px] italic text-muted-foreground",children:e("sidebar.kbEmpty")})}function O(e){let{rootId:t,section:s,pathname:n}=e,[l,i]=(0,r.useState)(!1);return(0,a.jsxs)("li",{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("button",{type:"button",onClick:()=>i(e=>!e),className:"h-5 w-5 flex items-center justify-center text-muted-foreground hover:text-foreground shrink-0",children:l?(0,a.jsx)(h.A,{className:"h-3 w-3"}):(0,a.jsx)(m.A,{className:"h-3 w-3"})}),(0,a.jsx)(b.A,{className:"h-3 w-3 text-muted-foreground shrink-0 mr-1"}),(0,a.jsx)("span",{className:"text-[12px] flex-1 truncate",children:s.label})]}),l&&s.children&&(0,a.jsx)("ul",{className:"ml-4 space-y-0.5 border-l pl-1",children:s.children.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)(V,{rootId:t,section:e,pathname:n})},e.rel))})]})}function V(e){let{rootId:t,section:s,pathname:r}=e;if(!s.fileRel)return null;let n=s.fileRel.split("/").map(encodeURIComponent).join("/"),i="/roots/".concat(t,"/kb/").concat(n),c=r===i;return(0,a.jsxs)(l(),{href:i,className:"flex items-center gap-1 px-2 py-1 text-[12px] rounded hover:bg-accent ".concat(c?"bg-accent":""),children:[(0,a.jsx)(f.A,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:s.label})]})}function B(e){let{rootId:t,topics:s,pathname:r}=e;return 0===s.length?(0,a.jsx)(K,{}):(0,a.jsx)("ul",{className:"ml-4 mt-0.5 space-y-0.5 border-l pl-1",children:s.map(e=>(0,a.jsx)(Q,{rootId:t,topic:e,pathname:r},e.id))})}function K(){let e=(0,o.c)("app");return(0,a.jsx)("div",{className:"ml-4 px-3 py-1 text-[11px] italic text-muted-foreground",children:e("sidebar.noTopics")})}function Q(e){let{rootId:t,topic:s,pathname:n}=e,d=(0,o.c)("app"),u="/roots/".concat(t,"/chat/").concat(s.id),x=n===u,[h,m]=(0,r.useTransition)(),p=(0,i.useRouter)();return(0,a.jsx)("li",{className:"group/topic",children:(0,a.jsxs)(l(),{href:u,className:"flex items-center gap-1 px-2 py-1 text-[12px] rounded hover:bg-accent ".concat(x?"bg-accent":""),children:[(0,a.jsx)(v.A,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"truncate flex-1 min-w-0",children:s.title}),(0,a.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),confirm(d("sidebar.deleteTopicConfirm",{title:s.title}))&&m(async()=>{let e=await (0,N.L)(t,s.id);if(!e.ok){var a;c.oR.error(null!=(a=e.error)?a:d("sidebar.deleteFailed"));return}c.oR.success(d("sidebar.topicDeleted")),(0,w.$d)(w.Zi.topicsChanged(t)),x&&p.push("/roots/".concat(t))})},disabled:h,"aria-label":d("sidebar.deleteTopic"),title:d("sidebar.deleteTopic"),className:"opacity-0 group-hover/topic:opacity-100 transition-opacity p-0.5 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive shrink-0",children:h?(0,a.jsx)(g.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(j.A,{className:"h-3 w-3"})})]})})}},80192:(e,t,s)=>{"use strict";s.d(t,{F:()=>l});var a=s(4624);s(99356);var r=s(14884),n=s(13506);function l(e){let{className:t,children:s,...l}=e;return(0,a.jsxs)(r.Root,{"data-slot":"scroll-area",className:(0,n.cn)("relative",t),...l,children:[(0,a.jsx)(r.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:s}),(0,a.jsx)(i,{}),(0,a.jsx)(r.Corner,{})]})}function i(e){let{className:t,orientation:s="vertical",...l}=e;return(0,a.jsx)(r.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:s,className:(0,n.cn)("flex touch-none p-px transition-colors select-none","vertical"===s&&"h-full w-2.5 border-l border-l-transparent","horizontal"===s&&"h-2.5 flex-col border-t border-t-transparent",t),...l,children:(0,a.jsx)(r.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},85253:(e,t,s)=>{"use strict";s.d(t,{$:()=>c});var a=s(4624);s(99356);var r=s(60621),n=s(50362),l=s(13506);let i=(0,r.F)("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function c(e){let{className:t,variant:s="default",size:r="default",asChild:c=!1,...o}=e,d=c?n.bL:"button";return(0,a.jsx)(d,{"data-slot":"button","data-variant":s,"data-size":r,className:(0,l.cn)(i({variant:s,size:r,className:t})),...o})}},91074:(e,t,s)=>{"use strict";s.d(t,{Separator:()=>l});var a=s(4624);s(99356);var r=s(44188),n=s(13506);function l(e){let{className:t,orientation:s="horizontal",decorative:l=!0,...i}=e;return(0,a.jsx)(r.b,{"data-slot":"separator",decorative:l,orientation:s,className:(0,n.cn)("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...i})}}},e=>{e.O(0,[497,4400,1217,9411,5097,6445,4933,146,7358],()=>e(e.s=17848)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{3823:(e,r,n)=>{"use strict";n.d(r,{h:()=>s});var i=n(7911);let s=(0,i.createServerReference)("704bacabaf84b2f058cf0aa17c123bfbb29185c855",i.callServer,void 0,i.findSourceMapURL,"generateTopicTitleAction")},9355:(e,r,n)=>{"use strict";n.d(r,{g:()=>s});var i=n(7911);let s=(0,i.createServerReference)("78973e33b20590eeb273db3bd81f8b711d142c9473",i.callServer,void 0,i.findSourceMapURL,"startTopicAction")},63392:(e,r,n)=>{Promise.resolve().then(n.bind(n,89061)),Promise.resolve().then(n.bind(n,96253)),Promise.resolve().then(n.bind(n,28050)),Promise.resolve().then(n.bind(n,94904)),Promise.resolve().then(n.bind(n,13270)),Promise.resolve().then(n.bind(n,99730)),Promise.resolve().then(n.bind(n,89146)),Promise.resolve().then(n.bind(n,19078)),Promise.resolve().then(n.bind(n,67854)),Promise.resolve().then(n.bind(n,69050)),Promise.resolve().then(n.bind(n,63739)),Promise.resolve().then(n.bind(n,33976)),Promise.resolve().then(n.bind(n,12537)),Promise.resolve().then(n.bind(n,97485)),Promise.resolve().then(n.bind(n,41923)),Promise.resolve().then(n.bind(n,73868)),Promise.resolve().then(n.bind(n,53511)),Promise.resolve().then(n.bind(n,2018)),Promise.resolve().then(n.bind(n,18487)),Promise.resolve().then(n.bind(n,98346)),Promise.resolve().then(n.bind(n,14884)),Promise.resolve().then(n.bind(n,85314)),Promise.resolve().then(n.bind(n,17280)),Promise.resolve().then(n.bind(n,8855)),Promise.resolve().then(n.bind(n,86631)),Promise.resolve().then(n.bind(n,2604)),Promise.resolve().then(n.bind(n,27237)),Promise.resolve().then(n.bind(n,49455)),Promise.resolve().then(n.bind(n,39211)),Promise.resolve().then(n.bind(n,56360)),Promise.resolve().then(n.t.bind(n,54400,23))},89061:(e,r,n)=>{"use strict";n.d(r,{UniversalChatBar:()=>v});var i=n(4624),s=n(99356),t=n(69285),o=n(69709),l=n(95265),a=n(56221),d=n(49411),c=n(9355),b=n(3823),m=n(88190),u=n(63602),h=n(63514);function v(e){var r,n,v;let{spaces:p}=e,f=(0,t.useRouter)(),x=(0,d.c)("app"),[P,g]=(0,s.useState)(null!=(n=null==(r=p[0])?void 0:r.id)?n:""),[w,j]=(0,s.useState)(!1),[,k]=(0,s.useTransition)(),N=(0,s.useRef)(null),S=null!=(v=p.find(e=>e.id===P))?v:p[0];if((0,s.useEffect)(()=>{if(!w)return;let e=e=>{var r;(null==(r=N.current)?void 0:r.contains(e.target))||j(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[w]),!S)return(0,i.jsx)("div",{className:"border-t bg-background",children:(0,i.jsxs)("div",{className:"mx-auto max-w-3xl px-6 py-5 text-center text-xs text-muted-foreground",children:[x("universal.createFirstSpace1")," ",(0,i.jsx)("a",{href:"/onboarding?force=1",className:"underline",children:x("universal.wizardLink")})," ",x("universal.or")," ",(0,i.jsx)("a",{href:"/roots/new",className:"underline",children:x("universal.manualLink")}),"."]})});let L=p.length>1?(0,i.jsxs)("div",{className:"relative",ref:N,children:[(0,i.jsxs)("button",{type:"button",onClick:()=>j(e=>!e),className:"inline-flex items-center gap-1 rounded-full border bg-card/80 px-2 py-0.5 text-[10px] font-medium hover:bg-accent normal-case tracking-normal",title:x("universal.pickSpace"),children:[(0,i.jsx)("span",{className:"text-muted-foreground",children:x("universal.in")}),(0,i.jsx)("span",{children:S.label}),(0,i.jsx)(o.A,{className:"h-3 w-3 text-muted-foreground"})]}),w&&(0,i.jsx)("ul",{className:"absolute bottom-full right-0 mb-1 min-w-[200px] max-h-60 overflow-y-auto rounded-md border bg-popover shadow-lg z-40 py-1",children:p.map(e=>(0,i.jsx)("li",{children:(0,i.jsx)("button",{type:"button",onClick:()=>{g(e.id),j(!1)},className:"block w-full text-left px-3 py-1.5 text-sm hover:bg-accent "+(e.id===S.id?"font-semibold":""),children:e.label})},e.id))})]}):null,y=async e=>await new Promise(r=>{k(async()=>{let n=await (0,c.g)(S.id,e.message,e.attachments);if(!n.ok){a.oR.error(n.error),r(!1);return}(0,h.$d)(h.Zi.topicsChanged(S.id)),e.message.trim()&&(0,b.h)(S.id,n.topicId,e.message).then(e=>{e.ok&&(0,h.$d)(h.Zi.topicsChanged(S.id))}),f.push("/roots/".concat(S.id,"/chat/").concat(n.topicId)),r(!0)})});return(0,i.jsx)(u.E,{label:x("universal.label"),...L?{headerRight:L}:{},children:(0,i.jsx)(m.L,{rootId:S.id,placeholder:x("universal.placeholder"),submitLabel:x("universal.submitLabel"),pendingLabel:x("universal.pendingLabel"),SubmitIcon:l.A,onSubmit:y},S.id)})}}},e=>{e.O(0,[4400,1217,9411,3335,5097,3954,7529,4933,146,7358],()=>e(e.s=63392)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[310],{3989:(e,t,s)=>{"use strict";s.d(t,{ChatView:()=>em});var r=s(4624),n=s(99356),a=s(49411),i=s(23506),o=s(1646),l=s(3239),d=s(95265),c=s(8096),m=s(56221),u=s(28310),p=s(25167),x=s(63602),h=s(88190),g=s(63514),f=s(69709),v=s(69205),b=s(49623),j=s(51587),w=s(76479),N=s(53296),y=s(43863),k=s(9923),C=s(94494),A=s(13506);function S(e){let{name:t,input:s,result:i,pending:o}=e,d=(0,a.c)("roots"),[c,m]=(0,n.useState)(!1),u=function(e){let t=e.toLowerCase();return"read"===t?b.A:"write"===t||"edit"===t?j.A:"bash"===t||"shell"===t?w.A:"glob"===t?N.A:"grep"===t||"search"===t?y.A:"ls"===t?k.A:C.A}(t),p=function(e,t){if(!t||"object"!=typeof t)return"";let s=e.toLowerCase();if(("read"===s||"write"===s||"edit"===s)&&"string"==typeof t.file_path)return t.file_path;if("bash"===s&&"string"==typeof t.command)return t.command.length>80?t.command.slice(0,77)+"…":t.command;if("glob"===s&&"string"==typeof t.pattern)return t.pattern;if("grep"===s){let e=[];return"string"==typeof t.pattern&&e.push(t.pattern),"string"==typeof t.path&&e.push("in ".concat(t.path)),e.join(" ")}return"ls"===s&&"string"==typeof t.path?t.path:""}(t,s);return(0,r.jsxs)("div",{className:(0,A.cn)("rounded-lg border my-2 text-sm overflow-hidden",(null==i?void 0:i.isError)?"border-destructive/40 bg-destructive/5":"bg-muted/30"),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>m(e=>!e),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-accent/40 transition-colors",children:[c?(0,r.jsx)(f.A,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}):(0,r.jsx)(v.A,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,r.jsx)(u,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,r.jsx)("span",{className:"font-mono text-xs font-medium",children:t}),p&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:p}),(0,r.jsx)("span",{className:"ml-auto text-[10px] uppercase tracking-wider text-muted-foreground shrink-0",children:o?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)(l.A,{className:"h-3 w-3 animate-spin"})," ",d("toolCall.working")]}):(null==i?void 0:i.isError)?(0,r.jsx)("span",{className:"text-destructive",children:d("toolCall.error")}):i?(0,r.jsx)("span",{children:d("toolCall.done")}):(0,r.jsx)("span",{children:"—"})})]}),c&&(0,r.jsxs)("div",{className:"px-3 pb-3 space-y-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:"input"}),(0,r.jsx)("pre",{className:"text-[11px] font-mono bg-background/60 rounded p-2 overflow-x-auto whitespace-pre-wrap break-all",children:function(e){try{return JSON.stringify(e,null,2)}catch(t){return String(e)}}(s)})]}),i&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:"output"}),(0,r.jsx)("pre",{className:(0,A.cn)("text-[11px] font-mono rounded p-2 overflow-x-auto whitespace-pre-wrap max-h-64 overflow-y-auto",i.isError?"bg-destructive/10 text-destructive-foreground":"bg-background/60"),children:i.content||"(empty)"})]})]})]})}var I=s(3024),P=s(86295),T=s(13561),q=s(43153),R=s(59145),B=s(35687),z=s(39783),E=s(65714),O=s(85253),$=s(15523),L=s(78825),D=s(66459);function U(e){let{perm:t}=e,s=(0,a.c)("roots"),[i,o]=(0,n.useTransition)(),d=t.resolved,c=(e,s)=>{o(async()=>{let r=await fetch("/api/agents/".concat(t.agentId,"/respond"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:"permission",requestId:t.requestId,decision:e,...s?{scope:s}:{},...t.tool?{tool:t.tool}:{}})});if(!r.ok){var n;let e=await r.json().catch(()=>({}));m.oR.error(null!=(n=e.error)?n:"HTTP ".concat(r.status))}})};return(0,r.jsx)("div",{className:(0,A.cn)("rounded-lg border-2 my-2 p-4 reflex-gradient",d&&"opacity-60"),children:(0,r.jsxs)("div",{className:"rounded-md bg-background/95 backdrop-blur p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-2 text-[11px] uppercase tracking-wider text-muted-foreground",children:[(0,r.jsx)(I.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:s("permissionCard.title")}),t.tool&&(0,r.jsx)("span",{className:"font-mono normal-case tracking-normal",children:t.tool}),(0,r.jsx)("span",{className:"ml-auto font-mono normal-case tracking-normal",children:t.requestId})]}),t.description&&(0,r.jsx)("p",{className:"text-sm mb-2",children:t.description}),void 0!==t.input&&(0,r.jsx)("pre",{className:"text-[11px] font-mono bg-muted/40 rounded p-2 overflow-x-auto whitespace-pre-wrap max-h-40 overflow-y-auto mb-3",children:K(t.input)}),d?(0,r.jsx)("div",{className:"flex items-center gap-2 text-sm",children:"allow"===d.decision?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(P.A,{className:"h-4 w-4 text-emerald-600"}),(0,r.jsx)("span",{children:s("permissionCard.allowed",{scope:d.scope?" (".concat(d.scope,")"):""})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(T.A,{className:"h-4 w-4 text-destructive"}),(0,r.jsx)("span",{children:s("permissionCard.denied")})]})}):(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsxs)(O.$,{size:"sm",onClick:()=>c("allow","once"),disabled:i,children:[i?(0,r.jsx)(l.A,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(q.A,{className:"mr-2 h-3.5 w-3.5"}),s("permissionCard.allow")]}),(0,r.jsxs)(O.$,{size:"sm",variant:"secondary",onClick:()=>c("allow","always"),disabled:i,children:[(0,r.jsx)(P.A,{className:"mr-2 h-3.5 w-3.5"}),s("permissionCard.allowAlways")]}),(0,r.jsxs)(O.$,{size:"sm",variant:"destructive",onClick:()=>c("deny"),disabled:i,children:[(0,r.jsx)(T.A,{className:"mr-2 h-3.5 w-3.5"}),s("permissionCard.deny")]})]})]})})}function H(e){var t;let{question:s}=e,i=(0,a.c)("roots"),[o,d]=(0,n.useState)(""),[c,u]=(0,n.useState)(new Set),[p,x]=(0,n.useTransition)(),h=s.resolved,g=s.options&&s.options.length>0?s.options:(null!=(t=s.choices)?t:[]).map(e=>({label:e})),f=e=>{e.trim()&&x(async()=>{let t=await fetch("/api/agents/".concat(s.agentId,"/respond"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:"answer",questionId:s.questionId,answer:e.trim()})});if(t.ok)d(""),u(new Set);else{var r;let e=await t.json().catch(()=>({}));m.oR.error(null!=(r=e.error)?r:"HTTP ".concat(t.status))}})};return(0,r.jsx)("div",{className:(0,A.cn)("rounded-lg border-2 my-2 p-4 reflex-gradient",h&&"opacity-60"),children:(0,r.jsxs)("div",{className:"rounded-md bg-background/95 backdrop-blur p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-2 text-[11px] uppercase tracking-wider text-muted-foreground flex-wrap",children:[(0,r.jsx)(R.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:i("questionCard.title")}),s.header&&(0,r.jsx)("span",{className:"rounded bg-violet-100 dark:bg-violet-950/60 text-violet-900 dark:text-violet-200 px-1.5 py-0.5 text-[10px] uppercase font-mono",children:s.header}),s.multiSelect&&(0,r.jsx)("span",{className:"text-[10px] normal-case tracking-normal italic",children:i("questionCard.multiSelect")}),(0,r.jsx)("span",{className:"ml-auto font-mono normal-case tracking-normal",children:s.questionId})]}),(0,r.jsx)("p",{className:"text-sm font-medium mb-3",children:s.prompt}),h?(0,r.jsxs)("p",{className:"text-sm text-muted-foreground",children:[i("questionCard.answerLabel")," ",(0,r.jsx)("span",{className:"text-foreground",children:function(e){if(!e.startsWith("["))return e;try{let t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e))return t.join(", ")}catch(e){}return e}(h.answer)})]}):(0,r.jsxs)("div",{className:"space-y-2",children:[g.length>0&&(0,r.jsx)("div",{className:"flex flex-col gap-1.5",children:g.map(e=>{let t=c.has(e.label);return s.multiSelect?(0,r.jsxs)("button",{type:"button",onClick:()=>{var t;return t=e.label,void u(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},disabled:p,className:(0,A.cn)("flex items-start gap-2 text-left rounded-md border p-2.5 transition",t?"border-violet-500 bg-violet-50 dark:bg-violet-950/30":"border-input hover:bg-accent/40",p&&"opacity-50"),children:[(0,r.jsx)("span",{className:(0,A.cn)("mt-0.5 h-3.5 w-3.5 shrink-0 rounded border flex items-center justify-center",t?"bg-violet-600 border-violet-600 text-white":"border-muted-foreground/40"),children:t&&(0,r.jsx)(q.A,{className:"h-2.5 w-2.5"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:e.label}),e.description&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5 leading-snug",children:e.description})]})]},e.label):(0,r.jsx)("button",{type:"button",onClick:()=>f(e.label),disabled:p,className:(0,A.cn)("flex items-start gap-2 text-left rounded-md border p-2.5 transition","border-input hover:bg-accent/60 hover:border-violet-400",p&&"opacity-50"),children:(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:e.label}),e.description&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5 leading-snug",children:e.description})]})},e.label)})}),s.multiSelect&&g.length>0&&(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-1",children:[(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:i("questionCard.selected",{count:c.size})}),(0,r.jsxs)(O.$,{type:"button",size:"sm",onClick:()=>{0!==c.size&&f(JSON.stringify([...c]))},disabled:p||0===c.size,children:[p?(0,r.jsx)(l.A,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(q.A,{className:"mr-2 h-3.5 w-3.5"}),i("questionCard.submit")]})]}),(0,r.jsxs)("form",{className:"flex gap-2",onSubmit:e=>{e.preventDefault(),f(o)},children:[(0,r.jsx)($.p,{value:o,onChange:e=>d(e.target.value),placeholder:i("questionCard.ownAnswerPlaceholder"),disabled:p,className:"h-9 text-sm"}),(0,r.jsxs)(O.$,{type:"submit",size:"sm",disabled:p||!o.trim(),children:[p?(0,r.jsx)(l.A,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(q.A,{className:"mr-2 h-3.5 w-3.5"}),i("questionCard.submit")]})]})]})]})})}function F(e){let{entry:t}=e,s=(0,a.c)("roots"),[i,o]=(0,n.useTransition)(),[d,c]=(0,n.useState)({}),u=t.resolved,p=e=>{if("approve"===e){var r,n;for(let e of null!=(r=t.secrets)?r:[])if(!e.oauth&&e.required&&!(null==(n=d[e.envKey])?void 0:n.trim()))return void m.oR.error(s("mcpAddCard.secretRequired",{label:e.label||e.envKey}))}o(async()=>{let s=await fetch("/api/agents/".concat(t.agentId,"/respond"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:"mcp-add",requestId:t.requestId,decision:e,..."approve"===e?{secretValues:d}:{}})});if(!s.ok){var r;let e=await s.json().catch(()=>({}));m.oR.error(null!=(r=e.error)?r:"HTTP ".concat(s.status))}})};return(0,r.jsx)("div",{className:(0,A.cn)("rounded-lg border-2 my-2 p-4 reflex-gradient",u&&"opacity-60"),children:(0,r.jsxs)("div",{className:"rounded-md bg-background/95 backdrop-blur p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-2 text-[11px] uppercase tracking-wider text-muted-foreground",children:[(0,r.jsx)(B.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:s("mcpAddCard.title")}),(0,r.jsx)("span",{className:"font-mono normal-case tracking-normal",children:t.server}),(0,r.jsx)("span",{className:"ml-auto font-mono normal-case tracking-normal",children:t.requestId})]}),(0,r.jsx)("div",{className:"text-sm font-medium",children:t.label}),t.description&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:t.description}),(0,r.jsx)("pre",{className:"text-[11px] font-mono bg-muted/40 rounded p-2 overflow-x-auto whitespace-pre-wrap max-h-40 overflow-y-auto my-3",children:K(t.config)}),t.secrets&&t.secrets.length>0&&!u&&(0,r.jsxs)("div",{className:"space-y-2 mb-3",children:[(0,r.jsx)("div",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:s("mcpAddCard.fillSecrets")}),t.secrets.map(e=>{var t;return e.oauth?(0,r.jsx)(J,{slot:e},e.envKey):(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("label",{className:"text-xs flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-mono",children:e.envKey}),(0,r.jsx)("span",{className:"text-muted-foreground",children:e.label}),e.required&&(0,r.jsx)("span",{className:"text-destructive text-[10px]",children:"*"})]}),e.description&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:e.description}),(0,r.jsx)($.p,{type:"password",value:null!=(t=d[e.envKey])?t:"",onChange:t=>c(s=>({...s,[e.envKey]:t.target.value})),placeholder:e.required?s("mcpAddCard.required"):s("mcpAddCard.optional"),className:"font-mono text-xs h-8"})]},e.envKey)})]}),u?(0,r.jsx)("div",{className:"flex items-center gap-2 text-sm",children:"approve"===u.decision?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(q.A,{className:"h-4 w-4 text-emerald-600"}),(0,r.jsx)("span",{children:s("mcpAddCard.registered")})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(T.A,{className:"h-4 w-4 text-destructive"}),(0,r.jsx)("span",{children:s("mcpAddCard.rejected")})]})}):(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,r.jsxs)(O.$,{type:"button",variant:"default",size:"sm",onClick:()=>p("approve"),disabled:i,children:[i&&(0,r.jsx)(l.A,{className:"mr-1 h-3.5 w-3.5 animate-spin"}),(0,r.jsx)(q.A,{className:"h-3.5 w-3.5 mr-1"})," ",s("mcpAddCard.register")]}),(0,r.jsxs)(O.$,{type:"button",variant:"outline",size:"sm",onClick:()=>p("reject"),disabled:i,children:[(0,r.jsx)(T.A,{className:"h-3.5 w-3.5 mr-1"})," ",s("mcpAddCard.reject")]})]})]})})}function J(e){var t,i;let{slot:o}=e,d=(0,a.c)("roots"),[c,u]=(0,n.useState)(null),[p,x]=(0,n.useState)(null),[h,g]=(0,n.useState)(""),[v,b]=(0,n.useState)(""),[j,w]=(0,n.useState)(!1),[N,y]=(0,n.useState)(!1),[k,C]=(0,n.useTransition)(),[A,S]=(0,n.useTransition)(),I=async()=>{if(!o.oauth)return;let{listOAuthStatusesAction:e,getOAuthClientAction:t}=await s.e(4108).then(s.bind(s,94108)),[r,n]=await Promise.all([e(),t(o.oauth)]);if(r.ok){let e=r.statuses.find(e=>e.id===o.oauth);e&&u({hasClient:e.hasClient,hasTokens:e.hasTokens})}if(n.ok){var a;x({setupHint:n.setupHint,consoleUrl:n.consoleUrl,needsClientSecret:n.needsClientSecret,setupSteps:null!=(a=n.setupSteps)?a:[]}),n.client?(g(n.client.clientId),w(n.client.hasSecret)):(g(""),w(!1))}};(0,n.useEffect)(()=>{I()},[o.oauth]);let P=!(null==c?void 0:c.hasClient);return(0,r.jsxs)("div",{className:"space-y-2 rounded border border-violet-200 bg-violet-50/30 p-2",children:[(0,r.jsxs)("label",{className:"text-xs flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-mono",children:o.envKey}),(0,r.jsx)("span",{className:"text-muted-foreground",children:o.label}),(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-violet-700 ml-auto",children:d("mcpAddCard.oauthLabel",{provider:null!=(t=o.oauth)?t:""})})]}),o.description&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:o.description}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(null==c?void 0:c.hasTokens)?(0,r.jsxs)("span",{className:"text-xs text-emerald-700 flex items-center gap-1",children:[(0,r.jsx)(q.A,{className:"h-3 w-3"})," ",d("mcpAddCard.authorized")]}):(null==c?void 0:c.hasClient)?(0,r.jsxs)(O.$,{type:"button",size:"sm",variant:"outline",onClick:()=>{o.oauth&&C(async()=>{let{beginOAuthAction:e,listOAuthStatusesAction:t}=await s.e(4108).then(s.bind(s,94108)),r=await e(o.oauth);if(!r.ok)return void m.oR.error(r.error);window.open(r.authorizeUrl,"reflex-oauth","width=600,height=720,noopener=no");let n=Date.now(),a=async()=>{if(Date.now()-n>3e5)return void m.oR.error(d("mcpAddCard.authorizationTimedOut"));let e=await t();if(e.ok){let t=e.statuses.find(e=>e.id===o.oauth);if(null==t?void 0:t.hasTokens){m.oR.success(d("mcpAddCard.providerAuthorized",{provider:o.oauth})),u({hasClient:t.hasClient,hasTokens:t.hasTokens});return}}setTimeout(()=>void a(),1500)};a()})},disabled:k,className:"h-7 text-xs",children:[k&&(0,r.jsx)(l.A,{className:"mr-1 h-3 w-3 animate-spin"}),d("mcpAddCard.authorizeVia",{provider:null!=(i=o.oauth)?i:""})]}):(0,r.jsx)("span",{className:"text-xs text-amber-700",children:d("mcpAddCard.clientIdNotConfigured")}),!P&&(0,r.jsxs)(O.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>y(e=>!e),className:"h-7 text-xs text-muted-foreground gap-1",children:[(0,r.jsx)(f.A,{className:"h-3 w-3 transition-transform ".concat(N?"rotate-180":"")}),N?d("mcpAddCard.hideClient"):d("mcpAddCard.editClient")]}),(0,r.jsx)(O.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>void I(),className:"h-7 text-xs text-muted-foreground ml-auto",children:d("mcpAddCard.refresh")})]}),(N||P)&&p&&(0,r.jsxs)("div",{className:"space-y-2 border-t border-violet-200 pt-2 mt-2",children:[p.setupHint&&(0,r.jsx)("div",{className:"rounded border border-amber-200 bg-amber-50 px-2 py-1.5 text-[10px] text-amber-900 leading-snug",children:p.setupHint}),(0,r.jsxs)("a",{href:p.consoleUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[11px] text-violet-700 hover:underline inline-flex items-center gap-1",children:[(0,r.jsx)(z.A,{className:"h-3 w-3"}),d("mcpAddCard.openProviderConsole")]}),p.setupSteps.length>0&&(0,r.jsxs)("div",{className:"rounded border border-violet-200 bg-white/60 p-2",children:[(0,r.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1.5",children:d("mcpAddCard.stepByStep")}),(0,r.jsx)(D.O,{steps:p.setupSteps})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(L.J,{className:"text-[10px]",children:d("mcpAddCard.clientIdLabel")}),(0,r.jsx)($.p,{value:h,onChange:e=>g(e.target.value),placeholder:"123…apps.googleusercontent.com",className:"font-mono text-xs h-7"})]}),p.needsClientSecret&&(0,r.jsxs)("div",{children:[(0,r.jsxs)(L.J,{className:"text-[10px]",children:[d("mcpAddCard.clientSecretLabel")," ",j&&(0,r.jsx)("span",{className:"text-muted-foreground",children:d("mcpAddCard.clientSecretSavedHint")})]}),(0,r.jsx)($.p,{type:"password",value:v,onChange:e=>b(e.target.value),placeholder:j?"••••":"GOCSPX-…",className:"font-mono text-xs h-7"})]}),(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsxs)(O.$,{type:"button",size:"sm",onClick:()=>{if(o.oauth){if(!h.trim())return void m.oR.error(d("mcpAddCard.clientIdRequired"));S(async()=>{let{saveOAuthClientAction:e}=await s.e(4108).then(s.bind(s,94108)),t=await e({provider:o.oauth,clientId:h.trim(),...v?{clientSecret:v}:{}});if(!t.ok)return void m.oR.error(t.error);m.oR.success(d("mcpAddCard.clientSaved")),b(""),await I()})}},disabled:A||!h.trim(),className:"h-7 text-xs",children:[A?(0,r.jsx)(l.A,{className:"mr-1 h-3 w-3 animate-spin"}):(0,r.jsx)(E.A,{className:"mr-1 h-3 w-3"}),d("mcpAddCard.saveClient")]})})]})]})}function K(e){try{return JSON.stringify(e,null,2)}catch(t){return String(e)}}var M=s(54400),_=s.n(M),W=s(7293),V=s(86515),G=s(16329),Z=s(40805),X=s(8583),Q=s(35994);function Y(e){let{rootId:t,entry:s}=e,n=(0,a.c)("roots"),i=function(e){let t=e.toLowerCase();return"task"===t||"tasks"===t?V.A:"meeting"===t||"meetings"===t?G.A:"product"===t||"products"===t?Z.A:"fact"===t||"facts"===t?X.A:Q.A}(s.kind),o="/roots/".concat(t,"?file=").concat(encodeURIComponent(s.relPath));return(0,r.jsx)(_(),{href:o,className:"my-2 block rounded-lg border-2 p-[2px] reflex-gradient hover:shadow-md transition-shadow",children:(0,r.jsxs)("div",{className:"rounded-md bg-background/95 backdrop-blur p-3 flex items-center gap-3",children:[(0,r.jsx)("div",{className:"reflex-gradient h-9 w-9 rounded-md flex items-center justify-center text-white shrink-0",children:(0,r.jsx)(i,{className:"h-4 w-4"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground flex items-center gap-1",children:[(0,r.jsx)(c.A,{className:"h-3 w-3"}),(0,r.jsx)("span",{children:n("kbWriteCard.writtenToKb")}),(0,r.jsx)("span",{className:"font-mono normal-case tracking-normal",children:s.kind})]}),(0,r.jsx)("div",{className:"text-sm font-medium truncate",children:s.title}),(0,r.jsx)("div",{className:"text-[11px] font-mono text-muted-foreground truncate",children:s.relPath})]}),(0,r.jsx)(W.A,{className:"h-4 w-4 text-muted-foreground shrink-0"})]})})}var ee=s(39624);function et(e){let{utility:t,rootId:s}=e,n=(0,a.c)("roots"),i="project"===t.scope&&s?"?rootId=".concat(encodeURIComponent(s)):"",o="/utilities/".concat(t.scope,"/").concat(t.id).concat(i);return(0,r.jsx)(_(),{href:o,className:"my-2 block rounded-lg border-2 p-[2px] reflex-gradient hover:shadow-md transition-shadow",children:(0,r.jsxs)("div",{className:"rounded-md bg-background/95 backdrop-blur p-3 flex items-center gap-3",children:[(0,r.jsx)("div",{className:"reflex-gradient h-9 w-9 rounded-md flex items-center justify-center text-white shrink-0",children:(0,r.jsx)(ee.A,{className:"h-4 w-4"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground flex items-center gap-1",children:[(0,r.jsx)(c.A,{className:"h-3 w-3"}),(0,r.jsx)("span",{children:n("utilityCard.installed")}),(0,r.jsx)("span",{className:"font-mono normal-case tracking-normal",children:t.scope})]}),(0,r.jsx)("div",{className:"text-sm font-medium truncate",children:t.name}),(0,r.jsxs)("div",{className:"text-[11px] font-mono text-muted-foreground truncate",children:[t.id," \xb7 v",t.version]})]})]})})}var es=s(94870),er=s(56380),en=s(76974),ea=s(40963),ei=s(24678);function eo(e){let{rootId:t,widget:s}=e,i=(0,a.c)("roots"),[o,l]=(0,n.useState)(!1),[d,p]=(0,n.useTransition)();return(0,r.jsxs)("div",{className:"my-3 rounded-lg border border-violet-200 bg-violet-50/40 dark:border-violet-900/40 dark:bg-violet-950/20 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-violet-200 dark:border-violet-900/40 bg-violet-100/40 dark:bg-violet-900/20 text-xs",children:[(0,r.jsx)(c.A,{className:"h-3 w-3 text-violet-600"}),(0,r.jsx)("span",{className:"font-medium text-violet-900 dark:text-violet-200",children:"create"===s.op?i("widgetPreview.created"):i("widgetPreview.updated")}),(0,r.jsx)(u.E,{variant:"outline",className:"text-[10px] font-mono",children:s.widgetKind}),(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono ml-1",children:s.widgetId}),o?(0,r.jsxs)("span",{className:"ml-auto inline-flex items-center gap-1 text-[10px] text-emerald-700",children:[(0,r.jsx)(q.A,{className:"h-3 w-3"}),i("widgetPreview.onDashboard")]}):(0,r.jsxs)("button",{type:"button",onClick:()=>{p(async()=>{let e=await (0,ei.t)(t,s.widgetId);e.ok?(l(!0),m.oR.success(i("widgetPreview.pinned"))):m.oR.error(e.error)})},disabled:d,className:"ml-auto inline-flex items-center gap-1 text-[10px] text-violet-700 hover:underline disabled:opacity-50",title:i("widgetPreview.pinToDashboardTitle"),children:[(0,r.jsx)(es.A,{className:"h-3 w-3"}),d?i("widgetPreview.pinning"):i("widgetPreview.pinToDashboard")]}),(0,r.jsx)(_(),{href:"/roots/".concat(t),className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-violet-700",title:i("widgetPreview.openDashboard"),children:(0,r.jsx)(er.A,{className:"h-3 w-3"})})]}),(0,r.jsxs)("div",{className:"p-3 space-y-2 bg-card",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h4",{className:"text-sm font-medium",children:s.title}),s.description&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:s.description})]}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground inline-flex items-center gap-0.5",title:i("widgetPreview.editViaChatTitle"),children:[(0,r.jsx)(en.A,{className:"h-2.5 w-2.5"}),i("widgetPreview.editViaChat")]})]}),(0,r.jsx)("div",{className:"pt-1",children:(0,ea.v)(t,s.widgetKind,s.data,{readonly:!0})})]})]})}var el=s(27474),ed=s(54207);function ec(e){let{rootId:t,workflow:s}=e,n=(0,a.c)("roots");return(0,r.jsxs)("div",{className:"my-3 rounded-lg border border-violet-200 bg-violet-50/40 dark:border-violet-900/40 dark:bg-violet-950/20 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-violet-200 dark:border-violet-900/40 bg-violet-100/40 dark:bg-violet-900/20 text-xs",children:[(0,r.jsx)(c.A,{className:"h-3 w-3 text-violet-600"}),(0,r.jsx)("span",{className:"font-medium text-violet-900 dark:text-violet-200",children:n("workflowPreview.created")}),(0,r.jsx)(u.E,{variant:"outline",className:"text-[10px] font-mono",children:s.trigger}),(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono ml-1",children:s.workflowId})]}),(0,r.jsxs)("div",{className:"p-3 space-y-2 bg-card",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(el.A,{className:"h-4 w-4 text-violet-600 mt-0.5 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h4",{className:"text-sm font-medium",children:s.label}),s.description&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:s.description}),(0,r.jsx)("p",{className:"text-[10px] text-muted-foreground mt-1",children:n.rich("workflowPreview.stepsCount",{count:s.stepCount,trigger:s.trigger,code:e=>(0,r.jsx)("code",{className:"font-mono",children:e})})})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-1 text-xs",children:[(0,r.jsxs)(_(),{href:"/roots/".concat(t,"/workflows/").concat(s.workflowId),className:"inline-flex items-center gap-1 rounded px-2 py-1 bg-violet-600 text-white hover:bg-violet-700",children:[(0,r.jsx)(ed.A,{className:"h-3 w-3"}),n("workflowPreview.openInEditor")]}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground inline-flex items-center gap-1",children:[(0,r.jsx)(en.A,{className:"h-2.5 w-2.5"}),n("workflowPreview.editHereViaChat")]})]})]})]})}function em(e){let{rootId:t,topicId:s,initialEvents:c,initialActive:p}=e,f=(0,a.c)("roots"),[v,b]=(0,n.useState)(c),[j,w]=(0,n.useState)(p),[N,y]=(0,n.useState)(!1),k=(0,n.useRef)(c.length>0?c[c.length-1].seq:-1),C=(0,n.useRef)(null),A=(0,n.useMemo)(()=>(function(e){let t=[],s=new Map,r=null,n=null,a=e=>{var a;let i=s.get(e),o={kind:"assistant",agentId:e,agentLabel:null!=(a=null==i?void 0:i.label)?a:"assistant",...(null==i?void 0:i.model)?{agentModel:i.model}:{},...(null==i?void 0:i.role)?{agentRole:i.role}:{},segments:[],pending:!0};return t.push(o),r=o,n=null,o},i=(e,t)=>{let s=r;s&&(s.pending=!1,"failed"===e&&t&&(s.error=t),r=null,n=null)};for(let l of e){if("agent-start"===l.type){s.set(l.agentId,l.meta);continue}if("turn-start"===l.type){a(l.agentId);continue}if("turn-end"===l.type||"agent-end"===l.type){i(l.status,l.error);continue}if("user-message"===l.type){let e=s.get(l.agentId),r=null==e?void 0:e.role;t.push({kind:"user",body:l.text,agentId:l.agentId,...r?{agentRole:r}:{},...(null==e?void 0:e.label)?{agentLabel:e.label}:{}});continue}if("system"===l.type){l.subtype&&l.subtype.startsWith("reflex.")&&t.push({kind:"system",body:l.text,systemSubtype:l.subtype});continue}if("assistant-delta"===l.type){let e=r;if(e||(e=a(l.agentId)),!e)continue;let t=e.segments;if(n&&"text"===n.kind)n.text+=l.text;else{let e={kind:"text",text:l.text};t.push(e),n=e}continue}if("tool-use"===l.type){let e=r;if(e||(e=a(l.agentId)),!e)continue;let t=e.segments,s={kind:"tool",tool:{toolUseId:l.toolUseId,name:l.name,input:l.input}};t.push(s),n=s;continue}if("tool-result"===l.type){var o;let e=r;if(!e)continue;let t=null!=(o=e.segments)?o:[];for(let e=t.length-1;e>=0;e--){let s=t[e];if("tool"===s.kind&&s.tool.toolUseId===l.toolUseId){s.tool.result={content:l.content,...l.isError?{isError:!0}:{}};break}}continue}if("error"===l.type){let e=r;e&&(e.error=l.message);continue}if("permission-request"===l.type){let e=null!=r?r:a(l.agentId);if(!e)continue;e.segments.push({kind:"permission",perm:{requestId:l.requestId,agentId:l.agentId,...l.tool?{tool:l.tool}:{},...l.action?{action:l.action}:{},...void 0!==l.input?{input:l.input}:{},...l.description?{description:l.description}:{}}}),n=e.segments[e.segments.length-1];continue}if("permission-response"===l.type){for(let e of t)if("assistant"===e.kind&&e.segments)for(let t of e.segments)"permission"===t.kind&&t.perm.requestId===l.requestId&&(t.perm.resolved={decision:l.decision,...l.scope?{scope:l.scope}:{}});continue}if("question"===l.type){let e=null!=r?r:a(l.agentId);if(!e)continue;e.segments.push({kind:"question",question:{questionId:l.questionId,agentId:l.agentId,prompt:l.prompt,...l.header?{header:l.header}:{},...l.multiSelect?{multiSelect:!0}:{},...l.choices?{choices:l.choices}:{},...l.options?{options:l.options}:{}}}),n=e.segments[e.segments.length-1];continue}if("answer"===l.type){for(let e of t)if("assistant"===e.kind&&e.segments)for(let t of e.segments)"question"===t.kind&&t.question.questionId===l.questionId&&(t.question.resolved={answer:l.answer});continue}if("mcp-add-request"===l.type){let e=null!=r?r:a(l.agentId);if(!e)continue;e.segments.push({kind:"mcp-add",entry:{requestId:l.requestId,agentId:l.agentId,server:l.server,label:l.label,...l.description?{description:l.description}:{},config:l.config,...l.secrets?{secrets:l.secrets}:{}}}),n=e.segments[e.segments.length-1];continue}if("mcp-add-response"===l.type){for(let e of t)if("assistant"===e.kind&&e.segments)for(let t of e.segments)"mcp-add"===t.kind&&t.entry.requestId===l.requestId&&(t.entry.resolved={decision:l.decision});continue}if("kb-write"===l.type){let e=null!=r?r:a(l.agentId);if(!e)continue;e.segments.push({kind:"kb",kb:{kind:l.kind,title:l.title,relPath:l.relPath}}),n=e.segments[e.segments.length-1];continue}if("utility-installed"===l.type){let e=null!=r?r:a(l.agentId);if(!e)continue;e.segments.push({kind:"utility",utility:{id:l.utilityId,name:l.name,scope:l.scope,version:l.version}}),n=e.segments[e.segments.length-1];continue}if("utility-error"===l.type){let e=null!=r?r:a(l.agentId);e&&(e.error=l.message);continue}if("widget-event"===l.type){let e=null!=r?r:a(l.agentId);if(!e)continue;e.segments.push({kind:"widget",widget:{op:l.op,widgetId:l.widgetId,title:l.title,...l.description?{description:l.description}:{},widgetKind:l.kind,data:l.data,...l.sourceTopicId?{sourceTopicId:l.sourceTopicId}:{}}}),n=e.segments[e.segments.length-1];continue}if("widget-error"===l.type){let e=null!=r?r:a(l.agentId);e&&(e.error=l.message);continue}if("workflow-event"===l.type){let e=null!=r?r:a(l.agentId);if(!e)continue;e.segments.push({kind:"workflow",workflow:{workflowId:l.workflowId,label:l.label,...l.description?{description:l.description}:{},trigger:l.trigger,stepCount:l.stepCount}}),n=e.segments[e.segments.length-1];continue}if("workflow-error"===l.type){let e=null!=r?r:a(l.agentId);e&&(e.error=l.message);continue}}return t})(v),[v]),S=(0,n.useCallback)(()=>{let e=C.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,n.useEffect)(()=>{S()},[A,S]),(0,n.useEffect)(()=>{let e=new AbortController,r="/api/roots/".concat(t,"/chat/").concat(s,"/stream?since=").concat(k.current),n=!1;return(async()=>{try{let a=await fetch(r,{signal:e.signal});if(!a.ok||!a.body)return void y(!1);y(!0);let i=a.body.getReader(),o=new TextDecoder,l="";for(;!n;){let{done:e,value:r}=await i.read();if(e)break;for(let e of(l+=o.decode(r,{stream:!0}),function(e){let t=[];for(;;){let s=e.indexOf("\n\n");if(s<0)break;let r=e.slice(0,s);e=e.slice(s+2);let n="message",a="";for(let e of r.split(/\r?\n/))!e.startsWith(":")&&(e.startsWith("event:")?n=e.slice(6).trim():e.startsWith("data:")&&(a+=e.slice(5).trimStart()));let i=null;try{i=a?JSON.parse(a):null}catch(e){i=null}t.push({event:n,data:i,rest:e})}return t}(l)))if(l=e.rest,"event"===e.event&&e.data){let t=e.data;I(t)}else if("error"===e.event){var t,s;m.oR.error(String(null!=(s=null==(t=e.data)?void 0:t.message)?s:"stream"))}}}catch(e){n||y(!1)}finally{y(!1)}})(),()=>{n=!0,e.abort()}},[s,t]);let I=(0,n.useCallback)(e=>{e.seq<=k.current||(k.current=e.seq,b(t=>[...t,e]),"turn-start"===e.type?w(!0):"agent-start"===e.type&&"orchestrator"===e.meta.role&&w(!0),("turn-end"===e.type||"agent-end"===e.type)&&(w(!1),(0,g.$d)(g.Zi.topicsChanged(t))),"kb-write"===e.type&&(0,g.$d)(g.Zi.kbChanged(t)))},[t]),P=(0,n.useCallback)(async()=>{try{let r=await fetch("/api/roots/".concat(t,"/chat/").concat(s,"/stop"),{method:"POST"});if(!r.ok){var e;let t=await r.json().catch(()=>({}));m.oR.error(null!=(e=t.error)?e:"HTTP ".concat(r.status));return}w(!1)}catch(e){m.oR.error(e instanceof Error?e.message:String(e))}},[t,s]),T=(0,n.useCallback)(async(e,r)=>{let n=e.trim();if(!n&&0===r.length)return!1;try{let e=await fetch("/api/roots/".concat(t,"/chat/").concat(s,"/send"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:n,attachments:r})});if(409===e.status)return m.oR.error(f("chat.waitForCurrentAnswer")),!1;if(!e.ok){var a;let t=await e.json().catch(()=>({}));return m.oR.error(null!=(a=t.error)?a:"HTTP ".concat(e.status)),!1}return!0}catch(e){return m.oR.error(e instanceof Error?e.message:String(e)),!1}},[t,s]);return(0,r.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,r.jsxs)("div",{className:"border-b px-6 py-2 flex items-center gap-3 text-xs",children:[(0,r.jsx)("span",{className:"text-muted-foreground inline-flex items-center gap-1",children:N?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.A,{className:"h-3 w-3 text-emerald-600"})," ",f("chat.connectedToStream")]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.A,{className:"h-3 w-3 text-muted-foreground"})," ",f("chat.offline")]})}),j&&(0,r.jsxs)(u.E,{variant:"default",className:"gap-1 bg-emerald-600",children:[(0,r.jsx)(l.A,{className:"h-3 w-3 animate-spin"})," ",f("chat.agentWorking")]}),(0,r.jsxs)("span",{className:"ml-auto text-[10px] text-muted-foreground font-mono",children:["seq: ",k.current]})]}),(0,r.jsx)("div",{ref:C,className:"flex-1 overflow-y-auto",children:(0,r.jsx)("div",{className:"mx-auto max-w-3xl px-6 py-6 space-y-4",children:0===A.length?(0,r.jsx)("p",{className:"text-sm text-muted-foreground italic",children:f("chat.topicEmpty")}):A.map((e,n)=>(0,r.jsx)(eu,{turn:e,rootId:t,topicId:s},n))})}),(0,r.jsx)(x.E,{label:f("chat.replyInTopicLabel"),children:(0,r.jsx)(h.L,{rootId:t,topicId:s,placeholder:f("chat.topicPlaceholder"),submitLabel:f("chat.send"),pendingLabel:f("chat.sendPending"),SubmitIcon:d.A,active:j,onStop:P,onSubmit:e=>{let{message:t,attachments:s}=e;return T(t,s)}})})]})}function eu(e){var t,s,n,i;let{turn:o,rootId:d,topicId:u}=e,x=(0,a.c)("roots"),h=(e,t)=>{let s=x("kb.summaryContextChat",{url:t,text:e});fetch("/api/roots/".concat(d,"/chat/").concat(u,"/send"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:s,attachments:[]})}).then(async e=>{if(!e.ok){var t;let s=await e.json().catch(()=>({}));m.oR.error(null!=(t=s.error)?t:"HTTP ".concat(e.status));return}m.oR.success(x("kb.summarySentToChat"))}).catch(e=>{m.oR.error(e instanceof Error?e.message:String(e))})};if("system"===o.kind)return(0,r.jsx)(ex,{body:null!=(s=o.body)?s:"",subtype:o.systemSubtype});if("user"===o.kind){if("subagent"===o.agentRole)return null;let e=null!=(n=o.body)?n:"",t=function(e,t){let s=e.trimStart(),r=/^\[MCP setup wizard\]\s*([^\n]*)/.exec(s);if(r)return{badge:t.mcpSetupBadge,summary:r[1].trim()||t.mcpSetupDefault,details:e};let n=/^\[Reflex\]\s+Answer for question\s+\S+:\s+([\s\S]*?)(?:\s*\.?\s*Continue\.\s*)?$/.exec(s);if(n)return{badge:t.answerBadge,summary:n[1].trim(),details:e};let a=/^\[Reflex\]\s+(Allowed|Denied|User (allowed|denied))[\s\S]*?:\s*([\s\S]*?)(?:\s*\.?\s*Continue\.\s*)?$/.exec(s);if(a){var i,o;return{badge:t.permissionBadge,summary:(null!=(o=null!=(i=a[3])?i:a[1])?o:"").trim()||t.permissionUserDecision,details:e}}if(/^\[Reflex\]\s+(MCP server|User rejected|Failed to register)[\s\S]*?$/.exec(s)){let r=s.split("\n",1)[0];return{badge:t.mcpBadge,summary:r.replace(/^\[Reflex\]\s+/,"").slice(0,200),details:e}}if(/^\[Reflex \/goal\]\s+([\s\S]*)/.exec(s))return{badge:t.goalBadge,summary:t.goalAutoContinue,details:e};let l=/^\[Reflex[^\]]*\]\s*([\s\S]*)/.exec(s);if(l){let s=l[1].split("\n",1)[0].trim();return{badge:t.systemBadge,summary:s.slice(0,200)||t.systemMessage,details:e}}return null}(e,{mcpSetupDefault:x("chat.mcpSetupDefault"),mcpSetupBadge:x("chat.mcpSetupBadge"),answerBadge:x("chat.answerBadge"),permissionBadge:x("chat.permissionBadge"),permissionUserDecision:x("chat.permissionUserDecision"),mcpBadge:x("chat.mcpBadge"),goalBadge:x("chat.goalBadge"),goalAutoContinue:x("chat.goalAutoContinue"),systemBadge:x("chat.systemBadge"),systemMessage:x("chat.systemMessage")});return t?(0,r.jsx)(eh,{system:t}):(0,r.jsxs)("div",{className:"rounded-lg border bg-muted/40 p-4",children:[(0,r.jsx)("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-2",children:"user"}),(0,r.jsx)(p.p,{source:e,onSendToChat:h})]})}let g="subagent"===o.agentRole;return(0,r.jsx)(ep,{isSubAgent:g,turn:o,children:(0,r.jsxs)("div",{className:g?"rounded-md border border-dashed bg-muted/30 px-3 py-2":"rounded-lg border bg-background p-4",children:[(0,r.jsxs)("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-2 flex items-center gap-2",children:[(0,r.jsx)(c.A,{className:"h-3 w-3"}),(0,r.jsx)("span",{children:null!=(i=o.agentLabel)?i:"assistant"}),g&&(0,r.jsx)("span",{className:"text-[10px] normal-case px-1.5 py-0.5 rounded bg-violet-100 text-violet-800 tracking-normal",children:"sub-agent"}),o.agentModel&&(0,r.jsx)("span",{className:"font-mono text-[10px] normal-case tracking-normal",children:o.agentModel}),o.pending&&(0,r.jsx)(l.A,{className:"h-3 w-3 animate-spin"}),o.error&&(0,r.jsx)("span",{className:"text-destructive text-xs normal-case",children:x("chat.errorPrefix",{message:o.error})})]}),null==(t=o.segments)?void 0:t.map((e,t)=>{if("text"===e.kind){let s=function(e){let t=e;for(let e of["permission","question","kb","utility","dispatch","mcp-add","youtube-summary","widget-create","widget-update","workflow-create","image-gen","memory","suggestion"]){let s=RegExp("<{1,2}reflex:".concat(e,">{1,2}[\\s\\S]*?<{1,2}\\/reflex:").concat(e,">{1,2}"),"g");t=t.replace(s,"")}return t}(e.text);return s.trim()?(0,r.jsx)(p.p,{source:s,onSendToChat:h},t):null}return"tool"===e.kind?(0,r.jsx)(S,{name:e.tool.name,input:e.tool.input,...e.tool.result?{result:e.tool.result}:{},pending:!e.tool.result},t):"permission"===e.kind?(0,r.jsx)(U,{perm:e.perm},t):"question"===e.kind?(0,r.jsx)(H,{question:e.question},t):"kb"===e.kind?(0,r.jsx)(Y,{rootId:d,entry:e.kb},t):"mcp-add"===e.kind?(0,r.jsx)(F,{entry:e.entry},t):"utility"===e.kind?(0,r.jsx)(et,{utility:e.utility,rootId:d},t):"widget"===e.kind?(0,r.jsx)(eo,{rootId:d,widget:e.widget},t):"workflow"===e.kind?(0,r.jsx)(ec,{rootId:d,workflow:e.workflow},t):null}),o.pending&&(!o.segments||0===o.segments.length)&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:x("chat.thinking")})]})})}function ep(e){var t;let{isSubAgent:s,turn:n,children:i}=e,o=(0,a.c)("roots");if(!s)return(0,r.jsx)(r.Fragment,{children:i});let d=[null!=(t=n.agentLabel)?t:"sub-agent",o(n.pending?"chat.subAgentWorking":n.error?"chat.subAgentError":"chat.subAgentDone")].join(" \xb7 ");return(0,r.jsxs)("details",{className:"group",open:n.pending,children:[(0,r.jsxs)("summary",{className:"cursor-pointer list-none flex items-center gap-2 text-xs text-muted-foreground border-l-2 border-violet-300 pl-2 py-1 hover:text-foreground select-none",children:[(0,r.jsx)("span",{className:"inline-block h-3 w-3 text-center transition-transform group-open:rotate-90",children:"▸"}),(0,r.jsx)(c.A,{className:"h-3 w-3 text-violet-500"}),(0,r.jsx)("span",{children:d}),n.pending&&(0,r.jsx)(l.A,{className:"h-3 w-3 animate-spin"})]}),(0,r.jsx)("div",{className:"mt-1 pl-4",children:i})]})}function ex(e){let{body:t,subtype:s}=e;return(0,r.jsxs)("div",{className:["rounded-md border px-3 py-2 text-xs flex items-start gap-2","reflex.preflight"===s?"border-violet-200 bg-violet-50/60 text-violet-900":"border-dashed bg-muted/30 text-muted-foreground"].join(" "),children:[(0,r.jsx)(c.A,{className:"h-3.5 w-3.5 mt-0.5 shrink-0 text-violet-600"}),(0,r.jsx)("div",{className:"whitespace-pre-wrap leading-relaxed flex-1 min-w-0",children:t})]})}function eh(e){let{system:t}=e;return(0,r.jsxs)("details",{className:"group rounded-md border border-dashed bg-muted/20 px-3 py-1.5 text-xs",children:[(0,r.jsxs)("summary",{className:"cursor-pointer list-none flex items-center gap-2 select-none",children:[(0,r.jsx)("span",{className:"inline-block h-3 w-3 text-center text-muted-foreground transition-transform group-open:rotate-90",children:"▸"}),(0,r.jsx)("span",{className:"rounded bg-muted-foreground/10 text-[10px] uppercase tracking-wider text-muted-foreground px-1.5 py-0.5 font-mono",children:t.badge}),(0,r.jsx)("span",{className:"truncate text-foreground/80",children:t.summary})]}),(0,r.jsx)("pre",{className:"mt-2 pl-5 text-[11px] whitespace-pre-wrap font-mono text-muted-foreground/90",children:t.details})]})}},16225:(e,t,s)=>{"use strict";s.d(t,{DeleteTopicButton:()=>p});var r=s(4624),n=s(99356),a=s(69285),i=s(49411),o=s(3239),l=s(46972),d=s(56221),c=s(85253),m=s(17570),u=s(63514);function p(e){let{rootId:t,topicId:s,topicTitle:p}=e,x=(0,i.c)("roots"),[h,g]=(0,n.useTransition)(),f=(0,a.useRouter)();return(0,r.jsxs)(c.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>{confirm(x("deleteTopic.confirm",{title:p}))&&g(async()=>{let e=await (0,m.L)(t,s);if(!e.ok){var r;d.oR.error(null!=(r=e.error)?r:x("deleteTopic.deleteFailed"));return}d.oR.success(x("deleteTopic.deleted")),(0,u.$d)(u.Zi.topicsChanged(t)),f.push("/roots/".concat(t))})},disabled:h,className:"gap-1 h-8 text-muted-foreground hover:text-destructive",title:x("deleteTopic.title"),children:[h?(0,r.jsx)(o.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,r.jsx)(l.A,{className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{className:"text-xs",children:x("deleteTopic.label")})]})}},17570:(e,t,s)=>{"use strict";s.d(t,{L:()=>n});var r=s(7911);let n=(0,r.createServerReference)("60de31e31af2e83152afdcf3e3f6f0aaa40b52a1f7",r.callServer,void 0,r.findSourceMapURL,"deleteTopicAction")},25342:(e,t,s)=>{Promise.resolve().then(s.bind(s,3989)),Promise.resolve().then(s.bind(s,16225)),Promise.resolve().then(s.bind(s,28126)),Promise.resolve().then(s.bind(s,91074)),Promise.resolve().then(s.bind(s,96253)),Promise.resolve().then(s.bind(s,28050)),Promise.resolve().then(s.bind(s,94904)),Promise.resolve().then(s.bind(s,13270)),Promise.resolve().then(s.bind(s,99730)),Promise.resolve().then(s.bind(s,89146)),Promise.resolve().then(s.bind(s,19078)),Promise.resolve().then(s.bind(s,67854)),Promise.resolve().then(s.bind(s,69050)),Promise.resolve().then(s.bind(s,63739)),Promise.resolve().then(s.bind(s,33976)),Promise.resolve().then(s.bind(s,12537)),Promise.resolve().then(s.bind(s,97485)),Promise.resolve().then(s.bind(s,41923)),Promise.resolve().then(s.bind(s,73868)),Promise.resolve().then(s.bind(s,53511)),Promise.resolve().then(s.bind(s,2018)),Promise.resolve().then(s.bind(s,18487)),Promise.resolve().then(s.bind(s,98346)),Promise.resolve().then(s.bind(s,14884)),Promise.resolve().then(s.bind(s,85314)),Promise.resolve().then(s.bind(s,17280)),Promise.resolve().then(s.bind(s,8855)),Promise.resolve().then(s.bind(s,86631)),Promise.resolve().then(s.bind(s,2604)),Promise.resolve().then(s.bind(s,27237)),Promise.resolve().then(s.bind(s,49455)),Promise.resolve().then(s.bind(s,39211)),Promise.resolve().then(s.bind(s,56360)),Promise.resolve().then(s.t.bind(s,54400,23))},28126:(e,t,s)=>{"use strict";s.d(t,{GoalBadge:()=>g});var r=s(4624),n=s(99356),a=s(49411),i=s(13561),o=s(58726),l=s(5270),d=s(41234),c=s(56221),m=s(85253),u=s(28310),p=s(13506),x=s(7911);let h=(0,x.createServerReference)("6021fac4c405ea0cfa76e6f701eabde00d86321fac",x.callServer,void 0,x.findSourceMapURL,"clearTopicGoalAction");function g(e){var t;let{rootId:s,topicId:x,goal:g,status:f,iterations:v}=e,b=(0,a.c)("roots"),[j,w]=(0,n.useTransition)(),N="completed"===(t=f)?o.A:"abandoned"===t?l.A:d.A;return(0,r.jsxs)("div",{className:(0,p.cn)("flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs","active"===f&&"reflex-gradient text-foreground border-transparent","completed"===f&&"border-emerald-500/40 bg-emerald-50","abandoned"===f&&"border-destructive/40 bg-destructive/5"),children:[(0,r.jsx)(N,{className:"h-3.5 w-3.5 shrink-0"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"text-[10px] uppercase tracking-wider opacity-80",children:["/goal \xb7 ",f," ","active"===f&&v>0&&(0,r.jsxs)("span",{className:"font-mono",children:["(",v,")"]})]}),(0,r.jsx)("div",{className:"truncate font-medium",title:g,children:g})]}),"active"===f&&(0,r.jsxs)(m.$,{type:"button",size:"sm",variant:"ghost",className:"h-7 shrink-0",disabled:j,onClick:()=>{confirm(b("goalBadge.stopConfirm"))&&w(async()=>{var e;let t=await h(s,x);t.ok?c.oR.success(b("goalBadge.stopSuccess")):c.oR.error(null!=(e=t.error)?e:b("goalBadge.stopFailed"))})},children:[(0,r.jsx)(i.A,{className:"mr-1 h-3 w-3"})," ",b("goalBadge.stop")]}),("completed"===f||"abandoned"===f)&&(0,r.jsx)(u.E,{variant:"outline",className:"shrink-0 capitalize",children:f})]})}},66459:(e,t,s)=>{"use strict";s.d(t,{O:()=>c});var r=s(4624),n=s(99356),a=s(43153),i=s(9598),o=s(56221),l=s(49411),d=s(85253);function c(e){let{steps:t}=e,s=(0,l.c)("app");return t&&0!==t.length?(0,r.jsx)("ol",{className:"space-y-2 text-xs",children:t.map((e,t)=>(0,r.jsxs)("li",{className:"flex gap-2",children:[(0,r.jsxs)("span",{className:"font-mono text-muted-foreground shrink-0 w-5 text-right",children:[t+1,"."]}),(0,r.jsxs)("div",{className:"space-y-1 flex-1 min-w-0",children:[(0,r.jsx)("div",{children:e.title}),e.choice&&(0,r.jsxs)("div",{className:"text-[11px]",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:s("oauth.copyHint")}),(0,r.jsx)("span",{className:"font-medium bg-muted/60 rounded px-1.5 py-0.5",children:e.choice})]}),e.body&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:e.body}),e.copy&&(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[e.field&&(0,r.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[e.field,":"]}),(0,r.jsx)("code",{className:"font-mono text-[11px] bg-muted/60 rounded px-1.5 py-0.5 break-all flex-1 min-w-0",children:e.copy}),(0,r.jsx)(m,{value:e.copy})]})]})]},t))}):null}function m(e){let{value:t}=e,s=(0,l.c)("app"),[c,m]=(0,n.useState)(!1);return(0,r.jsx)(d.$,{type:"button",size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0",onClick:async()=>{try{await navigator.clipboard.writeText(t),m(!0),o.oR.success(s("oauth.copied")),setTimeout(()=>m(!1),1200)}catch(e){o.oR.error(s("oauth.copyFailed"))}},title:s("oauth.copy"),children:c?(0,r.jsx)(a.A,{className:"h-3 w-3 text-emerald-600"}):(0,r.jsx)(i.A,{className:"h-3 w-3"})})}}},e=>{e.O(0,[4400,1217,9411,3335,5097,3954,8775,6568,7529,5771,1e3,4933,146,7358],()=>e(e.s=25342)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[532],{2046:(e,t,s)=>{Promise.resolve().then(s.bind(s,62952)),Promise.resolve().then(s.bind(s,85682)),Promise.resolve().then(s.bind(s,33125)),Promise.resolve().then(s.bind(s,91074)),Promise.resolve().then(s.bind(s,96253)),Promise.resolve().then(s.bind(s,28050)),Promise.resolve().then(s.bind(s,94904)),Promise.resolve().then(s.bind(s,13270)),Promise.resolve().then(s.bind(s,99730)),Promise.resolve().then(s.bind(s,89146)),Promise.resolve().then(s.bind(s,19078)),Promise.resolve().then(s.bind(s,67854)),Promise.resolve().then(s.bind(s,69050)),Promise.resolve().then(s.bind(s,63739)),Promise.resolve().then(s.bind(s,33976)),Promise.resolve().then(s.bind(s,12537)),Promise.resolve().then(s.bind(s,97485)),Promise.resolve().then(s.bind(s,41923)),Promise.resolve().then(s.bind(s,73868)),Promise.resolve().then(s.bind(s,53511)),Promise.resolve().then(s.bind(s,2018)),Promise.resolve().then(s.bind(s,18487)),Promise.resolve().then(s.bind(s,98346)),Promise.resolve().then(s.bind(s,14884)),Promise.resolve().then(s.bind(s,85314)),Promise.resolve().then(s.bind(s,17280)),Promise.resolve().then(s.bind(s,8855)),Promise.resolve().then(s.bind(s,86631)),Promise.resolve().then(s.bind(s,2604)),Promise.resolve().then(s.bind(s,27237)),Promise.resolve().then(s.bind(s,49455)),Promise.resolve().then(s.bind(s,39211)),Promise.resolve().then(s.bind(s,56360)),Promise.resolve().then(s.t.bind(s,54400,23))},5270:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},16329:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]])},23262:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]])},30441:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]])},33125:(e,t,s)=>{"use strict";s.d(t,{RootViewer:()=>F});var r=s(4624),n=s(99356),a=s(69285),i=s(49411),l=s(56221),c=s(80192),o=s(43504),d=s(28310),m=s(25167),x=s(7911);let u=(0,x.createServerReference)("60639f3697085c35e2964e17e9225ebbe783ca7936",x.callServer,void 0,x.findSourceMapURL,"readKbFileAction");var h=s(8190),p=s(45804);let y=(0,p.A)("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);var v=s(16329);let f=(0,p.A)("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),g=(0,p.A)("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]),b=(0,p.A)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]),j=(0,p.A)("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);var k=s(39783),N=s(58726),w=s(72691),A=s(5270);let P=(0,p.A)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);var E=s(13506);function C(e){let{kind:t,data:s}=e,n=(null!=t?t:"").toLowerCase();return"task"===n?(0,r.jsx)(L,{data:s}):"meeting"===n?(0,r.jsx)(_,{data:s}):"product"===n?(0,r.jsx)(z,{data:s}):"fact"===n?(0,r.jsx)(B,{data:s}):(0,r.jsx)(M,{data:s})}let S=new Set(["title","version","date","kind"]);function M(e){let{data:t}=e,s=Object.entries(t).filter(e=>{let[t]=e;return!S.has(t)});return 0===s.length?null:(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-1.5",children:s.map(e=>{let[t,s]=e;return(0,r.jsxs)(d.E,{variant:"outline",className:"font-mono text-[10px]",children:[(0,r.jsxs)("span",{className:"text-muted-foreground mr-1",children:[t,":"]}),(0,r.jsx)("span",{className:"truncate max-w-[16rem]",children:function e(t){if(null==t)return"";if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t)return String(t);if(Array.isArray(t))return t.map(t=>e(t)).join(", ");try{return JSON.stringify(t)}catch(e){return String(t)}}(s)})]},t)})})}function L(e){var t;let{data:s}=e,n=(0,i.c)("roots"),a=R(s.status),l=R(s.priority),c=null!=(t=R(s.due))?t:R(s.due_date),o=R(s.assignee),m=U(s.tags);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[a&&(0,r.jsxs)(d.E,{className:(0,E.cn)("gap-1 capitalize",function(e){let t=e.toLowerCase();return"done"===t?"bg-emerald-600 text-white":"doing"===t||"in_progress"===t?"bg-blue-600 text-white":"blocked"===t||"cancelled"===t?"bg-destructive text-destructive-foreground":"paused"===t?"bg-amber-600 text-white":"bg-secondary text-secondary-foreground"}(a)),children:[(0,r.jsx)(H,{status:a}),a]}),l&&(0,r.jsxs)(d.E,{variant:"outline",className:(0,E.cn)("gap-1 capitalize",function(e){let t=e.toLowerCase();return"high"===t||"p0"===t||"urgent"===t?"border-destructive text-destructive":"med"===t||"medium"===t||"p1"===t?"border-amber-600 text-amber-700":"border-muted-foreground text-muted-foreground"}(l)),children:[(0,r.jsx)(y,{className:"h-3 w-3"}),l]}),c&&(0,r.jsxs)(d.E,{variant:"secondary",className:"gap-1",children:[(0,r.jsx)(v.A,{className:"h-3 w-3"}),n("entityBadges.dueLabel",{date:c})]}),o&&(0,r.jsxs)(d.E,{variant:"outline",className:"gap-1",children:[(0,r.jsx)(f,{className:"h-3 w-3"}),o]}),null==m?void 0:m.map(e=>(0,r.jsxs)(d.E,{variant:"secondary",className:"gap-1",children:[(0,r.jsx)(g,{className:"h-3 w-3"}),e]},e))]})}function _(e){var t;let{data:s}=e,n=(0,i.c)("roots"),a=U(s.attendees),l=U(s.decisions),c=null!=(t=U(s.action_items))?t:U(s.actionItems);return(0,r.jsxs)("div",{className:"space-y-2",children:[a&&a.length>0&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.jsx)(b,{className:"h-3.5 w-3.5 text-muted-foreground"}),a.map(e=>(0,r.jsxs)(d.E,{variant:"outline",className:"gap-1",children:[(0,r.jsx)(f,{className:"h-3 w-3"})," ",e]},e))]}),l&&l.length>0&&(0,r.jsx)(I,{title:n("entityBadges.decisionsTitle"),items:l}),c&&c.length>0&&(0,r.jsx)(I,{title:"Action items",items:c})]})}function z(e){var t;let{data:s}=e,n=(0,i.c)("roots"),a=R(s.sku),l=s.price,c=R(s.currency),o=R(s.vendor),m=R(s.url),x=U(s.tags);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[null!=l&&""!==l&&(0,r.jsxs)(d.E,{className:"bg-emerald-600 text-white",children:["number"==typeof(t=l)?t.toLocaleString():"string"==typeof t?t:String(t),c?" ".concat(c):""]}),a&&(0,r.jsxs)(d.E,{variant:"outline",className:"gap-1 font-mono",children:[(0,r.jsx)(j,{className:"h-3 w-3"})," ",a]}),o&&(0,r.jsx)(d.E,{variant:"secondary",className:"gap-1",children:o}),m&&(0,r.jsxs)("a",{href:m,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary underline-offset-2 hover:underline",children:[(0,r.jsx)(k.A,{className:"h-3 w-3"}),n("entityBadges.openLink")]}),null==x?void 0:x.map(e=>(0,r.jsxs)(d.E,{variant:"outline",className:"gap-1",children:[(0,r.jsx)(g,{className:"h-3 w-3"})," ",e]},e))]})}function B(e){let{data:t}=e,s=(0,i.c)("roots"),n=U(t.tags),a=R(t.source);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[null==n?void 0:n.map(e=>(0,r.jsxs)(d.E,{variant:"secondary",className:"gap-1",children:[(0,r.jsx)(g,{className:"h-3 w-3"})," ",e]},e)),a&&(0,r.jsxs)(d.E,{variant:"outline",className:"gap-1 max-w-[24rem]",children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:s("entityBadges.sourceLabel")}),(0,r.jsx)("span",{className:"truncate",children:a})]})]})}function I(e){let{title:t,items:s}=e;return(0,r.jsxs)("div",{className:"rounded-md border bg-muted/30 p-2",children:[(0,r.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:t}),(0,r.jsx)("ul",{className:"space-y-0.5 text-sm",children:s.map((e,t)=>(0,r.jsxs)("li",{className:"leading-snug",children:["• ",e]},t))})]})}function H(e){let{status:t}=e,s=t.toLowerCase();return"done"===s?(0,r.jsx)(N.A,{className:"h-3 w-3"}):"doing"===s||"in_progress"===s?(0,r.jsx)(w.A,{className:"h-3 w-3"}):"blocked"===s||"cancelled"===s?(0,r.jsx)(A.A,{className:"h-3 w-3"}):"paused"===s?(0,r.jsx)(P,{className:"h-3 w-3"}):(0,r.jsx)(y,{className:"h-3 w-3"})}function R(e){return"string"==typeof e&&e.trim()?e:"number"==typeof e?String(e):void 0}function U(e){if(!Array.isArray(e))return;let t=e.map(e=>"string"==typeof e?e:null==e?"":String(e)).filter(e=>e.trim());return t.length>0?t:void 0}var q=s(9355);function F(e){var t,s;let{files:d,rootId:x,rootPath:p,initialFile:y}=e,v=(0,i.c)("roots"),f=(()=>{let e=new Map;for(let t of d)e.set(t.rel,t);return e})(),g=null!=(s=y&&f.has(y)?y:f.has("INDEX.md")?"INDEX.md":null==(t=d[0])?void 0:t.rel)?s:null,[b,j]=(0,n.useState)(g),[k,N]=(0,n.useState)(""),[w,A]=(0,n.useState)(null),[P,E]=(0,n.useTransition)(),C=(0,a.useRouter)();return(0,n.useEffect)(()=>{y&&f.has(y)&&j(y)},[y]),(0,n.useEffect)(()=>{b&&E(async()=>{let e=await u(x,b);if(e.ok)N(e.content),A(e.meta);else{var t;N("# Error\n\n".concat(null!=(t=e.error)?t:"")),A(null)}})},[b,x]),(0,r.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,r.jsx)(c.F,{className:"flex-1 min-h-0",children:(0,r.jsxs)("article",{className:"mx-auto max-w-3xl px-8 py-10",children:[b?P?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(o.E,{className:"h-8 w-3/5"}),(0,r.jsx)(o.E,{className:"h-4 w-full"}),(0,r.jsx)(o.E,{className:"h-4 w-11/12"}),(0,r.jsx)(o.E,{className:"h-4 w-4/5"})]}):(0,r.jsxs)(r.Fragment,{children:[w&&(0,r.jsx)(O,{meta:w,filename:b}),(0,r.jsx)(m.p,{source:function(e){if(!e.startsWith("---"))return e;let t=e.indexOf("\n---",3);return t<0?e:e.slice(t+4).replace(/^\r?\n/,"")}(k),onSendToChat:(e,t)=>{(async()=>{let s=v("kb.summaryContext",{url:t,text:e}),r=await (0,q.g)(x,s);if(!r.ok)return l.oR.error(r.error);C.push("/roots/".concat(x,"/chat/").concat(r.topicId))})()}})]}):(0,r.jsx)("p",{className:"text-muted-foreground",children:v("kb.selectFileHint")}),(0,r.jsxs)("div",{className:"mt-10 text-[11px] text-muted-foreground font-mono truncate",children:[p,"/.reflex/"]})]})}),(0,r.jsx)(h.CommandBar,{rootId:x,focusFile:null!=b?b:void 0})]})}function O(e){var t;let{meta:s,filename:n}=e;return s.title||void 0!==s.version||s.date||s.kind?(0,r.jsxs)("header",{className:"mb-6 pb-4 border-b space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-3 flex-wrap",children:[(0,r.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:null!=(t=s.title)?t:n}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.kind&&(0,r.jsx)(d.E,{variant:"default",className:"capitalize",children:s.kind}),void 0!==s.version&&(0,r.jsxs)(d.E,{variant:"outline",children:["v",s.version]}),s.date&&(0,r.jsx)("span",{className:"font-mono",children:s.date})]})]}),(0,r.jsx)(T,{createdBy:s.data.createdBy}),(0,r.jsx)(C,{kind:s.kind,data:s.data}),(0,r.jsx)("div",{className:"text-[11px] text-muted-foreground font-mono",children:n})]}):null}function T(e){let{createdBy:t}=e,s=(0,i.c)("roots");if("string"!=typeof t||!t)return null;let[n,a]=t.split(":",2);if(!n||!a)return null;let[l,c]=a.split("@",2),o="utility"===n?s("kb.createdMiniApp"):"workflow"===n?s("kb.createdWorkflow"):"agent"===n?s("kb.createdAgent"):n,d=(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border bg-violet-50 dark:bg-violet-950/30 px-2 py-0.5 text-[10px] text-violet-700 dark:text-violet-300",children:[(0,r.jsx)("span",{className:"text-[9px] uppercase tracking-wider text-muted-foreground",children:s("kb.createdLabel")}),(0,r.jsx)("span",{children:o}),(0,r.jsx)("code",{className:"font-mono",children:l}),c&&(0,r.jsxs)("span",{className:"font-mono text-muted-foreground",children:["v",c]})]});return"utility"===n&&l?(0,r.jsx)("a",{href:"/utilities/project/".concat(encodeURIComponent(l)),className:"inline-block hover:opacity-80",title:s("kb.openMiniApp"),children:d}):d}},39160:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]])},58726:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},59728:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},72691:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(45804).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])}},e=>{e.O(0,[4400,1217,9411,3335,5097,3954,8775,7529,5771,1226,4933,146,7358],()=>e(e.s=2046)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8138],{4959:(e,t,s)=>{"use strict";s.d(t,{BT:()=>l,Wu:()=>d,ZB:()=>o,Zp:()=>n,aR:()=>i,wL:()=>c});var a=s(4624);s(99356);var r=s(13506);function n(e){let{className:t,...s}=e;return(0,a.jsx)("div",{"data-slot":"card",className:(0,r.cn)("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",t),...s})}function i(e){let{className:t,...s}=e;return(0,a.jsx)("div",{"data-slot":"card-header",className:(0,r.cn)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...s})}function o(e){let{className:t,...s}=e;return(0,a.jsx)("div",{"data-slot":"card-title",className:(0,r.cn)("leading-none font-semibold",t),...s})}function l(e){let{className:t,...s}=e;return(0,a.jsx)("div",{"data-slot":"card-description",className:(0,r.cn)("text-sm text-muted-foreground",t),...s})}function d(e){let{className:t,...s}=e;return(0,a.jsx)("div",{"data-slot":"card-content",className:(0,r.cn)("px-6",t),...s})}function c(e){let{className:t,...s}=e;return(0,a.jsx)("div",{"data-slot":"card-footer",className:(0,r.cn)("flex items-center px-6 [.border-t]:pt-6",t),...s})}},23782:(e,t,s)=>{"use strict";s.d(t,{g:()=>r});var a=s(7911);let r=(0,a.createServerReference)("4031f583cc13c8f8da54a51e086ae1c1e27a7c0eac",a.callServer,void 0,a.findSourceMapURL,"installCuratedAction")},25113:(e,t,s)=>{"use strict";s.d(t,{B:()=>r});var a=s(7911);let r=(0,a.createServerReference)("00762c653a260fcc185bfc956595d97c73afce6e0b",a.callServer,void 0,a.findSourceMapURL,"listCuratedAction")},30549:(e,t,s)=>{"use strict";s.d(t,{j:()=>r});var a=s(7911);let r=(0,a.createServerReference)("70183e681a74dede1ee45c7f57b298d842bb8fc8bc",a.callServer,void 0,a.findSourceMapURL,"removeUtilityAction")},35984:(e,t,s)=>{Promise.resolve().then(s.bind(s,62952)),Promise.resolve().then(s.bind(s,85682)),Promise.resolve().then(s.bind(s,42163)),Promise.resolve().then(s.bind(s,8190)),Promise.resolve().then(s.bind(s,91062)),Promise.resolve().then(s.bind(s,64199)),Promise.resolve().then(s.bind(s,91074)),Promise.resolve().then(s.bind(s,96253)),Promise.resolve().then(s.bind(s,28050)),Promise.resolve().then(s.bind(s,94904)),Promise.resolve().then(s.bind(s,13270)),Promise.resolve().then(s.bind(s,99730)),Promise.resolve().then(s.bind(s,89146)),Promise.resolve().then(s.bind(s,19078)),Promise.resolve().then(s.bind(s,67854)),Promise.resolve().then(s.bind(s,69050)),Promise.resolve().then(s.bind(s,63739)),Promise.resolve().then(s.bind(s,33976)),Promise.resolve().then(s.bind(s,12537)),Promise.resolve().then(s.bind(s,97485)),Promise.resolve().then(s.bind(s,41923)),Promise.resolve().then(s.bind(s,73868)),Promise.resolve().then(s.bind(s,53511)),Promise.resolve().then(s.bind(s,2018)),Promise.resolve().then(s.bind(s,18487)),Promise.resolve().then(s.bind(s,98346)),Promise.resolve().then(s.bind(s,14884)),Promise.resolve().then(s.bind(s,85314)),Promise.resolve().then(s.bind(s,17280)),Promise.resolve().then(s.bind(s,8855)),Promise.resolve().then(s.bind(s,86631)),Promise.resolve().then(s.bind(s,2604)),Promise.resolve().then(s.bind(s,27237)),Promise.resolve().then(s.bind(s,49455)),Promise.resolve().then(s.bind(s,39211)),Promise.resolve().then(s.bind(s,56360)),Promise.resolve().then(s.t.bind(s,54400,23))},42163:(e,t,s)=>{"use strict";s.d(t,{AddUtilityButton:()=>S});var a=s(4624),r=s(99356),n=s(54400),i=s.n(n),o=s(69285),l=s(49411),d=s(39624),c=s(36059),m=s(13561),u=s(3239),x=s(39783),h=s(46972),p=s(43153),g=s(57751),f=s(56221),v=s(85253),j=s(25113),b=s(7911);let w=(0,b.createServerReference)("40f744cf7fbb3b1f5cc9979073d0edc24a1e01738e",b.callServer,void 0,b.findSourceMapURL,"checkUtilityUpdatesAction"),N=(0,b.createServerReference)("40480ed5a5a0eed48e526e507fa8e301ff544a0665",b.callServer,void 0,b.findSourceMapURL,"applyUtilityUpdateAction");var y=s(23782),k=s(30549),A=s(63514);function S(e){let{rootId:t,installed:s}=e,n=(0,l.c)("roots"),[b,S]=(0,r.useState)(!1),[C,R]=(0,r.useState)([]),[U,M]=(0,r.useState)(!1),[I,T]=(0,r.useState)(null),[D,E]=(0,r.useTransition)(),[P,L]=(0,r.useState)([]),z=(0,r.useRef)(null),W=(0,o.useRouter)(),F=new Set(s.map(e=>e.id)),Z=s.filter(e=>"project"===e.scope),$=new Map(P.map(e=>[e.id,e]));return(0,r.useEffect)(()=>{if(!b)return;let e=e=>{var t;(null==(t=z.current)?void 0:t.contains(e.target))||S(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[b]),(0,r.useEffect)(()=>{!b||C.length>0||U||(M(!0),(async()=>{try{let e=await (0,j.B)();R(e.items)}catch(e){f.oR.error(n("addUtility.loadCatalogFailed"))}finally{M(!1)}})())},[b,C.length,U]),(0,r.useEffect)(()=>{b&&0!==s.length&&(async()=>{let e=await w({rootId:t});e.ok&&L(e.updates)})()},[b,s.length,t]),(0,a.jsxs)("div",{className:"relative",ref:z,children:[(0,a.jsxs)(v.$,{type:"button",variant:"ghost",size:"sm",className:"gap-1",onClick:()=>S(e=>!e),title:n("addUtility.buttonTitle"),children:[(0,a.jsx)(d.A,{className:"h-4 w-4"}),n("addUtility.buttonLabel"),Z.length>0&&(0,a.jsx)("span",{className:"ml-1 text-[10px] rounded-full bg-violet-100 text-violet-700 px-1.5",children:Z.length}),P.length>0&&(0,a.jsxs)("span",{className:"ml-0.5 text-[10px] rounded-full bg-amber-100 text-amber-800 px-1.5 inline-flex items-center gap-0.5",title:n("addUtility.updatesTitle",{count:P.length}),children:[(0,a.jsx)(c.A,{className:"h-2.5 w-2.5"}),P.length]})]}),b&&(0,a.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-30 w-[440px] max-h-[75vh] overflow-y-auto rounded-lg border bg-popover shadow-lg",children:[(0,a.jsxs)("div",{className:"sticky top-0 bg-popover flex items-center gap-2 px-3 py-2 border-b",children:[(0,a.jsx)(d.A,{className:"h-3.5 w-3.5 text-violet-600"}),(0,a.jsx)("span",{className:"text-xs font-medium",children:n("addUtility.popoverTitle")}),(0,a.jsx)("button",{type:"button",onClick:()=>S(!1),className:"ml-auto p-0.5 rounded hover:bg-accent",children:(0,a.jsx)(m.A,{className:"h-3 w-3"})})]}),Z.length>0&&(0,a.jsxs)("section",{className:"p-2 border-b",children:[(0,a.jsx)("div",{className:"px-1 text-[10px] uppercase tracking-wider text-muted-foreground mb-1.5",children:n("addUtility.installedInProject")}),(0,a.jsx)("ul",{className:"space-y-1",children:Z.map(e=>{let s=$.get(e.id);return(0,a.jsxs)("li",{className:"flex items-center gap-1.5 rounded-md border bg-card px-2 py-1.5 text-xs",children:[(0,a.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"truncate font-medium",children:e.name}),s&&(0,a.jsxs)("div",{className:"text-[10px] text-amber-700 inline-flex items-center gap-0.5",children:[(0,a.jsx)(c.A,{className:"h-2.5 w-2.5"}),s.currentVersion," → ",s.latestVersion]})]}),s&&(0,a.jsxs)("button",{type:"button",onClick:()=>{T(s.id),E(async()=>{let e=await N({...s,rootId:t});if(T(null),!e.ok)return void f.oR.error(e.error);f.oR.success(n("addUtility.applyUpdateSuccess",{name:s.name,from:s.currentVersion,to:e.newVersion})),L(e=>e.filter(e=>e.id!==s.id)),(0,A.$d)(A.Zi.kbChanged(t)),W.refresh()})},disabled:D&&I===e.id,className:"text-[11px] rounded bg-amber-600 px-2 py-1 text-white hover:bg-amber-700 disabled:opacity-50 inline-flex items-center gap-0.5",title:n("addUtility.applyUpdateTitle"),children:[D&&I===e.id?(0,a.jsx)(u.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(c.A,{className:"h-3 w-3"}),n("addUtility.updateAction")]}),(0,a.jsx)(i(),{href:"/utilities/".concat(e.scope,"/").concat(e.id,"?rootId=").concat(encodeURIComponent(t)),className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground",title:n("addUtility.openAction"),children:(0,a.jsx)(x.A,{className:"h-3 w-3"})}),(0,a.jsx)("button",{type:"button",onClick:()=>{confirm(n("addUtility.removeConfirm",{name:e.name}))&&(T(e.id),E(async()=>{let s=await (0,k.j)(e.scope,e.id,"project"===e.scope?t:void 0);if(T(null),!s.ok){var a;f.oR.error(null!=(a=s.error)?a:n("addUtility.removeFailed"));return}f.oR.success(n("addUtility.removeSuccess",{name:e.name})),(0,A.$d)(A.Zi.kbChanged(t)),W.refresh()}))},disabled:D&&I===e.id,className:"p-1 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive disabled:opacity-50",title:n("addUtility.removeAction"),children:D&&I===e.id?(0,a.jsx)(u.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(h.A,{className:"h-3 w-3"})})]},e.id)})})]}),(0,a.jsxs)("section",{className:"p-2",children:[(0,a.jsx)("div",{className:"px-1 text-[10px] uppercase tracking-wider text-muted-foreground mb-1.5",children:n("addUtility.catalog")}),U?(0,a.jsxs)("div",{className:"px-2 py-4 text-xs text-muted-foreground flex items-center gap-1.5",children:[(0,a.jsx)(u.A,{className:"h-3 w-3 animate-spin"}),n("addUtility.loading")]}):0===C.length?(0,a.jsx)("p",{className:"px-2 py-4 text-xs text-muted-foreground",children:n("addUtility.catalogEmpty")}):(0,a.jsx)("ul",{className:"space-y-1",children:C.map(e=>{let s=F.has(e.id),r=I===e.id&&D;return(0,a.jsx)("li",{className:"rounded-md border bg-card px-2 py-2",children:(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)("span",{className:"text-xl leading-none",children:e.emoji}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"font-medium text-sm",children:e.name}),(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground leading-snug",children:e.description})]}),s?(0,a.jsxs)("span",{className:"text-[10px] text-emerald-700 inline-flex items-center gap-0.5",children:[(0,a.jsx)(p.A,{className:"h-3 w-3"})," ",n("addUtility.already")]}):(0,a.jsxs)("button",{type:"button",onClick:()=>{T(e.id),E(async()=>{var s;let a=null!=(s=e.suggestedScope)?s:"global",r=await (0,y.g)({github:e.github,scope:a,..."project"===a?{rootId:t}:{}});if(T(null),!r.ok)return void f.oR.error(r.error);f.oR.success(n("addUtility.installSuccess",{name:e.name})),(0,A.$d)(A.Zi.kbChanged(t)),W.refresh()})},disabled:r||D,className:"text-[11px] rounded bg-violet-600 px-2 py-1 text-white hover:bg-violet-700 disabled:opacity-50 inline-flex items-center gap-0.5",children:[r?(0,a.jsx)(u.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(g.A,{className:"h-3 w-3"}),n("addUtility.add")]})]})},e.id)})})]})]})]})}},64199:(e,t,s)=>{"use strict";s.d(t,{RunInitButton:()=>u});var a=s(4624),r=s(99356),n=s(3239),i=s(67805),o=s(56221),l=s(85253),d=s(7911);let c=(0,d.createServerReference)("70e9b527a1c007c4e0e0920d8024205bcd1f2b76e3",d.callServer,void 0,d.findSourceMapURL,"runInitAction");var m=s(63514);function u(e){let{rootPath:t,rootId:s}=e,[d,u]=(0,r.useTransition)();return(0,a.jsx)(l.$,{onClick:()=>u(async()=>{let e=o.oR.loading("Running agent — this can take a minute or two…"),a=await c(t,s,!1);if(o.oR.dismiss(e),a.ok)o.oR.success("Init complete"),(0,m.$d)(m.Zi.kbChanged(s)),(0,m.$d)(m.Zi.rootsChanged);else{var r;o.oR.error(null!=(r=a.error)?r:"Init failed")}}),disabled:d,children:d?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.A,{className:"mr-2 h-4 w-4 animate-spin"})," Running…"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.A,{className:"mr-2 h-4 w-4"})," Run init"]})})}},86154:(e,t,s)=>{"use strict";s.d(t,{p:()=>v});var a=s(4624),r=s(99356),n=s(56221),i=s(3239),o=s(85924),l=s(65714),d=s(46972),c=s(85253),m=s(4959),u=s(71651),x=s(13506),h=s(7911);let p=(0,h.createServerReference)("408f0923e17ad2beadac271aa8e0ee3266c9dc20b6",h.callServer,void 0,h.findSourceMapURL,"loadMemoryAction"),g=(0,h.createServerReference)("40393967edab75972198c3e3f689eb3b3d99027d00",h.callServer,void 0,h.findSourceMapURL,"saveMemoryFileAction"),f=(0,h.createServerReference)("4070e83977db4b680782d2f2fa1117a5d0d39d66bb",h.callServer,void 0,h.findSourceMapURL,"wipeMemoryAction");function v(e){let{scope:t,rootId:s,title:n,description:l,allowWipe:d}=e,[c,u]=(0,r.useState)([]),[x,h]=(0,r.useState)(!0),[g,f]=(0,r.useState)(null),v=(0,r.useCallback)(async()=>{h(!0);let e=await p(s?{scope:t,rootId:s}:{scope:t});if(h(!1),!e.ok)return void f(e.error);f(null),u(e.files)},[t,s]);return(0,r.useEffect)(()=>{v()},[v]),(0,a.jsxs)(m.Zp,{children:[(0,a.jsx)(m.aR,{children:(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(m.ZB,{className:"text-lg",children:n}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:l})]}),d&&c.length>0&&(0,a.jsx)(b,{scope:t,rootId:s,onWiped:v})]})}),(0,a.jsx)(m.Wu,{children:x?(0,a.jsxs)("div",{className:"text-sm text-muted-foreground flex items-center gap-2",children:[(0,a.jsx)(i.A,{className:"h-3 w-3 animate-spin"})," Loading…"]}):g?(0,a.jsxs)("p",{className:"text-sm text-destructive flex items-center gap-2",children:[(0,a.jsx)(o.A,{className:"h-3.5 w-3.5"}),g]}):(0,a.jsx)("div",{className:"space-y-4",children:c.map(e=>(0,a.jsx)(j,{snapshot:e,scope:t,rootId:s,onSaved:e=>u(t=>t.map(t=>t.file===e.file?e:t))},e.file))})})]})}function j(e){let{snapshot:t,scope:s,rootId:o,onSaved:d}=e,[m,h]=(0,r.useState)(t.content),[p,f]=(0,r.useTransition)();(0,r.useEffect)(()=>{h(t.content)},[t.content]);let v=m.trim(),j=v?v.split("\n").length:0,b=j>t.cap,w=j>.9*t.cap,N=m!==t.content;return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-sm font-semibold",children:t.file}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:t.description})]}),(0,a.jsxs)("span",{className:(0,x.cn)("text-xs tabular-nums",b?"text-destructive font-medium":w?"text-amber-600":"text-muted-foreground"),children:[j,"/",t.cap]})]}),(0,a.jsx)(u.T,{value:m,onChange:e=>h(e.target.value),rows:Math.min(t.cap+2,Math.max(3,j+1)),placeholder:"Empty",className:"font-mono text-xs"}),(0,a.jsx)("div",{className:"flex items-center justify-end gap-2",children:(0,a.jsxs)(c.$,{type:"button",size:"sm",variant:N?"default":"ghost",disabled:!N||p||b,onClick:()=>{if(b)return void n.oR.error("".concat(t.file," exceeds ").concat(t.cap,"-line cap (").concat(j,"). Trim before saving."));f(async()=>{let e=await g({scope:s,...o?{rootId:o}:{},file:t.file,content:v});if(!e.ok){var a;n.oR.error(null!=(a=e.error)?a:"Save failed");return}n.oR.success("Saved ".concat(t.file)),d({...t,content:v,lines:e.lines})})},children:[p?(0,a.jsx)(i.A,{className:"mr-1 h-3 w-3 animate-spin"}):(0,a.jsx)(l.A,{className:"mr-1 h-3 w-3"}),"Save"]})})]})}function b(e){let{scope:t,rootId:s,onWiped:i}=e,[o,l]=(0,r.useTransition)();return(0,a.jsxs)(c.$,{type:"button",size:"sm",variant:"ghost",disabled:o,onClick:()=>{confirm("Erase ALL memory at this scope? Cannot be undone.")&&l(async()=>{let e=await f(s?{scope:t,rootId:s}:{scope:t});if(!e.ok){var a;n.oR.error(null!=(a=e.error)?a:"Wipe failed");return}n.oR.success("Memory wiped"),await i()})},className:"text-destructive hover:text-destructive",children:[(0,a.jsx)(d.A,{className:"mr-1 h-3 w-3"}),"Wipe all"]})}},91062:(e,t,s)=>{"use strict";s.d(t,{Dashboard:()=>eC});var a=s(4624),r=s(99356),n=s(49411),i=s(3747),o=s(56221),l=s(85253),d=s(63514),c=s(54400),m=s.n(c),u=s(41234),x=s(3239),h=s(86790),p=s(28310),g=s(4959);function f(e){let{rootId:t,activeGoals:s,runningAgents:r}=e,i=(0,n.c)("roots"),o=s.length+r.length;return(0,a.jsxs)(g.Zp,{children:[(0,a.jsxs)(g.aR,{className:"pb-2 flex flex-row items-center justify-between space-y-0",children:[(0,a.jsxs)(g.ZB,{className:"text-sm flex items-center gap-2",children:[(0,a.jsx)(u.A,{className:"h-4 w-4 text-violet-600"}),i("activeGoals.title")]}),o>0&&(0,a.jsx)(p.E,{variant:"secondary",className:"text-[10px]",children:o})]}),(0,a.jsxs)(g.Wu,{className:"space-y-2",children:[0===o&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:i("activeGoals.empty")}),s.map(e=>(0,a.jsx)(m(),{href:"/roots/".concat(t,"/chat/").concat(e.topicId),className:"block rounded-md border bg-card hover:bg-accent/40 transition px-3 py-2",children:(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)(u.A,{className:"h-3.5 w-3.5 text-violet-600 mt-0.5 shrink-0"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium truncate flex-1 min-w-0",children:e.topicTitle}),e.running&&(0,a.jsx)(x.A,{className:"h-3 w-3 animate-spin text-violet-600 shrink-0"})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:e.goal}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1 text-[10px] text-muted-foreground",children:[(0,a.jsx)("span",{children:i("activeGoals.iterationLabel",{count:e.goalIterations})}),(0,a.jsx)("span",{children:"\xb7"}),(0,a.jsx)("span",{children:i("activeGoals.updatedLabel",{time:function(e,t){let s=Date.now()-Date.parse(e);if(!Number.isFinite(s)||s<0)return t("activeGoals.justNow");let a=Math.floor(s/6e4);if(a<1)return t("activeGoals.justNow");if(a<60)return t("activeGoals.minutesAgo",{count:a});let r=Math.floor(a/60);return r<24?t("activeGoals.hoursAgo",{count:r}):t("activeGoals.daysAgo",{count:Math.floor(r/24)})}(e.updatedAt,i)})})]})]})]})},e.topicId)),r.map(e=>(0,a.jsx)(m(),{href:"/roots/".concat(t,"/chat/").concat(e.topicId),className:"block rounded-md border bg-card hover:bg-accent/40 transition px-3 py-2",children:(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)(h.A,{className:"h-3.5 w-3.5 text-amber-600 mt-0.5 shrink-0"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium truncate flex-1 min-w-0",children:e.topicTitle}),(0,a.jsx)(x.A,{className:"h-3 w-3 animate-spin text-amber-600 shrink-0"}),(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground",children:i("activeGoals.agentRunning")})]})]})},e.topicId))]})]})}var v=s(85924),j=s(3024),b=s(59145),w=s(31108);function N(e){let{rootId:t,items:s}=e,r=(0,n.c)("roots");return(0,a.jsxs)(g.Zp,{children:[(0,a.jsxs)(g.aR,{className:"pb-2 flex flex-row items-center justify-between space-y-0",children:[(0,a.jsxs)(g.ZB,{className:"text-sm flex items-center gap-2",children:[(0,a.jsx)(v.A,{className:"h-4 w-4 text-amber-600"}),r("pendingApprovals.title")]}),s.length>0&&(0,a.jsx)(p.E,{variant:"secondary",className:"text-[10px]",children:s.length})]}),(0,a.jsxs)(g.Wu,{className:"space-y-2",children:[0===s.length&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:r("pendingApprovals.empty")}),s.map(e=>{var s;return(0,a.jsx)(m(),{href:"/roots/".concat(t,"/chat/").concat(e.topicId),className:"block rounded-md border bg-card hover:bg-accent/40 transition px-3 py-2",children:(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)(y,{kind:e.kind}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium truncate flex-1 min-w-0",children:e.summary}),(0,a.jsx)(p.E,{variant:"outline",className:"text-[10px] shrink-0",children:"permission"===(s=e.kind)?"permission":"question"===s?"question":"mcp-add"})]}),e.details&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:e.details}),(0,a.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-1",children:["topic ",e.topicId.slice(0,12)," \xb7 ",function(e,t){let s=Date.now()-Date.parse(e);if(!Number.isFinite(s)||s<0)return t("pendingApprovals.justNow");let a=Math.floor(s/6e4);if(a<1)return t("pendingApprovals.justNow");if(a<60)return t("pendingApprovals.minutesAgo",{count:a});let r=Math.floor(a/60);return r<24?t("pendingApprovals.hoursAgo",{count:r}):t("pendingApprovals.daysAgo",{count:Math.floor(r/24)})}(e.ts,r)]})]})]})},"".concat(e.kind,":").concat(e.requestId))})]})]})}function y(e){let{kind:t}=e,s="h-3.5 w-3.5 mt-0.5 shrink-0";return"permission"===t?(0,a.jsx)(j.A,{className:"".concat(s," text-rose-600")}):"question"===t?(0,a.jsx)(b.A,{className:"".concat(s," text-sky-600")}):(0,a.jsx)(w.A,{className:"".concat(s," text-emerald-600")})}var k=s(49623),A=s(7911);let S=(0,A.createServerReference)("601780e75ceed559c8c3f46cabdc0efdd8de394d18",A.callServer,void 0,A.findSourceMapURL,"readKbPreviewAction");function C(e){let{rootId:t,items:s}=e,i=(0,n.c)("roots"),[o,l]=(0,r.useState)({});return(0,r.useEffect)(()=>{let e=!1;return(async()=>{for(let a of s){if(o[a.rel])continue;let s=await S(t,a.rel);if(e)return;s.ok&&l(e=>({...e,[a.rel]:s.preview}))}})(),()=>{e=!0}},[t,s]),(0,a.jsxs)(g.Zp,{children:[(0,a.jsxs)(g.aR,{className:"pb-2 flex flex-row items-center justify-between space-y-0",children:[(0,a.jsxs)(g.ZB,{className:"text-sm flex items-center gap-2",children:[(0,a.jsx)(k.A,{className:"h-4 w-4 text-emerald-700"}),i("recentKb.title")]}),s.length>0&&(0,a.jsx)(p.E,{variant:"secondary",className:"text-[10px]",children:s.length})]}),(0,a.jsxs)(g.Wu,{className:"space-y-2",children:[0===s.length&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:i("recentKb.empty")}),s.map(e=>{var s;return(0,a.jsx)(m(),{href:"/roots/".concat(t,"/kb/").concat(e.rel.split("/").map(encodeURIComponent).join("/")),className:"block rounded-md border bg-card hover:bg-accent/40 transition px-3 py-2",children:(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)(k.A,{className:"h-3.5 w-3.5 mt-0.5 shrink-0 text-emerald-700"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium truncate flex-1 min-w-0",children:e.title}),e.kind&&(0,a.jsx)(p.E,{variant:"outline",className:"text-[10px] shrink-0",children:e.kind})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:null!=(s=o[e.rel])?s:e.rel}),(0,a.jsxs)("div",{className:"text-[10px] text-muted-foreground mt-1",children:[function(e,t){let s=Date.now()-Date.parse(e);if(!Number.isFinite(s)||s<0)return t("recentKb.justNow");let a=Math.floor(s/6e4);if(a<1)return t("recentKb.justNow");if(a<60)return t("recentKb.minutesAgo",{count:a});let r=Math.floor(a/60);return r<24?t("recentKb.hoursAgo",{count:r}):t("recentKb.daysAgo",{count:Math.floor(r/24)})}(e.modifiedAt,i)," \xb7 ",(0,a.jsx)("span",{className:"font-mono",children:e.rel})]})]})]})},e.rel)})]})]})}var R=s(69285),U=s(95046),M=s(8096),I=s(54207),T=s(95265),D=s(9355);function E(e){let{rootId:t,cache:s}=e,d=(0,n.c)("roots"),[c,m]=(0,r.useState)(s),[u,h]=(0,r.useTransition)(),f=(0,R.useRouter)(),v=c&&Date.now()-Date.parse(c.generatedAt)>864e5;return(0,a.jsxs)(g.Zp,{className:"lg:col-span-2",children:[(0,a.jsxs)(g.aR,{className:"pb-2 flex flex-row items-center justify-between space-y-0",children:[(0,a.jsxs)(g.ZB,{className:"text-sm flex items-center gap-2",children:[(0,a.jsx)(U.A,{className:"h-4 w-4 text-amber-500"}),d("aiSuggestions.title"),v&&(0,a.jsx)(p.E,{variant:"outline",className:"text-[10px]",children:d("aiSuggestions.stale")})]}),(0,a.jsxs)(l.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>{h(async()=>{try{let s=await fetch("/api/roots/".concat(t,"/suggestions"),{method:"POST",cache:"no-store"}),a=await s.json();if(!a.ok){var e;o.oR.error(null!=(e=a.error)?e:d("aiSuggestions.regenerateFailed"));return}a.cache&&m(a.cache)}catch(e){o.oR.error(e instanceof Error?e.message:String(e))}})},disabled:u,className:"gap-1 h-7 text-xs",children:[u?(0,a.jsx)(x.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(i.A,{className:"h-3 w-3"}),d("aiSuggestions.recompute")]})]}),(0,a.jsxs)(g.Wu,{className:"space-y-2",children:[!c&&!u&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:d("aiSuggestions.intro")}),c&&0===c.items.length&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:d("aiSuggestions.nothingUrgent")}),(0,a.jsx)("div",{className:"grid gap-2 md:grid-cols-2",children:null==c?void 0:c.items.map((e,s)=>(0,a.jsxs)("div",{className:"rounded-md border bg-card p-3 space-y-1.5",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)(M.A,{className:"h-3.5 w-3.5 text-amber-500 mt-0.5 shrink-0"}),(0,a.jsx)("p",{className:"text-sm font-medium leading-snug flex-1",children:e.title})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:e.why}),(0,a.jsx)(P,{rootId:t,item:e,router:f})]},s))}),c&&(0,a.jsx)("p",{className:"text-[10px] text-muted-foreground pt-1",children:d.rich("aiSuggestions.generatedAt",{time:function(e,t){let s=Date.now()-Date.parse(e);if(!Number.isFinite(s)||s<0)return t("aiSuggestions.justNow");let a=Math.floor(s/6e4);if(a<1)return t("aiSuggestions.justNow");if(a<60)return t("aiSuggestions.minutesAgo",{count:a});let r=Math.floor(a/60);return r<24?t("aiSuggestions.hoursAgo",{count:r}):t("aiSuggestions.daysAgo",{count:Math.floor(r/24)})}(c.generatedAt,d),model:c.model,code:e=>(0,a.jsx)("code",{className:"font-mono",children:e})})})]})]})}function P(e){let{rootId:t,item:s,router:i}=e,[c,u]=(0,r.useTransition)(),h=(0,n.c)("roots"),{action:p}=s;if("none"===p.kind)return null;if("open-topic"===p.kind&&p.target)return(0,a.jsx)(l.$,{asChild:!0,size:"sm",variant:"outline",className:"h-7 text-xs gap-1",children:(0,a.jsxs)(m(),{href:"/roots/".concat(t,"/chat/").concat(p.target),children:[(0,a.jsx)(I.A,{className:"h-3 w-3"}),p.label]})});if("open-kb"===p.kind&&p.target){let e=p.target.split("/").map(encodeURIComponent).join("/");return(0,a.jsx)(l.$,{asChild:!0,size:"sm",variant:"outline",className:"h-7 text-xs gap-1",children:(0,a.jsxs)(m(),{href:"/roots/".concat(t,"/kb/").concat(e),children:[(0,a.jsx)(I.A,{className:"h-3 w-3"}),p.label]})})}return"send-message"===p.kind&&p.target?(0,a.jsxs)(l.$,{type:"button",size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:()=>{u(async()=>{try{let s=await (0,D.g)(t,p.target,[],void 0);if(!s.ok){var e;o.oR.error(null!=(e=s.error)?e:h("aiSuggestions.sendFailed"));return}(0,d.$d)(d.Zi.topicsChanged(t)),i.push("/roots/".concat(t,"/chat/").concat(s.topicId))}catch(e){o.oR.error(e instanceof Error?e.message:String(e))}})},disabled:c,children:[c?(0,a.jsx)(x.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(T.A,{className:"h-3 w-3"}),p.label]}):null}var L=s(39624),z=s(71789),W=s(53732),F=s(43153),Z=s(13561);let $=(0,A.createServerReference)("40225ed2f118becb2355b22bc6a11bfcb93c1c0941",A.callServer,void 0,A.findSourceMapURL,"listSuggestionsAction"),O=(0,A.createServerReference)("40c22100ae289f0a92eddc5b89ee8040c3f310a038",A.callServer,void 0,A.findSourceMapURL,"approveSuggestionAction"),B=(0,A.createServerReference)("4082a58a874c84c27ec8610e0ecfd6cfea0d8fdcb6",A.callServer,void 0,A.findSourceMapURL,"rejectSuggestionAction");var K=s(13506);let G={utility:L.A,research:z.A,widget:W.A,goal:u.A,skill:M.A},H={utility:"text-emerald-600",research:"text-violet-600",widget:"text-blue-600",goal:"text-amber-600",skill:"text-pink-600"};function V(e){let{rootId:t}=e,s=(0,R.useRouter)(),[n,d]=(0,r.useState)([]),[c,m]=(0,r.useState)(!0),[u,h]=(0,r.useState)({}),[f,v]=(0,r.useTransition)(),j=(0,r.useCallback)(async()=>{let e=await $(t);m(!1),e.ok&&d(e.items)},[t]);return((0,r.useEffect)(()=>{j()},[j]),(0,r.useEffect)(()=>{let e=window.setInterval(()=>{"visible"===document.visibilityState&&j()},3e4);return()=>window.clearInterval(e)},[j]),c||0===n.length)?null:(0,a.jsxs)(g.Zp,{children:[(0,a.jsxs)(g.aR,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)(g.ZB,{className:"text-lg flex items-center gap-2",children:[(0,a.jsx)(U.A,{className:"h-4 w-4 text-amber-500"}),"Suggestions",(0,a.jsx)(p.E,{variant:"secondary",className:"ml-1",children:n.length})]}),(0,a.jsxs)(l.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>v(()=>j()),disabled:f,className:"h-7 gap-1",children:[(0,a.jsx)(i.A,{className:(0,K.cn)("h-3 w-3",f&&"animate-spin")}),"Refresh"]})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Hypotheses the agent put together from the onboarding chat. Approve to start a topic; dismiss to drop it (and remember you said no)."})]}),(0,a.jsx)(g.Wu,{className:"space-y-2",children:n.map(e=>{var r;let n=null!=(r=G[e.kind])?r:U.A,i=u[e.id];return(0,a.jsxs)("div",{className:"flex items-start gap-3 rounded-md border p-3",children:[(0,a.jsx)(n,{className:(0,K.cn)("h-4 w-4 mt-1 shrink-0",H[e.kind])}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-baseline gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"font-medium text-sm",children:e.title}),(0,a.jsx)(p.E,{variant:"outline",className:"text-[10px]",children:e.kind})]}),e.description&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1 leading-snug",children:e.description}),e.prompt&&(0,a.jsx)("code",{className:"block mt-1 text-[10px] font-mono text-muted-foreground/70 truncate",children:e.prompt})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,a.jsxs)(l.$,{type:"button",size:"sm",variant:"default",disabled:!!i,onClick:()=>{h(t=>({...t,[e.id]:"approve"})),(async()=>{let a=await O({rootId:t,suggestionId:e.id});if(h(t=>({...t,[e.id]:null})),!a.ok){var r;o.oR.error(null!=(r=a.error)?r:"Failed to start topic");return}o.oR.success("Started: ".concat(e.title)),d(t=>t.filter(t=>t.id!==e.id)),s.push("/roots/".concat(t,"/chat/").concat(a.topicId))})()},className:"h-8 gap-1",children:["approve"===i?(0,a.jsx)(x.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(F.A,{className:"h-3 w-3"}),"Approve"]}),(0,a.jsxs)(l.$,{type:"button",size:"sm",variant:"ghost",disabled:!!i,onClick:()=>{h(t=>({...t,[e.id]:"reject"})),(async()=>{let s=await B({rootId:t,suggestionId:e.id});if(h(t=>({...t,[e.id]:null})),!s.ok){var a;o.oR.error(null!=(a=s.error)?a:"Failed to reject");return}o.oR.success("Dismissed: ".concat(e.title)),d(t=>t.filter(t=>t.id!==e.id))})()},className:"h-8 gap-1 text-muted-foreground hover:text-destructive",children:["reject"===i?(0,a.jsx)(x.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(Z.A,{className:"h-3 w-3"}),"Dismiss"]})]})]},e.id)})})]})}var _=s(86154),q=s(93305),J=s(41379);let Q=(0,A.createServerReference)("60b28a842c18130eadecdb4119dd7a552ca5df7f7f",A.callServer,void 0,A.findSourceMapURL,"saveWidgetOrderAction"),X=(0,A.createServerReference)("606963888f6e3319570ad4f6200d011dc7f37f6367",A.callServer,void 0,A.findSourceMapURL,"hideWidgetAction"),Y={sm:2,md:3,wide:6},ee=["sys:active-goals","sys:pending","sys:recent-kb","sys:ai-suggestions"],et=[{id:"sys:active-goals",title:"Active goals & running agents",description:"Topics with an active /goal and a running orchestrator."},{id:"sys:pending",title:"Awaiting response",description:"Unanswered permission / question / mcp-add cards."},{id:"sys:recent-kb",title:"Recent in KB",description:"KB files modified in the last 72 hours."},{id:"sys:ai-suggestions",title:"What's next — Reflex suggestions",description:"Gemini-driven analysis of project state with actions."}],es=(0,A.createServerReference)("704ba870883e58e28e970348621c46d73ae73faafc",A.callServer,void 0,A.findSourceMapURL,"setWidgetSizeAction"),ea=[{mode:"sm",label:"S",titleKey:"widgetsCommon.sizeSm"},{mode:"md",label:"M",titleKey:"widgetsCommon.sizeMd"},{mode:"wide",label:"W",titleKey:"widgetsCommon.sizeWide"}];function er(e){let{rootId:t,widgetId:s,mode:i,onChanged:l}=e,d=(0,n.c)("roots"),[c,m]=(0,r.useTransition)();return(0,a.jsx)("div",{role:"radiogroup","aria-label":d("widgetsCommon.sizeAria"),className:"inline-flex items-center rounded border bg-background/80 backdrop-blur overflow-hidden text-[10px] leading-none",children:ea.map(e=>{let r=e.mode===i,n="sm"===e.mode?d("widgetsCommon.sizeSm"):"md"===e.mode?d("widgetsCommon.sizeMd"):d("widgetsCommon.sizeWide");return(0,a.jsx)("button",{type:"button",role:"radio","aria-checked":r,"aria-label":n,title:n,onClick:()=>{var a;(a=e.mode)!==i&&m(async()=>{let e=await es(t,s,a);if(!e.ok){var r;o.oR.error(null!=(r=e.error)?r:d("widgetsCommon.sizeFailed"));return}l()})},disabled:c,className:["px-1.5 py-0.5 font-mono transition-colors disabled:opacity-50",r?"bg-violet-600 text-white":"text-muted-foreground hover:bg-accent hover:text-foreground"].join(" "),children:e.label},e.mode)})})}function en(e){let t=Y[e];return 2===t?"lg:col-span-2":3===t?"lg:col-span-3":"lg:col-span-6"}var ei=s(73600),eo=s(76974),el=s(72691),ed=s(22841),ec=s(40963);let em=(0,A.createServerReference)("7816722a497c7ee46567b47ccbf042bfb2db815cfb",A.callServer,void 0,A.findSourceMapURL,"patchWidgetDataAction"),eu=(0,A.createServerReference)("7058f2f89be65f75b1bfda7d6c635c9d4aad6fdce3",A.callServer,void 0,A.findSourceMapURL,"setWidgetRefreshAction"),ex=(0,A.createServerReference)("601a08138cfb8c8ef4bcb0f2156316aff898e8ef03",A.callServer,void 0,A.findSourceMapURL,"refreshWidgetNowAction");function eh(e){let{rootId:t,widget:s,mode:i,onHide:l,hiding:d,onLayoutChanged:c,dnd:u}=e,x=(0,n.c)("roots"),[h,f]=(0,r.useTransition)(),v=u.dragging===s.id,j=u.dropTarget===s.id&&!v,b=en(i);return(0,a.jsxs)(g.Zp,{draggable:!0,onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",s.id),u.onDragStart(s.id)},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",u.dropTarget!==s.id&&u.onDragOver(s.id)},onDrop:e=>{e.preventDefault(),u.onDrop(s.id)},onDragEnd:()=>u.onDragEnd(),className:[b,"transition-all",v?"opacity-50":"",j?"ring-2 ring-violet-400 ring-offset-2 ring-offset-background":""].join(" "),children:[(0,a.jsxs)(g.aR,{className:"pb-2 flex flex-row items-start gap-2 space-y-0",children:[(0,a.jsx)(ei.A,{className:"h-3.5 w-3.5 text-muted-foreground/60 cursor-grab active:cursor-grabbing mt-1 shrink-0","aria-label":x("widgetsCommon.dragHandle")}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)(g.ZB,{className:"text-sm flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"truncate",children:s.title}),(0,a.jsx)(p.E,{variant:"outline",className:"text-[10px] font-mono shrink-0",children:s.kind})]}),s.description&&(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground mt-0.5 line-clamp-2",children:s.description})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 -mt-0.5 shrink-0",children:[(0,a.jsx)(er,{rootId:t,widgetId:s.id,mode:i,onChanged:c}),s.sourceTopicId&&(0,a.jsx)(m(),{href:"/roots/".concat(t,"/chat/").concat(s.sourceTopicId),className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground","aria-label":x("widgetsCommon.editViaTopicAria"),title:x("widgetsCommon.editViaTopicTitle"),children:(0,a.jsx)(eo.A,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("button",{type:"button",onClick:()=>f(async()=>{await Promise.resolve(),l(s.id)}),disabled:h||d,"aria-label":x("widgetsCommon.hideAria"),title:x("widgetsCommon.hideTitle"),className:"p-1 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive",children:(0,a.jsx)(Z.A,{className:"h-3.5 w-3.5"})})]})]}),(0,a.jsxs)(g.Wu,{className:"space-y-3",children:[(0,ec.v)(t,s.kind,s.data,{onPatch:async e=>{let a=await em(t,s.id,e);if(!a.ok){var r,n;throw o.oR.error(null!=(r=a.error)?r:x("widgetsCommon.savePatchFailed")),Error(null!=(n=a.error)?n:x("widgetsCommon.patchFailed"))}}}),(0,a.jsx)(ep,{rootId:t,widget:s})]})]})}function ep(e){var t,s;let{rootId:l,widget:d}=e,c=(0,n.c)("roots"),[m,u]=(0,r.useTransition)(),[x,h]=(0,r.useTransition)(),p=null!=(t=d.refresh)?t:"manual",g=null!=(s=d.lastRefreshAt)?s:d.updatedAt;return d.sourceTopicId?(0,a.jsxs)("div",{className:"flex items-center gap-2 pt-2 border-t text-[11px] text-muted-foreground",children:[(0,a.jsx)(el.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{className:"shrink-0",children:c("widgetsCommon.updatedAt",{time:function(e,t){let s=Date.now()-Date.parse(e);if(!Number.isFinite(s)||s<0)return t("widgetsCommon.justNow");let a=Math.floor(s/6e4);if(a<1)return t("widgetsCommon.justNow");if(a<60)return t("widgetsCommon.minutesAgo",{count:a});let r=Math.floor(a/60);return r<24?t("widgetsCommon.hoursAgo",{count:r}):t("widgetsCommon.daysAgo",{count:Math.floor(r/24)})}(g,c)})}),(0,a.jsxs)("div",{className:"ml-auto flex items-center gap-1.5 shrink-0",children:[(0,a.jsxs)(ed.l6,{value:p,onValueChange:e=>{h(async()=>{var t,s;let a=await eu(l,d.id,e);a.ok?o.oR.success("manual"===e?c("widgetsCommon.autoRefreshOff"):c("widgetsCommon.cadenceSet",{cadence:(s=e,c("hourly"===s?"widgetsCommon.cadenceHourly":"daily"===s?"widgetsCommon.cadenceDaily":"weekly"===s?"widgetsCommon.cadenceWeekly":"widgetsCommon.cadenceManual"))})):o.oR.error(null!=(t=a.error)?t:c("widgetsCommon.cadenceFailed"))})},disabled:x,children:[(0,a.jsx)(ed.bq,{className:"h-6 text-[10px] gap-1 px-1.5 w-auto min-w-[110px]",children:(0,a.jsx)(ed.yv,{})}),(0,a.jsxs)(ed.gC,{children:[(0,a.jsx)(ed.eb,{value:"manual",children:c("widgetsCommon.manual")}),(0,a.jsx)(ed.eb,{value:"hourly",children:c("widgetsCommon.hourly")}),(0,a.jsx)(ed.eb,{value:"daily",children:c("widgetsCommon.daily")}),(0,a.jsx)(ed.eb,{value:"weekly",children:c("widgetsCommon.weekly")})]})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{u(async()=>{var e;let t=await ex(l,d.id);t.ok?o.oR.success(c("widgetsCommon.refreshStarted")):o.oR.error(null!=(e=t.error)?e:c("widgetsCommon.refreshFailed"))})},disabled:m,className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 hover:bg-accent text-foreground/80 hover:text-foreground",title:c("widgetsCommon.refreshNowTitle"),children:[(0,a.jsx)(i.A,{className:"h-3 w-3 ".concat(m?"animate-spin":"")}),c("widgetsCommon.refreshLabel")]})]})]}):null}var eg=s(84784),ef=s(41280),ev=s(46972),ej=s(80192),eb=s(24678);let ew=(0,A.createServerReference)("60282be6932af53a90211fb957c579a15c6bdc434e",A.callServer,void 0,A.findSourceMapURL,"deleteWidgetAction");function eN(e){let{rootId:t,open:s,onOpenChange:i,widgets:o,layout:d,onChanged:c}=e,m=(0,n.c)("roots");if((0,r.useEffect)(()=>{if(!s)return;let e=e=>{"Escape"===e.key&&i(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s,i]),!s)return null;let u=new Set(d.hidden);return(0,a.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:e=>{e.target===e.currentTarget&&i(!1)},children:[(0,a.jsx)("div",{"aria-hidden":!0,className:"absolute inset-0 bg-background/80 backdrop-blur-sm",onClick:()=>i(!1)}),(0,a.jsxs)("div",{className:"relative bg-card border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 border-b",children:[(0,a.jsx)(q.A,{className:"h-4 w-4 text-violet-600"}),(0,a.jsx)("h2",{className:"text-sm font-medium flex-1",children:m("widgetsCommon.libraryTitle")}),(0,a.jsx)(l.$,{type:"button",size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>i(!1),children:(0,a.jsx)(Z.A,{className:"h-4 w-4"})})]}),(0,a.jsx)(ej.F,{className:"flex-1 min-h-0",children:(0,a.jsxs)("div",{className:"p-4 space-y-4",children:[(0,a.jsxs)("section",{className:"space-y-2",children:[(0,a.jsx)("h3",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:m("widgetsCommon.systemWidgetsHeading")}),et.map(e=>(0,a.jsx)(ey,{rootId:t,id:e.id,title:e.title,description:e.description,badge:"system",badgeVariant:"default",hidden:u.has(e.id),canDelete:!1,onChanged:c},e.id))]}),(0,a.jsxs)("section",{className:"space-y-2",children:[(0,a.jsx)("h3",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:m("widgetsCommon.userWidgetsHeading",{count:o.length})}),0===o.length&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:m("widgetsCommon.noUserWidgets")}),o.map(e=>{var s;return(0,a.jsx)(ey,{rootId:t,id:e.id,title:e.title,description:null!=(s=e.description)?s:"kind: ".concat(e.kind),badge:e.kind,badgeVariant:"outline",hidden:u.has(e.id),canDelete:!0,onChanged:c},e.id)})]})]})})]})]})}function ey(e){let{rootId:t,id:s,title:i,description:d,badge:c,badgeVariant:m,hidden:u,canDelete:x,onChanged:h}=e,g=(0,n.c)("roots"),[f,v]=(0,r.useTransition)();return(0,a.jsxs)("div",{className:"flex items-start gap-3 rounded-md border bg-card px-3 py-2",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"text-sm font-medium truncate",children:i}),(0,a.jsx)(p.E,{variant:m,className:"text-[10px] font-mono",children:c}),u&&(0,a.jsx)(p.E,{variant:"secondary",className:"text-[10px]",children:g("widgetsCommon.hidden")})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:d})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,a.jsx)(l.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>{v(async()=>{let e=u?await (0,eb.t)(t,s):await X(t,s);if(!e.ok)return void o.oR.error(e.error);h()})},disabled:f,className:"gap-1 h-7 text-xs",children:u?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eg.A,{className:"h-3 w-3"}),g("widgetsCommon.show")]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ef.A,{className:"h-3 w-3"}),g("widgetsCommon.hide")]})}),x&&(0,a.jsx)(l.$,{type:"button",size:"icon",variant:"ghost",onClick:()=>{confirm(g("widgetsCommon.deleteWidgetConfirm",{title:i}))&&v(async()=>{let e=await ew(t,s);if(!e.ok)return void o.oR.error(e.error);h()})},disabled:f,className:"h-7 w-7 text-muted-foreground hover:text-destructive",title:g("widgetsCommon.deleteForever"),children:(0,a.jsx)(ev.A,{className:"h-3.5 w-3.5"})})]})]})}function ek(e){let{rootId:t,widgets:s,layout:i,systemRenderers:d,snapshot:c,onLayoutChanged:m}=e,u=(0,n.c)("roots"),x=(0,r.useMemo)(()=>{let e=new Map;for(let t of s)e.set(t.id,t);return e},[s]),[h,p]=(0,r.useState)(i.order),[g,f]=(0,r.useState)(i.hidden),[,v]=(0,r.useTransition)(),[j,b]=(0,r.useState)(null),[w,N]=(0,r.useState)(null),[y,k]=(0,r.useState)(!1);eS(i.order,p),eS(i.hidden,f);let A=(0,r.useCallback)(e=>{p(e),v(async()=>{let s=await Q(t,e);s.ok?(p(s.layout.order),f(s.layout.hidden),m()):o.oR.error(s.error)})},[t,m]),S=(0,r.useCallback)(e=>{p(h.filter(t=>t!==e)),f(t=>[...new Set([e,...t])]),v(async()=>{let s=await X(t,e);if(!s.ok)return void o.oR.error(s.error);p(s.layout.order),f(s.layout.hidden),m()})},[t,h,m]),C={onDragStart:e=>b(e),onDragOver:e=>N(e),onDrop:e=>{if(b(null),N(null),!j||j===e)return;let t=[...h],s=t.indexOf(j),a=t.indexOf(e);s<0||a<0||(t.splice(s,1),t.splice(a,0,j),A(t))},onDragEnd:()=>{b(null),N(null)},dragging:j,dropTarget:w};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:u("widgetsCommon.projectWidgetsTitle")}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:u("widgetsCommon.projectWidgetsHint")})]}),(0,a.jsxs)(l.$,{type:"button",size:"sm",variant:"outline",onClick:()=>k(!0),className:"gap-1 h-8",children:[(0,a.jsx)(q.A,{className:"h-3.5 w-3.5"}),u("widgetsCommon.library",{count:g.length})]})]}),0===h.length&&(0,a.jsxs)("div",{className:"rounded-md border border-dashed bg-muted/20 p-6 text-center space-y-2",children:[(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:u.rich("widgetsCommon.emptyDashboard",{example:()=>(0,a.jsx)("em",{children:u("widgetsCommon.emptyDashboardExample")})})}),(0,a.jsxs)(l.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>k(!0),className:"gap-1",children:[(0,a.jsx)(J.A,{className:"h-3 w-3"}),u("widgetsCommon.restoreSystem")]})]}),(0,a.jsx)("div",{className:"grid grid-cols-1 lg:grid-cols-6 gap-4",children:h.map(e=>{var s,r;let n=x.get(e),o=null==(s=i.sizes)?void 0:s[e],l=null!=o?o:(null==(r=null==n?void 0:n.size)?void 0:r.mode)?r.mode:(null==r?void 0:r.cols)===1?"sm":(null==r?void 0:r.cols)===2?"md":(null==r?void 0:r.cols)===3?"wide":"md";return ee.includes(e)?(0,a.jsx)(eA,{rootId:t,id:e,node:d[e],onHide:S,dnd:C,mode:l,onLayoutChanged:m},e):n?(0,a.jsx)(eh,{rootId:t,widget:n,mode:l,onHide:S,hiding:!1,dnd:C,onLayoutChanged:m},e):null})}),(0,a.jsx)(eN,{open:y,onOpenChange:k,rootId:t,widgets:s,layout:{order:h,hidden:g},onChanged:()=>{m()}})]})}function eA(e){let{rootId:t,id:s,node:r,onHide:i,dnd:o,mode:l,onLayoutChanged:d}=e,c=(0,n.c)("roots"),m=o.dragging===s,u=o.dropTarget===s&&!m,x=en(l);return(0,a.jsxs)("div",{draggable:!0,onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",s),o.onDragStart(s)},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",o.dropTarget!==s&&o.onDragOver(s)},onDrop:e=>{e.preventDefault(),o.onDrop(s)},onDragEnd:()=>o.onDragEnd(),className:[x,"relative group/sys transition-all",m?"opacity-50":"",u?"ring-2 ring-violet-400 ring-offset-2 ring-offset-background rounded-lg":""].join(" "),children:[r,(0,a.jsxs)("div",{className:"absolute top-2 right-2 opacity-0 group-hover/sys:opacity-100 transition-opacity flex items-center gap-1 bg-background/85 backdrop-blur rounded p-0.5",children:[(0,a.jsx)(er,{rootId:t,widgetId:s,mode:l,onChanged:d}),(0,a.jsx)("button",{type:"button",onClick:()=>i(s),"aria-label":c("widgetsCommon.hideAria"),title:c("widgetsCommon.hideSystemTitle"),className:"p-1 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive",children:"\xd7"})]})]})}function eS(e,t){(0,r.useMemo)(()=>{t(e)},[JSON.stringify(e)])}function eC(e){let{rootId:t,initialSnapshot:s}=e,c=(0,n.c)("roots"),[m,u]=(0,r.useState)(s),[x,h]=(0,r.useTransition)(),p=(0,r.useCallback)(()=>{h(async()=>{try{let s=await fetch("/api/roots/".concat(t,"/dashboard"),{cache:"no-store"}),a=await s.json();if(!a.ok||!a.snapshot){var e;o.oR.error(null!=(e=a.error)?e:c("dashboard.refreshFailed"));return}u(a.snapshot)}catch(e){o.oR.error(e instanceof Error?e.message:String(e))}})},[t,c]);(0,d.S9)(d.Zi.topicsChanged(t),p),(0,d.S9)(d.Zi.kbChanged(t),p),(0,r.useEffect)(()=>{let e=window.setInterval(()=>{"visible"===document.visibilityState&&p()},3e4);return()=>window.clearInterval(e)},[p]);let g={"sys:active-goals":(0,a.jsx)(f,{rootId:t,activeGoals:m.activeGoals,runningAgents:m.runningAgents}),"sys:pending":(0,a.jsx)(N,{rootId:t,items:m.pendingApprovals}),"sys:recent-kb":(0,a.jsx)(C,{rootId:t,items:m.recentKb}),"sys:ai-suggestions":(0,a.jsx)(E,{rootId:t,cache:m.suggestions})};return(0,a.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:(0,a.jsxs)("div",{className:"p-6 space-y-5 max-w-6xl mx-auto",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:c("dashboard.projectOverview")}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:c("dashboard.projectOverviewHint")})]}),(0,a.jsxs)(l.$,{type:"button",size:"sm",variant:"ghost",onClick:p,disabled:x,className:"gap-1 h-8",children:[(0,a.jsx)(i.A,{className:"h-3.5 w-3.5 ".concat(x?"animate-spin":"")}),c("dashboard.refresh")]})]}),(0,a.jsx)(V,{rootId:t}),(0,a.jsx)(ek,{rootId:t,widgets:m.widgets,layout:m.layout,systemRenderers:g,snapshot:m,onLayoutChanged:p}),(0,a.jsx)(_.p,{scope:"project",rootId:t,title:c("dashboard.memoryTitle"),description:c("dashboard.memoryHint")})]})})}}},e=>{e.O(0,[4400,1217,9411,3335,5097,3954,8775,8566,7529,5771,1e3,1226,4933,146,7358],()=>e(e.s=35984)),_N_E=e.O()}]);