@flexkit/studio 0.2.31 → 0.2.33

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 (155) hide show
  1. package/dist/activity-nav-button-ZHQOZBCC.js +2 -0
  2. package/dist/{activity-nav-button-E4I4YC3X.js.map → activity-nav-button-ZHQOZBCC.js.map} +1 -1
  3. package/dist/astro.js +1 -1
  4. package/dist/chat-page-LR7XC2US.js +4 -0
  5. package/dist/{chat-page-JS5SJ4OG.js.map → chat-page-LR7XC2US.js.map} +1 -1
  6. package/dist/chunk-2MVQXXY7.js +4 -0
  7. package/dist/{chunk-OMYDXVWS.js.map → chunk-2MVQXXY7.js.map} +1 -1
  8. package/dist/{chunk-ERCVR23U.js → chunk-36DLIVZF.js} +2 -2
  9. package/dist/{chunk-ERCVR23U.js.map → chunk-36DLIVZF.js.map} +1 -1
  10. package/dist/chunk-3SY46ERM.js +2 -0
  11. package/dist/chunk-3SY46ERM.js.map +1 -0
  12. package/dist/chunk-4ZWQ44NZ.js +2 -0
  13. package/dist/{chunk-2NXQF2F7.js.map → chunk-4ZWQ44NZ.js.map} +1 -1
  14. package/dist/chunk-5JUG4BEF.js +2 -0
  15. package/dist/chunk-5JUG4BEF.js.map +1 -0
  16. package/dist/chunk-6I7D2JBA.js +3 -0
  17. package/dist/chunk-6I7D2JBA.js.map +1 -0
  18. package/dist/chunk-7ODGH7G2.js +2 -0
  19. package/dist/{chunk-5LGIALCK.js.map → chunk-7ODGH7G2.js.map} +1 -1
  20. package/dist/{chunk-SZEGGBOC.js → chunk-A4DPLZZF.js} +2 -2
  21. package/dist/{chunk-SZEGGBOC.js.map → chunk-A4DPLZZF.js.map} +1 -1
  22. package/dist/{chunk-C4XLDODU.js → chunk-C2KPTRYM.js} +3 -1
  23. package/dist/chunk-C3OHXPJV.js +2 -0
  24. package/dist/chunk-C3OHXPJV.js.map +1 -0
  25. package/dist/{chunk-D76P4TER.js → chunk-CFYO546Y.js} +3 -3
  26. package/dist/{chunk-D76P4TER.js.map → chunk-CFYO546Y.js.map} +1 -1
  27. package/dist/chunk-DHE6PO3V.js +2 -0
  28. package/dist/{chunk-57X5WRMY.js.map → chunk-DHE6PO3V.js.map} +1 -1
  29. package/dist/{chunk-V7C4EHK3.js → chunk-DSLPTDZX.js} +2 -2
  30. package/dist/{chunk-V7C4EHK3.js.map → chunk-DSLPTDZX.js.map} +1 -1
  31. package/dist/chunk-HSGUVQXU.js +10 -0
  32. package/dist/chunk-HSGUVQXU.js.map +1 -0
  33. package/dist/{chunk-EMFHKTAV.js → chunk-K3HW6YWS.js} +2 -2
  34. package/dist/{chunk-EMFHKTAV.js.map → chunk-K3HW6YWS.js.map} +1 -1
  35. package/dist/chunk-L5T56MRH.js +7 -0
  36. package/dist/chunk-L5T56MRH.js.map +1 -0
  37. package/dist/chunk-MBBE4RND.js +3 -0
  38. package/dist/chunk-MBBE4RND.js.map +1 -0
  39. package/dist/{chunk-USNXQOMJ.js → chunk-N33S7BSG.js} +2 -2
  40. package/dist/{chunk-USNXQOMJ.js.map → chunk-N33S7BSG.js.map} +1 -1
  41. package/dist/{chunk-KN7OJFEX.js → chunk-N52JTYBJ.js} +2 -2
  42. package/dist/{chunk-KN7OJFEX.js.map → chunk-N52JTYBJ.js.map} +1 -1
  43. package/dist/{chunk-SZ3DX7XD.js → chunk-NFEQBTIW.js} +2 -2
  44. package/dist/{chunk-SZ3DX7XD.js.map → chunk-NFEQBTIW.js.map} +1 -1
  45. package/dist/chunk-RFUMT6ZR.js +2 -0
  46. package/dist/{chunk-W74OKBZG.js.map → chunk-RFUMT6ZR.js.map} +1 -1
  47. package/dist/{chunk-6GXNHR6H.js → chunk-RLVHUIFC.js} +2 -2
  48. package/dist/{chunk-6GXNHR6H.js.map → chunk-RLVHUIFC.js.map} +1 -1
  49. package/dist/chunk-S26WK6RF.js +2 -0
  50. package/dist/{chunk-54AXLGAK.js.map → chunk-S26WK6RF.js.map} +1 -1
  51. package/dist/{chunk-T4SEZXGL.js → chunk-S7VNSSIK.js} +2 -2
  52. package/dist/{chunk-T4SEZXGL.js.map → chunk-S7VNSSIK.js.map} +1 -1
  53. package/dist/chunk-S7Z6KKIN.js +2 -0
  54. package/dist/chunk-S7Z6KKIN.js.map +1 -0
  55. package/dist/{chunk-KVYQ3O4F.js → chunk-U5XZWEPO.js} +3 -3
  56. package/dist/{chunk-KVYQ3O4F.js.map → chunk-U5XZWEPO.js.map} +1 -1
  57. package/dist/chunk-UB22GYFK.js +2 -0
  58. package/dist/{chunk-GQTWNWT7.js.map → chunk-UB22GYFK.js.map} +1 -1
  59. package/dist/chunk-VUZ7GHSO.js +7 -0
  60. package/dist/{chunk-5NQ47SWN.js.map → chunk-VUZ7GHSO.js.map} +1 -1
  61. package/dist/chunk-X3SHNHHM.js +2 -0
  62. package/dist/chunk-X3SHNHHM.js.map +1 -0
  63. package/dist/{chunk-GXQSNOGM.js → chunk-YKM3FUGK.js} +3 -3
  64. package/dist/{chunk-GXQSNOGM.js.map → chunk-YKM3FUGK.js.map} +1 -1
  65. package/dist/electron.js +1 -1
  66. package/dist/{entry-PFXS633U.js → entry-ROTT3ZDN.js} +2 -2
  67. package/dist/{entry-PFXS633U.js.map → entry-ROTT3ZDN.js.map} +1 -1
  68. package/dist/index.d.ts +10 -1
  69. package/dist/index.js +7 -7
  70. package/dist/index.js.map +1 -1
  71. package/dist/list-N4E3VXM5.js +3 -0
  72. package/dist/{list-EWWRLK4I.js.map → list-N4E3VXM5.js.map} +1 -1
  73. package/dist/list-RCTHBJOK.js +2 -0
  74. package/dist/{list-R7SJFXCX.js.map → list-RCTHBJOK.js.map} +1 -1
  75. package/dist/nextjs.js +1 -1
  76. package/dist/pages-XUJGIHQI.js +5 -0
  77. package/dist/pages-XUJGIHQI.js.map +1 -0
  78. package/dist/plugin-pages-FEQILAQR.js +2 -0
  79. package/dist/{plugin-pages-X3V2VPAU.js.map → plugin-pages-FEQILAQR.js.map} +1 -1
  80. package/dist/project-selector-U64ROZ5D.js +2 -0
  81. package/dist/project-selector-U64ROZ5D.js.map +1 -0
  82. package/dist/record-links-HO4SEHOA.js +2 -0
  83. package/dist/{record-links-VH2TPCK4.js.map → record-links-HO4SEHOA.js.map} +1 -1
  84. package/dist/root-BUXIQKA5.js +14 -0
  85. package/dist/{root-4QRY7KAC.js.map → root-BUXIQKA5.js.map} +1 -1
  86. package/dist/root-CCUROZVR.js +2 -0
  87. package/dist/{root-HQQ4TNTR.js.map → root-CCUROZVR.js.map} +1 -1
  88. package/dist/root-GQL3P63Z.js +31 -0
  89. package/dist/{root-NYAXP66A.js.map → root-GQL3P63Z.js.map} +1 -1
  90. package/dist/root-KXY4A6DW.js +2 -0
  91. package/dist/{root-OJ4UFMRX.js.map → root-KXY4A6DW.js.map} +1 -1
  92. package/dist/root-MLEJUEMJ.js +23 -0
  93. package/dist/{root-7YXE6DEA.js.map → root-MLEJUEMJ.js.map} +1 -1
  94. package/dist/root-VA3E6HEY.js +2 -0
  95. package/dist/{root-FNXHGVQT.js.map → root-VA3E6HEY.js.map} +1 -1
  96. package/dist/search-YY4GQQRM.js +2 -0
  97. package/dist/{search-LSIHN6OI.js.map → search-YY4GQQRM.js.map} +1 -1
  98. package/dist/skills-pages-SAOZTUOH.js +2 -0
  99. package/dist/{skills-pages-W47HECK3.js.map → skills-pages-SAOZTUOH.js.map} +1 -1
  100. package/dist/source-2S24MZ5D.js +2 -0
  101. package/dist/{source-3N7BQVYO.js.map → source-2S24MZ5D.js.map} +1 -1
  102. package/dist/spec-renderer-ZSIVMKVE.js +2 -0
  103. package/dist/{spec-renderer-3GAVSV52.js.map → spec-renderer-ZSIVMKVE.js.map} +1 -1
  104. package/dist/tanstack-start.js +1 -1
  105. package/dist/ui.js +1 -1
  106. package/dist/user-nav-ZH63YHX7.js +2 -0
  107. package/dist/{user-nav-OWTTAXZS.js.map → user-nav-ZH63YHX7.js.map} +1 -1
  108. package/package.json +4 -4
  109. package/dist/activity-nav-button-E4I4YC3X.js +0 -2
  110. package/dist/chat-page-JS5SJ4OG.js +0 -4
  111. package/dist/chunk-2NXQF2F7.js +0 -2
  112. package/dist/chunk-32ZU4MLE.js +0 -2
  113. package/dist/chunk-32ZU4MLE.js.map +0 -1
  114. package/dist/chunk-54AXLGAK.js +0 -2
  115. package/dist/chunk-57X5WRMY.js +0 -2
  116. package/dist/chunk-5LGIALCK.js +0 -2
  117. package/dist/chunk-5NQ47SWN.js +0 -7
  118. package/dist/chunk-6NRQMG26.js +0 -2
  119. package/dist/chunk-6NRQMG26.js.map +0 -1
  120. package/dist/chunk-AKQ6ELDX.js +0 -2
  121. package/dist/chunk-AKQ6ELDX.js.map +0 -1
  122. package/dist/chunk-DGIY4SKN.js +0 -7
  123. package/dist/chunk-DGIY4SKN.js.map +0 -1
  124. package/dist/chunk-GQTWNWT7.js +0 -2
  125. package/dist/chunk-HDOIOXMP.js +0 -2
  126. package/dist/chunk-HDOIOXMP.js.map +0 -1
  127. package/dist/chunk-LF4B2TQI.js +0 -10
  128. package/dist/chunk-LF4B2TQI.js.map +0 -1
  129. package/dist/chunk-O2QMYUPS.js +0 -2
  130. package/dist/chunk-O2QMYUPS.js.map +0 -1
  131. package/dist/chunk-OMYDXVWS.js +0 -4
  132. package/dist/chunk-W74OKBZG.js +0 -2
  133. package/dist/chunk-WPCPL2TQ.js +0 -3
  134. package/dist/chunk-WPCPL2TQ.js.map +0 -1
  135. package/dist/chunk-XLFAJBPN.js +0 -3
  136. package/dist/chunk-XLFAJBPN.js.map +0 -1
  137. package/dist/list-EWWRLK4I.js +0 -3
  138. package/dist/list-R7SJFXCX.js +0 -2
  139. package/dist/pages-UKJWXOMO.js +0 -5
  140. package/dist/pages-UKJWXOMO.js.map +0 -1
  141. package/dist/plugin-pages-X3V2VPAU.js +0 -2
  142. package/dist/project-selector-72VM6SUI.js +0 -2
  143. package/dist/project-selector-72VM6SUI.js.map +0 -1
  144. package/dist/record-links-VH2TPCK4.js +0 -2
  145. package/dist/root-4QRY7KAC.js +0 -14
  146. package/dist/root-7YXE6DEA.js +0 -23
  147. package/dist/root-FNXHGVQT.js +0 -2
  148. package/dist/root-HQQ4TNTR.js +0 -2
  149. package/dist/root-NYAXP66A.js +0 -31
  150. package/dist/root-OJ4UFMRX.js +0 -2
  151. package/dist/search-LSIHN6OI.js +0 -2
  152. package/dist/skills-pages-W47HECK3.js +0 -2
  153. package/dist/source-3N7BQVYO.js +0 -2
  154. package/dist/spec-renderer-3GAVSV52.js +0 -2
  155. package/dist/user-nav-OWTTAXZS.js +0 -2
