@flexkit/studio 0.2.39 → 0.2.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/{chat-page-2ES466GO.js → chat-page-I2IFVZA3.js} +3 -3
  2. package/dist/{chat-page-2ES466GO.js.map → chat-page-I2IFVZA3.js.map} +1 -1
  3. package/dist/{chunk-DQ2OVNOB.js → chunk-2IJWBRN2.js} +2 -2
  4. package/dist/{chunk-DQ2OVNOB.js.map → chunk-2IJWBRN2.js.map} +1 -1
  5. package/dist/{chunk-DUS2CRB3.js → chunk-4JG3OWQW.js} +2 -2
  6. package/dist/{chunk-DUS2CRB3.js.map → chunk-4JG3OWQW.js.map} +1 -1
  7. package/dist/{chunk-7FYOLFHG.js → chunk-53GVTCXC.js} +3 -3
  8. package/dist/{chunk-7FYOLFHG.js.map → chunk-53GVTCXC.js.map} +1 -1
  9. package/dist/{chunk-WSXNYZQC.js → chunk-CQS6AIOX.js} +2 -2
  10. package/dist/{chunk-WSXNYZQC.js.map → chunk-CQS6AIOX.js.map} +1 -1
  11. package/dist/{chunk-KWE3LHFM.js → chunk-DAXVPJJS.js} +4 -4
  12. package/dist/{chunk-KWE3LHFM.js.map → chunk-DAXVPJJS.js.map} +1 -1
  13. package/dist/{chunk-TOISBMRE.js → chunk-DFOPVG7I.js} +2 -2
  14. package/dist/{chunk-TOISBMRE.js.map → chunk-DFOPVG7I.js.map} +1 -1
  15. package/dist/{chunk-DR36N2JC.js → chunk-E3KO5NGM.js} +2 -2
  16. package/dist/{chunk-DR36N2JC.js.map → chunk-E3KO5NGM.js.map} +1 -1
  17. package/dist/chunk-GPMBBJHK.js +7 -0
  18. package/dist/chunk-GPMBBJHK.js.map +1 -0
  19. package/dist/{chunk-JJFOUJMQ.js → chunk-GPTSQ2WH.js} +3 -3
  20. package/dist/{chunk-JJFOUJMQ.js.map → chunk-GPTSQ2WH.js.map} +1 -1
  21. package/dist/{chunk-SAVZBVP5.js → chunk-HOAVEDVI.js} +3 -3
  22. package/dist/{chunk-SAVZBVP5.js.map → chunk-HOAVEDVI.js.map} +1 -1
  23. package/dist/{chunk-Z7JAN2UW.js → chunk-HUG2NGZI.js} +2 -2
  24. package/dist/{chunk-Z7JAN2UW.js.map → chunk-HUG2NGZI.js.map} +1 -1
  25. package/dist/{chunk-U3PTPLSE.js → chunk-L62VVHKS.js} +2 -2
  26. package/dist/{chunk-U3PTPLSE.js.map → chunk-L62VVHKS.js.map} +1 -1
  27. package/dist/{chunk-SGQMQZIW.js → chunk-LO37DY2Z.js} +2 -2
  28. package/dist/{chunk-SGQMQZIW.js.map → chunk-LO37DY2Z.js.map} +1 -1
  29. package/dist/{chunk-R7EOMV6C.js → chunk-LWI3HNJL.js} +3 -3
  30. package/dist/{chunk-R7EOMV6C.js.map → chunk-LWI3HNJL.js.map} +1 -1
  31. package/dist/{chunk-CESG6WQB.js → chunk-NPMBADZL.js} +3 -3
  32. package/dist/{chunk-CESG6WQB.js.map → chunk-NPMBADZL.js.map} +1 -1
  33. package/dist/chunk-NPO7ISWV.js +2 -0
  34. package/dist/chunk-NPO7ISWV.js.map +1 -0
  35. package/dist/{chunk-VR3LFFJ3.js → chunk-X5QKLF63.js} +3 -3
  36. package/dist/chunk-X5QKLF63.js.map +1 -0
  37. package/dist/{chunk-TP6QGIJH.js → chunk-Y7VBTUNI.js} +3 -3
  38. package/dist/{chunk-TP6QGIJH.js.map → chunk-Y7VBTUNI.js.map} +1 -1
  39. package/dist/{entry-ZYSQFFEW.js → entry-NCKQ45MI.js} +2 -2
  40. package/dist/{entry-ZYSQFFEW.js.map → entry-NCKQ45MI.js.map} +1 -1
  41. package/dist/index.d.ts +12 -1
  42. package/dist/index.js +2 -2
  43. package/dist/index.js.map +1 -1
  44. package/dist/list-UHHDZ3DM.js +2 -0
  45. package/dist/list-UHHDZ3DM.js.map +1 -0
  46. package/dist/{list-XTC2OYA6.js → list-VWN4IJYC.js} +3 -3
  47. package/dist/{list-XTC2OYA6.js.map → list-VWN4IJYC.js.map} +1 -1
  48. package/dist/{pages-HW4OCENA.js → pages-LZEKCA4W.js} +3 -3
  49. package/dist/{pages-HW4OCENA.js.map → pages-LZEKCA4W.js.map} +1 -1
  50. package/dist/{plugin-pages-CUTCB6NU.js → plugin-pages-LLJPZJWL.js} +2 -2
  51. package/dist/{plugin-pages-CUTCB6NU.js.map → plugin-pages-LLJPZJWL.js.map} +1 -1
  52. package/dist/{project-selector-Z4Q6G6GM.js → project-selector-K3T6H77F.js} +2 -2
  53. package/dist/{project-selector-Z4Q6G6GM.js.map → project-selector-K3T6H77F.js.map} +1 -1
  54. package/dist/record-links-CILZYRSE.js +2 -0
  55. package/dist/{record-links-DBU5G6ZH.js.map → record-links-CILZYRSE.js.map} +1 -1
  56. package/dist/{root-SYRZ3UBN.js → root-ADEORVTL.js} +2 -2
  57. package/dist/{root-SYRZ3UBN.js.map → root-ADEORVTL.js.map} +1 -1
  58. package/dist/root-CE6LNBBW.js +23 -0
  59. package/dist/root-CE6LNBBW.js.map +1 -0
  60. package/dist/{root-7NZPP7IC.js → root-LSBCX6AE.js} +2 -2
  61. package/dist/{root-7NZPP7IC.js.map → root-LSBCX6AE.js.map} +1 -1
  62. package/dist/{root-3Q44ISGQ.js → root-PY5SBJ4F.js} +3 -3
  63. package/dist/{root-3Q44ISGQ.js.map → root-PY5SBJ4F.js.map} +1 -1
  64. package/dist/{root-7FYWXLI6.js → root-XTF6EH63.js} +3 -3
  65. package/dist/{root-7FYWXLI6.js.map → root-XTF6EH63.js.map} +1 -1
  66. package/dist/{root-Q6SHODPG.js → root-Y3D2FTDR.js} +2 -2
  67. package/dist/{root-Q6SHODPG.js.map → root-Y3D2FTDR.js.map} +1 -1
  68. package/dist/{search-X7F5JZOU.js → search-MGY3OWZQ.js} +2 -2
  69. package/dist/{search-X7F5JZOU.js.map → search-MGY3OWZQ.js.map} +1 -1
  70. package/dist/{skills-pages-X3DVZXY5.js → skills-pages-7QYBKBSB.js} +2 -2
  71. package/dist/{skills-pages-X3DVZXY5.js.map → skills-pages-7QYBKBSB.js.map} +1 -1
  72. package/dist/{source-43PHAELP.js → source-M746FR3B.js} +2 -2
  73. package/dist/{source-43PHAELP.js.map → source-M746FR3B.js.map} +1 -1
  74. package/package.json +3 -3
  75. package/dist/chunk-MGCXYA2S.js +0 -7
  76. package/dist/chunk-MGCXYA2S.js.map +0 -1
  77. package/dist/chunk-PR3MTHFM.js +0 -2
  78. package/dist/chunk-PR3MTHFM.js.map +0 -1
  79. package/dist/chunk-VR3LFFJ3.js.map +0 -1
  80. package/dist/list-4EXGXJZA.js +0 -2
  81. package/dist/list-4EXGXJZA.js.map +0 -1
  82. package/dist/record-links-DBU5G6ZH.js +0 -2
  83. package/dist/root-422O7YX5.js +0 -23
  84. package/dist/root-422O7YX5.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import'./index.css';import {c as c$3,i,j,d as d$2,l,f,b as b$1}from'./chunk-JJFOUJMQ.js';import {c as c$4}from'./chunk-MBBE4RND.js';import {e,g,a,b,c as c$1,d as d$1}from'./chunk-G5N6HEPW.js';import {a as a$1,d,c,e as e$1,g as g$1}from'./chunk-S7Z6KKIN.js';import {c as c$2,a as a$2}from'./chunk-X3SHNHHM.js';import {useId,useState}from'react';import {useNavigate}from'react-router-dom';import {ShoppingBag,MessageSquareText,Sparkles,Loader2}from'lucide-react';import ve,{mutate}from'swr';import {jsx,jsxs}from'react/jsx-runtime';function Le(e,t,o=[]){return o.find(n=>n.id===e)?.name??t.find(n=>n.projectId===e)?.title??e}function He(e,t){let o=new Map;for(let n of e){let m=t.find(c=>c.id===n),f=m?.team.id??"",s=o.get(f)??{label:m?.team.name??"",projectIds:[]};s.projectIds.push(n),o.set(f,s);}return o.size<=1?[{label:null,projectIds:e}]:[...o.values()].map(n=>({label:n.label||null,projectIds:n.projectIds}))}var se="Could not create the project. Please try again.";async function ie(e){let t=await b$1(c$4.myProjects,"POST",e,se);return t.ok?!t.project?.id||!t.team?.id?{ok:false,code:"unknown_error",message:se}:{ok:true,project:t.project,team:t.team}:t}function me(e){return e.filter(t=>t.role==="owner")}function de(e){return `/${e}/ai/agent`}var F="hosted-session";async function he(){try{let e=await fetch(c$4.me,{credentials:"same-origin"});return e.status===401?{kind:"anonymous"}:e.ok?{kind:"ready",data:await e.json()}:{kind:"error",message:`Flexkit answered ${String(e.status)} while loading your projects.`}}catch(e){return {kind:"error",message:e instanceof Error?e.message:"Flexkit is not reachable."}}}function xe(e){return e?e.kind==="anonymous"?{status:"anonymous"}:e.kind==="error"?{status:"error",message:e.message}:{status:"ready",projects:e.data.projects,teams:e.data.teams??[],user:e.data.user}:{status:"loading"}}function Ue(){let{data:e}=ve(F,he,{revalidateOnFocus:false,revalidateOnReconnect:false,shouldRetryOnError:false});return xe(e)}function Pe(e,t){if(e?.kind!=="ready"||e.data.projects.some(m=>m.id===t.project.id))return e;let o=e.data.teams??[],n={avatarUrl:null,id:t.project.id,name:t.project.name,readOnly:false,role:"owner",suspended:false,team:t.team};return {kind:"ready",data:{...e.data,projects:[...e.data.projects,n],teams:o.some(m=>m.id===t.team.id)?o:[...o,{...t.team,role:"owner"}]}}}async function x(e){await mutate(F,t=>Pe(t,e),{revalidate:false});}function we(e,t){return e?.kind!=="ready"?e:{kind:"ready",data:{...e.data,user:{...e.data.user,displayName:t}}}}async function ce(e){await mutate(F,t=>we(t,e),{revalidate:false});}function rt({askForName:e$2=false,isFirstProject:t=false,onCancel:o,onCreated:n,teams:m}){let f$1=useNavigate(),s={you:useId(),name:useId(),team:useId(),description:useId(),sample:useId()},c$2=me(m),[E,j$1]=useState(e$2?"you":"project"),[R,ue]=useState(""),[P,fe]=useState(""),[U,pe]=useState(null),w=c$2.some(a=>a.id===U)?U??"":c$2[0]?.id??"",[k,N]=useState("starter"),[B,ke]=useState(true),[C,ge]=useState(""),[O,l$1]=useState(null),[u,g$2]=useState(false),[v,ye]=useState(null);async function be(){let a=R.trim();if(!a){l$1("Tell us your name.");return}l$1(null),g$2(true);let p=await c$3(a);if(g$2(false),!p.ok){l$1(p.message);return}await ce(a),j$1("project");}function Se(){let a=i(P);l$1(a),a||j$1("start");}async function je(){if(k==="describe"&&!C.trim()){l$1("Describe your business in a sentence or two, or pick another way to start.");return}l$1(null),g$2(true);let a=v??await ie({name:P.trim(),...w?{teamId:w}:{}});if(!a.ok){l$1(a.message),g$2(false),a.code==="invalid_name"&&j$1("project");return}ye(a);let p=a.project.id,y=j(k,B,C),I={};if(y.kind==="starter"){let $=await d$2(p,{template:y.template,sampleData:y.sampleData});if(!$.ok){l$1(`${a.project.name} was created, but the starter could not be applied: ${$.message}`),g$2(false),!t&&!v&&await x(a);return}l({projectId:p});}else y.kind==="describe"&&(I={onboardingPrompt:f(y.description)});let K=de(p);t?(f$1(K,{state:I}),await x(a)):(await x(a),f$1(K,{state:I})),n?.(p);}let T=O?jsx(e,{variant:"destructive",children:jsx(g,{children:O})}):null;return E==="you"?jsxs(M,{onSubmit:()=>{be();},children:[jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(a,{htmlFor:s.you,children:"Your name"}),jsx(b,{autoComplete:"name",autoFocus:true,disabled:u,id:s.you,maxLength:80,onChange:a=>{ue(a.target.value);},placeholder:"e.g. Ann Meyer",value:R}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Your teammates see it on changes and comments."})]}),T,jsx(A,{isSubmitting:u,submitLabel:"Continue"})]}):E==="project"?jsxs(M,{onSubmit:Se,children:[jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(a,{htmlFor:s.name,children:"Project name"}),jsx(b,{"aria-invalid":O?true:void 0,autoComplete:"off",autoFocus:true,id:s.name,maxLength:48,onChange:a=>{fe(a.target.value);},placeholder:"e.g. Aven Living",value:P}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Usually your store or company name. You can change it later."})]}),c$2.length>1?jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(a,{htmlFor:s.team,children:"Team"}),jsxs(a$1,{onValueChange:pe,value:w,children:[jsx(d,{id:s.team,children:jsx(c,{})}),jsx(e$1,{children:c$2.map(a=>jsx(g$1,{value:a.id,children:a.name},a.id))})]})]}):null,T,jsx(A,{onCancel:o,submitLabel:"Continue"})]}):jsxs(M,{onSubmit:()=>{je();},children:[jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("p",{className:"fk:text-sm fk:font-medium",id:`${s.name}-start`,children:"How do you want to start?"}),jsxs("div",{"aria-labelledby":`${s.name}-start`,className:"fk:flex fk:flex-col fk:gap-2",role:"radiogroup",children:[jsx(D,{checked:k==="starter",description:"22 ready-made entities for catalog, inventory, orders, customers and marketing, with EU, UK and US markets.",disabled:u,icon:ShoppingBag,onSelect:()=>{N("starter");},recommended:true,title:"Commerce starter",children:jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-3 fk:pt-1",children:[jsx(a,{className:"fk:text-xs fk:font-normal fk:text-muted-foreground",htmlFor:s.sample,children:"Add a sample store (Aven Living) to try things out"}),jsx(c$1,{checked:B,disabled:u,id:s.sample,onCheckedChange:ke})]})}),jsx(D,{checked:k==="describe",description:"Tell the agent what you sell and how you work; it proposes a schema for you to review.",disabled:u,icon:MessageSquareText,onSelect:()=>{N("describe");},title:"Describe your business",children:jsx(d$1,{"aria-label":"Your business",autoFocus:true,disabled:u,id:s.description,maxLength:2e3,onChange:a=>{ge(a.target.value);},placeholder:"e.g. We sell handmade ceramics online and to 40 shops in Europe, with seasonal collections.",rows:3,value:C})}),jsx(D,{checked:k==="empty",description:"Start with an empty project and build the schema in the chat.",disabled:u,icon:Sparkles,onSelect:()=>{N("empty");},title:"Start from scratch"})]})]}),T,jsx(A,{isSubmitting:u,onBack:v?void 0:()=>{l$1(null),j$1("project");},submitLabel:v?"Continue":"Create project"})]})}function M({children:e,onSubmit:t}){return jsx("form",{className:"fk:flex fk:w-full fk:flex-col fk:gap-4",onSubmit:o=>{o.preventDefault(),t();},children:e})}function A({isSubmitting:e=false,onBack:t,onCancel:o,submitLabel:n}){let m=t??o;return jsxs("div",{className:"fk:flex fk:justify-end fk:gap-2",children:[m?jsx(c$2,{disabled:e,onClick:m,type:"button",variant:"outline",children:t?"Back":"Cancel"}):null,jsxs(c$2,{className:m?void 0:"fk:w-full",disabled:e,type:"submit",children:[e?jsx(Loader2,{className:"fk:h-4 fk:w-4 fk:animate-spin"}):null,n]})]})}function D({checked:e,children:t,description:o,disabled:n,icon:m,onSelect:f,recommended:s=false,title:c}){return jsxs("div",{className:a$2("fk:rounded-lg fk:border fk:p-3 fk:transition-colors",e?"fk:border-foreground/70 fk:bg-muted/50 fk:ring-1 fk:ring-foreground/20":"fk:border-border fk:hover:bg-muted/30"),children:[jsxs("button",{"aria-checked":e,className:"fk:flex fk:w-full fk:items-start fk:gap-3 fk:text-left fk:disabled:opacity-60",disabled:n,onClick:f,role:"radio",type:"button",children:[jsx(m,{className:"fk:mt-0.5 fk:h-4 fk:w-4 fk:shrink-0 fk:text-muted-foreground"}),jsxs("span",{className:"fk:flex fk:flex-col fk:gap-0.5",children:[jsxs("span",{className:"fk:flex fk:items-center fk:gap-2 fk:text-sm fk:font-medium",children:[c,s?jsx("span",{className:"fk:rounded-full fk:bg-primary/10 fk:px-2 fk:py-0.5 fk:text-[11px] fk:font-medium fk:text-primary",children:"Recommended"}):null]}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:o})]})]}),e&&t?jsx("div",{className:"fk:mt-2 fk:pl-7",children:t}):null]})}export{Le as a,He as b,Ue as c,rt as d};//# sourceMappingURL=chunk-TOISBMRE.js.map
2
- //# sourceMappingURL=chunk-TOISBMRE.js.map
1
+ import'./index.css';import {c as c$3,i,j,d as d$2,l,f,b as b$1}from'./chunk-GPTSQ2WH.js';import {c as c$4}from'./chunk-MBBE4RND.js';import {e,g,a,b,c as c$1,d as d$1}from'./chunk-G5N6HEPW.js';import {a as a$1,d,c,e as e$1,g as g$1}from'./chunk-S7Z6KKIN.js';import {c as c$2,a as a$2}from'./chunk-X3SHNHHM.js';import {useId,useState}from'react';import {useNavigate}from'react-router-dom';import {ShoppingBag,MessageSquareText,Sparkles,Loader2}from'lucide-react';import ve,{mutate}from'swr';import {jsx,jsxs}from'react/jsx-runtime';function Le(e,t,o=[]){return o.find(n=>n.id===e)?.name??t.find(n=>n.projectId===e)?.title??e}function He(e,t){let o=new Map;for(let n of e){let m=t.find(c=>c.id===n),f=m?.team.id??"",s=o.get(f)??{label:m?.team.name??"",projectIds:[]};s.projectIds.push(n),o.set(f,s);}return o.size<=1?[{label:null,projectIds:e}]:[...o.values()].map(n=>({label:n.label||null,projectIds:n.projectIds}))}var se="Could not create the project. Please try again.";async function ie(e){let t=await b$1(c$4.myProjects,"POST",e,se);return t.ok?!t.project?.id||!t.team?.id?{ok:false,code:"unknown_error",message:se}:{ok:true,project:t.project,team:t.team}:t}function me(e){return e.filter(t=>t.role==="owner")}function de(e){return `/${e}/ai/agent`}var F="hosted-session";async function he(){try{let e=await fetch(c$4.me,{credentials:"same-origin"});return e.status===401?{kind:"anonymous"}:e.ok?{kind:"ready",data:await e.json()}:{kind:"error",message:`Flexkit answered ${String(e.status)} while loading your projects.`}}catch(e){return {kind:"error",message:e instanceof Error?e.message:"Flexkit is not reachable."}}}function xe(e){return e?e.kind==="anonymous"?{status:"anonymous"}:e.kind==="error"?{status:"error",message:e.message}:{status:"ready",projects:e.data.projects,teams:e.data.teams??[],user:e.data.user}:{status:"loading"}}function Ue(){let{data:e}=ve(F,he,{revalidateOnFocus:false,revalidateOnReconnect:false,shouldRetryOnError:false});return xe(e)}function Pe(e,t){if(e?.kind!=="ready"||e.data.projects.some(m=>m.id===t.project.id))return e;let o=e.data.teams??[],n={avatarUrl:null,id:t.project.id,name:t.project.name,readOnly:false,role:"owner",suspended:false,team:t.team};return {kind:"ready",data:{...e.data,projects:[...e.data.projects,n],teams:o.some(m=>m.id===t.team.id)?o:[...o,{...t.team,role:"owner"}]}}}async function x(e){await mutate(F,t=>Pe(t,e),{revalidate:false});}function we(e,t){return e?.kind!=="ready"?e:{kind:"ready",data:{...e.data,user:{...e.data.user,displayName:t}}}}async function ce(e){await mutate(F,t=>we(t,e),{revalidate:false});}function rt({askForName:e$2=false,isFirstProject:t=false,onCancel:o,onCreated:n,teams:m}){let f$1=useNavigate(),s={you:useId(),name:useId(),team:useId(),description:useId(),sample:useId()},c$2=me(m),[E,j$1]=useState(e$2?"you":"project"),[R,ue]=useState(""),[P,fe]=useState(""),[U,pe]=useState(null),w=c$2.some(a=>a.id===U)?U??"":c$2[0]?.id??"",[k,N]=useState("starter"),[B,ke]=useState(true),[C,ge]=useState(""),[O,l$1]=useState(null),[u,g$2]=useState(false),[v,ye]=useState(null);async function be(){let a=R.trim();if(!a){l$1("Tell us your name.");return}l$1(null),g$2(true);let p=await c$3(a);if(g$2(false),!p.ok){l$1(p.message);return}await ce(a),j$1("project");}function Se(){let a=i(P);l$1(a),a||j$1("start");}async function je(){if(k==="describe"&&!C.trim()){l$1("Describe your business in a sentence or two, or pick another way to start.");return}l$1(null),g$2(true);let a=v??await ie({name:P.trim(),...w?{teamId:w}:{}});if(!a.ok){l$1(a.message),g$2(false),a.code==="invalid_name"&&j$1("project");return}ye(a);let p=a.project.id,y=j(k,B,C),I={};if(y.kind==="starter"){let $=await d$2(p,{template:y.template,sampleData:y.sampleData});if(!$.ok){l$1(`${a.project.name} was created, but the starter could not be applied: ${$.message}`),g$2(false),!t&&!v&&await x(a);return}l({projectId:p});}else y.kind==="describe"&&(I={onboardingPrompt:f(y.description)});let K=de(p);t?(f$1(K,{state:I}),await x(a)):(await x(a),f$1(K,{state:I})),n?.(p);}let T=O?jsx(e,{variant:"destructive",children:jsx(g,{children:O})}):null;return E==="you"?jsxs(M,{onSubmit:()=>{be();},children:[jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(a,{htmlFor:s.you,children:"Your name"}),jsx(b,{autoComplete:"name",autoFocus:true,disabled:u,id:s.you,maxLength:80,onChange:a=>{ue(a.target.value);},placeholder:"e.g. Ann Meyer",value:R}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Your teammates see it on changes and comments."})]}),T,jsx(A,{isSubmitting:u,submitLabel:"Continue"})]}):E==="project"?jsxs(M,{onSubmit:Se,children:[jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(a,{htmlFor:s.name,children:"Project name"}),jsx(b,{"aria-invalid":O?true:void 0,autoComplete:"off",autoFocus:true,id:s.name,maxLength:48,onChange:a=>{fe(a.target.value);},placeholder:"e.g. Aven Living",value:P}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"Usually your store or company name. You can change it later."})]}),c$2.length>1?jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx(a,{htmlFor:s.team,children:"Team"}),jsxs(a$1,{onValueChange:pe,value:w,children:[jsx(d,{id:s.team,children:jsx(c,{})}),jsx(e$1,{children:c$2.map(a=>jsx(g$1,{value:a.id,children:a.name},a.id))})]})]}):null,T,jsx(A,{onCancel:o,submitLabel:"Continue"})]}):jsxs(M,{onSubmit:()=>{je();},children:[jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("p",{className:"fk:text-sm fk:font-medium",id:`${s.name}-start`,children:"How do you want to start?"}),jsxs("div",{"aria-labelledby":`${s.name}-start`,className:"fk:flex fk:flex-col fk:gap-2",role:"radiogroup",children:[jsx(D,{checked:k==="starter",description:"22 ready-made entities for catalog, inventory, orders, customers and marketing, with EU, UK and US markets.",disabled:u,icon:ShoppingBag,onSelect:()=>{N("starter");},recommended:true,title:"Commerce starter",children:jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-3 fk:pt-1",children:[jsx(a,{className:"fk:text-xs fk:font-normal fk:text-muted-foreground",htmlFor:s.sample,children:"Add a sample store (Aven Living) to try things out"}),jsx(c$1,{checked:B,disabled:u,id:s.sample,onCheckedChange:ke})]})}),jsx(D,{checked:k==="describe",description:"Tell the agent what you sell and how you work; it proposes a schema for you to review.",disabled:u,icon:MessageSquareText,onSelect:()=>{N("describe");},title:"Describe your business",children:jsx(d$1,{"aria-label":"Your business",autoFocus:true,disabled:u,id:s.description,maxLength:2e3,onChange:a=>{ge(a.target.value);},placeholder:"e.g. We sell handmade ceramics online and to 40 shops in Europe, with seasonal collections.",rows:3,value:C})}),jsx(D,{checked:k==="empty",description:"Start with an empty project and build the schema in the chat.",disabled:u,icon:Sparkles,onSelect:()=>{N("empty");},title:"Start from scratch"})]})]}),T,jsx(A,{isSubmitting:u,onBack:v?void 0:()=>{l$1(null),j$1("project");},submitLabel:v?"Continue":"Create project"})]})}function M({children:e,onSubmit:t}){return jsx("form",{className:"fk:flex fk:w-full fk:flex-col fk:gap-4",onSubmit:o=>{o.preventDefault(),t();},children:e})}function A({isSubmitting:e=false,onBack:t,onCancel:o,submitLabel:n}){let m=t??o;return jsxs("div",{className:"fk:flex fk:justify-end fk:gap-2",children:[m?jsx(c$2,{disabled:e,onClick:m,type:"button",variant:"outline",children:t?"Back":"Cancel"}):null,jsxs(c$2,{className:m?void 0:"fk:w-full",disabled:e,type:"submit",children:[e?jsx(Loader2,{className:"fk:h-4 fk:w-4 fk:animate-spin"}):null,n]})]})}function D({checked:e,children:t,description:o,disabled:n,icon:m,onSelect:f,recommended:s=false,title:c}){return jsxs("div",{className:a$2("fk:rounded-lg fk:border fk:p-3 fk:transition-colors",e?"fk:border-foreground/70 fk:bg-muted/50 fk:ring-1 fk:ring-foreground/20":"fk:border-border fk:hover:bg-muted/30"),children:[jsxs("button",{"aria-checked":e,className:"fk:flex fk:w-full fk:items-start fk:gap-3 fk:text-left fk:disabled:opacity-60",disabled:n,onClick:f,role:"radio",type:"button",children:[jsx(m,{className:"fk:mt-0.5 fk:h-4 fk:w-4 fk:shrink-0 fk:text-muted-foreground"}),jsxs("span",{className:"fk:flex fk:flex-col fk:gap-0.5",children:[jsxs("span",{className:"fk:flex fk:items-center fk:gap-2 fk:text-sm fk:font-medium",children:[c,s?jsx("span",{className:"fk:rounded-full fk:bg-primary/10 fk:px-2 fk:py-0.5 fk:text-[11px] fk:font-medium fk:text-primary",children:"Recommended"}):null]}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:o})]})]}),e&&t?jsx("div",{className:"fk:mt-2 fk:pl-7",children:t}):null]})}export{Le as a,He as b,Ue as c,rt as d};//# sourceMappingURL=chunk-DFOPVG7I.js.map
2
+ //# sourceMappingURL=chunk-DFOPVG7I.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ui/components/project-label.ts","../src/core/config/create-project.ts","../src/core/config/use-hosted-session.ts","../src/ui/components/new-project-flow.tsx"],"names":["getProjectLabel","projectId","projects","projectSummaries","project","groupProjectIdsByTeam","projectIds","teams","id","summary","key","group","FALLBACK_MESSAGE","createHostedProject","input","outcome","send","userApiPaths","ownedTeams","team","newProjectPath","SESSION_KEY","fetchMe","response","error","toHostedSession","useHostedSession","data","useSWR","withCreatedProject","created","rememberCreatedProject","mutate","current","withDisplayName","displayName","rememberDisplayName","NewProjectFlow","askForName","isFirstProject","onCancel","onCreated","navigate","useNavigate","ids","useId","owned","step","setStep","useState","setDisplayName","name","setName","pickedTeamId","setPickedTeamId","selectedTeamId","startKind","setStartKind","sampleData","setSampleData","description","setDescription","setError","isSubmitting","setIsSubmitting","setCreated","submitName","trimmed","saveDisplayName","submitProjectName","invalid","validateProjectName","createProject","start","toProjectStart","state","applied","applyStarter","watchStarter","describeBusinessPrompt","path","errorAlert","jsx","Alert","AlertDescription","jsxs","StepForm","Label","Input","event","StepActions","Select","SelectTrigger","SelectValue","SelectContent","SelectItem","StartOption","ShoppingBag","Switch","MessageSquareText","Textarea","Sparkles","children","onSubmit","onBack","submitLabel","secondary","Button","Loader2","checked","disabled","Icon","onSelect","recommended","title","cn"],"mappings":"khBAGO,SAASA,GACdC,CAAAA,CACAC,CAAAA,CACAC,EAAqC,EAAC,CAC9B,CACR,OACEA,CAAAA,CAAiB,KAAMC,CAAAA,EAAYA,CAAAA,CAAQ,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E,EACT,IAAA,CAAK,OAAA,CACL,KAAK,QAAA,CAEL,QAAA,CAAA,CAAA9B,GAAAA,CAAC6B,CAAAA,CAAA,CAAK,SAAA,CAAU,8DAAA,CAA+D,EAC/E1B,IAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,gCAAA,CACd,QAAA,CAAA,CAAAA,KAAC,MAAA,CAAA,CAAK,SAAA,CAAU,6DACb,QAAA,CAAA,CAAA6B,CAAAA,CACAD,EACC/B,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,kGAAA,CAAmG,QAAA,CAAA,aAAA,CAEnH,EACE,IAAA,CAAA,CACN,CAAA,CACAA,IAAC,MAAA,CAAA,CAAK,SAAA,CAAU,sCAAuC,QAAA,CAAAtB,CAAAA,CAAY,GACrE,CAAA,CAAA,CACF,CAAA,CACCiD,GAAWP,CAAAA,CAAWpB,GAAAA,CAAC,OAAI,SAAA,CAAU,iBAAA,CAAmB,SAAAoB,CAAAA,CAAS,CAAA,CAAS,MAC7E,CAEJ","file":"chunk-TOISBMRE.js","sourcesContent":["import type { ProjectSummary, ProjectUiConfig } from '../../core/config/types';\n\n/** Name of a project: the listed name, else the deployed schema title, else the id. */\nexport function getProjectLabel(\n projectId: string,\n projects: ProjectUiConfig[],\n projectSummaries: ProjectSummary[] = []\n): string {\n return (\n projectSummaries.find((project) => project.id === projectId)?.name ??\n projects.find((project) => project.projectId === projectId)?.title ??\n projectId\n );\n}\n\n/** Groups ids by team when the summaries span more than one team; otherwise a single unnamed group. */\nexport function groupProjectIdsByTeam(\n projectIds: string[],\n projectSummaries: ProjectSummary[]\n): { label: string | null; projectIds: string[] }[] {\n const teams = new Map<string, { label: string; projectIds: string[] }>();\n\n for (const id of projectIds) {\n const summary = projectSummaries.find((project) => project.id === id);\n const key = summary?.team.id ?? '';\n const group = teams.get(key) ?? { label: summary?.team.name ?? '', projectIds: [] };\n group.projectIds.push(id);\n teams.set(key, group);\n }\n\n if (teams.size <= 1) {\n return [{ label: null, projectIds }];\n }\n\n return [...teams.values()].map((group) => ({ label: group.label || null, projectIds: group.projectIds }));\n}\n","import { userApiPaths } from '../api-paths';\nimport { send } from './onboarding';\nimport type { HostedTeam } from './types';\n\n/** What `POST /api/me/projects` answers: the new project and the team it went to (possibly a new personal team). */\nexport type CreatedProject = { project: { id: string; name: string }; team: { id: string; name: string } };\n\nexport type CreateProjectOutcome = ({ ok: true } & CreatedProject) | { ok: false; code: string; message: string };\n\nconst FALLBACK_MESSAGE = 'Could not create the project. Please try again.';\n\n/** Hosted mode: creates a project for the signed-in user (Free plan, user as owner). */\nexport async function createHostedProject(input: { name: string; teamId?: string }): Promise<CreateProjectOutcome> {\n const outcome = await send<Partial<CreatedProject>>(userApiPaths.myProjects, 'POST', input, FALLBACK_MESSAGE);\n\n if (!outcome.ok) {\n return outcome;\n }\n\n if (!outcome.project?.id || !outcome.team?.id) {\n return { ok: false, code: 'unknown_error', message: FALLBACK_MESSAGE };\n }\n\n return { ok: true, project: outcome.project, team: outcome.team };\n}\n\n/** Teams the user may create projects in, in the order `/api/me` lists them (oldest first). */\nexport function ownedTeams(teams: HostedTeam[]): HostedTeam[] {\n return teams.filter((team) => team.role === 'owner');\n}\n\n/**\n * Where a new project opens: the AI chat, which can design its schema. The\n * chat route itself, not `/ai`: that redirect would drop the navigation state\n * carrying the onboarding prompt.\n */\nexport function newProjectPath(projectId: string): string {\n return `/${projectId}/ai/agent`;\n}\n","'use client';\n\nimport useSWR, { mutate } from 'swr';\nimport { userApiPaths } from '../api-paths';\nimport type { CreatedProject } from './create-project';\nimport type { HostedTeam, HostedUser, ProjectSummary } from './types';\n\nexport type HostedSession =\n | { status: 'loading' }\n | { status: 'anonymous' }\n | { status: 'error'; message: string }\n | { status: 'ready'; user: HostedUser; projects: ProjectSummary[]; teams: HostedTeam[] };\n\n/** `teams` is missing from backends older than Studio onboarding. */\ntype MeResponse = { projects: ProjectSummary[]; teams?: HostedTeam[]; user: HostedUser };\n\nconst SESSION_KEY = 'hosted-session';\nexport type MeOutcome =\n | { kind: 'anonymous' }\n | { kind: 'error'; message: string }\n | { kind: 'ready'; data: MeResponse };\n\nasync function fetchMe(): Promise<MeOutcome> {\n try {\n const response = await fetch(userApiPaths.me, { credentials: 'same-origin' });\n\n if (response.status === 401) {\n return { kind: 'anonymous' };\n }\n\n if (!response.ok) {\n return { kind: 'error', message: `Flexkit answered ${String(response.status)} while loading your projects.` };\n }\n\n return { kind: 'ready', data: (await response.json()) as MeResponse };\n } catch (error) {\n return { kind: 'error', message: error instanceof Error ? error.message : 'Flexkit is not reachable.' };\n }\n}\n\nexport function toHostedSession(outcome: MeOutcome | undefined): HostedSession {\n if (!outcome) {\n return { status: 'loading' };\n }\n\n if (outcome.kind === 'anonymous') {\n return { status: 'anonymous' };\n }\n\n if (outcome.kind === 'error') {\n return { status: 'error', message: outcome.message };\n }\n\n return {\n status: 'ready',\n projects: outcome.data.projects,\n teams: outcome.data.teams ?? [],\n user: outcome.data.user,\n };\n}\n\n/**\n * Hosted mode: who is signed in and which projects they can open. Fetched once\n * per page load; `rememberCreatedProject` adds a project the user just created.\n */\nexport function useHostedSession(): HostedSession {\n const { data } = useSWR(SESSION_KEY, fetchMe, {\n revalidateOnFocus: false,\n revalidateOnReconnect: false,\n shouldRetryOnError: false,\n });\n\n return toHostedSession(data);\n}\n\n/** The session with a just-created project (and its team, if new) added; the user owns both. */\nexport function withCreatedProject(outcome: MeOutcome | undefined, created: CreatedProject): MeOutcome | undefined {\n if (outcome?.kind !== 'ready' || outcome.data.projects.some((project) => project.id === created.project.id)) {\n return outcome;\n }\n\n const teams = outcome.data.teams ?? [];\n const project: ProjectSummary = {\n avatarUrl: null,\n id: created.project.id,\n name: created.project.name,\n readOnly: false,\n role: 'owner',\n suspended: false,\n team: created.team,\n };\n\n return {\n kind: 'ready',\n data: {\n ...outcome.data,\n projects: [...outcome.data.projects, project],\n teams: teams.some((team) => team.id === created.team.id) ? teams : [...teams, { ...created.team, role: 'owner' }],\n },\n };\n}\n\n/**\n * Adds a project the user just created to the session, so the Studio can open\n * it at once. No `/api/me` round trip: the create response says everything the\n * session needs, and a failed re-read must not hide a project that exists.\n */\nexport async function rememberCreatedProject(created: CreatedProject): Promise<void> {\n await mutate<MeOutcome>(SESSION_KEY, (current) => withCreatedProject(current, created), { revalidate: false });\n}\n\n/** The session with the signed-in user's new display name. */\nexport function withDisplayName(outcome: MeOutcome | undefined, displayName: string): MeOutcome | undefined {\n if (outcome?.kind !== 'ready') {\n return outcome;\n }\n\n return { kind: 'ready', data: { ...outcome.data, user: { ...outcome.data.user, displayName } } };\n}\n\n/** Shows a display name the user just saved, without re-reading `/api/me`. */\nexport async function rememberDisplayName(displayName: string): Promise<void> {\n await mutate<MeOutcome>(SESSION_KEY, (current) => withDisplayName(current, displayName), { revalidate: false });\n}\n","import { useId, useState, type JSX, type ReactNode } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { Loader2, MessageSquareText, ShoppingBag, Sparkles, type LucideIcon } from 'lucide-react';\nimport { watchStarter } from '../../apps/ai/starter-watch';\nimport {\n createHostedProject,\n newProjectPath,\n ownedTeams,\n type CreateProjectOutcome,\n} from '../../core/config/create-project';\nimport {\n applyStarter,\n describeBusinessPrompt,\n saveDisplayName,\n toProjectStart,\n validateProjectName,\n type OnboardingNavigationState,\n type ProjectStart,\n} from '../../core/config/onboarding';\nimport type { HostedTeam } from '../../core/config/types';\nimport { rememberCreatedProject, rememberDisplayName } from '../../core/config/use-hosted-session';\nimport { cn } from '../lib/utils';\nimport { Alert, AlertDescription } from '../primitives/alert';\nimport { Button } from '../primitives/button';\nimport { Input } from '../primitives/input';\nimport { Label } from '../primitives/label';\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../primitives/select';\nimport { Switch } from '../primitives/switch';\nimport { Textarea } from '../primitives/textarea';\n\ntype Step = 'you' | 'project' | 'start';\ntype StartKind = ProjectStart['kind'];\n\n/**\n * Hosted mode: create a project in at most three short steps. Your name (only\n * when the account has none, e.g. an email sign-up), the project name, and how\n * to start: the commerce starter (schema plus an optional sample store), a\n * description the agent turns into a schema, or an empty project. The project\n * then opens in its AI chat.\n */\nexport function NewProjectFlow({\n askForName = false,\n isFirstProject = false,\n onCancel,\n onCreated,\n teams,\n}: {\n /** Ask for the user's own name first. */\n askForName?: boolean;\n /**\n * The user has no project yet, so the Studio shows this at `/`. Leave `/`\n * before the session lists the project: there, `/` redirects to the project\n * root instead of its AI chat.\n */\n isFirstProject?: boolean;\n onCancel?: () => void;\n /** Called with the new project's id once the Studio opened it. */\n onCreated?: (projectId: string) => void;\n teams: HostedTeam[];\n}): JSX.Element {\n const navigate = useNavigate();\n const ids = { you: useId(), name: useId(), team: useId(), description: useId(), sample: useId() };\n const owned = ownedTeams(teams);\n const [step, setStep] = useState<Step>(askForName ? 'you' : 'project');\n const [displayName, setDisplayName] = useState('');\n const [name, setName] = useState('');\n const [pickedTeamId, setPickedTeamId] = useState<string | null>(null);\n // Follow the teams prop: a pick that is no longer owned falls back to the first owned team.\n const selectedTeamId = owned.some((team) => team.id === pickedTeamId) ? (pickedTeamId ?? '') : (owned[0]?.id ?? '');\n const [startKind, setStartKind] = useState<StartKind>('starter');\n const [sampleData, setSampleData] = useState(true);\n const [description, setDescription] = useState('');\n const [error, setError] = useState<string | null>(null);\n const [isSubmitting, setIsSubmitting] = useState(false);\n // Set once the project exists, so a failed starter is retried on it instead of creating another project.\n const [created, setCreated] = useState<Extract<CreateProjectOutcome, { ok: true }> | null>(null);\n\n async function submitName(): Promise<void> {\n const trimmed = displayName.trim();\n\n if (!trimmed) {\n setError('Tell us your name.');\n\n return;\n }\n\n setError(null);\n setIsSubmitting(true);\n\n const outcome = await saveDisplayName(trimmed);\n\n setIsSubmitting(false);\n\n if (!outcome.ok) {\n setError(outcome.message);\n\n return;\n }\n\n await rememberDisplayName(trimmed);\n setStep('project');\n }\n\n function submitProjectName(): void {\n const invalid = validateProjectName(name);\n\n setError(invalid);\n\n if (!invalid) {\n setStep('start');\n }\n }\n\n async function createProject(): Promise<void> {\n if (startKind === 'describe' && !description.trim()) {\n setError('Describe your business in a sentence or two, or pick another way to start.');\n\n return;\n }\n\n setError(null);\n setIsSubmitting(true);\n\n // No owned team yet: let the backend create the personal team.\n const outcome =\n created ??\n (await createHostedProject({\n name: name.trim(),\n ...(selectedTeamId ? { teamId: selectedTeamId } : {}),\n }));\n\n if (!outcome.ok) {\n setError(outcome.message);\n setIsSubmitting(false);\n\n if (outcome.code === 'invalid_name') {\n setStep('project');\n }\n\n return;\n }\n\n setCreated(outcome);\n\n const projectId = outcome.project.id;\n const start = toProjectStart(startKind, sampleData, description);\n let state: OnboardingNavigationState = {};\n\n if (start.kind === 'starter') {\n const applied = await applyStarter(projectId, { template: start.template, sampleData: start.sampleData });\n\n if (!applied.ok) {\n setError(`${outcome.project.name} was created, but the starter could not be applied: ${applied.message}`);\n setIsSubmitting(false);\n\n // List it now, so closing the dialog does not hide the project until a reload. The welcome screen\n // (first project) would leave this flow once the session lists a project, so it waits for Continue.\n if (!isFirstProject && !created) {\n await rememberCreatedProject(outcome);\n }\n\n return;\n }\n\n watchStarter({ projectId });\n } else if (start.kind === 'describe') {\n state = { onboardingPrompt: describeBusinessPrompt(start.description) };\n }\n\n const path = newProjectPath(projectId);\n\n // Inside a project the Studio only opens ids the session lists, so add it first there.\n if (isFirstProject) {\n navigate(path, { state });\n await rememberCreatedProject(outcome);\n } else {\n await rememberCreatedProject(outcome);\n navigate(path, { state });\n }\n\n onCreated?.(projectId);\n }\n\n const errorAlert = error ? (\n <Alert variant=\"destructive\">\n <AlertDescription>{error}</AlertDescription>\n </Alert>\n ) : null;\n\n if (step === 'you') {\n return (\n <StepForm onSubmit={() => void submitName()}>\n <div className=\"fk:flex fk:flex-col fk:gap-2\">\n <Label htmlFor={ids.you}>Your name</Label>\n <Input\n autoComplete=\"name\"\n autoFocus\n disabled={isSubmitting}\n id={ids.you}\n maxLength={80}\n onChange={(event) => {\n setDisplayName(event.target.value);\n }}\n placeholder=\"e.g. Ann Meyer\"\n value={displayName}\n />\n <p className=\"fk:text-xs fk:text-muted-foreground\">Your teammates see it on changes and comments.</p>\n </div>\n {errorAlert}\n <StepActions isSubmitting={isSubmitting} submitLabel=\"Continue\" />\n </StepForm>\n );\n }\n\n if (step === 'project') {\n return (\n <StepForm onSubmit={submitProjectName}>\n <div className=\"fk:flex fk:flex-col fk:gap-2\">\n <Label htmlFor={ids.name}>Project name</Label>\n <Input\n aria-invalid={error ? true : undefined}\n autoComplete=\"off\"\n autoFocus\n id={ids.name}\n maxLength={48}\n onChange={(event) => {\n setName(event.target.value);\n }}\n placeholder=\"e.g. Aven Living\"\n value={name}\n />\n <p className=\"fk:text-xs fk:text-muted-foreground\">\n Usually your store or company name. You can change it later.\n </p>\n </div>\n {owned.length > 1 ? (\n <div className=\"fk:flex fk:flex-col fk:gap-2\">\n <Label htmlFor={ids.team}>Team</Label>\n <Select onValueChange={setPickedTeamId} value={selectedTeamId}>\n <SelectTrigger id={ids.team}>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {owned.map((team) => (\n <SelectItem key={team.id} value={team.id}>\n {team.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n ) : null}\n {errorAlert}\n <StepActions onCancel={onCancel} submitLabel=\"Continue\" />\n </StepForm>\n );\n }\n\n return (\n <StepForm onSubmit={() => void createProject()}>\n <div className=\"fk:flex fk:flex-col fk:gap-2\">\n <p className=\"fk:text-sm fk:font-medium\" id={`${ids.name}-start`}>\n How do you want to start?\n </p>\n <div aria-labelledby={`${ids.name}-start`} className=\"fk:flex fk:flex-col fk:gap-2\" role=\"radiogroup\">\n <StartOption\n checked={startKind === 'starter'}\n description=\"22 ready-made entities for catalog, inventory, orders, customers and marketing, with EU, UK and US markets.\"\n disabled={isSubmitting}\n icon={ShoppingBag}\n onSelect={() => {\n setStartKind('starter');\n }}\n recommended\n title=\"Commerce starter\"\n >\n <div className=\"fk:flex fk:items-center fk:justify-between fk:gap-3 fk:pt-1\">\n <Label className=\"fk:text-xs fk:font-normal fk:text-muted-foreground\" htmlFor={ids.sample}>\n Add a sample store (Aven Living) to try things out\n </Label>\n <Switch checked={sampleData} disabled={isSubmitting} id={ids.sample} onCheckedChange={setSampleData} />\n </div>\n </StartOption>\n <StartOption\n checked={startKind === 'describe'}\n description=\"Tell the agent what you sell and how you work; it proposes a schema for you to review.\"\n disabled={isSubmitting}\n icon={MessageSquareText}\n onSelect={() => {\n setStartKind('describe');\n }}\n title=\"Describe your business\"\n >\n <Textarea\n aria-label=\"Your business\"\n autoFocus\n disabled={isSubmitting}\n id={ids.description}\n maxLength={2000}\n onChange={(event) => {\n setDescription(event.target.value);\n }}\n placeholder=\"e.g. We sell handmade ceramics online and to 40 shops in Europe, with seasonal collections.\"\n rows={3}\n value={description}\n />\n </StartOption>\n <StartOption\n checked={startKind === 'empty'}\n description=\"Start with an empty project and build the schema in the chat.\"\n disabled={isSubmitting}\n icon={Sparkles}\n onSelect={() => {\n setStartKind('empty');\n }}\n title=\"Start from scratch\"\n />\n </div>\n </div>\n {errorAlert}\n <StepActions\n isSubmitting={isSubmitting}\n onBack={\n created\n ? undefined\n : () => {\n setError(null);\n setStep('project');\n }\n }\n submitLabel={created ? 'Continue' : 'Create project'}\n />\n </StepForm>\n );\n}\n\nfunction StepForm({ children, onSubmit }: { children: ReactNode; onSubmit: () => void }): JSX.Element {\n return (\n <form\n className=\"fk:flex fk:w-full fk:flex-col fk:gap-4\"\n onSubmit={(event) => {\n event.preventDefault();\n onSubmit();\n }}\n >\n {children}\n </form>\n );\n}\n\nfunction StepActions({\n isSubmitting = false,\n onBack,\n onCancel,\n submitLabel,\n}: {\n isSubmitting?: boolean;\n onBack?: () => void;\n onCancel?: () => void;\n submitLabel: string;\n}): JSX.Element {\n const secondary = onBack ?? onCancel;\n\n return (\n <div className=\"fk:flex fk:justify-end fk:gap-2\">\n {secondary ? (\n <Button disabled={isSubmitting} onClick={secondary} type=\"button\" variant=\"outline\">\n {onBack ? 'Back' : 'Cancel'}\n </Button>\n ) : null}\n <Button className={secondary ? undefined : 'fk:w-full'} disabled={isSubmitting} type=\"submit\">\n {isSubmitting ? <Loader2 className=\"fk:h-4 fk:w-4 fk:animate-spin\" /> : null}\n {submitLabel}\n </Button>\n </div>\n );\n}\n\nfunction StartOption({\n checked,\n children,\n description,\n disabled,\n icon: Icon,\n onSelect,\n recommended = false,\n title,\n}: {\n checked: boolean;\n children?: ReactNode;\n description: string;\n disabled: boolean;\n icon: LucideIcon;\n onSelect: () => void;\n recommended?: boolean;\n title: string;\n}): JSX.Element {\n return (\n <div\n className={cn(\n 'fk:rounded-lg fk:border fk:p-3 fk:transition-colors',\n checked\n ? 'fk:border-foreground/70 fk:bg-muted/50 fk:ring-1 fk:ring-foreground/20'\n : 'fk:border-border fk:hover:bg-muted/30'\n )}\n >\n <button\n aria-checked={checked}\n className=\"fk:flex fk:w-full fk:items-start fk:gap-3 fk:text-left fk:disabled:opacity-60\"\n disabled={disabled}\n onClick={onSelect}\n role=\"radio\"\n type=\"button\"\n >\n <Icon className=\"fk:mt-0.5 fk:h-4 fk:w-4 fk:shrink-0 fk:text-muted-foreground\" />\n <span className=\"fk:flex fk:flex-col fk:gap-0.5\">\n <span className=\"fk:flex fk:items-center fk:gap-2 fk:text-sm fk:font-medium\">\n {title}\n {recommended ? (\n <span className=\"fk:rounded-full fk:bg-primary/10 fk:px-2 fk:py-0.5 fk:text-[11px] fk:font-medium fk:text-primary\">\n Recommended\n </span>\n ) : null}\n </span>\n <span className=\"fk:text-xs fk:text-muted-foreground\">{description}</span>\n </span>\n </button>\n {checked && children ? <div className=\"fk:mt-2 fk:pl-7\">{children}</div> : null}\n </div>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/ui/components/project-label.ts","../src/core/config/create-project.ts","../src/core/config/use-hosted-session.ts","../src/ui/components/new-project-flow.tsx"],"names":["getProjectLabel","projectId","projects","projectSummaries","project","groupProjectIdsByTeam","projectIds","teams","id","summary","key","group","FALLBACK_MESSAGE","createHostedProject","input","outcome","send","userApiPaths","ownedTeams","team","newProjectPath","SESSION_KEY","fetchMe","response","error","toHostedSession","useHostedSession","data","useSWR","withCreatedProject","created","rememberCreatedProject","mutate","current","withDisplayName","displayName","rememberDisplayName","NewProjectFlow","askForName","isFirstProject","onCancel","onCreated","navigate","useNavigate","ids","useId","owned","step","setStep","useState","setDisplayName","name","setName","pickedTeamId","setPickedTeamId","selectedTeamId","startKind","setStartKind","sampleData","setSampleData","description","setDescription","setError","isSubmitting","setIsSubmitting","setCreated","submitName","trimmed","saveDisplayName","submitProjectName","invalid","validateProjectName","createProject","start","toProjectStart","state","applied","applyStarter","watchStarter","describeBusinessPrompt","path","errorAlert","jsx","Alert","AlertDescription","jsxs","StepForm","Label","Input","event","StepActions","Select","SelectTrigger","SelectValue","SelectContent","SelectItem","StartOption","ShoppingBag","Switch","MessageSquareText","Textarea","Sparkles","children","onSubmit","onBack","submitLabel","secondary","Button","Loader2","checked","disabled","Icon","onSelect","recommended","title","cn"],"mappings":"khBAGO,SAASA,GACdC,CAAAA,CACAC,CAAAA,CACAC,EAAqC,EAAC,CAC9B,CACR,OACEA,CAAAA,CAAiB,KAAMC,CAAAA,EAAYA,CAAAA,CAAQ,KAAOH,CAAS,CAAA,EAAG,MAC9DC,CAAAA,CAAS,IAAA,CAAME,GAAYA,CAAAA,CAAQ,SAAA,GAAcH,CAAS,CAAA,EAAG,OAC7DA,CAEJ,CAGO,SAASI,EAAAA,CACdC,CAAAA,CACAH,EACkD,CAClD,IAAMI,EAAQ,IAAI,GAAA,CAElB,QAAWC,CAAAA,IAAMF,CAAAA,CAAY,CAC3B,IAAMG,CAAAA,CAAUN,EAAiB,IAAA,CAAMC,CAAAA,EAAYA,CAAAA,CAAQ,EAAA,GAAOI,CAAE,CAAA,CAC9DE,CAAAA,CAAMD,GAAS,IAAA,CAAK,EAAA,EAAM,GAC1BE,CAAAA,CAAQJ,CAAAA,CAAM,IAAIG,CAAG,CAAA,EAAK,CAAE,KAAA,CAAOD,CA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CAAA,CACF,CAAA,CACCiD,GAAWP,CAAAA,CAAWpB,GAAAA,CAAC,OAAI,SAAA,CAAU,iBAAA,CAAmB,SAAAoB,CAAAA,CAAS,CAAA,CAAS,MAC7E,CAEJ","file":"chunk-DFOPVG7I.js","sourcesContent":["import type { ProjectSummary, ProjectUiConfig } from '../../core/config/types';\n\n/** Name of a project: the listed name, else the deployed schema title, else the id. */\nexport function getProjectLabel(\n projectId: string,\n projects: ProjectUiConfig[],\n projectSummaries: ProjectSummary[] = []\n): string {\n return (\n projectSummaries.find((project) => project.id === projectId)?.name ??\n projects.find((project) => project.projectId === projectId)?.title ??\n projectId\n );\n}\n\n/** Groups ids by team when the summaries span more than one team; otherwise a single unnamed group. */\nexport function groupProjectIdsByTeam(\n projectIds: string[],\n projectSummaries: ProjectSummary[]\n): { label: string | null; projectIds: string[] }[] {\n const teams = new Map<string, { label: string; projectIds: string[] }>();\n\n for (const id of projectIds) {\n const summary = projectSummaries.find((project) => project.id === id);\n const key = summary?.team.id ?? '';\n const group = teams.get(key) ?? { label: summary?.team.name ?? '', projectIds: [] };\n group.projectIds.push(id);\n teams.set(key, group);\n }\n\n if (teams.size <= 1) {\n return [{ label: null, projectIds }];\n }\n\n return [...teams.values()].map((group) => ({ label: group.label || null, projectIds: group.projectIds }));\n}\n","import { userApiPaths } from '../api-paths';\nimport { send } from './onboarding';\nimport type { HostedTeam } from './types';\n\n/** What `POST /api/me/projects` answers: the new project and the team it went to (possibly a new personal team). */\nexport type CreatedProject = { project: { id: string; name: string }; team: { id: string; name: string } };\n\nexport type CreateProjectOutcome = ({ ok: true } & CreatedProject) | { ok: false; code: string; message: string };\n\nconst FALLBACK_MESSAGE = 'Could not create the project. Please try again.';\n\n/** Hosted mode: creates a project for the signed-in user (Free plan, user as owner). */\nexport async function createHostedProject(input: { name: string; teamId?: string }): Promise<CreateProjectOutcome> {\n const outcome = await send<Partial<CreatedProject>>(userApiPaths.myProjects, 'POST', input, FALLBACK_MESSAGE);\n\n if (!outcome.ok) {\n return outcome;\n }\n\n if (!outcome.project?.id || !outcome.team?.id) {\n return { ok: false, code: 'unknown_error', message: FALLBACK_MESSAGE };\n }\n\n return { ok: true, project: outcome.project, team: outcome.team };\n}\n\n/** Teams the user may create projects in, in the order `/api/me` lists them (oldest first). */\nexport function ownedTeams(teams: HostedTeam[]): HostedTeam[] {\n return teams.filter((team) => team.role === 'owner');\n}\n\n/**\n * Where a new project opens: the AI chat, which can design its schema. The\n * chat route itself, not `/ai`: that redirect would drop the navigation state\n * carrying the onboarding prompt.\n */\nexport function newProjectPath(projectId: string): string {\n return `/${projectId}/ai/agent`;\n}\n","'use client';\n\nimport useSWR, { mutate } from 'swr';\nimport { userApiPaths } from '../api-paths';\nimport type { CreatedProject } from './create-project';\nimport type { HostedTeam, HostedUser, ProjectSummary } from './types';\n\nexport type HostedSession =\n | { status: 'loading' }\n | { status: 'anonymous' }\n | { status: 'error'; message: string }\n | { status: 'ready'; user: HostedUser; projects: ProjectSummary[]; teams: HostedTeam[] };\n\n/** `teams` is missing from backends older than Studio onboarding. */\ntype MeResponse = { projects: ProjectSummary[]; teams?: HostedTeam[]; user: HostedUser };\n\nconst SESSION_KEY = 'hosted-session';\nexport type MeOutcome =\n | { kind: 'anonymous' }\n | { kind: 'error'; message: string }\n | { kind: 'ready'; data: MeResponse };\n\nasync function fetchMe(): Promise<MeOutcome> {\n try {\n const response = await fetch(userApiPaths.me, { credentials: 'same-origin' });\n\n if (response.status === 401) {\n return { kind: 'anonymous' };\n }\n\n if (!response.ok) {\n return { kind: 'error', message: `Flexkit answered ${String(response.status)} while loading your projects.` };\n }\n\n return { kind: 'ready', data: (await response.json()) as MeResponse };\n } catch (error) {\n return { kind: 'error', message: error instanceof Error ? error.message : 'Flexkit is not reachable.' };\n }\n}\n\nexport function toHostedSession(outcome: MeOutcome | undefined): HostedSession {\n if (!outcome) {\n return { status: 'loading' };\n }\n\n if (outcome.kind === 'anonymous') {\n return { status: 'anonymous' };\n }\n\n if (outcome.kind === 'error') {\n return { status: 'error', message: outcome.message };\n }\n\n return {\n status: 'ready',\n projects: outcome.data.projects,\n teams: outcome.data.teams ?? [],\n user: outcome.data.user,\n };\n}\n\n/**\n * Hosted mode: who is signed in and which projects they can open. Fetched once\n * per page load; `rememberCreatedProject` adds a project the user just created.\n */\nexport function useHostedSession(): HostedSession {\n const { data } = useSWR(SESSION_KEY, fetchMe, {\n revalidateOnFocus: false,\n revalidateOnReconnect: false,\n shouldRetryOnError: false,\n });\n\n return toHostedSession(data);\n}\n\n/** The session with a just-created project (and its team, if new) added; the user owns both. */\nexport function withCreatedProject(outcome: MeOutcome | undefined, created: CreatedProject): MeOutcome | undefined {\n if (outcome?.kind !== 'ready' || outcome.data.projects.some((project) => project.id === created.project.id)) {\n return outcome;\n }\n\n const teams = outcome.data.teams ?? [];\n const project: ProjectSummary = {\n avatarUrl: null,\n id: created.project.id,\n name: created.project.name,\n readOnly: false,\n role: 'owner',\n suspended: false,\n team: created.team,\n };\n\n return {\n kind: 'ready',\n data: {\n ...outcome.data,\n projects: [...outcome.data.projects, project],\n teams: teams.some((team) => team.id === created.team.id) ? teams : [...teams, { ...created.team, role: 'owner' }],\n },\n };\n}\n\n/**\n * Adds a project the user just created to the session, so the Studio can open\n * it at once. No `/api/me` round trip: the create response says everything the\n * session needs, and a failed re-read must not hide a project that exists.\n */\nexport async function rememberCreatedProject(created: CreatedProject): Promise<void> {\n await mutate<MeOutcome>(SESSION_KEY, (current) => withCreatedProject(current, created), { revalidate: false });\n}\n\n/** The session with the signed-in user's new display name. */\nexport function withDisplayName(outcome: MeOutcome | undefined, displayName: string): MeOutcome | undefined {\n if (outcome?.kind !== 'ready') {\n return outcome;\n }\n\n return { kind: 'ready', data: { ...outcome.data, user: { ...outcome.data.user, displayName } } };\n}\n\n/** Shows a display name the user just saved, without re-reading `/api/me`. */\nexport async function rememberDisplayName(displayName: string): Promise<void> {\n await mutate<MeOutcome>(SESSION_KEY, (current) => withDisplayName(current, displayName), { revalidate: false });\n}\n","import { useId, useState, type JSX, type ReactNode } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { Loader2, MessageSquareText, ShoppingBag, Sparkles, type LucideIcon } from 'lucide-react';\nimport { watchStarter } from '../../apps/ai/starter-watch';\nimport {\n createHostedProject,\n newProjectPath,\n ownedTeams,\n type CreateProjectOutcome,\n} from '../../core/config/create-project';\nimport {\n applyStarter,\n describeBusinessPrompt,\n saveDisplayName,\n toProjectStart,\n validateProjectName,\n type OnboardingNavigationState,\n type ProjectStart,\n} from '../../core/config/onboarding';\nimport type { HostedTeam } from '../../core/config/types';\nimport { rememberCreatedProject, rememberDisplayName } from '../../core/config/use-hosted-session';\nimport { cn } from '../lib/utils';\nimport { Alert, AlertDescription } from '../primitives/alert';\nimport { Button } from '../primitives/button';\nimport { Input } from '../primitives/input';\nimport { Label } from '../primitives/label';\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../primitives/select';\nimport { Switch } from '../primitives/switch';\nimport { Textarea } from '../primitives/textarea';\n\ntype Step = 'you' | 'project' | 'start';\ntype StartKind = ProjectStart['kind'];\n\n/**\n * Hosted mode: create a project in at most three short steps. Your name (only\n * when the account has none, e.g. an email sign-up), the project name, and how\n * to start: the commerce starter (schema plus an optional sample store), a\n * description the agent turns into a schema, or an empty project. The project\n * then opens in its AI chat.\n */\nexport function NewProjectFlow({\n askForName = false,\n isFirstProject = false,\n onCancel,\n onCreated,\n teams,\n}: {\n /** Ask for the user's own name first. */\n askForName?: boolean;\n /**\n * The user has no project yet, so the Studio shows this at `/`. Leave `/`\n * before the session lists the project: there, `/` redirects to the project\n * root instead of its AI chat.\n */\n isFirstProject?: boolean;\n onCancel?: () => void;\n /** Called with the new project's id once the Studio opened it. */\n onCreated?: (projectId: string) => void;\n teams: HostedTeam[];\n}): JSX.Element {\n const navigate = useNavigate();\n const ids = { you: useId(), name: useId(), team: useId(), description: useId(), sample: useId() };\n const owned = ownedTeams(teams);\n const [step, setStep] = useState<Step>(askForName ? 'you' : 'project');\n const [displayName, setDisplayName] = useState('');\n const [name, setName] = useState('');\n const [pickedTeamId, setPickedTeamId] = useState<string | null>(null);\n // Follow the teams prop: a pick that is no longer owned falls back to the first owned team.\n const selectedTeamId = owned.some((team) => team.id === pickedTeamId) ? (pickedTeamId ?? '') : (owned[0]?.id ?? '');\n const [startKind, setStartKind] = useState<StartKind>('starter');\n const [sampleData, setSampleData] = useState(true);\n const [description, setDescription] = useState('');\n const [error, setError] = useState<string | null>(null);\n const [isSubmitting, setIsSubmitting] = useState(false);\n // Set once the project exists, so a failed starter is retried on it instead of creating another project.\n const [created, setCreated] = useState<Extract<CreateProjectOutcome, { ok: true }> | null>(null);\n\n async function submitName(): Promise<void> {\n const trimmed = displayName.trim();\n\n if (!trimmed) {\n setError('Tell us your name.');\n\n return;\n }\n\n setError(null);\n setIsSubmitting(true);\n\n const outcome = await saveDisplayName(trimmed);\n\n setIsSubmitting(false);\n\n if (!outcome.ok) {\n setError(outcome.message);\n\n return;\n }\n\n await rememberDisplayName(trimmed);\n setStep('project');\n }\n\n function submitProjectName(): void {\n const invalid = validateProjectName(name);\n\n setError(invalid);\n\n if (!invalid) {\n setStep('start');\n }\n }\n\n async function createProject(): Promise<void> {\n if (startKind === 'describe' && !description.trim()) {\n setError('Describe your business in a sentence or two, or pick another way to start.');\n\n return;\n }\n\n setError(null);\n setIsSubmitting(true);\n\n // No owned team yet: let the backend create the personal team.\n const outcome =\n created ??\n (await createHostedProject({\n name: name.trim(),\n ...(selectedTeamId ? { teamId: selectedTeamId } : {}),\n }));\n\n if (!outcome.ok) {\n setError(outcome.message);\n setIsSubmitting(false);\n\n if (outcome.code === 'invalid_name') {\n setStep('project');\n }\n\n return;\n }\n\n setCreated(outcome);\n\n const projectId = outcome.project.id;\n const start = toProjectStart(startKind, sampleData, description);\n let state: OnboardingNavigationState = {};\n\n if (start.kind === 'starter') {\n const applied = await applyStarter(projectId, { template: start.template, sampleData: start.sampleData });\n\n if (!applied.ok) {\n setError(`${outcome.project.name} was created, but the starter could not be applied: ${applied.message}`);\n setIsSubmitting(false);\n\n // List it now, so closing the dialog does not hide the project until a reload. The welcome screen\n // (first project) would leave this flow once the session lists a project, so it waits for Continue.\n if (!isFirstProject && !created) {\n await rememberCreatedProject(outcome);\n }\n\n return;\n }\n\n watchStarter({ projectId });\n } else if (start.kind === 'describe') {\n state = { onboardingPrompt: describeBusinessPrompt(start.description) };\n }\n\n const path = newProjectPath(projectId);\n\n // Inside a project the Studio only opens ids the session lists, so add it first there.\n if (isFirstProject) {\n navigate(path, { state });\n await rememberCreatedProject(outcome);\n } else {\n await rememberCreatedProject(outcome);\n navigate(path, { state });\n }\n\n onCreated?.(projectId);\n }\n\n const errorAlert = error ? (\n <Alert variant=\"destructive\">\n <AlertDescription>{error}</AlertDescription>\n </Alert>\n ) : null;\n\n if (step === 'you') {\n return (\n <StepForm onSubmit={() => void submitName()}>\n <div className=\"fk:flex fk:flex-col fk:gap-2\">\n <Label htmlFor={ids.you}>Your name</Label>\n <Input\n autoComplete=\"name\"\n autoFocus\n disabled={isSubmitting}\n id={ids.you}\n maxLength={80}\n onChange={(event) => {\n setDisplayName(event.target.value);\n }}\n placeholder=\"e.g. Ann Meyer\"\n value={displayName}\n />\n <p className=\"fk:text-xs fk:text-muted-foreground\">Your teammates see it on changes and comments.</p>\n </div>\n {errorAlert}\n <StepActions isSubmitting={isSubmitting} submitLabel=\"Continue\" />\n </StepForm>\n );\n }\n\n if (step === 'project') {\n return (\n <StepForm onSubmit={submitProjectName}>\n <div className=\"fk:flex fk:flex-col fk:gap-2\">\n <Label htmlFor={ids.name}>Project name</Label>\n <Input\n aria-invalid={error ? true : undefined}\n autoComplete=\"off\"\n autoFocus\n id={ids.name}\n maxLength={48}\n onChange={(event) => {\n setName(event.target.value);\n }}\n placeholder=\"e.g. Aven Living\"\n value={name}\n />\n <p className=\"fk:text-xs fk:text-muted-foreground\">\n Usually your store or company name. You can change it later.\n </p>\n </div>\n {owned.length > 1 ? (\n <div className=\"fk:flex fk:flex-col fk:gap-2\">\n <Label htmlFor={ids.team}>Team</Label>\n <Select onValueChange={setPickedTeamId} value={selectedTeamId}>\n <SelectTrigger id={ids.team}>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {owned.map((team) => (\n <SelectItem key={team.id} value={team.id}>\n {team.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n ) : null}\n {errorAlert}\n <StepActions onCancel={onCancel} submitLabel=\"Continue\" />\n </StepForm>\n );\n }\n\n return (\n <StepForm onSubmit={() => void createProject()}>\n <div className=\"fk:flex fk:flex-col fk:gap-2\">\n <p className=\"fk:text-sm fk:font-medium\" id={`${ids.name}-start`}>\n How do you want to start?\n </p>\n <div aria-labelledby={`${ids.name}-start`} className=\"fk:flex fk:flex-col fk:gap-2\" role=\"radiogroup\">\n <StartOption\n checked={startKind === 'starter'}\n description=\"22 ready-made entities for catalog, inventory, orders, customers and marketing, with EU, UK and US markets.\"\n disabled={isSubmitting}\n icon={ShoppingBag}\n onSelect={() => {\n setStartKind('starter');\n }}\n recommended\n title=\"Commerce starter\"\n >\n <div className=\"fk:flex fk:items-center fk:justify-between fk:gap-3 fk:pt-1\">\n <Label className=\"fk:text-xs fk:font-normal fk:text-muted-foreground\" htmlFor={ids.sample}>\n Add a sample store (Aven Living) to try things out\n </Label>\n <Switch checked={sampleData} disabled={isSubmitting} id={ids.sample} onCheckedChange={setSampleData} />\n </div>\n </StartOption>\n <StartOption\n checked={startKind === 'describe'}\n description=\"Tell the agent what you sell and how you work; it proposes a schema for you to review.\"\n disabled={isSubmitting}\n icon={MessageSquareText}\n onSelect={() => {\n setStartKind('describe');\n }}\n title=\"Describe your business\"\n >\n <Textarea\n aria-label=\"Your business\"\n autoFocus\n disabled={isSubmitting}\n id={ids.description}\n maxLength={2000}\n onChange={(event) => {\n setDescription(event.target.value);\n }}\n placeholder=\"e.g. We sell handmade ceramics online and to 40 shops in Europe, with seasonal collections.\"\n rows={3}\n value={description}\n />\n </StartOption>\n <StartOption\n checked={startKind === 'empty'}\n description=\"Start with an empty project and build the schema in the chat.\"\n disabled={isSubmitting}\n icon={Sparkles}\n onSelect={() => {\n setStartKind('empty');\n }}\n title=\"Start from scratch\"\n />\n </div>\n </div>\n {errorAlert}\n <StepActions\n isSubmitting={isSubmitting}\n onBack={\n created\n ? undefined\n : () => {\n setError(null);\n setStep('project');\n }\n }\n submitLabel={created ? 'Continue' : 'Create project'}\n />\n </StepForm>\n );\n}\n\nfunction StepForm({ children, onSubmit }: { children: ReactNode; onSubmit: () => void }): JSX.Element {\n return (\n <form\n className=\"fk:flex fk:w-full fk:flex-col fk:gap-4\"\n onSubmit={(event) => {\n event.preventDefault();\n onSubmit();\n }}\n >\n {children}\n </form>\n );\n}\n\nfunction StepActions({\n isSubmitting = false,\n onBack,\n onCancel,\n submitLabel,\n}: {\n isSubmitting?: boolean;\n onBack?: () => void;\n onCancel?: () => void;\n submitLabel: string;\n}): JSX.Element {\n const secondary = onBack ?? onCancel;\n\n return (\n <div className=\"fk:flex fk:justify-end fk:gap-2\">\n {secondary ? (\n <Button disabled={isSubmitting} onClick={secondary} type=\"button\" variant=\"outline\">\n {onBack ? 'Back' : 'Cancel'}\n </Button>\n ) : null}\n <Button className={secondary ? undefined : 'fk:w-full'} disabled={isSubmitting} type=\"submit\">\n {isSubmitting ? <Loader2 className=\"fk:h-4 fk:w-4 fk:animate-spin\" /> : null}\n {submitLabel}\n </Button>\n </div>\n );\n}\n\nfunction StartOption({\n checked,\n children,\n description,\n disabled,\n icon: Icon,\n onSelect,\n recommended = false,\n title,\n}: {\n checked: boolean;\n children?: ReactNode;\n description: string;\n disabled: boolean;\n icon: LucideIcon;\n onSelect: () => void;\n recommended?: boolean;\n title: string;\n}): JSX.Element {\n return (\n <div\n className={cn(\n 'fk:rounded-lg fk:border fk:p-3 fk:transition-colors',\n checked\n ? 'fk:border-foreground/70 fk:bg-muted/50 fk:ring-1 fk:ring-foreground/20'\n : 'fk:border-border fk:hover:bg-muted/30'\n )}\n >\n <button\n aria-checked={checked}\n className=\"fk:flex fk:w-full fk:items-start fk:gap-3 fk:text-left fk:disabled:opacity-60\"\n disabled={disabled}\n onClick={onSelect}\n role=\"radio\"\n type=\"button\"\n >\n <Icon className=\"fk:mt-0.5 fk:h-4 fk:w-4 fk:shrink-0 fk:text-muted-foreground\" />\n <span className=\"fk:flex fk:flex-col fk:gap-0.5\">\n <span className=\"fk:flex fk:items-center fk:gap-2 fk:text-sm fk:font-medium\">\n {title}\n {recommended ? (\n <span className=\"fk:rounded-full fk:bg-primary/10 fk:px-2 fk:py-0.5 fk:text-[11px] fk:font-medium fk:text-primary\">\n Recommended\n </span>\n ) : null}\n </span>\n <span className=\"fk:text-xs fk:text-muted-foreground\">{description}</span>\n </span>\n </button>\n {checked && children ? <div className=\"fk:mt-2 fk:pl-7\">{children}</div> : null}\n </div>\n );\n}\n"]}
@@ -1,2 +1,2 @@
1
- import'./index.css';import {a}from'./chunk-QSTWBKPN.js';import {a as a$1,d}from'./chunk-L5Z56DDM.js';import {f,d as d$2}from'./chunk-PLCI2RJA.js';import {f as f$1}from'./chunk-TP6QGIJH.js';import {M,ea,fa,ga,ma,o,p,q as q$1}from'./chunk-RULCANNM.js';import {e,g,h,i,j,t,d as d$1,a as a$2,b as b$3,c as c$2,o as o$1}from'./chunk-A4DPLZZF.js';import {e as e$2,g as g$1,b as b$2}from'./chunk-G5N6HEPW.js';import {m,b as b$1}from'./chunk-5JUG4BEF.js';import {b,c as c$1,e as e$1}from'./chunk-N33S7BSG.js';import {c}from'./chunk-X3SHNHHM.js';import {useState,useMemo,useRef,useEffect}from'react';import {useNavigate,useLocation,useParams,Link}from'react-router-dom';import q,{useSWRConfig}from'swr';import {Plug,ArrowLeft,ExternalLink,RefreshCw,ChevronLeft,ChevronRight,Plus,CheckIcon,XIcon,MoreHorizontal,TriangleAlert}from'lucide-react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function Re(n){let a;try{a=new URL(n);}catch{return null}return a.protocol!=="https:"||a.username!==""||a.password!==""?null:a.href}function xe(){let{currentProjectId:n}=f$1();return {api:useMemo(()=>n?d$2(n):null,[n]),base:n?`/api/flexkit/${n}`:null}}function Ee(n){return n.length===2?"Project & Personal":n[0]==="project"?"Project":"Personal"}function ze(n){return n.length===2?"fk:bg-indigo-100 fk:text-indigo-800 fk:dark:bg-indigo-950 fk:dark:text-indigo-300":n[0]==="project"?"fk:bg-sky-100 fk:text-sky-800 fk:dark:bg-sky-950 fk:dark:text-sky-300":"fk:bg-teal-100 fk:text-teal-800 fk:dark:bg-teal-950 fk:dark:text-teal-300"}function T(n){return n.connections.length>0}function Ie(n){return n==="project"?"Project":"Personal"}function z(n,a,t){return t==="personal"?n.allowPersonal:a}function he(n,a){return n.connections.filter(t=>t.scope===a).sort((t,s)=>Number(s.isPrimary)-Number(t.isPrimary)||t.createdAt.localeCompare(s.createdAt))}function $e(n){let a=n.connections.filter(t=>t.isPrimary&&t.status==="connected");return a.find(t=>t.scope==="personal")??a.find(t=>t.scope==="project")??null}function je({busy:n,canManage:a,plugin:t,onConnect:s}){let i$1=t.scopes.filter(k=>he(t,k).length===0),[f]=i$1;if(!f)return null;if(t.scopes.length===1)return jsxs(c,{disabled:n||!t.enabled||!z(t,a,f),size:"sm",type:"button",onClick:()=>s(f),children:[jsx(Plug,{}),"Connect"]});let m=i$1.some(k=>z(t,a,k));return jsxs(e,{children:[jsx(g,{asChild:true,children:jsxs(c,{disabled:n||!t.enabled||!m,size:"sm",type:"button",children:[jsx(Plug,{}),"Connect"]})}),jsx(h,{align:"end",className:"fk:w-72",children:jsx(i,{children:i$1.map(k=>jsx(j,{disabled:!z(t,a,k),onSelect:()=>s(k),children:jsxs("span",{className:"fk:flex fk:flex-col fk:gap-0.5",children:[jsx("span",{children:Ie(k)}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:k==="personal"?"Only you can use this connection in this project.":"Shared with project members who can use this plugin."})]})},k))})})]})}function S(n,a){let t=/^(.*\/ai)(?:\/|$)/.exec(n);return t?`${t[1]}/${a}`:a}function H(n){return n.split(/[\s_-]+/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function Be(n){let a={};for(let t of n){let s=a[t.category];if(s){s.push(t);continue}a[t.category]=[t];}return Object.entries(a).sort(([t],[s])=>H(t).localeCompare(H(s))).map(([t,s])=>({category:t,plugins:s}))}var ce=[{id:"first",rows:[{descriptionWidth:"fk:w-44",id:"first-a",nameWidth:"fk:w-24"},{descriptionWidth:"fk:w-52",id:"first-b",nameWidth:"fk:w-16"},{descriptionWidth:"fk:w-40",id:"first-c",nameWidth:"fk:w-28"},{descriptionWidth:"fk:w-48",id:"first-d",nameWidth:"fk:w-20"}]},{id:"second",rows:[{descriptionWidth:"fk:w-36",id:"second-a",nameWidth:"fk:w-32"},{descriptionWidth:"fk:w-56",id:"second-b",nameWidth:"fk:w-24"}]}];function ke({action:n,row:a}){return 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 ${a.nameWidth}`}),jsx(t,{className:`fk:h-4 ${a.descriptionWidth}`})]}),n?jsx(t,{className:"fk:size-4 fk:shrink-0"}):null]})}var K="fk:grid fk:grid-cols-1 fk:gap-x-16 fk:gap-y-1 fk:lg:grid-cols-2";function We({grouped:n=true}){let a=ce.flatMap(t=>t.rows);return n?jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-8",children:[jsx("span",{className:"fk:sr-only",children:"Loading plugins"}),ce.map(t$1=>jsxs("section",{children:[jsx(t,{className:"fk:mb-1 fk:h-4 fk:w-28"}),jsx("div",{className:K,children:t$1.rows.map(s=>jsx(ke,{action:true,row:s},s.id))})]},t$1.id))]}):jsxs("div",{"aria-busy":"true",className:K,children:[jsx("span",{className:"fk:sr-only",children:"Loading plugins"}),a.map(t=>jsx(ke,{action:true,row:t},t.id))]})}function Ue(){let n=useNavigate(),{pathname:a}=useLocation(),t=/\/ai\/plugins\/?$/.test(a),s=a.includes("/ai/skills");return jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b,{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(ea,{value:s?"skills":"plugins",onValueChange:f=>{let m=f==="skills"?"skills":"plugins";(f==="skills"?s:t)||n(S(a,m));},children:jsxs(fa,{children:[jsx(ga,{value:"plugins",onClick:()=>{t||n(S(a,"plugins"));},children:"Plugins"}),jsx(ga,{value:"skills",children:"Skills"})]})})]})}function Xe({onOpen:n,plugin:a$1}){let t=T(a$1),s=a$1.connections.filter(f=>f.status==="needs_auth").length,i=s===1?"An account needs to be reconnected":`${s.toString()} accounts need to be reconnected`;return jsxs("button",{type:"button",onClick:n,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(a,{className:"fk:size-10 fk:rounded-lg",src:a$1.logoUrl}),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:a$1.name}),jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:text-muted-foreground",children:a$1.description})]}),s>0?jsxs(b,{children:[jsx(c$1,{asChild:true,children:jsxs("span",{className:"fk:flex fk:shrink-0",children:[jsx(TriangleAlert,{"aria-hidden":true,className:"fk:size-4 fk:text-destructive"}),jsx("span",{className:"fk:sr-only",children:i})]})}),jsx(e$1,{children:i})]}):t?jsx(CheckIcon,{className:"fk:size-4 fk:shrink-0 fk:text-success"}):jsx(Plus,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"})]})}function ue({onOpen:n,plugins:a}){return jsx("div",{className:K,children:a.map(t=>jsx(Xe,{plugin:t,onOpen:()=>n(t.id)},t.id))})}function be({installedOnly:n=false}){let{base:a}=xe(),{data:t$1,error:s,isLoading:i}=q(a?`${a}/plugins`:null,f),[f$1,m$1]=useState(""),k=useNavigate(),{pathname:p}=useLocation(),x=f$1.trim().toLowerCase(),l=(t$1?.plugins??[]).filter(c=>(!n||T(c))&&`${c.name} ${c.description}`.toLowerCase().includes(x)),b=(t$1?.plugins??[]).filter(T),u=n?[]:Be(l),g="Plugins are being prepared. Check back soon.";n&&!x?g="No plugins installed yet.":(t$1?.catalogSha||n)&&(g="No plugins match your search.");function M(c){k(S(p,`plugins/${c}`));}let r=jsx("div",{className:"fk:flex fk:flex-col fk:gap-8",children:u.map(c=>jsxs("section",{children:[jsx("h3",{className:"fk:mb-1 fk:text-sm fk:font-medium",children:H(c.category)}),jsx(ue,{plugins:c.plugins,onOpen:M})]},c.category))});return n&&(r=jsx(ue,{plugins:l,onOpen:M})),(i||s||l.length===0)&&(r=null),jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsx(Ue,{}),jsx(m,{className:"fk:h-0 fk:min-h-0 fk:flex-1",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:"Plugins"}),jsx("p",{className:"fk:mt-2 fk:text-muted-foreground",children:"Connect the tools you use and add skills to your workflows."})]}),jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:[jsx(b$2,{"aria-label":"Search plugins",className:"fk:mr-auto fk:w-full fk:max-w-xs",placeholder:"Search plugins\u2026",value:f$1,onChange:c=>m$1(c.target.value)}),!n&&i?jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[jsx("div",{className:"fk:flex fk:-space-x-2",children:["installed-a","installed-b","installed-c"].map(c=>jsx(t,{className:"fk:size-8 fk:rounded-md fk:ring-2 fk:ring-background"},c))}),jsx(t,{className:"fk:h-4 fk:w-20"})]}):null,!n&&!i&&b.length>0?jsx(d$1,{children:b.slice(0,9).map(c=>jsxs(a$2,{className:"fk:rounded-md",children:[jsx(b$3,{src:c.logoUrl,alt:""}),jsx(c$2,{children:c.name.charAt(0)})]},c.id))}):null,n?jsxs(Link,{to:S(p,"plugins"),className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground",children:[jsx(ChevronLeft,{className:"fk:size-4"}),"Show all"]}):null,!n&&!i?jsxs(Link,{to:S(p,"plugins/installed"),className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground",children:[b.length," installed",jsx(ChevronRight,{className:"fk:size-4"})]}):null]}),s?jsx(e$2,{variant:"destructive",children:jsx(g$1,{children:"Unable to load plugins. Please try again."})}):null,i?jsx(We,{grouped:!n}):null,!i&&!s&&l.length===0?jsx(e$2,{children:jsx(g$1,{children:g})}):null,r]})})]})}function on(){return jsx(be,{})}function sn(){return jsx(be,{installedOnly:true})}function Je({base:n,connectionId:a}){let{data:t$1,error:s}=q(`${n}/plugin-connections/${a}/tools`,f);return s?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Unable to discover tools. Reconnect or try again."}):t$1?jsx("div",{className:"fk:flex fk:flex-col fk:gap-3",children:t$1.servers.map(i=>jsxs("section",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("h4",{className:"fk:font-medium",children:i.name}),i.error?jsx("p",{children:i.error}):null,i.tools.length>0?jsxs(o,{className:"fk:group",children:[jsxs(p,{className:"fk:flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground",children:[jsx(ChevronRight,{className:"fk:size-4 fk:transition-transform fk:group-data-[state=open]:rotate-90"}),_e(i.tools.length)]}),jsx(q$1,{children:jsx("ul",{className:"fk:mt-2 fk:flex fk:flex-col fk:gap-2",children:i.tools.map(f=>jsxs("li",{children:[jsx("span",{className:"fk:text-sm fk:font-medium",children:f.name}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:f.description})]},f.name))})})]}):null]},i.name))}):jsx(t,{className:"fk:h-12 fk:w-full"})}function _e(n){return n===1?"1 tool":`${n.toString()} tools`}function Ge(n){return n.accountName&&n.accountName!==n.displayName?n.accountName:n.scope==="project"?"Shared with this project":"Only you can use this account"}function Fe({actionable:n,actions:a,busy:t,connection:s,pluginEnabled:i$1}){let[f,m]=useState(false),[k,p]=useState(""),x=useRef(null),l=s.status==="needs_auth",b=async()=>{let u=k.trim();await a.onRename(s,u||null),m(false);};return useEffect(()=>{if(!f)return;let u=window.setTimeout(()=>x.current?.focus(),0);return ()=>window.clearTimeout(u)},[f]),jsxs("li",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:py-2",children:[jsx(a$2,{className:"fk:size-8",children:jsx(c$2,{children:s.displayName.charAt(0).toUpperCase()})}),f?jsxs("form",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:items-center fk:gap-2",onSubmit:u=>{u.preventDefault(),b();},children:[jsx(b$2,{"aria-label":"Account name",ref:x,className:"fk:h-8 fk:max-w-xs",disabled:t,placeholder:s.accountName??"Account name",value:k,onChange:u=>p(u.target.value),onKeyDown:u=>{u.key==="Escape"&&m(false);}}),jsx(c,{"aria-label":"Save name",disabled:t,size:"icon",type:"submit",variant:"ghost",children:jsx(CheckIcon,{})}),jsx(c,{"aria-label":"Cancel rename",size:"icon",type:"button",variant:"ghost",onClick:()=>m(false),children:jsx(XIcon,{})})]}):jsxs("span",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col",children:[jsxs("span",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-2",children:[jsx("span",{className:"fk:truncate fk:text-sm fk:font-medium",children:s.displayName}),s.isPrimary?jsx(b$1,{variant:"secondary",children:"Primary"}):null,l?jsx(b$1,{variant:"destructive",children:"Needs reconnect"}):null]}),jsx("span",{className:"fk:truncate fk:text-sm fk:text-muted-foreground",children:Ge(s)})]}),n&&!f?jsxs(e,{children:[jsx(g,{asChild:true,children:jsx(c,{"aria-label":`Manage ${s.displayName}`,disabled:t,size:"icon",variant:"ghost",children:jsx(MoreHorizontal,{})})}),jsxs(h,{align:"end",children:[jsxs(i,{children:[!s.isPrimary&&!l?jsx(j,{onSelect:()=>a.onMakePrimary(s),children:"Make primary"}):null,jsx(j,{onSelect:()=>{p(s.label??""),m(true);},children:"Rename"}),jsx(j,{disabled:!i$1,onSelect:()=>a.onReconnect(s),children:"Reconnect"})]}),jsx(o$1,{}),jsx(j,{variant:"destructive",onSelect:()=>a.onDisconnect(s),children:"Disconnect"})]})]}):null]})}function He({actions:n,busy:a,canManage:t,onConnect:s,plugin:i}){let f=i.scopes.length>1;return jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Connected accounts"}),i.scopes.map(m=>{let k=he(i,m),p=z(i,t,m),x=m==="personal"||t;return k.length===0&&!p?null:jsxs("div",{className:"fk:flex fk:flex-col",children:[f?jsx("h3",{className:"fk:text-sm fk:font-medium fk:text-muted-foreground",children:m==="project"?"Project accounts":"Your accounts"}):null,jsxs("ul",{className:"fk:flex fk:flex-col fk:divide-y",children:[k.map(l=>jsx(Fe,{actionable:x,actions:n,busy:a,connection:l,pluginEnabled:i.enabled},l.id)),p?jsx("li",{children:jsxs("button",{className:"fk:flex fk:w-full fk:items-center fk:gap-3 fk:py-2 fk:text-left fk:text-sm fk:text-muted-foreground fk:transition-colors fk:hover:text-foreground fk:disabled:pointer-events-none fk:disabled:opacity-50",disabled:a||!i.enabled,type:"button",onClick:()=>s(m),children:[jsx("span",{className:"fk:flex fk:size-8 fk:shrink-0 fk:items-center fk:justify-center fk:rounded-full fk:border fk:border-dashed",children:jsx(Plus,{className:"fk:size-4"})}),k.length>0?"Connect another account":"Connect an account"]})}):null]})]},m)})]})}function ln(){let{pluginId:n}=useParams(),{api:a$2,base:t$1}=xe(),{data:s,error:i,mutate:f$1}=q(t$1&&n?`${t$1}/plugins/${n}`:null,f),{mutate:m$1}=useSWRConfig(),k=useNavigate(),[p,x]=useState(false),l=s?.plugin,b$2=l?Re(l.sourceUrl):null,u=async r=>{x(true);try{await r(),await f$1();}catch(c){if(c instanceof a$1){ma.error('You signed in with a different account. Use "Connect another account" to add it.');return}ma.error(c instanceof Error?c.message:"Unable to complete this action.");}finally{x(false);}};if(i)return jsx("div",{className:"fk:p-6",children:jsx(e$2,{variant:"destructive",children:jsx(g$1,{children:"Unable to load this plugin."})})});if(!l||!s||!a$2||!t$1)return jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b,{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"})]}),jsxs(c,{variant:"ghost",size:"sm",onClick:()=>k("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(m,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{"aria-busy":"true",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:[jsx("span",{className:"fk:sr-only",children:"Loading plugin"}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-4",children:[jsx(t,{className:"fk:size-14 fk:shrink-0 fk:rounded-lg"}),jsx(t,{className:"fk:h-7 fk:w-40"}),jsx(t,{className:"fk:ml-auto fk:h-9 fk:w-28"})]}),jsx(t,{className:"fk:h-4 fk:w-full"}),jsx(t,{className:"fk:h-4 fk:w-2/3"}),jsx(t,{className:"fk:h-6 fk:w-24 fk:rounded-full"})]})]})})]});let g=$e(l),M$1={onDisconnect:r=>{u(()=>a$2.disconnectPlugin(r.id));},onMakePrimary:r=>{u(()=>a$2.updatePluginConnection(r.id,{primary:!0}));},onReconnect:r=>{u(()=>d(a$2,l,r.scope,{connectionId:r.id}));},onRename:(r,c)=>u(()=>a$2.updatePluginConnection(r.id,{label:c}))};return jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b,{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"})]}),jsxs(c,{variant:"ghost",size:"sm",onClick:()=>k("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(m,{className:"fk:h-0 fk:min-h-0 fk:flex-1",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("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-4",children:[jsx(a,{className:"fk:size-14 fk:rounded-lg",src:l.logoUrl}),jsxs("div",{className:"fk:flex fk:min-w-0 fk:flex-col fk:gap-0.5",children:[jsx("h1",{className:"fk:text-xl fk:font-semibold",children:l.name}),b$2?jsxs("a",{href:b$2,target:"_blank",rel:"noopener noreferrer",className:"fk:inline-flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:hover:underline fk:text-muted-foreground",children:["View source",jsx(ExternalLink,{className:"fk:size-3"})]}):null]}),jsx("div",{className:"fk:ml-auto fk:flex fk:shrink-0 fk:flex-wrap fk:items-center fk:justify-end fk:gap-2",children:T(l)?null:jsx(je,{busy:p,canManage:s.canManage,plugin:l,onConnect:r=>{u(()=>d(a$2,l,r));}})})]}),jsx("p",{className:"fk:text-muted-foreground",children:l.description}),jsx("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:jsx(b$1,{className:`fk:border-0 fk:text-[0.625rem] fk:leading-4.5 fk:font-normal fk:py-0 fk:px-2 ${ze(l.scopes)}`,variant:"default",children:Ee(l.scopes)})}),l.scopes.map(r=>(r==="personal"?l.allowPersonal:s.canManage)?null:jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:r==="project"?"Ask an owner or developer to connect.":"Personal connections are disabled by project policy."},r))]}),l.enabled?null:jsx(e$2,{children:jsx(g$1,{children:"This plugin is disabled by project policy."})}),T(l)?jsx(He,{actions:M$1,busy:p,canManage:s.canManage,plugin:l,onConnect:r=>{u(()=>d(a$2,l,r));}}):null,jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Included tools"}),l.capabilities.agentTools&&g?jsxs(c,{className:"fk:ml-auto",disabled:p,size:"sm",variant:"ghost",onClick:()=>{u(async()=>{await a$2.refreshPluginTools(g.id),await m$1(`${t$1}/plugin-connections/${g.id}/tools`);});},children:[jsx(RefreshCw,{}),"Refresh"]}):null]}),l.capabilities.automationDelivery?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Automation delivery to selected channels. This plugin does not expose MCP messaging tools."}):null,l.capabilities.agentTools&&!g?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Connect to discover available tools."}):null,l.capabilities.agentTools&&g?jsxs(Fragment,{children:[jsxs("p",{className:"fk:text-sm fk:text-muted-foreground",children:["Tools \xB7 via ",g.displayName]}),jsx(Je,{base:t$1,connectionId:g.id},g.id)]}):null]}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Included skills"}),s.skills.length===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"This plugin includes no skills."}):s.skills.map(r=>jsxs("div",{children:[jsx("h3",{className:"fk:font-medium",children:r.name}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:r.description})]},r.key))]}),jsxs("section",{className:"fk:space-y-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Used by"}),l.usedBy.length===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"No automations visible to you use this plugin yet."}):jsx("ul",{children:l.usedBy.map(r=>jsx("li",{children:jsx(c,{className:"fk:pl-0!",variant:"link",onClick:()=>k(`../../automations/${r.id}`,{relative:"path"}),children:r.name})},r.id))})]})]})})]})}export{je as a,Ue as b,on as c,sn as d,ln as e};//# sourceMappingURL=chunk-DR36N2JC.js.map
2
- //# sourceMappingURL=chunk-DR36N2JC.js.map
1
+ import'./index.css';import {a}from'./chunk-QSTWBKPN.js';import {a as a$1,d}from'./chunk-L5Z56DDM.js';import {f,d as d$2}from'./chunk-PLCI2RJA.js';import {f as f$1}from'./chunk-Y7VBTUNI.js';import {M,ea,fa,ga,ma,o,p,q as q$1}from'./chunk-RULCANNM.js';import {e,g,h,i,j,t,d as d$1,a as a$2,b as b$3,c as c$2,o as o$1}from'./chunk-A4DPLZZF.js';import {e as e$2,g as g$1,b as b$2}from'./chunk-G5N6HEPW.js';import {m,b as b$1}from'./chunk-5JUG4BEF.js';import {b,c as c$1,e as e$1}from'./chunk-N33S7BSG.js';import {c}from'./chunk-X3SHNHHM.js';import {useState,useMemo,useRef,useEffect}from'react';import {useNavigate,useLocation,useParams,Link}from'react-router-dom';import q,{useSWRConfig}from'swr';import {Plug,ArrowLeft,ExternalLink,RefreshCw,ChevronLeft,ChevronRight,Plus,CheckIcon,XIcon,MoreHorizontal,TriangleAlert}from'lucide-react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function Re(n){let a;try{a=new URL(n);}catch{return null}return a.protocol!=="https:"||a.username!==""||a.password!==""?null:a.href}function xe(){let{currentProjectId:n}=f$1();return {api:useMemo(()=>n?d$2(n):null,[n]),base:n?`/api/flexkit/${n}`:null}}function Ee(n){return n.length===2?"Project & Personal":n[0]==="project"?"Project":"Personal"}function ze(n){return n.length===2?"fk:bg-indigo-100 fk:text-indigo-800 fk:dark:bg-indigo-950 fk:dark:text-indigo-300":n[0]==="project"?"fk:bg-sky-100 fk:text-sky-800 fk:dark:bg-sky-950 fk:dark:text-sky-300":"fk:bg-teal-100 fk:text-teal-800 fk:dark:bg-teal-950 fk:dark:text-teal-300"}function T(n){return n.connections.length>0}function Ie(n){return n==="project"?"Project":"Personal"}function z(n,a,t){return t==="personal"?n.allowPersonal:a}function he(n,a){return n.connections.filter(t=>t.scope===a).sort((t,s)=>Number(s.isPrimary)-Number(t.isPrimary)||t.createdAt.localeCompare(s.createdAt))}function $e(n){let a=n.connections.filter(t=>t.isPrimary&&t.status==="connected");return a.find(t=>t.scope==="personal")??a.find(t=>t.scope==="project")??null}function je({busy:n,canManage:a,plugin:t,onConnect:s}){let i$1=t.scopes.filter(k=>he(t,k).length===0),[f]=i$1;if(!f)return null;if(t.scopes.length===1)return jsxs(c,{disabled:n||!t.enabled||!z(t,a,f),size:"sm",type:"button",onClick:()=>s(f),children:[jsx(Plug,{}),"Connect"]});let m=i$1.some(k=>z(t,a,k));return jsxs(e,{children:[jsx(g,{asChild:true,children:jsxs(c,{disabled:n||!t.enabled||!m,size:"sm",type:"button",children:[jsx(Plug,{}),"Connect"]})}),jsx(h,{align:"end",className:"fk:w-72",children:jsx(i,{children:i$1.map(k=>jsx(j,{disabled:!z(t,a,k),onSelect:()=>s(k),children:jsxs("span",{className:"fk:flex fk:flex-col fk:gap-0.5",children:[jsx("span",{children:Ie(k)}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:k==="personal"?"Only you can use this connection in this project.":"Shared with project members who can use this plugin."})]})},k))})})]})}function S(n,a){let t=/^(.*\/ai)(?:\/|$)/.exec(n);return t?`${t[1]}/${a}`:a}function H(n){return n.split(/[\s_-]+/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function Be(n){let a={};for(let t of n){let s=a[t.category];if(s){s.push(t);continue}a[t.category]=[t];}return Object.entries(a).sort(([t],[s])=>H(t).localeCompare(H(s))).map(([t,s])=>({category:t,plugins:s}))}var ce=[{id:"first",rows:[{descriptionWidth:"fk:w-44",id:"first-a",nameWidth:"fk:w-24"},{descriptionWidth:"fk:w-52",id:"first-b",nameWidth:"fk:w-16"},{descriptionWidth:"fk:w-40",id:"first-c",nameWidth:"fk:w-28"},{descriptionWidth:"fk:w-48",id:"first-d",nameWidth:"fk:w-20"}]},{id:"second",rows:[{descriptionWidth:"fk:w-36",id:"second-a",nameWidth:"fk:w-32"},{descriptionWidth:"fk:w-56",id:"second-b",nameWidth:"fk:w-24"}]}];function ke({action:n,row:a}){return 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 ${a.nameWidth}`}),jsx(t,{className:`fk:h-4 ${a.descriptionWidth}`})]}),n?jsx(t,{className:"fk:size-4 fk:shrink-0"}):null]})}var K="fk:grid fk:grid-cols-1 fk:gap-x-16 fk:gap-y-1 fk:lg:grid-cols-2";function We({grouped:n=true}){let a=ce.flatMap(t=>t.rows);return n?jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-8",children:[jsx("span",{className:"fk:sr-only",children:"Loading plugins"}),ce.map(t$1=>jsxs("section",{children:[jsx(t,{className:"fk:mb-1 fk:h-4 fk:w-28"}),jsx("div",{className:K,children:t$1.rows.map(s=>jsx(ke,{action:true,row:s},s.id))})]},t$1.id))]}):jsxs("div",{"aria-busy":"true",className:K,children:[jsx("span",{className:"fk:sr-only",children:"Loading plugins"}),a.map(t=>jsx(ke,{action:true,row:t},t.id))]})}function Ue(){let n=useNavigate(),{pathname:a}=useLocation(),t=/\/ai\/plugins\/?$/.test(a),s=a.includes("/ai/skills");return jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b,{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(ea,{value:s?"skills":"plugins",onValueChange:f=>{let m=f==="skills"?"skills":"plugins";(f==="skills"?s:t)||n(S(a,m));},children:jsxs(fa,{children:[jsx(ga,{value:"plugins",onClick:()=>{t||n(S(a,"plugins"));},children:"Plugins"}),jsx(ga,{value:"skills",children:"Skills"})]})})]})}function Xe({onOpen:n,plugin:a$1}){let t=T(a$1),s=a$1.connections.filter(f=>f.status==="needs_auth").length,i=s===1?"An account needs to be reconnected":`${s.toString()} accounts need to be reconnected`;return jsxs("button",{type:"button",onClick:n,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(a,{className:"fk:size-10 fk:rounded-lg",src:a$1.logoUrl}),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:a$1.name}),jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:text-muted-foreground",children:a$1.description})]}),s>0?jsxs(b,{children:[jsx(c$1,{asChild:true,children:jsxs("span",{className:"fk:flex fk:shrink-0",children:[jsx(TriangleAlert,{"aria-hidden":true,className:"fk:size-4 fk:text-destructive"}),jsx("span",{className:"fk:sr-only",children:i})]})}),jsx(e$1,{children:i})]}):t?jsx(CheckIcon,{className:"fk:size-4 fk:shrink-0 fk:text-success"}):jsx(Plus,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"})]})}function ue({onOpen:n,plugins:a}){return jsx("div",{className:K,children:a.map(t=>jsx(Xe,{plugin:t,onOpen:()=>n(t.id)},t.id))})}function be({installedOnly:n=false}){let{base:a}=xe(),{data:t$1,error:s,isLoading:i}=q(a?`${a}/plugins`:null,f),[f$1,m$1]=useState(""),k=useNavigate(),{pathname:p}=useLocation(),x=f$1.trim().toLowerCase(),l=(t$1?.plugins??[]).filter(c=>(!n||T(c))&&`${c.name} ${c.description}`.toLowerCase().includes(x)),b=(t$1?.plugins??[]).filter(T),u=n?[]:Be(l),g="Plugins are being prepared. Check back soon.";n&&!x?g="No plugins installed yet.":(t$1?.catalogSha||n)&&(g="No plugins match your search.");function M(c){k(S(p,`plugins/${c}`));}let r=jsx("div",{className:"fk:flex fk:flex-col fk:gap-8",children:u.map(c=>jsxs("section",{children:[jsx("h3",{className:"fk:mb-1 fk:text-sm fk:font-medium",children:H(c.category)}),jsx(ue,{plugins:c.plugins,onOpen:M})]},c.category))});return n&&(r=jsx(ue,{plugins:l,onOpen:M})),(i||s||l.length===0)&&(r=null),jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsx(Ue,{}),jsx(m,{className:"fk:h-0 fk:min-h-0 fk:flex-1",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:"Plugins"}),jsx("p",{className:"fk:mt-2 fk:text-muted-foreground",children:"Connect the tools you use and add skills to your workflows."})]}),jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:[jsx(b$2,{"aria-label":"Search plugins",className:"fk:mr-auto fk:w-full fk:max-w-xs",placeholder:"Search plugins\u2026",value:f$1,onChange:c=>m$1(c.target.value)}),!n&&i?jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[jsx("div",{className:"fk:flex fk:-space-x-2",children:["installed-a","installed-b","installed-c"].map(c=>jsx(t,{className:"fk:size-8 fk:rounded-md fk:ring-2 fk:ring-background"},c))}),jsx(t,{className:"fk:h-4 fk:w-20"})]}):null,!n&&!i&&b.length>0?jsx(d$1,{children:b.slice(0,9).map(c=>jsxs(a$2,{className:"fk:rounded-md",children:[jsx(b$3,{src:c.logoUrl,alt:""}),jsx(c$2,{children:c.name.charAt(0)})]},c.id))}):null,n?jsxs(Link,{to:S(p,"plugins"),className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground",children:[jsx(ChevronLeft,{className:"fk:size-4"}),"Show all"]}):null,!n&&!i?jsxs(Link,{to:S(p,"plugins/installed"),className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground",children:[b.length," installed",jsx(ChevronRight,{className:"fk:size-4"})]}):null]}),s?jsx(e$2,{variant:"destructive",children:jsx(g$1,{children:"Unable to load plugins. Please try again."})}):null,i?jsx(We,{grouped:!n}):null,!i&&!s&&l.length===0?jsx(e$2,{children:jsx(g$1,{children:g})}):null,r]})})]})}function on(){return jsx(be,{})}function sn(){return jsx(be,{installedOnly:true})}function Je({base:n,connectionId:a}){let{data:t$1,error:s}=q(`${n}/plugin-connections/${a}/tools`,f);return s?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Unable to discover tools. Reconnect or try again."}):t$1?jsx("div",{className:"fk:flex fk:flex-col fk:gap-3",children:t$1.servers.map(i=>jsxs("section",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("h4",{className:"fk:font-medium",children:i.name}),i.error?jsx("p",{children:i.error}):null,i.tools.length>0?jsxs(o,{className:"fk:group",children:[jsxs(p,{className:"fk:flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground",children:[jsx(ChevronRight,{className:"fk:size-4 fk:transition-transform fk:group-data-[state=open]:rotate-90"}),_e(i.tools.length)]}),jsx(q$1,{children:jsx("ul",{className:"fk:mt-2 fk:flex fk:flex-col fk:gap-2",children:i.tools.map(f=>jsxs("li",{children:[jsx("span",{className:"fk:text-sm fk:font-medium",children:f.name}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:f.description})]},f.name))})})]}):null]},i.name))}):jsx(t,{className:"fk:h-12 fk:w-full"})}function _e(n){return n===1?"1 tool":`${n.toString()} tools`}function Ge(n){return n.accountName&&n.accountName!==n.displayName?n.accountName:n.scope==="project"?"Shared with this project":"Only you can use this account"}function Fe({actionable:n,actions:a,busy:t,connection:s,pluginEnabled:i$1}){let[f,m]=useState(false),[k,p]=useState(""),x=useRef(null),l=s.status==="needs_auth",b=async()=>{let u=k.trim();await a.onRename(s,u||null),m(false);};return useEffect(()=>{if(!f)return;let u=window.setTimeout(()=>x.current?.focus(),0);return ()=>window.clearTimeout(u)},[f]),jsxs("li",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:py-2",children:[jsx(a$2,{className:"fk:size-8",children:jsx(c$2,{children:s.displayName.charAt(0).toUpperCase()})}),f?jsxs("form",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:items-center fk:gap-2",onSubmit:u=>{u.preventDefault(),b();},children:[jsx(b$2,{"aria-label":"Account name",ref:x,className:"fk:h-8 fk:max-w-xs",disabled:t,placeholder:s.accountName??"Account name",value:k,onChange:u=>p(u.target.value),onKeyDown:u=>{u.key==="Escape"&&m(false);}}),jsx(c,{"aria-label":"Save name",disabled:t,size:"icon",type:"submit",variant:"ghost",children:jsx(CheckIcon,{})}),jsx(c,{"aria-label":"Cancel rename",size:"icon",type:"button",variant:"ghost",onClick:()=>m(false),children:jsx(XIcon,{})})]}):jsxs("span",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col",children:[jsxs("span",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-2",children:[jsx("span",{className:"fk:truncate fk:text-sm fk:font-medium",children:s.displayName}),s.isPrimary?jsx(b$1,{variant:"secondary",children:"Primary"}):null,l?jsx(b$1,{variant:"destructive",children:"Needs reconnect"}):null]}),jsx("span",{className:"fk:truncate fk:text-sm fk:text-muted-foreground",children:Ge(s)})]}),n&&!f?jsxs(e,{children:[jsx(g,{asChild:true,children:jsx(c,{"aria-label":`Manage ${s.displayName}`,disabled:t,size:"icon",variant:"ghost",children:jsx(MoreHorizontal,{})})}),jsxs(h,{align:"end",children:[jsxs(i,{children:[!s.isPrimary&&!l?jsx(j,{onSelect:()=>a.onMakePrimary(s),children:"Make primary"}):null,jsx(j,{onSelect:()=>{p(s.label??""),m(true);},children:"Rename"}),jsx(j,{disabled:!i$1,onSelect:()=>a.onReconnect(s),children:"Reconnect"})]}),jsx(o$1,{}),jsx(j,{variant:"destructive",onSelect:()=>a.onDisconnect(s),children:"Disconnect"})]})]}):null]})}function He({actions:n,busy:a,canManage:t,onConnect:s,plugin:i}){let f=i.scopes.length>1;return jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Connected accounts"}),i.scopes.map(m=>{let k=he(i,m),p=z(i,t,m),x=m==="personal"||t;return k.length===0&&!p?null:jsxs("div",{className:"fk:flex fk:flex-col",children:[f?jsx("h3",{className:"fk:text-sm fk:font-medium fk:text-muted-foreground",children:m==="project"?"Project accounts":"Your accounts"}):null,jsxs("ul",{className:"fk:flex fk:flex-col fk:divide-y",children:[k.map(l=>jsx(Fe,{actionable:x,actions:n,busy:a,connection:l,pluginEnabled:i.enabled},l.id)),p?jsx("li",{children:jsxs("button",{className:"fk:flex fk:w-full fk:items-center fk:gap-3 fk:py-2 fk:text-left fk:text-sm fk:text-muted-foreground fk:transition-colors fk:hover:text-foreground fk:disabled:pointer-events-none fk:disabled:opacity-50",disabled:a||!i.enabled,type:"button",onClick:()=>s(m),children:[jsx("span",{className:"fk:flex fk:size-8 fk:shrink-0 fk:items-center fk:justify-center fk:rounded-full fk:border fk:border-dashed",children:jsx(Plus,{className:"fk:size-4"})}),k.length>0?"Connect another account":"Connect an account"]})}):null]})]},m)})]})}function ln(){let{pluginId:n}=useParams(),{api:a$2,base:t$1}=xe(),{data:s,error:i,mutate:f$1}=q(t$1&&n?`${t$1}/plugins/${n}`:null,f),{mutate:m$1}=useSWRConfig(),k=useNavigate(),[p,x]=useState(false),l=s?.plugin,b$2=l?Re(l.sourceUrl):null,u=async r=>{x(true);try{await r(),await f$1();}catch(c){if(c instanceof a$1){ma.error('You signed in with a different account. Use "Connect another account" to add it.');return}ma.error(c instanceof Error?c.message:"Unable to complete this action.");}finally{x(false);}};if(i)return jsx("div",{className:"fk:p-6",children:jsx(e$2,{variant:"destructive",children:jsx(g$1,{children:"Unable to load this plugin."})})});if(!l||!s||!a$2||!t$1)return jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b,{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"})]}),jsxs(c,{variant:"ghost",size:"sm",onClick:()=>k("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(m,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{"aria-busy":"true",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:[jsx("span",{className:"fk:sr-only",children:"Loading plugin"}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-4",children:[jsx(t,{className:"fk:size-14 fk:shrink-0 fk:rounded-lg"}),jsx(t,{className:"fk:h-7 fk:w-40"}),jsx(t,{className:"fk:ml-auto fk:h-9 fk:w-28"})]}),jsx(t,{className:"fk:h-4 fk:w-full"}),jsx(t,{className:"fk:h-4 fk:w-2/3"}),jsx(t,{className:"fk:h-6 fk:w-24 fk:rounded-full"})]})]})})]});let g=$e(l),M$1={onDisconnect:r=>{u(()=>a$2.disconnectPlugin(r.id));},onMakePrimary:r=>{u(()=>a$2.updatePluginConnection(r.id,{primary:!0}));},onReconnect:r=>{u(()=>d(a$2,l,r.scope,{connectionId:r.id}));},onRename:(r,c)=>u(()=>a$2.updatePluginConnection(r.id,{label:c}))};return jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b,{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"})]}),jsxs(c,{variant:"ghost",size:"sm",onClick:()=>k("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(m,{className:"fk:h-0 fk:min-h-0 fk:flex-1",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("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-4",children:[jsx(a,{className:"fk:size-14 fk:rounded-lg",src:l.logoUrl}),jsxs("div",{className:"fk:flex fk:min-w-0 fk:flex-col fk:gap-0.5",children:[jsx("h1",{className:"fk:text-xl fk:font-semibold",children:l.name}),b$2?jsxs("a",{href:b$2,target:"_blank",rel:"noopener noreferrer",className:"fk:inline-flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:hover:underline fk:text-muted-foreground",children:["View source",jsx(ExternalLink,{className:"fk:size-3"})]}):null]}),jsx("div",{className:"fk:ml-auto fk:flex fk:shrink-0 fk:flex-wrap fk:items-center fk:justify-end fk:gap-2",children:T(l)?null:jsx(je,{busy:p,canManage:s.canManage,plugin:l,onConnect:r=>{u(()=>d(a$2,l,r));}})})]}),jsx("p",{className:"fk:text-muted-foreground",children:l.description}),jsx("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:jsx(b$1,{className:`fk:border-0 fk:text-[0.625rem] fk:leading-4.5 fk:font-normal fk:py-0 fk:px-2 ${ze(l.scopes)}`,variant:"default",children:Ee(l.scopes)})}),l.scopes.map(r=>(r==="personal"?l.allowPersonal:s.canManage)?null:jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:r==="project"?"Ask an owner or developer to connect.":"Personal connections are disabled by project policy."},r))]}),l.enabled?null:jsx(e$2,{children:jsx(g$1,{children:"This plugin is disabled by project policy."})}),T(l)?jsx(He,{actions:M$1,busy:p,canManage:s.canManage,plugin:l,onConnect:r=>{u(()=>d(a$2,l,r));}}):null,jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Included tools"}),l.capabilities.agentTools&&g?jsxs(c,{className:"fk:ml-auto",disabled:p,size:"sm",variant:"ghost",onClick:()=>{u(async()=>{await a$2.refreshPluginTools(g.id),await m$1(`${t$1}/plugin-connections/${g.id}/tools`);});},children:[jsx(RefreshCw,{}),"Refresh"]}):null]}),l.capabilities.automationDelivery?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Automation delivery to selected channels. This plugin does not expose MCP messaging tools."}):null,l.capabilities.agentTools&&!g?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Connect to discover available tools."}):null,l.capabilities.agentTools&&g?jsxs(Fragment,{children:[jsxs("p",{className:"fk:text-sm fk:text-muted-foreground",children:["Tools \xB7 via ",g.displayName]}),jsx(Je,{base:t$1,connectionId:g.id},g.id)]}):null]}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Included skills"}),s.skills.length===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"This plugin includes no skills."}):s.skills.map(r=>jsxs("div",{children:[jsx("h3",{className:"fk:font-medium",children:r.name}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:r.description})]},r.key))]}),jsxs("section",{className:"fk:space-y-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Used by"}),l.usedBy.length===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"No automations visible to you use this plugin yet."}):jsx("ul",{children:l.usedBy.map(r=>jsx("li",{children:jsx(c,{className:"fk:pl-0!",variant:"link",onClick:()=>k(`../../automations/${r.id}`,{relative:"path"}),children:r.name})},r.id))})]})]})})]})}export{je as a,Ue as b,on as c,sn as d,ln as e};//# sourceMappingURL=chunk-E3KO5NGM.js.map
2
+ //# sourceMappingURL=chunk-E3KO5NGM.js.map