@flexkit/studio 0.2.33 → 0.2.35
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-IR4RF46H.js +4 -0
- package/dist/chat-page-IR4RF46H.js.map +1 -0
- package/dist/{chunk-RLVHUIFC.js → chunk-7N3LTSVX.js} +2 -2
- package/dist/{chunk-RLVHUIFC.js.map → chunk-7N3LTSVX.js.map} +1 -1
- package/dist/chunk-BTH7HU5Y.js +2 -0
- package/dist/chunk-BTH7HU5Y.js.map +1 -0
- package/dist/chunk-DEG7QP5C.js +30 -0
- package/dist/chunk-DEG7QP5C.js.map +1 -0
- 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-HSGUVQXU.js → chunk-FJRDLP7V.js} +8 -8
- package/dist/{chunk-HSGUVQXU.js.map → chunk-FJRDLP7V.js.map} +1 -1
- package/dist/chunk-G5N6HEPW.js +2 -0
- package/dist/chunk-G5N6HEPW.js.map +1 -0
- package/dist/chunk-J6EGNRRT.js +7 -0
- package/dist/{chunk-VUZ7GHSO.js.map → chunk-J6EGNRRT.js.map} +1 -1
- package/dist/chunk-KEGJNZLW.js +378 -0
- package/dist/chunk-KEGJNZLW.js.map +1 -0
- package/dist/chunk-PMLDA2FF.js +2 -0
- package/dist/chunk-PMLDA2FF.js.map +1 -0
- package/dist/chunk-PWGLA33F.js +3 -0
- package/dist/chunk-PWGLA33F.js.map +1 -0
- package/dist/chunk-PZWEC6KD.js +2 -0
- package/dist/chunk-PZWEC6KD.js.map +1 -0
- package/dist/{chunk-UB22GYFK.js → chunk-Q4CWQHBJ.js} +2 -2
- package/dist/{chunk-UB22GYFK.js.map → chunk-Q4CWQHBJ.js.map} +1 -1
- package/dist/{chunk-U5XZWEPO.js → chunk-R6DPAMLC.js} +3 -3
- package/dist/{chunk-U5XZWEPO.js.map → chunk-R6DPAMLC.js.map} +1 -1
- package/dist/{chunk-DHE6PO3V.js → chunk-RAUQCO6W.js} +2 -2
- package/dist/{chunk-DHE6PO3V.js.map → chunk-RAUQCO6W.js.map} +1 -1
- package/dist/{chunk-RFUMT6ZR.js → chunk-RFKMFD2O.js} +2 -2
- package/dist/{chunk-RFUMT6ZR.js.map → chunk-RFKMFD2O.js.map} +1 -1
- package/dist/chunk-RULCANNM.js +7 -0
- package/dist/chunk-RULCANNM.js.map +1 -0
- package/dist/{chunk-6I7D2JBA.js → chunk-TI3EHLRE.js} +3 -3
- package/dist/{chunk-6I7D2JBA.js.map → chunk-TI3EHLRE.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-W7JDZHCV.js +2 -0
- package/dist/chunk-W7JDZHCV.js.map +1 -0
- 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-XYE6ZAUB.js +2 -0
- package/dist/{chunk-S7VNSSIK.js.map → chunk-XYE6ZAUB.js.map} +1 -1
- package/dist/chunk-ZMONKGWJ.js +4 -0
- package/dist/{chunk-2MVQXXY7.js.map → chunk-ZMONKGWJ.js.map} +1 -1
- package/dist/{chunk-YKM3FUGK.js → chunk-ZRTWLY77.js} +3 -3
- package/dist/{chunk-YKM3FUGK.js.map → chunk-ZRTWLY77.js.map} +1 -1
- package/dist/entry-NQRN7SWV.js +2 -0
- package/dist/{entry-ROTT3ZDN.js.map → entry-NQRN7SWV.js.map} +1 -1
- package/dist/index.css +43 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/list-7SCWJXUE.js +3 -0
- package/dist/{list-N4E3VXM5.js.map → list-7SCWJXUE.js.map} +1 -1
- package/dist/list-RPIG75US.js +2 -0
- package/dist/{list-RCTHBJOK.js.map → list-RPIG75US.js.map} +1 -1
- package/dist/pages-KXERA5Z6.js +5 -0
- package/dist/{pages-XUJGIHQI.js.map → pages-KXERA5Z6.js.map} +1 -1
- package/dist/plugin-pages-NXA4BT7Y.js +2 -0
- package/dist/{plugin-pages-FEQILAQR.js.map → plugin-pages-NXA4BT7Y.js.map} +1 -1
- package/dist/project-selector-SA6UUVBK.js +2 -0
- package/dist/project-selector-SA6UUVBK.js.map +1 -0
- package/dist/record-links-RTMCYEPM.js +2 -0
- package/dist/{record-links-HO4SEHOA.js.map → record-links-RTMCYEPM.js.map} +1 -1
- package/dist/{root-GQL3P63Z.js → root-6H6K3YQF.js} +3 -3
- package/dist/{root-GQL3P63Z.js.map → root-6H6K3YQF.js.map} +1 -1
- package/dist/root-IBZPU2D4.js +23 -0
- package/dist/{root-MLEJUEMJ.js.map → root-IBZPU2D4.js.map} +1 -1
- package/dist/{root-CCUROZVR.js → root-MBFQXX4E.js} +2 -2
- package/dist/{root-CCUROZVR.js.map → root-MBFQXX4E.js.map} +1 -1
- package/dist/root-TSZ3CSJU.js +14 -0
- package/dist/root-TSZ3CSJU.js.map +1 -0
- package/dist/{root-VA3E6HEY.js → root-TZIXWEZO.js} +2 -2
- package/dist/{root-VA3E6HEY.js.map → root-TZIXWEZO.js.map} +1 -1
- package/dist/{root-KXY4A6DW.js → root-W5ZPSNQ2.js} +2 -2
- package/dist/{root-KXY4A6DW.js.map → root-W5ZPSNQ2.js.map} +1 -1
- package/dist/{search-YY4GQQRM.js → search-ZLEYFT3T.js} +2 -2
- package/dist/{search-YY4GQQRM.js.map → search-ZLEYFT3T.js.map} +1 -1
- package/dist/skills-pages-RPMWIBLS.js +2 -0
- package/dist/{skills-pages-SAOZTUOH.js.map → skills-pages-RPMWIBLS.js.map} +1 -1
- package/dist/source-VYWE5EB5.js +2 -0
- package/dist/{source-2S24MZ5D.js.map → source-VYWE5EB5.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-2MVQXXY7.js +0 -4
- package/dist/chunk-3SY46ERM.js +0 -2
- package/dist/chunk-3SY46ERM.js.map +0 -1
- package/dist/chunk-4PUMSUJL.js +0 -30
- package/dist/chunk-4PUMSUJL.js.map +0 -1
- package/dist/chunk-C3OHXPJV.js +0 -2
- package/dist/chunk-C3OHXPJV.js.map +0 -1
- package/dist/chunk-CFYO546Y.js +0 -378
- package/dist/chunk-CFYO546Y.js.map +0 -1
- package/dist/chunk-ERDARDGB.js +0 -2
- package/dist/chunk-ERDARDGB.js.map +0 -1
- package/dist/chunk-L5T56MRH.js +0 -7
- package/dist/chunk-L5T56MRH.js.map +0 -1
- package/dist/chunk-NFEQBTIW.js +0 -2
- package/dist/chunk-NFEQBTIW.js.map +0 -1
- package/dist/chunk-S7VNSSIK.js +0 -2
- package/dist/chunk-VUZ7GHSO.js +0 -7
- package/dist/chunk-XMOSCJOI.js +0 -2
- package/dist/chunk-XMOSCJOI.js.map +0 -1
- package/dist/chunk-YDVO6XWD.js +0 -2
- package/dist/chunk-YDVO6XWD.js.map +0 -1
- package/dist/entry-ROTT3ZDN.js +0 -2
- package/dist/list-N4E3VXM5.js +0 -3
- package/dist/list-RCTHBJOK.js +0 -2
- 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/root-BUXIQKA5.js +0 -14
- package/dist/root-BUXIQKA5.js.map +0 -1
- package/dist/root-MLEJUEMJ.js +0 -23
- package/dist/skills-pages-SAOZTUOH.js +0 -2
- package/dist/source-2S24MZ5D.js +0 -2
package/dist/root-MLEJUEMJ.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import'./index.css';import {a as a$1}from'./chunk-CLCIE5RF.js';import {c as c$3,a as a$5}from'./chunk-S7VNSSIK.js';import {a as a$4}from'./chunk-S26WK6RF.js';import {a as a$3}from'./chunk-NFEQBTIW.js';import {m,a,b as b$1,d,f as f$1,e as e$4,c as c$5,h as h$3,j as j$4,i as i$1,k as k$1}from'./chunk-VUZ7GHSO.js';import {b as b$5}from'./chunk-CAZ6EUR2.js';import'./chunk-2DXR5NJV.js';import {s,j,e as e$1,h,g}from'./chunk-CFYO546Y.js';import {b as b$2}from'./chunk-DSLPTDZX.js';import {e,j as j$2}from'./chunk-YKM3FUGK.js';import {c}from'./chunk-XMOSCJOI.js';import'./chunk-YDVO6XWD.js';import'./chunk-ERDARDGB.js';import {f,b}from'./chunk-6I7D2JBA.js';import'./chunk-MBBE4RND.js';import'./chunk-5CVDMZUI.js';import {v,w,x,la,c as c$4,d as d$1,n}from'./chunk-L5T56MRH.js';import {e as e$3,g as g$1,h as h$1,j as j$1,o,t as t$1}from'./chunk-A4DPLZZF.js';import {b as b$4}from'./chunk-3SY46ERM.js';import {m as m$1,d as d$2,e as e$5,f as f$2,g as g$2,h as h$2,j as j$3,i}from'./chunk-5JUG4BEF.js';import {k,l,p,q,s as s$1,t,r}from'./chunk-S7Z6KKIN.js';import'./chunk-U45E5X3H.js';import {a as a$2,b as b$3,c as c$1,e as e$2}from'./chunk-N33S7BSG.js';import {c as c$2}from'./chunk-X3SHNHHM.js';import {useState,useMemo,useCallback,useRef,useEffect}from'react';import {TagIcon,PlusIcon,Loader2,Ellipsis,Check,Copy,Link,MinusIcon,Trash2,LoaderCircle,Search,X,ImagePlayIcon,ImageIcon,FilePlayIcon,LayersIcon,SplinePointerIcon,ListChecks,Trash2Icon,LayoutGrid,List}from'lucide-react';import {gql}from'@apollo/client';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {useLocation,Outlet,useParams}from'react-router-dom';import {useReactTable,getSortedRowModel,getPaginationRowModel,getFilteredRowModel,getCoreRowModel}from'@tanstack/react-table';import {defaultStyles,FileIcon}from'react-file-icon';var be={where:{},limit:500,offset:0,sort:[{name:"ASC"}]},Y={selection:"display",includeCount:false};function Pt(){let{scope:e}=c(),{currentProjectSchema:n}=f(),[t$1,s$2,r$1]=f$1(),[f$2,l$1]=useState(""),[u,D]=useState(false),[v,g$2]=useState(false),[I,i]=useState(null),[A,d]=useState(false),[_,x]=useState(null),[J,M]=useState(""),[P,O]=useState(false),[R,B]=useState(false),k$1=b$2(),w="_tag",c$3="_tags",{data:b,isLoading:T}=s({entityNamePlural:c$3,schema:n,scope:e,variables:be,...Y}),z=(Array.isArray(b)?b:[]).map(a=>{let U=a;return {_id:U._id,name:U.name}}),L=useCallback(async()=>{let a=f$2.trim();if(!a)return;O(true);let U=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now()}`,F=j(c$3,n,{name:{value:a,disabled:false,scope:"default"}},U),j$1=e$1(c$3,e,n,Y),K=gql`
|
|
2
|
-
${j$1.query}
|
|
3
|
-
`;await new Promise(h=>{s$2(gql`
|
|
4
|
-
${F}
|
|
5
|
-
`),r$1({refetchQueries:[K],onCompleted:()=>{l$1(""),D(false),h();}}),t$1(true);}),O(false);},[c$3,t$1,n,e,s$2,r$1,f$2]),q$1=useCallback(async a=>{B(true);let U=h(w,n,a),Z=e$1(c$3,e,n,Y),F=gql`
|
|
6
|
-
${Z.query}
|
|
7
|
-
`;await new Promise((j,K)=>{s$2(gql`
|
|
8
|
-
${U}
|
|
9
|
-
`),r$1({variables:{where:{_id:{eq:a}}},refetchQueries:[F],onCompleted:()=>{j();},onError:h=>{K(h);}}),t$1(true);}),B(false);},[w,c$3,t$1,n,e,s$2,r$1]),y=useCallback(async()=>{let a=J.trim();if(!a||!_)return;O(true);let U={name:{value:a,disabled:false,scope:"default"}},Z={},F=g(c$3,_._id,e,n,Z,U),j=e$1(c$3,e,n,Y),K=gql`
|
|
10
|
-
${j.query}
|
|
11
|
-
`;await new Promise(h=>{s$2(gql`
|
|
12
|
-
${F}
|
|
13
|
-
`),r$1({variables:{where:{_id:{eq:_._id}}},refetchQueries:[K],onCompleted:()=>{d(false),x(null),M(""),h();}}),t$1(true);}),O(false);},[J,c$3,t$1,n,e,s$2,r$1,_]);return jsxs("div",{className:"fk:flex fk:h-full fk:max-h-screen fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:flex fk:h-12 fk:items-center fk:border-b fk:border-b-border fk:px-4 fk:lg:px-6",children:[jsx(TagIcon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:px-4 fk:text-sm fk:font-semibold fk:tracking-tight",children:"Tags"}),k$1?jsx(a$2,{children:jsxs(b$3,{children:[jsx(c$1,{asChild:true,children:jsxs(k,{open:u,onOpenChange:D,children:[jsx(l,{asChild:true,children:jsxs(c$2,{variant:"secondary",size:"icon",className:"fk:ml-auto fk:h-8 fk:w-8",children:[jsx(PlusIcon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Add tag"})]})}),jsxs(p,{children:[jsxs(q,{children:[jsx(s$1,{children:"New tag"}),jsx(t,{className:"fk:sr-only",children:"Create a new tag"})]}),jsx("div",{className:"fk:flex fk:gap-2",children:jsx(b$4,{autoFocus:true,value:f$2,placeholder:"New tag name",onChange:a=>l$1(a.target.value),onKeyDown:a=>{a.key==="Enter"&&L();}})}),jsx(r,{children:jsxs(c$2,{disabled:P,onClick:L,variant:"default",children:[P?jsx(Loader2,{className:"fk:h-4 fk:w-4 fk:mr-2 fk:animate-spin"}):null,"Add"]})})]})]})}),jsx(e$2,{children:jsx("p",{children:"Add tag"})})]})}):jsx("div",{className:"fk:ml-auto",children:jsx(la,{disabled:true,children:jsxs(c$2,{disabled:true,variant:"secondary",size:"icon",className:"fk:h-8 fk:w-8",children:[jsx(PlusIcon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Add tag"})]})})})]}),jsx(m$1,{className:"fk:h-full",children:jsx("div",{className:"fk:flex fk:flex-col fk:gap-2 fk:px-4 fk:py-2",children:T?jsx("div",{className:"fk:text-sm fk:text-muted-foreground",children:"Loading..."}):z.length===0?jsx("div",{className:"fk:text-sm fk:text-muted-foreground",children:"No tags yet"}):z.map(a=>jsxs("div",{className:"fk:group fk:flex fk:items-center fk:justify-between fk:rounded-sm fk:border fk:border-border fk:bg-card fk:px-3 fk:py-1 fk:corner-squircle",children:[jsx("span",{className:"fk:text-sm",children:a.name}),jsxs(e$3,{children:[jsx(la,{disabled:!k$1,children:jsx(g$1,{asChild:true,children:jsx(c$2,{"aria-label":`Actions for ${a.name}`,disabled:!k$1,title:k$1?`Actions for ${a.name}`:void 0,variant:"ghost",size:"icon",className:"fk:h-7 fk:w-7 fk:text-muted-foreground fk:hover:text-foreground",children:jsx(Ellipsis,{className:"fk:h-4 fk:w-4"})})})}),jsxs(h$1,{align:"end",className:"w-[160px]",children:[jsx(j$1,{onClick:()=>{x(a),M(a.name),d(true);},children:"Edit"}),jsx(o,{}),jsx(j$1,{className:"fk:text-destructive",onClick:()=>{i(a),g$2(true);},children:"Remove"})]})]})]},a._id))})}),jsx(k,{open:A,onOpenChange:d,children:jsxs(p,{children:[jsxs(q,{children:[jsx(s$1,{children:"Edit tag"}),jsx(t,{className:"fk:sr-only",children:"Rename an existing tag"})]}),jsx("div",{className:"fk:flex fk:gap-2",children:jsx(b$4,{autoFocus:true,value:J,placeholder:"Tag name",onChange:a=>M(a.target.value),onKeyDown:a=>{a.key==="Enter"&&y();}})}),jsxs(r,{children:[jsx(c$2,{disabled:P,variant:"secondary",onClick:()=>{d(false),x(null);},children:"Cancel"}),jsxs(c$2,{disabled:P,onClick:y,variant:"default",children:[P?jsx(Loader2,{className:"fk:h-4 fk:w-4 fk:mr-2 fk:animate-spin"}):null,"Save"]})]})]})}),jsx(k,{open:v,onOpenChange:g$2,children:jsxs(p,{children:[jsxs(q,{children:[jsx(s$1,{children:"Delete tag"}),jsx(t,{className:"fk:sr-only",children:"Confirm deletion of a tag"})]}),jsxs("div",{className:"fk:text-sm fk:text-muted-foreground",children:["Are you sure you want to delete the tag"," ",jsx("span",{className:"fk:font-semibold fk:text-foreground",children:I?.name}),"?"]}),jsxs(r,{children:[jsx(c$2,{disabled:R,variant:"secondary",onClick:()=>{g$2(false),i(null);},children:"Cancel"}),jsxs(c$2,{disabled:R,variant:"destructive",onClick:()=>{I&&(async()=>(await q$1(I._id),g$2(false),i(null)))();},children:[R?jsx(Loader2,{className:"fk:h-4 fk:w-4 fk:mr-2 fk:animate-spin"}):null,"Delete"]})]})]})})]})}var Ft=`_updatedAt
|
|
14
|
-
tags(limit: 3, offset: 0) {
|
|
15
|
-
_id
|
|
16
|
-
name
|
|
17
|
-
}
|
|
18
|
-
`;function Le({assetIds:e,mode:n,onModeChange:t,onCompleted:s$1}){let{scope:r}=c(),f$3=a$5("_assets"),[l,u,D]=f$1(),{currentProjectSchema:v}=f(),[g$1,I]=useState([]),[i$1,A]=useState(false),{data:d}=s({entityNamePlural:"_tags",schema:v,scope:r,variables:be,...Y}),_=useMemo(()=>(Array.isArray(d)?d:[]).map(w=>({_id:w._id,name:w.name})),[d]),x=useCallback(()=>{I([]);},[]),J=useCallback(k=>{!k&&!i$1&&(t(null),x());},[i$1,t,x]),M=useCallback(k=>{let c=(k?.update_assets?._assets??[]).filter(b=>typeof b?._id=="string").map(b=>{let T=(Array.isArray(b.tags)?b.tags:[]).map(z=>z.name).filter(Boolean).slice(0,3).join(", ");return {_id:b._id,attributes:{tags:T,...typeof b._updatedAt=="string"?{_updatedAt:b._updatedAt}:{}}}});c.length>0&&f$3(c);},[f$3]),P=useCallback(async()=>{if(!(e.length===0||g$1.length===0||i$1)){A(true);try{let k={tags:{relationships:{connect:g$1.map(c=>({_id:c}))},disabled:!1,scope:r}},w=g("_assets",e[0]??"",r,v,{},k,{responseFields:Ft});await new Promise((c,b)=>{u(gql`
|
|
19
|
-
${w}
|
|
20
|
-
`),D({variables:{where:{_id:{in:e}}},onCompleted:T=>{M(T),c();},onError:T=>b(T)}),l(!0);}),s$1?.(),x(),t(null);}catch{}finally{A(false);}}},[M,e,i$1,s$1,t,x,l,v,r,g$1,u,D]),O=useCallback(async()=>{if(!(e.length===0||g$1.length===0||i$1)){A(true);try{let k={tags:{relationships:{disconnect:g$1},disabled:!1,scope:r}},w=g("_assets",e[0]??"",r,v,{},k,{responseFields:Ft});await new Promise((c,b)=>{u(gql`
|
|
21
|
-
${w}
|
|
22
|
-
`),D({variables:{where:{_id:{in:e}}},onCompleted:T=>{M(T),c();},onError:T=>b(T)}),l(!0);}),s$1?.(),x(),t(null);}catch{}finally{A(false);}}},[M,e,i$1,s$1,t,x,l,v,r,g$1,u,D]),R=n==="remove",B=R?"Remove tag(s)":"Add tag(s)";return e.length>1&&(B=R?"Remove tag(s) from selected assets":"Add tag(s) to selected assets"),jsxs(d$2,{open:n!==null,onOpenChange:J,children:[jsx(e$5,{placeholder:"Search tags..."}),jsxs(f$2,{className:"fk:h-75",children:[jsx(g$2,{children:"No tags found."}),jsx(h$2,{heading:"Tags",children:_.map(k=>{let w=g$1.includes(k._id);return jsxs(j$3,{disabled:i$1,onSelect:()=>{i$1||I(c=>w?c.filter(b=>b!==k._id):[...c,k._id]);},children:[jsx("input",{className:"fk:mr-2",checked:w,onChange:()=>{},type:"checkbox"}),k.name]},k._id)})})]}),jsx(i,{}),jsx("div",{className:"fk:p-2",children:jsxs(c$2,{className:"fk:w-full",disabled:g$1.length===0||i$1,onClick:R?O:P,children:[i$1?jsx(LoaderCircle,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin"}):null,B]})})]})}function Ve({overlay:e=false,row:n}){let[t,s]=useState(null),[r,f]=useState(null),l=j$2(),u=b$2(),D=n.original,v=D._id??"",g=D.url??"";function I(){l({type:"DeleteEntity",payload:{entityId:v,entityName:b.name}});}function i(d,_){navigator.clipboard.writeText(_),s(d),window.setTimeout(()=>s(null),1500);}return jsxs(Fragment,{children:[jsxs(e$3,{children:[jsx(g$1,{asChild:true,children:jsxs(c$2,{className:e?"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:text-white fk:group-hover:bg-background/10 fk:group-hover:text-white! fk:data-[state=open]:bg-background/15":"fk:flex fk:h-8 fk:w-8 fk:p-0 fk:data-[state=open]:bg-muted",onClick:d=>d.stopPropagation(),variant:"ghost",children:[jsx(Ellipsis,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Open menu"})]})}),jsxs(h$1,{align:"start",className:"fk:w-45",children:[jsxs(j$1,{disabled:!v,onClick:d=>{d.stopPropagation(),i("id",v);},children:[t==="id"?jsx(Check,{className:"fk:mr-2 fk:h-4 fk:w-4"}):jsx(Copy,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Copy ID"]}),jsxs(j$1,{disabled:!g,onClick:d=>{d.stopPropagation(),i("url",g);},children:[t==="url"?jsx(Check,{className:"fk:mr-2 fk:h-4 fk:w-4"}):jsx(Link,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Copy URL"]}),jsx(o,{}),jsxs(j$1,{disabled:!v||!u,onClick:d=>{d.stopPropagation(),f("add");},children:[jsx(TagIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Add tag"]}),jsxs(j$1,{disabled:!v||!u,onClick:d=>{d.stopPropagation(),f("remove");},children:[jsx(MinusIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Remove tag"]}),jsx(o,{}),jsxs(j$1,{className:"fk:text-destructive",disabled:!v||!u,onClick:d=>{d.stopPropagation(),I();},children:[jsx(Trash2,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Delete"]})]})]}),r!==null?jsx(Le,{assetIds:v?[v]:[],mode:r,onModeChange:f}):null]})}var ho=FileIcon,yo="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 vo(e){return e==null||Number.isNaN(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ut({columns:e$1,data:n,entityName:t,hasMore:s=false,isLoading:r=false,isLoadingMore:f=false,onLoadMore:l,onSortingChange:u,pageSize:D,sorting:v,toolbarComponent:g}){let I=useRef(null),{schemaErrorMessage:i}=e(),[A,d]=useState({}),[_,x]=useState({}),[J,M]=useState([]),[P,O]=useState([]),R=v??P;useEffect(()=>{I.current?.scrollTo({top:0});},[t]);function B(y){if(u){u(y);return}O(y);}let k=useReactTable({data:n,columns:e$1,state:{sorting:R,columnVisibility:_,rowSelection:A,columnFilters:J},initialState:{pagination:{pageSize:D??50}},enableRowSelection:true,onRowSelectionChange:d,onSortingChange:B,onColumnFiltersChange:M,onColumnVisibilityChange:x,getCoreRowModel:getCoreRowModel(),getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),getSortedRowModel:getSortedRowModel(),getRowId:y=>y._id,manualFiltering:true,manualPagination:true,manualSorting:true}),{rows:w}=k.getRowModel(),c=useRef(l),b=useRef(s),T=useRef(f);c.current=l,b.current=s,T.current=f;let z=useCallback(y=>{if(!c.current||!b.current||T.current)return;let a=y??I.current;a&&c$5(a)&&(T.current=true,c.current());},[]),L=b$5();useEffect(()=>{L&&z();},[z,w.length,s,f,L]);function q(y){z(y.currentTarget);}return i?jsx(Fragment,{}):jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:w-full fk:min-w-0 fk:flex-col fk:gap-4",children:[g?g(k):null,jsxs("div",{className:"fk:relative fk:min-h-0 fk:min-w-0 fk:flex-1",children:[f?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,jsxs("div",{className:"fk:h-full fk:overflow-auto fk:pt-px fk:pb-20 fk:-ml-0.5 fk:pr-3",onScroll:q,ref:I,children:[r?jsx("div",{className:"fk:grid fk:grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] fk:gap-3",children:Array.from({length:D??50},(y,a)=>jsxs("div",{className:"fk:rounded-md fk:border fk:border-border fk:p-2 fk:corner-squircle",children:[jsx(t$1,{className:"fk:aspect-square fk:w-full fk:rounded-sm fk:corner-squircle"}),jsx(t$1,{className:"fk:mt-2 fk:h-3 fk:w-[75%]"}),jsx(t$1,{className:"fk:mt-1.5 fk:h-3 fk:w-[50%]"})]},`skeleton-${a}`))}):null,!r&&w.length===0?jsx("div",{className:"fk:flex fk:h-24 fk:items-center fk:justify-center fk:text-sm fk:text-muted-foreground",children:"No results."}):null,!r&&w.length>0?jsx("div",{className:"fk:grid fk:grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] fk:pl-0.5 fk:gap-3",children:w.map(y=>jsx(wo,{row:y},y.id))}):null]})]})]})}function wo({row:e}){let n$1=e.original,t=h$3(n$1)||"Untitled",s=n$1.mimeType??"",r=vo(n$1.size),f=e.getIsSelected(),l=[s,r].filter(Boolean).join(" \xB7 ");return jsxs("div",{className:`fk:relative fk:rounded-md fk:border fk:p-2 fk:transition-colors ${f?"fk:border-primary fk:ring-1 fk:ring-primary/40 fk:bg-muted/40":"fk:border-border fk:bg-background fk:hover:border-muted-foreground/30"} fk:corner-squircle`,"data-state":f?"selected":void 0,children:[jsx("div",{className:"fk:absolute fk:left-3 fk:top-3 fk:z-10 fk:mix-blend-difference",children:jsx(n,{className:"fk:border-white!","aria-label":`Select ${t}`,checked:f,onCheckedChange:u=>{e.toggleSelected(!!u);},onClick:u=>u.stopPropagation()})}),jsx("div",{className:"fk:group fk:absolute fk:right-2 fk:top-2 fk:z-10 fk:mix-blend-difference",children:jsx(Ve,{overlay:true,row:e})}),jsx(bo,{asset:n$1,filename:t}),jsx("div",{className:"fk:mt-2 fk:truncate fk:text-xs fk:font-medium",title:t,children:t}),l?jsx("div",{className:"fk:mt-0.5 fk:truncate fk:text-[11px] fk:text-muted-foreground",title:l,children:l}):null]})}function bo({asset:e,filename:n}){let[t$1,s]=useState(false),[r,f]=useState(false),l=e.url??"";if(!l&&!e.path)return jsx("div",{className:"fk:flex fk:aspect-square fk:items-center fk:justify-center fk:rounded-sm fk:bg-muted fk:corner-squircle",children:jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"No preview"})});if(!j$4(e)||!l){let i=i$1(e),A=defaultStyles[i];return jsx("div",{className:"fk:flex fk:aspect-square fk:items-center fk:justify-center fk:rounded-sm fk:bg-muted fk:[&>svg]:h-12 fk:[&>svg]:w-auto fk:corner-squircle",children:jsx(ho,{extension:i,...A||{}})})}let D=k$1(l,{width:320,height:320}),v=l;function g(i){i.stopPropagation(),f(false),s(true);}function I(i){s(i),i||f(false);}return jsxs(Fragment,{children:[jsx("button",{className:`fk:aspect-square fk:w-full fk:cursor-zoom-in fk:overflow-hidden fk:rounded-sm fk:border-0 fk:p-0 ${yo} fk:corner-squircle`,onClick:g,type:"button",children:jsx("img",{alt:n,className:"fk:h-full fk:w-full fk:object-contain",src:D})}),jsx(k,{open:t$1,onOpenChange:I,children:jsxs(p,{className:"fk:sm:max-w-4xl fk:p-3",children:[jsxs(q,{children:[jsx(s$1,{className:"fk:sr-only",children:"Asset preview"}),jsx(t,{className:"fk:sr-only",children:"Enlarged asset preview"})]}),jsxs("div",{className:"fk:relative fk:flex fk:h-[min(85vh,56rem)] fk:w-full fk:items-center fk:justify-center fk:overflow-hidden fk:rounded-md fk:corner-squircle",children:[r?null:jsx(LoaderCircle,{"aria-label":"Loading image",className:"fk:absolute fk:h-8 fk:w-8 fk:animate-spin fk:text-muted-foreground"}),jsx("img",{alt:n,className:`fk:max-h-full fk:max-w-full fk:object-contain fk:transition-opacity ${r?"fk:opacity-100":"fk:opacity-0"}`,onError:()=>f(true),onLoad:()=>f(true),src:v})]})]})})]})}var Fo=[{value:"image/gif",label:"GIF",icon:ImagePlayIcon},{value:"image/jpeg",label:"JPEG",icon:ImageIcon},{value:"video/mp4",label:"MP4",icon:FilePlayIcon},{value:"image/png",label:"PNG",icon:LayersIcon},{value:"image/svg+xml",label:"SVG",icon:SplinePointerIcon},{value:"image/webp",label:"WebP",icon:ImageIcon}];function je({entityName:e,isUploading:n=false,table:t,viewMode:s$1,onUploadClick:r,onViewModeChange:f$1,onSearchLoadingChange:l,onSearchWhereChange:u}){let D=t.getState().columnFilters.length>0,{projectId:v}=useParams(),g=j$2(),{scope:I}=c(),[i,A]=useState(null),{currentProjectSchema:d}=f(),_=b$2(),[x,J]=useState(""),M=useRef({}),P=useRef({});function O(){return {searchRequests:{searches:[{collection:"_assets"},{collection:"_tags"}]},commonParams:{q:""}}}let R=useMemo(()=>O(),[]),[B,k]=useState(R),{results:w,isLoading:c$1}=a$3(v??"",B),b=useRef(""),T=x.trim(),z=B.commonParams.q??"",L=T.length>0&&(c$1||z!==T),q=useMemo(()=>Lo(m=>{k({...R,commonParams:{q:m}});},300),[R]);useEffect(()=>()=>{q.cancel();},[q]);let y=t.getSelectedRowModel().rows.map(m=>m.original._id),{data:a}=s({entityNamePlural:"_tags",schema:d,scope:I,variables:be,...Y}),U=useMemo(()=>(Array.isArray(a)?a:[]).map(S=>({_id:S._id,name:S.name})),[a]),Z=useMemo(()=>U.map(m=>({value:m._id,label:m.name})),[U]),F=useCallback(()=>{if(!u)return;let m=[];Object.keys(M.current).length>0&&m.push(M.current),Object.keys(P.current).length>0&&m.push(P.current);let S=m.length===0?{}:m.length===1?m[0]:{AND:m},H=JSON.stringify(S);b.current!==H&&(b.current=H,u(S));},[u]);function j(){q.cancel(),J(""),k({...R,commonParams:{q:""}}),M.current={},F();}async function K(){g({type:"AlertDialog",payload:{options:{dialogTitle:`Delete ${y.length} asset${y.length>1?"s":""}`,dialogMessage:y.length>1?"Are you sure you want to delete the selected assets? They will be deleted permanently.":"Are you sure you want to delete the selected asset? The item will be deleted permanently.",dialogCancelTitle:"Cancel",dialogActionLabel:"Delete",isDestructive:true,dialogActionCancel:()=>{},dialogActionSubmit:()=>{g({type:"DeleteEntity",_id:`delete-batch-${Date.now()}`,payload:{entityId:y,entityName:e,silent:true}}),t.resetRowSelection();}}}});}useEffect(()=>{l?.(L);},[L,l]),useEffect(()=>{if(!u)return;if(T.length===0){M.current={},F();return}if(L)return;let m=w??[],S={};if(m.length===0)S={_id:{in:[]}};else {let H=m.filter(V=>V._entityNamePlural==="_assets").map(V=>V._id),xe=m.filter(V=>V._entityNamePlural==="_tags").map(V=>({tags:{some:{_id:{eq:V._id}}}})),Q=[];H.length>0&&Q.push({_id:{in:H}}),Q.push(...xe),Q.length===0?S={_id:{in:[]}}:Q.length===1?S=Q[0]:S={OR:Q};}M.current=S,F();},[F,L,u,w,T]);let h=JSON.stringify(t.getState().columnFilters);return useEffect(()=>{if(!u)return;let m=t.getState().columnFilters.find(V=>V.id==="mimeType"),S=Array.isArray(m?.value)?m?.value:[],H=t.getState().columnFilters.find(V=>V.id==="tags"),xe=Array.isArray(H?.value)?H?.value:[],Q=[];if(S.length>0&&Q.push({mimeType:{in:S}}),xe.length>0){let V=xe.map(jt=>({tags:{some:{_id:{eq:jt}}}}));Q.push(V.length===1?V[0]:{OR:V});}Q.length===0?P.current={}:Q.length===1?P.current=Q[0]:P.current={AND:Q},F();},[h,F,u,t]),jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:pr-3",children:[jsxs("div",{className:"fk:flex fk:flex-1 fk:items-center fk:space-x-2",children:[jsxs("div",{className:"fk:relative",children:[c$1?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$4,{placeholder:"Search assets...",name:"search-assets",value:x,onChange:m=>{let{value:S}=m.target;if(J(S),S.trim().length===0){j();return}q(S.trim());},className:"fk:h-8 fk:w-37.5 fk:lg:w-70 fk:px-7"}),x?jsx(c$2,{"aria-label":"Clear search",className:"fk:absolute fk:right-1 fk:top-1 fk:h-6 fk:w-6 fk:text-muted-foreground fk:hover:text-foreground fk:hover:bg-foreground/10 fk:cursor-pointer fk:rounded-full fk:bg-transparent fk:corner-squircle",onClick:j,type:"button",children:jsx(X,{className:"fk:h-4 fk:w-4"})}):null]}),t.getColumn("mimeType")&&jsx(a$4,{column:t.getColumn("mimeType"),options:Fo,title:"File type"}),t.getColumn("tags")&&jsx(a$4,{column:t.getColumn("tags"),options:Z,title:"Tags"}),D&&jsxs(c$2,{variant:"ghost",onClick:()=>{t.resetColumnFilters(),P.current={},F();},className:"fk:h-8 fk:px-2 fk:lg:px-3",children:["Reset",jsx(X,{className:"fk:ml-2 fk:h-4 fk:w-4"})]}),jsx(e$4,{table:t})]}),y.length>0?jsx("div",{className:"fk:flex fk:items-center fk:gap-2",children:jsxs(e$3,{children:[jsx(la,{disabled:!_,children:jsx(g$1,{asChild:true,children:jsxs(c$2,{className:"fk:h-8 fk:mr-2 fk:lg:flex",disabled:!_,size:"sm",variant:"secondary",children:["Actions ",jsx(ListChecks,{className:"fk:ml-2 fk:h-4 fk:w-4"})]})})}),jsxs(h$1,{align:"end",className:"fk:w-[240px]",children:[jsxs(j$1,{onClick:()=>A("add"),children:[jsx(TagIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Add tag"]}),jsxs(j$1,{onClick:()=>A("remove"),children:[jsx(MinusIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Remove tag"]}),jsx(o,{}),jsxs(j$1,{onClick:K,className:"fk:text-destructive",children:[jsx(Trash2Icon,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Delete asset",y.length>1?"s":""," (",y.length,")"]})]})]})}):null,jsxs("div",{className:"fk:ml-auto fk:flex fk:items-center fk:gap-2",children:[jsxs(c$4,{size:"sm",type:"single",value:s$1,onValueChange:m=>{(m==="list"||m==="grid")&&f$1(m);},children:[jsx(d$1,{"aria-label":"Grid view",value:"grid",children:jsx(LayoutGrid,{className:"fk:h-4 fk:w-4"})}),jsx(d$1,{"aria-label":"List view",value:"list",children:jsx(List,{className:"fk:h-4 fk:w-4"})})]}),jsx(la,{disabled:!_,children:jsxs(c$2,{"aria-busy":n,className:"fk:h-8 fk:lg:flex",disabled:!_||n,onClick:r,size:"sm",variant:"default",children:[n?jsx(LoaderCircle,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin"}):null,"Upload assets"]})})]}),i!==null?jsx(Le,{assetIds:y,mode:i,onCompleted:()=>t.resetRowSelection(),onModeChange:A}):null]})}function Lo(e,n=300){let t,s=function(...r){t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e.apply(this,r);},n);};return s.cancel=()=>{t!==void 0&&(clearTimeout(t),t=void 0);},s}var Uo=4*1024*1024;function Gt(){let{projectId:e}=useParams(),n=c$3(),t=b$2(),[s,r]=useState(false);async function f(l){if(!(!t||s)&&!(l&&l.length===0))try{await n({files:l,maxBytes:Uo,multiple:!0,onUploadStart:()=>{r(!0);},projectId:e});}finally{r(false);}}return {canMutate:t,isUploading:s,uploadFiles:l=>f(l),uploadFromDialog:()=>f()}}var Wt="flexkit-asset-manager:viewMode";function $t(){if(typeof localStorage>"u")return "grid";try{let e=localStorage.getItem(Wt);if(e==="list"||e==="grid")return e}catch{}return "grid"}function Jt(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(Wt,e);}catch{}}var Me=36,Qo=[{_updatedAt:"DESC"},{_id:"DESC"}];function Xt(){let e$1="_assets",{search:n}=useLocation(),s$1=new URLSearchParams(n).get("id"),{scope:r}=c(),{schemaErrorMessage:f$1}=e(),{currentProject:l}=f(),u=l?.schema??[],[D,v]=useState([]),[g,I]=useState(()=>$t()),i=m({attributesSchema:b.attributes,actionsComponent:h=>jsx(Ve,{row:h}),checkboxSelect:"multiple",enableColumnSorting:true}),[A,d$1]=useState({}),[_,x]=useState(false),{canMutate:J,isUploading:M,uploadFiles:P,uploadFromDialog:O}=Gt(),R=useMemo(()=>{let h=s$1?{_id:{eq:s$1}}:{NOT:{path:{eq:null}}};return !A||Object.keys(A).length===0||s$1?h:{AND:[h,A]}},[s$1,A]),B=useMemo(()=>{if(D.length===0)return Qo;let h=D.map(({id:S,desc:H})=>({[S]:H?"DESC":"ASC"}));return h.some(S=>"_id"in S)?h:[...h,{_id:"DESC"}]},[D]),k=useMemo(()=>({where:R,offset:0,limit:Me,sort:B}),[R,B]);function w(h){v(h);}function c$1(h){I(h),Jt(h);}let{isLoading:b$2,isLoadingMore:T,fetchMore:z,count:L,data:q,isProjectDisabled:y}=s({entityNamePlural:e$1,schema:u,scope:r,variables:k,selection:"list"}),a$2=_||b$2&&(q==null||q.length===0),U=q?.length??0,Z=!_&&L>0&&U>0&&U<L,F=useCallback(()=>{z({variables:{offset:0,limit:Me}});},[z]),j=useMemo(()=>Array.from({length:Me},(h,m)=>({_id:`loading-${m}`})),[]),K=useMemo(()=>Go(i),[i]);return y?jsx("div",{className:"fk:flex fk:flex-col fk:h-full fk:pl-3",children:jsx(a,{})}):jsxs("div",{className:"fk:flex fk:flex-col fk:h-full fk:pl-3",children:[jsx(b$1,{}),jsxs("div",{className:"fk:mb-4 fk:flex fk:items-center fk:gap-2 fk:pr-3",children:[jsx("h2",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:"Asset Manager"}),a$2?null:jsxs("span",{className:"fk:ml-auto fk:text-sm fk:font-normal fk:text-muted-foreground",children:[L.toLocaleString()," ",L===1?"record":"records"]})]}),f$1?null:jsx(a$1,{disabled:!J||M,onDropFiles:P,children:g==="list"?jsx(d,{classNames:{row:"fk:h-20"},columns:a$2?K:i,data:a$2?j:q??[],entityName:b.name,hasMore:Z,isLoadingMore:T,pageSize:Me,sorting:D,onLoadMore:F,onSortingChange:w,toolbarComponent:h=>jsx(je,{entityName:b.name,isUploading:M,table:h,viewMode:g,onSearchLoadingChange:x,onSearchWhereChange:d$1,onUploadClick:O,onViewModeChange:c$1})}):jsx(Ut,{columns:i,data:a$2?[]:q??[],entityName:b.name,hasMore:Z,isLoading:a$2,isLoadingMore:T,pageSize:Me,sorting:D,onLoadMore:F,onSortingChange:w,toolbarComponent:h=>jsx(je,{entityName:b.name,isUploading:M,table:h,viewMode:g,onSearchLoadingChange:x,onSearchWhereChange:d$1,onUploadClick:O,onViewModeChange:c$1})})}),jsx(Outlet,{})]})}function Go(e){return e.map(n=>({...n,cell:()=>jsx(t$1,{className:"fk:h-4 fk:w-full",style:{marginTop:"7px",marginBottom:"6px"}})}))}function Rn(){return jsxs(v,{orientation:"horizontal",className:"fk:h-full",children:[jsx(w,{className:"fk:p-3",defaultSize:"82%",children:jsx("div",{className:"fk:flex fk:flex-col fk:h-full",children:jsx(Xt,{})})}),jsx(x,{className:"fk:hover:bg-blue-500 fk:transition-colors",withHandle:true}),jsx(w,{defaultSize:"18%",minSize:"10%",children:jsx("div",{className:"fk:sm:hidden fk:md:block",children:jsx(Pt,{})})})]})}export{Rn as Root};//# sourceMappingURL=root-MLEJUEMJ.js.map
|
|
23
|
-
//# sourceMappingURL=root-MLEJUEMJ.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
|