@@ -1,2 +0,0 @@
1
- import'./index.css';import {clsx}from'clsx';import {extendTailwindMerge}from'tailwind-merge';var n=extendTailwindMerge({prefix:"fk"});function s(...e){return n(clsx(e))}export{s as a};//# sourceMappingURL=chunk-O2QMYUPS.js.map
2
- //# sourceMappingURL=chunk-O2QMYUPS.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ui/lib/utils.ts"],"names":["twMerge","extendTailwindMerge","cn","inputs","clsx"],"mappings":"6FAGA,IAAMA,CAAAA,CAAUC,mBAAAA,CAAoB,CAClC,MAAA,CAAQ,IACV,CAAC,CAAA,CAEM,SAASC,CAAAA,CAAAA,GAAMC,CAAAA,CAA8B,CAClD,OAAOH,CAAAA,CAAQI,IAAAA,CAAKD,CAAM,CAAC,CAC7B","file":"chunk-O2QMYUPS.js","sourcesContent":["import { type ClassValue, clsx } from 'clsx';\nimport { extendTailwindMerge } from 'tailwind-merge';\n\nconst twMerge = extendTailwindMerge({\n prefix: 'fk',\n});\n\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n"]}
@@ -1,4 +0,0 @@
1
- import'./index.css';import {f as f$1,e as e$2}from'./chunk-5NQ47SWN.js';import {p,o as o$1,h as h$1,i}from'./chunk-D76P4TER.js';import {b}from'./chunk-V7C4EHK3.js';import {j}from'./chunk-GXQSNOGM.js';import {d,c}from'./chunk-XMOSCJOI.js';import {s}from'./chunk-7KLXWCDS.js';import {f}from'./chunk-XLFAJBPN.js';import {na}from'./chunk-DGIY4SKN.js';import {e,g,h,j as j$1,o,n,k}from'./chunk-SZEGGBOC.js';import {a,d as d$1,c as c$1,e as e$1,g as g$1}from'./chunk-HDOIOXMP.js';import {b as b$1}from'./chunk-6NRQMG26.js';import {PencilIcon,Trash2Icon,Ellipsis,Settings2,RefreshCw,Loader2,Trash2}from'lucide-react';import {jsxs,jsx}from'react/jsx-runtime';import {lazy,useState,Suspense}from'react';import {find,propEq}from'ramda';import {gql}from'@apollo/client';import {useApolloClient}from'@apollo/client/react';import {toast}from'sonner';function Be({entityName:e$1,entityNamePlural:a,row:c,options:i={canDelete:true,canEdit:true}}){let m=j(),N=b(),p=c.original._id,D=(i.canDelete??true)&&N,f=i.canEdit??true;function h$1(){m({type:"EditEntity",payload:{entityId:p,entityNamePlural:a}});}function d(){m({type:"DeleteEntity",payload:{entityId:p,entityName:e$1}});}return jsxs("div",{className:"fk:flex",children:[f&&jsxs(b$1,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1",onClick:h$1,variant:"ghost",children:[jsx(PencilIcon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Edit"})]}),D&&!f&&jsxs(b$1,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:mr-1",onClick:d,variant:"ghost",children:[jsx(Trash2Icon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Delete"})]}),f&&D&&jsxs(e,{children:[jsx(g,{asChild:true,children:jsxs(b$1,{className:"fk:flex fk:h-7 fk:w-7 fk:p-0",variant:"ghost",children:[jsx(Ellipsis,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Additional actions"})]})}),jsxs(h,{align:"end",className:"w-[160px]",children:[jsxs(j$1,{onClick:h$1,children:[jsx(PencilIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Edit"]}),jsx(o,{}),jsxs(j$1,{className:"fk:text-destructive",onClick:d,children:[jsx(Trash2Icon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Delete"]})]})]})]})}function Z({table:e$1}){return jsxs(e,{children:[jsx(g,{asChild:true,children:jsxs(b$1,{className:"fk:hidden fk:h-8 fk:lg:flex",size:"sm",variant:"outline",children:[jsx(Settings2,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"View"]})}),jsxs(h,{align:"end",className:"fk:w-[150px]",children:[jsx(n,{children:"Toggle columns"}),jsx(o,{}),e$1.getAllColumns().filter(a=>typeof a.accessorFn<"u"&&a.getCanHide()).map(a=>jsx(k,{checked:a.getIsVisible(),className:"capitalize",onCheckedChange:c=>{a.toggleVisibility(!!c);},children:a.id},a.id))]})]})}var Ce=lazy(()=>import('./record-links-VH2TPCK4.js').then(e=>({default:e.EntityKnowledgeButton}))),ve=lazy(()=>import('./entry-PFXS633U.js').then(e=>({default:e.EntityGraphButton})));function at({entityName:e,isReloading:a$1=false,onReload:c$2,table:i$1}){let m=j(),N=d(),p$1=c(),D=useApolloClient(),{currentProject:f$2,currentProjectId:h}=f(),d$2=f$2?.schema??[],w=f$2?.scopes,[ae,ne,le]=f$1(),[b$2,P]=useState(false),y=b(),r=i$1.getSelectedRowModel().rows.map(t=>t.original._id);function se(){m({type:"AddEntity",payload:{entityName:e}});}function ie(t){N({type:"setScope",payload:{projectId:h,scope:t}});}async function re(t){if(t.length===0)return;let u=h$1(e,d$2,t);await new Promise((pe,fe)=>{ne(gql`
2
- ${u}
3
- `),le({variables:{where:i(t)},update(x){for(let me of t)x.evict({id:me});},onCompleted:()=>{pe();},onError:x=>{fe(x);}}),ae(true);});}function ce(){let t=e==="_asset"?"asset":e.toLowerCase();m({type:"AlertDialog",payload:{options:{dialogTitle:`Delete ${r.length} ${t}${r.length>1?"s":""}`,dialogMessage:r.length>1?`Are you sure you want to delete the selected ${t}s? They will be deleted permanently.`:`Are you sure you want to delete the selected ${t}? The item will be deleted permanently.`,dialogCancelTitle:"Cancel",dialogActionLabel:"Delete",isDestructive:true,dialogActionSubmit:async()=>{P(true);try{let u=[...r];await re(u),i$1.resetRowSelection(),await p(D,o$1(e,d$2),u),toast.success(u.length>1?"Items successfully deleted.":"Item successfully deleted.");}catch{toast.error("Failed to delete selected items.");}finally{P(false);}},dialogActionCancel:()=>{}}}});}return jsxs("div",{className:"fk:flex fk:items-center fk:justify-between",children:[jsxs("div",{className:"fk:flex fk:flex-1 fk:items-center fk:space-x-2",children:[w&&w.length>0?jsxs(a,{defaultValue:p$1.scope,onValueChange:t=>{ie(t);},value:p$1.scope,children:[jsxs(d$1,{className:"fk:w-48!",id:"project",size:"sm",children:[jsx("span",{className:"fk:text-muted-foreground",children:"Scope:"}),jsx(c$1,{children:(find(propEq(p$1.scope??"","name"))(w)||null)?.label})]}),jsx(e$1,{children:w.map(t=>jsx(g$1,{value:t.name,children:t.label},t.name))})]}):null,jsx(Z,{table:i$1}),c$2?jsx(b$1,{"aria-label":"Reload",className:"fk:h-8",disabled:b$2||a$1,onClick:c$2,size:"icon-sm",variant:"outline",children:jsx(RefreshCw,{className:a$1?"fk:animate-spin":void 0})}):null,jsx(e$2,{table:i$1})]}),r.length>0?jsx(na,{disabled:!y,children:jsxs(b$1,{className:"fk:h-8 fk:mr-2 fk:lg:flex",disabled:b$2||!y,onClick:ce,size:"sm",variant:"destructive",children:[b$2?jsx(Loader2,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin"}):jsx(Trash2,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Delete (",r.length,")"]})}):null,e&&s(e)?jsx(Suspense,{fallback:null,children:jsx(Ce,{entityName:e})}):null,e?jsx(Suspense,{fallback:null,children:jsx(ve,{entityName:e,selectedIds:r})}):null,jsx(na,{disabled:!y,children:jsx(b$1,{className:"fk:h-8 fk:lg:flex",disabled:b$2||!y,onClick:se,size:"sm",variant:"default",children:"Create"})})]})}export{Be as a,Z as b,at as c};//# sourceMappingURL=chunk-OMYDXVWS.js.map
4
- //# sourceMappingURL=chunk-OMYDXVWS.js.map
@@ -1,2 +0,0 @@
1
- import'./index.css';import {x}from'./chunk-LF4B2TQI.js';import {g,f}from'./chunk-U6VZY3V2.js';import {s}from'./chunk-DGIY4SKN.js';import {e,g as g$1,h,j}from'./chunk-SZEGGBOC.js';import {c,h as h$1,i,k,j as j$1}from'./chunk-32ZU4MLE.js';import {b}from'./chunk-6NRQMG26.js';import {useState,useEffect,useMemo,useTransition}from'react';import {LoaderCircle,MessageSquareIcon,MoreHorizontalIcon,PencilIcon,Trash2Icon}from'lucide-react';import {useLocation,useNavigate}from'react-router-dom';import H,{useSWRConfig}from'swr';import U from'swr/infinite';import {jsx,jsxs}from'react/jsx-runtime';function ue(){let a=useLocation(),n="/agent",t=a.pathname.indexOf(n);return t===-1?`${a.pathname.replace(/\/$/,"")}/agent`:a.pathname.slice(0,t+n.length)}function de(a,n){let[t,o]=useState(a);return useEffect(()=>{let f=window.setTimeout(()=>{o(a);},n);return ()=>{window.clearTimeout(f);}},[n,a]),t}function Z(a){let n=new Date(a.lastMessageAt??a.updatedAt).getTime(),t=new Date,o=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime();return n>=o?"Today":n>=o-864e5?"Yesterday":n>=o-7*864e5?"Previous 7 days":"Older"}function ee(a){let n=[];for(let t of a){let o=Z(t),f=n.find(u=>u.label===o);f?f.chats.push(t):n.push({chats:[t],label:o});}return n}function te({active:a,api:n,chat:t,onChanged:o,onDeleted:f,onOpen:u}){let[r,l]=useState(null),[g,d]=useState(t.title??""),[p,D]=useTransition(),k$1=t.title?.trim()||"New chat";function v(){D(async()=>{await n.renameAgentChat(t.id,g.trim()),l(null),o();});}function y(){D(async()=>{await n.deleteAgentChat(t.id),l(null),f();});}return jsxs("div",{className:`fk:group/chat fk:flex fk:items-center fk:gap-1 fk:rounded-md fk:pr-1 ${a?"fk:bg-sidebar-accent":"fk:hover:bg-accent/60"} fk:corner-squircle`,children:[jsx("button",{className:"fk:min-w-0 fk:flex-1 fk:truncate fk:px-2 fk:py-1.5 fk:text-left fk:text-sm",title:k$1,type:"button",onClick:u,children:k$1}),jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsx(b,{className:"fk:size-6 fk:shrink-0 fk:opacity-0 fk:group-hover/chat:opacity-100 fk:data-[state=open]:opacity-100",size:"icon",variant:"ghost",children:jsx(MoreHorizontalIcon,{className:"fk:size-4"})})}),jsxs(h,{align:"start",children:[jsxs(j,{onClick:()=>{d(t.title??""),l("rename");},children:[jsx(PencilIcon,{className:"fk:size-4"}),"Rename"]}),jsxs(j,{className:"fk:text-destructive",onClick:()=>l("delete"),children:[jsx(Trash2Icon,{className:"fk:size-4"}),"Delete"]})]})]}),jsx(c,{open:r==="rename",onOpenChange:m=>l(m?"rename":null),children:jsxs(h$1,{className:"fk:max-w-sm",children:[jsx(i,{children:jsx(k,{children:"Rename chat"})}),jsx(s,{value:g,onChange:m=>d(m.target.value),placeholder:"Chat title"}),jsx(j$1,{children:jsx(b,{disabled:p||!g.trim(),size:"sm",onClick:v,children:p?"Saving...":"Save"})})]})}),jsx(c,{open:r==="delete",onOpenChange:m=>l(m?"delete":null),children:jsxs(h$1,{className:"fk:max-w-sm",children:[jsx(i,{children:jsx(k,{children:"Delete chat?"})}),jsxs("p",{className:"fk:text-sm fk:text-muted-foreground",children:["\u201C",k$1,"\u201D and its messages will be permanently deleted."]}),jsx(j$1,{children:jsx(b,{disabled:p,size:"sm",variant:"destructive",onClick:y,children:p?"Deleting...":"Delete"})})]})})]})}function ne({onOpen:a,projectId:n,query:t}){let{data:o,isLoading:f$1}=H(g(n).agentChatSearch(t),f,{keepPreviousData:true});return f$1&&!o?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}),"Searching..."]}):o?.results.length?jsx("div",{className:"fk:space-y-1",children:o.results.map(u=>jsxs("button",{className:"fk:block fk:w-full fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:hover:bg-accent/60 fk:corner-squircle",type:"button",onClick:()=>a(u.chatId),children:[jsx("span",{className:"fk:block fk:truncate fk:text-sm",children:u.chatTitle?.trim()||"New chat"}),jsx("span",{className:"fk:block fk:truncate fk:text-xs fk:text-muted-foreground",children:u.snippet})]},u.messageId))}):jsx("p",{className:"fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground",children:"No matching chats."})}function me({query:a}){let{api:n,projectId:t}=x(),o=useNavigate(),f$1=useLocation(),{mutate:u}=useSWRConfig(),r=/\/agent\/chats\/([^/]+)/.exec(f$1.pathname)?.[1],{data:l,isLoading:g$1,mutate:d,setSize:p,size:D}=U((s,c)=>!t||c&&!c.hasMore?null:g(t).agentChats(s*30),f,{revalidateFirstPage:true}),{data:k}=H(t&&r?g(t).agentChat(r):null,f),v=useMemo(()=>{let s=(l??[]).flatMap(h=>h.chats),c=k?.chat.title?.trim();return !r||!c?s:s.map(h=>h.id!==r||h.title?.trim()?h:{...h,title:c})},[k?.chat.title,r,l]),y=l?.[l.length-1]?.hasMore??false,m=useMemo(()=>ee(v),[v]);if(useEffect(()=>{d();},[r,d]),!t||!n)return null;let J=n,z=t;function L(s){o(`agent/chats/${s}`);}function X(s){d(),s===r?o("agent"):u(g(z).agentChat(s),void 0,{revalidate:false});}return jsx("div",{className:"fk:space-y-2",children:a?jsx(ne,{projectId:z,query:a,onOpen:L}):jsxs("div",{className:"fk:space-y-3",children:[m.map(s=>jsxs("div",{children:[jsx("p",{className:"fk:px-2 fk:pb-1 fk:text-xs fk:font-medium fk:text-muted-foreground",children:s.label}),jsx("div",{className:"fk:space-y-0.5",children:s.chats.map(c=>jsx(te,{active:c.id===r,api:J,chat:c,onChanged:()=>{d();},onDeleted:()=>X(c.id),onOpen:()=>L(c.id)},c.id))})]},s.label)),g$1?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}),"Loading recent chats..."]}):null,!g$1&&v.length===0?jsxs("div",{className:"fk:flex fk:flex-col fk:items-center fk:gap-2 fk:px-2 fk:py-6 fk:text-center fk:text-xs fk:text-muted-foreground",children:[jsx(MessageSquareIcon,{className:"fk:size-5"}),jsx("span",{children:"No chats yet. Start a conversation with the agent."})]}):null,y?jsx(b,{className:"fk:w-full",size:"sm",variant:"ghost",onClick:()=>{p(D+1);},children:"Load more"}):null]})})}export{ue as a,de as b,me as c};//# sourceMappingURL=chunk-W74OKBZG.js.map
2
- //# sourceMappingURL=chunk-W74OKBZG.js.map
@@ -1,3 +0,0 @@
1
- import'./index.css';import {c}from'./chunk-5CVDMZUI.js';import {createContext,useContext}from'react';import $ from'swr';import {useParams,useHref}from'react-router-dom';import {jsx}from'react/jsx-runtime';var p=c,l=`https://${p}`,n=t=>t?`https://${t}.api.${p}`:l,w=`${l}/images/`,i="-",f={authProviders:`/api/flexkit/${i}/auth/providers`,clientErrors:`/api/flexkit/${i}/client-errors`,logout:`/api/flexkit/${i}/auth/logout`,productEvents:`/api/flexkit/${i}/product-events`,me:`/api/flexkit/${i}/me`,notificationPreferences:`/api/flexkit/${i}/me/notification-preferences`,push:`/api/flexkit/${i}/me/push`,otpConfirm:`/api/flexkit/${i}/auth/otp/confirm`,otpSend:`/api/flexkit/${i}/auth/otp/send`};function a(t=""){return {assets:`/api/flexkit/${t}/assets`,authProviders:`/api/flexkit/${t}/auth/providers`,completion:`/api/flexkit/${t}/completion`,currentUser:`/api/flexkit/${t}/users/me`,loginOtpConfirm:`${n(t)}/auth/otp/confirm`,loginOtpSend:`${n(t)}/auth/otp/send`,logout:e=>{let o=new URLSearchParams({redirect:e});return `/api/flexkit/${t}/auth/logout?${o.toString()}`},schema:`/api/flexkit/${t}/schema`,search:`/api/flexkit/${t}/search`,sessionId:`${n(t)}/api/auth/login/session`}}async function h(t){try{await fetch(f.logout,{credentials:"same-origin",method:"POST"});}catch{}await fetch("/api/flexkit/logout",{credentials:"include",method:"GET"}),window.location.assign(t);}function u(t="projects"){let{projectId:e}=useParams(),o=useHref(`/${e??""}`),s=useHref("/"),{data:g,isLoading:x}=$(e?a(e).currentUser:null,S=>fetch(S,{mode:"cors",credentials:"include"}).then(r=>r.json()).then(r=>({...r,spaces:r.spaces??[]})));return [!!e&&x,{user:g,logout:async()=>{if(t==="hosted"){await h(s);return}await fetch(a(e??"").logout(o),{method:"POST",mode:"cors",credentials:"include"}),await fetch("/api/flexkit/logout",{method:"GET",credentials:"include"}),window.location.reload();}}]}var d=createContext([true,{user:null,logout:()=>Promise.resolve()}]);function B({children:t,mode:e="projects"}){let[o,s]=u(e);return jsx(d.Provider,{value:[o,s],children:t})}function J(){return useContext(d)}
2
- export{l as a,w as b,f as c,a as d,h as e,B as f,J as g};//# sourceMappingURL=chunk-WPCPL2TQ.js.map
3
- //# sourceMappingURL=chunk-WPCPL2TQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/api-paths.ts","../src/auth/hosted-logout.ts","../src/auth/use-auth-service.ts","../src/auth/auth-context.tsx"],"names":["domain","flexkitDomain","baseApiUrl","baseProjectApiUrl","projectId","IMAGES_BASE_URL","USER_API_SEGMENT","userApiPaths","apiPaths","redirectPath","params","signOutHosted","rootHref","useAuthService","mode","useParams","projectHref","useHref","user","isLoadingUser","useSWR","url","res","data","AuthContext","createContext","AuthProvider","children","isLoading","auth","jsx","useAuth","useContext"],"mappings":"6MAEA,IAAMA,EAASC,CAAAA,CACFC,CAAAA,CAAa,WAAWF,CAAM,CAAA,CAAA,CACrCG,EAAqBC,CAAAA,EACzBA,CAAAA,CAAY,CAAA,QAAA,EAAWA,CAAS,QAAQJ,CAAM,CAAA,CAAA,CAAKE,EAiBxCG,CAAAA,CAAkB,CAAA,EAAGH,CAAU,CAAA,QAAA,CAAA,CAQ/BI,CAAAA,CAAmB,GAAA,CAEnBC,CAAAA,CAAe,CAC1B,aAAA,CAAe,CAAA,aAAA,EAAgBD,CAAgB,CAAA,eAAA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AAM,KAAA,CAAM,sBAAuB,CAAE,MAAA,CAAQ,MAAO,WAAA,CAAa,SAAU,CAAC,CAAA,CAE5E,OAAO,QAAA,CAAS,MAAA,GAClB,CACF,CACF,CACF,CCxCA,IAAMQ,EAAcC,aAAAA,CAAc,CAChC,KACA,CACE,IAAA,CAAM,KACN,MAAA,CAAQ,IAAM,OAAA,CAAQ,OAAA,EACxB,CACF,CAAC,EAEM,SAASC,CAAAA,CAAa,CAC3B,QAAA,CAAAC,CAAAA,CACA,KAAAb,CAAAA,CAAO,UACT,EAGgB,CACd,GAAM,CAACc,CAAAA,CAAWC,CAAI,EAAIhB,CAAAA,CAAeC,CAAI,CAAA,CAE7C,OAAOgB,IAACN,CAAAA,CAAY,QAAA,CAAZ,CAAqB,KAAA,CAAO,CAACI,EAAWC,CAAI,CAAA,CAAI,SAAAF,CAAAA,CAAS,CACnE,CAEO,SAASI,CAAAA,EAAuB,CACrC,OAAOC,UAAAA,CAAWR,CAAW,CAC/B","file":"chunk-WPCPL2TQ.js","sourcesContent":["import { flexkitDomain } from './domains';\n\nconst domain = flexkitDomain;\nexport const baseApiUrl = `https://${domain}`;\nconst baseProjectApiUrl = (projectId?: string): string =>\n projectId ? `https://${projectId}.api.${domain}` : baseApiUrl;\n\ninterface ApiPaths {\n assets: string;\n authProviders: string;\n completion: string;\n currentUser: string;\n loginOtpConfirm: string;\n loginOtpSend: string;\n /** `redirectPath` is the absolute in-app path to return to after logout. */\n logout: (redirectPath: string) => string;\n /** Deployed project schema, scopes, spaces, title and menu groups. */\n schema: string;\n search: string;\n sessionId: string;\n}\n\nexport const IMAGES_BASE_URL = `${baseApiUrl}/images/`;\n\n/**\n * Reserved BFF segment for user-level (project-less) Flexkit API calls:\n * `/api/flexkit/-/me` is proxied to `https://<flexkitDomain>/api/me` with the\n * session as a bearer token. Project ids are ten characters, so `-` can never\n * collide with one.\n */\nexport const USER_API_SEGMENT = '-';\n\nexport const userApiPaths = {\n authProviders: `/api/flexkit/${USER_API_SEGMENT}/auth/providers`,\n /** POST: Studio error reports (see core/error/error-reporter.ts). */\n clientErrors: `/api/flexkit/${USER_API_SEGMENT}/client-errors`,\n logout: `/api/flexkit/${USER_API_SEGMENT}/auth/logout`,\n /** POST: product events only Studio sees (see core/analytics/product-events.ts). */\n productEvents: `/api/flexkit/${USER_API_SEGMENT}/product-events`,\n /** Signed-in user plus every project they can open. */\n me: `/api/flexkit/${USER_API_SEGMENT}/me`,\n /** The signed-in user's notification preferences (desktop kinds, approval email). */\n notificationPreferences: `/api/flexkit/${USER_API_SEGMENT}/me/notification-preferences`,\n /** Web Push: GET the VAPID public key, POST or DELETE this browser's subscription. */\n push: `/api/flexkit/${USER_API_SEGMENT}/me/push`,\n otpConfirm: `/api/flexkit/${USER_API_SEGMENT}/auth/otp/confirm`,\n otpSend: `/api/flexkit/${USER_API_SEGMENT}/auth/otp/send`,\n} as const;\n\nexport function apiPaths(projectId = ''): ApiPaths {\n return {\n assets: `/api/flexkit/${projectId}/assets`,\n authProviders: `/api/flexkit/${projectId}/auth/providers`,\n completion: `/api/flexkit/${projectId}/completion`,\n currentUser: `/api/flexkit/${projectId}/users/me`,\n loginOtpConfirm: `${baseProjectApiUrl(projectId)}/auth/otp/confirm`,\n loginOtpSend: `${baseProjectApiUrl(projectId)}/auth/otp/send`,\n logout: (redirectPath: string) => {\n const params = new URLSearchParams({ redirect: redirectPath });\n\n return `/api/flexkit/${projectId}/auth/logout?${params.toString()}`;\n },\n schema: `/api/flexkit/${projectId}/schema`,\n search: `/api/flexkit/${projectId}/search`,\n sessionId: `${baseProjectApiUrl(projectId)}/api/auth/login/session`,\n };\n}\n","import { userApiPaths } from '../core/api-paths';\n\n/** Hosted mode sign-out: end the Flexkit session, drop the first-party cookie, go back to the Studio root. */\nexport async function signOutHosted(rootHref: string): Promise<void> {\n try {\n await fetch(userApiPaths.logout, { credentials: 'same-origin', method: 'POST' });\n } catch {\n // The cookie is cleared below either way; the session expires server-side.\n }\n\n await fetch('/api/flexkit/logout', { credentials: 'include', method: 'GET' });\n window.location.assign(rootHref);\n}\n","'use client';\n\nimport useSWR from 'swr';\nimport { useHref, useParams } from 'react-router-dom';\nimport { apiPaths } from '../core/api-paths';\nimport type { StudioMode } from '../core/config/types';\nimport { signOutHosted } from './hosted-logout';\nimport type { AuthService, User } from './types';\n\nexport default function useAuthService(mode: StudioMode = 'projects'): AuthService {\n const { projectId } = useParams();\n // Absolute path of the current project under the router basename.\n const projectHref = useHref(`/${projectId ?? ''}`);\n const rootHref = useHref('/');\n // Role and spaces are per project, so there is nothing to ask until a project is open.\n const { data: user, isLoading: isLoadingUser } = useSWR(projectId ? apiPaths(projectId).currentUser : null, (url: string) =>\n fetch(url, { mode: 'cors', credentials: 'include' })\n .then((res) => res.json() as Promise<User>)\n .then((data) => ({ ...data, spaces: data.spaces ?? [] }))\n );\n const isLoading = Boolean(projectId) && isLoadingUser;\n\n return [\n isLoading,\n {\n user,\n logout: async () => {\n if (mode === 'hosted') {\n await signOutHosted(rootHref);\n\n return;\n }\n\n // wipe remote session\n await fetch(apiPaths(projectId ?? '').logout(projectHref), {\n method: 'POST',\n mode: 'cors',\n credentials: 'include',\n });\n\n // delete first-party auth cookie\n await fetch('/api/flexkit/logout', { method: 'GET', credentials: 'include' });\n\n window.location.reload();\n },\n },\n ];\n}\n","'use client';\n\nimport { createContext, JSX, useContext } from 'react';\nimport useAuthService from './use-auth-service';\nimport type { Auth, AuthService, User } from './types';\nimport type { StudioMode } from '../core/config/types';\n\nconst AuthContext = createContext([\n true,\n {\n user: null as User | null,\n logout: () => Promise.resolve(),\n } as Auth,\n]);\n\nexport function AuthProvider({\n children,\n mode = 'projects',\n}: {\n children: React.ReactNode;\n mode?: StudioMode;\n}): JSX.Element {\n const [isLoading, auth] = useAuthService(mode);\n\n return <AuthContext.Provider value={[isLoading, auth]}>{children}</AuthContext.Provider>;\n}\n\nexport function useAuth(): AuthService {\n return useContext(AuthContext) as AuthService;\n}\n"]}
@@ -1,3 +0,0 @@
1
- import'./index.css';import {g as g$1,d}from'./chunk-WPCPL2TQ.js';import {b as b$1}from'./chunk-U45E5X3H.js';import v,{mutate}from'swr';import {createContext,lazy,Suspense,useMemo,useContext}from'react';import {Navigate,useParams}from'react-router-dom';import {Bot,Layout,FileStack,BookOpenText,Waypoints,SquarePlay}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';var f={name:"_asset",plural:"_assets",display:"originalFilename",menu:{hidden:true},attributes:[{name:"path",label:"Asset",scope:"global",options:{size:140},dataType:"string",inputType:"text",previewType:"assetPreviewField",defaultValue:""},{name:"originalFilename",label:"Filename",scope:"global",options:{size:320},dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"size",label:"Size",scope:"global",options:{size:120},dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"width",label:"Width",scope:"global",options:{size:90},dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"height",label:"Height",scope:"global",options:{size:100},dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"mimeType",label:"Mime Type",scope:"global",options:{size:160},dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"lqip",label:"lqip",scope:"global",hidden:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"url",label:"URL",scope:"global",hidden:true,readOnly:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"_updatedAt",label:"Updated At",scope:"global",options:{size:220},readOnly:true,hidden:true,dataType:"datetime",inputType:"datetime",previewType:"datetime",defaultValue:""},{name:"tags",label:"Tags",scope:"relationship",dataType:"string",inputType:"relationship",defaultValue:"",previewType:"tags",options:{size:300},relationship:{mode:"multiple",field:"name",entity:"_tag"}}]};var g={name:"_tag",plural:"_tags",display:"name",menu:{hidden:true},attributes:[{name:"name",label:"Tag Name",scope:"global",options:{size:220},dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"_updatedAt",label:"Updated At",scope:"global",options:{size:220},readOnly:true,hidden:true,dataType:"datetime",inputType:"datetime",previewType:"datetime",defaultValue:""},{name:"assets",label:"Assets",scope:"relationship",dataType:"string",inputType:"relationship",defaultValue:"",relationship:{mode:"multiple",field:"originalFilename",entity:"_asset"}}]};async function w(e){try{let t=await fetch(d(e).schema,{credentials:"include",mode:"cors",cache:"no-cache"});if(!t.ok){let a=t.statusText||`Request failed with status ${String(t.status)}`;try{let i=await t.json();a=i.error??i.message??a;}catch{}return {ok:!1,projectId:e,error:{status:t.status,message:a}}}let n=await t.json();return {ok:!0,project:{...n,projectId:n.projectId||e}}}catch(t){return {ok:false,projectId:e,error:{status:0,message:t instanceof Error?t.message:"Network error"}}}}function C(e,t){let n=[],a={};for(let i of e??[])i.ok?n.push(i.project):a[i.projectId]=i.error;return {projects:n,errors:a,isLoading:t}}var b={revalidateOnFocus:true,focusThrottleInterval:15e3,revalidateOnReconnect:false};function L(e,t){return !t.ok&&e?.ok?e:t}function A(e,t){let n=t&&e.length>0?["project-schemas",t,...e]:null,{data:a,isLoading:i}=v(n,async()=>(await Promise.all(e.map(l=>w(l)))).map((l,u)=>L(a?.[u],l)),b);return C(a,!!n&&(i||a===void 0))}function U(e,t){return C(e?[e]:void 0,t)}function E(e,t){let n=t&&e?["project-schema",t,e]:null,{data:a,isLoading:i}=v(n,async()=>L(a,await w(e??"")),b);return U(a,!!n&&(i||a===void 0))}function N(e,t){return Array.isArray(e)&&(e[0]==="project-schema"||e[0]==="project-schemas")&&e.slice(2).includes(t)}function Ie(e){return mutate(t=>N(t,e))}function I(){let{resolvedTheme:e}=b$1();return jsx("div",{className:"fk:flex fk:w-full fk:h-full fk:justify-center fk:items-center fk:bg-background",children:jsxs("div",{className:"fk:flex fk:flex-col fk:items-center",children:[e==="dark"?jsxs("svg",{className:"fk:h-8 fk:w-8 fk:animate-bounce",fill:"none",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M7 8H41V40H7V8Z",fill:"#020817"}),jsx("path",{d:"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z",fill:"white"})]}):jsxs("svg",{className:"fk:h-8 fk:w-8 fk:animate-bounce",fill:"none",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M7 8H41V40H7V8Z",fill:"white"}),jsx("path",{d:"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z",fill:"#020817"})]}),jsx("div",{className:"fk:text-foreground fk:text-center fk:mt-4 fk:animate-pulse",children:"Loading..."})]})})}var G=Navigate;function o(e){let t=lazy(e);return jsx(Suspense,{fallback:jsx(I,{}),children:jsx(t,{})})}var $=o(()=>import('./root-HQQ4TNTR.js').then(e=>({default:e.Root}))),Q=o(()=>import('./list-R7SJFXCX.js').then(e=>({default:e.List}))),Y=o(()=>import('./edit-entity-PVT34FD7.js').then(e=>({default:e.EditEntity}))),ee=o(()=>import('./root-7YXE6DEA.js').then(e=>({default:e.Root}))),te=o(()=>import('./root-OJ4UFMRX.js').then(e=>({default:e.Root}))),oe=o(()=>import('./list-EWWRLK4I.js').then(e=>({default:e.List}))),ne=o(()=>import('./source-3N7BQVYO.js').then(e=>({default:e.Source}))),ae=o(()=>import('./root-4QRY7KAC.js').then(e=>({default:e.Root}))),ie=o(()=>import('./root-NYAXP66A.js').then(e=>({default:e.Root}))),re=o(()=>import('./root-FNXHGVQT.js').then(e=>({default:e.Root}))),se=o(()=>import('./plugin-pages-X3V2VPAU.js').then(e=>({default:e.PluginsPage}))),pe=o(()=>import('./plugin-pages-X3V2VPAU.js').then(e=>({default:e.InstalledPluginsPage}))),ce=o(()=>import('./plugin-pages-X3V2VPAU.js').then(e=>({default:e.PluginDetailPage}))),R=o(()=>import('./chat-page-JS5SJ4OG.js').then(e=>({default:e.AgentChatPage}))),le=o(()=>import('./pages-UKJWXOMO.js').then(e=>({default:e.AutomationsPage}))),me=o(()=>import('./pages-UKJWXOMO.js').then(e=>({default:e.RunHistoryPage}))),ue=o(()=>import('./pages-UKJWXOMO.js').then(e=>({default:e.ApprovalsPage}))),de=o(()=>import('./pages-UKJWXOMO.js').then(e=>({default:e.ActivityPage}))),he=o(()=>import('./pages-UKJWXOMO.js').then(e=>({default:e.ActivityItemPage}))),fe=o(()=>import('./pages-UKJWXOMO.js').then(e=>({default:e.CreateAutomationPage}))),ge=o(()=>import('./pages-UKJWXOMO.js').then(e=>({default:e.AutomationDetailPage}))),ye=o(()=>import('./pages-UKJWXOMO.js').then(e=>({default:e.RunsPage}))),Pe=o(()=>import('./pages-UKJWXOMO.js').then(e=>({default:e.RunDetailPage}))),Se=o(()=>import('./skills-pages-W47HECK3.js').then(e=>({default:e.SkillsPage}))),ke=o(()=>import('./skills-pages-W47HECK3.js').then(e=>({default:e.CreateSkillPage}))),je=o(()=>import('./skills-pages-W47HECK3.js').then(e=>({default:e.SkillDetailPage}))),m=[{name:"ai",icon:jsx(Bot,{strokeWidth:1.5}),title:"AI",component:re,routes:[{path:"plugins",component:se},{path:"plugins/installed",component:pe},{path:"plugins/:pluginId",component:ce},{component:jsx(G,{replace:true,to:"agent"}),path:""},{component:R,path:"agent"},{component:R,path:"agent/chats/:chatId"},{component:le,path:"automations"},{component:me,path:"runs"},{component:ue,path:"approvals"},{component:de,path:"activity"},{component:he,path:"activity/:itemId"},{component:fe,path:"automations/new"},{component:ge,path:"automations/:automationId"},{component:ye,path:"automations/:automationId/runs"},{component:Pe,path:"automations/:automationId/runs/:runId"},{component:Se,path:"skills"},{component:ke,path:"skills/new"},{component:je,path:"skills/:skillId"}]},{name:"desk",icon:jsx(Layout,{strokeWidth:1.5}),title:"Desk",component:$,routes:[{path:"list/:entity",component:Q,children:[{path:"edit/:id",component:Y}]}]},{name:"asset-manager",icon:jsx(FileStack,{strokeWidth:1.5}),title:"Asset Manager",component:ee,routes:[]},{name:"knowledge",icon:jsx(BookOpenText,{strokeWidth:1.5}),title:"Knowledge",component:te,routes:[{component:oe,path:""},{component:ne,path:":sourceId"}]},{name:"graph",icon:jsx(Waypoints,{strokeWidth:1.5}),title:"Graph",component:ae,routes:[]},{name:"explorer",icon:jsx(SquarePlay,{strokeWidth:1.5}),title:"Explorer",component:ie,routes:[]}];var V=createContext({mode:"projects",apps:m,contributions:{apps:m},currentProjectId:void 0,currentProject:void 0,currentProjectSchema:[],projects:[],projectIds:[],projectSummaries:[],schemaErrors:{},isLoadingSchemas:false});function we(e){return [...e.filter(n=>n.name!==f.name&&n.name!==g.name),f,g]}function Ke({projectIds:e,projectSummaries:t=[],mode:n="projects",userId:a,children:i}){let{projectId:p}=useParams(),[,l]=g$1(),u=l.user?.id??a,F=A(n==="projects"?e:[],u),H=E(n==="hosted"&&p&&e.includes(p)?p:void 0,u),{projects:P,errors:S,isLoading:k}=n==="hosted"?H:F,d=useMemo(()=>e.map(s=>P.find(h=>h.projectId===s)).filter(s=>s!==void 0).map(s=>({...s,schema:we(s.schema)})),[P,e]),M=useMemo(()=>{let s=d.find(h=>h.projectId===p);return {mode:n,apps:m,contributions:{apps:m},currentProjectId:p,currentProject:s,currentProjectSchema:s?.schema??[],projects:d,projectIds:e,projectSummaries:t,schemaErrors:S,isLoadingSchemas:k}},[p,S,k,n,e,t,d]);return jsx(V.Provider,{value:M,children:i})}function Ge(){return useContext(V)}
2
- export{I as a,f as b,g as c,Ie as d,Ke as e,Ge as f};//# sourceMappingURL=chunk-XLFAJBPN.js.map
3
- //# sourceMappingURL=chunk-XLFAJBPN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/entities/assets-schema.ts","../src/entities/tags-schema.ts","../src/core/config/use-project-schemas.ts","../src/ui/components/loading.tsx","../src/core/apps/built-in-apps.tsx","../src/core/config/config-context.tsx"],"names":["assetSchema","tagSchema","fetchProjectSchema","projectId","response","apiPaths","message","body","project","error","toProjectSchemasState","outcomes","isLoading","projects","errors","outcome","SCHEMA_SWR_OPTIONS","keepLoadedSchema","previous","next","useProjectSchemas","projectIds","userId","key","data","useSWR","index","toProjectSchemaState","useProjectSchema","isProjectSchemaKey","revalidateProjectSchema","mutate","Loading","resolvedTheme","useTheme","jsx","jsxs","NavigateCompat","Navigate","lazyElement","loader","Component","lazy","Suspense","deskRoot","m","deskList","deskEditEntity","assetManagerRoot","knowledgeRoot","knowledgeList","knowledgeSource","graphRoot","explorerRoot","aiRoot","aiPluginsPage","aiInstalledPluginsPage","aiPluginDetailPage","aiAgentChatPage","aiAutomationsPage","aiRunHistoryPage","aiApprovalsPage","aiActivityPage","aiActivityItemPage","aiCreateAutomationPage","aiAutomationDetailPage","aiRunsPage","aiRunDetailPage","aiSkillsPage","aiCreateSkillPage","aiSkillDetailPage","builtInApps","BotIcon","LayoutIcon","FileStackIcon","BookOpenTextIcon","WaypointsIcon","SquarePlayIcon","ConfigContext","createContext","upsertReservedEntities","schema","entity","ConfigProvider","projectSummaries","mode","children","currentProjectId","useParams","auth","useAuth","schemaUserId","allSchemas","currentSchema","loadedProjects","useMemo","value","currentProject","useConfig","useContext"],"mappings":"uXAEO,IAAMA,CAAAA,CAAsB,CACjC,IAAA,CAAM,QAAA,CACN,OAAQ,SAAA,CACR,OAAA,CAAS,kBAAA,CACT,IAAA,CAAM,CACJ,MAAA,CAAQ,IACV,CAAA,CACA,UAAA,CAAY,CACV,CACE,IAAA,CAAM,OACN,KAAA,CAAO,OAAA,CACP,KAAA,CAAO,QAAA,CACP,OAAA,CAAS,CACP,KAAM,GACR,CAAA,CACA,SAAU,QAAA,CACV,SAAA,CAAW,OACX,WAAA,CAA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,CACtF/E,CAAAA,CAAWkF,OAAAA,CACf,IACE1E,EACG,GAAA,CAAKlB,CAAAA,EAAc2F,EAAe,IAAA,CAAMtF,CAAAA,EAAYA,EAAQ,SAAA,GAAcL,CAAS,CAAC,CAAA,CACpF,MAAA,CAAQK,CAAAA,EAAwCA,IAAY,MAAS,CAAA,CACrE,IAAKA,CAAAA,GAAa,CAAE,GAAGA,CAAAA,CAAS,MAAA,CAAQwE,EAAAA,CAAuBxE,CAAAA,CAAQ,MAAM,CAAE,EAAE,CAAA,CACtF,CAACsF,EAAgBzE,CAAU,CAC7B,EAEM2E,CAAAA,CAAQD,OAAAA,CAAuB,IAAM,CACzC,IAAME,CAAAA,CAAiBpF,EAAS,IAAA,CAAML,CAAAA,EAAYA,CAAAA,CAAQ,SAAA,GAAc+E,CAAgB,CAAA,CAExF,OAAO,CACL,IAAA,CAAAF,CAAAA,CACA,IAAA,CAAMd,CAAAA,CACN,aAAA,CAAe,CAAE,IAAA,CAAMA,CAAY,EACnC,gBAAA,CAAAgB,CAAAA,CACA,eAAAU,CAAAA,CACA,oBAAA,CAAsBA,CAAAA,EAAgB,MAAA,EAAU,EAAC,CACjD,SAAApF,CAAAA,CACA,UAAA,CAAAQ,CAAAA,CACA,gBAAA,CAAA+D,CAAAA,CACA,YAAA,CAActE,EACd,gBAAA,CAAkBF,CACpB,CACF,CAAA,CAAG,CAAC2E,CAAAA,CAAkBzE,EAAQF,CAAAA,CAAWyE,CAAAA,CAAMhE,EAAY+D,CAAAA,CAAkBvE,CAAQ,CAAC,CAAA,CAEtF,OAAOsB,GAAAA,CAAC2C,CAAAA,CAAc,QAAA,CAAd,CAAuB,MAAOkB,CAAAA,CAAQ,QAAA,CAAAV,CAAAA,CAAS,CACzD,CAEO,SAASY,IAA2B,CACzC,OAAOC,UAAAA,CAAWrB,CAAa,CACjC","file":"chunk-XLFAJBPN.js","sourcesContent":["import type { Entity } from '../core/types';\n\nexport const assetSchema: Entity = {\n name: '_asset',\n plural: '_assets',\n display: 'originalFilename',\n menu: {\n hidden: true,\n },\n attributes: [\n {\n name: 'path',\n label: 'Asset',\n scope: 'global',\n options: {\n size: 140,\n },\n dataType: 'string',\n inputType: 'text',\n previewType: 'assetPreviewField',\n defaultValue: '',\n },\n {\n name: 'originalFilename',\n label: 'Filename',\n scope: 'global',\n options: {\n size: 320,\n },\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'size',\n label: 'Size',\n scope: 'global',\n options: {\n size: 120,\n },\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'width',\n label: 'Width',\n scope: 'global',\n options: {\n size: 90,\n },\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'height',\n label: 'Height',\n scope: 'global',\n options: {\n size: 100,\n },\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'mimeType',\n label: 'Mime Type',\n scope: 'global',\n options: {\n size: 160,\n },\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'lqip',\n label: 'lqip',\n scope: 'global',\n hidden: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'url',\n label: 'URL',\n scope: 'global',\n hidden: true,\n readOnly: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: '_updatedAt',\n label: 'Updated At',\n scope: 'global',\n options: {\n size: 220,\n },\n readOnly: true,\n hidden: true,\n dataType: 'datetime',\n inputType: 'datetime',\n previewType: 'datetime',\n defaultValue: '',\n },\n {\n name: 'tags',\n label: 'Tags',\n scope: 'relationship',\n dataType: 'string',\n inputType: 'relationship',\n defaultValue: '',\n previewType: 'tags',\n options: {\n size: 300,\n },\n relationship: {\n mode: 'multiple',\n field: 'name',\n entity: '_tag',\n },\n },\n ],\n};\n","import type { Entity } from '../core/types';\n\nexport const tagSchema: Entity = {\n name: '_tag',\n plural: '_tags',\n display: 'name',\n menu: {\n hidden: true,\n },\n attributes: [\n {\n name: 'name',\n label: 'Tag Name',\n scope: 'global',\n options: {\n size: 220,\n },\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: '_updatedAt',\n label: 'Updated At',\n scope: 'global',\n options: {\n size: 220,\n },\n readOnly: true,\n hidden: true,\n dataType: 'datetime',\n inputType: 'datetime',\n previewType: 'datetime',\n defaultValue: '',\n },\n {\n name: 'assets',\n label: 'Assets',\n scope: 'relationship',\n dataType: 'string',\n inputType: 'relationship',\n defaultValue: '',\n relationship: {\n mode: 'multiple',\n field: 'originalFilename',\n entity: '_asset',\n },\n },\n ],\n};\n","'use client';\n\nimport useSWR, { mutate } from 'swr';\nimport { apiPaths } from '../api-paths';\nimport type { ProjectSchemaError, ProjectUiConfig } from './types';\n\nexport type ProjectSchemasState = {\n projects: ProjectUiConfig[];\n errors: { [projectId: string]: ProjectSchemaError };\n isLoading: boolean;\n};\n\nexport type FetchOutcome =\n | { ok: true; project: ProjectUiConfig }\n | { ok: false; projectId: string; error: ProjectSchemaError };\n\nasync function fetchProjectSchema(projectId: string): Promise<FetchOutcome> {\n try {\n const response = await fetch(apiPaths(projectId).schema, {\n credentials: 'include',\n mode: 'cors',\n // Revalidate with the server on every fetch (304 when unchanged), so a\n // refetch after a deploy never reads a stale HTTP-cached schema.\n cache: 'no-cache',\n });\n\n if (!response.ok) {\n let message = response.statusText || `Request failed with status ${String(response.status)}`;\n\n try {\n const body = (await response.json()) as { error?: string; message?: string };\n message = body.error ?? body.message ?? message;\n } catch {\n // keep the status text\n }\n\n return { ok: false, projectId, error: { status: response.status, message } };\n }\n\n const project = (await response.json()) as ProjectUiConfig;\n\n return { ok: true, project: { ...project, projectId: project.projectId || projectId } };\n } catch (error) {\n return {\n ok: false,\n projectId,\n error: { status: 0, message: error instanceof Error ? error.message : 'Network error' },\n };\n }\n}\n\nexport function toProjectSchemasState(outcomes: FetchOutcome[] | undefined, isLoading: boolean): ProjectSchemasState {\n const projects: ProjectUiConfig[] = [];\n const errors: { [projectId: string]: ProjectSchemaError } = {};\n\n for (const outcome of outcomes ?? []) {\n if (outcome.ok) {\n projects.push(outcome.project);\n } else {\n errors[outcome.projectId] = outcome.error;\n }\n }\n\n return { projects, errors, isLoading };\n}\n\n/**\n * Schemas change on deploy, which can happen outside this tab (the agent, the\n * CLI). Refetch when the user comes back to the tab, at most every 15s;\n * SWR compares the result, so an unchanged schema does not re-render.\n */\nconst SCHEMA_SWR_OPTIONS = {\n revalidateOnFocus: true,\n focusThrottleInterval: 15_000,\n revalidateOnReconnect: false,\n} as const;\n\n/**\n * A refetch (tab focus, reload button, watched deploy) must never replace a\n * schema that already loaded with an error: that would swap the whole app for\n * an error screen and drop an open edit drawer. Offline, an expired session or\n * revoked access still surface through the GraphQL requests themselves.\n */\nexport function keepLoadedSchema(previous: FetchOutcome | undefined, next: FetchOutcome): FetchOutcome {\n return !next.ok && previous?.ok ? previous : next;\n}\n\n/**\n * Loads the deployed schema of every project the Studio can open. Fetching\n * starts once the user is known (the endpoint needs a session). The result is\n * refetched on tab focus, on the list's reload button and after a deploy the\n * Studio watched.\n */\nexport function useProjectSchemas(projectIds: string[], userId: string | undefined): ProjectSchemasState {\n const key = userId && projectIds.length > 0 ? ['project-schemas', userId, ...projectIds] : null;\n const { data, isLoading } = useSWR(\n key,\n async (): Promise<FetchOutcome[]> => {\n const outcomes = await Promise.all(projectIds.map((projectId) => fetchProjectSchema(projectId)));\n\n // The key fixes the order of projectIds, so outcomes line up with the previous data.\n return outcomes.map((outcome, index) => keepLoadedSchema(data?.[index], outcome));\n },\n SCHEMA_SWR_OPTIONS\n );\n\n return toProjectSchemasState(data, Boolean(key) && (isLoading || data === undefined));\n}\n\n/** State of a single project's schema, in the same shape as the multi-project hook. */\nexport function toProjectSchemaState(outcome: FetchOutcome | undefined, isLoading: boolean): ProjectSchemasState {\n return toProjectSchemasState(outcome ? [outcome] : undefined, isLoading);\n}\n\n/**\n * Hosted mode: loads only the project currently open. Each project has its own\n * SWR key, so switching back to a project reuses the schema already fetched.\n */\nexport function useProjectSchema(projectId: string | undefined, userId: string | undefined): ProjectSchemasState {\n const key = userId && projectId ? ['project-schema', userId, projectId] : null;\n const { data, isLoading } = useSWR(\n key,\n async (): Promise<FetchOutcome> => keepLoadedSchema(data, await fetchProjectSchema(projectId ?? '')),\n SCHEMA_SWR_OPTIONS\n );\n\n return toProjectSchemaState(data, Boolean(key) && (isLoading || data === undefined));\n}\n\n/** True for the SWR keys that hold `projectId`'s schema (single- and multi-project hooks). */\nexport function isProjectSchemaKey(key: unknown, projectId: string): boolean {\n return (\n Array.isArray(key) &&\n (key[0] === 'project-schema' || key[0] === 'project-schemas') &&\n key.slice(2).includes(projectId)\n );\n}\n\n/** Refetches the deployed schema of `projectId`, e.g. after the agent deployed a schema change. */\nexport function revalidateProjectSchema(projectId: string): Promise<unknown> {\n return mutate((key) => isProjectSchemaKey(key, projectId));\n}\n","import type { JSX } from 'react';\nimport { useTheme } from '../theme-context';\n\nexport function Loading(): JSX.Element {\n const { resolvedTheme } = useTheme();\n\n return (\n <div className=\"fk:flex fk:w-full fk:h-full fk:justify-center fk:items-center fk:bg-background\">\n <div className=\"fk:flex fk:flex-col fk:items-center\">\n {resolvedTheme === 'dark' ? (\n <svg\n className=\"fk:h-8 fk:w-8 fk:animate-bounce\"\n fill=\"none\"\n viewBox=\"0 0 48 48\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path d=\"M7 8H41V40H7V8Z\" fill=\"#020817\" />\n <path\n d=\"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z\"\n fill=\"white\"\n />\n </svg>\n ) : (\n <svg\n className=\"fk:h-8 fk:w-8 fk:animate-bounce\"\n fill=\"none\"\n viewBox=\"0 0 48 48\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path d=\"M7 8H41V40H7V8Z\" fill=\"white\" />\n <path\n d=\"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z\"\n fill=\"#020817\"\n />\n </svg>\n )}\n <div className=\"fk:text-foreground fk:text-center fk:mt-4 fk:animate-pulse\">Loading...</div>\n </div>\n </div>\n );\n}\n","import { lazy, Suspense } from 'react';\nimport type { ComponentType, JSX } from 'react';\nimport {\n BookOpenText as BookOpenTextIcon,\n Bot as BotIcon,\n FileStack as FileStackIcon,\n Layout as LayoutIcon,\n SquarePlay as SquarePlayIcon,\n Waypoints as WaypointsIcon,\n} from 'lucide-react';\nimport { Navigate } from 'react-router-dom';\nimport { Loading } from '../../ui/components/loading';\nimport type { AppOptions } from '../config/types';\n\nconst NavigateCompat = Navigate as unknown as ComponentType<{\n replace?: boolean;\n to: string;\n}>;\n\n/**\n * Wraps a lazily imported component in Suspense so each built-in app (and each of its routes)\n * is only downloaded when it is first rendered.\n */\nfunction lazyElement(loader: () => Promise<{ default: ComponentType }>): JSX.Element {\n const Component = lazy(loader);\n\n return (\n <Suspense fallback={<Loading />}>\n <Component />\n </Suspense>\n );\n}\n\n// Desk\nconst deskRoot = lazyElement(() => import('../../apps/desk/root').then((m) => ({ default: m.Root })));\nconst deskList = lazyElement(() => import('../../apps/desk/list').then((m) => ({ default: m.List })));\nconst deskEditEntity = lazyElement(() =>\n import('../../apps/desk/edit-entity').then((m) => ({ default: m.EditEntity }))\n);\n\n// Asset Manager\nconst assetManagerRoot = lazyElement(() => import('../../apps/asset-manager/root').then((m) => ({ default: m.Root })));\n\n// Knowledge\nconst knowledgeRoot = lazyElement(() => import('../../apps/knowledge/root').then((m) => ({ default: m.Root })));\nconst knowledgeList = lazyElement(() => import('../../apps/knowledge/list').then((m) => ({ default: m.List })));\nconst knowledgeSource = lazyElement(() => import('../../apps/knowledge/source').then((m) => ({ default: m.Source })));\n\n// Graph\nconst graphRoot = lazyElement(() => import('../../apps/graph/root').then((m) => ({ default: m.Root })));\n\n// Explorer\nconst explorerRoot = lazyElement(() => import('../../apps/explorer/root').then((m) => ({ default: m.Root })));\n\n// AI\nconst aiRoot = lazyElement(() => import('../../apps/ai/root').then((m) => ({ default: m.Root })));\nconst aiPluginsPage = lazyElement(() => import('../../apps/ai/plugin-pages').then((m) => ({ default: m.PluginsPage })));\nconst aiInstalledPluginsPage = lazyElement(() =>\n import('../../apps/ai/plugin-pages').then((m) => ({ default: m.InstalledPluginsPage }))\n);\nconst aiPluginDetailPage = lazyElement(() =>\n import('../../apps/ai/plugin-pages').then((m) => ({ default: m.PluginDetailPage }))\n);\nconst aiAgentChatPage = lazyElement(() =>\n import('../../apps/ai/agent/chat-page').then((m) => ({ default: m.AgentChatPage }))\n);\nconst aiAutomationsPage = lazyElement(() =>\n import('../../apps/ai/pages').then((m) => ({ default: m.AutomationsPage }))\n);\nconst aiRunHistoryPage = lazyElement(() => import('../../apps/ai/pages').then((m) => ({ default: m.RunHistoryPage })));\nconst aiApprovalsPage = lazyElement(() => import('../../apps/ai/pages').then((m) => ({ default: m.ApprovalsPage })));\nconst aiActivityPage = lazyElement(() => import('../../apps/ai/pages').then((m) => ({ default: m.ActivityPage })));\nconst aiActivityItemPage = lazyElement(() =>\n import('../../apps/ai/pages').then((m) => ({ default: m.ActivityItemPage }))\n);\nconst aiCreateAutomationPage = lazyElement(() =>\n import('../../apps/ai/pages').then((m) => ({ default: m.CreateAutomationPage }))\n);\nconst aiAutomationDetailPage = lazyElement(() =>\n import('../../apps/ai/pages').then((m) => ({ default: m.AutomationDetailPage }))\n);\nconst aiRunsPage = lazyElement(() => import('../../apps/ai/pages').then((m) => ({ default: m.RunsPage })));\nconst aiRunDetailPage = lazyElement(() => import('../../apps/ai/pages').then((m) => ({ default: m.RunDetailPage })));\nconst aiSkillsPage = lazyElement(() => import('../../apps/ai/skills-pages').then((m) => ({ default: m.SkillsPage })));\nconst aiCreateSkillPage = lazyElement(() =>\n import('../../apps/ai/skills-pages').then((m) => ({ default: m.CreateSkillPage }))\n);\nconst aiSkillDetailPage = lazyElement(() =>\n import('../../apps/ai/skills-pages').then((m) => ({ default: m.SkillDetailPage }))\n);\n\nexport const builtInApps: AppOptions[] = [\n {\n name: 'ai',\n icon: <BotIcon strokeWidth={1.5} />,\n title: 'AI',\n component: aiRoot,\n routes: [\n { path: 'plugins', component: aiPluginsPage },\n { path: 'plugins/installed', component: aiInstalledPluginsPage },\n { path: 'plugins/:pluginId', component: aiPluginDetailPage },\n {\n component: <NavigateCompat replace to=\"agent\" />,\n path: '',\n },\n {\n component: aiAgentChatPage,\n path: 'agent',\n },\n {\n component: aiAgentChatPage,\n path: 'agent/chats/:chatId',\n },\n {\n component: aiAutomationsPage,\n path: 'automations',\n },\n {\n component: aiRunHistoryPage,\n path: 'runs',\n },\n {\n component: aiApprovalsPage,\n path: 'approvals',\n },\n {\n component: aiActivityPage,\n path: 'activity',\n },\n {\n component: aiActivityItemPage,\n path: 'activity/:itemId',\n },\n {\n component: aiCreateAutomationPage,\n path: 'automations/new',\n },\n {\n component: aiAutomationDetailPage,\n path: 'automations/:automationId',\n },\n {\n component: aiRunsPage,\n path: 'automations/:automationId/runs',\n },\n {\n component: aiRunDetailPage,\n path: 'automations/:automationId/runs/:runId',\n },\n {\n component: aiSkillsPage,\n path: 'skills',\n },\n {\n component: aiCreateSkillPage,\n path: 'skills/new',\n },\n {\n component: aiSkillDetailPage,\n path: 'skills/:skillId',\n },\n ],\n },\n {\n name: 'desk',\n icon: <LayoutIcon strokeWidth={1.5} />,\n title: 'Desk',\n component: deskRoot,\n routes: [\n {\n path: 'list/:entity',\n component: deskList,\n children: [\n {\n path: 'edit/:id',\n component: deskEditEntity, // Not used, left here as an example of how to nest routes in apps\n },\n ],\n },\n ],\n },\n {\n name: 'asset-manager',\n icon: <FileStackIcon strokeWidth={1.5} />,\n title: 'Asset Manager',\n component: assetManagerRoot,\n routes: [],\n },\n {\n name: 'knowledge',\n icon: <BookOpenTextIcon strokeWidth={1.5} />,\n title: 'Knowledge',\n component: knowledgeRoot,\n routes: [\n {\n component: knowledgeList,\n path: '',\n },\n {\n component: knowledgeSource,\n path: ':sourceId',\n },\n ],\n },\n {\n name: 'graph',\n icon: <WaypointsIcon strokeWidth={1.5} />,\n title: 'Graph',\n component: graphRoot,\n routes: [],\n },\n {\n name: 'explorer',\n icon: <SquarePlayIcon strokeWidth={1.5} />,\n title: 'Explorer',\n component: explorerRoot,\n routes: [],\n },\n];\n","'use client';\n\nimport { createContext, useContext, useMemo } from 'react';\nimport type { JSX } from 'react';\nimport { useParams } from 'react-router-dom';\nimport { useAuth } from '../../auth/auth-context';\nimport { assetSchema } from '../../entities/assets-schema';\nimport { tagSchema } from '../../entities/tags-schema';\nimport { builtInApps } from '../apps/built-in-apps';\nimport type { AppOptions, ProjectSchemaError, ProjectSummary, ProjectUiConfig, StudioMode } from './types';\nimport type { Entity } from '../types';\nimport { useProjectSchema, useProjectSchemas } from './use-project-schemas';\n\nexport interface ConfigContext {\n /** `projects` when the host passed `projectIds`, `hosted` when the Studio listed the user's projects itself. */\n mode: StudioMode;\n /** The Studio apps shown in the app bar, in order. */\n apps: AppOptions[];\n /** Kept for callers that read `contributions.apps`; same list as `apps`. */\n contributions: {\n apps: AppOptions[];\n };\n currentProjectId?: string;\n /** The project named by the `:projectId` route param, once its schema has loaded. */\n currentProject?: ProjectUiConfig;\n currentProjectSchema: Entity[];\n /** Projects whose schema loaded, in `projectIds` order. */\n projects: ProjectUiConfig[];\n /** Every project id the Studio can open, loaded or not. */\n projectIds: string[];\n /** Hosted mode: name, avatar, role and team of each project, known before any schema loads. */\n projectSummaries: ProjectSummary[];\n /** Per project id: why its schema could not be loaded. */\n schemaErrors: { [projectId: string]: ProjectSchemaError };\n isLoadingSchemas: boolean;\n}\n\nconst ConfigContext = createContext<ConfigContext>({\n mode: 'projects',\n apps: builtInApps,\n contributions: { apps: builtInApps },\n currentProjectId: undefined,\n currentProject: undefined,\n currentProjectSchema: [],\n projects: [],\n projectIds: [],\n projectSummaries: [],\n schemaErrors: {},\n isLoadingSchemas: false,\n});\n\n/** Appends the reserved asset and tag entities to a deployed schema. */\nexport function upsertReservedEntities(schema: Entity[]): Entity[] {\n const withoutReserved = schema.filter((entity) => entity.name !== assetSchema.name && entity.name !== tagSchema.name);\n\n return [...withoutReserved, assetSchema, tagSchema];\n}\n\nexport function ConfigProvider({\n projectIds,\n projectSummaries = [],\n mode = 'projects',\n userId,\n children,\n}: {\n projectIds: string[];\n projectSummaries?: ProjectSummary[];\n mode?: StudioMode;\n /** Hosted mode: the signed-in user's id, known before the per-project `/users/me` call. */\n userId?: string;\n children: React.ReactNode;\n}): JSX.Element {\n /**\n * Getting the projectId from the URL via react-router-dom's useParams hook triggers a rerender of this Context\n * every time the URL changes.\n */\n const { projectId: currentProjectId } = useParams<{ projectId: string }>();\n const [, auth] = useAuth();\n const schemaUserId = auth.user?.id ?? userId;\n // Project mode loads every project up front (short, host-defined list); hosted mode only the one open.\n const allSchemas = useProjectSchemas(mode === 'projects' ? projectIds : [], schemaUserId);\n const currentSchema = useProjectSchema(\n mode === 'hosted' && currentProjectId && projectIds.includes(currentProjectId) ? currentProjectId : undefined,\n schemaUserId\n );\n const { projects: loadedProjects, errors, isLoading } = mode === 'hosted' ? currentSchema : allSchemas;\n const projects = useMemo(\n () =>\n projectIds\n .map((projectId) => loadedProjects.find((project) => project.projectId === projectId))\n .filter((project): project is ProjectUiConfig => project !== undefined)\n .map((project) => ({ ...project, schema: upsertReservedEntities(project.schema) })),\n [loadedProjects, projectIds]\n );\n\n const value = useMemo<ConfigContext>(() => {\n const currentProject = projects.find((project) => project.projectId === currentProjectId);\n\n return {\n mode,\n apps: builtInApps,\n contributions: { apps: builtInApps },\n currentProjectId,\n currentProject,\n currentProjectSchema: currentProject?.schema ?? [],\n projects,\n projectIds,\n projectSummaries,\n schemaErrors: errors,\n isLoadingSchemas: isLoading,\n };\n }, [currentProjectId, errors, isLoading, mode, projectIds, projectSummaries, projects]);\n\n return <ConfigContext.Provider value={value}>{children}</ConfigContext.Provider>;\n}\n\nexport function useConfig(): ConfigContext {\n return useContext(ConfigContext);\n}\n"]}
@@ -1,3 +0,0 @@
1
- import'./index.css';import {a as a$1}from'./chunk-CLCIE5RF.js';import {a}from'./chunk-EMFHKTAV.js';import {e,b as b$1,j as j$1,n,c as c$3,i as i$1,h as h$1,l as l$1,o,k as k$2}from'./chunk-6GXNHR6H.js';import'./chunk-2NXQF2F7.js';import {c}from'./chunk-CAZ6EUR2.js';import {b}from'./chunk-V7C4EHK3.js';import {w,j,d,x,c as c$2,a as a$2,e as e$3,k as k$1,i as i$2,f,g}from'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import'./chunk-XLFAJBPN.js';import'./chunk-WPCPL2TQ.js';import'./chunk-5CVDMZUI.js';import {Tc,Vc,s,c as c$1,d as d$1,na,$,aa,da,ea,ba,O,e as e$2,qa,fa}from'./chunk-DGIY4SKN.js';import {t}from'./chunk-SZEGGBOC.js';import {v,c as c$5,h,i,k,l,j as j$2,b as b$4}from'./chunk-32ZU4MLE.js';import'./chunk-U45E5X3H.js';import'./chunk-HDOIOXMP.js';import {b as b$3,c as c$4,e as e$1}from'./chunk-USNXQOMJ.js';import {b as b$2}from'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {useState,useRef,useMemo,useEffect}from'react';import {formatDistance,format}from'date-fns';import {SearchIcon,XIcon,ListIcon,LayoutGridIcon,LinkIcon,UploadIcon,LoaderCircle}from'lucide-react';import {useNavigate,Link}from'react-router-dom';import st from'swr/infinite';import {jsx,jsxs}from'react/jsx-runtime';var He=25,it=3e3,rt=250;function ft(t,a){let[o,s]=useState(t);return useEffect(()=>{let r=setTimeout(()=>s(t),a);return ()=>clearTimeout(r)},[a,t]),o}var dt={failed:"No document failed to index.",processing:"No document is being indexed right now.",ready:"No document is ready yet."};function ct({viewMode:t$1}){let a=["a","b","c","d","e","f"];return t$1==="grid"?jsxs("div",{"aria-busy":"true",className:Oe,children:[jsx("span",{className:"fk:sr-only",children:"Loading documents"}),a.map(o=>jsxs("div",{className:"fk:flex fk:flex-col fk:gap-3 fk:rounded-xl fk:border fk:p-3 fk:corner-squircle",children:[jsxs("span",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(t,{className:"fk:size-6 fk:rounded-md"}),jsx(t,{className:"fk:h-4 fk:flex-1"})]}),jsx(t,{className:"fk:aspect-[4/3] fk:w-full fk:rounded-lg"})]},o))]}):jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col",children:[jsx("span",{className:"fk:sr-only",children:"Loading documents"}),a.map(o=>jsxs("div",{className:"fk:flex fk:h-12 fk:items-center fk:gap-3 fk:border-b fk:px-3",children:[jsx(t,{className:"fk:size-6 fk:shrink-0 fk:rounded-md"}),jsx(t,{className:"fk:h-4 fk:w-1/3"}),jsx(t,{className:"fk:ml-auto fk:h-4 fk:w-16"}),jsx(t,{className:"fk:hidden fk:h-4 fk:w-24 fk:md:block"})]},o))]})}function kt(t,a){let[o,s]=useState([]),r=useRef(Promise.resolve());function m(p){if(t)for(let f of p){let u=e$3(f);if(u){qa.error(u);continue}let d={id:`${f.name}-${String(Date.now())}-${String(Math.random())}`,name:f.name};s(i=>[...i,d]),r.current=r.current.then(async()=>{try{let i=await t.addFile(f);i$1(i,f.name),a();}catch(i){qa.error(h$1(i,`${f.name} could not be added.`));}finally{s(i=>i.filter(w=>w.id!==d.id));}}).catch(()=>{});}}return {addFiles:m,pending:o}}function ut({api:t,onOpenChange:a,onRegistered:o,open:s$1}){let[r,m]=useState(""),[p,f]=useState(""),[u,d]=useState(""),[i$2,w]=useState(false);function N(){a(false),m(""),f(""),d("");}async function K(c){c.preventDefault();let x=g(r);if("error"in x){d(x.error);return}w(true),d("");try{let E=await t.addUrl({title:p.trim()||void 0,url:x.url});i$1(E,x.url),o(),N();}catch(E){d(h$1(E,"The page could not be added."));}finally{w(false);}}return jsx(c$5,{open:s$1,onOpenChange:c=>c?a(true):N(),children:jsx(h,{children:jsxs("form",{className:"fk:flex fk:flex-col fk:gap-4",onSubmit:c=>{K(c);},children:[jsxs(i,{children:[jsx(k,{children:"Add a web page"}),jsx(l,{children:"The page is fetched and indexed now, and again whenever you re-index it. Only public pages work."})]}),jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1.5",children:[jsx(e$2,{htmlFor:"knowledge-url",children:"Address"}),jsx(s,{autoFocus:true,id:"knowledge-url",inputMode:"url",placeholder:"https://example.com/help/returns",value:r,onChange:c=>{m(c.target.value),d("");}})]}),jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1.5",children:[jsx(e$2,{htmlFor:"knowledge-url-title",children:"Title (optional)"}),jsx(s,{id:"knowledge-url-title",maxLength:a$2,placeholder:"Defaults to the page address",value:p,onChange:c=>f(c.target.value)})]}),u?jsx("p",{className:"fk:text-sm fk:text-destructive",children:u}):null,jsxs(j$2,{children:[jsx(b$2,{disabled:i$2,size:"sm",type:"button",variant:"outline",onClick:N,children:"Cancel"}),jsxs(b$2,{disabled:i$2||!r.trim(),size:"sm",type:"submit",children:[i$2?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):jsx(LinkIcon,{className:"fk:size-4"}),"Add page"]})]})]})})})}var Oe="fk:grid fk:grid-cols-[repeat(auto-fill,minmax(14rem,1fr))] fk:gap-4";function mt(t){return format(new Date(t),"MMM d, yyyy")}function Ue(){return jsx(b$4,{className:"fk:shrink-0 fk:corner-squircle",variant:"outline",children:"Hidden from agent"})}function Ge(){return jsx(b$4,{className:"fk:shrink-0 fk:corner-squircle","data-knowledge-content-match":true,variant:"secondary",children:"In content"})}function pt(t,a){let o=t.target;t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||!t.currentTarget.contains(o)||o.closest("a, button")||a();}function gt({source:t,...a}){let o$1=k$1(t),s=o$1.tone==="ready"?"fk:hidden fk:xl:inline":"fk:hidden fk:md:inline";return jsxs(da,{className:"fk:h-12 fk:cursor-pointer","data-knowledge-row":true,onClick:r=>pt(r,()=>a.onOpen(t)),children:[jsx(fa,{className:"fk:max-w-0 fk:w-full",children:jsxs("span",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-3",children:[jsx(l$1,{source:t}),jsx(Link,{className:"fk:truncate fk:text-sm fk:font-medium fk:hover:underline fk:underline-offset-2 fk:focus-visible:outline-none fk:focus-visible:underline",to:t.id,children:t.title}),t.matchedIn==="content"?jsx(Ge,{}):null,t.agentVisible?null:jsx(Ue,{})]})}),jsx(fa,{className:"fk:whitespace-nowrap",children:jsxs("span",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(k$2,{label:o$1.label,tone:o$1.tone}),jsx("span",{className:`${s} fk:max-w-64 fk:truncate fk:text-xs fk:text-muted-foreground`,title:o$1.detail,children:o$1.detail})]})}),jsx(fa,{className:"fk:hidden fk:whitespace-nowrap fk:text-muted-foreground fk:md:table-cell",children:i$2(t)}),jsx(fa,{className:"fk:hidden fk:whitespace-nowrap fk:text-right fk:tabular-nums fk:text-muted-foreground fk:md:table-cell",children:t.size===null?"\u2014":f(t.size)}),jsx(fa,{className:"fk:hidden fk:whitespace-nowrap fk:text-muted-foreground fk:sm:table-cell",children:jsxs(b$3,{children:[jsx(c$4,{asChild:true,children:jsx("span",{children:mt(t.createdAt)})}),jsxs(e$1,{children:["Updated ",formatDistance(new Date(t.updatedAt),new Date,{addSuffix:true})]})]})}),jsx(fa,{className:"fk:w-12 fk:pr-2 fk:text-right",children:jsx(o,{source:t,onOpen:()=>a.onOpen(t),onRemoved:()=>a.onRemoved(t)})})]})}function ht({sources:t,...a}){return jsxs($,{"data-knowledge-list":true,children:[jsx(aa,{children:jsxs(da,{className:"fk:hover:bg-transparent",children:[jsx(ea,{children:"Name"}),jsx(ea,{children:"Status"}),jsx(ea,{className:"fk:hidden fk:md:table-cell",children:"Type"}),jsx(ea,{className:"fk:hidden fk:text-right fk:md:table-cell",children:"Size"}),jsx(ea,{className:"fk:hidden fk:sm:table-cell",children:"Added"}),jsx(ea,{className:"fk:w-12",children:jsx("span",{className:"fk:sr-only",children:"Actions"})})]})}),jsx(ba,{children:t.map(o=>jsx(gt,{source:o,...a},o.id))})]})}function bt({source:t}){let a=t.preview?.trim();return jsx("div",{className:"fk:relative fk:aspect-[4/3] fk:overflow-hidden fk:rounded-lg fk:bg-muted fk:corner-squircle",children:a?jsxs("div",{"aria-hidden":true,className:"fk:absolute fk:inset-x-4 fk:top-3 fk:bottom-0 fk:overflow-hidden fk:rounded-t-sm fk:bg-background fk:px-3 fk:pt-3 fk:shadow-sm",children:[jsx("p",{className:"fk:whitespace-pre-line fk:text-[9px] fk:leading-[1.45] fk:text-foreground/80 fk:select-none",children:a}),jsx("span",{className:"fk:pointer-events-none fk:absolute fk:inset-x-0 fk:bottom-0 fk:h-10 fk:bg-gradient-to-t fk:from-background fk:to-transparent"})]}):jsx("div",{className:"fk:flex fk:h-full fk:items-center fk:justify-center",children:jsx(l$1,{size:56,source:t})})})}function vt({source:t,...a}){let o$1=k$1(t),s=[i$2(t)];return t.size!==null&&s.push(f(t.size)),s.push(o$1.detail),jsxs("div",{className:"fk:relative fk:flex fk:min-w-0 fk:flex-col fk:gap-3 fk:rounded-xl fk:border fk:bg-card fk:p-3 fk:transition-colors fk:hover:bg-accent/60 fk:has-[>a:focus-visible]:ring-2 fk:has-[>a:focus-visible]:ring-ring fk:corner-squircle","data-knowledge-card":true,title:t.title,children:[jsx(Link,{"aria-label":`Open ${t.title}`,className:"fk:absolute fk:inset-0 fk:rounded-xl fk:focus-visible:outline-none fk:corner-squircle",to:t.id}),jsxs("span",{className:"fk:pointer-events-none fk:relative fk:flex fk:min-w-0 fk:items-center fk:gap-2",children:[jsx(l$1,{source:t}),jsx("span",{className:"fk:min-w-0 fk:flex-1 fk:truncate fk:text-sm fk:font-medium",children:t.title}),jsx("span",{className:"fk:pointer-events-auto fk:-my-1 fk:-mr-1.5",children:jsx(o,{source:t,onOpen:()=>a.onOpen(t),onRemoved:()=>a.onRemoved(t)})})]}),jsx("span",{className:"fk:pointer-events-none fk:relative",children:jsx(bt,{source:t})}),jsxs("span",{className:"fk:pointer-events-none fk:relative fk:flex fk:min-w-0 fk:items-center fk:gap-2",children:[jsx(k$2,{label:o$1.label,tone:o$1.tone}),jsx("span",{className:"fk:min-w-0 fk:flex-1 fk:truncate fk:text-xs fk:text-muted-foreground",children:s.join(" \xB7 ")}),t.matchedIn==="content"?jsx(Ge,{}):null,t.agentVisible?null:jsx(Ue,{})]})]})}function wt({sources:t,...a}){return jsx("div",{className:Oe,"data-knowledge-grid":true,children:t.map(o=>jsx(vt,{source:o,...a},o.id))})}function Nt(){return jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2 fk:pr-4",children:[jsxs(b$3,{children:[jsx(c$4,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:h-4"}),jsx("h1",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:"Knowledge"})]})}function Pt(){let{api:t,projectId:a$2}=e(),o=useNavigate(),s$1=b(),r=c(),m=a(),[p,f]=useState(""),u=ft(p.trim(),rt),[d$2,i]=useState(()=>w()),[w$1,N]=useState(false),K=useRef(null),c$4=useRef(null),[x$1,E]=useState(false),Ve=(l,T)=>!a$2||T&&!T.hasMore?null:c$3(a$2).sources({limit:He,offset:l*He,search:u||void 0,status:m}),{data:h,isLoading:Xe,mutate:L,setSize:A,size:Je}=st(Ve,b$1,{refreshInterval:r&&x$1?it:0}),S=useMemo(()=>h?.flatMap(l=>l.sources)??[],[h]),z=h?.[0]?.count??0,qe=h?.[h.length-1]?.hasMore??false,te=h!==void 0&&Je>h.length,$e=Xe&&S.length===0,{addFiles:ne,pending:ae}=kt(t,()=>{L();}),oe=useRef(L);oe.current=L,useEffect(()=>{oe.current();},[]),useEffect(()=>{E(S.some(l=>j(l)));},[S]);let le=useRef(A);if(le.current=A,useEffect(()=>{le.current(1);},[u]),!a$2||!t)return jsx(j$1,{children:"Select a project to manage its knowledge."});function je(l){let T=Array.from(l.target.files??[]);l.target.value="",ne(T);}let P=`No documents yet. Upload ${d} files, or add a public web page, and the agent will search and cite them.`;u?P="No document title or content matches your search.":m&&(P=dt[m]);let se={onOpen:l=>{o(l.id);},onRemoved:l=>{L(T=>T?.map(F=>({...F,count:Math.max(0,F.count-1),sources:F.sources.filter(We=>We.id!==l.id)})),{revalidate:true});}},R=d$2==="grid"?jsx(wt,{sources:S,...se}):jsx(ht,{sources:S,...se});return $e?R=jsx(ct,{viewMode:d$2}):S.length===0&&(R=jsx(Tc,{children:jsx(Vc,{children:P})})),jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsx(Nt,{}),jsx(a$1,{disabled:!s$1,onDropFiles:ne,children:jsx("div",{className:"fk:min-h-0 fk:flex-1 fk:overflow-auto",children:jsxs("div",{className:"fk:flex fk:w-full fk:flex-col fk:gap-5 fk:py-4 fk:pl-4 fk:pr-6",children:[jsxs("div",{children:[jsx("h2",{className:"fk:text-2xl fk:font-semibold",children:"Documents"}),jsx("p",{className:"fk:mt-1 fk:text-sm fk:text-muted-foreground",children:"Policies, manuals, specs and other reference material for your team and agents. The agent searches them when a question needs them and cites the passage it used."})]}),jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:[jsxs("div",{className:"fk:relative fk:w-full fk:max-w-sm",children:[jsx(SearchIcon,{className:"fk:pointer-events-none fk:absolute fk:left-2.5 fk:top-1/2 fk:size-4 fk:-translate-y-1/2 fk:text-muted-foreground"}),jsx(s,{"aria-label":"Search documents",className:"fk:pl-8 fk:pr-9",placeholder:"Search by title or content\u2026",ref:c$4,value:p,onChange:l=>f(l.target.value)}),p?jsx(b$2,{"aria-label":"Clear search",className:"fk:absolute fk:right-1.5 fk:top-1/2 fk:flex fk:size-6 fk:-translate-y-1/2 fk:items-center fk:justify-center fk:rounded-full fk:bg-transparent fk:text-muted-foreground fk:hover:bg-foreground/10 fk:hover:text-foreground fk:corner-squircle","data-knowledge-clear-search":true,type:"button",onClick:()=>{f(""),c$4.current?.focus();},children:jsx(XIcon,{className:"fk:size-4"})}):null]}),z>0?jsxs("span",{className:"fk:text-sm fk:text-muted-foreground",children:[z.toLocaleString()," ",z===1?"document":"documents"]}):null,jsxs("div",{className:"fk:ml-auto fk:flex fk:items-center fk:gap-2",children:[jsxs(c$1,{"aria-label":"Layout",size:"sm",type:"single",value:d$2,variant:"outline",onValueChange:l=>{(l==="list"||l==="grid")&&(i(l),x(l));},children:[jsx(d$1,{"aria-label":"List layout",value:"list",children:jsx(ListIcon,{className:"fk:size-4"})}),jsx(d$1,{"aria-label":"Grid layout",value:"grid",children:jsx(LayoutGridIcon,{className:"fk:size-4"})})]}),jsx(na,{disabled:!s$1,children:jsxs(b$2,{disabled:!s$1,size:"sm",variant:"outline",onClick:()=>N(true),children:[jsx(LinkIcon,{}),"Add web page"]})}),jsx(na,{disabled:!s$1,children:jsxs(b$2,{disabled:!s$1,size:"sm",onClick:()=>K.current?.click(),children:[jsx(UploadIcon,{}),"Upload documents"]})}),jsx("input",{accept:c$2,className:"fk:hidden",multiple:true,ref:K,type:"file",onChange:je})]})]}),ae.length>0?jsx("div",{className:"fk:flex fk:flex-col fk:gap-1 fk:text-sm fk:text-muted-foreground",children:ae.map(l=>jsxs("span",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),"Uploading ",l.name,"\u2026"]},l.id))}):null,R,qe&&!te?jsx(n,{onVisible:()=>{A(l=>l+1);}}):null,te?jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:py-4 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),jsx("span",{children:"Loading more documents..."})]}):null]})})}),jsx(ut,{api:t,open:w$1,onOpenChange:N,onRegistered:()=>{L();}})]})}
2
- export{Pt as List};//# sourceMappingURL=list-EWWRLK4I.js.map
3
- //# sourceMappingURL=list-EWWRLK4I.js.map
@@ -1,2 +0,0 @@
1
- import'./index.css';import {c as c$2,a as a$1}from'./chunk-OMYDXVWS.js';import {m as m$2,a,b,d as d$2}from'./chunk-5NQ47SWN.js';import'./chunk-CAZ6EUR2.js';import'./chunk-2DXR5NJV.js';import {m as m$1,d,s}from'./chunk-D76P4TER.js';import'./chunk-V7C4EHK3.js';import {e}from'./chunk-GXQSNOGM.js';import {c}from'./chunk-XMOSCJOI.js';import'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import'./chunk-YDVO6XWD.js';import'./chunk-ERDARDGB.js';import {f,d as d$1}from'./chunk-XLFAJBPN.js';import'./chunk-WPCPL2TQ.js';import'./chunk-5CVDMZUI.js';import {O}from'./chunk-DGIY4SKN.js';import {t}from'./chunk-SZEGGBOC.js';import {v}from'./chunk-32ZU4MLE.js';import'./chunk-U45E5X3H.js';import'./chunk-HDOIOXMP.js';import {b as b$1,c as c$1,e as e$1}from'./chunk-USNXQOMJ.js';import'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {useState,useMemo,useCallback}from'react';import {useParams,useLocation,Outlet}from'react-router-dom';import {jsx,jsxs}from'react/jsx-runtime';var m=36,pt=[{_updatedAt:"DESC"},{_id:"DESC"}];function Mt(){let{entity:t}=useParams(),{search:a$1}=useLocation(),h=new URLSearchParams(a$1).get("id"),{scope:W}=c(),{schemaErrorMessage:B}=e(),{currentProject:O$1,currentProjectId:f$1}=f(),S=O$1?.schema??[],n=m$1(S,t??""),[r,k]=useState([]),[F,H]=useState(0),[Y,Z]=useState(t);t!==Y&&(Z(t),k([]));let y=m$2({attributesSchema:n?.attributes??[],actionsComponent:o=>gt({entityName:n?.name??"",entityNamePlural:t??"",row:o}),checkboxSelect:"multiple",enableColumnSorting:true}),u=useMemo(()=>{if(r.length===0)return pt;let o=r.map(({id:p,desc:mt})=>({[p]:mt?"DESC":"ASC"}));return o.some(p=>"_id"in p)?o:[...o,{_id:"DESC"}]},[r]),b$2=useMemo(()=>{if(r.length!==0)return d(u,n)},[n,u,r.length]),$=h?{where:{_id:{eq:h}}}:{offset:0,limit:m,sort:u,...b$2?{where:b$2}:{}},{isLoading:tt,isLoadingMore:et,fetchMore:C,reload:N,count:i,data:l,isProjectDisabled:ot}=s({entityNamePlural:t??"",schema:S,scope:W,variables:$,selection:"list"});function nt(o){k(o);}let T=l?.length??0,rt=i>0&&T>0&&T<i,at=useCallback(()=>{C({variables:{offset:0,limit:m}});},[C]),it=useCallback(()=>{H(w=>w+1),(f$1?d$1(f$1):Promise.resolve()).catch(()=>{}).then(()=>N());},[f$1,N]),lt=Array(m).fill({}),st=ht(y),s$1=tt&&(l==null||l.length===0);return ot?jsx("div",{className:"fk:flex fk:flex-col fk:h-full fk:px-4 fk:pt-3",children:jsx(a,{})}):jsxs("div",{className:"fk:flex fk:flex-col fk:h-full fk:px-4 fk:pt-3",children:[jsx(b,{}),jsxs("div",{className:"fk:flex fk:items-center fk:mb-4 fk:gap-2",children:[jsxs(b$1,{children:[jsx(c$1,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:w-4 fk:h-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:h-4"}),jsx("h2",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:dt(n?.menu?.label??n?.plural??"")}),s$1?null:jsxs("span",{className:"fk:ml-auto fk:text-sm fk:font-normal fk:text-muted-foreground",children:[i.toLocaleString()," ",i===1?"record":"records"]})]}),B?null:jsx(d$2,{columns:s$1?st:y,data:s$1?lt:l??[],entityName:n?.name??"",hasMore:rt,isLoadingMore:et,pageSize:m,scrollToTopKey:F,sorting:r,onLoadMore:at,onSortingChange:nt,toolbarComponent:o=>jsx(c$2,{entityName:n?.name??"",isReloading:s$1,onReload:it,table:o})}),jsx(Outlet,{})]})}function dt(t){return t.charAt(0).toUpperCase()+t.slice(1)}function gt({entityName:t,entityNamePlural:a,row:g}){return jsx(a$1,{entityName:t,entityNamePlural:a,row:g})}function ht(t$1){return t$1.map(a=>({...a,cell:()=>jsx(t,{className:"fk:h-4 fk:w-full",style:{marginTop:"7px",marginBottom:"6px"}})}))}export{Mt as List};//# sourceMappingURL=list-R7SJFXCX.js.map
2
- //# sourceMappingURL=list-R7SJFXCX.js.map
@@ -1,5 +0,0 @@
1
- import'./index.css';import {f as f$3,b as b$6,c as c$4,d as d$2,e as e$4,g as g$4}from'./chunk-CSUHZFEP.js';import {x,a,b as b$4,d,c as c$3,y,C,D,B,g as g$2,h as h$1,i,f as f$2,z,I,E,H,e as e$3,F}from'./chunk-LF4B2TQI.js';import {a as a$5}from'./chunk-57X5WRMY.js';import {a as a$4}from'./chunk-QSTWBKPN.js';import {c as c$2,a as a$1,b as b$5,e as e$2,d as d$1,g as g$6,i as i$1,h as h$2}from'./chunk-KN7OJFEX.js';import {a as a$2}from'./chunk-54AXLGAK.js';import {b as b$7,d as d$4}from'./chunk-5LGIALCK.js';import {f,g,e as e$7,c as c$6,d as d$5}from'./chunk-U6VZY3V2.js';import'./chunk-6GXNHR6H.js';import'./chunk-2NXQF2F7.js';import {c as c$1}from'./chunk-CAZ6EUR2.js';import {b}from'./chunk-V7C4EHK3.js';import'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import {f as f$4}from'./chunk-XLFAJBPN.js';import {g as g$3}from'./chunk-WPCPL2TQ.js';import'./chunk-5CVDMZUI.js';import {$,aa as aa$1,da,ea,ba,fa,O,f as f$1,na as na$1,ha as ha$1,ia as ia$1,ja,ab,bb,db,qa,s,e as e$5,_,la as la$1,t as t$1,u,v as v$1}from'./chunk-DGIY4SKN.js';import {e,g as g$1,h,j,o,t,q,r,s as s$1,k}from'./chunk-SZEGGBOC.js';import {b as b$1,v,w,x as x$1,m,o as o$1,p,q as q$1,r as r$1,t as t$2}from'./chunk-32ZU4MLE.js';import'./chunk-U45E5X3H.js';import {a as a$3,d as d$3,c as c$5,e as e$6,g as g$5}from'./chunk-HDOIOXMP.js';import {b as b$3,c,e as e$1}from'./chunk-USNXQOMJ.js';import {b as b$2}from'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {useState,useRef,useMemo,useCallback,useEffect,useTransition,Fragment as Fragment$1,useId}from'react';import {formatDistance,format}from'date-fns';import {Ellipsis,Pencil,Trash2,Plus,ArrowLeft,LoaderCircle,Play,XIcon,TriangleAlertIcon,ZapIcon,BotIcon,Search,X,CoinsIcon,BrainIcon,Trash2Icon,LoaderCircleIcon,GraduationCapIcon,WrenchIcon,Settings2Icon,BellIcon,ClockIcon,WebhookIcon,DatabaseZapIcon,CircleCheckBigIcon,RefreshCwIcon,PlusIcon,ChevronDownIcon,LockIcon,CheckIcon,ChevronsUpDownIcon,CopyIcon,KeyRoundIcon}from'lucide-react';import {useNavigate,Link,useParams}from'react-router-dom';import {useReactTable,getCoreRowModel}from'@tanstack/react-table';import De,{useSWRConfig}from'swr';import It from'swr/infinite';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {CronExpressionParser}from'cron-parser';var Ua=[{kind:"approval_request",label:"Approval requests"},{kind:"automation_failure",label:"Automation failures"},{kind:"automation_result",label:"Automation results"},{kind:"monitor_event",label:"Chat monitors"},{kind:"question",label:"Agent questions"}];function $o({checked:t,disabled:n,label:o,onCheckedChange:i}){let l=useId();return jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-3",children:[jsx("label",{className:"fk:text-sm",htmlFor:l,children:o}),jsx(_,{checked:t,disabled:n,id:l,onCheckedChange:i})]})}function Vo(){let{mode:t}=f$4(),{isLoaded:n,mutate:o,preferences:i}=g$6(),[l,k]=useState(false);async function f(c){k(true);try{await o(h$2(c),{optimisticData:{preferences:c},rollbackOnError:!0});}catch{qa.error("Unable to save your notification settings.");}finally{k(false);}}function g(c,p){let d=new Set(i.desktopMutedKinds);p?d.delete(c):d.add(c),f({...i,desktopMutedKinds:[...d]});}return jsxs(t$1,{children:[jsx(u,{asChild:true,children:jsx(b$2,{"aria-label":"Notification settings",className:"fk:ml-auto",size:"icon",variant:"ghost",children:jsx(Settings2Icon,{className:"fk:size-4"})})}),jsxs(v$1,{align:"end",className:"fk:w-80 fk:space-y-4",children:[jsxs("div",{className:"fk:space-y-2",children:[jsx("p",{className:"fk:text-sm fk:font-medium",children:"Desktop notifications"}),jsxs("p",{className:"fk:text-xs fk:text-muted-foreground",children:[t==="hosted"?"Shown while Studio is in the background, and while your browser runs with no Studio tab open.":"Shown while Studio is open in the background."," ","Activity always keeps every item."]}),Ua.map(({kind:c,label:p})=>jsx($o,{checked:!i.desktopMutedKinds.includes(c),disabled:l||!n,label:p,onCheckedChange:d=>g(c,d)},c))]}),jsxs("div",{className:"fk:space-y-2",children:[jsx("p",{className:"fk:text-sm fk:font-medium",children:"Email"}),jsx($o,{checked:i.approvalEmail,disabled:l||!n,label:"Approval requests I haven\u2019t read",onCheckedChange:c=>{f({...i,approvalEmail:c});}})]}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"These settings apply to every project you open."})]})]})}var Za=[{label:"Enabled",value:"enabled"},{label:"Disabled",value:"disabled"}],Ya=[{label:"Project",value:"project"},{label:"Space",value:"space"},{label:"Personal",value:"personal"}];function Qa(t,n=300){let o,i=function(...l){o!==void 0&&clearTimeout(o),o=setTimeout(()=>{o=void 0,t.apply(this,l);},n);};return i.cancel=()=>{o!==void 0&&(clearTimeout(o),o=void 0);},i}function Jo({actions:t,isSearchLoading:n=false,onSearchChange:o,search:i,searchPlaceholder:l="Search automations...",table:k}){let f=k.getState().columnFilters.length>0||i.trim().length>0,g=k.getAllColumns().find(P=>P.id==="status"),c=k.getAllColumns().find(P=>P.id==="visibility"),[p,d]=useState(i),v=p.trim(),C=i.trim(),T=v.length>0&&(n||v!==C),j=useRef(o);j.current=o;let A=useMemo(()=>Qa(P=>{j.current(P);},300),[]);useEffect(()=>{d(i);},[i]),useEffect(()=>()=>{A.cancel();},[A]);function x(){A.cancel(),d(""),o("");}function b(){k.resetColumnFilters(),x();}return jsx("div",{className:"fk:flex fk:w-full fk:min-w-0",children:jsxs(w,{className:"fk:w-0 fk:min-w-0 fk:flex-1 fk:whitespace-nowrap fk:-ml-0.75",children:[jsxs("div",{className:"fk:flex fk:w-full fk:items-center fk:justify-between fk:gap-3 fk:p-0.75 fk:pb-2.5",children:[jsxs("div",{className:"fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs("div",{className:"fk:relative",children:[T?jsx(LoaderCircle,{className:"fk:absolute fk:left-2 fk:top-2 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50 fk:animate-spin"}):jsx(Search,{className:"fk:absolute fk:left-2 fk:top-2 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50"}),jsx(s,{className:"fk:h-8 fk:w-37.5 fk:lg:w-70 fk:px-7 fk:text-sm",name:"search-automations",placeholder:l,value:p,onChange:P=>{let{value:F}=P.target;if(d(F),F.trim().length===0){A.cancel(),o("");return}A(F.trim());}}),p?jsx(b$2,{"aria-label":"Clear search",className:"fk:absolute fk:right-1 fk:top-1 fk:h-6 fk:w-6 fk:text-muted-foreground fk:hover:text-foreground fk:hover:bg-foreground/10 fk:cursor-pointer fk:rounded-full fk:bg-transparent fk:corner-squircle",onClick:x,type:"button",children:jsx(X,{className:"fk:h-4 fk:w-4"})}):null]}),g?jsx(a$2,{column:g,options:Za,title:"Status"}):null,c?jsx(a$2,{column:c,options:Ya,title:"Visibility"}):null,f?jsxs(b$2,{className:"fk:h-8 fk:px-2 fk:lg:px-3",onClick:b,variant:"ghost",children:["Reset",jsx(X,{className:"fk:ml-2 fk:h-4 fk:w-4"})]}):null]}),t?jsx("div",{className:"fk:ml-auto fk:flex fk:shrink-0 fk:items-center fk:gap-3",children:t}):null]}),jsx(x$1,{orientation:"horizontal"})]})})}function Sn(t,n,o){return (o??[]).some(i=>i.toLowerCase().includes(n.trim().toLowerCase()))?1:0}function Xt({disabled:t,emptyText:n,footer:o,items:i,searchPlaceholder:l,triggerLabel:k="Attach",onToggle:f}){let[g,c]=useState(false),p$1=useRef(null);return jsxs(t$1,{open:g,onOpenChange:c,children:[jsx(u,{asChild:true,children:jsxs(b$2,{disabled:t,size:"sm",type:"button",variant:"outline",children:[k,jsx(ChevronDownIcon,{className:"fk:ml-1 fk:size-4"})]})}),jsx(v$1,{align:"end",className:"fk:w-72 fk:p-0",onOpenAutoFocus:d=>{d.preventDefault(),p$1.current?.focus({preventScroll:true});},children:jsxs(m,{filter:Sn,children:[jsx(o$1,{placeholder:l,ref:p$1}),jsxs(p,{className:"fk:max-h-72",children:[jsx(q$1,{children:n}),jsx(r$1,{children:i.map(d=>jsxs(t$2,{disabled:!!d.lockedHint,title:d.lockedHint,value:d.id,keywords:[d.label],onSelect:()=>f(d.id,!d.attached),children:[d.lockedHint?jsx(LockIcon,{className:"fk:size-4"}):jsx(CheckIcon,{className:d.attached?"fk:size-4":"fk:size-4 fk:opacity-0"}),jsx("span",{className:"fk:truncate",children:d.label}),d.badge?jsx(b$1,{className:"fk:ml-auto fk:py-0 fk:text-[10px]",variant:"secondary",children:d.badge}):null]},d.id))})]}),o]})})]})}function Ho(t){return t==="project"?"Project":"Personal"}function Tt(t,n){return t.connections.filter(o=>o.scope===n&&o.status==="connected")}function In(t,n){if(!n)return null;let o=Tt(t,n.connectionMode);return n.connectionId?o.find(i=>i.id===n.connectionId)??null:o.find(i=>i.isPrimary)??null}function Nt(t){return t?t.connectionId?`account:${t.connectionId}`:`primary:${t.connectionMode}`:""}function Pn({ariaLabel:t,disabled:n,plugin:o,scopes:i,value:l,onChange:k}){let f=[];for(let c of i){let p=Tt(o,c),d=p.find(C=>C.isPrimary),[v]=p;if(p.length===1&&v){let C=l?.connectionMode===c&&l.connectionId===v.id;f.push({choice:{connectionMode:c,connectionId:C||!v.isPrimary?v.id:null},label:`${Ho(c)} \xB7 ${v.displayName}`});continue}d&&f.push({choice:{connectionMode:c,connectionId:null},label:`Primary ${c} account (${d.displayName})`});for(let C of p)f.push({choice:{connectionMode:c,connectionId:C.id},label:`${Ho(c)} \xB7 ${C.displayName}`});}let g=Nt(l);return jsxs(a$3,{disabled:n,value:f.some(c=>Nt(c.choice)===g)?g:"",onValueChange:c=>{let p=f.find(d=>Nt(d.choice)===c);p&&k(p.choice);},children:[jsx(d$3,{"aria-label":t,className:"fk:w-fit fk:max-w-full",size:"sm",children:jsx(c$5,{placeholder:"Select account"})}),jsx(e$6,{children:f.map(c=>jsx(g$5,{value:Nt(c.choice),children:c.label},Nt(c.choice)))})]})}var wn=2;function Wo(t){return t.scopes.filter(n=>n==="project"||t.allowPersonal)}function fs(t){let n=Wo(t),o=n.includes("personal")&&(!n.includes("project")||Tt(t,"project").length===0&&Tt(t,"personal").length>0);return {pluginId:t.id,enabled:true,connectionMode:o?"personal":"project",connectionId:null,allTools:true,selectedTools:[],deliveryEnabled:false,channels:[]}}function us(t,n){return `${encodeURIComponent(t)}:${encodeURIComponent(n)}`}function ds(t){return decodeURIComponent(t.slice(t.indexOf(":")+1))}function ms(t){let n=t.map(ds),o=n.slice(0,wn).join(", ");return n.length>wn?`${o} +${n.length-wn} more`:o}function ks({canManage:t,disabled:n,plugin:o$1,projectId:i,usage:l,onChange:k,onRemove:f$1}){let g=Wo(o$1),c=g.some(w=>Tt(o$1,w).length>0),p=g.includes(l.connectionMode)?{connectionMode:l.connectionMode,connectionId:l.connectionId}:null,d=In(o$1,p),{data:v$1,error:C}=De(d?`/api/flexkit/${i}/plugin-connections/${d.id}/tools`:null,f),T=(v$1?.servers??[]).flatMap(w=>w.tools.map(H=>({key:us(w.name,H.name),entry:H}))),j$1=(v$1?.servers??[]).flatMap(w=>w.error?[w.error]:[]),A=l.allTools!==false,x=n||!o$1.enabled,b=w=>k({...l,allTools:false,selectedTools:w,enabled:w.length>0}),P=()=>k({...l,allTools:true,selectedTools:[],enabled:true}),F=w=>({...l,connectionMode:w.connectionMode,connectionId:w.connectionId,selectedTools:[],enabled:A}),{mutate:S}=useSWRConfig(),[_,M]=useState(false),B=async w=>{M(true);try{if(!await d$4(d$5(i),o$1,w))return;await S(`/api/flexkit/${i}/plugins`),k(F({connectionMode:w,connectionId:null}));}catch(H){qa.error(H instanceof Error?H.message:`Unable to connect ${o$1.name}.`);}finally{M(false);}},U=null;return o$1.enabled?c?p?d?C||j$1.length?U={text:j$1[0]??"Unable to load tools. Reconnect or try again.",tone:"warning"}:A?U={text:"All tools",tone:"muted"}:l.selectedTools.length===0?U={text:"No tools selected, so the agent cannot use this plugin yet.",tone:"warning"}:U={text:ms(l.selectedTools),tone:"muted"}:U={text:p.connectionId?"The selected account is no longer connected.":`The primary ${p.connectionMode} account needs reconnecting.`,tone:"warning"}:U={text:"Select an account.",tone:"warning"}:U={text:`Connect ${o$1.name} to use its tools.`,tone:"warning"}:U={text:"Disabled by project policy.",tone:"warning"},jsxs(Fragment,{children:[jsxs("div",{className:"fk:m-1.5 fk:flex fk:flex-wrap fk:items-center fk:justify-between fk:gap-x-3 fk:gap-y-2 fk:rounded-md fk:px-1.25 fk:py-1.5 fk:hover:bg-muted fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:items-center fk:gap-2.5",children:[jsx(a$4,{className:"fk:size-5 fk:self-start fk:rounded",src:o$1.logoUrl}),jsxs("div",{className:"fk:min-w-0",children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:o$1.name}),jsx("p",{className:U.tone==="warning"?"fk:truncate fk:text-xs fk:text-warning":"fk:truncate fk:text-xs fk:text-muted-foreground",children:U.text}),l.connectionMode==="personal"&&l.enabled?jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Using your account makes this automation personal."}):null]})]}),jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-1.5",children:[c?jsxs(Fragment,{children:[jsx(Pn,{ariaLabel:`${o$1.name} account`,disabled:x,plugin:o$1,scopes:g,value:p,onChange:w=>{w.connectionMode===l.connectionMode&&w.connectionId===l.connectionId||k(F(w));}}),jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsxs(b$2,{disabled:x||!d||!v$1,size:"sm",type:"button",variant:"outline",children:[A?"All tools":l.selectedTools.length?`Tools (${l.selectedTools.length})`:"Select tools",jsx(ChevronDownIcon,{className:"fk:ml-1 fk:size-4"})]})}),jsxs(h,{align:"end",className:"fk:max-h-80 fk:w-80 fk:overflow-y-auto",children:[jsxs(j,{className:"fk:items-start",onSelect:w=>{w.preventDefault(),A?b(T.map(H=>H.key)):P();},children:[jsx(CheckIcon,{className:A?"fk:mt-0.5 fk:size-4":"fk:mt-0.5 fk:size-4 fk:opacity-0"}),jsxs("span",{className:"fk:min-w-0",children:[jsx("span",{className:"fk:block",children:"All tools (recommended)"}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Includes tools added later. Uncheck to pick specific ones."})]})]}),jsx(o,{}),T.map(({key:w,entry:H})=>{let $=A||l.selectedTools.includes(w);return jsxs(j,{className:"fk:items-start",onSelect:he=>{he.preventDefault();let q=A?T.map(be=>be.key):l.selectedTools;b($?q.filter(be=>be!==w):[...q,w]);},children:[jsx(CheckIcon,{className:$?"fk:mt-0.5 fk:size-4":"fk:mt-0.5 fk:size-4 fk:opacity-0"}),jsxs("span",{className:"fk:min-w-0",children:[jsx("span",{className:"fk:block",children:H.name}),H.description?jsx("span",{className:"fk:line-clamp-2 fk:text-xs fk:text-muted-foreground",children:H.description}):null]})]},w)}),v$1&&T.length===0?jsx(j,{disabled:true,children:"This account exposes no tools."}):null]})]})]}):jsx(a$5,{busy:_||n,canManage:t,plugin:o$1,onConnect:w=>{B(w);}}),jsx(b$2,{"aria-label":`Remove ${o$1.name} from automation`,disabled:n,size:"icon",type:"button",variant:"ghost",onClick:f$1,children:jsx(Trash2Icon,{className:"fk:size-4"})})]})]}),jsx(v,{})]})}function ps({disabled:t,plugins:n,onAdd:o}){let[i,l]=useState(false),k=useRef(null);return jsxs(t$1,{open:i,onOpenChange:l,children:[jsx(u,{asChild:true,children:jsxs("button",{className:"fk:m-1.5 fk:flex fk:w-[calc(100%-0.75rem)] fk:cursor-pointer fk:items-center fk:gap-2.5 fk:rounded-md fk:px-1.25 fk:py-1.5 fk:text-left fk:text-sm fk:text-muted-foreground fk:hover:bg-muted fk:hover:text-foreground disabled:fk:cursor-not-allowed disabled:fk:opacity-50 fk:corner-squircle",disabled:t||n.length===0,type:"button",children:[jsx(PlusIcon,{className:"fk:size-5"}),"Plugin tools"]})}),jsx(v$1,{align:"start",className:"fk:w-72 fk:p-0",onOpenAutoFocus:f=>{f.preventDefault(),k.current?.focus({preventScroll:true});},children:jsxs(m,{filter:Sn,children:[jsx(o$1,{placeholder:"Search plugins\u2026",ref:k}),jsxs(p,{children:[jsx(q$1,{children:"No plugins found."}),jsx(r$1,{children:n.map(f=>jsxs(t$2,{value:f.id,keywords:[f.name],onSelect:()=>{o(f),l(false);},children:[jsx(a$4,{className:"fk:size-5 fk:rounded",src:f.logoUrl}),jsx("span",{className:"fk:truncate",children:f.name}),f.connections.some(g=>g.status==="connected")?null:jsx("span",{className:"fk:ml-auto fk:text-xs fk:text-muted-foreground",children:"Not connected"})]},f.id))})]})]})})]})}function Go({projectId:t,value:n,disabled:o,onChange:i}){let{data:l,error:k}=De(`/api/flexkit/${t}/plugins`,f),f$1=(l?.plugins??[]).filter(p=>p.capabilities.agentTools),g=new Map(f$1.map(p=>[p.id,p])),c=f$1.filter(p=>p.enabled&&!n.some(d=>d.pluginId===p.id));return jsxs(Fragment,{children:[n.map(p=>{let d=g.get(p.pluginId);return d?jsx(ks,{disabled:o,canManage:l?.canManage??false,plugin:d,projectId:t,usage:p,onChange:v=>i(n.map(C=>C.pluginId===d.id?v:C)),onRemove:()=>i(n.filter(v=>v.pluginId!==d.id))},p.pluginId):null}),k?jsx("p",{className:"fk:mx-3 fk:text-xs fk:text-warning",role:"alert",children:"Unable to load plugins. Your existing selections are preserved."}):null,jsx(ps,{disabled:o||!l,plugins:c,onAdd:p=>i([...n,fs(p)])})]})}var Kt=["slack","teams"],na=["create","update","delete"],ka="0 * * * *",Ss="0 9 * * *",ws="0 9 * * 1",As="0 9 1 * *",Is=[{label:"Monday",value:1},{label:"Tuesday",value:2},{label:"Wednesday",value:3},{label:"Thursday",value:4},{label:"Friday",value:5},{label:"Saturday",value:6},{label:"Sunday",value:0}],Ps=Array.from({length:24},(t,n)=>({label:`${n.toString().padStart(2,"0")}:00`,value:n})),oa={automation_run:"a run of",bulk_action:"a bulk action of",schema_deploy:"a schema deployment"},aa={any:"finishes",failed:"fails",succeeded:"succeeds"},Ms=[{label:"=",value:"eq"},{label:"\u2260",value:"neq"},{label:">",value:"gt"},{label:"\u2265",value:"gte"},{label:"<",value:"lt"},{label:"\u2264",value:"lte"},{label:"contains",value:"contains"},{label:"exists",value:"exists"}],Ln=5,Dn=1440,Rs=15,Mn="__any__";function Es(t){return !t.instructions&&!t.model&&!t.name&&!t.plugins&&!t.space&&Object.keys(t.toolErrors).length===0&&Object.keys(t.triggerErrors).length===0}function sa(t){return t.some(n=>n.enabled&&n.connectionMode==="personal")}function Xe({id:t,message:n}){return n?jsxs("p",{className:"fk:flex fk:items-start fk:text-sm fk:text-warning fk:gap-1",id:t,role:"alert",children:[jsx(TriangleAlertIcon,{className:"fk:size-4 fk:shrink-0 fk:mt-0.5"}),n]}):null}function ft(){return crypto.randomUUID()}function Ls(t){return (t?.triggers??[]).map(n=>({...n,key:n.id??ft()}))}function Ds(t){return t.connected&&t.connectionLabel?`While your local runtime (${t.connectionLabel}) is connected, manually running this automation uses its custom tools so you can test them.`:t.connected?"While `flexkit dev` is connected, manually running this automation uses the custom tools from your local runtime so you can test them.":t.origin?`Using ${t.origin}`:t.tools.length===0?"":"Registered in this project"}function zs(){return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}function Fs(){let t=crypto.getRandomValues(new Uint8Array(24));return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}function _s(t){if(t===ka)return {kind:"hourly"};let n=/^0 (\d{1,2}) \* \* \*$/.exec(t);if(n)return {hour:Number(n[1]),kind:"daily"};let o=/^0 (\d{1,2}) \* \* ([0-6])$/.exec(t);return o?{day:Number(o[2]),hour:Number(o[1]),kind:"weekly"}:{kind:"custom"}}function pa(t,n,o){try{let i=CronExpressionParser.parse(t,{tz:n});return Array.from({length:o},()=>i.next().toDate())}catch{return []}}function ga(t,n){return new Intl.DateTimeFormat("en-US",{day:"numeric",hour:"numeric",minute:"2-digit",month:"short",timeZone:n,weekday:"short"}).format(t)}function va(t,n){let o=t.trim();if(!o)return "Cron expression is required";let i=o.split(/\s+/).length;if(i<5||i>6)return `Expected 5 fields (min hour day month weekday), got ${i.toString()}`;try{return CronExpressionParser.parse(o,{tz:n}),null}catch{return "Invalid cron expression"}}function Bs(t,n,o){let i=t.filter(k=>!k.deprecated);if(n!=="edit"||!o)return i;let l=c$4(t,o);return l?.deprecated?[l,...i.filter(k=>b$6(k)!==o)]:l?i:[{deprecated:true,effort:null,efforts:[],id:o,kind:"model",name:o},...i]}function zn(t){return `${t.teamId??""}:${t.id}`}function js(t,n){let o={};for(let i of [...t,...n])o[zn(i)]=i;return Object.values(o)}function ia(t,n){return {...t,availableChannels:t.channels,channelsLoaded:!t.connected,enabled:t.connected&&n==="edit"&&t.enabled,loadingChannels:false}}function $s(t,n){return {slack:ia(t.providers.slack,n),teams:ia(t.providers.teams,n)}}function Vs({channels:t,disabled:n,loading:o,onChange:i,onRefresh:l,provider:k,value:f}){let[g,c]=useState(false),[p,d]=useState(""),v=useRef(null),C=new Set(f.map(b=>b.id)),T=k==="slack"?"Slack":"Teams",j=t.filter(b=>b.name.toLowerCase().includes(p.toLowerCase()));useEffect(()=>{if(!g)return;function b(F){let{target:S}=F;!(S instanceof Node)||v.current?.contains(S)||c(false);}function P(F){F.key==="Escape"&&c(false);}return document.addEventListener("pointerdown",b),document.addEventListener("keydown",P),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",P);}},[g]);function A(b){if(C.has(b.id)){i(f.filter(P=>P.id!==b.id));return}i([...f,b]);}function x(b){i(f.filter(P=>P.id!==b));}return jsxs("div",{className:"fk:relative",ref:v,children:[jsxs(b$2,{"aria-expanded":g,className:"fk:h-auto fk:min-h-8 fk:w-full fk:max-w-100 fk:justify-between fk:bg-muted/60 fk:px-3 fk:py-1 hover:fk:border-secondary fk:dark:bg-muted/30",disabled:n,role:"combobox",type:"button",variant:"outline",onClick:()=>c(b=>!b),children:[jsx("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:gap-1",children:f.length===0?jsx("span",{className:"fk:text-muted-foreground",children:o?`Loading ${T} channels...`:`Select ${T} channels`}):f.map(b=>jsxs(b$1,{className:"fk:rounded-sm fk:bg-accent fk:text-xs fk:corner-squircle",variant:"secondary",onClick:P=>{P.stopPropagation(),x(b.id);},children:[b.name,jsx(XIcon,{className:"fk:ml-1 fk:size-3 fk:cursor-pointer"})]},zn(b)))}),jsx(ChevronsUpDownIcon,{className:"fk:size-4 fk:shrink-0 fk:opacity-50"})]}),g?jsxs("div",{className:"fk:absolute fk:z-50 fk:mt-1 fk:w-full fk:max-w-100 fk:rounded-md fk:border fk:bg-popover fk:p-0 fk:text-popover-foreground fk:shadow-md fk:corner-squircle",children:[jsx("div",{className:"fk:border-b fk:p-2",children:jsx(s,{className:"fk:h-8",placeholder:`Search ${T} channels...`,value:p,onChange:b=>d(b.target.value)})}),jsx("div",{className:"fk:max-h-56 fk:overflow-auto fk:p-1",children:j.length>0?j.map(b=>jsxs(b$2,{className:"fk:h-auto fk:w-full fk:justify-start fk:rounded-sm fk:px-2 fk:py-1.5 fk:font-normal fk:corner-squircle",type:"button",variant:"ghost",onClick:()=>A(b),children:[jsx(CheckIcon,{className:`fk:mr-2 fk:size-4 ${C.has(b.id)?"fk:opacity-100":"fk:opacity-0"}`}),b.name]},zn(b))):jsx("div",{className:"fk:px-2 fk:py-6 fk:text-center fk:text-sm fk:text-muted-foreground",children:o?"Loading channels...":"No channels found."})}),jsx("div",{className:"fk:border-t fk:border-border fk:p-2",children:jsx(b$2,{className:"fk:h-8 fk:w-full fk:justify-start fk:text-xs",disabled:o,type:"button",variant:"ghost",onClick:l,children:o?jsxs(Fragment,{children:[jsx(LoaderCircleIcon,{className:"fk:mr-2 fk:size-3 fk:animate-spin"}),"Refreshing channels..."]}):jsxs(Fragment,{children:[jsx(RefreshCwIcon,{className:"fk:mr-2 fk:size-3"}),"Refresh channels"]})})})]}):null]})}function Wt({cron:t,timezone:n}){let[o]=pa(t,n,1);return o?jsxs("span",{className:"fk:text-sm fk:text-muted-foreground",children:["Next run ",ga(o,n)]}):null}function la({onChange:t,value:n}){return jsxs(a$3,{value:n.toString(),onValueChange:o=>t(Number(o)),children:[jsx(d$3,{"aria-label":"Hour",className:"fk:h-7 fk:w-fit fk:gap-1 fk:border-transparent fk:bg-background/90 fk:px-2 fk:py-0 fk:text-sm fk:shadow-sm hover:fk:border-border",size:"sm",children:jsx(c$5,{})}),jsx(e$6,{children:Ps.map(o=>jsx(g$5,{value:o.value.toString(),children:o.label},o.value))})]})}function Os({onChange:t,value:n}){return jsxs(a$3,{value:n.toString(),onValueChange:o=>t(Number(o)),children:[jsx(d$3,{"aria-label":"Day of week",className:"fk:h-7 fk:w-fit fk:gap-1 fk:border-transparent fk:bg-background/90 fk:px-2 fk:py-0 fk:text-sm fk:shadow-sm hover:fk:border-border",size:"sm",children:jsx(c$5,{})}),jsx(e$6,{children:Is.map(o=>jsx(g$5,{value:o.value.toString(),children:o.label},o.value))})]})}function qs({onChange:t,timezone:n,value:o}){let[i,l]=useState(false),k=useRef(null),f=va(o,n),g=f?[]:pa(o,n,3);return useEffect(()=>{if(!i)return;function c(d){let{target:v}=d;!(v instanceof Node)||k.current?.contains(v)||l(false);}function p(d){d.key==="Escape"&&l(false);}return document.addEventListener("pointerdown",c),document.addEventListener("keydown",p),()=>{document.removeEventListener("pointerdown",c),document.removeEventListener("keydown",p);}},[i]),jsxs("div",{className:"fk:relative",ref:k,children:[jsxs(b$2,{className:"fk:h-auto fk:gap-1.5 fk:bg-background/90 fk:px-2 fk:py-1 fk:font-mono fk:font-normal fk:shadow-sm hover:fk:bg-accent",type:"button",variant:"ghost",onClick:()=>l(c=>!c),children:[o||"Set cron",jsx(ChevronDownIcon,{className:"fk:size-3.5 fk:opacity-50"})]}),i?jsxs("div",{className:"fk:absolute fk:z-50 fk:mt-1 fk:w-72 fk:rounded-md fk:border fk:bg-popover fk:p-3 fk:text-popover-foreground fk:shadow-md fk:corner-squircle",children:[jsxs("div",{className:"fk:mb-2 fk:text-xs fk:text-muted-foreground",children:["Cron expression (",n,")"]}),jsx(s,{className:`fk:h-8 fk:font-mono ${f?"fk:border-destructive focus-visible:fk:ring-destructive":""}`,value:o,onChange:c=>t(c.target.value)}),f?jsx("p",{className:"fk:mt-2 fk:text-xs fk:text-destructive",children:f}):jsxs("div",{className:"fk:mt-2 fk:space-y-0.5 fk:text-xs fk:text-muted-foreground",children:[jsx("p",{className:"fk:mb-1",children:"5 fields: min hour day month weekday"}),g.map(c=>jsx("p",{children:ga(c,n)},c.toISOString()))]})]}):null]})}function Js({onChange:t,trigger:n}){let o=_s(n.cron);return o.kind==="hourly"?jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"Every hour"}),jsx(Wt,{cron:n.cron,timezone:n.timezone})]}):o.kind==="daily"?jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"Every day at"}),jsx(la,{value:o.hour,onChange:i=>t({...n,cron:`0 ${i.toString()} * * *`})}),jsx("span",{className:"fk:text-muted-foreground",children:n.timezone}),jsx(Wt,{cron:n.cron,timezone:n.timezone})]}):o.kind==="weekly"?jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"Every week on"}),jsx(Os,{value:o.day,onChange:i=>t({...n,cron:`0 ${o.hour.toString()} * * ${i.toString()}`})}),jsx("span",{children:"at"}),jsx(la,{value:o.hour,onChange:i=>t({...n,cron:`0 ${i.toString()} * * ${o.day.toString()}`})}),jsx("span",{className:"fk:text-muted-foreground",children:n.timezone}),jsx(Wt,{cron:n.cron,timezone:n.timezone})]}):jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"Custom schedule"}),jsx(qs,{timezone:n.timezone,value:n.cron,onChange:i=>t({...n,cron:i})}),jsx("span",{className:"fk:text-muted-foreground",children:n.timezone}),jsx(Wt,{cron:n.cron,timezone:n.timezone})]})}function Us({onChange:t,projectId:n,trigger:o}){let[i,l]=useState(false),[k,f]=useState(false),g=o.url??c$6(n,o.token);function c$1(p,d){navigator.clipboard.writeText(p).then(()=>{d(true),window.setTimeout(()=>d(false),1500);});}return jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"Webhook triggered"}),jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsxs(b$2,{className:"fk:h-auto fk:min-w-0 fk:max-w-60 fk:gap-1.5 fk:bg-background/90 fk:px-2 fk:py-1 fk:text-xs fk:font-normal fk:shadow-sm hover:fk:bg-accent",type:"button",variant:"ghost",onClick:()=>c$1(g,l),children:[jsx("span",{className:"fk:truncate",children:g}),i?jsx(CheckIcon,{className:"fk:size-3.5 fk:shrink-0"}):jsx(CopyIcon,{className:"fk:size-3.5 fk:shrink-0 fk:opacity-60"})]})}),jsx(e$1,{className:"fk:max-w-96 fk:break-all",children:g})]}),o.secret?jsxs(b$2,{className:"fk:h-7 fk:px-2.5 fk:text-xs",size:"sm",type:"button",variant:"outline",onClick:()=>c$1(`Bearer ${o.secret??""}`,f),children:[k?jsx(CheckIcon,{className:"fk:size-3.5"}):jsx(KeyRoundIcon,{className:"fk:size-3.5"}),"Copy auth header"]}):jsxs(b$2,{className:"fk:h-7 fk:px-2.5 fk:text-xs",size:"sm",type:"button",variant:"outline",onClick:()=>t({...o,secret:Fs()}),children:[jsx(KeyRoundIcon,{className:"fk:size-3.5"}),"Generate auth header"]})]})}function Hs({entities:t,onChange:n,trigger:o}){function i(f){let g=o.events.includes(f)?o.events.filter(c=>c!==f):[...o.events,f];n({...o,events:na.filter(c=>g.includes(c))});}function l(f){let g=o.entities.includes(f)?o.entities.filter(c=>c!==f):[...o.entities,f];n({...o,entities:g});}let k$1=o.entities.length>0?o.entities.join(", "):"All entities";return jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"On"}),jsx("div",{className:"fk:flex fk:items-center fk:gap-1",children:na.map(f=>jsxs(b$2,{className:"fk:h-7 fk:px-2.5 fk:text-xs fk:capitalize",size:"sm",type:"button",variant:o.events.includes(f)?"secondary":"ghost",onClick:()=>i(f),children:[o.events.includes(f)?jsx(CheckIcon,{className:"fk:size-3"}):null,f]},f))}),jsx("span",{children:"of"}),jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsxs(b$2,{className:"fk:h-7 fk:max-w-60 fk:px-2.5 fk:text-xs",size:"sm",type:"button",variant:"outline",children:[jsx("span",{className:"fk:truncate",children:k$1}),jsx(ChevronDownIcon,{className:"fk:size-3.5 fk:opacity-50"})]})}),jsx(h,{align:"start",className:"fk:max-h-64 fk:w-56 fk:overflow-auto",children:t.length===0?jsx(j,{disabled:true,children:"No entities found in the project schema"}):t.map(f=>jsx(k,{checked:o.entities.includes(f),onCheckedChange:()=>l(f),onSelect:g=>g.preventDefault(),children:f},f))})]})]})}function Xs({automationId:t,onChange:n,projectId:o,trigger:i}){let{data:l}=De(i.job==="schema_deploy"?null:g(o).automations({limit:100}),f),k=(l?.automations??[]).filter(f=>f.id!==t);return jsxs("div",{className:"fk:flex fk:flex-1 fk:flex-wrap fk:items-center fk:gap-2 fk:text-sm",children:[jsx("span",{children:"When"}),jsxs(a$3,{value:i.job,onValueChange:f=>n({...i,automationId:f==="schema_deploy"?null:i.automationId,job:f}),children:[jsx(d$3,{className:"fk:h-7 fk:w-auto fk:text-xs",children:jsx(c$5,{})}),jsx(e$6,{children:Object.keys(oa).map(f=>jsx(g$5,{value:f,children:oa[f]},f))})]}),i.job==="schema_deploy"?null:jsxs(a$3,{value:i.automationId??(i.job==="bulk_action"?Mn:""),onValueChange:f=>n({...i,automationId:f===Mn?null:f}),children:[jsx(d$3,{className:"fk:h-7 fk:w-auto fk:max-w-60 fk:text-xs",children:jsx(c$5,{placeholder:"Choose an automation"})}),jsxs(e$6,{children:[i.job==="bulk_action"?jsx(g$5,{value:Mn,children:"any automation"}):null,k.map(f=>jsx(g$5,{value:f.id,children:f.name},f.id))]})]}),jsxs(a$3,{value:i.outcome,onValueChange:f=>n({...i,outcome:f}),children:[jsx(d$3,{className:"fk:h-7 fk:w-auto fk:text-xs",children:jsx(c$5,{})}),jsx(e$6,{children:Object.keys(aa).map(f=>jsx(g$5,{value:f,children:aa[f]},f))})]})]})}function Ks(t){let n=t.trim();return n==="true"||n==="false"?n==="true":n==="null"?null:n!==""&&Number.isFinite(Number(n))?Number(n):t}function Ws(t){return t===void 0?"":String(t)}function Gs({onChange:t,value:n}){let[o,i]=useState(()=>Ws(n));return jsx(s,{"aria-label":"Value",className:"fk:h-7 fk:w-32 fk:text-xs",placeholder:"10",value:o,onChange:l=>{i(l.target.value),t(Ks(l.target.value));}})}function Zs({onChange:t,trigger:n}){let o=useId(),{condition:i}=n;return jsxs("div",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-2 fk:text-sm",children:[jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsx("span",{children:"Every"}),jsx(s,{"aria-label":"Minutes between checks",className:"fk:h-7 fk:w-16 fk:text-xs",max:Dn,min:Ln,type:"number",value:Number.isFinite(n.intervalMinutes)?n.intervalMinutes:"",onChange:l=>t({...n,intervalMinutes:Number.parseInt(l.target.value,10)})}),jsx("span",{children:"minutes, run when"}),jsxs(a$3,{value:i?"condition":"changed",onValueChange:l=>t({...n,condition:l==="changed"?null:{op:"gte",path:"",value:""}}),children:[jsx(d$3,{className:"fk:h-7 fk:w-auto fk:text-xs",children:jsx(c$5,{})}),jsxs(e$6,{children:[jsx(g$5,{value:"condition",children:"a value meets a condition"}),jsx(g$5,{value:"changed",children:"the result changes"})]})]})]}),i?jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsx(s,{"aria-label":"Path in the result",className:"fk:h-7 fk:w-78 fk:font-mono fk:text-xs",placeholder:"data.ordersConnection.totalCount",value:i.path,onChange:l=>t({...n,condition:{...i,path:l.target.value}})}),jsxs(a$3,{value:i.op,onValueChange:l=>t({...n,condition:l==="exists"?{op:"exists",path:i.path}:{...i,op:l}}),children:[jsx(d$3,{className:"fk:h-7 fk:w-auto fk:text-xs",children:jsx(c$5,{})}),jsx(e$6,{children:Ms.map(l=>jsx(g$5,{value:l.value,children:l.label},l.value))})]}),i.op==="exists"?null:jsx(Gs,{value:i.value,onChange:l=>t({...n,condition:{...i,value:l}})})]}):null,jsx(e$5,{className:"fk:sr-only",htmlFor:o,children:"Read-only GraphQL query"}),jsx(la$1,{className:"fk:min-h-20 fk:font-mono fk:text-xs",id:o,placeholder:`query {
2
- ordersConnection(where: { status: { eq: "pending" } }) { totalCount }
3
- }`,value:n.query,onChange:l=>t({...n,query:l.target.value})})]})}function Ys({automationId:t,entities:n,errors:o,onChange:i,projectId:l,triggers:k}){let f=k.some(v=>v.type==="webhook");function g(v){i([...k,v]);}function c(v){g({cron:v,key:ft(),timezone:zs(),type:"schedule"});}function p(v){i(k.map(C=>C.key===v.key?v:C));}function d(v){i(k.filter(C=>C.key!==v));}return jsxs("div",{className:"fk:rounded-lg fk:border fk:bg-muted/60 fk:dark:bg-muted/30 fk:corner-squircle",children:[k.map(v$1=>jsxs(Fragment$1,{children:[jsxs("div",{className:"fk:group fk:rounded-md fk:m-1.5 fk:p-1.5 fk:hover:bg-muted fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[v$1.type==="schedule"?jsx(ClockIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}):null,v$1.type==="webhook"?jsx(WebhookIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}):null,v$1.type==="entity"?jsx(DatabaseZapIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}):null,v$1.type==="job"?jsx(CircleCheckBigIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}):null,v$1.type==="poll"?jsx(RefreshCwIcon,{className:"fk:size-4 fk:shrink-0 fk:self-start fk:mt-2.5 fk:text-muted-foreground"}):null,v$1.type==="schedule"?jsx(Js,{trigger:v$1,onChange:p}):null,v$1.type==="webhook"?jsx(Us,{projectId:l,trigger:v$1,onChange:p}):null,v$1.type==="entity"?jsx(Hs,{entities:n,trigger:v$1,onChange:p}):null,v$1.type==="job"?jsx(Xs,{automationId:t,projectId:l,trigger:v$1,onChange:p}):null,v$1.type==="poll"?jsx(Zs,{trigger:v$1,onChange:p}):null,jsx(b$2,{"aria-label":"Remove trigger",className:"fk:opacity-0 fk:group-hover:opacity-100",size:"icon",type:"button",variant:"ghost",onClick:()=>d(v$1.key),children:jsx(Trash2Icon,{className:"fk:size-4 fk:text-muted-foreground"})})]}),o[v$1.key]?jsx("div",{className:"fk:mt-1 fk:pl-7",children:jsx(Xe,{message:o[v$1.key]})}):null]},v$1.key),jsx(v,{className:"fk:h-4"})]},v$1.key)),jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsxs(b$2,{className:`fk:h-auto fk:w-full fk:justify-start fk:gap-3 fk:px-3 fk:py-3 fk:text-muted-foreground hover:fk:bg-muted hover:fk:text-foreground ${k.length===0?"fk:rounded-lg fk:corner-squircle":"fk:rounded-none fk:rounded-b-lg fk:corner-squircle"}`,type:"button",variant:"ghost",children:[jsx(PlusIcon,{className:"fk:size-4"}),"Add Trigger"]})}),jsxs(h,{align:"start",className:"fk:w-56",children:[jsxs(q,{children:[jsxs(r,{children:[jsx(ClockIcon,{className:"fk:mr-2 fk:size-4 fk:text-muted-foreground"}),"Scheduled"]}),jsxs(s$1,{children:[jsx(j,{onClick:()=>c(ka),children:"Hourly"}),jsx(j,{onClick:()=>c(Ss),children:"Daily"}),jsx(j,{onClick:()=>c(ws),children:"Weekly"}),jsx(j,{onClick:()=>c(As),children:"Custom (cron)"})]})]}),jsxs(j,{disabled:f,onClick:()=>g({key:ft(),secret:null,token:crypto.randomUUID(),type:"webhook"}),children:[jsx(WebhookIcon,{className:"fk:mr-2 fk:size-4 fk:text-muted-foreground"}),"Webhook Triggered"]}),jsxs(j,{onClick:()=>g({entities:[],events:["create"],key:ft(),type:"entity"}),children:[jsx(DatabaseZapIcon,{className:"fk:mr-2 fk:size-4 fk:text-muted-foreground"}),"Entity Events"]}),jsxs(j,{onClick:()=>g({automationId:null,job:"schema_deploy",key:ft(),outcome:"succeeded",type:"job"}),children:[jsx(CircleCheckBigIcon,{className:"fk:mr-2 fk:size-4 fk:text-muted-foreground"}),"Job Finished"]}),jsxs(j,{onClick:()=>g({condition:{op:"gte",path:"",value:""},intervalMinutes:Rs,key:ft(),query:"",type:"poll",variables:null}),children:[jsx(RefreshCwIcon,{className:"fk:mr-2 fk:size-4 fk:text-muted-foreground"}),"Poll Condition"]})]})]})]})}function Qs(){return jsxs("svg",{"aria-label":"Slack",className:"fk:mt-1 fk:size-3.5 fk:text-muted-foreground",fill:"currentColor",role:"img",viewBox:"0 0 127 127",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M27.2 80c0 7.3-5.9 13.2-13.2 13.2C6.7 93.2.8 87.3.8 80c0-7.3 5.9-13.2 13.2-13.2h13.2V80zm6.6 0c0-7.3 5.9-13.2 13.2-13.2 7.3 0 13.2 5.9 13.2 13.2v33c0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V80z"}),jsx("path",{d:"M47 27c-7.3 0-13.2-5.9-13.2-13.2C33.8 6.5 39.7.6 47 .6c7.3 0 13.2 5.9 13.2 13.2V27H47zm0 6.7c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H13.9C6.6 60.1.7 54.2.7 46.9c0-7.3 5.9-13.2 13.2-13.2H47z"}),jsx("path",{d:"M99.9 46.9c0-7.3 5.9-13.2 13.2-13.2 7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H99.9V46.9zm-6.6 0c0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V13.8C66.9 6.5 72.8.6 80.1.6c7.3 0 13.2 5.9 13.2 13.2v33.1z"}),jsx("path",{d:"M80.1 99.8c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2-7.3 0-13.2-5.9-13.2-13.2V99.8h13.2zm0-6.6c-7.3 0-13.2-5.9-13.2-13.2 0-7.3 5.9-13.2 13.2-13.2h33.1c7.3 0 13.2 5.9 13.2 13.2 0 7.3-5.9 13.2-13.2 13.2H80.1z"})]})}function ei(){return jsxs("svg",{"aria-label":"Microsoft Teams",className:"fk:mt-1 fk:size-3.5 fk:text-muted-foreground",fill:"currentColor",role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{clipRule:"evenodd",d:"M15.5 5A3 3 0 0 1 14 7.599V7.5a2 2 0 0 0-2-2H9.541A3 3 0 1 1 15.5 5Zm6.25 1a2 2 0 1 1-4 0 2 2 0 0 1 4 0Zm-3.294 11.732A3.25 3.25 0 0 0 23 14.75v-4.361a.889.889 0 0 0-.889-.889h-3.879c.17.294.268.636.268 1V17c0 .248-.015.492-.044.732ZM8.169 19.5A5 5 0 0 0 17.5 17v-6.5a1 1 0 0 0-1-1H14v8a2 2 0 0 1-2 2H8.169Z",fillRule:"evenodd"}),jsx("path",{clipRule:"evenodd",d:"M1 17.5v-10a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1Zm6.75-6.75H9.5v-1.5h-5v1.5h1.75v4.75h1.5v-4.75Z",fillRule:"evenodd"})]})}function Zt(t,n,o){return t.visibility==="space"?n==="space"&&o!==null&&t.spaceId===o:t.visibility==="personal"?n==="personal":true}function ti(t,n,o){return t.visibility==="space"&&!Zt(t,n,o)}function ni(t,n){let o=t.spaceId?n[t.spaceId]:void 0;return o?`Only available on ${o} automations`:"Only available on space automations"}async function oi(t,n){try{return (await f(g(t).skill(n))).skill}catch(o){if(o instanceof e$7&&o.status===404)return null;throw o}}var ha=[{label:"Results that need attention (recommended)",value:"when_flagged"},{label:"Every finished run",value:"always"},{label:"Failures only",value:"failures"},{label:"Never",value:"never"}];function ai(t){return ha.some(n=>n.value===t)}function Fn({api:t,automation:n,mode:o,onSaved:i,projectId:l}){let[k,f$1]=useState((n?.toolConfigs??[]).filter(s=>!["slack","teams"].includes(s.pluginId))),[g$1,c]=useState(n?.name??""),[p,d]=useState(n?.instructions??""),[v$1,C]=useState(n?.enabled??false),[T,j]=useState(null),[A,x]=useState(null),[b$3,P]=useState(n?.mutationPolicy??"require_approval"),[F,S]=useState(n?.toolAllowRules),[_$1,M]=useState(n?.notifyRule??"when_flagged"),[B,U]=useState(n?.notifyCreator??true),[w,H]=useState(n?.subscriberIds??[]),[$,he]=useState(n?.visibility??"project"),[q,be]=useState(n?.spaceId??null),[ye,Be]=useState(n?.skillIds??[]),[me,dt]=useState(n?.customToolNames??[]),[Ce,ze]=useState(()=>Ls(n)),[je,We]=useState(false),[Ge,$e]=useState(""),[R,N]=useState({instructions:false,name:false}),[E,ke]=useState(null),[Pt,mt]=useState(null),{mutate:$n}=useSWRConfig(),[kt,Vn]=useState(()=>({slack:n?.toolConfigs?.find(s=>s.pluginId==="slack")?.connectionId??null,teams:n?.toolConfigs?.find(s=>s.pluginId==="teams")?.connectionId??null})),Mt=useRef({}),On=useRef(null),{data:Ze,error:Ma}=De(`/api/flexkit/${l}/plugins`,f),qn=!!(Ze||Ma),Ra=g(l).tools(n?.id),{data:Ve,error:Ea}=De(Ra,f),{data:La}=De(g(l).entities,f),{data:an}=De(g(l).spaces,f),{data:Rt}=De($==="personal"?null:g(l).members($==="space"?q:null),f),{data:oe}=De(g(l).skills({limit:100}),f),[,Da]=g$3(),ae=b(),za=Da.user?.spaces??[],Jn=(an?.spaces??[]).filter(s=>za.includes(s.code)),Et=Ve?.tools.models,Un=useMemo(()=>{let s=n?.modelId??"";return s?f$3(s,Et??[])??{effort:null,modelKey:s}:null},[n?.modelId,Et]),sn=T??Un?.modelKey??"",pt=useMemo(()=>Bs(Et??[],o,sn),[o,Et,sn]),Lt=sn||(pt[0]?b$6(pt[0]):""),Hn=c$4(pt,Lt),ln=d$2(Hn,A??(T===null?Un?.effort??null:null)),Xn=e$4(Hn),rn=Lt?g$4({effort:ln,modelKey:Lt},pt):"",Kn=useMemo(()=>new Set((oe?.skills??[]).map(s=>s.id)),[oe?.skills]),Ye=useMemo(()=>oe?ye.filter(s=>!Kn.has(s)).sort():[],[Kn,ye,oe]),Fa=Ye.length>0?[l,"attached-skills",...Ye]:null,{data:Dt}=De(Fa,()=>Promise.all(Ye.map(s=>oi(l,s)))),Qe=useMemo(()=>{let s={};for(let h of oe?.skills??[])s[h.id]=h;for(let h of Dt??[])h&&(s[h.id]=h);return s},[Dt,oe?.skills]),cn=useMemo(()=>{let s=(oe?.skills??[]).filter(y=>Zt(y,$,q)),h=new Set(s.map(y=>y.id));return [...ye.map(y=>Qe[y]).filter(y=>!y||h.has(y.id)?false:Zt(y,$,q)),...s]},[ye,Qe,oe?.skills,q,$]),_a=useMemo(()=>{let s={};for(let h of an?.spaces??[])s[h.id]=h.label;return s},[an?.spaces]),fn=useMemo(()=>(oe?.skills??[]).filter(s=>ti(s,$,q)),[oe?.skills,q,$]),Fe=Ve?.tools.customTools,un=useMemo(()=>{let s={};for(let h of Fe?.tools??[])s[h.name]=h;return s},[Fe?.tools]),dn=useMemo(()=>{let s=Fe?.tools??[],h=new Set(s.map(y=>y.name));return [...me.filter(y=>!h.has(y)).map(y=>un[y]??{description:"",name:y}),...s]},[me,un,Fe?.tools]),Wn=Fe?Ds(Fe):"";useEffect(()=>{if(!oe)return;let s=Ye.length>0&&Dt===void 0,h=new Set(s?[]:Ye.filter(m=>!Qe[m]));Be(m=>{let y=m.filter(D=>{if(h.has(D))return false;let Me=Qe[D];return Me?Zt(Me,$,q):true});return y.length===m.length?m:y});},[Dt,Qe,oe,q,Ye,$]);let et=sa(k),le=useMemo(()=>{let s={};for(let m of Ce){if(m.type==="schedule"){let y=va(m.cron,m.timezone);y&&(s[m.key]=y);}m.type==="entity"&&m.events.length===0&&(s[m.key]="Select at least one event (create, update or delete)"),m.type==="job"&&m.job==="automation_run"&&!m.automationId&&(s[m.key]="Choose the automation whose runs start this one"),m.type==="poll"&&(!Number.isInteger(m.intervalMinutes)||m.intervalMinutes<Ln||m.intervalMinutes>Dn?s[m.key]=`Check every ${Ln.toString()} to ${Dn.toString()} minutes`:m.query.trim()?m.condition&&!m.condition.path.trim()&&(s[m.key]="Enter the path of the value to compare, e.g. data.ordersConnection.totalCount"):s[m.key]="Enter the read-only GraphQL query to check");}let h={};for(let m of Kt){let y=E?.[m];y?.enabled&&y.channels.length===0&&(h[m]=`Select at least one ${m==="slack"?"Slack":"Teams"} channel or remove the tool`);}return {instructions:p.trim()?"":"Instructions are required",model:rn?"":"Select a model",name:g$1.trim()?"":"Name is required",plugins:et&&$!=="personal"?"Personal plugin connections can only be used by a personal automation.":"",space:$==="space"&&!q?"Select a space":"",toolErrors:h,triggerErrors:s}},[rn,p,g$1,et,q,E,Ce,$]),mn=Es(le),zt=R.name&&!!le.name,gt=R.instructions&&!!le.instructions;useEffect(()=>{let s=`${n?.id??""}:${o}`;!Ve?.tools||On.current===s||(On.current=s,ke($s(Ve.tools,o)));},[n?.id,o,Ve?.tools]);let Ft=useMemo(()=>({slack:Ze?.plugins.find(s=>s.id==="slack")??null,teams:Ze?.plugins.find(s=>s.id==="teams")??null}),[Ze]),kn=useMemo(()=>{let s=h=>{let m=Ft[h];return m?In(m,{connectionMode:"project",connectionId:kt[h]})?.id??null:null};return {slack:s("slack"),teams:s("teams")}},[kt,Ft]),pn=useCallback(async(s,h)=>{Mt.current[s]=h,ke(m=>m&&{...m,[s]:{...m[s],channelsLoadError:void 0,loadingChannels:true}});try{let m=await t.listChannels(s,h);if(Mt.current[s]!==h)return;let y=m.success?void 0:m.errorMessage??`Failed to load ${s==="slack"?"Slack":"Teams"} channels.`;ke(D=>D&&{...D,[s]:{...D[s],availableChannels:js(D[s].channels,m.channels),channelsLoadError:y,channelsLoaded:!0,loadingChannels:!1}});}catch(m){if(Mt.current[s]!==h)return;let y=m instanceof Error?m.message:"Failed to load integration channels.";ke(D=>D&&{...D,[s]:{...D[s],channelsLoadError:y,channelsLoaded:true,loadingChannels:false}});}},[t]);useEffect(()=>{if(!(!E||!ae||!qn))for(let s of Kt){let h=E[s];h.connected&&!h.channelsLoaded&&!h.loadingChannels&&pn(s,kn[s]);}},[ae,pn,qn,kn,E]);async function Ba(s){let h=Ft[s];if(h){mt(s);try{await b$7(t,h.id,"project");let y=(await $n(`/api/flexkit/${l}/plugins`))?.plugins.find(D=>D.id===h.id)?.connections.find(D=>D.scope==="project"&&D.isPrimary&&D.status==="connected");Vn(D=>({...D,[s]:null})),Gn(s,{connected:!0,enabled:!0,workspaceName:y?.displayName??null});}catch(m){qa.error(m instanceof Error?m.message:`Unable to connect ${h.name}.`);}finally{mt(null);}}}function _t(s,h){ke(m=>m&&{...m,[s]:{...m[s],...h}});}function ja(s,h){kt[s]!==h&&(Vn(m=>({...m,[s]:h})),Gn(s));}function Gn(s,h={}){Mt.current[s]=void 0,_t(s,{...h,availableChannels:[],channels:[],channelsLoaded:false,channelsLoadError:void 0,loadingChannels:false});}function $a(s){_t(s,{channels:[],enabled:false});}function Zn(s,h){Be(m=>h?m.includes(s)?m:[...m,s]:m.filter(y=>y!==s));}function Yn(s,h){dt(m=>h?m.includes(s)?m:[...m,s]:m.filter(y=>y!==s));}async function Va(s){if(s.preventDefault(),!ae)return;if(!mn){N({instructions:true,name:true});return}We(true),$e("");let h=Kt.map(y=>{let D=E?.[y]??Ve?.tools.providers[y];return {channels:D?.channels??[],enabled:D?.enabled??false,pluginId:y,connectionMode:"project",connectionId:kt[y],selectedTools:[],deliveryEnabled:D?.enabled??false}}),m={customToolNames:me,enabled:v$1,instructions:p,modelId:rn,mutationPolicy:b$3,name:g$1,notifyCreator:B,notifyRule:_$1,skillIds:ye,subscriberIds:$==="personal"?[]:w,...F!==void 0?{toolAllowRules:F}:{},spaceId:$==="space"?q:null,toolConfigs:[...h,...k],triggers:Ce.map(({key:y,...D})=>D),visibility:$};try{let y=o==="create"||!n?await t.createAutomation(m):await t.updateAutomation(n.id,m);if(!y.success){$e(Array.isArray(y.errorMessage)?y.errorMessage.join(", "):y.errorMessage);return}qa.success(o==="create"||!n?"Automation created.":"Automation saved."),i(y.automation);}catch(y){$e(y instanceof Error?y.message:"Failed to save automation.");}finally{We(false);}}return jsxs("form",{className:"fk:max-w-4xl fk:space-y-8 fk:px-1 fk:mx-auto",onSubmit:s=>{Va(s);},children:[Ge?jsx("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-3 fk:text-sm fk:text-destructive fk:corner-squircle",children:Ge}):null,jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",children:"Status"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-1",children:"Disabling an automation stops its schedules and ignores webhook calls and entity events"}),jsxs("div",{className:"fk:flex fk:h-10 fk:items-center fk:gap-2",children:[jsx(_,{checked:v$1,id:"automation-enabled",onCheckedChange:C}),jsx(e$5,{className:"fk:font-normal",htmlFor:"automation-enabled",children:v$1?"Active":"Inactive"})]})]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",htmlFor:"automation-name",children:"Name"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-2",children:"Identifying label for this automation"}),jsx(s,{"aria-describedby":zt?"automation-name-error":void 0,"aria-invalid":zt,className:zt?"fk:border-destructive focus-visible:fk:ring-destructive":"",id:"automation-name",value:g$1,onBlur:()=>N(s=>({...s,name:true})),onChange:s=>c(s.target.value)}),zt?jsx(Xe,{id:"automation-name-error",message:le.name}):null]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",htmlFor:"automation-visibility",children:"Visibility"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-2",children:"Who can see and manage this automation. Space automations are only visible to members of the selected space; personal automations are private to you."}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsxs(a$3,{value:$,onValueChange:s=>{et&&s!=="personal"||(he(s==="space"||s==="personal"?s:"project"),s!=="space"&&be(null));},children:[jsx(d$3,{"aria-label":"Visibility",className:"fk:w-fit",id:"automation-visibility",children:jsx(c$5,{})}),jsxs(e$6,{align:"start",children:[jsx(g$5,{disabled:et,value:"project",children:"Project"}),jsx(g$5,{disabled:et||Jn.length===0,value:"space",children:"Space"}),jsx(g$5,{value:"personal",children:"Personal"})]})]}),$==="space"?jsxs(a$3,{value:q??"",onValueChange:s=>{be(s||null);},children:[jsx(d$3,{"aria-label":"Space",className:"fk:w-fit",children:jsx(c$5,{placeholder:"Select a space"})}),jsx(e$6,{align:"start",children:Jn.map(s=>jsx(g$5,{value:s.id,children:s.label},s.id))})]}):null]}),et?jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"This automation uses a personal plugin connection, so project and space visibility are unavailable."}):null,le.plugins?jsx(Xe,{message:le.plugins}):null,$==="space"&&le.space?jsx(Xe,{message:le.space}):null]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",children:"Triggers"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-2",children:"When this automation should run. Schedules run in your timezone; webhooks run when their URL is called."}),jsx(Ys,{automationId:n?.id,entities:La?.entities??[],errors:le.triggerErrors,projectId:l,triggers:Ce,onChange:ze})]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",htmlFor:"automation-instructions",children:"Agent instructions"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-2",children:"Natural-language instructions the agent follows on every run. Be specific about entities, conditions, and the expected outcome."}),jsxs("div",{children:[jsx("div",{className:`fk:rounded-t-md fk:border-x fk:border-t fk:bg-muted/60 fk:ring-offset-background focus-within:fk:ring-2 focus-within:fk:ring-ring focus-within:fk:ring-offset-2 fk:dark:bg-muted/30 ${gt?"fk:border-destructive":"fk:border-input"} fk:corner-squircle`,children:jsx(la$1,{"aria-describedby":gt?"automation-instructions-error":void 0,"aria-invalid":gt,className:"fk:flex fk:min-h-[160px] fk:max-h-[320px] fk:w-full fk:rounded-none fk:border-0 fk:bg-transparent fk:dark:bg-transparent fk:pb-11 fk:shadow-none focus-visible:fk:ring-0 focus-visible:fk:ring-offset-0 fk:mask-[linear-gradient(to_bottom,black_calc(100%-2.75rem),#0009_calc(100%-1.25rem),#0003_calc(100%-0.5rem),transparent)] fk:corner-squircle",id:"automation-instructions",placeholder:"Describe what the agent should do on each run, e.g. 'When a new Review is created, translate the text to English, run a sentiment analysis and store the result in the sentiment attribute...'",rows:8,value:p,onBlur:()=>N(s=>({...s,instructions:true})),onChange:s=>d(s.target.value)})}),jsx("div",{className:`fk:rounded-b-md fk:border-x fk:border-b fk:bg-muted/60 fk:dark:bg-muted/30 fk:px-2 fk:py-2 ${gt?"fk:border-destructive":"fk:border-input"} fk:corner-squircle`,children:jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsxs(a$3,{value:Lt,onValueChange:s=>{j(s),x(null);},children:[jsx(d$3,{"aria-label":"Model",className:"fk:w-fit fk:border-transparent fk:bg-background/90 fk:px-2.5 fk:py-0 fk:text-xs fk:shadow-sm hover:fk:border-border",size:"sm",children:jsx(c$5,{placeholder:"Select a model"})}),jsx(e$6,{align:"start",children:pt.map(s=>jsxs(g$5,{value:b$6(s),children:[s.name,s.deprecated?" (Legacy)":""]},b$6(s)))})]}),Xn.length>1&&ln?jsxs(a$3,{value:ln,onValueChange:x,children:[jsx(d$3,{"aria-label":"Reasoning effort",className:"fk:w-fit fk:border-transparent fk:bg-background/90 fk:px-2.5 fk:py-0 fk:text-xs fk:shadow-sm hover:fk:border-border",size:"sm",children:jsx(c$5,{placeholder:"Effort"})}),jsx(e$6,{align:"start",children:Xn.map(s=>jsx(g$5,{value:s.value,children:s.label},s.value))})]}):null]})})]}),gt?jsx(Xe,{id:"automation-instructions-error",message:le.instructions}):null,Ve&&le.model?jsx(Xe,{message:le.model}):null]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",htmlFor:"automation-mutation-policy",children:"Mutations"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-2",children:"How data changes proposed by the agent are handled. With approval required, runs pause until a project member reviews a before/after preview in the Approvals inbox."}),jsxs(a$3,{value:b$3,onValueChange:s=>{P(s==="auto_approve"?"auto_approve":"require_approval");},children:[jsx(d$3,{"aria-label":"Mutation policy",className:"fk:w-fit",id:"automation-mutation-policy",children:jsx(c$5,{})}),jsxs(e$6,{align:"start",children:[jsx(g$5,{value:"require_approval",children:"Require approval (recommended)"}),jsx(g$5,{value:"auto_approve",children:"Auto-approve"})]})]}),b$3==="auto_approve"&&k.some(s=>s.enabled)?jsxs("p",{className:"fk:flex fk:items-start fk:gap-1 fk:text-xs fk:text-warning",role:"status",children:[jsx(TriangleAlertIcon,{className:"fk:mt-px fk:size-3.5 fk:shrink-0"}),"Plugin tools will run without review. Content the agent reads, such as emails or documents, could lead it to act on your connected accounts."]}):null,b$3==="require_approval"&&F&&F.length>0?jsxs("div",{className:"fk:space-y-2",children:[jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Always allowed plugin tools (approved with \u201Calways allow\u201D from the Approvals inbox):"}),jsx("ul",{className:"fk:space-y-1",children:F.map(s=>jsxs("li",{className:"fk:flex fk:items-center fk:justify-between fk:gap-2 fk:rounded-md fk:border fk:border-border fk:px-2.5 fk:py-1.5 fk:text-xs fk:corner-squircle",children:[jsxs("code",{children:[s.pluginId,": ",s.tool]}),jsx(b$2,{"aria-label":`Remove allow rule for ${s.pluginId} ${s.tool}`,size:"sm",type:"button",variant:"ghost",onClick:()=>S(h=>(h??[]).filter(m=>m!==s)),children:"Remove"})]},`${s.pluginId}/${s.server}/${s.tool}`))})]}):null]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(e$5,{className:"fk:mb-1",htmlFor:"automation-notify-rule",children:"Notifications"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground fk:mb-2",children:"Approval requests and run results appear in Activity in Studio. Failures are always reported unless set to Never."}),jsxs(a$3,{value:_$1,onValueChange:s=>{ai(s)&&M(s);},children:[jsx(d$3,{"aria-label":"Notify about runs",className:"fk:w-fit",id:"automation-notify-rule",children:jsx(c$5,{})}),jsx(e$6,{align:"start",children:ha.map(s=>jsx(g$5,{value:s.value,children:s.label},s.value))})]}),jsxs("div",{className:"fk:flex fk:h-8 fk:items-center fk:gap-2",children:[jsx(_,{checked:B,id:"automation-notify-creator",onCheckedChange:U}),jsx(e$5,{className:"fk:font-normal",htmlFor:"automation-notify-creator",children:"Notify the creator"})]}),$==="personal"?null:jsxs("div",{className:"fk:space-y-2",children:[jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-2",children:[jsxs("div",{children:[jsx("p",{className:"fk:text-sm",children:"Subscribers"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Members who also get its notifications. Only owners and developers receive approval requests."})]}),jsx(Xt,{disabled:!ae||!Rt,emptyText:"No members match.",items:(Rt?.members??[]).map(s=>({attached:w.includes(s.id),id:s.id,label:s.displayName})),searchPlaceholder:"Search members\u2026",triggerLabel:"Add",onToggle:(s,h)=>H(m=>h?[...new Set([...m,s])]:m.filter(y=>y!==s))})]}),w.length>0?jsx("div",{className:"fk:flex fk:flex-wrap fk:gap-1.5",children:w.map(s=>{let m=Rt?.members.find(y=>y.id===s)?.displayName??(Rt?"No longer has access":"Loading\u2026");return jsxs(b$1,{className:"fk:gap-1 fk:pr-1 fk:font-normal",variant:"secondary",children:[m,jsx("button",{"aria-label":`Remove subscriber ${m}`,className:"fk:cursor-pointer fk:rounded-sm fk:text-muted-foreground fk:hover:text-foreground disabled:fk:cursor-not-allowed fk:corner-squircle",disabled:!ae,type:"button",onClick:()=>H(y=>y.filter(D=>D!==s)),children:jsx(XIcon,{className:"fk:size-3"})})]},s)})}):null]})]}),jsxs("div",{className:"fk:space-y-4",children:[jsxs("div",{children:[jsx(e$5,{className:"fk:text-sm fk:font-medium",children:"Tools"}),jsx("p",{className:"fk:mb-3 fk:text-xs fk:text-muted-foreground",children:"Configure additional destinations and built-in capabilities for this automation."})]}),jsxs("div",{className:"fk:rounded-lg fk:border fk:bg-muted/60 fk:dark:bg-muted/30 fk:corner-squircle",children:[jsx("div",{className:"fk:rounded-t-lg fk:corner-squircle",children:jsxs("div",{className:"fk:m-1.5 fk:flex fk:items-start fk:justify-between fk:gap-3 fk:rounded-md fk:p-1.5 fk:hover:bg-muted fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:gap-3 fk:pb-0.5",children:[jsx(BrainIcon,{className:"fk:mt-1 fk:size-3.5 fk:text-muted-foreground"}),jsxs("div",{children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:"Memories"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Builds memory across runs to make automations smarter over time"})]})]}),jsx(b$1,{className:"fk:mt-1.5 fk:py-0 fk:text-[10px] fk:font-light fk:tracking-wide",variant:"secondary",children:"Always on"})]})}),jsx(v,{}),E?Kt.map(s=>{let h=E[s],m=s==="slack"?"Send to Slack":"Send to Microsoft Teams",y=s==="slack"?Qs:ei,D=Ft[s];return jsxs(Fragment$1,{children:[jsxs("div",{className:"fk:m-1.5 fk:space-y-2 fk:rounded-md fk:p-1.5 fk:hover:bg-muted fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:gap-3",children:[jsx(y,{}),jsxs("div",{children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:m}),h.connected&&h.workspaceName?jsxs("p",{className:"fk:text-xs fk:text-muted-foreground",children:["Connected to ",h.workspaceName]}):null,h.connected?null:jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:Ze?.canManage===false?"Not connected. Ask a project owner or developer to connect it.":"Not connected"})]})]}),h.connected?h.enabled?jsx(b$2,{"aria-label":`Remove ${s==="slack"?"Slack":"Microsoft Teams"} from automation`,size:"icon",type:"button",variant:"ghost",onClick:()=>$a(s),children:jsx(Trash2Icon,{className:"fk:size-4 fk:text-muted-foreground"})}):jsx(b$2,{size:"sm",type:"button",variant:"outline",onClick:()=>_t(s,{enabled:true}),children:"Add"}):jsx(b$2,{disabled:!ae||!D?.enabled||!Ze?.canManage||Pt!==null,size:"sm",type:"button",variant:"outline",onClick:()=>{Ba(s);},children:Pt===s?"Connecting\u2026":"Connect"})]}),h.connected&&h.enabled?jsxs("div",{className:"fk:space-y-2 fk:pl-7",children:[D&&D.connections.filter(Me=>Me.scope==="project"&&Me.status==="connected").length>1?jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:[jsx(e$5,{className:"fk:text-xs fk:font-medium",children:"Workspace"}),jsx(Pn,{ariaLabel:`${s==="slack"?"Slack":"Microsoft Teams"} workspace`,disabled:!ae,plugin:D,scopes:["project"],value:{connectionMode:"project",connectionId:kt[s]},onChange:Me=>ja(s,Me.connectionId)})]}):null,jsx(e$5,{className:"fk:mr-3 fk:text-xs fk:font-medium",children:"Channels"}),jsx(Vs,{channels:h.availableChannels,disabled:h.loadingChannels||!ae,loading:h.loadingChannels,provider:s,value:h.channels,onChange:Me=>_t(s,{channels:Me}),onRefresh:()=>{pn(s,kn[s]);}}),h.channelsLoadError?jsxs("p",{className:"fk:flex fk:items-start fk:text-sm fk:text-warning fk:gap-1",children:[jsx(TriangleAlertIcon,{className:"fk:size-4 fk:shrink-0 fk:mt-0.5"}),h.channelsLoadError]}):null,!h.channelsLoadError&&le.toolErrors[s]?jsx(Xe,{message:le.toolErrors[s]}):null]}):null]}),jsx(v,{})]},s)}):Ea?jsx("p",{className:"fk:m-1.5 fk:p-1.5 fk:text-xs fk:text-warning",role:"alert",children:"Unable to load Slack and Microsoft Teams delivery. Reload the page to try again."}):jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:p-4 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircleIcon,{className:"fk:size-4 fk:animate-spin"}),"Loading tools..."]}),jsxs("div",{className:"fk:m-1.5 fk:space-y-2 fk:rounded-md fk:px-1.25 fk:py-1.5 fk:hover:bg-muted fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:gap-2.5",children:[jsx(GraduationCapIcon,{className:"fk:mt-px fk:size-5 fk:text-muted-foreground"}),jsxs("div",{children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:"Skills"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Attached skills are always loaded into the agent context. All other skills you can see stay discoverable by the agent when relevant."})]})]}),jsx(Xt,{disabled:!ae||cn.length===0&&fn.length===0,emptyText:"No skills match.",items:[...cn.map(s=>({id:s.id,label:s.name,attached:ye.includes(s.id),badge:s.source==="code"?"Code":void 0})),...fn.map(s=>({id:s.id,label:s.name,attached:false,badge:s.source==="code"?"Code":void 0,lockedHint:ni(s,_a)}))],searchPlaceholder:"Search skills\u2026",onToggle:Zn})]}),oe&&cn.length===0&&fn.length===0?jsx("p",{className:"fk:pl-7 fk:text-xs fk:text-muted-foreground",children:"No attachable skills yet. Create them on the Skills tab."}):null,oe?.hasMore?jsxs("p",{className:"fk:pl-7 fk:text-xs fk:text-muted-foreground",children:["Showing the ",oe.skills.length," most recently updated skills. Attached skills outside this list are kept when you save."]}):null,ye.length>0?jsx("div",{className:"fk:flex fk:flex-wrap fk:gap-1.5 fk:pl-7",children:ye.map(s=>{let h=Qe[s],m=h?.name??"Loading skill\u2026";return jsxs(b$1,{className:"fk:gap-1 fk:pr-1 fk:font-normal",variant:"secondary",children:[m,h?.source==="code"?jsx("span",{className:"fk:text-[10px] fk:uppercase",children:"Code"}):null,jsx("button",{"aria-label":h?`Detach ${h.name}`:"Detach skill",className:"fk:cursor-pointer fk:rounded-sm fk:text-muted-foreground fk:hover:text-foreground disabled:fk:cursor-not-allowed fk:corner-squircle",disabled:!ae,type:"button",onClick:()=>Zn(s,false),children:jsx(XIcon,{className:"fk:size-3"})})]},s)})}):null]}),jsx(v,{}),jsxs("div",{className:"fk:m-1.5 fk:space-y-2 fk:rounded-md fk:px-1.25 fk:py-1.5 fk:hover:bg-muted fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:gap-2.5",children:[jsx(WrenchIcon,{className:"fk:mt-px fk:size-5 fk:text-muted-foreground"}),jsxs("div",{children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:"Custom tools"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Attached custom tools can be called during a run. Tools you do not attach stay unavailable to this automation."}),Wn?jsx("p",{className:Fe?.connected?"fk:mt-1 fk:text-xs fk:text-warning":"fk:mt-1 fk:text-xs fk:text-muted-foreground",children:Wn}):null]})]}),jsx(Xt,{disabled:!ae||dn.length===0,emptyText:"No custom tools match.",items:dn.map(s=>({id:s.name,label:s.name,attached:me.includes(s.name)})),searchPlaceholder:"Search custom tools\u2026",onToggle:Yn})]}),Fe&&dn.length===0?jsx("p",{className:"fk:pl-7 fk:text-xs fk:text-muted-foreground",children:"No custom tools registered yet. Define them in flexkit.tools.ts, run `flexkit dev` or sync them from the Dashboard, then attach the ones this automation needs."}):null,me.length>0?jsx("div",{className:"fk:flex fk:flex-wrap fk:gap-1.5 fk:pl-7",children:me.map(s=>{let m=un[s]?.name??s;return jsxs(b$1,{className:"fk:gap-1 fk:pr-1 fk:font-normal",variant:"secondary",children:[m,jsx("button",{"aria-label":`Detach ${m}`,className:"fk:cursor-pointer fk:rounded-sm fk:text-muted-foreground fk:hover:text-foreground disabled:fk:cursor-not-allowed fk:corner-squircle",disabled:!ae,type:"button",onClick:()=>Yn(s,false),children:jsx(XIcon,{className:"fk:size-3"})})]},s)})}):null]}),jsx(v,{}),jsx(Go,{projectId:l,value:k,disabled:!ae,onChange:s=>{f$1(s),sa(s)&&(he("personal"),be(null));}})]})]}),jsxs("div",{className:"fk:flex fk:items-center fk:justify-end fk:gap-3",children:[mn?null:jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Complete the required fields to save"}),jsx(na$1,{disabled:!ae,children:jsx(b$2,{disabled:je||!mn||!ae,type:"submit",children:je?"Saving...":o==="create"?"Create automation":"Update automation"})})]})]})}var xa=25;function vi(t){return Math.max(600,t)}function hi(t){return t==="mine"||t==="team"}function Z({children:t}){return jsx("div",{className:"fk:rounded-md fk:border fk:border-dashed fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground fk:corner-squircle",children:t})}function bi(t){return t==="success"?"fk:bg-success/20 fk:text-success":t==="awaiting_approval"?"fk:bg-amber-500/20 fk:text-amber-600":t==="skipped"?"fk:bg-orange-500/20 fk:text-orange-700":"fk:bg-secondary fk:text-secondary-foreground"}function wa({status:t}){return jsx(b$1,{className:`fk:border-none fk:h-4.75 fk:text-[0.6875rem] fk:leading-4.5 fk:tracking-wide ${bi(t)}`,variant:t==="success"?"default":"secondary",children:t==="awaiting_approval"?"awaiting approval":t})}function yi(t){if(t==="0 * * * *")return "Every hour";let n=/^0 (\d{1,2}) \* \* \*$/.exec(t);if(n)return `Every day at ${n[1].padStart(2,"0")}:00`;let o=/^0 (\d{1,2}) \* \* ([0-6])$/.exec(t);return o?`Every ${["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][Number(o[2])]??"week"} at ${o[1].padStart(2,"0")}:00`:t}function xi(t){let n=t.triggers.map(o=>{if(o.type==="schedule")return yi(o.cron);if(o.type==="webhook")return "Webhook";if(o.type==="job")return o.job==="schema_deploy"?"After a deployment":o.job==="automation_run"?"After another automation":"After a bulk action";if(o.type==="poll")return `Poll every ${o.intervalMinutes.toString()} min`;let i=o.entities.length>0?o.entities.join(", "):"all entities";return `On ${o.events.join("/")} of ${i}`});return n.length===0?"Manual only":n.join(" \xB7 ")}function Aa(t){return t?!!(t.name.trim()&&t.instructions.trim()&&t.modelId.trim()):false}function Ni({projectId:t}){let{data:n}=De(g(t).creditBalance,f),o=n?.creditBalance;return o?jsx(b$2,{asChild:true,size:"sm",variant:"secondary",children:jsxs("a",{href:o.billingUrl,rel:"noopener noreferrer",target:"_blank",children:[jsx(CoinsIcon,{className:"fk:mr-2 fk:size-4"}),o.display," Credit"]})}):null}function Ti(t,n){let o=t.visibility??"project";return o==="space"?(t.spaceId?n.get(t.spaceId):void 0)??"Space":o==="personal"?"Personal":"Project"}var Ia="fk:sticky fk:top-0 fk:z-10 fk:[&_th]:sticky fk:[&_th]:top-0 fk:[&_th]:bg-muted";function Ci(){return jsxs($,{children:[jsx(aa$1,{className:Ia,children:jsxs(da,{children:[jsx(ea,{children:"Automation"}),jsx(ea,{children:"Triggers"}),jsx(ea,{children:"Last run"}),jsx(ea,{className:"fk:text-center",children:"Runs"}),jsx(ea,{children:"Visibility"}),jsx(ea,{className:"fk:text-center",children:"Status"}),jsx(ea,{})]})}),jsx(ba,{children:Array.from({length:5},(t$1,n)=>jsxs(da,{children:[jsx(fa,{children:jsx(t,{className:"fk:h-4 fk:w-36"})}),jsx(fa,{children:jsx(t,{className:"fk:h-4 fk:w-48"})}),jsx(fa,{children:jsx(t,{className:"fk:h-4 fk:w-24"})}),jsx(fa,{className:"fk:text-center",children:jsx(t,{className:"fk:mx-auto fk:h-4 fk:w-8"})}),jsx(fa,{children:jsx(t,{className:"fk:h-4.75 fk:w-16"})}),jsx(fa,{className:"fk:text-center",children:jsx(t,{className:"fk:mx-auto fk:h-4.75 fk:w-16"})}),jsx(fa,{className:"fk:text-right",children:jsx(t,{className:"fk:ml-auto fk:size-8"})})]},n))})]})}function Na(t,n){let i=t.find(l=>l.id===n)?.value;return Array.isArray(i)?i.filter(l=>typeof l=="string"):[]}function Si(t){if(t.length===0)return;let n=t.map(o=>o==="enabled"?true:o==="disabled"?false:null).filter(o=>o!==null);if(n.length!==0)return n}function wi(t){if(t.length===0)return;let n=t.filter(o=>o==="project"||o==="space"||o==="personal");if(n.length!==0)return n}function Jl(){let{api:t,projectId:n}=x(),o$1=useNavigate(),[i,l]=useState([]),[k,f$2]=useState(""),[g$2,c$1]=useState(""),p=b(),d=useRef(null),v$1=Na(i,"status"),C=Na(i,"visibility"),T=Si(v$1),j$1=wi(C),A=i.length>0||k.trim().length>0,x$1=JSON.stringify({enabledFilter:T,search:k,visibilityFilter:j$1}),b$4=(N,E)=>!n||E&&E.hasMore===false?null:g(n).automations({enabled:T,limit:xa,offset:N*xa,search:k.trim()||void 0,visibility:j$1}),{data:P,isLoading:F,mutate:S,setSize:_,size:M}=It(b$4,f),{data:B}=De(n?g(n).spaces:null,f),U=useMemo(()=>new Map((B?.spaces??[]).map(N=>[N.id,N.label])),[B?.spaces]),w=P?.flatMap(N=>N.automations)??[],$$1=P?.[P.length-1]?.hasMore??false,he=P!==void 0&&M>P.length,q=P?.[0]?.count,be=F&&w.length===0,ye=useMemo(()=>[{id:"status",accessorKey:"enabled"},{id:"visibility",accessorKey:"visibility"}],[]),Be=useReactTable({columns:ye,data:w,getCoreRowModel:getCoreRowModel(),manualFiltering:true,onColumnFiltersChange:N=>{_(1),l(N);},state:{columnFilters:i}}),me=useRef(()=>{_(N=>N+1);}),dt=useRef($$1),Ce=useRef(he);me.current=()=>{_(N=>N+1);},dt.current=$$1,Ce.current=he;let ze=useCallback(N=>{if(!me.current||!dt.current||Ce.current)return;let E=N??d.current;if(!E)return;let{scrollHeight:ke,scrollTop:Pt,clientHeight:mt}=E;ke-Pt-mt>=vi(mt)||(Ce.current=true,me.current());},[]);useEffect(()=>{ze();},[ze,w.length,$$1,he,x$1]),useEffect(()=>{d.current?.scrollTo({top:0});},[x$1]);let je=useRef(k);je.current=k;let We=useCallback(N=>{N!==je.current&&(_(1),f$2(N));},[_]);if(!n||!t)return jsx(Z,{children:"Select a project to view automations."});async function Ge(N){if(c$1(""),!t)return;let E=await t.deleteAutomation(N.id);if(!E.success){c$1(Array.isArray(E.errorMessage)?E.errorMessage.join(", "):E.errorMessage);return}await S();}function $e(N){ze(N.currentTarget);}let R;return F&&w.length===0?R=jsx(Ci,{}):w.length===0?R=jsx(Z,{children:A?"No results.":"No automations yet."}):R=jsxs($,{children:[jsx(aa$1,{className:Ia,children:jsxs(da,{children:[jsx(ea,{children:"Automation"}),jsx(ea,{children:"Triggers"}),jsx(ea,{children:"Last run"}),jsx(ea,{className:"fk:text-center",children:"Runs"}),jsx(ea,{children:"Visibility"}),jsx(ea,{className:"fk:text-center",children:"Status"}),jsx(ea,{})]})}),jsx(ba,{children:w.map(N=>jsxs(da,{className:"fk:cursor-pointer",onClick:()=>o$1(N.id),children:[jsx(fa,{children:jsx("span",{className:"fk:font-medium",children:N.name})}),jsx(fa,{className:"fk:text-muted-foreground",children:xi(N)}),jsx(fa,{children:N.lastRunAt?formatDistance(new Date(N.lastRunAt),new Date,{addSuffix:true}):"Never"}),jsx(fa,{className:"fk:text-center",children:N.totalRuns}),jsx(fa,{children:jsx(b$1,{className:"fk:h-4.75 fk:text-[0.6875rem] fk:leading-4.5 fk:tracking-wide",variant:N.visibility==="personal"?"secondary":"outline",children:Ti(N,U)})}),jsx(fa,{className:"fk:text-center",children:jsx(b$1,{className:`fk:border-none fk:h-4.75 fk:text-[0.6875rem] fk:leading-4.5 fk:tracking-wide ${N.enabled?"fk:bg-success/20 fk:text-success":"fk:bg-secondary fk:text-secondary-foreground"}`,variant:N.enabled?"default":"secondary",children:N.enabled?"Enabled":"Disabled"})}),jsx(fa,{className:"fk:text-right",children:jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsx(b$2,{"aria-label":`Actions for ${N.name}`,size:"icon",type:"button",variant:"ghost",onClick:E=>{E.stopPropagation();},children:jsx(Ellipsis,{className:"fk:size-4"})})}),jsxs(h,{align:"end",className:"fk:w-40",children:[jsxs(j,{onClick:E=>{E.stopPropagation(),o$1(N.id);},children:[jsx(Pencil,{}),"Edit"]}),jsx(o,{}),jsxs(j,{disabled:!p,variant:"destructive",onClick:E=>{E.stopPropagation(),Ge(N);},children:[jsx(Trash2,{}),"Delete"]})]})]})})]},N.id))})]}),jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:gap-4 fk:pr-4",children:[jsxs("div",{className:"fk:flex fk:shrink-0 fk:items-start fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:mt-1 fk:h-4"}),jsxs("div",{className:"fk:min-w-0 fk:flex-1",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx("h1",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:"Automations"}),!be&&q!==void 0?jsxs("span",{className:"fk:ml-auto fk:text-sm fk:font-normal fk:text-muted-foreground",children:[q.toLocaleString()," ",q===1?"automation":"automations"]}):null]}),jsxs("p",{className:"fk:mt-1 fk:text-sm fk:text-muted-foreground",children:["Agent-powered tasks that run on a schedule or when your data changes.",jsx(f$1,{href:"https://flexkit.io/docs/automations",children:"Learn more"})]})]})]}),g$2?jsx("div",{className:"fk:text-sm fk:text-destructive",children:g$2}):null,jsx(Jo,{actions:jsxs(Fragment,{children:[jsx(Ni,{projectId:n}),p?jsx(b$2,{asChild:true,className:"fk:h-8",size:"sm",children:jsxs(Link,{to:"new",children:[jsx(Plus,{className:"fk:mr-2 fk:size-4"}),"New Automation"]})}):jsx(na$1,{disabled:true,children:jsxs(b$2,{className:"fk:h-8",disabled:true,size:"sm",children:[jsx(Plus,{className:"fk:mr-2 fk:size-4"}),"New Automation"]})})]}),isSearchLoading:F&&k.trim().length>0,search:k,table:Be,onSearchChange:We}),jsxs("div",{className:"fk:relative fk:min-h-0 fk:min-w-0 fk:flex-1",children:[he?jsx("div",{"aria-hidden":true,className:"fk:pointer-events-none fk:absolute fk:top-0 fk:right-px fk:left-px fk:z-20 fk:h-0.5 fk:overflow-hidden fk:opacity-40",children:jsx("div",{className:"fk:animate-progress fk:h-full fk:w-full fk:bg-foreground"})}):null,jsx("div",{className:"fk:h-full fk:overflow-auto",onScroll:$e,ref:d,children:R})]})]})}function Ul(){let{api:t,projectId:n}=x(),o=useNavigate();return !n||!t?jsx(Z,{children:"Select a project to create automations."}):jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:mb-4 fk:flex fk:shrink-0 fk:items-start fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:mt-1 fk:h-4"}),jsx("div",{className:"fk:flex-1",children:jsx("h1",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:"New Automation"})})]}),jsx(b$2,{asChild:true,className:"fk:shrink-0 fk:w-fit",size:"sm",variant:"ghost",children:jsxs(Link,{relative:"path",to:"..",children:[jsx(ArrowLeft,{className:"fk:mr-2 fk:size-4"}),"Automations"]})}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsx("div",{className:"fk:pb-6 fk:pr-4",children:jsx(Fn,{api:t,mode:"create",projectId:n,onSaved:()=>o("..",{relative:"path"})})})})]})}function Hl(){let{api:t,projectId:n}=x(),{automationId:o}=useParams(),i=useNavigate(),[l,k]=useTransition(),f$1=b(),{data:g$1,mutate:c$1}=De(n&&o?g(n).automation(o):null,f);if(!n||!t||!o)return jsx(Z,{children:"Select an automation."});if(!g$1?.automation)return jsx(Z,{children:"Loading automation..."});let p=t,d=Aa(g$1.automation)&&f$1,v$1=o;function C(){d&&k(async()=>{let T=await p.runAutomation(v$1);if(T.success&&T.runId){i(`runs/${T.runId}`);return}await c$1();});}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:mb-4 fk:flex fk:shrink-0 fk:items-start fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:mt-1 fk:h-4"}),jsx("div",{className:"fk:flex-1",children:jsx("h1",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:g$1.automation.name})})]}),jsxs("div",{className:"fk:flex fk:shrink-0 fk:flex-wrap fk:items-center fk:justify-between fk:gap-3 fk:pr-4",children:[jsx(b$2,{asChild:true,size:"sm",variant:"ghost",children:jsxs(Link,{to:"../automations",children:[jsx(ArrowLeft,{className:"fk:mr-2 fk:size-4"}),"Automations"]})}),jsx(ha$1,{value:"settings",children:jsxs(ia$1,{children:[jsx(ja,{className:"text-xs",value:"settings",children:"Settings"}),jsx(ja,{className:"text-xs",value:"runs",children:jsx(Link,{to:"runs",children:"Runs"})})]})}),jsx(na$1,{disabled:!f$1,children:jsxs(b$2,{disabled:l||!d,size:"sm",onClick:C,children:[l?jsx(LoaderCircle,{className:"fk:mr-2 fk:size-4 fk:animate-spin"}):jsx(Play,{className:"fk:mr-2 fk:size-4"}),"Run now"]})})]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsx("div",{className:"fk:pb-6 fk:pr-4",children:jsx(Fn,{api:t,automation:g$1.automation,mode:"edit",projectId:n,onSaved:T=>{T?c$1({automation:T},{revalidate:false}):c$1();}})})})]})}var tn=25;function Xl(){let{api:t,projectId:n}=x(),{automationId:o}=useParams(),i=useNavigate(),[l,k]=useTransition(),{data:f$1}=De(n&&o?g(n).automation(o):null,f),g$1=(B,U)=>!n||!o||U&&U.hasMore===false?null:g(n).automationRuns(o,B*tn,tn),{data:c$1,isLoading:p,mutate:d,setSize:v$1,size:C}=It(g$1,f),T=b();if(!n||!t||!o)return jsx(Z,{children:"Select an automation to view runs."});let j=t,A=Aa(f$1?.automation)&&T,x$1=o;function b$1(){A&&k(async()=>{let B=await j.runAutomation(x$1);if(B.success&&B.runId){i(B.runId);return}await d();});}let P=c$1?.flatMap(B=>B.runs)??[],S=c$1?.[c$1.length-1]?.hasMore??false,_=c$1!==void 0&&C>c$1.length;function M(){v$1(B=>B+1);}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:mb-4 fk:flex fk:shrink-0 fk:items-start fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:mt-1 fk:h-4"}),jsx("div",{className:"fk:flex-1",children:jsx("h1",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:f$1?.automation.name??"Automation"})})]}),jsxs("div",{className:"fk:flex fk:shrink-0 fk:flex-wrap fk:items-center fk:justify-between fk:gap-3 fk:pr-4",children:[jsx(b$2,{asChild:true,size:"sm",variant:"ghost",children:jsxs(Link,{to:"../automations",children:[jsx(ArrowLeft,{className:"fk:mr-2 fk:size-4"}),"Automations"]})}),jsx(ha$1,{value:"runs",children:jsxs(ia$1,{children:[jsx(ja,{className:"text-xs",value:"settings",children:jsx(Link,{relative:"path",to:"..",children:"Settings"})}),jsx(ja,{className:"text-xs",value:"runs",children:"Runs"})]})}),jsx(na$1,{disabled:!T,children:jsxs(b$2,{disabled:l||!A,size:"sm",onClick:b$1,children:[l?jsx(LoaderCircle,{className:"fk:mr-2 fk:size-4 fk:animate-spin"}):jsx(Play,{className:"fk:mr-2 fk:size-4"}),"Run now"]})})]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:pb-6 fk:pr-4",children:[jsx(Pa,{basePath:".",isLoading:p,runs:P}),S&&!_?jsx(on,{onVisible:M}):null,_?jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:py-4 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),jsx("span",{children:"Loading more runs..."})]}):null]})})]})}function on({onVisible:t}){let n=useRef(null),o=useRef(t);return o.current=t,useEffect(()=>{let i=n.current;if(!i)return;let l=new IntersectionObserver(k=>{k.some(f=>f.isIntersecting)&&o.current();});return l.observe(i),()=>{l.disconnect();}},[]),jsx("div",{className:"fk:h-px",ref:n})}function jn(){return jsx($,{children:jsx(ba,{children:Array.from({length:5},(t$1,n)=>jsxs(da,{children:[jsx(fa,{className:"fk:py-2",children:jsx(t,{className:"fk:h-4 fk:w-28"})}),jsx(fa,{children:jsx(t,{className:"fk:h-4 fk:w-20"})}),jsx(fa,{children:jsx(t,{className:"fk:h-4.75 fk:w-16"})}),jsx(fa,{children:jsx(t,{className:"fk:h-4 fk:w-full fk:max-w-md"})})]},n))})})}function Pa({basePath:t,isLoading:n=false,runs:o}){return n?jsx(jn,{}):o.length===0?jsx(Z,{children:"No runs found."}):jsx($,{children:jsx(ba,{children:o.map(i=>jsxs(da,{children:[jsx(fa,{className:"fk:py-2",children:jsx(Link,{className:"fk:font-medium hover:fk:underline",to:`${t}/${i.id}`,children:formatDistance(new Date(i.startedAt),new Date,{addSuffix:true})})}),jsx(fa,{className:"fk:text-muted-foreground",children:i.triggerType}),jsx(fa,{children:jsx(wa,{status:i.status})}),jsx(fa,{className:"fk:max-w-md fk:truncate fk:text-muted-foreground",children:i.summary??""})]},i.id))})})}function Kl(){let{projectId:t$1}=x(),[n,o]=useState("team"),i=(x,b)=>!t$1||b&&!b.history.hasMore?null:g(t$1).runHistory(n,x*tn,tn),{data:l,isLoading:k,setSize:f$1,size:g$1}=It(i,f),c$1=l?.[0]?.history.metrics,p=l?.flatMap(x=>x.history.runs)??[],v=l?.[l.length-1]?.history.hasMore??false,C=l!==void 0&&g$1>l.length;if(!t$1)return jsx(Z,{children:"Select a project to view run history."});function T(){f$1(x=>x+1);}function j(x){!hi(x)||x===n||o(x);}let A=null;return k?A=jsx("div",{className:"fk:mb-6 fk:grid fk:shrink-0 fk:gap-3 fk:grid-cols-4 fk:pr-4",children:Array.from({length:4},(x,b)=>jsxs("div",{className:"fk:rounded-md fk:bg-muted/60 fk:p-4 fk:corner-squircle",children:[jsx(t,{className:"fk:h-4 fk:w-24"}),jsx(t,{className:"fk:mt-2 fk:h-8 fk:w-12"})]},b))}):c$1&&(A=jsxs("div",{className:"fk:mb-6 fk:grid fk:shrink-0 fk:gap-3 fk:grid-cols-4 fk:pr-4",children:[jsx(en,{title:"Successful 24h",value:c$1.successful24h}),jsx(en,{title:"Failed 24h",value:c$1.failed24h}),jsx(en,{title:"Successful 7d",value:c$1.successful7d}),jsx(en,{title:"Failed 7d",value:c$1.failed7d})]})),jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(ha$1,{value:n,onValueChange:j,children:jsxs(ia$1,{children:[jsx(ja,{value:"team",children:"Team"}),jsx(ja,{value:"mine",children:"Mine"})]})})]}),A,jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:pb-6 fk:pr-4",children:[jsx(Pa,{basePath:"../automations",isLoading:k,runs:p.map(x=>({...x,id:`${x.automationId}/runs/${x.id}`}))}),v&&!C?jsx(on,{onVisible:T}):null,C?jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:py-4 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),jsx("span",{children:"Loading more runs..."})]}):null]})})]})}var Ta=25;function Ai(t){return t==="pending"||t==="all"}function Wl(){let{api:t,projectId:n}=x(),[o,i]=useState("pending"),[l,k]=useState(null),f$1=(M,B)=>!n||B&&!B.hasMore?null:g(n).approvals({limit:Ta,offset:M*Ta,status:o==="pending"?"pending":void 0}),{data:g$1,isLoading:c$1,mutate:p,setSize:d$1,size:v}=It(f$1,f,{refreshInterval:3e4}),C=g$1?.flatMap(M=>M.approvals)??[],T=g$1?.[0]?.pendingCount??0,j=g$1?.[0],A=a();useEffect(()=>{j&&A(j);},[j,A]);let b=g$1?.[g$1.length-1]?.hasMore??false,P=g$1!==void 0&&v>g$1.length,F=C.find(M=>M.id===l)??null;if(useEffect(()=>{l===null||F!==null||c$1||g$1===void 0||k(null);},[g$1,c$1,F,l]),!n||!t)return jsx(Z,{children:"Select a project to view approvals."});function S(){d$1(M=>M+1);}function _(M){!Ai(M)||M===o||(d$1(1),i(M));}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(ha$1,{value:o,onValueChange:_,children:jsxs(ia$1,{children:[jsxs(ja,{value:"pending",children:["Pending",T>0?` (${T.toString()})`:""]}),jsx(ja,{value:"all",children:"All"})]})})]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:pb-6 fk:pr-4",children:[c$1?jsx(jn,{}):C.length===0?jsx(Z,{children:o==="pending"?"No proposals are waiting for approval.":"No approvals found."}):jsx($,{children:jsx(ba,{children:C.map(M=>jsxs(da,{className:"fk:cursor-pointer",onClick:()=>k(M.id),children:[jsx(fa,{children:jsx(b$4,{status:M.status})}),jsx(fa,{className:"fk:font-medium",children:M.operationsSummary}),jsx(fa,{className:"fk:text-muted-foreground",children:M.automationName}),jsx(fa,{className:"fk:text-muted-foreground",children:formatDistance(new Date(M.requestedAt),new Date,{addSuffix:true})}),jsx(fa,{onClick:B=>B.stopPropagation(),children:M.chatId?jsx(Link,{className:"fk:text-xs fk:text-muted-foreground hover:fk:underline",to:`../agent/chats/${M.chatId}`,children:"View chat"}):M.automationId&&M.runId?jsx(Link,{className:"fk:text-xs fk:text-muted-foreground hover:fk:underline",to:`../automations/${M.automationId}/runs/${M.runId}`,children:"View run"}):null})]},M.id))})}),b&&!P?jsx(on,{onVisible:S}):null,P?jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:py-4 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),jsx("span",{children:"Loading more approvals..."})]}):null]})}),F?jsx(d,{api:t,approval:F,onClose:()=>k(null),onDecided:()=>{p();}},`${F.id}-${F.status}`):null]})}var Ca=25,Ii={attention:"fk:border-none fk:bg-amber-500/20 fk:text-amber-600 fk:corner-squircle",failure:"fk:border-none fk:bg-destructive/15 fk:text-destructive fk:corner-squircle",neutral:"fk:corner-squircle"};function Pi(t){return t==="needs_action"||t==="all"}function Mi(){let{mode:t}=f$4(),[n,o]=useState(()=>typeof Notification>"u"?"unsupported":Notification.permission);return n!=="default"?null:jsxs("div",{className:"fk:mb-3 fk:flex fk:items-center fk:gap-3 fk:rounded-md fk:border fk:p-3 fk:text-sm fk:corner-squircle",children:[jsx(BellIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}),jsx("span",{className:"fk:flex-1",children:"Get a desktop notification when something needs you while Studio is in the background."}),jsx(b$2,{size:"sm",variant:"outline",onClick:()=>{Notification.requestPermission().then(i=>{o(i),i==="granted"&&t==="hosted"&&i$1().catch(()=>{});});},children:"Turn on"})]})}function Gl(){let{api:t,projectId:n}=x(),o=useNavigate(),i=c$1(),[l,k]=useState("needs_action"),[f$1,g$1]=useState(()=>new Set),c$3=a(),p=(S,_)=>!n||_&&!_.hasMore?null:g(n).activity({filter:l,limit:Ca,offset:S*Ca}),{data:d,isLoading:v,mutate:C,setSize:T,size:j}=It(p,f,{refreshInterval:3e4}),A=useMemo(()=>d?.flatMap(S=>S.items)??[],[d]),x$1=d?.[d.length-1]?.hasMore??false,b=d!==void 0&&j>d.length;if(useEffect(()=>{let S=A.filter(_=>_.state==="unread").map(_=>_.id);!t||!i||S.length===0||(g$1(_=>new Set([..._,...S])),t.markActivityRead(S).then(()=>c$3()));},[t,i,A,c$3]),!n||!t)return jsx(Z,{children:"Select a project to view activity."});function P(S){!Pi(S)||S===l||(T(1),k(S));}function F(S){t&&t.setActivityItemState(S.id,"dismissed").catch(_=>{qa.error(_ instanceof Error?_.message:"Unable to dismiss this item.");}).finally(()=>{C();});}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(ha$1,{value:l,onValueChange:P,children:jsxs(ia$1,{children:[jsx(ja,{value:"needs_action",children:"Needs attention"}),jsx(ja,{value:"all",children:"All"})]})}),jsx(Vo,{})]}),jsx(Mi,{}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:pb-6 fk:pr-4",children:[v?jsx(jn,{}):A.length===0?jsx(Z,{children:l==="needs_action"?"Nothing needs your attention.":"No activity yet."}):jsx($,{children:jsx(ba,{children:A.map(S=>{let _=c$2(S),M=a$1(S),B=b$5(S),U=e$2(S),w=d$1(S);return jsxs(da,{className:"fk:cursor-pointer",onClick:()=>o(S.id),children:[jsx(fa,{className:"fk:w-4 fk:pr-0",children:f$1.has(S.id)||S.state==="unread"?jsx("span",{"aria-label":"Unread",className:"fk:block fk:size-2 fk:rounded-full fk:bg-primary"}):null}),jsxs(fa,{children:[jsx("div",{className:"fk:font-medium",children:S.title}),S.body?jsx("div",{className:"fk:text-xs fk:text-muted-foreground",children:S.body}):null]}),jsx(fa,{children:_?jsx(b$1,{className:Ii[w],variant:w==="neutral"?"outline":"default",children:_}):null}),jsx(fa,{className:"fk:whitespace-nowrap fk:text-muted-foreground",children:formatDistance(new Date(S.createdAt),new Date,{addSuffix:true})}),jsx(fa,{className:"fk:whitespace-nowrap",onClick:H=>H.stopPropagation(),children:M&&B?jsx(Link,{className:"fk:text-xs fk:text-muted-foreground hover:fk:underline",to:`../${M}`,children:B}):null}),jsx(fa,{className:"fk:w-8",onClick:H=>H.stopPropagation(),children:U?null:jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(b$2,{"aria-label":"Dismiss",size:"icon",variant:"ghost",onClick:()=>F(S),children:jsx(XIcon,{className:"fk:size-4"})})}),jsx(e$1,{children:"Dismiss"})]})})]},S.id)})})}),x$1&&!b?jsx(on,{onVisible:()=>{T(S=>S+1);}}):null,b?jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:py-4 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),jsx("span",{children:"Loading more activity..."})]}):null]})})]})}function Zl(){let{api:t$1,projectId:n}=x(),{itemId:o=""}=useParams(),i=a(),{data:l,error:k,isLoading:f$1,mutate:g$1}=De(n&&o?g(n).activityItem(o):null,f),c$2=l?.item,p=c$2?.approvalId??null,{data:d,mutate:v$1}=De(n&&p?g(n).approval(p):null,f),C=c$2?.state==="unread",T=c$1();if(useEffect(()=>{!t$1||!C||!T||t$1.markActivityRead([o]).then(()=>{g$1(),i();});},[t$1,C,T,o,g$1,i]),!n||!t$1)return jsx(Z,{children:"Select a project to view activity."});let j=c$2?a$1(c$2):null,A=c$2?b$5(c$2):null,x$1;return k?x$1=jsx(Z,{children:"This activity item no longer exists."}):f$1||!c$2?x$1=jsxs("div",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsx(t,{className:"fk:h-4 fk:w-64"}),jsx(t,{className:"fk:h-32 fk:w-full"})]}):x$1=jsxs("div",{className:"fk:flex fk:flex-col fk:gap-6",children:[jsxs("div",{className:"fk:text-sm fk:text-muted-foreground",children:[c$2.body?`${c$2.body} \xB7 `:"",formatDistance(new Date(c$2.createdAt),new Date,{addSuffix:true})]}),d?jsx(c$3,{api:t$1,approval:d.approval,chat:d.approval.chatId!==null,onDecided:()=>{g$1(),v$1(),i();}},`${d.approval.id}-${d.approval.status}`):p?jsx(t,{className:"fk:h-32 fk:w-full"}):null]}),jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:mb-4 fk:flex fk:shrink-0 fk:items-start fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:mt-1 fk:h-4"}),jsx("div",{className:"fk:flex-1",children:jsx("h1",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:c$2?.title??"Activity"})})]}),jsxs("div",{className:"fk:flex fk:shrink-0 fk:items-center fk:justify-between fk:gap-3 fk:pr-4",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(b$2,{asChild:true,"aria-label":"Back to Activity",size:"icon",variant:"ghost",children:jsx(Link,{relative:"path",to:"..",children:jsx(ArrowLeft,{className:"fk:size-4"})})})}),jsx(e$1,{children:"Back to Activity"})]}),j&&A?jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsx(Link,{to:`../${j}`,children:A})}):null]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsx("div",{className:"fk:pb-6 fk:pr-4",children:x$1})})]})}function en({title:t,value:n}){return jsxs("div",{className:"fk:rounded-md fk:bg-muted/60 fk:p-4 fk:corner-squircle",children:[jsx("div",{className:"fk:text-sm fk:text-muted-foreground",children:t}),jsx("div",{className:"fk:mt-1 fk:text-2xl fk:font-medium",children:n.toLocaleString()})]})}function Yl(){let{api:t,projectId:n}=x(),{automationId:o,runId:i}=useParams(),{data:l,mutate:k}=De(n&&i?g(n).run(i):null,f,{refreshInterval:P=>!P?.run||C(P.run.status)?0:y}),{data:f$1}=De(n&&o?g(n).automation(o):null,f),[g$1,c$1]=useTransition(),[p,d]=useState(false);if(useEffect(()=>{d(false);},[i]),!n||!t||!o||!i)return jsx(Z,{children:"Select a run."});let v$1=t,C$1=i,T=l?.run,j=T?.status==="running"&&!p;function A(){c$1(async()=>{await v$1.cancelRun(C$1),await k();});}function x$1(){d(true),k();}function b(){k();}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:mb-4 fk:flex fk:shrink-0 fk:items-start fk:gap-2",children:[jsxs(b$3,{children:[jsx(c,{asChild:true,children:jsx(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(v,{orientation:"vertical",className:"fk:mt-1 fk:h-4"}),jsx("div",{className:"fk:flex-1",children:jsx("h1",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:f$1?.automation.name??"Automation"})})]}),jsxs("div",{className:"fk:flex fk:shrink-0 fk:flex-wrap fk:items-start fk:justify-between fk:gap-3 fk:pr-4",children:[jsxs("div",{children:[jsx(b$2,{asChild:true,size:"sm",variant:"ghost",children:jsxs(Link,{relative:"path",to:"..",children:[jsx(ArrowLeft,{className:"fk:mr-2 fk:size-4"}),"Runs"]})}),jsxs("div",{className:"fk:mt-4 fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsx("h2",{className:"fk:text-sm fk:font-medium",children:T?`Run from ${format(new Date(T.startedAt),"PPpp")}`:"Loading run..."}),T?jsx(wa,{status:T.status}):null]})]}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[T&&C(T.status)?jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsx("a",{href:v$1.getTranscriptUrl(C$1),rel:"noreferrer",target:"_blank",children:"Transcript"})}):null,j?jsx(b$2,{disabled:g$1,size:"sm",variant:"destructive",onClick:A,children:g$1?"Cancelling...":"Cancel run"}):null]})]}),jsxs(ab,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:[jsx(bb,{className:"fk:gap-0 fk:p-0",children:jsx("div",{className:"fk:mx-auto fk:w-full fk:max-w-5xl fk:pb-6 fk:pr-4",children:T?jsx(Ei,{api:t,run:T,onRunUpdated:b,onStreamFinished:x$1}):jsx(Z,{children:"Loading run..."})})}),jsx(db,{})]})]})}function Ri(t){return t==="unavailable"?"No replay events were recorded.":t==="error"?"Unable to load run replay.":"Loading run replay..."}function Ei({api:t,onRunUpdated:n,onStreamFinished:o,run:i$1}){let{projectId:l}=x(),{workflowRunId:k}=i$1,f$1=k?t.getStreamUrl(k):"",[g$1,c]=useState(0),[p,d]=useState(false),[v,C$1]=useState([]),[T,j]=useState({}),A=useRef(null),{message:x$1,status:b}=D(f$1,{decidedApprovals:T,recordStatus:i$1.status,resumeToken:g$1,suppressApprovalPause:p}),P=useMemo(()=>x$1?[x$1]:[],[x$1]),F=B(P),S=useRef(n);S.current=n;let _=useRef(o);_.current=o;let M=useMemo(()=>({onApprovalDecided:(R,N)=>{R&&N&&N!=="pending"&&j(E=>({...E,[R]:N})),!(R&&A.current===R)&&(R&&(A.current=R),d(true),c(E=>E+1),S.current?.());}}),[]),B$1=!p&&i$1.status!=="running"&&!C(i$1.status)&&(b==="paused"||i$1.status==="awaiting_approval"||g$2(x$1)),U=a(),w=C(i$1.status);useEffect(()=>{(B$1||w)&&U();},[B$1,U,w]);let H$1=g$2(x$1),$=B$1&&!H$1&&l!=null,{data:he}=De($&&l?g(l).approvals({limit:25,offset:0,runId:i$1.id,status:"pending"}):null,f,{refreshInterval:y}),q=useMemo(()=>new Set(h$1(x$1)),[x$1]),be=v.filter(R=>!q.has(R.id)),Be=!C(i$1.status)&&(b==="streaming"||b==="paused"),me=F.length>0||be.length>0||Be;if(useEffect(()=>{c(0),d(false),A.current=null,C$1([]),j({});},[i$1.id]),useEffect(()=>{let R=he?.approvals;R?.length&&C$1(N=>{let E=new Map(N.map(ke=>[ke.id,ke]));for(let ke of R)E.set(ke.id,ke);return [...E.values()]});},[he]),useEffect(()=>{C$1(R=>{if(R.length===0)return R;let N=R.filter(E=>!q.has(E.id));return N.length===R.length?R:N});},[q]),useEffect(()=>{if(!p)return;if(i$1.status==="running"){d(false);return}if(i$1.status!=="awaiting_approval")return;let R=i(x$1),N=A.current;R.length===0||N===null||R.every(E=>E!==N)&&d(false);},[x$1,i$1.status,p]),useEffect(()=>{b==="finished"&&_.current?.();},[b]),useEffect(()=>{b==="paused"&&S.current?.();},[b]),useEffect(()=>{if(i$1.status!=="awaiting_approval")return;let R=window.setInterval(()=>{S.current?.();},y);return ()=>{window.clearInterval(R);}},[i$1.status]),!k)return jsx(Z,{children:"The run has not started streaming yet."});let Ce=Be||B$1&&b!=="finished"&&b!=="error",ze=x$1?.parts[x$1.parts.length-1],je=ze?.type==="text"&&ze.state==="streaming",We=B$1?"Awaiting approval":f$2(x$1)??"Thinking",Ge=B$1||!je,$e=Ri(b);return jsx(z.Provider,{value:M,children:jsxs("div",{className:"fk:space-y-4",children:[i$1.status==="failed"&&i$1.error?jsx("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-4 fk:text-sm fk:corner-squircle",children:i$1.summary??i$1.error}):null,b==="unavailable"?jsx("div",{className:"fk:rounded-md fk:border fk:border-amber-500/30 fk:bg-amber-500/5 fk:p-4 fk:text-sm fk:corner-squircle",children:"The workflow replay is no longer available. Generated artifacts may still be available below."}):null,b==="error"&&!me?jsx("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-4 fk:text-sm fk:corner-squircle",children:"Failed to load the run stream. Try reloading the page."}):null,me?jsxs("div",{className:"fk:space-y-5 fk:rounded-md fk:bg-background fk:corner-squircle",children:[F.map(R=>jsx(Li,{api:t,message:R},R.id)),be.map(R=>jsx(I,{api:t,message:E(R)},R.id)),Ce?jsx(H,{label:We,visible:Ge}):null]}):jsxs("div",{className:"fk:flex fk:items-center fk:justify-center fk:gap-2 fk:rounded-md fk:border fk:border-dashed fk:p-8 fk:font-mono fk:text-sm fk:text-muted-foreground fk:corner-squircle",children:[b==="unavailable"||b==="error"?jsx(TriangleAlertIcon,{className:"fk:size-4"}):jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),jsx("span",{children:$e})]})]})})}function Li({api:t,message:n}){let o=n.role==="user",i=n.parts.filter(l=>!e$3(l));return i.length===0?null:jsxs("div",{className:o?"fk:ml-auto fk:w-full fk:max-w-[70%]":"fk:w-full fk:min-w-0",children:[jsx("div",{className:"fk:mb-2 fk:flex fk:items-center fk:gap-2 fk:font-mono fk:text-sm fk:font-medium fk:text-primary",children:o?jsxs(Fragment,{children:[jsx(ZapIcon,{className:"fk:ml-auto fk:size-4"}),jsx("span",{children:"Trigger"})]}):jsxs(Fragment,{children:[jsx(BotIcon,{className:"fk:size-4"}),jsxs("span",{children:["Agent",n.metadata?.model?` (${n.metadata.model})`:""]})]})}),jsx("div",{className:"fk:space-y-8 fk:min-w-0",children:i.map((l,k)=>jsx(F,{api:t,part:l,partIndex:k,parts:i},k))})]})}
4
- export{Zl as ActivityItemPage,Gl as ActivityPage,Wl as ApprovalsPage,Hl as AutomationDetailPage,Jl as AutomationsPage,Ul as CreateAutomationPage,Yl as RunDetailPage,Kl as RunHistoryPage,Xl as RunsPage};//# sourceMappingURL=pages-UKJWXOMO.js.map
5
- //# sourceMappingURL=pages-UKJWXOMO.js.map