@flexkit/studio 0.2.33 → 0.2.34
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.
- package/dist/chat-page-7XT4K75G.js +4 -0
- package/dist/chat-page-7XT4K75G.js.map +1 -0
- package/dist/{chunk-2MVQXXY7.js → chunk-2FCVATRT.js} +3 -3
- package/dist/{chunk-2MVQXXY7.js.map → chunk-2FCVATRT.js.map} +1 -1
- package/dist/{chunk-S7VNSSIK.js → chunk-3OBELKJU.js} +2 -2
- package/dist/{chunk-S7VNSSIK.js.map → chunk-3OBELKJU.js.map} +1 -1
- package/dist/{chunk-YKM3FUGK.js → chunk-6AJRQSFO.js} +3 -3
- package/dist/{chunk-YKM3FUGK.js.map → chunk-6AJRQSFO.js.map} +1 -1
- package/dist/{chunk-DHE6PO3V.js → chunk-7JA6SI5H.js} +2 -2
- package/dist/{chunk-DHE6PO3V.js.map → chunk-7JA6SI5H.js.map} +1 -1
- package/dist/{chunk-RLVHUIFC.js → chunk-CHNQZU2P.js} +2 -2
- package/dist/{chunk-RLVHUIFC.js.map → chunk-CHNQZU2P.js.map} +1 -1
- package/dist/{chunk-HSGUVQXU.js → chunk-DFBG7PUJ.js} +8 -8
- package/dist/{chunk-HSGUVQXU.js.map → chunk-DFBG7PUJ.js.map} +1 -1
- package/dist/{chunk-K3HW6YWS.js → chunk-EUWIIL3X.js} +2 -2
- package/dist/{chunk-K3HW6YWS.js.map → chunk-EUWIIL3X.js.map} +1 -1
- package/dist/chunk-G5N6HEPW.js +2 -0
- package/dist/chunk-G5N6HEPW.js.map +1 -0
- package/dist/chunk-HR4QZ5TD.js +3 -0
- package/dist/chunk-HR4QZ5TD.js.map +1 -0
- package/dist/chunk-KO2JLLUJ.js +2 -0
- package/dist/chunk-KO2JLLUJ.js.map +1 -0
- package/dist/{chunk-CFYO546Y.js → chunk-PC5Z37LT.js} +3 -3
- package/dist/{chunk-CFYO546Y.js.map → chunk-PC5Z37LT.js.map} +1 -1
- package/dist/{chunk-U5XZWEPO.js → chunk-PSECMZJC.js} +3 -3
- package/dist/{chunk-U5XZWEPO.js.map → chunk-PSECMZJC.js.map} +1 -1
- package/dist/chunk-RBGXXVF4.js +7 -0
- package/dist/{chunk-VUZ7GHSO.js.map → chunk-RBGXXVF4.js.map} +1 -1
- package/dist/chunk-RULCANNM.js +7 -0
- package/dist/chunk-RULCANNM.js.map +1 -0
- package/dist/{chunk-NFEQBTIW.js → chunk-U6NFYYTF.js} +2 -2
- package/dist/{chunk-NFEQBTIW.js.map → chunk-U6NFYYTF.js.map} +1 -1
- package/dist/{chunk-S26WK6RF.js → chunk-VFV44YZB.js} +2 -2
- package/dist/{chunk-S26WK6RF.js.map → chunk-VFV44YZB.js.map} +1 -1
- package/dist/{chunk-6I7D2JBA.js → chunk-VRDTHLA3.js} +3 -3
- package/dist/{chunk-6I7D2JBA.js.map → chunk-VRDTHLA3.js.map} +1 -1
- package/dist/{chunk-7ODGH7G2.js → chunk-WU2KCXBC.js} +2 -2
- package/dist/{chunk-7ODGH7G2.js.map → chunk-WU2KCXBC.js.map} +1 -1
- package/dist/{chunk-RFUMT6ZR.js → chunk-XYFS6X74.js} +2 -2
- package/dist/{chunk-RFUMT6ZR.js.map → chunk-XYFS6X74.js.map} +1 -1
- package/dist/{chunk-UB22GYFK.js → chunk-YC7PBLTK.js} +2 -2
- package/dist/{chunk-UB22GYFK.js.map → chunk-YC7PBLTK.js.map} +1 -1
- package/dist/{entry-ROTT3ZDN.js → entry-APJ4V7PW.js} +2 -2
- package/dist/{entry-ROTT3ZDN.js.map → entry-APJ4V7PW.js.map} +1 -1
- package/dist/index.css +43 -0
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/list-7IHDJM54.js +3 -0
- package/dist/{list-N4E3VXM5.js.map → list-7IHDJM54.js.map} +1 -1
- package/dist/{list-RCTHBJOK.js → list-7WFALOUT.js} +2 -2
- package/dist/{list-RCTHBJOK.js.map → list-7WFALOUT.js.map} +1 -1
- package/dist/pages-BV3ABSFQ.js +5 -0
- package/dist/{pages-XUJGIHQI.js.map → pages-BV3ABSFQ.js.map} +1 -1
- package/dist/plugin-pages-OWGJPPWV.js +2 -0
- package/dist/{plugin-pages-FEQILAQR.js.map → plugin-pages-OWGJPPWV.js.map} +1 -1
- package/dist/project-selector-V5N2724B.js +2 -0
- package/dist/project-selector-V5N2724B.js.map +1 -0
- package/dist/record-links-3P3XSW66.js +2 -0
- package/dist/{record-links-HO4SEHOA.js.map → record-links-3P3XSW66.js.map} +1 -1
- package/dist/{root-CCUROZVR.js → root-F2GTYDJM.js} +2 -2
- package/dist/{root-CCUROZVR.js.map → root-F2GTYDJM.js.map} +1 -1
- package/dist/{root-GQL3P63Z.js → root-GBBZ3DX5.js} +3 -3
- package/dist/{root-GQL3P63Z.js.map → root-GBBZ3DX5.js.map} +1 -1
- package/dist/{root-KXY4A6DW.js → root-J62PBDZ2.js} +2 -2
- package/dist/{root-KXY4A6DW.js.map → root-J62PBDZ2.js.map} +1 -1
- package/dist/{root-BUXIQKA5.js → root-LYRL7VPN.js} +3 -3
- package/dist/{root-BUXIQKA5.js.map → root-LYRL7VPN.js.map} +1 -1
- package/dist/{root-VA3E6HEY.js → root-NIL2UHKS.js} +2 -2
- package/dist/{root-VA3E6HEY.js.map → root-NIL2UHKS.js.map} +1 -1
- package/dist/{root-MLEJUEMJ.js → root-RGZZYETM.js} +4 -4
- package/dist/{root-MLEJUEMJ.js.map → root-RGZZYETM.js.map} +1 -1
- package/dist/{search-YY4GQQRM.js → search-IIGNCQEZ.js} +2 -2
- package/dist/{search-YY4GQQRM.js.map → search-IIGNCQEZ.js.map} +1 -1
- package/dist/skills-pages-T52MF4DO.js +2 -0
- package/dist/{skills-pages-SAOZTUOH.js.map → skills-pages-T52MF4DO.js.map} +1 -1
- package/dist/source-IJAAJDGW.js +2 -0
- package/dist/{source-2S24MZ5D.js.map → source-IJAAJDGW.js.map} +1 -1
- package/dist/{spec-renderer-ZSIVMKVE.js → spec-renderer-Z6GVHLFU.js} +2 -2
- package/dist/{spec-renderer-ZSIVMKVE.js.map → spec-renderer-Z6GVHLFU.js.map} +1 -1
- package/dist/ui.js +1 -1
- package/package.json +4 -4
- package/dist/chat-page-LR7XC2US.js +0 -4
- package/dist/chat-page-LR7XC2US.js.map +0 -1
- package/dist/chunk-3SY46ERM.js +0 -2
- package/dist/chunk-3SY46ERM.js.map +0 -1
- package/dist/chunk-C3OHXPJV.js +0 -2
- package/dist/chunk-C3OHXPJV.js.map +0 -1
- package/dist/chunk-L5T56MRH.js +0 -7
- package/dist/chunk-L5T56MRH.js.map +0 -1
- package/dist/chunk-VUZ7GHSO.js +0 -7
- package/dist/list-N4E3VXM5.js +0 -3
- package/dist/pages-XUJGIHQI.js +0 -5
- package/dist/plugin-pages-FEQILAQR.js +0 -2
- package/dist/project-selector-U64ROZ5D.js +0 -2
- package/dist/project-selector-U64ROZ5D.js.map +0 -1
- package/dist/record-links-HO4SEHOA.js +0 -2
- package/dist/skills-pages-SAOZTUOH.js +0 -2
- package/dist/source-2S24MZ5D.js +0 -2
package/dist/chunk-VUZ7GHSO.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import'./index.css';import {b}from'./chunk-CAZ6EUR2.js';import {b as b$2}from'./chunk-2DXR5NJV.js';import {e as e$1,a as a$2,b as b$1}from'./chunk-YKM3FUGK.js';import {g as g$1,b as b$5}from'./chunk-MBBE4RND.js';import {Z,_,ba,ca,$,da,n}from'./chunk-L5T56MRH.js';import {e as e$2,g,h,j}from'./chunk-A4DPLZZF.js';import {c,d,e}from'./chunk-3SY46ERM.js';import {b as b$4}from'./chunk-5JUG4BEF.js';import {k,p,q,s,t}from'./chunk-S7Z6KKIN.js';import {a,b as b$3,c as c$2,d as d$1,e as e$3}from'./chunk-N33S7BSG.js';import {a as a$1,c as c$1}from'./chunk-X3SHNHHM.js';import {AlertCircle,X,ChevronDown,ArrowUp,ArrowDown,Star,CircleCheck,CircleX,Check,Copy}from'lucide-react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {useRef,useState,useEffect,useCallback,useMemo}from'react';import {useReactTable,getSortedRowModel,getPaginationRowModel,getFilteredRowModel,getCoreRowModel,flexRender}from'@tanstack/react-table';import {useVirtualizer}from'@tanstack/react-virtual';import {gql}from'@apollo/client';import {useMutation}from'@apollo/client/react';import {getText,getSchema,getTextSerializersFromSchema}from'@tiptap/core';import {Node}from'@tiptap/pm/model';import {TiptapLink,TiptapImage,UploadImagesPlugin,TaskList,TaskItem,HorizontalRule,StarterKit,CodeBlockLowlight,Youtube,Twitter,Mathematics,CharacterCount,Placeholder,AIHighlight,TiptapUnderline,HighlightExtension,TextStyle,Color,CustomKeymap,GlobalDragHandle}from'novel';import {Markdown}from'tiptap-markdown';import {cx}from'class-variance-authority';import {createLowlight,common}from'lowlight';import {defaultStyles,FileIcon}from'react-file-icon';import {isValid,format}from'date-fns';function Xr(){return jsxs(c,{variant:"destructive",children:[jsx(AlertCircle,{className:"fk:h-4 fk:w-4"}),jsx(d,{children:"Project Paused"}),jsxs(e,{children:["This project has been paused. To troubleshoot this error, please"," ",jsx("a",{className:"fk:text-blue-500 fk:underline",href:"https://flexkit.io/docs/errors/project-paused",target:"_blank",rel:"noopener noreferrer",children:"follow these steps"}),"."]})]})}function Kr(){let{schemaErrorMessage:e$2}=e$1();if(!e$2)return jsx(Fragment,{});let[t,n,...r]=e$2.split(`
|
|
2
|
-
`);return jsxs(c,{className:"fk:mb-4",variant:"destructive",children:[jsx(AlertCircle,{className:"fk:h-4 fk:w-4"}),jsx(d,{children:"Schema mismatch"}),jsxs(e,{children:[jsx("p",{children:t}),n?jsx("p",{className:"fk:mt-1",children:n}):null,r.length>0?jsx("ul",{className:"fk:mt-2 fk:list-disc fk:pl-4",children:r.map(o=>jsx("li",{children:o.replace(/^- /,"")},o))}):null]})]})}function lt({scrollHeight:e,scrollTop:t,clientHeight:n}){if(n<=0)return false;let r=t>0?Math.max(600,n):1;return e-t-n<r}var ln=36,cn=15,fn=2,ut=40;function pt(e){if(!e)return;let t=e.split(/\s+/);if(t.includes("fk:h-20"))return 80;if(t.includes("fk:h-10"))return 40;if(t.includes("fk:h-9"))return 36}function un(e,t){return e??pt(t)??ln}function lo({classNames:e,columns:t,data:n,entityName:r,hasMore:o=false,initialSelectionState:l,isLoadingMore:s=false,onEntitySelectionChange:b$1,onLoadMore:u,onScroll:k,onSortingChange:S,pageSize:M,rowHeightEstimate:g,rowAdditionState:i,rowDeletionState:T,scrollToTopKey:X,sorting:de,toolbarComponent:j}){let y=useRef(null),{schemaErrorMessage:N}=e$1(),[C,me]=useState(l??{}),[Ot,Ut]=useState({}),[zt,Bt]=useState([]),[Xt,jt]=useState([]),$t=de??Xt;useEffect(()=>{y.current?.scrollTo({top:0,left:0});},[r,X]),useEffect(()=>{if(!l)return;let a=Object.keys(C).sort().join(","),c=Object.keys(l).sort().join(",");a!==c&&me(l);},[l,C]);function Jt(a){if(S){S(a);return}jt(a);}let V=useReactTable({data:n,columns:t,state:{sorting:$t,columnVisibility:Ot,rowSelection:C,columnFilters:zt},initialState:{pagination:{pageSize:M??50}},enableRowSelection:true,onRowSelectionChange:Kt,onSortingChange:Jt,onColumnFiltersChange:Bt,onColumnVisibilityChange:Ut,getCoreRowModel:getCoreRowModel(),getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),getSortedRowModel:getSortedRowModel(),getRowId:a=>a._id,manualFiltering:true,manualPagination:true,manualSorting:true,meta:{getRowBackground:a=>mn(a,T,i)}}),{rows:$$1}=V.getRowModel(),Pe=un(g,e?.row),qt=pt(e?.row)!=null,Le=useVirtualizer({count:$$1.length,estimateSize:()=>Pe,getItemKey:a=>$$1[a]?.id??a,getScrollElement:()=>y.current,overscan:cn,scrollMargin:ut}),F=V.getVisibleLeafColumns(),Ie=V.getHeaderGroups(),R=Ie.length===1,K=useVirtualizer({horizontal:true,count:F.length,estimateSize:a=>F[a].getSize(),getItemKey:a=>F[a].id,getScrollElement:()=>y.current,overscan:fn,enabled:R}),Gt=JSON.stringify(F.map(a=>[a.id,a.getSize()]));useEffect(()=>{K.measure();},[Gt,K]);let H=K.getVirtualItems(),W=R?H[0]?.index??0:0,_e=R?(H[H.length-1]?.index??-1)+1:F.length,Y=R?H[0]?.start??0:0,Q=R?Math.max(0,K.getTotalSize()-(H[H.length-1]?.end??0)):0,Ve=Le.getVirtualItems(),{paddingTop:Fe,paddingBottom:He}=dn(Ve,Le.getTotalSize(),ut),pe=useRef(u),Oe=useRef(o),ge=useRef(s);pe.current=u,Oe.current=o,ge.current=s;let ke=useCallback(a=>{if(!pe.current||!Oe.current||ge.current)return;let c=a??y.current;c&<(c)&&(ge.current=true,pe.current());},[]),Ue=b();useEffect(()=>{Ue&&ke();},[ke,$$1.length,o,s,Ue]);function Kt(a){let c=Object.keys(typeof a=="function"?a(C):a);me(a),b$1?.(c);}function Wt(a){k?.(a),ke(a.currentTarget);}return N?jsx(Fragment,{}):jsxs("div",{className:a$1("fk:flex fk:h-full fk:min-h-0 fk:w-full fk:min-w-0 fk:flex-col fk:gap-4",e?.wrapper),children:[j&&j(V),jsx("div",{className:"fk:relative fk:min-h-0 fk:min-w-0 fk:flex-1 fk:-mb-px",children:jsx(a,{delayDuration:400,children:jsxs(Z,{className:a$1("fk:grid fk:pb-20",e?.table),"aria-colcount":F.length,style:{minWidth:V.getTotalSize()},containerClassName:e?.tableContainer,onScroll:Wt,ref:y,children:[jsx(_,{className:"fk:sticky fk:top-0 fk:z-20 fk:grid",children:Ie.map(a=>jsxs(ba,{className:"fk:flex fk:w-full",children:[Y>0?jsx(le,{width:Y,header:true}):null,(R?a.headers.slice(W,_e):a.headers).map((c,P)=>jsxs(ca,{"aria-colindex":R?W+P+1:void 0,className:a$1("fk:flex fk:shrink-0 fk:items-center",c.column.id==="actions"&&"fk:pl-0"),colSpan:c.colSpan,style:c.getSize()?{width:`${c.getSize().toString()}px`}:{},children:[c.isPlaceholder?null:flexRender(c.column.columnDef.header,c.getContext()),s?jsx("div",{"aria-hidden":true,className:"fk:pointer-events-none fk:absolute fk:top-10.25 fk:right-px fk:left-px fk:z-20 fk:h-0.5 fk:overflow-hidden fk:opacity-4",children:jsx("div",{className:"fk:animate-progress fk:h-full fk:w-full fk:bg-foreground"})}):null]},c.id)),Q>0?jsx(le,{width:Q,header:true}):null]},a.id))}),jsx($,{className:"fk:grid fk:relative",children:$$1.length===0?jsx(ba,{children:jsx(da,{className:"fk:h-24 fk:text-center",colSpan:t.length,children:"No results."})}):jsxs(Fragment,{children:[Fe>0?jsx(dt,{height:Fe}):null,Ve.map(a=>{let c=$$1[a.index];return jsxs(ba,{className:a$1(V.options.meta.getRowBackground(c),"fk:flex fk:w-full fk:overflow-hidden fk:transition-none",!qt&&g==null&&"fk:h-9",e?.row),"data-index":a.index,"data-state":c.getIsSelected()&&"selected",style:{height:`${Pe.toString()}px`},children:[Y>0?jsx(le,{width:Y}):null,c.getVisibleCells().slice(W,_e).map((P,Yt)=>jsx(da,{className:a$1("fk:flex fk:shrink-0 fk:items-center fk:truncate",P.column.id==="actions"&&"fk:pl-1!"),"aria-colindex":W+Yt+1,style:{width:P.column.getSize()},children:flexRender(P.column.columnDef.cell,P.getContext())},P.id)),Q>0?jsx(le,{width:Q}):null]},a.key)}),He>0?jsx(dt,{height:He}):null]})})]})})})]})}function dn(e,t,n){if(e.length===0)return {paddingTop:0,paddingBottom:0};let r=e[0]?.start??0,o=e[e.length-1]?.end??0;return {paddingTop:Math.max(0,r-n),paddingBottom:Math.max(0,t-(o-n))}}function le({width:e,header:t=false}){return jsx(t?"th":"td",{"aria-hidden":true,style:{width:e,flexShrink:0,padding:0,border:0}})}function dt({height:e}){return jsx("tr",{"aria-hidden":true,className:"fk:pointer-events-none fk:border-0",style:{display:"block",height:`${e.toString()}px`},children:jsx("td",{className:"fk:p-0 fk:border-0"})})}function mn(e,t,n){return t?.includes(e.original._id)?"fk:bg-row-removed fk:hover:bg-row-removed-hover":n?.some(r=>r._id===e.original._id)?"fk:bg-row-added fk:hover:bg-row-added-hover":""}function po({table:e}){let[t]=e.getState().sorting;if(!t)return null;let r=e.getColumn(t.id)?.columnDef.meta?.label??t.id,o=t.desc?"desc":"asc";return jsxs(c$1,{"aria-label":`Clear sorting by ${r}`,className:"fk:h-8 fk:px-2 fk:lg:px-3 fk:text-success fk:border-none",onClick:()=>{e.resetSorting();},size:"sm",variant:"outline",children:["Sorted by ",r," ",o,jsx(X,{className:"fk:ml-1 fk:h-4 fk:w-4"})]})}function So(){let[e,t]=useState(false),[n,r]=useState(gql`
|
|
3
|
-
mutation updateEntity($any: Any) {
|
|
4
|
-
any
|
|
5
|
-
}
|
|
6
|
-
`),[o,l]=useState({}),[s,{data:b,loading:u,error:k}]=useMutation(n,o),S=a$2(k),{isProjectDisabled:M,isProjectReadOnly:g}=(()=>{if(S?.statusCode===403){let i=b$1(S.bodyText);if(i&&typeof i.code=="string"){if(i.code==="PROJECT_PAUSED")return {isProjectDisabled:true,isProjectReadOnly:false};if(i.code==="READ_ONLY_MODE")return {isProjectDisabled:false,isProjectReadOnly:true}}return {isProjectDisabled:true,isProjectReadOnly:false}}return {isProjectDisabled:false,isProjectReadOnly:false}})();return useEffect(()=>{e&&(s(),t(false));},[e,s]),[t,r,l,{data:b,loading:u,error:k,isProjectDisabled:M,isProjectReadOnly:g}]}function Se({column:e,title:t,className:n}){if(!e.getCanSort())return jsx("div",{className:a$1("fk:flex fk:items-center",n),children:t});let r=e.getIsSorted()==="asc",o=e.getIsSorted()==="desc";return jsxs("div",{className:a$1("fk:flex fk:w-full fk:items-center fk:justify-between fk:gap-1",n),children:[jsx("span",{className:"fk:truncate",children:t}),jsxs(e$2,{children:[jsx(g,{asChild:true,children:jsx("button",{"aria-label":`Sort ${t}`,className:"fk:inline-flex fk:shrink-0 fk:items-center fk:justify-center fk:rounded-sm fk:p-0.5 fk:text-muted-foreground fk:outline-hidden fk:hover:bg-accent fk:hover:text-accent-foreground fk:focus-visible:ring-1 fk:focus-visible:ring-ring fk:corner-squircle",type:"button",children:jsx(ChevronDown,{className:"fk:h-3.5 fk:w-3.5"})})}),jsxs(h,{align:"end",className:"fk:w-44",children:[jsxs(j,{"aria-checked":r,className:a$1(r&&"fk:bg-accent fk:text-accent-foreground"),onSelect:()=>{if(r){e.clearSorting();return}e.toggleSorting(false);},role:"menuitemcheckbox",children:[jsx(ArrowUp,{className:a$1("fk:h-4 fk:w-4",r&&"fk:text-white")}),"Sort Ascending"]}),jsxs(j,{"aria-checked":o,className:a$1(o&&"fk:bg-accent fk:text-accent-foreground"),onSelect:()=>{if(o){e.clearSorting();return}e.toggleSorting(true);},role:"menuitemcheckbox",children:[jsx(ArrowDown,{className:a$1("fk:h-4 fk:w-4",o&&"fk:text-white")}),"Sort Descending"]})]})]})]})}function xe({value:e}){return jsx("div",{className:"fk:flex fk:w-full fk:justify-center",children:e?jsx(CircleCheck,{className:"fk:w-4 fk:h-4 fk:text-emerald-500"}):jsx(CircleX,{className:"fk:w-4 fk:h-4 fk:text-muted-foreground"})})}var ht=500,En=3e3;function w({value:e}){let t=useRef(null),n=useRef(null),[r,o]=useState(false),[l,s]=useState(false);useEffect(()=>()=>{n.current&&clearTimeout(n.current);},[]);function b(){let g=t.current;return g?g.scrollWidth>g.clientWidth:false}async function u(g){if(g.preventDefault(),g.stopPropagation(),!!e){try{await navigator.clipboard.writeText(e);}catch{return}o(true),s(true),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{o(false),s(false);},En);}}function k(){b();}function S(g){if(!r){if(g){s(b());return}s(false);}}if(!e)return jsx("div",{className:"fk:truncate"});let M=e.length>ht?`${e.slice(0,ht)}\u2026`:e;return jsxs(b$3,{open:l,onOpenChange:S,children:[jsx(c$2,{asChild:true,children:jsxs("button",{"aria-label":"Copy value",className:a$1("fk:group/copyable fk:relative fk:flex fk:w-full fk:min-w-0 fk:items-center fk:rounded-sm fk:border-0 fk:bg-transparent fk:px-0.5 fk:-mx-0.5 fk:py-0.5 fk:text-left fk:text-inherit fk:font-inherit fk:corner-squircle","fk:cursor-pointer fk:transition-[transform,background-color] fk:duration-75 fk:ease-out","fk:hover:bg-muted/50 fk:active:translate-y-px fk:active:scale-[0.98] fk:active:bg-muted/70","fk:focus-visible:outline-hidden fk:focus-visible:ring-1 fk:focus-visible:ring-ring"),onClick:u,onPointerEnter:k,type:"button",children:[jsx("span",{className:"fk:min-w-0 fk:flex-1 fk:truncate fk:pr-4",ref:t,children:e}),jsx("span",{"aria-hidden":true,className:a$1("fk:pointer-events-none fk:absolute fk:right-0.5 fk:top-1/2 fk:flex fk:-translate-y-1/2 fk:items-center fk:justify-center","fk:rounded-sm fk:bg-muted/80 fk:p-0.5 fk:text-muted-foreground fk:shadow-sm fk:ring-1 fk:ring-border/60 fk:corner-squircle","fk:transition-opacity fk:duration-100",r?"fk:opacity-100 fk:text-foreground":"fk:opacity-0 fk:group-hover/copyable:opacity-100 fk:group-focus-visible/copyable:opacity-100"),children:r?jsx(Check,{className:"fk:size-3"}):jsx(Copy,{className:"fk:size-3"})})]})}),jsx(e$3,{className:"fk:max-w-xs fk:wrap-break-word",children:r?"Copied to clipboard":M})]})}function B({value:e}){let t=typeof e=="object"||Array.isArray(e)?JSON.stringify(e):e;return t=t==="null"||t==null?"":String(t),jsx(w,{value:t})}var Zn=AIHighlight,er=Placeholder,tr=TiptapLink.configure({HTMLAttributes:{class:cx("fk:text-muted-foreground fk:underline fk:underline-offset-[3px] fk:hover:text-primary fk:transition-colors fk:cursor-pointer")}}),nr=Markdown.configure({html:true,tightLists:true,tightListClass:"tight",bulletListMarker:"-",linkify:false,breaks:false,transformPastedText:false,transformCopiedText:false}),rr=TiptapImage.extend({addProseMirrorPlugins(){return [UploadImagesPlugin({imageClass:cx("fk:opacity-40 fk:rounded-lg fk:border fk:border-stone-200 fk:corner-squircle")})]}}).configure({allowBase64:true,HTMLAttributes:{class:cx("fk:rounded-lg fk:border fk:border-muted fk:corner-squircle")}}),or=TaskList.configure({HTMLAttributes:{class:cx("fk:not-prose fk:pl-2 ")}}),ir=TaskItem.configure({HTMLAttributes:{class:cx("fk:flex gap-2 fk:items-start fk:my-2")},nested:true}),ar=HorizontalRule.configure({HTMLAttributes:{class:cx("mt-4 mb-6 border-t border-muted-foreground")}}),sr=StarterKit.configure({bulletList:{HTMLAttributes:{class:cx("fk:list-disc fk:list-outside fk:leading-3 fk:-mt-2")}},orderedList:{HTMLAttributes:{class:cx("fk:list-decimal fk:list-outside fk:leading-3 fk:-mt-2")}},listItem:{HTMLAttributes:{class:cx("fk:leading-normal fk:-mb-2")}},blockquote:{HTMLAttributes:{class:cx("fk:border-l-4 fk:border-primary")}},codeBlock:false,code:{HTMLAttributes:{class:cx("fk:rounded-md fk:bg-muted fk:px-1.5 fk:py-1 fk:font-mono fk:font-medium fk:corner-squircle"),spellcheck:"false"}},horizontalRule:false,dropcursor:{color:"#DBEAFE",width:4},gapcursor:false}),lr=CodeBlockLowlight.configure({lowlight:createLowlight(common)}),cr=Youtube.configure({HTMLAttributes:{class:cx("fk:rounded-lg fk:border fk:border-muted fk:corner-squircle")},inline:false}),fr=Twitter.configure({HTMLAttributes:{class:cx("fk:not-prose")},inline:false}),ur=Mathematics.configure({HTMLAttributes:{class:cx("fk:text-foreground fk:rounded-sm fk:p-1 fk:hover:bg-muted fk:cursor-pointer fk:corner-squircle")},katexOptions:{throwOnError:false}}),dr=CharacterCount.configure(),Tt=[sr,er,tr,rr,or,ir,ar,Zn,lr,cr,fr,ur,dr,TiptapUnderline,nr,HighlightExtension,TextStyle,Color,CustomKeymap,GlobalDragHandle];var ve;function hr(){let e=getSchema(Tt);return {schema:e,textSerializers:getTextSerializersFromSchema(e)}}function yt(e,t=100){if(!e)return "";try{let n=JSON.parse(e);return ve??=hr(),getText(Node.fromJSON(ve.schema,n),{textSerializers:ve.textSerializers}).substring(0,t)}catch{return e.substring(0,t)}}function St({value:e}){let t=useMemo(()=>yt(e),[e]);return jsx(w,{value:t})}var wt=250,xr=25e5,v=new Map,Ce=new Map,Ae=new Set,xt=new Map;function ce(e){if(xt.has(e))return;let t=new Image;t.decoding="async",t.src=e,xt.set(e,t);}function fe(e){let t=v.get(e);t&&v.set(e,{...t,lastUsedAt:Date.now()});}function vr(){if(v.size<=wt)return;let e=Array.from(v.entries()).sort((n,r)=>n[1].lastUsedAt-r[1].lastUsedAt),t=Math.max(1,Math.ceil(wt*.1));for(let n=0;n<t&&n<e.length;n+=1){let[r,o]=e[n];v.delete(r),URL.revokeObjectURL(o.objectUrl);}}async function Cr(e){if(Ae.has(e)){ce(e);return}if(v.has(e)){fe(e);return}let t=Ce.get(e);if(t){await t;return}let n=(async()=>{try{let r=await fetch(e,{mode:"cors",cache:"force-cache"});if(!r.ok){ce(e);return}let o=await r.blob();if(o.size>xr)return;let l=URL.createObjectURL(o);v.set(e,{objectUrl:l,byteSize:o.size,lastUsedAt:Date.now()}),vr();}catch(r){r instanceof TypeError&&Ae.add(e),ce(e);}})();Ce.set(e,n),await n,Ce.delete(e);}function vt(e){let t=useMemo(()=>{if(!e)return null;let o=v.get(e);return o?(fe(e),o.objectUrl):null},[e]),[n,r]=useState(t);return useEffect(()=>{if(!e){r(null);return}if(Ae.has(e)){ce(e),r(null);return}let o=v.get(e);if(o){fe(e),r(o.objectUrl);return}r(null);let l=false;return Cr(e).then(()=>{let s=v.get(e);s&&(l||(fe(e),r(s.objectUrl)));}),()=>{l=true;}},[e]),n}var De="fk:bg-[#fafafa] [--asset-checker:#f0f0f0] [background-image:linear-gradient(45deg,var(--asset-checker)_25%,transparent_25%),linear-gradient(-45deg,var(--asset-checker)_25%,transparent_25%),linear-gradient(45deg,transparent_75%,var(--asset-checker)_75%),linear-gradient(-45deg,transparent_75%,var(--asset-checker)_75%)] [background-position:0_0,0_4px,4px_-4px,-4px_0px] [background-size:8px_8px] fk:dark:bg-[#222] dark:[--asset-checker:#2a2a2a]";function Ct({value:e}){return Array.isArray(e)?jsx(Mr,{value:e}):jsx(Er,{value:e})}function Er({value:e}){let t=e?.path??"",n=!!t,r=n&&/\.(png|jpe?g|gif|webp|avif|svg)$/i.test(t),o=u=>{let[k]=u.split("?"),S=k.split(".");return S.length>1?S.pop().toLowerCase():"file"},l=n?t.endsWith(".svg")?`${b$5}${t}`:`${b$5}${t}?w=84&h=84&f=webp`:null,s=n?t.endsWith(".svg")?`${b$5}${t}`:`${b$5}${t}?w=624&h=624&f=webp`:"",b=vt(l);return n?jsx("div",{className:"fk:z-10",children:r?jsxs(b$3,{children:[jsx(c$2,{asChild:true,children:jsx("img",{alt:"asset",className:`fk:w-7 fk:h-7 fk:cursor-zoom-in fk:overflow-hidden fk:rounded-md fk:object-contain ${De} fk:corner-squircle`,decoding:"async",src:b??void 0})}),jsx(d$1,{children:jsx(e$3,{children:jsx("img",{alt:"asset",className:`fk:w-52 fk:h-52 fk:overflow-hidden fk:rounded-md fk:object-contain ${De} fk:corner-squircle`,decoding:"async",src:s})})})]}):jsxs(b$3,{children:[jsx(c$2,{asChild:true,children:jsx("div",{className:"fk:w-7 fk:h-7 fk:rounded-sm fk:bg-transparent fk:flex fk:items-center fk:justify-center fk:[&>svg]:h-full fk:[&>svg]:w-auto fk:corner-squircle",children:(()=>{let u=o(t),k=defaultStyles[u];return jsx(FileIcon,{extension:u,...k||{}})})()})}),jsx(d$1,{children:jsx(e$3,{children:jsx("div",{className:"fk:text-sm fk:text-muted-foreground",children:"Preview not available"})})})]})}):null}function Mr({value:e}){let t=e.filter(o=>!!o.path).slice(0,3),n=Math.max(e[0]?.totalCount??0,e.length);if(t.length===0)return n>0?jsx("div",{className:"fk:flex fk:items-center",children:jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:n===1?"1 asset":`${n} assets`})}):null;let r=n-t.length;return jsxs("div",{className:"fk:flex fk:items-center",children:[jsx("div",{className:"fk:flex fk:-space-x-2",children:t.map(o=>jsx("img",{alt:"asset",className:`fk:h-7 fk:w-7 fk:overflow-hidden fk:rounded-md fk:object-contain ${De} fk:corner-squircle`,decoding:"async",src:`${b$5}${o.path}?w=84&h=84&f=webp`},o._id))}),r>0?jsxs("span",{className:"fk:ml-2 fk:text-xs fk:text-muted-foreground",children:["+",r]}):null]})}function Me({value:e}){if(e==null||e===""||typeof e!="string")return jsx(w,{value:""});let t=new Date(e);if(!isValid(t))return jsx(w,{value:""});let n=format(t,"MMM d, yyyy")+" at "+format(t,"HH:mm");return jsx(w,{value:n})}function Rr(e){return "groupLabel"in e}function Pr(e){return e.flatMap(t=>Rr(t)?t.items:[t])}function Lr(e,t){if(!t)return e;let n=Pr(t).find(r=>String(r.value)===e);return n?n.label:e}function Et({value:e,options:t}){if(e==null)return jsx(w,{value:""});let n=String(e),r=Lr(n,t?.list);return jsx(w,{value:r})}function Nt({value:e}){return !e||!e.split(",").length?null:jsx("div",{className:"fk:flex fk:flex-wrap fk:gap-1 fk:max-w-full truncate",children:e.split(",").map(t=>jsx(b$4,{className:"fk:px-2.5 fk:py-0 fk:font-normal fk:text-[0.6875rem] fk:leading-4",variant:"secondary",children:t},t))})}function Rt(e,t=5){let n=Number.isFinite(t)&&t>=1?Math.floor(t):5,r=typeof e=="string"&&e.trim()!==""?Number(e):e;if(typeof r!="number"||!Number.isFinite(r))return null;let o=Math.min(n,Math.max(0,Math.round(r)));return {filled:o,max:n,label:`${String(o)} out of ${String(n)} stars`}}function Pt({value:e,options:t}){let n=Rt(e,t?.max);return n?jsx("span",{"aria-label":n.label,className:"fk:inline-flex fk:items-center fk:gap-0.5",role:"img",title:n.label,children:Array.from({length:n.max},(r,o)=>jsx(Star,{"aria-hidden":true,className:o<n.filled?"fk:h-3.5 fk:w-3.5 fk:fill-amber-400 fk:text-amber-400":"fk:h-3.5 fk:w-3.5 fk:fill-transparent fk:text-muted-foreground/40",strokeWidth:1.5},o))}):jsx("span",{})}var _r=/\.(png|jpe?g|gif|webp|avif|svg)$/i;function Lt(e){try{let{pathname:t}=new URL(e);return t.split("/").pop()||t}catch{let[t]=e.split("?");return t}}function It(e){return e.originalFilename?e.originalFilename:e.path?e.path:e.url?Lt(e.url):""}function _t(e){let t=It(e),[n]=t.split("?"),r=n.split(".");return r.length>1?r.pop().toLowerCase():"file"}function Vt(e){return e.mimeType?e.mimeType.startsWith("image/"):_r.test(It(e))}function Re(e,t){if(!e||!t||Lt(e).toLowerCase().endsWith(".svg"))return e;let n=new URLSearchParams({f:"webp",h:String(t.height),w:String(t.width)}),r=e.includes("?")?"&":"?";return `${e}${r}${n.toString()}`}var Or=FileIcon,Ft="fk:bg-[#fafafa] [--asset-checker:#f0f0f0] [background-image:linear-gradient(45deg,var(--asset-checker)_25%,transparent_25%),linear-gradient(-45deg,var(--asset-checker)_25%,transparent_25%),linear-gradient(45deg,transparent_75%,var(--asset-checker)_75%),linear-gradient(-45deg,transparent_75%,var(--asset-checker)_75%)] [background-position:0_0,0_4px,4px_-4px,-4px_0px] [background-size:8px_8px] fk:dark:bg-[#222] dark:[--asset-checker:#2a2a2a]";function Ht({value:e}){let[t$1,n]=useState(false),r=e?.url??"";if(!e||!r&&!e.path&&!e.originalFilename)return null;if(!(Vt(e)&&!!r)){let u=_t(e),k=defaultStyles[u];return jsx("div",{className:"fk:z-10",children:jsx(a,{children:jsxs(b$3,{children:[jsx(c$2,{asChild:true,children:jsx("div",{className:"fk:w-7 fk:h-7 fk:rounded-sm fk:bg-transparent fk:flex fk:items-center fk:justify-center fk:[&>svg]:h-full fk:[&>svg]:w-auto fk:corner-squircle",children:jsx(Or,{extension:u,...k||{}})})}),jsx(d$1,{children:jsx(e$3,{children:jsx("div",{className:"fk:text-sm fk:text-muted-foreground",children:"Preview not available"})})})]})})})}let l=Re(r,{width:84,height:84}),s$1=Re(r,{width:624,height:624});function b(u){u.stopPropagation(),n(true);}return jsx("div",{className:"fk:z-10",children:jsxs(a,{children:[jsxs(b$3,{children:[jsx(c$2,{asChild:true,children:jsx("img",{src:l,alt:"asset",className:`fk:w-12 fk:h-12 fk:cursor-zoom-in fk:overflow-hidden fk:rounded-md fk:object-contain ${Ft} fk:corner-squircle`,onClick:b})}),jsx(d$1,{children:jsx(e$3,{children:jsx("img",{src:s$1,alt:"asset",className:`fk:w-52 fk:h-52 fk:overflow-hidden fk:rounded-md fk:object-contain ${Ft} fk:corner-squircle`})})})]}),jsx(k,{open:t$1,onOpenChange:n,children:jsxs(p,{className:"fk:sm:max-w-4xl fk:p-3",children:[jsxs(q,{children:[jsx(s,{className:"fk:sr-only",children:"Asset preview"}),jsx(t,{className:"fk:sr-only",children:"Enlarged asset preview"})]}),jsx("img",{src:r,alt:"asset",className:"fk:max-h-[85vh] fk:w-full fk:overflow-hidden fk:rounded-md fk:object-contain fk:corner-squircle"})]})})]})})}var Ur=new Set(["text","number","datetime","switch","select"]);function Xi({attributesSchema:e,checkboxSelect:t,actionsComponent:n$1,enableColumnSorting:r=false}){let[,o]=g$1(),l=b$2(e,o.user?.spaces),s={datetime:"datetime",editor:"editor",asset:"asset",number:"text",relationship:"text",select:"select",switch:"boolean",text:"text",textarea:"text"},b={boolean:xe,date:B,datetime:Me,editor:St,asset:Ct,number:B,relationship:B,select:Et,switch:xe,text:B,textarea:B,tags:Nt,rating:Pt,assetPreviewField:Ht},u=l.map(i=>{if(i.name==="_updatedAt")return null;let T=(i.inputType==="relationship"&&i.relationship?.entity==="_asset"?"asset":void 0)??i.previewType??s[i.inputType],X=b[T]??b.text;if(i.hidden===true)return null;let de=T==="tags",j=r&&i.scope==="global"&&Ur.has(i.inputType);return {accessorKey:i.name,filterFn:(y,N,C)=>de?true:(Array.isArray(C)?C:[C]).includes(y.getValue(N)),header:({column:y})=>j?jsx(Se,{column:y,title:i.label}):jsx("div",{className:"fk:flex fk:items-center",children:i.label}),cell:({row:y})=>{let N=X;return T==="select"||T==="rating"?jsx(N,{value:y.getValue(i.name),options:i.options}):T==="assetPreviewField"?jsx(N,{value:y.original}):jsx(N,{value:y.getValue(i.name)})},enableSorting:j,enableHiding:true,meta:{label:i.label},size:i.options?.size??150}}).filter(i=>i!==null),k={id:"actions",cell:({row:i})=>n$1?n$1(i):null,size:80},S={accessorKey:"_updatedAt",header:({column:i})=>r?jsx(Se,{column:i,title:"Updated At"}):jsx("div",{className:"fk:flex fk:items-center",children:"Updated At"}),cell:({row:i})=>jsx(Me,{value:i.getValue("_updatedAt")}),enableSorting:r,enableHiding:false,meta:{label:"Updated At"},size:220},M={id:"select",cell:({row:i,table:T})=>jsx(n,{"aria-label":"Select row",checked:i.getIsSelected(),onCheckedChange:X=>{T.toggleAllPageRowsSelected(false),i.toggleSelected(!!X);}}),enableSorting:false,enableHiding:false,size:50},g={id:"select",header:({table:i})=>jsx(n,{className:"fk:dark:bg-white/15","aria-label":"Select all",checked:i.getIsAllPageRowsSelected()||i.getIsSomePageRowsSelected()&&"indeterminate",onCheckedChange:T=>{i.toggleAllPageRowsSelected(!!T);}}),cell:({row:i})=>jsx(n,{"aria-label":"Select row",checked:i.getIsSelected(),onCheckedChange:T=>{i.toggleSelected(!!T);}}),enableSorting:false,enableHiding:false,size:50};return [...t==="single"?[M]:[],...t==="multiple"?[g]:[],...n$1?[k]:[],...u,S]}export{Xr as a,Kr as b,lt as c,lo as d,po as e,So as f,Tt as g,It as h,_t as i,Vt as j,Re as k,Se as l,Xi as m};//# sourceMappingURL=chunk-VUZ7GHSO.js.map
|
|
7
|
-
//# sourceMappingURL=chunk-VUZ7GHSO.js.map
|
package/dist/list-N4E3VXM5.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import'./index.css';import {a as a$1}from'./chunk-CLCIE5RF.js';import {a}from'./chunk-K3HW6YWS.js';import {e,b as b$1,j as j$1,n,c as c$5,i,h,l as l$1,o,k as k$2}from'./chunk-RLVHUIFC.js';import'./chunk-4ZWQ44NZ.js';import {c}from'./chunk-CAZ6EUR2.js';import {b}from'./chunk-DSLPTDZX.js';import {w,j,d,x,c as c$4,a as a$3,e as e$3,k as k$1,i as i$1,f,g}from'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import'./chunk-6I7D2JBA.js';import'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import {c as c$3,d as d$1,la,Z,_,ba,ca,$,M,oa,da}from'./chunk-L5T56MRH.js';import {t}from'./chunk-A4DPLZZF.js';import {c as c$1,e as e$1,b as b$2,a as a$2}from'./chunk-3SY46ERM.js';import {l,b as b$4}from'./chunk-5JUG4BEF.js';import {k,p,q,s,t as t$1,r}from'./chunk-S7Z6KKIN.js';import'./chunk-U45E5X3H.js';import {b as b$3,c as c$6,e as e$2}from'./chunk-N33S7BSG.js';import {c as c$2}from'./chunk-X3SHNHHM.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){oa.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$1=await t.addFile(f);i(i$1,f.name),a();}catch(i){oa.error(h(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$1,m]=useState(""),[p$1,f]=useState(""),[u,d]=useState(""),[i$1,w]=useState(false);function N(){a(false),m(""),f(""),d("");}async function K(c){c.preventDefault();let x=g(r$1);if("error"in x){d(x.error);return}w(true),d("");try{let E=await t.addUrl({title:p$1.trim()||void 0,url:x.url});i(E,x.url),o(),N();}catch(E){d(h(E,"The page could not be added."));}finally{w(false);}}return jsx(k,{open:s$1,onOpenChange:c=>c?a(true):N(),children:jsx(p,{children:jsxs("form",{className:"fk:flex fk:flex-col fk:gap-4",onSubmit:c=>{K(c);},children:[jsxs(q,{children:[jsx(s,{children:"Add a web page"}),jsx(t$1,{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(a$2,{htmlFor:"knowledge-url",children:"Address"}),jsx(b$2,{autoFocus:true,id:"knowledge-url",inputMode:"url",placeholder:"https://example.com/help/returns",value:r$1,onChange:c=>{m(c.target.value),d("");}})]}),jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1.5",children:[jsx(a$2,{htmlFor:"knowledge-url-title",children:"Title (optional)"}),jsx(b$2,{id:"knowledge-url-title",maxLength:a$3,placeholder:"Defaults to the page address",value:p$1,onChange:c=>f(c.target.value)})]}),u?jsx("p",{className:"fk:text-sm fk:text-destructive",children:u}):null,jsxs(r,{children:[jsx(c$2,{disabled:i$1,size:"sm",type:"button",variant:"outline",onClick:N,children:"Cancel"}),jsxs(c$2,{disabled:i$1||!r$1.trim(),size:"sm",type:"submit",children:[i$1?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(ba,{className:"fk:h-12 fk:cursor-pointer","data-knowledge-row":true,onClick:r=>pt(r,()=>a.onOpen(t)),children:[jsx(da,{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(da,{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(da,{className:"fk:hidden fk:whitespace-nowrap fk:text-muted-foreground fk:md:table-cell",children:i$1(t)}),jsx(da,{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(da,{className:"fk:hidden fk:whitespace-nowrap fk:text-muted-foreground fk:sm:table-cell",children:jsxs(b$3,{children:[jsx(c$6,{asChild:true,children:jsx("span",{children:mt(t.createdAt)})}),jsxs(e$2,{children:["Updated ",formatDistance(new Date(t.updatedAt),new Date,{addSuffix:true})]})]})}),jsx(da,{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(Z,{"data-knowledge-list":true,children:[jsx(_,{children:jsxs(ba,{className:"fk:hover:bg-transparent",children:[jsx(ca,{children:"Name"}),jsx(ca,{children:"Status"}),jsx(ca,{className:"fk:hidden fk:md:table-cell",children:"Type"}),jsx(ca,{className:"fk:hidden fk:text-right fk:md:table-cell",children:"Size"}),jsx(ca,{className:"fk:hidden fk:sm:table-cell",children:"Added"}),jsx(ca,{className:"fk:w-12",children:jsx("span",{className:"fk:sr-only",children:"Actions"})})]})}),jsx($,{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$1(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$6,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$2,{children:"Toggle Sidebar"})]}),jsx(l,{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=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$6=useRef(null),[x$1,E]=useState(false),Ve=(l,T)=>!a$2||T&&!T.hasMore?null:c$5(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(c$1,{children:jsx(e$1,{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,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(b$2,{"aria-label":"Search documents",className:"fk:pl-8 fk:pr-9",placeholder:"Search by title or content\u2026",ref:c$6,value:p,onChange:l=>f(l.target.value)}),p?jsx(c$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$6.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$3,{"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(la,{disabled:!s,children:jsxs(c$2,{disabled:!s,size:"sm",variant:"outline",onClick:()=>N(true),children:[jsx(LinkIcon,{}),"Add web page"]})}),jsx(la,{disabled:!s,children:jsxs(c$2,{disabled:!s,size:"sm",onClick:()=>K.current?.click(),children:[jsx(UploadIcon,{}),"Upload documents"]})}),jsx("input",{accept:c$4,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-N4E3VXM5.js.map
|
|
3
|
-
//# sourceMappingURL=list-N4E3VXM5.js.map
|
package/dist/pages-XUJGIHQI.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import'./index.css';import {f as f$2,b as b$7,c as c$5,d as d$2,e as e$5,g as g$4}from'./chunk-CSUHZFEP.js';import {x,a,b as b$3,d,c as c$4,y,C,D,B,g as g$2,h as h$1,i,f as f$1,z,I,E,H,e as e$4,F}from'./chunk-HSGUVQXU.js';import {a as a$6}from'./chunk-DHE6PO3V.js';import {a as a$5}from'./chunk-QSTWBKPN.js';import {c as c$3,a as a$1,b as b$4,e as e$3,d as d$1,g as g$6,i as i$1,h as h$3}from'./chunk-N52JTYBJ.js';import {a as a$2}from'./chunk-S26WK6RF.js';import {b as b$8,d as d$4}from'./chunk-7ODGH7G2.js';import {f,g,e as e$7,c as c$8,d as d$5}from'./chunk-U6VZY3V2.js';import'./chunk-RLVHUIFC.js';import'./chunk-4ZWQ44NZ.js';import {c as c$2}from'./chunk-CAZ6EUR2.js';import {b}from'./chunk-DSLPTDZX.js';import'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import {f as f$3}from'./chunk-6I7D2JBA.js';import {g as g$3}from'./chunk-MBBE4RND.js';import {b as b$5}from'./chunk-5CVDMZUI.js';import {Z as Z$1,_,ba as ba$1,ca,$,da,M,e as e$2,la as la$1,fa,ga as ga$1,ha as ha$1,_a,$a,bb,oa as oa$1,Y,ja,r,s,t as t$1}from'./chunk-L5T56MRH.js';import {e,g as g$1,h,j,o,t,q,r as r$1,s as s$1,k}from'./chunk-A4DPLZZF.js';import {b as b$6,a as a$3}from'./chunk-3SY46ERM.js';import {b as b$1,l,m,n,c as c$7,e as e$8,f as f$4,g as g$7,h as h$2,j as j$1}from'./chunk-5JUG4BEF.js';import {a as a$4,d as d$3,c as c$6,e as e$6,g as g$5}from'./chunk-S7Z6KKIN.js';import'./chunk-U45E5X3H.js';import {b as b$2,c as c$1,e as e$1}from'./chunk-N33S7BSG.js';import {c}from'./chunk-X3SHNHHM.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 Ha=[{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 Vo({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(Y,{checked:t,disabled:n,id:l,onCheckedChange:i})]})}function Oo(){let{mode:t}=f$3(),{isLoaded:n,mutate:o,preferences:i}=g$6(),[l,k]=useState(false);async function f(c){k(true);try{await o(h$3(c),{optimisticData:{preferences:c},rollbackOnError:!0});}catch{oa$1.error("Unable to save your notification settings.");}finally{k(false);}}function v(c,p){let d=new Set(i.desktopMutedKinds);p?d.delete(c):d.add(c),f({...i,desktopMutedKinds:[...d]});}return jsxs(r,{children:[jsx(s,{asChild:true,children:jsx(c,{"aria-label":"Notification settings",className:"fk:ml-auto",size:"icon",variant:"ghost",children:jsx(Settings2Icon,{className:"fk:size-4"})})}),jsxs(t$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."]}),Ha.map(({kind:c,label:p})=>jsx(Vo,{checked:!i.desktopMutedKinds.includes(c),disabled:l||!n,label:p,onCheckedChange:d=>v(c,d)},c))]}),jsxs("div",{className:"fk:space-y-2",children:[jsx("p",{className:"fk:text-sm fk:font-medium",children:"Email"}),jsx(Vo,{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 Ya=[{label:"Enabled",value:"enabled"},{label:"Disabled",value:"disabled"}],Qa=[{label:"Project",value:"project"},{label:"Space",value:"space"},{label:"Personal",value:"personal"}];function es(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 Uo({actions:t,isSearchLoading:n$1=false,onSearchChange:o,search:i,searchPlaceholder:l="Search automations...",table:k}){let f=k.getState().columnFilters.length>0||i.trim().length>0,v=k.getAllColumns().find(P=>P.id==="status"),c$1=k.getAllColumns().find(P=>P.id==="visibility"),[p,d]=useState(i),g=p.trim(),T=i.trim(),C=g.length>0&&(n$1||g!==T),j=useRef(o);j.current=o;let A=useMemo(()=>es(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(m,{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:[C?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(b$6,{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(c,{"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]}),v?jsx(a$2,{column:v,options:Ya,title:"Status"}):null,c$1?jsx(a$2,{column:c$1,options:Qa,title:"Visibility"}):null,f?jsxs(c,{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(n,{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[v,c$1]=useState(false),p=useRef(null);return jsxs(r,{open:v,onOpenChange:c$1,children:[jsx(s,{asChild:true,children:jsxs(c,{disabled:t,size:"sm",type:"button",variant:"outline",children:[k,jsx(ChevronDownIcon,{className:"fk:ml-1 fk:size-4"})]})}),jsx(t$1,{align:"end",className:"fk:w-72 fk:p-0",onOpenAutoFocus:d=>{d.preventDefault(),p.current?.focus({preventScroll:true});},children:jsxs(c$7,{filter:Sn,children:[jsx(e$8,{placeholder:l,ref:p}),jsxs(f$4,{className:"fk:max-h-72",children:[jsx(g$7,{children:n}),jsx(h$2,{children:i.map(d=>jsxs(j$1,{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 Xo(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(T=>T.isPrimary),[g]=p;if(p.length===1&&g){let T=l?.connectionMode===c&&l.connectionId===g.id;f.push({choice:{connectionMode:c,connectionId:T||!g.isPrimary?g.id:null},label:`${Xo(c)} \xB7 ${g.displayName}`});continue}d&&f.push({choice:{connectionMode:c,connectionId:null},label:`Primary ${c} account (${d.displayName})`});for(let T of p)f.push({choice:{connectionMode:c,connectionId:T.id},label:`${Xo(c)} \xB7 ${T.displayName}`});}let v=Nt(l);return jsxs(a$4,{disabled:n,value:f.some(c=>Nt(c.choice)===v)?v:"",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$6,{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 Go(t){return t.scopes.filter(n=>n==="project"||t.allowPersonal)}function us(t){let n=Go(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 ds(t,n){return `${encodeURIComponent(t)}:${encodeURIComponent(n)}`}function ms(t){return decodeURIComponent(t.slice(t.indexOf(":")+1))}function ks(t){let n=t.map(ms),o=n.slice(0,wn).join(", ");return n.length>wn?`${o} +${n.length-wn} more`:o}function ps({canManage:t,disabled:n,plugin:o$1,projectId:i,usage:l$1,onChange:k,onRemove:f$1}){let v=Go(o$1),c$1=v.some(w=>Tt(o$1,w).length>0),p=v.includes(l$1.connectionMode)?{connectionMode:l$1.connectionMode,connectionId:l$1.connectionId}:null,d=In(o$1,p),{data:g,error:T}=De(d?`/api/flexkit/${i}/plugin-connections/${d.id}/tools`:null,f),C=(g?.servers??[]).flatMap(w=>w.tools.map(H=>({key:ds(w.name,H.name),entry:H}))),j$1=(g?.servers??[]).flatMap(w=>w.error?[w.error]:[]),A=l$1.allTools!==false,x=n||!o$1.enabled,b=w=>k({...l$1,allTools:false,selectedTools:w,enabled:w.length>0}),P=()=>k({...l$1,allTools:true,selectedTools:[],enabled:true}),F=w=>({...l$1,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){oa$1.error(H instanceof Error?H.message:`Unable to connect ${o$1.name}.`);}finally{M(false);}},U=null;return o$1.enabled?c$1?p?d?T||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$1.selectedTools.length===0?U={text:"No tools selected, so the agent cannot use this plugin yet.",tone:"warning"}:U={text:ks(l$1.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$5,{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$1.connectionMode==="personal"&&l$1.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$1?jsxs(Fragment,{children:[jsx(Pn,{ariaLabel:`${o$1.name} account`,disabled:x,plugin:o$1,scopes:v,value:p,onChange:w=>{w.connectionMode===l$1.connectionMode&&w.connectionId===l$1.connectionId||k(F(w));}}),jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsxs(c,{disabled:x||!d||!g,size:"sm",type:"button",variant:"outline",children:[A?"All tools":l$1.selectedTools.length?`Tools (${l$1.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(C.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,{}),C.map(({key:w,entry:H})=>{let $=A||l$1.selectedTools.includes(w);return jsxs(j,{className:"fk:items-start",onSelect:he=>{he.preventDefault();let q=A?C.map(be=>be.key):l$1.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)}),g&&C.length===0?jsx(j,{disabled:true,children:"This account exposes no tools."}):null]})]})]}):jsx(a$6,{busy:_||n,canManage:t,plugin:o$1,onConnect:w=>{B(w);}}),jsx(c,{"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(l,{})]})}function gs({disabled:t,plugins:n,onAdd:o}){let[i,l]=useState(false),k=useRef(null);return jsxs(r,{open:i,onOpenChange:l,children:[jsx(s,{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(t$1,{align:"start",className:"fk:w-72 fk:p-0",onOpenAutoFocus:f=>{f.preventDefault(),k.current?.focus({preventScroll:true});},children:jsxs(c$7,{filter:Sn,children:[jsx(e$8,{placeholder:"Search plugins\u2026",ref:k}),jsxs(f$4,{children:[jsx(g$7,{children:"No plugins found."}),jsx(h$2,{children:n.map(f=>jsxs(j$1,{value:f.id,keywords:[f.name],onSelect:()=>{o(f),l(false);},children:[jsx(a$5,{className:"fk:size-5 fk:rounded",src:f.logoUrl}),jsx("span",{className:"fk:truncate",children:f.name}),f.connections.some(v=>v.status==="connected")?null:jsx("span",{className:"fk:ml-auto fk:text-xs fk:text-muted-foreground",children:"Not connected"})]},f.id))})]})]})})]})}function Zo({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),v=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=v.get(p.pluginId);return d?jsx(ps,{disabled:o,canManage:l?.canManage??false,plugin:d,projectId:t,usage:p,onChange:g=>i(n.map(T=>T.pluginId===d.id?g:T)),onRemove:()=>i(n.filter(g=>g.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(gs,{disabled:o||!l,plugins:c,onAdd:p=>i([...n,us(p)])})]})}var Kt=["slack","teams"],oa=["create","update","delete"],pa="0 * * * *",ws="0 9 * * *",As="0 9 * * 1",Is="0 9 1 * *",Ps=[{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}],Ms=Array.from({length:24},(t,n)=>({label:`${n.toString().padStart(2,"0")}:00`,value:n})),aa={automation_run:"a run of",bulk_action:"a bulk action of",schema_deploy:"a schema deployment"},sa={any:"finishes",failed:"fails",succeeded:"succeeds"},Rs=[{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,Es=15,Mn="__any__";function Ls(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 ia(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 Ds(t){return (t?.triggers??[]).map(n=>({...n,key:n.id??ft()}))}function zs(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 Fs(){return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}function _s(){let t=crypto.getRandomValues(new Uint8Array(24));return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}function Bs(t){if(t===pa)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 ga(t,n,o){try{let i=CronExpressionParser.parse(t,{tz:n});return Array.from({length:o},()=>i.next().toDate())}catch{return []}}function va(t,n){return new Intl.DateTimeFormat("en-US",{day:"numeric",hour:"numeric",minute:"2-digit",month:"short",timeZone:n,weekday:"short"}).format(t)}function ha(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 js(t,n,o){let i=t.filter(k=>!k.deprecated);if(n!=="edit"||!o)return i;let l=c$5(t,o);return l?.deprecated?[l,...i.filter(k=>b$7(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 $s(t,n){let o={};for(let i of [...t,...n])o[zn(i)]=i;return Object.values(o)}function la(t,n){return {...t,availableChannels:t.channels,channelsLoaded:!t.connected,enabled:t.connected&&n==="edit"&&t.enabled,loadingChannels:false}}function Vs(t,n){return {slack:la(t.providers.slack,n),teams:la(t.providers.teams,n)}}function Os({channels:t,disabled:n,loading:o,onChange:i,onRefresh:l,provider:k,value:f}){let[v,c$1]=useState(false),[p,d]=useState(""),g=useRef(null),T=new Set(f.map(b=>b.id)),C=k==="slack"?"Slack":"Teams",j=t.filter(b=>b.name.toLowerCase().includes(p.toLowerCase()));useEffect(()=>{if(!v)return;function b(F){let{target:S}=F;!(S instanceof Node)||g.current?.contains(S)||c$1(false);}function P(F){F.key==="Escape"&&c$1(false);}return document.addEventListener("pointerdown",b),document.addEventListener("keydown",P),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",P);}},[v]);function A(b){if(T.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:g,children:[jsxs(c,{"aria-expanded":v,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$1(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 ${C} channels...`:`Select ${C} 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"})]}),v?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(b$6,{className:"fk:h-8",placeholder:`Search ${C} 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(c,{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 ${T.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(c,{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]=ga(t,n,1);return o?jsxs("span",{className:"fk:text-sm fk:text-muted-foreground",children:["Next run ",va(o,n)]}):null}function ra({onChange:t,value:n}){return jsxs(a$4,{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$6,{})}),jsx(e$6,{children:Ms.map(o=>jsx(g$5,{value:o.value.toString(),children:o.label},o.value))})]})}function qs({onChange:t,value:n}){return jsxs(a$4,{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$6,{})}),jsx(e$6,{children:Ps.map(o=>jsx(g$5,{value:o.value.toString(),children:o.label},o.value))})]})}function Js({onChange:t,timezone:n,value:o}){let[i,l]=useState(false),k=useRef(null),f=ha(o,n),v=f?[]:ga(o,n,3);return useEffect(()=>{if(!i)return;function c(d){let{target:g}=d;!(g instanceof Node)||k.current?.contains(g)||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(c,{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(b$6,{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"}),v.map(c=>jsx("p",{children:va(c,n)},c.toISOString()))]})]}):null]})}function Us({onChange:t,trigger:n}){let o=Bs(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(ra,{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(qs,{value:o.day,onChange:i=>t({...n,cron:`0 ${o.hour.toString()} * * ${i.toString()}`})}),jsx("span",{children:"at"}),jsx(ra,{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(Js,{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 Hs({onChange:t,projectId:n,trigger:o}){let[i,l]=useState(false),[k,f]=useState(false),v=o.url??c$8(n,o.token);function c$2(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$2,{children:[jsx(c$1,{asChild:true,children:jsxs(c,{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$2(v,l),children:[jsx("span",{className:"fk:truncate",children:v}),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:v})]}),o.secret?jsxs(c,{className:"fk:h-7 fk:px-2.5 fk:text-xs",size:"sm",type:"button",variant:"outline",onClick:()=>c$2(`Bearer ${o.secret??""}`,f),children:[k?jsx(CheckIcon,{className:"fk:size-3.5"}):jsx(KeyRoundIcon,{className:"fk:size-3.5"}),"Copy auth header"]}):jsxs(c,{className:"fk:h-7 fk:px-2.5 fk:text-xs",size:"sm",type:"button",variant:"outline",onClick:()=>t({...o,secret:_s()}),children:[jsx(KeyRoundIcon,{className:"fk:size-3.5"}),"Generate auth header"]})]})}function Xs({entities:t,onChange:n,trigger:o}){function i(f){let v=o.events.includes(f)?o.events.filter(c=>c!==f):[...o.events,f];n({...o,events:oa.filter(c=>v.includes(c))});}function l(f){let v=o.entities.includes(f)?o.entities.filter(c=>c!==f):[...o.entities,f];n({...o,entities:v});}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:oa.map(f=>jsxs(c,{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(c,{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:v=>v.preventDefault(),children:f},f))})]})]})}function Ks({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$4,{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$6,{})}),jsx(e$6,{children:Object.keys(aa).map(f=>jsx(g$5,{value:f,children:aa[f]},f))})]}),i.job==="schema_deploy"?null:jsxs(a$4,{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$6,{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$4,{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$6,{})}),jsx(e$6,{children:Object.keys(sa).map(f=>jsx(g$5,{value:f,children:sa[f]},f))})]})]})}function Ws(t){let n=t.trim();return n==="true"||n==="false"?n==="true":n==="null"?null:n!==""&&Number.isFinite(Number(n))?Number(n):t}function Gs(t){return t===void 0?"":String(t)}function Zs({onChange:t,value:n}){let[o,i]=useState(()=>Gs(n));return jsx(b$6,{"aria-label":"Value",className:"fk:h-7 fk:w-32 fk:text-xs",placeholder:"10",value:o,onChange:l=>{i(l.target.value),t(Ws(l.target.value));}})}function Ys({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(b$6,{"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$4,{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$6,{})}),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(b$6,{"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$4,{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$6,{})}),jsx(e$6,{children:Rs.map(l=>jsx(g$5,{value:l.value,children:l.label},l.value))})]}),i.op==="exists"?null:jsx(Zs,{value:i.value,onChange:l=>t({...n,condition:{...i,value:l}})})]}):null,jsx(a$3,{className:"fk:sr-only",htmlFor:o,children:"Read-only GraphQL query"}),jsx(ja,{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 Qs({automationId:t,entities:n,errors:o,onChange:i,projectId:l$1,triggers:k}){let f=k.some(g=>g.type==="webhook");function v(g){i([...k,g]);}function c$1(g){v({cron:g,key:ft(),timezone:Fs(),type:"schedule"});}function p(g){i(k.map(T=>T.key===g.key?g:T));}function d(g){i(k.filter(T=>T.key!==g));}return jsxs("div",{className:"fk:rounded-lg fk:border fk:bg-muted/60 fk:dark:bg-muted/30 fk:corner-squircle",children:[k.map(g=>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:[g.type==="schedule"?jsx(ClockIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}):null,g.type==="webhook"?jsx(WebhookIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}):null,g.type==="entity"?jsx(DatabaseZapIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}):null,g.type==="job"?jsx(CircleCheckBigIcon,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"}):null,g.type==="poll"?jsx(RefreshCwIcon,{className:"fk:size-4 fk:shrink-0 fk:self-start fk:mt-2.5 fk:text-muted-foreground"}):null,g.type==="schedule"?jsx(Us,{trigger:g,onChange:p}):null,g.type==="webhook"?jsx(Hs,{projectId:l$1,trigger:g,onChange:p}):null,g.type==="entity"?jsx(Xs,{entities:n,trigger:g,onChange:p}):null,g.type==="job"?jsx(Ks,{automationId:t,projectId:l$1,trigger:g,onChange:p}):null,g.type==="poll"?jsx(Ys,{trigger:g,onChange:p}):null,jsx(c,{"aria-label":"Remove trigger",className:"fk:opacity-0 fk:group-hover:opacity-100",size:"icon",type:"button",variant:"ghost",onClick:()=>d(g.key),children:jsx(Trash2Icon,{className:"fk:size-4 fk:text-muted-foreground"})})]}),o[g.key]?jsx("div",{className:"fk:mt-1 fk:pl-7",children:jsx(Xe,{message:o[g.key]})}):null]},g.key),jsx(l,{className:"fk:h-4"})]},g.key)),jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsxs(c,{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$1,{children:[jsx(ClockIcon,{className:"fk:mr-2 fk:size-4 fk:text-muted-foreground"}),"Scheduled"]}),jsxs(s$1,{children:[jsx(j,{onClick:()=>c$1(pa),children:"Hourly"}),jsx(j,{onClick:()=>c$1(ws),children:"Daily"}),jsx(j,{onClick:()=>c$1(As),children:"Weekly"}),jsx(j,{onClick:()=>c$1(Is),children:"Custom (cron)"})]})]}),jsxs(j,{disabled:f,onClick:()=>v({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:()=>v({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:()=>v({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:()=>v({condition:{op:"gte",path:"",value:""},intervalMinutes:Es,key:ft(),query:"",type:"poll",variables:null}),children:[jsx(RefreshCwIcon,{className:"fk:mr-2 fk:size-4 fk:text-muted-foreground"}),"Poll Condition"]})]})]})]})}function ei(){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 ti(){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 ni(t,n,o){return t.visibility==="space"&&!Zt(t,n,o)}function oi(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 ai(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 ba=[{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 si(t){return ba.some(n=>n.value===t)}function Fn({api:t,automation:n,mode:o,onSaved:i,projectId:l$1}){let[k,f$1]=useState((n?.toolConfigs??[]).filter(s=>!["slack","teams"].includes(s.pluginId))),[v,c$1]=useState(n?.name??""),[p,d]=useState(n?.instructions??""),[g$1,T]=useState(n?.enabled??false),[C,j]=useState(null),[A,x]=useState(null),[b$2,P]=useState(n?.mutationPolicy??"require_approval"),[F,S]=useState(n?.toolAllowRules),[_,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(()=>Ds(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:Ra}=De(`/api/flexkit/${l$1}/plugins`,f),qn=!!(Ze||Ra),Ea=g(l$1).tools(n?.id),{data:Ve,error:La}=De(Ea,f),{data:Da}=De(g(l$1).entities,f),{data:an}=De(g(l$1).spaces,f),{data:Rt}=De($==="personal"?null:g(l$1).members($==="space"?q:null),f),{data:oe}=De(g(l$1).skills({limit:100}),f),[,za]=g$3(),ae=b(),Fa=za.user?.spaces??[],Jn=(an?.spaces??[]).filter(s=>Fa.includes(s.code)),Et=Ve?.tools.models,Un=useMemo(()=>{let s=n?.modelId??"";return s?f$2(s,Et??[])??{effort:null,modelKey:s}:null},[n?.modelId,Et]),sn=C??Un?.modelKey??"",pt=useMemo(()=>js(Et??[],o,sn),[o,Et,sn]),Lt=sn||(pt[0]?b$7(pt[0]):""),Hn=c$5(pt,Lt),ln=d$2(Hn,A??(C===null?Un?.effort??null:null)),Xn=e$5(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]),_a=Ye.length>0?[l$1,"attached-skills",...Ye]:null,{data:Dt}=De(_a,()=>Promise.all(Ye.map(s=>ai(l$1,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,$]),Ba=useMemo(()=>{let s={};for(let h of an?.spaces??[])s[h.id]=h.label;return s},[an?.spaces]),fn=useMemo(()=>(oe?.skills??[]).filter(s=>ni(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?zs(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=ia(k),le=useMemo(()=>{let s={};for(let m of Ce){if(m.type==="schedule"){let y=ha(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:v.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,v,et,q,E,Ce,$]),mn=Ls(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(Vs(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:$s(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 ja$1(s){let h=Ft[s];if(h){mt(s);try{await b$8(t,h.id,"project");let y=(await $n(`/api/flexkit/${l$1}/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){oa$1.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 $a(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 Va(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 Oa(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:g$1,instructions:p,modelId:rn,mutationPolicy:b$2,name:v,notifyCreator:B,notifyRule:_,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}oa$1.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=>{Oa(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(a$3,{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(Y,{checked:g$1,id:"automation-enabled",onCheckedChange:T}),jsx(a$3,{className:"fk:font-normal",htmlFor:"automation-enabled",children:g$1?"Active":"Inactive"})]})]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(a$3,{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(b$6,{"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:v,onBlur:()=>N(s=>({...s,name:true})),onChange:s=>c$1(s.target.value)}),zt?jsx(Xe,{id:"automation-name-error",message:le.name}):null]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(a$3,{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$4,{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$6,{})}),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$4,{value:q??"",onValueChange:s=>{be(s||null);},children:[jsx(d$3,{"aria-label":"Space",className:"fk:w-fit",children:jsx(c$6,{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(a$3,{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(Qs,{automationId:n?.id,entities:Da?.entities??[],errors:le.triggerErrors,projectId:l$1,triggers:Ce,onChange:ze})]}),jsxs("div",{className:"fk:space-y-3",children:[jsx(a$3,{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(ja,{"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$4,{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$6,{placeholder:"Select a model"})}),jsx(e$6,{align:"start",children:pt.map(s=>jsxs(g$5,{value:b$7(s),children:[s.name,s.deprecated?" (Legacy)":""]},b$7(s)))})]}),Xn.length>1&&ln?jsxs(a$4,{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$6,{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(a$3,{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$4,{value:b$2,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$6,{})}),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$2==="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$2==="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(c,{"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(a$3,{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$4,{value:_,onValueChange:s=>{si(s)&&M(s);},children:[jsx(d$3,{"aria-label":"Notify about runs",className:"fk:w-fit",id:"automation-notify-rule",children:jsx(c$6,{})}),jsx(e$6,{align:"start",children:ba.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(Y,{checked:B,id:"automation-notify-creator",onCheckedChange:U}),jsx(a$3,{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(a$3,{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(l,{}),E?Kt.map(s=>{let h=E[s],m=s==="slack"?"Send to Slack":"Send to Microsoft Teams",y=s==="slack"?ei:ti,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(c,{"aria-label":`Remove ${s==="slack"?"Slack":"Microsoft Teams"} from automation`,size:"icon",type:"button",variant:"ghost",onClick:()=>Va(s),children:jsx(Trash2Icon,{className:"fk:size-4 fk:text-muted-foreground"})}):jsx(c,{size:"sm",type:"button",variant:"outline",onClick:()=>_t(s,{enabled:true}),children:"Add"}):jsx(c,{disabled:!ae||!D?.enabled||!Ze?.canManage||Pt!==null,size:"sm",type:"button",variant:"outline",onClick:()=>{ja$1(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(a$3,{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=>$a(s,Me.connectionId)})]}):null,jsx(a$3,{className:"fk:mr-3 fk:text-xs fk:font-medium",children:"Channels"}),jsx(Os,{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(l,{})]},s)}):La?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:oi(s,Ba)}))],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(l,{}),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(l,{}),jsx(Zo,{projectId:l$1,value:k,disabled:!ae,onChange:s=>{f$1(s),ia(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(la$1,{disabled:!ae,children:jsx(c,{disabled:je||!mn||!ae,type:"submit",children:je?"Saving...":o==="create"?"Create automation":"Update automation"})})]})]})}var Na=25;function hi(t){return Math.max(600,t)}function bi(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 yi(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 Aa({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 ${yi(t)}`,variant:t==="success"?"default":"secondary",children:t==="awaiting_approval"?"awaiting approval":t})}function xi(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 Ni(t){let n=t.triggers.map(o=>{if(o.type==="schedule")return xi(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 Ia(t){return t?!!(t.name.trim()&&t.instructions.trim()&&t.modelId.trim()):false}function Ti({projectId:t}){let{data:n}=De(g(t).creditBalance,f),o=n?.creditBalance;return o?jsx(c,{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 Ci(t,n){let o=t.visibility??"project";return o==="space"?(t.spaceId?n.get(t.spaceId):void 0)??"Space":o==="personal"?"Personal":"Project"}var Pa="fk:sticky fk:top-0 fk:z-10 fk:[&_th]:sticky fk:[&_th]:top-0 fk:[&_th]:bg-muted";function Si(){return jsxs(Z$1,{children:[jsx(_,{className:Pa,children:jsxs(ba$1,{children:[jsx(ca,{children:"Automation"}),jsx(ca,{children:"Triggers"}),jsx(ca,{children:"Last run"}),jsx(ca,{className:"fk:text-center",children:"Runs"}),jsx(ca,{children:"Visibility"}),jsx(ca,{className:"fk:text-center",children:"Status"}),jsx(ca,{})]})}),jsx($,{children:Array.from({length:5},(t$1,n)=>jsxs(ba$1,{children:[jsx(da,{children:jsx(t,{className:"fk:h-4 fk:w-36"})}),jsx(da,{children:jsx(t,{className:"fk:h-4 fk:w-48"})}),jsx(da,{children:jsx(t,{className:"fk:h-4 fk:w-24"})}),jsx(da,{className:"fk:text-center",children:jsx(t,{className:"fk:mx-auto fk:h-4 fk:w-8"})}),jsx(da,{children:jsx(t,{className:"fk:h-4.75 fk:w-16"})}),jsx(da,{className:"fk:text-center",children:jsx(t,{className:"fk:mx-auto fk:h-4.75 fk:w-16"})}),jsx(da,{className:"fk:text-right",children:jsx(t,{className:"fk:ml-auto fk:size-8"})})]},n))})]})}function Ta(t,n){let i=t.find(l=>l.id===n)?.value;return Array.isArray(i)?i.filter(l=>typeof l=="string"):[]}function wi(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 Ai(t){if(t.length===0)return;let n=t.filter(o=>o==="project"||o==="space"||o==="personal");if(n.length!==0)return n}function Hl(){let{api:t,projectId:n}=x(),o$1=useNavigate(),[i,l$1]=useState([]),[k,f$1]=useState(""),[v,c$2]=useState(""),p=b(),d=useRef(null),g$2=Ta(i,"status"),T=Ta(i,"visibility"),C=wi(g$2),j$1=Ai(T),A=i.length>0||k.trim().length>0,x$1=JSON.stringify({enabledFilter:C,search:k,visibilityFilter:j$1}),b$3=(N,E)=>!n||E&&E.hasMore===false?null:g(n).automations({enabled:C,limit:Na,offset:N*Na,search:k.trim()||void 0,visibility:j$1}),{data:P,isLoading:F,mutate:S,setSize:_$1,size:M$1}=It(b$3,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$1>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(1),l$1(N);},state:{columnFilters:i}}),me=useRef(()=>{_$1(N=>N+1);}),dt=useRef($$1),Ce=useRef(he);me.current=()=>{_$1(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>=hi(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(1),f$1(N));},[_$1]);if(!n||!t)return jsx(Z,{children:"Select a project to view automations."});async function Ge(N){if(c$2(""),!t)return;let E=await t.deleteAutomation(N.id);if(!E.success){c$2(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(Si,{}):w.length===0?R=jsx(Z,{children:A?"No results.":"No automations yet."}):R=jsxs(Z$1,{children:[jsx(_,{className:Pa,children:jsxs(ba$1,{children:[jsx(ca,{children:"Automation"}),jsx(ca,{children:"Triggers"}),jsx(ca,{children:"Last run"}),jsx(ca,{className:"fk:text-center",children:"Runs"}),jsx(ca,{children:"Visibility"}),jsx(ca,{className:"fk:text-center",children:"Status"}),jsx(ca,{})]})}),jsx($,{children:w.map(N=>jsxs(ba$1,{className:"fk:cursor-pointer",onClick:()=>o$1(N.id),children:[jsx(da,{children:jsx("span",{className:"fk:font-medium",children:N.name})}),jsx(da,{className:"fk:text-muted-foreground",children:Ni(N)}),jsx(da,{children:N.lastRunAt?formatDistance(new Date(N.lastRunAt),new Date,{addSuffix:true}):"Never"}),jsx(da,{className:"fk:text-center",children:N.totalRuns}),jsx(da,{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:Ci(N,U)})}),jsx(da,{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(da,{className:"fk:text-right",children:jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsx(c,{"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$2,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(l,{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(e$2,{href:"https://flexkit.io/docs/automations",children:"Learn more"})]})]})]}),v?jsx("div",{className:"fk:text-sm fk:text-destructive",children:v}):null,jsx(Uo,{actions:jsxs(Fragment,{children:[jsx(Ti,{projectId:n}),p?jsx(c,{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(la$1,{disabled:true,children:jsxs(c,{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 Xl(){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$2,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(l,{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(c,{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(m,{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 Kl(){let{api:t,projectId:n}=x(),{automationId:o}=useParams(),i=useNavigate(),[l$1,k]=useTransition(),f$1=b(),{data:v,mutate:c$2}=De(n&&o?g(n).automation(o):null,f);if(!n||!t||!o)return jsx(Z,{children:"Select an automation."});if(!v?.automation)return jsx(Z,{children:"Loading automation..."});let p=t,d=Ia(v.automation)&&f$1,g$1=o;function T(){d&&k(async()=>{let C=await p.runAutomation(g$1);if(C.success&&C.runId){i(`runs/${C.runId}`);return}await c$2();});}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$2,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(l,{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:v.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(c,{asChild:true,size:"sm",variant:"ghost",children:jsxs(Link,{to:"../automations",children:[jsx(ArrowLeft,{className:"fk:mr-2 fk:size-4"}),"Automations"]})}),jsx(fa,{value:"settings",children:jsxs(ga$1,{children:[jsx(ha$1,{className:"text-xs",value:"settings",children:"Settings"}),jsx(ha$1,{className:"text-xs",value:"runs",children:jsx(Link,{to:"runs",children:"Runs"})})]})}),jsx(la$1,{disabled:!f$1,children:jsxs(c,{disabled:l$1||!d,size:"sm",onClick:T,children:[l$1?jsx(LoaderCircle,{className:"fk:mr-2 fk:size-4 fk:animate-spin"}):jsx(Play,{className:"fk:mr-2 fk:size-4"}),"Run now"]})})]}),jsx(m,{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:v.automation,mode:"edit",projectId:n,onSaved:C=>{C?c$2({automation:C},{revalidate:false}):c$2();}})})})]})}var tn=25;function Wl(){let{api:t,projectId:n}=x(),{automationId:o}=useParams(),i=useNavigate(),[l$1,k]=useTransition(),{data:f$1}=De(n&&o?g(n).automation(o):null,f),v=(B,U)=>!n||!o||U&&U.hasMore===false?null:g(n).automationRuns(o,B*tn,tn),{data:c$2,isLoading:p,mutate:d,setSize:g$1,size:T}=It(v,f),C=b();if(!n||!t||!o)return jsx(Z,{children:"Select an automation to view runs."});let j=t,A=Ia(f$1?.automation)&&C,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$2?.flatMap(B=>B.runs)??[],S=c$2?.[c$2.length-1]?.hasMore??false,_=c$2!==void 0&&T>c$2.length;function M$1(){g$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$2,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(l,{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(c,{asChild:true,size:"sm",variant:"ghost",children:jsxs(Link,{to:"../automations",children:[jsx(ArrowLeft,{className:"fk:mr-2 fk:size-4"}),"Automations"]})}),jsx(fa,{value:"runs",children:jsxs(ga$1,{children:[jsx(ha$1,{className:"text-xs",value:"settings",children:jsx(Link,{relative:"path",to:"..",children:"Settings"})}),jsx(ha$1,{className:"text-xs",value:"runs",children:"Runs"})]})}),jsx(la$1,{disabled:!C,children:jsxs(c,{disabled:l$1||!A,size:"sm",onClick:b$1,children:[l$1?jsx(LoaderCircle,{className:"fk:mr-2 fk:size-4 fk:animate-spin"}):jsx(Play,{className:"fk:mr-2 fk:size-4"}),"Run now"]})})]}),jsx(m,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:pb-6 fk:pr-4",children:[jsx(Ma,{basePath:".",isLoading:p,runs:P}),S&&!_?jsx(on,{onVisible:M$1}):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(Z$1,{children:jsx($,{children:Array.from({length:5},(t$1,n)=>jsxs(ba$1,{children:[jsx(da,{className:"fk:py-2",children:jsx(t,{className:"fk:h-4 fk:w-28"})}),jsx(da,{children:jsx(t,{className:"fk:h-4 fk:w-20"})}),jsx(da,{children:jsx(t,{className:"fk:h-4.75 fk:w-16"})}),jsx(da,{children:jsx(t,{className:"fk:h-4 fk:w-full fk:max-w-md"})})]},n))})})}function Ma({basePath:t,isLoading:n=false,runs:o}){return n?jsx(jn,{}):o.length===0?jsx(Z,{children:"No runs found."}):jsx(Z$1,{children:jsx($,{children:o.map(i=>jsxs(ba$1,{children:[jsx(da,{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(da,{className:"fk:text-muted-foreground",children:i.triggerType}),jsx(da,{children:jsx(Aa,{status:i.status})}),jsx(da,{className:"fk:max-w-md fk:truncate fk:text-muted-foreground",children:i.summary??""})]},i.id))})})}function Gl(){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:v}=It(i,f),c=l?.[0]?.history.metrics,p=l?.flatMap(x=>x.history.runs)??[],g$1=l?.[l.length-1]?.history.hasMore??false,T=l!==void 0&&v>l.length;if(!t$1)return jsx(Z,{children:"Select a project to view run history."});function C(){f$1(x=>x+1);}function j(x){!bi(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&&(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.successful24h}),jsx(en,{title:"Failed 24h",value:c.failed24h}),jsx(en,{title:"Successful 7d",value:c.successful7d}),jsx(en,{title:"Failed 7d",value:c.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$2,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(fa,{value:n,onValueChange:j,children:jsxs(ga$1,{children:[jsx(ha$1,{value:"team",children:"Team"}),jsx(ha$1,{value:"mine",children:"Mine"})]})})]}),A,jsx(m,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:pb-6 fk:pr-4",children:[jsx(Ma,{basePath:"../automations",isLoading:k,runs:p.map(x=>({...x,id:`${x.automationId}/runs/${x.id}`}))}),g$1&&!T?jsx(on,{onVisible:C}):null,T?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 Ca=25;function Ii(t){return t==="pending"||t==="all"}function Zl(){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:Ca,offset:M*Ca,status:o==="pending"?"pending":void 0}),{data:v,isLoading:c,mutate:p,setSize:d$1,size:g$1}=It(f$1,f,{refreshInterval:3e4}),T=v?.flatMap(M=>M.approvals)??[],C=v?.[0]?.pendingCount??0,j=v?.[0],A=a();useEffect(()=>{j&&A(j);},[j,A]);let b=v?.[v.length-1]?.hasMore??false,P=v!==void 0&&g$1>v.length,F=T.find(M=>M.id===l)??null;if(useEffect(()=>{l===null||F!==null||c||v===void 0||k(null);},[v,c,F,l]),!n||!t)return jsx(Z,{children:"Select a project to view approvals."});function S(){d$1(M=>M+1);}function _(M){!Ii(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$2,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(fa,{value:o,onValueChange:_,children:jsxs(ga$1,{children:[jsxs(ha$1,{value:"pending",children:["Pending",C>0?` (${C.toString()})`:""]}),jsx(ha$1,{value:"all",children:"All"})]})})]}),jsx(m,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:pb-6 fk:pr-4",children:[c?jsx(jn,{}):T.length===0?jsx(Z,{children:o==="pending"?"No proposals are waiting for approval.":"No approvals found."}):jsx(Z$1,{children:jsx($,{children:T.map(M=>jsxs(ba$1,{className:"fk:cursor-pointer",onClick:()=>k(M.id),children:[jsx(da,{children:jsx(b$3,{status:M.status})}),jsx(da,{className:"fk:font-medium",children:M.operationsSummary}),jsx(da,{className:"fk:text-muted-foreground",children:M.automationName}),jsx(da,{className:"fk:text-muted-foreground",children:formatDistance(new Date(M.requestedAt),new Date,{addSuffix:true})}),jsx(da,{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 Sa=25,Pi={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 Mi(t){return t==="needs_action"||t==="all"}function Ri(){let{mode:t}=f$3(),[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(c,{size:"sm",variant:"outline",onClick:()=>{Notification.requestPermission().then(i=>{o(i),i==="granted"&&t==="hosted"&&i$1().catch(()=>{});});},children:"Turn on"})]})}function Yl(){let{api:t,projectId:n}=x(),o=useNavigate(),i=c$2(),[l,k]=useState("needs_action"),[f$1,v]=useState(()=>new Set),c$4=a(),p=(S,_)=>!n||_&&!_.hasMore?null:g(n).activity({filter:l,limit:Sa,offset:S*Sa}),{data:d,isLoading:g$1,mutate:T,setSize:C,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||(v(_=>new Set([..._,...S])),t.markActivityRead(S).then(()=>c$4()));},[t,i,A,c$4]),!n||!t)return jsx(Z,{children:"Select a project to view activity."});function P(S){!Mi(S)||S===l||(C(1),k(S));}function F(S){t&&t.setActivityItemState(S.id,"dismissed").catch(_=>{oa$1.error(_ instanceof Error?_.message:"Unable to dismiss this item.");}).finally(()=>{T();});}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$2,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(fa,{value:l,onValueChange:P,children:jsxs(ga$1,{children:[jsx(ha$1,{value:"needs_action",children:"Needs attention"}),jsx(ha$1,{value:"all",children:"All"})]})}),jsx(Oo,{})]}),jsx(Ri,{}),jsx(m,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:pb-6 fk:pr-4",children:[g$1?jsx(jn,{}):A.length===0?jsx(Z,{children:l==="needs_action"?"Nothing needs your attention.":"No activity yet."}):jsx(Z$1,{children:jsx($,{children:A.map(S=>{let _=c$3(S),M=a$1(S),B=b$4(S),U=e$3(S),w=d$1(S);return jsxs(ba$1,{className:"fk:cursor-pointer",onClick:()=>o(S.id),children:[jsx(da,{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(da,{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(da,{children:_?jsx(b$1,{className:Pi[w],variant:w==="neutral"?"outline":"default",children:_}):null}),jsx(da,{className:"fk:whitespace-nowrap fk:text-muted-foreground",children:formatDistance(new Date(S.createdAt),new Date,{addSuffix:true})}),jsx(da,{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(da,{className:"fk:w-8",onClick:H=>H.stopPropagation(),children:U?null:jsxs(b$2,{children:[jsx(c$1,{asChild:true,children:jsx(c,{"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:()=>{C(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 Ql(){let{api:t$1,projectId:n}=x(),{itemId:o=""}=useParams(),i=a(),{data:l$1,error:k,isLoading:f$1,mutate:v}=De(n&&o?g(n).activityItem(o):null,f),c$3=l$1?.item,p=c$3?.approvalId??null,{data:d,mutate:g$1}=De(n&&p?g(n).approval(p):null,f),T=c$3?.state==="unread",C=c$2();if(useEffect(()=>{!t$1||!T||!C||t$1.markActivityRead([o]).then(()=>{v(),i();});},[t$1,T,C,o,v,i]),!n||!t$1)return jsx(Z,{children:"Select a project to view activity."});let j=c$3?a$1(c$3):null,A=c$3?b$4(c$3):null,x$1;return k?x$1=jsx(Z,{children:"This activity item no longer exists."}):f$1||!c$3?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$3.body?`${c$3.body} \xB7 `:"",formatDistance(new Date(c$3.createdAt),new Date,{addSuffix:true})]}),d?jsx(c$4,{api:t$1,approval:d.approval,chat:d.approval.chatId!==null,onDecided:()=>{v(),g$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$2,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(l,{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$3?.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$2,{children:[jsx(c$1,{asChild:true,children:jsx(c,{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(c,{asChild:true,size:"sm",variant:"outline",children:jsx(Link,{to:`../${j}`,children:A})}):null]}),jsx(m,{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 er(){let{api:t,projectId:n}=x(),{automationId:o,runId:i}=useParams(),{data:l$1,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),[v,c$2]=useTransition(),[p,d]=useState(false);if(useEffect(()=>{d(false);},[i]),!n||!t||!o||!i)return jsx(Z,{children:"Select a run."});let g$1=t,T=i,C$1=l$1?.run,j=C$1?.status==="running"&&!p;function A(){c$2(async()=>{await g$1.cancelRun(T),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$2,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(l,{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(c,{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:C$1?`Run from ${format(new Date(C$1.startedAt),"PPpp")}`:"Loading run..."}),C$1?jsx(Aa,{status:C$1.status}):null]})]}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[C$1&&C(C$1.status)?jsx(c,{asChild:true,size:"sm",variant:"outline",children:b$5()?jsx("a",{download:`transcript-${T}.json`,href:g$1.getTranscriptUrl(T),children:"Transcript"}):jsx("a",{href:g$1.getTranscriptUrl(T),rel:"noreferrer",target:"_blank",children:"Transcript"})}):null,j?jsx(c,{disabled:v,size:"sm",variant:"destructive",onClick:A,children:v?"Cancelling...":"Cancel run"}):null]})]}),jsxs(_a,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:[jsx($a,{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:C$1?jsx(Li,{api:t,run:C$1,onRunUpdated:b,onStreamFinished:x$1}):jsx(Z,{children:"Loading run..."})})}),jsx(bb,{})]})]})}function Ei(t){return t==="unavailable"?"No replay events were recorded.":t==="error"?"Unable to load run replay.":"Loading run replay..."}function Li({api:t,onRunUpdated:n,onStreamFinished:o,run:i$1}){let{projectId:l}=x(),{workflowRunId:k}=i$1,f$2=k?t.getStreamUrl(k):"",[v,c]=useState(0),[p,d]=useState(false),[g$1,T]=useState([]),[C$1,j]=useState({}),A=useRef(null),{message:x$1,status:b}=D(f$2,{decidedApprovals:C$1,recordStatus:i$1.status,resumeToken:v,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=g$1.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,T([]),j({});},[i$1.id]),useEffect(()=>{let R=he?.approvals;R?.length&&T(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(()=>{T(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$1(x$1)??"Thinking",Ge=B$1||!je,$e=Ei(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(Di,{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 Di({api:t,message:n}){let o=n.role==="user",i=n.parts.filter(l=>!e$4(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{Ql as ActivityItemPage,Yl as ActivityPage,Zl as ApprovalsPage,Kl as AutomationDetailPage,Hl as AutomationsPage,Xl as CreateAutomationPage,er as RunDetailPage,Gl as RunHistoryPage,Wl as RunsPage};//# sourceMappingURL=pages-XUJGIHQI.js.map
|
|
5
|
-
//# sourceMappingURL=pages-XUJGIHQI.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import'./index.css';export{b as CatalogHeader,d as InstalledPluginsPage,a as PluginConnectControl,e as PluginDetailPage,c as PluginsPage}from'./chunk-DHE6PO3V.js';import'./chunk-QSTWBKPN.js';import'./chunk-7ODGH7G2.js';import'./chunk-U6VZY3V2.js';import'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import'./chunk-6I7D2JBA.js';import'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import'./chunk-L5T56MRH.js';import'./chunk-A4DPLZZF.js';import'./chunk-3SY46ERM.js';import'./chunk-5JUG4BEF.js';import'./chunk-S7Z6KKIN.js';import'./chunk-U45E5X3H.js';import'./chunk-N33S7BSG.js';import'./chunk-X3SHNHHM.js';//# sourceMappingURL=plugin-pages-FEQILAQR.js.map
|
|
2
|
-
//# sourceMappingURL=plugin-pages-FEQILAQR.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import'./index.css';import {a,b,d as d$1}from'./chunk-C3OHXPJV.js';export{a as getProjectLabel}from'./chunk-C3OHXPJV.js';import {f}from'./chunk-6I7D2JBA.js';import'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import'./chunk-3SY46ERM.js';import {a as a$1,d,c,e,b as b$1,f as f$1,g,h,k,p,q as q$1,s,t}from'./chunk-S7Z6KKIN.js';import'./chunk-U45E5X3H.js';import'./chunk-X3SHNHHM.js';import {useState}from'react';import {useNavigate}from'react-router-dom';import {Plus}from'lucide-react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';var _="__new_project__";function q({projectId:s$1,projectIds:v,projectSummaries:a$2=[],projects:i}){let L=useNavigate(),{mode:E,teams:V}=f(),[m,l]=useState(false),p$1=a(s$1,i,a$2),F=b(v,a$2),g$1=E==="hosted";return jsxs(Fragment,{children:[jsxs(a$1,{onValueChange:o=>{if(o===_){l(true);return}L(`/${o}`);},value:s$1,children:[jsx(d,{className:"fk:w-48! fk:h-9 fk:py-1",id:"project",children:jsx(c,{"aria-label":p$1,children:p$1})}),jsxs(e,{children:[F.map((o,J)=>jsxs(b$1,{children:[o.label?jsx(f$1,{children:o.label}):null,o.projectIds.map(c=>jsx(g,{value:c,children:a(c,i,a$2)},c))]},o.label??J)),g$1?jsxs(Fragment,{children:[jsx(h,{}),jsxs(g,{value:_,children:[jsx(Plus,{className:"fk:h-4 fk:w-4"}),"New project"]})]}):null]})]}),g$1?jsx(k,{onOpenChange:l,open:m,children:jsxs(p,{className:"fk:sm:max-w-md",children:[jsxs(q$1,{children:[jsx(s,{children:"New project"}),jsx(t,{children:"Projects start on the Free plan. The AI agent helps you design the schema once it opens."})]}),m?jsx(d$1,{autoFocus:true,onCancel:()=>{l(false);},onCreated:()=>{l(false);},teams:V}):null]})}):null]})}export{q as ProjectSelector};//# sourceMappingURL=project-selector-U64ROZ5D.js.map
|
|
2
|
-
//# sourceMappingURL=project-selector-U64ROZ5D.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ui/components/project-selector.tsx"],"names":["NEW_PROJECT_VALUE","ProjectSelector","projectId","projectIds","projectSummaries","projects","navigate","useNavigate","mode","teams","useConfig","isCreating","setIsCreating","useState","label","getProjectLabel","groups","groupProjectIdsByTeam","canCreate","jsxs","Fragment","Select","id","jsx","SelectTrigger","SelectValue","SelectContent","group","index","SelectGroup","SelectLabel","SelectItem","SelectSeparator","Plus","Dialog","DialogContent","DialogHeader","DialogTitle","DialogDescription","CreateProjectForm"],"mappings":"2hBAoBA,IAAMA,CAAAA,CAAoB,iBAAA,CAcnB,SAASC,CAAAA,CAAgB,CAAE,SAAA,CAAAC,GAAAA,CAAW,UAAA,CAAAC,CAAAA,CAAY,iBAAAC,GAAAA,CAAmB,EAAC,CAAG,QAAA,CAAAC,CAAS,CAAA,CAAuB,CAC9G,IAAMC,CAAAA,CAAWC,WAAAA,EAAY,CACvB,CAAE,IAAA,CAAAC,CAAAA,CAAM,KAAA,CAAAC,CAAM,CAAA,CAAIC,CAAAA,EAAU,CAC5B,CAACC,CAAAA,CAAYC,CAAa,CAAA,CAAIC,QAAAA,CAAS,KAAK,CAAA,CAC5CC,GAAAA,CAAQC,CAAAA,CAAgBb,GAAAA,CAAWG,CAAAA,CAAUD,GAAgB,CAAA,CAC7DY,CAAAA,CAASC,CAAAA,CAAsBd,CAAAA,CAAYC,GAAgB,CAAA,CAE3Dc,GAAAA,CAAYV,CAAAA,GAAS,QAAA,CAE3B,OACEW,IAAAA,CAAAC,QAAAA,CAAA,CACE,QAAA,CAAA,CAAAD,IAAAA,CAACE,GAAAA,CAAA,CACC,aAAA,CAAgBC,CAAAA,EAAO,CACrB,GAAIA,CAAAA,GAAOtB,CAAAA,CAAmB,CAC5BY,CAAAA,CAAc,IAAI,CAAA,CAElB,MACF,CAEAN,CAAAA,CAAS,CAAA,CAAA,EAAIgB,CAAE,CAAA,CAAE,EACnB,CAAA,CACA,KAAA,CAAOpB,GAAAA,CAEP,QAAA,CAAA,CAAAqB,GAAAA,CAACC,CAAAA,CAAA,CAAc,SAAA,CAAU,yBAAA,CAA0B,EAAA,CAAG,SAAA,CACpD,QAAA,CAAAD,GAAAA,CAACE,CAAAA,CAAA,CAAY,YAAA,CAAYX,GAAAA,CAAQ,QAAA,CAAAA,GAAAA,CAAM,CAAA,CACzC,CAAA,CACAK,IAAAA,CAACO,CAAAA,CAAA,CACE,QAAA,CAAA,CAAAV,CAAAA,CAAO,GAAA,CAAI,CAACW,EAAOC,CAAAA,GAClBT,IAAAA,CAACU,GAAAA,CAAA,CACE,QAAA,CAAA,CAAAF,CAAAA,CAAM,KAAA,CAAQJ,GAAAA,CAACO,GAAAA,CAAA,CAAa,QAAA,CAAAH,CAAAA,CAAM,KAAA,CAAM,CAAA,CAAiB,IAAA,CACzDA,CAAAA,CAAM,UAAA,CAAW,GAAA,CAAKL,CAAAA,EACrBC,GAAAA,CAACQ,CAAAA,CAAA,CAAoB,KAAA,CAAOT,CAAAA,CACzB,QAAA,CAAAP,CAAAA,CAAgBO,CAAAA,CAAIjB,CAAAA,CAAUD,GAAgB,CAAA,CAAA,CADhCkB,CAEjB,CACD,CAAA,CAAA,CAAA,CANeK,CAAAA,CAAM,KAAA,EAASC,CAOjC,CACD,CAAA,CACAV,GAAAA,CACCC,IAAAA,CAAAC,QAAAA,CAAA,CACE,QAAA,CAAA,CAAAG,GAAAA,CAACS,CAAAA,CAAA,EAAgB,CAAA,CACjBb,IAAAA,CAACY,CAAAA,CAAA,CAAW,KAAA,CAAO/B,CAAAA,CACjB,QAAA,CAAA,CAAAuB,GAAAA,CAACU,IAAAA,CAAA,CAAK,SAAA,CAAU,eAAA,CAAgB,CAAA,CAAE,aAAA,CAAA,CAEpC,CAAA,CAAA,CACF,EACE,IAAA,CAAA,CACN,CAAA,CAAA,CACF,CAAA,CACCf,GAAAA,CACCK,GAAAA,CAACW,CAAAA,CAAA,CAAO,YAAA,CAActB,CAAAA,CAAe,IAAA,CAAMD,CAAAA,CACzC,QAAA,CAAAQ,IAAAA,CAACgB,CAAAA,CAAA,CAAc,SAAA,CAAU,gBAAA,CACvB,QAAA,CAAA,CAAAhB,IAAAA,CAACiB,GAAAA,CAAA,CACC,QAAA,CAAA,CAAAb,GAAAA,CAACc,CAAAA,CAAA,CAAY,QAAA,CAAA,aAAA,CAAW,CAAA,CACxBd,GAAAA,CAACe,CAAAA,CAAA,CAAkB,QAAA,CAAA,0FAAA,CAEnB,CAAA,CAAA,CACF,CAAA,CACC3B,CAAAA,CACCY,GAAAA,CAACgB,GAAAA,CAAA,CACC,SAAA,CAAS,IAAA,CACT,QAAA,CAAU,IAAM,CACd3B,CAAAA,CAAc,KAAK,EACrB,CAAA,CACA,SAAA,CAAW,IAAM,CACfA,CAAAA,CAAc,KAAK,EACrB,CAAA,CACA,KAAA,CAAOH,CAAAA,CACT,CAAA,CACE,IAAA,CAAA,CACN,CAAA,CACF,CAAA,CACE,IAAA,CAAA,CACN,CAEJ","file":"project-selector-U64ROZ5D.js","sourcesContent":["import { useState, type JSX } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { Plus } from 'lucide-react';\nimport { useConfig } from '../../core/config/config-context';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../primitives/dialog';\nimport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectSeparator,\n SelectTrigger,\n SelectValue,\n} from '../primitives/select';\nimport type { ProjectSummary, ProjectUiConfig } from '../../core/config/types';\nimport { CreateProjectForm } from './create-project-form';\nimport { getProjectLabel, groupProjectIdsByTeam } from './project-label';\n\n/** Select value of the \"New project\" entry; project ids are ten lowercase characters, so it cannot collide. */\nconst NEW_PROJECT_VALUE = '__new_project__';\n\nexport { getProjectLabel } from './project-label';\n\ntype Props = {\n projectId: string;\n /** Every project the Studio can open, loaded or not. */\n projectIds: string[];\n /** Hosted mode: names and teams known before any schema loads. */\n projectSummaries?: ProjectSummary[];\n /** Projects whose schema has loaded; used for titles. */\n projects: ProjectUiConfig[];\n};\n\nexport function ProjectSelector({ projectId, projectIds, projectSummaries = [], projects }: Props): JSX.Element {\n const navigate = useNavigate();\n const { mode, teams } = useConfig();\n const [isCreating, setIsCreating] = useState(false);\n const label = getProjectLabel(projectId, projects, projectSummaries);\n const groups = groupProjectIdsByTeam(projectIds, projectSummaries);\n // Projects are created from the hosted Studio only; a self-hosted Studio lists fixed project ids.\n const canCreate = mode === 'hosted';\n\n return (\n <>\n <Select\n onValueChange={(id) => {\n if (id === NEW_PROJECT_VALUE) {\n setIsCreating(true);\n\n return;\n }\n\n navigate(`/${id}`);\n }}\n value={projectId}\n >\n <SelectTrigger className=\"fk:w-48! fk:h-9 fk:py-1\" id=\"project\">\n <SelectValue aria-label={label}>{label}</SelectValue>\n </SelectTrigger>\n <SelectContent>\n {groups.map((group, index) => (\n <SelectGroup key={group.label ?? index}>\n {group.label ? <SelectLabel>{group.label}</SelectLabel> : null}\n {group.projectIds.map((id) => (\n <SelectItem key={id} value={id}>\n {getProjectLabel(id, projects, projectSummaries)}\n </SelectItem>\n ))}\n </SelectGroup>\n ))}\n {canCreate ? (\n <>\n <SelectSeparator />\n <SelectItem value={NEW_PROJECT_VALUE}>\n <Plus className=\"fk:h-4 fk:w-4\" />\n New project\n </SelectItem>\n </>\n ) : null}\n </SelectContent>\n </Select>\n {canCreate ? (\n <Dialog onOpenChange={setIsCreating} open={isCreating}>\n <DialogContent className=\"fk:sm:max-w-md\">\n <DialogHeader>\n <DialogTitle>New project</DialogTitle>\n <DialogDescription>\n Projects start on the Free plan. The AI agent helps you design the schema once it opens.\n </DialogDescription>\n </DialogHeader>\n {isCreating ? (\n <CreateProjectForm\n autoFocus\n onCancel={() => {\n setIsCreating(false);\n }}\n onCreated={() => {\n setIsCreating(false);\n }}\n teams={teams}\n />\n ) : null}\n </DialogContent>\n </Dialog>\n ) : null}\n </>\n );\n}\n"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import'./index.css';export{a as EntityKnowledgeButton,c as LinkedRecordsSection,b as RecordKnowledgePanel}from'./chunk-UB22GYFK.js';import'./chunk-RLVHUIFC.js';import'./chunk-4ZWQ44NZ.js';import'./chunk-CFYO546Y.js';import'./chunk-DSLPTDZX.js';import'./chunk-YKM3FUGK.js';import'./chunk-XMOSCJOI.js';import'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import'./chunk-YDVO6XWD.js';import'./chunk-ERDARDGB.js';import'./chunk-6I7D2JBA.js';import'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import'./chunk-L5T56MRH.js';import'./chunk-A4DPLZZF.js';import'./chunk-3SY46ERM.js';import'./chunk-5JUG4BEF.js';import'./chunk-S7Z6KKIN.js';import'./chunk-U45E5X3H.js';import'./chunk-N33S7BSG.js';import'./chunk-X3SHNHHM.js';//# sourceMappingURL=record-links-HO4SEHOA.js.map
|
|
2
|
-
//# sourceMappingURL=record-links-HO4SEHOA.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import'./index.css';import {b as b$4,a as a$3}from'./chunk-MLHXPTBT.js';import {b as b$1}from'./chunk-DHE6PO3V.js';import {a as a$2}from'./chunk-QSTWBKPN.js';import'./chunk-7ODGH7G2.js';import {f,g,d as d$1}from'./chunk-U6VZY3V2.js';import {b}from'./chunk-DSLPTDZX.js';import'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import {f as f$1}from'./chunk-6I7D2JBA.js';import {g as g$1}from'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import {la,fa,ga,ha,oa,M}from'./chunk-L5T56MRH.js';import {t}from'./chunk-A4DPLZZF.js';import {c,e,b as b$2,a}from'./chunk-3SY46ERM.js';import {m,l,b as b$5}from'./chunk-5JUG4BEF.js';import {a as a$1,d,c as c$3,e as e$2,g as g$2}from'./chunk-S7Z6KKIN.js';import'./chunk-U45E5X3H.js';import {b as b$3,c as c$2,e as e$1}from'./chunk-N33S7BSG.js';import {c as c$1}from'./chunk-X3SHNHHM.js';import {useState,useId,useRef,useMemo,useEffect}from'react';import {Plus,LoaderCircle,Info,PenLine,Eye,Trash2,GraduationCapIcon,ArrowLeft}from'lucide-react';import Lt from'react-markdown';import {useNavigate,Link,useParams}from'react-router-dom';import pe from'swr';import Et from'swr/infinite';import {history,defaultKeymap,historyKeymap,indentWithTab}from'@codemirror/commands';import {markdown}from'@codemirror/lang-markdown';import {languages}from'@codemirror/language-data';import {foldGutter,indentOnInput,bracketMatching,foldKeymap}from'@codemirror/language';import {highlightSelectionMatches,searchKeymap}from'@codemirror/search';import {Compartment,EditorState,Prec}from'@codemirror/state';import {EditorView,lineNumbers,highlightActiveLineGutter,highlightSpecialChars,drawSelection,dropCursor,highlightActiveLine,keymap,placeholder}from'@codemirror/view';import {jsx,jsxs,Fragment}from'react/jsx-runtime';function ce(){let t=document.documentElement;return t.getAttribute("data-theme")==="dark"||t.classList.contains("dark")||t.style.colorScheme==="dark"}var pt=EditorView.theme({"&":{fontSize:"13px",height:"100%",maxHeight:"100%",maxWidth:"100%",minHeight:"0",minWidth:"0",width:"100%"},"&.cm-focused":{outline:"none"},".cm-scroller":{height:"100%",lineHeight:"1.6",minHeight:"0",minWidth:"0",overflow:"auto",width:"100%"},".cm-content":{fontSize:"13px",fontStyle:"normal",fontWeight:"400",minWidth:"0 !important",padding:"12px 0"},".cm-line, .cm-line span":{fontSize:"inherit",fontStyle:"inherit",fontWeight:"inherit",lineHeight:"inherit"},".cm-gutters":{borderRight:"1px solid transparent"},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none"}});function de(t){return [t?a$3:b$4,pt]}function je(t){return [EditorState.readOnly.of(t),EditorView.editable.of(!t)]}function Be(t){let i={"aria-multiline":"true",role:"textbox"};return t.ariaLabel&&(i["aria-label"]=t.ariaLabel),t.ariaLabelledBy&&(i["aria-labelledby"]=t.ariaLabelledBy),t.ariaDescribedBy&&(i["aria-describedby"]=t.ariaDescribedBy),t.ariaInvalid&&(i["aria-invalid"]="true"),t.readOnly&&(i["aria-readonly"]="true"),i}function Re({ariaDescribedBy:t,ariaInvalid:i,ariaLabel:f,ariaLabelledBy:a,className:l,onBlur:c,onChange:d,onSave:m,placeholder:k,readOnly:o=false,value:u}){let p=useRef(null),h=useRef(null),T=useRef(new Compartment),M=useRef(new Compartment),y=useRef(new Compartment),N=useRef(c),w=useRef(d),E=useRef(m),v=useRef(u);return N.current=c,w.current=d,E.current=m,v.current=u,useEffect(()=>{let s=p.current;if(!s)return;let g=new EditorView({parent:s,state:EditorState.create({doc:v.current,extensions:[lineNumbers(),highlightActiveLineGutter(),highlightSpecialChars(),history(),foldGutter(),drawSelection(),dropCursor(),EditorState.allowMultipleSelections.of(true),indentOnInput(),bracketMatching(),highlightActiveLine(),highlightSelectionMatches(),EditorView.lineWrapping,markdown({codeLanguages:languages}),keymap.of([...defaultKeymap,...historyKeymap,...searchKeymap,...foldKeymap,indentWithTab]),Prec.highest(keymap.of([{key:"Mod-s",run:()=>(E.current?.(),true)}])),EditorView.updateListener.of(F=>{F.docChanged&&w.current?.(F.state.doc.toString()),F.focusChanged&&!F.view.hasFocus&&N.current?.();}),T.current.of(de(ce())),M.current.of(je(o)),y.current.of(EditorView.contentAttributes.of(Be({ariaDescribedBy:t,ariaInvalid:i,ariaLabel:f,ariaLabelledBy:a,readOnly:o}))),...k?[placeholder(k)]:[]]})});h.current=g;let q=new ResizeObserver(()=>{g.requestMeasure();});q.observe(s);let $=new MutationObserver(()=>{g.dispatch({effects:T.current.reconfigure(de(ce()))});});return $.observe(document.documentElement,{attributeFilter:["class","data-theme","style"],attributes:true}),()=>{q.disconnect(),$.disconnect(),g.destroy(),h.current=null;}},[]),useEffect(()=>{let s=h.current;s&&s.dispatch({effects:T.current.reconfigure(de(ce()))});},[b$4,a$3]),useEffect(()=>{let s=h.current;if(!s)return;let g=s.state.doc.toString();g!==u&&s.dispatch({changes:{from:0,to:g.length,insert:u}});},[u]),useEffect(()=>{let s=h.current;s&&s.dispatch({effects:[M.current.reconfigure(je(o)),y.current.reconfigure(EditorView.contentAttributes.of(Be({ariaDescribedBy:t,ariaInvalid:i,ariaLabel:f,ariaLabelledBy:a,readOnly:o})))]});},[t,i,f,a,o]),jsx("div",{className:l??"fk:h-full fk:min-h-0 fk:min-w-0 fk:w-full fk:overflow-hidden",ref:p})}var Xe=25,It=[{descriptionWidth:"fk:w-44",id:"skill-a",nameWidth:"fk:w-28"},{descriptionWidth:"fk:w-52",id:"skill-b",nameWidth:"fk:w-20"},{descriptionWidth:"fk:w-40",id:"skill-c",nameWidth:"fk:w-36"},{descriptionWidth:"fk:w-48",id:"skill-d",nameWidth:"fk:w-24"},{descriptionWidth:"fk:w-36",id:"skill-e",nameWidth:"fk:w-32"},{descriptionWidth:"fk:w-56",id:"skill-f",nameWidth:"fk:w-16"}];function Mt(){return jsxs("div",{"aria-busy":"true",className:"fk:grid fk:grid-cols-1 fk:gap-x-16 fk:gap-y-1 fk:lg:grid-cols-2",children:[jsx("span",{className:"fk:sr-only",children:"Loading skills"}),It.map(t$1=>jsxs("div",{className:"fk:-mx-3 fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:px-3 fk:py-2",children:[jsx(t,{className:"fk:size-10 fk:shrink-0 fk:rounded-lg"}),jsxs("span",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-1.5",children:[jsx(t,{className:`fk:h-4 ${t$1.nameWidth}`}),jsx(t,{className:`fk:h-4 ${t$1.descriptionWidth}`})]})]},t$1.id))]})}var Pt={code({children:t,className:i,node:f,...a}){return typeof i=="string"&&i.split(" ").some(c=>c.startsWith("language-"))?jsx("code",{className:i,...a,children:t}):jsx("code",{className:"fk:rounded fk:bg-muted fk:px-1.5 fk:py-0.5 fk:font-mono fk:text-[0.875em] fk:font-medium fk:before:content-none fk:after:content-none fk:corner-squircle",...a,children:t})}};function ge(){let{currentProjectId:t}=f$1();return {api:useMemo(()=>t?d$1(t):null,[t]),projectId:t}}function Y({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 At({onVisible:t}){let i=useRef(null),f=useRef(t);return f.current=t,useEffect(()=>{let a=i.current;if(!a)return;let l=new IntersectionObserver(c=>{c.some(d=>d.isIntersecting)&&f.current();});return l.observe(a),()=>{l.disconnect();}},[]),jsx("div",{"aria-hidden":true,className:"fk:h-px",ref:i})}function Ft(t,i){return t.visibility==="space"?(t.spaceId?i.get(t.spaceId):void 0)??"Space":t.visibility==="personal"?"Personal":"Project"}function Wt({skill:t}){return t.logoUrl?jsx(a$2,{className:"fk:size-10 fk:rounded-lg",src:t.logoUrl}):jsx("span",{className:"fk:flex fk:size-10 fk:shrink-0 fk:items-center fk:justify-center fk:rounded-lg fk:bg-muted fk:text-muted-foreground fk:corner-squircle",children:jsx(GraduationCapIcon,{className:"fk:size-5"})})}function fi(){let{api:t,projectId:i}=ge(),f$1=useNavigate(),[a,l]=useState(""),c$2=b(),d=a.trim().length>0,m=(s,g$1)=>!i||g$1&&!g$1.hasMore?null:g(i).skills({limit:Xe,offset:s*Xe,search:a.trim()||void 0}),{data:k,isLoading:o,setSize:u,size:p}=Et(m,f),h=k?.flatMap(s=>s.skills)??[],M=k?.[k.length-1]?.hasMore??false,y=k!==void 0&&p>k.length,N=o&&h.length===0;if(!i||!t)return jsx(Y,{children:"Select a project to view skills."});function w(){u(s=>s+1);}let E="No skills yet.";d&&(E="No skills match your search.");let v=jsx("div",{className:"fk:grid fk:grid-cols-1 fk:gap-x-16 fk:gap-y-1 fk:lg:grid-cols-2",children:h.map(s=>jsxs("button",{type:"button",onClick:()=>f$1(s.id),className:"fk:-mx-3 fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:rounded-lg fk:px-3 fk:py-2 fk:text-left fk:transition-colors fk:hover:bg-accent fk:focus-visible:bg-accent fk:focus-visible:outline-none fk:corner-squircle",children:[jsx(Wt,{skill:s}),jsxs("span",{className:"fk:min-w-0 fk:flex-1",children:[jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:font-medium",children:s.name}),jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:text-muted-foreground",children:s.description})]})]},s.id))});return N?v=jsx(Mt,{}):h.length===0&&(v=jsx(c,{children:jsx(e,{children:E})})),jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsx(b$1,{}),jsx("div",{className:"fk:min-h-0 fk:flex-1 fk:overflow-auto",children:jsxs("div",{className:"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6",children:[jsxs("div",{children:[jsx("h2",{className:"fk:text-2xl fk:font-semibold",children:"Skills for your agents"}),jsx("p",{className:"fk:mt-2 fk:text-muted-foreground",children:"Reusable Markdown instructions that agents load when relevant, or always when attached to an automation."})]}),jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:[jsx(b$2,{"aria-label":"Search skills",className:"fk:w-full fk:max-w-xs",placeholder:"Search skills\u2026",value:a,onChange:s=>{u(1),l(s.target.value);}}),c$2?jsx(c$1,{asChild:true,className:"fk:ml-auto",size:"sm",children:jsxs(Link,{to:"new",children:[jsx(Plus,{}),"New Skill"]})}):jsx(la,{disabled:true,children:jsxs(c$1,{className:"fk:ml-auto",disabled:true,size:"sm",children:[jsx(Plus,{}),"New Skill"]})})]}),v,M&&!y?jsx(At,{onVisible:w}):null,y?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 skills..."})]}):null]})})]})}function Q({className:t,id:i,message:f}){return jsx("p",{className:`fk:text-sm fk:text-destructive ${t??""}`,id:i,children:f})}function z({children:t,hint:i,htmlFor:f,id:a$1}){return jsxs("div",{className:"fk:mb-1.5 fk:pl-2.5 fk:flex fk:items-center fk:gap-1",children:[jsx(a,{htmlFor:f,id:a$1,children:t}),jsxs(b$3,{children:[jsx(c$2,{asChild:true,children:jsx("button",{"aria-label":`About ${t.toLowerCase()}`,className:"fk:rounded-sm fk:text-muted-foreground hover:fk:text-foreground fk:corner-squircle",type:"button",children:jsx(Info,{className:"fk:size-3.5"})})}),jsx(e$1,{className:"fk:max-w-xs",children:i})]})]})}function he({actions:t,title:i}){return jsxs(Fragment,{children:[jsxs("div",{className:"fk:flex fk:shrink-0 fk:items-center fk:gap-2 fk:pr-4",children:[jsxs(b$3,{children:[jsx(c$2,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(l,{orientation:"vertical",className:"fk:h-4"}),jsx("h1",{className:"fk:min-w-0 fk:flex-1 fk:truncate fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:i}),t]}),jsx(c$1,{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"}),"Skills"]})})]})}function jt(){return jsxs("div",{"aria-busy":"true",className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:gap-3 fk:overflow-hidden fk:pb-3",children:[jsx("span",{className:"fk:sr-only",children:"Loading skill"}),jsx(he,{actions:jsx(t,{className:"fk:h-8 fk:w-24"}),title:jsx(t,{className:"fk:h-5 fk:w-40"})}),jsxs("div",{className:"fk:m-auto fk:flex fk:min-h-0 fk:w-full fk:max-w-6xl fk:flex-1 fk:flex-col fk:gap-8 fk:px-6",children:[jsxs("div",{className:"fk:grid fk:shrink-0 fk:gap-3 fk:lg:grid-cols-[minmax(0,1fr)_minmax(0,1.6fr)_auto]",children:[["name","description"].map(t$1=>jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(t,{className:"fk:h-4 fk:w-20"}),jsx(t,{className:"fk:h-9 fk:w-full"})]},t$1)),jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(t,{className:"fk:h-4 fk:w-20"}),jsx(t,{className:"fk:h-9 fk:w-32"})]})]}),jsxs("div",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col fk:gap-1.5",children:[jsx(t,{className:"fk:h-4 fk:w-16"}),jsx(t,{className:"fk:min-h-48 fk:flex-1 fk:rounded-md"})]})]})]})}function Ve({content:t,onBlur:i,onChange:f,onSave:a$1,readOnly:l=false,showContentError:c,validationMessage:d}){let[m$1,k]=useState("write"),o=useId(),u=t.length>5e4,p;return t.trim()?p=jsx(Lt,{components:Pt,children:t}):p=jsx("p",{className:"fk:text-muted-foreground",children:"Nothing to preview."}),jsxs("div",{className:"fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-1.5",children:[jsxs("div",{className:"fk:pl-3.25 fk:flex fk:shrink-0 fk:items-center fk:gap-1",children:[jsx(a,{htmlFor:o,id:`${o}-label`,children:"Content"}),jsxs(b$3,{children:[jsx(c$2,{asChild:true,children:jsx("button",{"aria-label":"About skill content",className:"fk:rounded-sm fk:text-muted-foreground hover:fk:text-foreground fk:corner-squircle",type:"button",children:jsx(Info,{className:"fk:size-3.5"})})}),jsx(e$1,{className:"fk:max-w-sm",children:"The skill itself, in Markdown. Write it like instructions for a capable colleague: procedures, rules, examples, and edge cases. Attached skills are always loaded; other visible skills are loaded on demand."})]})]}),jsxs("div",{className:`fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col fk:ml-0.75 fk:overflow-hidden fk:rounded-md fk:border ${c?"fk:border-destructive":""} fk:corner-squircle`,children:[jsxs("div",{className:"fk:flex fk:shrink-0 fk:items-center fk:justify-between fk:gap-2 fk:border-b fk:px-2.5 fk:py-1",children:[jsx(fa,{value:m$1,onValueChange:h=>{k(h==="preview"?"preview":"write");},children:jsxs(ga,{children:[jsxs(b$3,{children:[jsx(c$2,{asChild:true,children:jsx("span",{className:"fk:inline-flex",children:jsx(ha,{"aria-label":"Write",className:"fk:px-2.5",value:"write",children:jsx(PenLine,{className:"fk:size-3.5"})})})}),jsx(e$1,{children:"Write"})]}),jsxs(b$3,{children:[jsx(c$2,{asChild:true,children:jsx("span",{className:"fk:inline-flex",children:jsx(ha,{"aria-label":"Preview",className:"fk:px-2.5",value:"preview",children:jsx(Eye,{className:"fk:size-3.5"})})})}),jsx(e$1,{children:"Preview"})]})]})}),jsxs("span",{className:u?"fk:text-xs fk:text-destructive":"fk:text-xs fk:text-muted-foreground",children:[t.length.toLocaleString()," / ",5e4.toLocaleString()]})]}),jsx("div",{className:"fk:min-h-0 fk:min-w-0 fk:flex-1 fk:overflow-hidden",hidden:m$1!=="write",children:jsx(Re,{ariaDescribedBy:c?`${o}-error`:void 0,ariaInvalid:c,ariaLabelledBy:`${o}-label`,className:"fk:h-full fk:min-h-0 fk:min-w-0 fk:w-full fk:overflow-hidden",readOnly:l,value:t,onBlur:i,onChange:f,onSave:a$1})}),m$1==="preview"?jsx(m,{className:"fk:min-h-0 fk:flex-1",children:jsx("div",{className:"fk:prose fk:prose-sm fk:dark:prose-invert fk:max-w-none fk:px-4 fk:py-3",children:p})}):null,c&&d?jsx(Q,{className:"fk:border-t fk:px-3 fk:py-2",id:`${o}-error`,message:d}):null]})]})}function He({api:t,mode:i,onSaved:f$1,projectId:a,skill:l}){let[c,d$1]=useState(l?.name??""),[m,k]=useState(l?.description??""),[o,u]=useState(l?.content??""),[p,h]=useState(l?.visibility??"project"),[T,M]=useState(l?.spaceId??null),[y,N]=useState(false),w=useRef(false),[E,v]=useState(""),[s,g$3]=useState({content:false,description:false,name:false}),q=useNavigate(),{data:$}=pe(g(a).spaces,f),[,F]=g$1(),X=b(),Oe=F.user?.spaces??[],ve=($?.spaces??[]).filter(r=>Oe.includes(r.code)),te="";o.trim()?o.length>5e4&&(te=`Content must be at most ${String(5e4)} characters`):te="Content is required";let b$1={content:te,description:m.trim()?"":"Description is required",name:c.trim()?"":"Name is required",space:p==="space"&&!T?"Select a space":""},ie=!b$1.content&&!b$1.description&&!b$1.name&&!b$1.space,K=s.name&&!!b$1.name,G=s.description&&!!b$1.description,_e=s.content&&!!b$1.content,qe=i==="create"?"New Skill":l?.name??"Skill",ne="Update skill";y?ne="Saving...":i==="create"&&(ne="Create skill");async function be(){if(!X||w.current)return;if(!ie){g$3({content:true,description:true,name:true});return}w.current=true,N(true),v("");let r={content:o,description:m,name:c,spaceId:p==="space"?T:null,visibility:p};try{let I=i==="create"||!l?await t.createSkill(r):await t.updateSkill(l.id,r);if(!I.success){v(Array.isArray(I.errorMessage)?I.errorMessage.join(", "):I.errorMessage);return}oa.success(i==="create"||!l?"Skill created.":"Skill saved."),f$1(I.skill);}catch(I){v(I instanceof Error?I.message:"Failed to save skill.");}finally{w.current=false,N(false);}}async function $e(r){r.preventDefault(),await be();}async function Ke(){if(!(!l||!X||w.current)){w.current=true,N(true),v("");try{let r=await t.deleteSkill(l.id);if(!r.success){v(Array.isArray(r.errorMessage)?r.errorMessage.join(", "):r.errorMessage);return}q("..",{relative:"path"});}catch(r){v(r instanceof Error?r.message:"Failed to delete skill.");}finally{w.current=false,N(false);}}}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:gap-3 fk:pb-3",children:[jsx(he,{actions:jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[ie?null:jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Complete the required fields to save"}),i==="edit"&&l?jsxs(c$1,{disabled:y||!X,size:"sm",type:"button",variant:"outline",onClick:()=>{Ke();},children:[jsx(Trash2,{}),"Delete"]}):null,jsx(la,{disabled:!X,children:jsx(c$1,{disabled:y||!ie||!X,form:"skill-editor-form",size:"sm",type:"submit",children:ne})})]}),title:qe}),E?jsx("div",{className:"fk:shrink-0 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:E}):null,jsxs("form",{className:"fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-6 fk:w-full fk:max-w-6xl fk:m-auto fk:gap-8 fk:px-4",id:"skill-editor-form",onSubmit:r=>{$e(r);},children:[jsxs("div",{className:"fk:grid fk:min-w-0 fk:shrink-0 fk:gap-3 fk:px-0.75 fk:lg:grid-cols-[minmax(0,1fr)_minmax(0,1.6fr)_auto]",children:[jsxs("div",{children:[jsx(z,{hint:"Identifying label for this skill",htmlFor:"skill-name",children:"Name"}),jsx(b$2,{"aria-describedby":K?"skill-name-error":void 0,"aria-invalid":K,className:K?"fk:border-destructive focus-visible:fk:ring-destructive":"",id:"skill-name",value:c,onBlur:()=>g$3(r=>({...r,name:true})),onChange:r=>d$1(r.target.value)}),K?jsx(Q,{id:"skill-name-error",message:b$1.name}):null]}),jsxs("div",{children:[jsx(z,{hint:"One or two sentences describing when to use this skill. Agents rely on it to decide whether the skill applies to their current task.",htmlFor:"skill-description",children:"Description"}),jsx(b$2,{"aria-describedby":G?"skill-description-error":void 0,"aria-invalid":G,className:G?"fk:border-destructive focus-visible:fk:ring-destructive":"",id:"skill-description",placeholder:"e.g. Rules for writing product descriptions in our brand voice",value:m,onBlur:()=>g$3(r=>({...r,description:true})),onChange:r=>k(r.target.value)}),G?jsx(Q,{id:"skill-description-error",message:b$1.description}):null]}),jsxs("div",{children:[jsx(z,{hint:"Who can see and use this skill. Space skills are only visible to members of the selected space and only usable by automations in that space; personal skills are private to you.",htmlFor:"skill-visibility",children:"Visibility"}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsxs(a$1,{value:p,onValueChange:r=>{h(r==="space"||r==="personal"?r:"project"),r!=="space"&&M(null);},children:[jsx(d,{"aria-label":"Visibility",className:"fk:w-fit fk:min-w-26",id:"skill-visibility",children:jsx(c$3,{})}),jsxs(e$2,{align:"start",children:[jsx(g$2,{value:"project",children:"Project"}),jsx(g$2,{disabled:ve.length===0,value:"space",children:"Space"}),jsx(g$2,{value:"personal",children:"Personal"})]})]}),p==="space"?jsxs(a$1,{value:T??"",onValueChange:r=>{M(r||null);},children:[jsx(d,{"aria-label":"Space",className:"fk:w-fit fk:min-w-34",children:jsx(c$3,{placeholder:"Select a space"})}),jsx(e$2,{align:"start",children:ve.map(r=>jsx(g$2,{value:r.id,children:r.label},r.id))})]}):null]}),p==="space"&&b$1.space?jsx(Q,{message:b$1.space}):null]})]}),jsx(Ve,{content:o,showContentError:_e,validationMessage:b$1.content,onBlur:()=>g$3(r=>({...r,content:true})),onChange:u,onSave:()=>{be();}})]})]})}function Bt({projectId:t,skill:i,spaceLabelById:f}){let a=b(),l=useNavigate(),[c,d$1]=useState(false),[m,k]=useState("");async function o(){d$1(true),k("");let u;try{u=await fetch(`/api/flexkit/${t}/skills/${i.id}/fork`,{method:"POST",credentials:"include"});}catch{k("Unable to create a copy. Try again."),d$1(false);return}if(d$1(false),!u.ok){k("Unable to create a copy. Check your permissions.");return}l("..",{relative:"path"});}return jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:gap-3 fk:pb-3",children:[jsx(he,{actions:jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(b$5,{variant:"secondary",children:i.source==="plugin"?"Plugin":"Code"}),i.source==="plugin"&&jsx(c$1,{type:"button",disabled:c||!a,onClick:()=>{o();},size:"sm",children:"Edit a copy"})]}),title:i.name}),jsxs("div",{className:"fk:flex fk:flex-col fk:h-full fk:px-4 fk:gap-3 fk:max-w-6xl fk:m-auto",children:[jsxs("div",{className:"fk:shrink-0 fk:rounded-md fk:border fk:bg-muted/30 fk:px-3 fk:py-2 fk:corner-squircle",children:[jsx("p",{className:"fk:text-sm fk:font-medium",children:"Version-controlled skill"}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:i.source==="plugin"?"This skill is managed by its plugin. Edit a copy to create a personal Studio skill.":"Edit this skill in your repository and re-sync it from the Custom Tools settings."})]}),jsxs("div",{className:"fk:grid fk:min-w-0 fk:shrink-0 fk:gap-3 fk:lg:grid-cols-[minmax(0,1fr)_minmax(0,1.6fr)_auto]",children:[jsxs("div",{children:[jsx(z,{hint:"Identifying label for this skill",htmlFor:"skill-name",children:"Name"}),jsx(b$2,{className:"fk:opacity-100!",disabled:true,id:"skill-name",value:i.name})]}),jsxs("div",{children:[jsx(z,{hint:"One or two sentences describing when to use this skill. Agents rely on it to decide whether the skill applies to their current task.",htmlFor:"skill-description",children:"Description"}),jsx(b$2,{className:"fk:opacity-100!",disabled:true,id:"skill-description",placeholder:"e.g. Rules for writing product descriptions in our brand voice",value:i.description})]}),jsxs("div",{children:[jsx(z,{hint:"Who can see and use this skill. Space skills are only visible to members of the selected space and only usable by automations in that space; personal skills are private to you.",htmlFor:"skill-visibility",children:"Visibility"}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsxs(a$1,{disabled:true,value:i.visibility,children:[jsx(d,{"aria-label":"Visibility",className:"fk:w-fit fk:min-w-26 fk:opacity-100!",id:"skill-visibility",children:jsx(c$3,{})}),jsxs(e$2,{align:"start",children:[jsx(g$2,{value:"project",children:"Project"}),jsx(g$2,{disabled:!i.spaceId,value:"space",children:"Space"}),jsx(g$2,{value:"personal",children:"Personal"})]})]}),i.visibility==="space"?jsxs(a$1,{disabled:true,value:i.spaceId??"",children:[jsx(d,{"aria-label":"Space",className:"fk:w-fit fk:min-w-34 fk:opacity-100!",children:jsx(c$3,{placeholder:"Select a space"})}),jsx(e$2,{align:"start",children:jsx(g$2,{value:i.spaceId??"",children:Ft(i,f)})})]}):null]})]})]}),m&&jsx("p",{role:"alert",children:m}),jsx(Ve,{content:i.content,readOnly:true})]})]})}function ci(){let{api:t,projectId:i}=ge(),f=useNavigate();return !i||!t?jsx(Y,{children:"Select a project to create skills."}):jsx(He,{api:t,mode:"create",projectId:i,onSaved:()=>f("..",{relative:"path"})})}function di(){let{api:t,projectId:i}=ge(),{skillId:f$1}=useParams(),{data:a,error:l,isLoading:c,mutate:d}=pe(i&&f$1?g(i).skill(f$1):null,f),{data:m}=pe(i?g(i).spaces:null,f);if(!i||!t||!f$1)return jsx(Y,{children:"Select a skill."});if(l)return jsx(Y,{children:"Failed to load skill."});if(c||!a?.skill)return jsx(jt,{});let k=new Map((m?.spaces??[]).map(o=>[o.id,o.label]));return a.skill.source!=="studio"?jsx(Bt,{projectId:i,skill:a.skill,spaceLabelById:k}):jsx(He,{api:t,mode:"edit",projectId:i,skill:a.skill,onSaved:o=>{o?d({skill:o},{revalidate:false}):d();}})}export{ci as CreateSkillPage,Ve as SkillContentPane,di as SkillDetailPage,He as SkillForm,fi as SkillsPage};//# sourceMappingURL=skills-pages-SAOZTUOH.js.map
|
|
2
|
-
//# sourceMappingURL=skills-pages-SAOZTUOH.js.map
|
package/dist/source-2S24MZ5D.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import'./index.css';import {c as c$4}from'./chunk-UB22GYFK.js';import {e,c as c$1,b as b$1,j as j$1,o,m,k as k$1,h,f as f$1}from'./chunk-RLVHUIFC.js';import'./chunk-4ZWQ44NZ.js';import {c}from'./chunk-CAZ6EUR2.js';import'./chunk-CFYO546Y.js';import {b}from'./chunk-DSLPTDZX.js';import'./chunk-YKM3FUGK.js';import'./chunk-XMOSCJOI.js';import {j,k,i,f,m as m$1,a as a$1,n as n$1,l as l$1,b as b$4}from'./chunk-7KLXWCDS.js';import'./chunk-HKN6BX5U.js';import'./chunk-YDVO6XWD.js';import'./chunk-ERDARDGB.js';import'./chunk-6I7D2JBA.js';import {g}from'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import {la,oa,M,Y,n}from'./chunk-L5T56MRH.js';import {t}from'./chunk-A4DPLZZF.js';import {c as c$3,e as e$1,a,b as b$3}from'./chunk-3SY46ERM.js';import {l}from'./chunk-5JUG4BEF.js';import'./chunk-S7Z6KKIN.js';import'./chunk-U45E5X3H.js';import {b as b$2,c as c$5,e as e$2}from'./chunk-N33S7BSG.js';import {c as c$2}from'./chunk-X3SHNHHM.js';import {useState,useEffect}from'react';import {formatDistance}from'date-fns';import {ExternalLinkIcon,LoaderCircle,RefreshCwIcon,BookOpenIcon,ArrowLeft}from'lucide-react';import {useParams,useNavigate,Link}from'react-router-dom';import me from'swr';import Se from'swr/infinite';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Ne=2e3;function be({actions:f,title:i}){return jsxs(Fragment,{children:[jsxs("div",{className:"fk:flex fk:shrink-0 fk:items-center fk:gap-2 fk:pr-4",children:[jsxs(b$2,{children:[jsx(c$5,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$2,{children:"Toggle Sidebar"})]}),jsx(l,{orientation:"vertical",className:"fk:h-4"}),jsx("h1",{className:"fk:min-w-0 fk:flex-1 fk:truncate fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:i}),f]}),jsx(c$2,{asChild:true,className:"fk:w-fit fk:shrink-0",size:"sm",variant:"ghost",children:jsxs(Link,{relative:"path",to:"..",children:[jsx(ArrowLeft,{className:"fk:mr-2 fk:size-4"}),"All documents"]})})]})}function we(){return jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-6 fk:py-6 fk:pl-4 fk:pr-6",children:[jsx("span",{className:"fk:sr-only",children:"Loading document"}),jsx(t,{className:"fk:h-6 fk:w-64"}),jsx(t,{className:"fk:h-4 fk:w-96"}),jsx(t,{className:"fk:h-32 fk:w-full"})]})}function ce({children:f}){return jsx("h3",{className:"fk:text-sm fk:font-semibold fk:tracking-tight",children:f})}function ye({projectId:f,source:i}){let h=i.currentVersion?.status==="published"?i.currentVersion:null,n=h?.passageCount??0,u=h?.id??null,N=o=>{if(!u||o*b$4>=n)return null;let l=o*b$4;return `${c$1(f).passages(i.id,{from:l,to:Math.min(l+b$4-1,n-1)})}&version=${encodeURIComponent(u)}`},{data:b,error:S,isLoading:x,setSize:p,size:r}=Se(N,b$1,{revalidateFirstPage:false}),d=b?.flatMap(o=>o.passages)??[],v=d.length;return useEffect(()=>{p(1);},[p,u]),n===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Passages appear here once the document is indexed."}):S?jsx("p",{className:"fk:text-sm fk:text-destructive",children:"The passages could not be loaded."}):jsxs("div",{className:"fk:flex fk:flex-col fk:gap-3",children:[d.map(o=>{let l=l$1(o.locator);return jsxs("article",{className:"fk:rounded-lg fk:border fk:bg-background fk:px-4 fk:py-3 fk:corner-squircle",children:[jsxs("header",{className:"fk:mb-1.5 fk:flex fk:items-center fk:gap-2 fk:text-xs fk:text-muted-foreground",children:[jsxs("span",{className:"fk:font-medium",children:["#",String(o.order+1)]}),l?jsx("span",{className:"fk:truncate",children:l}):null]}),jsx("p",{className:"fk:whitespace-pre-wrap fk:text-sm fk:leading-relaxed",children:o.text})]},o.id)}),x?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:py-2 fk:text-sm fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),"Loading passages\u2026"]}):null,v<n&&!x?jsxs(c$2,{className:"fk:w-fit",size:"sm",variant:"outline",onClick:()=>{p(r+1);},children:["Show more (",String(v)," of ",String(n),")"]}):null]})}function Te({api:f,onSaved:i,projectId:h$1,source:n$2}){let u=b(),[,N]=g(),{data:b$2}=me(c$1(h$1).spaces,b$1),S=N.user?.spaces??[],x=b$2?.spaces??[],p=x.filter(a=>S.includes(a.code)),r=n$2.spaces.filter(a=>!S.includes(a)),[d,v]=useState(n$2.title),[o,l]=useState(false),s=d.trim()!==n$2.title&&d.trim().length>0;useEffect(()=>{v(n$2.title);},[n$2.title]);async function m(a){if(u){l(true);try{let g=await f.updateSource(n$2.id,a);i(g.source),f$1();}catch(g){oa.error(h(g,"The document could not be updated."));}finally{l(false);}}}let k=!u||o||r.length>0,w="This project has no spaces yet, so every member can read it.";return x.length>0&&(w="You are not a member of any space in this project."),jsxs("div",{className:"fk:flex fk:flex-col fk:gap-5",children:[r.length>0?jsx(c$3,{children:jsxs(e$1,{children:["This document is shared with spaces you are not a member of (",r.join(", "),"), so only an owner or a member of all of them can change it."]})}):null,jsxs("div",{className:"fk:flex fk:flex-col fk:gap-1.5",children:[jsx(a,{htmlFor:"knowledge-title",children:"Title"}),jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(b$3,{className:"fk:max-w-md",disabled:k,id:"knowledge-title",maxLength:a$1,value:d,onChange:a=>v(a.target.value),onKeyDown:a=>{a.key==="Enter"&&s&&(a.preventDefault(),m({title:d.trim()}));}}),s?jsx(c$2,{disabled:k,size:"sm",variant:"outline",onClick:()=>{m({title:d.trim()});},children:"Save"}):null]}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"The agent cites the document by this title."})]}),jsxs("label",{className:"fk:flex fk:w-fit fk:cursor-pointer fk:items-center fk:gap-3",children:[jsx(Y,{checked:n$2.agentVisible,disabled:k,onCheckedChange:a=>{m({agentVisible:a});}}),jsxs("span",{className:"fk:flex fk:flex-col",children:[jsx("span",{className:"fk:text-sm fk:font-medium",children:"Visible to the agent"}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Off keeps the document in the list for people but out of the agent's searches."})]})]}),jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("span",{className:"fk:text-sm fk:font-medium",children:"Spaces"}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:n$2.spaces.length===0?"Every project member can read this document. Pick spaces to limit it to their members.":"Only members of the selected spaces (and the agent working for them) can read this document."}),p.length===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:w}):jsx("div",{className:"fk:flex fk:flex-wrap fk:gap-x-6 fk:gap-y-2",children:p.map(a=>jsxs("label",{className:"fk:flex fk:cursor-pointer fk:items-center fk:gap-2 fk:text-sm",children:[jsx(n,{checked:n$2.spaces.includes(a.code),disabled:k,onCheckedChange:()=>{m({spaces:n$1(n$2.spaces,a.code)});}}),a.label]},a.id))})]})]})}function Xe(){let{api:f$1,projectId:i$1}=e(),{sourceId:h$1}=useParams(),n=useNavigate(),u=b(),N=c(),[b$2,S]=useState(false),[x,p]=useState(false),{data:r,error:d,isLoading:v,mutate:o$1}=me(i$1&&h$1?c$1(i$1).source(h$1):null,b$1,{refreshInterval:N&&b$2?Ne:0});if(useEffect(()=>{S(r?j(r.source,r.job):false);},[r]),!i$1||!f$1||!h$1)return jsx(j$1,{children:"Select a document."});if(d&&!r)return jsx(j$1,{children:"This document does not exist or is not shared with you."});if(v||!r)return jsx(we,{});let{job:l$1,source:s}=r,m$2=k(s,l$1),k$2=s.currentVersion,w=x;async function a(){p(true);try{let c=await f$1.reingestSource(s.id);oa.success("Re-indexing started."),await o$1({job:c.job,source:{...s,status:"processing"}},{revalidate:!0});}catch(c){oa.error(h(c,"The document could not be re-indexed."));}finally{p(false);}}let g=[{label:"Type",value:i(s)}];return s.originUrl&&g.push({label:"Address",value:jsxs("a",{className:"fk:inline-flex fk:items-center fk:gap-1 fk:underline fk:underline-offset-2",href:s.originUrl,rel:"noreferrer",target:"_blank",children:[jsx("span",{className:"fk:truncate",children:s.originUrl}),jsx(ExternalLinkIcon,{className:"fk:size-3.5 fk:shrink-0"})]})}),s.size!==null&&g.push({label:"Size",value:f(s.size)}),g.push({label:"Added",value:formatDistance(new Date(s.createdAt),new Date,{addSuffix:true})}),k$2?.publishedAt&&g.push({label:"Indexed",value:formatDistance(new Date(k$2.publishedAt),new Date,{addSuffix:true})}),jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:gap-3 fk:pb-3",children:[jsx(be,{actions:jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(la,{disabled:!u,children:jsxs(c$2,{disabled:!u||w||m$2.tone==="busy",size:"sm",variant:"outline",onClick:()=>{a();},children:[x?jsx(LoaderCircle,{className:"fk:animate-spin"}):jsx(RefreshCwIcon,{}),"Re-index"]})}),jsx(o,{isBusy:w,source:s,trigger:"page",onRemoved:()=>n("..",{relative:"path"})})]}),title:s.title}),jsx("div",{className:"fk:min-h-0 fk:flex-1 fk:overflow-auto",children:jsxs("div",{className:"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-2 fk:pl-4 fk:pr-6",children:[jsxs("section",{className:"fk:flex fk:items-start fk:gap-4",children:[jsx(m,{source:s}),jsxs("div",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsx(k$1,{label:m$2.label,tone:m$2.tone}),jsx("span",{className:"fk:text-sm fk:text-muted-foreground",children:m$2.detail})]}),l$1?.error?.hint&&(m$2.tone==="error"||l$1.state==="failed")?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:l$1.error.hint}):null,jsx("dl",{className:"fk:grid fk:grid-cols-[auto_1fr] fk:gap-x-4 fk:gap-y-1 fk:text-sm",children:g.map(c=>jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:text-muted-foreground",children:c.label}),jsx("dd",{className:"fk:min-w-0 fk:truncate",children:c.value})]},c.label))}),k$2&&k$2.warnings.length>0?jsx(c$3,{children:jsx(e$1,{children:jsx("ul",{className:"fk:list-disc fk:pl-4",children:k$2.warnings.map(c=>jsx("li",{children:m$1(c)},c))})})}):null]})]}),jsx(l,{}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-4",children:[jsx(ce,{children:"Settings"}),jsx(Te,{api:f$1,projectId:i$1,source:s,onSaved:c=>{o$1({job:l$1,source:c},{revalidate:false});}})]}),jsx(l,{}),jsx("section",{className:"fk:flex fk:flex-col fk:gap-4",children:jsx(c$4,{api:f$1,projectId:i$1,source:s})}),jsx(l,{}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-4",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(BookOpenIcon,{className:"fk:size-4 fk:text-muted-foreground"}),jsx(ce,{children:"Passages"})]}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"The document is split into passages the agent searches and cites. Each one keeps its page, slide or section so a citation points back to the right place."}),jsx(ye,{projectId:i$1,source:s})]})]})})]})}export{Xe as Source};//# sourceMappingURL=source-2S24MZ5D.js.map
|
|
2
|
-
//# sourceMappingURL=source-2S24MZ5D.js.map
|