@flexkit/studio 0.2.32 → 0.2.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/dist/activity-nav-button-ZHQOZBCC.js +2 -0
  2. package/dist/{activity-nav-button-E4I4YC3X.js.map → activity-nav-button-ZHQOZBCC.js.map} +1 -1
  3. package/dist/astro.js +1 -1
  4. package/dist/chat-page-7XT4K75G.js +4 -0
  5. package/dist/chat-page-7XT4K75G.js.map +1 -0
  6. package/dist/chunk-2FCVATRT.js +4 -0
  7. package/dist/{chunk-R2O4WC3H.js.map → chunk-2FCVATRT.js.map} +1 -1
  8. package/dist/{chunk-ERCVR23U.js → chunk-36DLIVZF.js} +2 -2
  9. package/dist/{chunk-ERCVR23U.js.map → chunk-36DLIVZF.js.map} +1 -1
  10. package/dist/{chunk-ONB3FWK5.js → chunk-3OBELKJU.js} +2 -2
  11. package/dist/{chunk-ONB3FWK5.js.map → chunk-3OBELKJU.js.map} +1 -1
  12. package/dist/chunk-4ZWQ44NZ.js +2 -0
  13. package/dist/{chunk-2NXQF2F7.js.map → chunk-4ZWQ44NZ.js.map} +1 -1
  14. package/dist/chunk-5JUG4BEF.js +2 -0
  15. package/dist/chunk-5JUG4BEF.js.map +1 -0
  16. package/dist/{chunk-XV7U33XQ.js → chunk-6AJRQSFO.js} +3 -3
  17. package/dist/{chunk-XV7U33XQ.js.map → chunk-6AJRQSFO.js.map} +1 -1
  18. package/dist/chunk-7JA6SI5H.js +2 -0
  19. package/dist/{chunk-5AJXR47U.js.map → chunk-7JA6SI5H.js.map} +1 -1
  20. package/dist/{chunk-SZEGGBOC.js → chunk-A4DPLZZF.js} +2 -2
  21. package/dist/{chunk-SZEGGBOC.js.map → chunk-A4DPLZZF.js.map} +1 -1
  22. package/dist/{chunk-C4XLDODU.js → chunk-C2KPTRYM.js} +3 -1
  23. package/dist/{chunk-GSGPULRL.js → chunk-CHNQZU2P.js} +2 -2
  24. package/dist/{chunk-GSGPULRL.js.map → chunk-CHNQZU2P.js.map} +1 -1
  25. package/dist/chunk-DFBG7PUJ.js +10 -0
  26. package/dist/{chunk-JAPZBEBZ.js.map → chunk-DFBG7PUJ.js.map} +1 -1
  27. package/dist/{chunk-V7C4EHK3.js → chunk-DSLPTDZX.js} +2 -2
  28. package/dist/{chunk-V7C4EHK3.js.map → chunk-DSLPTDZX.js.map} +1 -1
  29. package/dist/{chunk-EMFHKTAV.js → chunk-EUWIIL3X.js} +2 -2
  30. package/dist/{chunk-EMFHKTAV.js.map → chunk-EUWIIL3X.js.map} +1 -1
  31. package/dist/chunk-G5N6HEPW.js +2 -0
  32. package/dist/chunk-G5N6HEPW.js.map +1 -0
  33. package/dist/chunk-HR4QZ5TD.js +3 -0
  34. package/dist/chunk-HR4QZ5TD.js.map +1 -0
  35. package/dist/chunk-KO2JLLUJ.js +2 -0
  36. package/dist/chunk-KO2JLLUJ.js.map +1 -0
  37. package/dist/chunk-MBBE4RND.js +3 -0
  38. package/dist/chunk-MBBE4RND.js.map +1 -0
  39. package/dist/{chunk-USNXQOMJ.js → chunk-N33S7BSG.js} +2 -2
  40. package/dist/{chunk-USNXQOMJ.js.map → chunk-N33S7BSG.js.map} +1 -1
  41. package/dist/{chunk-KN7OJFEX.js → chunk-N52JTYBJ.js} +2 -2
  42. package/dist/{chunk-KN7OJFEX.js.map → chunk-N52JTYBJ.js.map} +1 -1
  43. package/dist/{chunk-KR27GOH6.js → chunk-PC5Z37LT.js} +3 -3
  44. package/dist/{chunk-KR27GOH6.js.map → chunk-PC5Z37LT.js.map} +1 -1
  45. package/dist/{chunk-2NQ2RZ2M.js → chunk-PSECMZJC.js} +3 -3
  46. package/dist/{chunk-2NQ2RZ2M.js.map → chunk-PSECMZJC.js.map} +1 -1
  47. package/dist/chunk-RBGXXVF4.js +7 -0
  48. package/dist/{chunk-NNISUDZX.js.map → chunk-RBGXXVF4.js.map} +1 -1
  49. package/dist/chunk-RULCANNM.js +7 -0
  50. package/dist/chunk-RULCANNM.js.map +1 -0
  51. package/dist/chunk-S7Z6KKIN.js +2 -0
  52. package/dist/chunk-S7Z6KKIN.js.map +1 -0
  53. package/dist/{chunk-AY2RXJWS.js → chunk-U6NFYYTF.js} +2 -2
  54. package/dist/{chunk-AY2RXJWS.js.map → chunk-U6NFYYTF.js.map} +1 -1
  55. package/dist/chunk-VFV44YZB.js +2 -0
  56. package/dist/{chunk-54AXLGAK.js.map → chunk-VFV44YZB.js.map} +1 -1
  57. package/dist/chunk-VRDTHLA3.js +3 -0
  58. package/dist/chunk-VRDTHLA3.js.map +1 -0
  59. package/dist/chunk-WU2KCXBC.js +2 -0
  60. package/dist/{chunk-5LGIALCK.js.map → chunk-WU2KCXBC.js.map} +1 -1
  61. package/dist/chunk-X3SHNHHM.js +2 -0
  62. package/dist/chunk-X3SHNHHM.js.map +1 -0
  63. package/dist/chunk-XYFS6X74.js +2 -0
  64. package/dist/{chunk-JWJJZVP3.js.map → chunk-XYFS6X74.js.map} +1 -1
  65. package/dist/chunk-YC7PBLTK.js +2 -0
  66. package/dist/{chunk-MRHZN4G4.js.map → chunk-YC7PBLTK.js.map} +1 -1
  67. package/dist/electron.js +1 -1
  68. package/dist/{entry-CA2QAEHN.js → entry-APJ4V7PW.js} +2 -2
  69. package/dist/{entry-CA2QAEHN.js.map → entry-APJ4V7PW.js.map} +1 -1
  70. package/dist/index.css +43 -0
  71. package/dist/index.d.ts +10 -1
  72. package/dist/index.js +8 -8
  73. package/dist/index.js.map +1 -1
  74. package/dist/list-7IHDJM54.js +3 -0
  75. package/dist/{list-Q2KAEJ26.js.map → list-7IHDJM54.js.map} +1 -1
  76. package/dist/list-7WFALOUT.js +2 -0
  77. package/dist/{list-UMMVRYVD.js.map → list-7WFALOUT.js.map} +1 -1
  78. package/dist/nextjs.js +1 -1
  79. package/dist/pages-BV3ABSFQ.js +5 -0
  80. package/dist/{pages-KZ66JVNU.js.map → pages-BV3ABSFQ.js.map} +1 -1
  81. package/dist/plugin-pages-OWGJPPWV.js +2 -0
  82. package/dist/{plugin-pages-SR2WSUKZ.js.map → plugin-pages-OWGJPPWV.js.map} +1 -1
  83. package/dist/project-selector-V5N2724B.js +2 -0
  84. package/dist/project-selector-V5N2724B.js.map +1 -0
  85. package/dist/record-links-3P3XSW66.js +2 -0
  86. package/dist/{record-links-3WZGSVFU.js.map → record-links-3P3XSW66.js.map} +1 -1
  87. package/dist/root-F2GTYDJM.js +2 -0
  88. package/dist/{root-6QTQUYK4.js.map → root-F2GTYDJM.js.map} +1 -1
  89. package/dist/root-GBBZ3DX5.js +31 -0
  90. package/dist/{root-7BUVDOMV.js.map → root-GBBZ3DX5.js.map} +1 -1
  91. package/dist/root-J62PBDZ2.js +2 -0
  92. package/dist/{root-2VBLPRG7.js.map → root-J62PBDZ2.js.map} +1 -1
  93. package/dist/root-LYRL7VPN.js +14 -0
  94. package/dist/{root-LFJ5BQSY.js.map → root-LYRL7VPN.js.map} +1 -1
  95. package/dist/root-NIL2UHKS.js +2 -0
  96. package/dist/{root-OXS3QQX6.js.map → root-NIL2UHKS.js.map} +1 -1
  97. package/dist/root-RGZZYETM.js +23 -0
  98. package/dist/{root-FZLKYL5W.js.map → root-RGZZYETM.js.map} +1 -1
  99. package/dist/search-IIGNCQEZ.js +2 -0
  100. package/dist/{search-AZK3Q2KX.js.map → search-IIGNCQEZ.js.map} +1 -1
  101. package/dist/skills-pages-T52MF4DO.js +2 -0
  102. package/dist/{skills-pages-7IYBJ4QI.js.map → skills-pages-T52MF4DO.js.map} +1 -1
  103. package/dist/source-IJAAJDGW.js +2 -0
  104. package/dist/{source-4BP5PJ2N.js.map → source-IJAAJDGW.js.map} +1 -1
  105. package/dist/spec-renderer-Z6GVHLFU.js +2 -0
  106. package/dist/{spec-renderer-3GAVSV52.js.map → spec-renderer-Z6GVHLFU.js.map} +1 -1
  107. package/dist/tanstack-start.js +1 -1
  108. package/dist/ui.js +1 -1
  109. package/dist/user-nav-ZH63YHX7.js +2 -0
  110. package/dist/{user-nav-OWTTAXZS.js.map → user-nav-ZH63YHX7.js.map} +1 -1
  111. package/package.json +2 -2
  112. package/dist/activity-nav-button-E4I4YC3X.js +0 -2
  113. package/dist/chat-page-7UB3BMBF.js +0 -4
  114. package/dist/chat-page-7UB3BMBF.js.map +0 -1
  115. package/dist/chunk-2NXQF2F7.js +0 -2
  116. package/dist/chunk-32ZU4MLE.js +0 -2
  117. package/dist/chunk-32ZU4MLE.js.map +0 -1
  118. package/dist/chunk-54AXLGAK.js +0 -2
  119. package/dist/chunk-5AJXR47U.js +0 -2
  120. package/dist/chunk-5LGIALCK.js +0 -2
  121. package/dist/chunk-6NRQMG26.js +0 -2
  122. package/dist/chunk-6NRQMG26.js.map +0 -1
  123. package/dist/chunk-AKQ6ELDX.js +0 -2
  124. package/dist/chunk-AKQ6ELDX.js.map +0 -1
  125. package/dist/chunk-DGIY4SKN.js +0 -7
  126. package/dist/chunk-DGIY4SKN.js.map +0 -1
  127. package/dist/chunk-HDOIOXMP.js +0 -2
  128. package/dist/chunk-HDOIOXMP.js.map +0 -1
  129. package/dist/chunk-HZOD2HOF.js +0 -3
  130. package/dist/chunk-HZOD2HOF.js.map +0 -1
  131. package/dist/chunk-JAPZBEBZ.js +0 -10
  132. package/dist/chunk-JWJJZVP3.js +0 -2
  133. package/dist/chunk-MRHZN4G4.js +0 -2
  134. package/dist/chunk-NNISUDZX.js +0 -7
  135. package/dist/chunk-O2QMYUPS.js +0 -2
  136. package/dist/chunk-O2QMYUPS.js.map +0 -1
  137. package/dist/chunk-R2O4WC3H.js +0 -4
  138. package/dist/chunk-WPCPL2TQ.js +0 -3
  139. package/dist/chunk-WPCPL2TQ.js.map +0 -1
  140. package/dist/list-Q2KAEJ26.js +0 -3
  141. package/dist/list-UMMVRYVD.js +0 -2
  142. package/dist/pages-KZ66JVNU.js +0 -5
  143. package/dist/plugin-pages-SR2WSUKZ.js +0 -2
  144. package/dist/project-selector-72VM6SUI.js +0 -2
  145. package/dist/project-selector-72VM6SUI.js.map +0 -1
  146. package/dist/record-links-3WZGSVFU.js +0 -2
  147. package/dist/root-2VBLPRG7.js +0 -2
  148. package/dist/root-6QTQUYK4.js +0 -2
  149. package/dist/root-7BUVDOMV.js +0 -31
  150. package/dist/root-FZLKYL5W.js +0 -23
  151. package/dist/root-LFJ5BQSY.js +0 -14
  152. package/dist/root-OXS3QQX6.js +0 -2
  153. package/dist/search-AZK3Q2KX.js +0 -2
  154. package/dist/skills-pages-7IYBJ4QI.js +0 -2
  155. package/dist/source-4BP5PJ2N.js +0 -2
  156. package/dist/spec-renderer-3GAVSV52.js +0 -2
  157. package/dist/user-nav-OWTTAXZS.js +0 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/apps/ai/activity-nav-button.tsx"],"names":["useActivitySummary","projectId","data","useSWR","paths","fetcher","formatCount","count","ActivityNavButton","summary","needsAction","unread","useEffect","desktop","getDesktop","label","jsx","TooltipProvider","jsxs","Tooltip","TooltipTrigger","Button","Link","BellIcon","TooltipContent"],"mappings":"mWAeO,SAASA,CAAAA,CAAmBC,EAA4D,CAC7F,GAAM,CAAE,IAAA,CAAAC,CAAK,EAAIC,CAAAA,CAAwBF,CAAAA,CAAYG,EAAMH,CAAS,CAAA,CAAE,iBAAgB,CAAI,IAAA,CAAMI,IAAS,CACvG,eAAA,CAAiB,GACnB,CAAC,CAAA,CAED,OAAOH,CACT,CAEA,SAASI,EAAYC,CAAAA,CAAuB,CAC1C,OAAOA,CAAAA,CAAQ,EAAA,CAAK,MAAQA,CAAAA,CAAM,QAAA,EACpC,CAGO,SAASC,EAAkB,CAAE,SAAA,CAAAP,CAAU,CAAA,CAAuC,CACnF,IAAMQ,CAAAA,CAAUT,CAAAA,CAAmBC,CAAS,CAAA,CACtCS,GAAAA,CAAcD,GAAS,gBAAA,EAAoB,CAAA,CAC3CE,EAASF,CAAAA,EAAS,WAAA,EAAe,EAGvCG,SAAAA,CAAU,IAAM,CACd,IAAMC,CAAAA,CAAUC,GAAW,CAE3B,GAAKD,EAIL,OAAAA,CAAAA,CAAQ,cAAcH,GAAW,CAAA,CAE1B,IAAM,CACXG,CAAAA,CAAQ,aAAA,CAAc,CAAC,EACzB,CACF,EAAG,CAACH,GAAW,CAAC,CAAA,CAEhB,IAAMK,EACJL,GAAAA,CAAc,CAAA,CACV,aAAaJ,CAAAA,CAAYI,GAAW,CAAC,CAAA,gBAAA,CAAA,CACrCC,CAAAA,CAAS,EACP,CAAA,UAAA,EAAaL,CAAAA,CAAYK,CAAM,CAAC,CAAA,OAAA,CAAA,CAChC,WAER,OACEK,GAAAA,CAACC,EAAA,CACC,QAAA,CAAAC,KAACC,GAAAA,CAAA,CACC,UAAAH,GAAAA,CAACI,CAAAA,CAAA,CAAe,OAAA,CAAO,IAAA,CACrB,SAAAJ,GAAAA,CAACK,GAAAA,CAAA,CAAO,OAAA,CAAO,IAAA,CAAC,YAAA,CAAYN,CAAAA,CAAO,SAAA,CAAU,2CAAA,CAA4C,KAAK,MAAA,CAAO,OAAA,CAAQ,QAC3G,QAAA,CAAAG,IAAAA,CAACI,KAAA,CAAK,EAAA,CAAI,IAAIrB,CAAS,CAAA,YAAA,CAAA,CACrB,UAAAe,GAAAA,CAACO,QAAAA,CAAA,CAAS,SAAA,CAAU,WAAA,CAAY,EAC/Bb,GAAAA,CAAc,CAAA,CACbM,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,yMAAA,CACb,SAAAV,CAAAA,CAAYI,GAAW,EAC1B,CAAA,CACEC,CAAAA,CAAS,EACXK,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,yEAAA,CAA0E,CAAA,CACxF,MACN,CAAA,CACF,CAAA,CACF,EACAA,GAAAA,CAACQ,CAAAA,CAAA,CAAgB,QAAA,CAAAT,CAAAA,CAAM,CAAA,CAAA,CACzB,CAAA,CACF,CAEJ","file":"chunk-ERCVR23U.js","sourcesContent":["import { useEffect } from 'react';\nimport type { JSX } from 'react';\nimport { BellIcon } from 'lucide-react';\nimport { Link } from 'react-router-dom';\nimport useSWR from 'swr';\nimport { Button } from '../../ui/primitives/button';\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../ui/primitives/tooltip';\nimport { getDesktop } from '../../core/desktop';\nimport { fetcher, paths } from './api';\nimport type { ActivitySummary } from './types';\n\n/**\n * The project's Activity badge counts. `ActivityNotifier` refreshes the same\n * SWR key on every poll, so every reader stays in sync with one request.\n */\nexport function useActivitySummary(projectId: string | undefined): ActivitySummary | undefined {\n const { data } = useSWR<ActivitySummary>(projectId ? paths(projectId).activitySummary() : null, fetcher, {\n refreshInterval: 30_000,\n });\n\n return data;\n}\n\nfunction formatCount(count: number): string {\n return count > 99 ? '99+' : count.toString();\n}\n\n/** Navbar shortcut to Activity, so pending items are visible from every app. */\nexport function ActivityNavButton({ projectId }: { projectId: string }): JSX.Element {\n const summary = useActivitySummary(projectId);\n const needsAction = summary?.needsActionCount ?? 0;\n const unread = summary?.unreadCount ?? 0;\n // The desktop app shows what waits for you on its dock or taskbar icon;\n // leaving the project or signing out clears it.\n useEffect(() => {\n const desktop = getDesktop();\n\n if (!desktop) {\n return;\n }\n\n desktop.setBadgeCount(needsAction);\n\n return () => {\n desktop.setBadgeCount(0);\n };\n }, [needsAction]);\n\n const label =\n needsAction > 0\n ? `Activity: ${formatCount(needsAction)} waiting for you`\n : unread > 0\n ? `Activity: ${formatCount(unread)} unread`\n : 'Activity';\n\n return (\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button asChild aria-label={label} className=\"fk:relative fk:h-8 fk:w-8 fk:rounded-full\" size=\"icon\" variant=\"ghost\">\n <Link to={`/${projectId}/ai/activity`}>\n <BellIcon className=\"fk:size-4\" />\n {needsAction > 0 ? (\n <span className=\"fk:absolute fk:-right-1 fk:-top-1 fk:flex fk:h-4 fk:min-w-4 fk:items-center fk:justify-center fk:rounded-full fk:bg-amber-500 fk:px-1 fk:text-[0.625rem] fk:font-semibold fk:leading-none fk:text-white\">\n {formatCount(needsAction)}\n </span>\n ) : unread > 0 ? (\n <span className=\"fk:absolute fk:right-1 fk:top-1 fk:size-2 fk:rounded-full fk:bg-success\" />\n ) : null}\n </Link>\n </Button>\n </TooltipTrigger>\n <TooltipContent>{label}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/apps/ai/activity-nav-button.tsx"],"names":["useActivitySummary","projectId","data","useSWR","paths","fetcher","formatCount","count","ActivityNavButton","summary","needsAction","unread","useEffect","desktop","getDesktop","label","jsx","TooltipProvider","jsxs","Tooltip","TooltipTrigger","Button","Link","BellIcon","TooltipContent"],"mappings":"mWAeO,SAASA,CAAAA,CAAmBC,EAA4D,CAC7F,GAAM,CAAE,IAAA,CAAAC,CAAK,EAAIC,CAAAA,CAAwBF,CAAAA,CAAYG,EAAMH,CAAS,CAAA,CAAE,iBAAgB,CAAI,IAAA,CAAMI,IAAS,CACvG,eAAA,CAAiB,GACnB,CAAC,CAAA,CAED,OAAOH,CACT,CAEA,SAASI,EAAYC,CAAAA,CAAuB,CAC1C,OAAOA,CAAAA,CAAQ,EAAA,CAAK,MAAQA,CAAAA,CAAM,QAAA,EACpC,CAGO,SAASC,EAAkB,CAAE,SAAA,CAAAP,CAAU,CAAA,CAAuC,CACnF,IAAMQ,CAAAA,CAAUT,CAAAA,CAAmBC,CAAS,CAAA,CACtCS,GAAAA,CAAcD,GAAS,gBAAA,EAAoB,CAAA,CAC3CE,EAASF,CAAAA,EAAS,WAAA,EAAe,EAGvCG,SAAAA,CAAU,IAAM,CACd,IAAMC,CAAAA,CAAUC,GAAW,CAE3B,GAAKD,EAIL,OAAAA,CAAAA,CAAQ,cAAcH,GAAW,CAAA,CAE1B,IAAM,CACXG,CAAAA,CAAQ,aAAA,CAAc,CAAC,EACzB,CACF,EAAG,CAACH,GAAW,CAAC,CAAA,CAEhB,IAAMK,EACJL,GAAAA,CAAc,CAAA,CACV,aAAaJ,CAAAA,CAAYI,GAAW,CAAC,CAAA,gBAAA,CAAA,CACrCC,CAAAA,CAAS,EACP,CAAA,UAAA,EAAaL,CAAAA,CAAYK,CAAM,CAAC,CAAA,OAAA,CAAA,CAChC,WAER,OACEK,GAAAA,CAACC,EAAA,CACC,QAAA,CAAAC,KAACC,GAAAA,CAAA,CACC,UAAAH,GAAAA,CAACI,CAAAA,CAAA,CAAe,OAAA,CAAO,IAAA,CACrB,SAAAJ,GAAAA,CAACK,GAAAA,CAAA,CAAO,OAAA,CAAO,IAAA,CAAC,YAAA,CAAYN,CAAAA,CAAO,SAAA,CAAU,2CAAA,CAA4C,KAAK,MAAA,CAAO,OAAA,CAAQ,QAC3G,QAAA,CAAAG,IAAAA,CAACI,KAAA,CAAK,EAAA,CAAI,IAAIrB,CAAS,CAAA,YAAA,CAAA,CACrB,UAAAe,GAAAA,CAACO,QAAAA,CAAA,CAAS,SAAA,CAAU,WAAA,CAAY,EAC/Bb,GAAAA,CAAc,CAAA,CACbM,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,yMAAA,CACb,SAAAV,CAAAA,CAAYI,GAAW,EAC1B,CAAA,CACEC,CAAAA,CAAS,EACXK,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,yEAAA,CAA0E,CAAA,CACxF,MACN,CAAA,CACF,CAAA,CACF,EACAA,GAAAA,CAACQ,CAAAA,CAAA,CAAgB,QAAA,CAAAT,CAAAA,CAAM,CAAA,CAAA,CACzB,CAAA,CACF,CAEJ","file":"chunk-36DLIVZF.js","sourcesContent":["import { useEffect } from 'react';\nimport type { JSX } from 'react';\nimport { BellIcon } from 'lucide-react';\nimport { Link } from 'react-router-dom';\nimport useSWR from 'swr';\nimport { Button } from '../../ui/primitives/button';\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../ui/primitives/tooltip';\nimport { getDesktop } from '../../core/desktop';\nimport { fetcher, paths } from './api';\nimport type { ActivitySummary } from './types';\n\n/**\n * The project's Activity badge counts. `ActivityNotifier` refreshes the same\n * SWR key on every poll, so every reader stays in sync with one request.\n */\nexport function useActivitySummary(projectId: string | undefined): ActivitySummary | undefined {\n const { data } = useSWR<ActivitySummary>(projectId ? paths(projectId).activitySummary() : null, fetcher, {\n refreshInterval: 30_000,\n });\n\n return data;\n}\n\nfunction formatCount(count: number): string {\n return count > 99 ? '99+' : count.toString();\n}\n\n/** Navbar shortcut to Activity, so pending items are visible from every app. */\nexport function ActivityNavButton({ projectId }: { projectId: string }): JSX.Element {\n const summary = useActivitySummary(projectId);\n const needsAction = summary?.needsActionCount ?? 0;\n const unread = summary?.unreadCount ?? 0;\n // The desktop app shows what waits for you on its dock or taskbar icon;\n // leaving the project or signing out clears it.\n useEffect(() => {\n const desktop = getDesktop();\n\n if (!desktop) {\n return;\n }\n\n desktop.setBadgeCount(needsAction);\n\n return () => {\n desktop.setBadgeCount(0);\n };\n }, [needsAction]);\n\n const label =\n needsAction > 0\n ? `Activity: ${formatCount(needsAction)} waiting for you`\n : unread > 0\n ? `Activity: ${formatCount(unread)} unread`\n : 'Activity';\n\n return (\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button asChild aria-label={label} className=\"fk:relative fk:h-8 fk:w-8 fk:rounded-full\" size=\"icon\" variant=\"ghost\">\n <Link to={`/${projectId}/ai/activity`}>\n <BellIcon className=\"fk:size-4\" />\n {needsAction > 0 ? (\n <span className=\"fk:absolute fk:-right-1 fk:-top-1 fk:flex fk:h-4 fk:min-w-4 fk:items-center fk:justify-center fk:rounded-full fk:bg-amber-500 fk:px-1 fk:text-[0.625rem] fk:font-semibold fk:leading-none fk:text-white\">\n {formatCount(needsAction)}\n </span>\n ) : unread > 0 ? (\n <span className=\"fk:absolute fk:right-1 fk:top-1 fk:size-2 fk:rounded-full fk:bg-success\" />\n ) : null}\n </Link>\n </Button>\n </TooltipTrigger>\n <TooltipContent>{label}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n );\n}\n"]}
@@ -1,2 +1,2 @@
1
- import'./index.css';import {q as q$1,o,r}from'./chunk-KR27GOH6.js';import {f}from'./chunk-HZOD2HOF.js';import {d}from'./chunk-WPCPL2TQ.js';import {useCallback}from'react';import {toast}from'sonner';import {useApolloClient}from'@apollo/client/react';function E(i){let{currentProjectSchema:t}=f();return useCallback(a=>{t&&q$1(o(i,t),a);},[i,t])}var g=["image/jpeg","image/png","image/webp","image/vnd.microsoft.icon","image/bmp","image/gif","image/tiff","image/svg+xml","image/avif","image/heic","image/heif","image/heic-sequence","image/heif-sequence","image/apng","audio/aac","audio/mpeg","audio/wav","audio/webm","audio/midi","audio/x-midi","audio/ogg","video/x-msvideo","video/mp4","video/mpeg","video/webm","video/quicktime","video/ogg","video/mp2t","video/3gpp","video/3gpp2","application/x-7z-compressed","application/zip","application/vnd.amazon.ebook","application/octet-stream","application/epub+zip","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-fontobject","application/gzip","application/x-gzip","application/java-archive","application/json","application/ld+json","text/javascript","application/vnd.oasis.opendocument.presentation","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.text","application/ogg","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.rar","application/x-tar","application/vnd.visio","application/xhtml+xml","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/xml"];function F(i,t){if(!i.type)return true;let a=t?t.split(",").map(e=>e.trim()).filter(Boolean):g;return a.length===0?true:a.some(e=>e.endsWith("/*")?i.type.startsWith(e.slice(0,-1)):i.type===e)}async function x(i,t){let a=new URLSearchParams({filename:i.name}),e=await fetch(`${d(t).assets}?${a.toString()}`,{method:"POST",headers:{"Content-Type":i.type||"application/octet-stream"},body:i});if(!e.ok)throw new Error(`Upload failed for ${i.name}`);let n=await e.json(),o={_id:n._id,path:n.path??"",originalFilename:n.originalFilename??i.name,size:n.size??i.size,mimeType:n.mimeType??i.type,lqip:n.lqip??"",width:n.width??0,height:n.height??0};return {pathname:o.path,lqip:o.lqip||void 0,originalFilename:o.originalFilename,size:o.size,mimeType:o.mimeType,width:o.width||void 0,height:o.height||void 0,_id:o._id,asset:o}}async function h(i,t){let{projectId:a,accept:e,maxBytes:n=4*1024*1024,onUploadStart:o}=t,l=[];for(let p of Array.from(i)){if(p.size>n){toast.error(`File size too big (max ${(n/(1024*1024)).toFixed(0)}MB): ${p.name}`);continue}if(!F(p,e)){toast.error(`Unsupported file type: ${p.name}`);continue}l.push(p);}if(l.length===0)return [];o?.();try{let p=await Promise.all(l.map(async f=>x(f,a)));return p.length>0&&toast.success(`Uploaded ${p.length} file${p.length>1?"s":""}`),p}catch(p){return console.error(p),toast.error("Upload failed. Please try again."),[]}}async function b(i){let{accept:t,multiple:a=true}=i,e=document.createElement("input");e.type="file",e.accept=t??g.join(","),e.multiple=a,e.style.display="none",document.body.appendChild(e);try{let n=await new Promise(o=>{e.addEventListener("change",()=>o(e.files),{once:!0}),e.addEventListener("cancel",()=>o(null),{once:!0}),e.click();});return !n||n.length===0?[]:h(n,i)}finally{document.body.removeChild(e);}}function q(){let i=useApolloClient();return useCallback(async t=>{let a=t.files?await h(t.files,t):await b(t);return a.length>0&&await r(i,"GetAssets").catch(e=>{console.error("Error refreshing asset lists after upload:",e);}),a},[i])}export{E as a,x as b,q as c};//# sourceMappingURL=chunk-ONB3FWK5.js.map
2
- //# sourceMappingURL=chunk-ONB3FWK5.js.map
1
+ import'./index.css';import {q as q$1,o,r}from'./chunk-PC5Z37LT.js';import {f}from'./chunk-VRDTHLA3.js';import {d}from'./chunk-MBBE4RND.js';import {useCallback}from'react';import {toast}from'sonner';import {useApolloClient}from'@apollo/client/react';function E(i){let{currentProjectSchema:t}=f();return useCallback(a=>{t&&q$1(o(i,t),a);},[i,t])}var g=["image/jpeg","image/png","image/webp","image/vnd.microsoft.icon","image/bmp","image/gif","image/tiff","image/svg+xml","image/avif","image/heic","image/heif","image/heic-sequence","image/heif-sequence","image/apng","audio/aac","audio/mpeg","audio/wav","audio/webm","audio/midi","audio/x-midi","audio/ogg","video/x-msvideo","video/mp4","video/mpeg","video/webm","video/quicktime","video/ogg","video/mp2t","video/3gpp","video/3gpp2","application/x-7z-compressed","application/zip","application/vnd.amazon.ebook","application/octet-stream","application/epub+zip","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-fontobject","application/gzip","application/x-gzip","application/java-archive","application/json","application/ld+json","text/javascript","application/vnd.oasis.opendocument.presentation","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.text","application/ogg","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.rar","application/x-tar","application/vnd.visio","application/xhtml+xml","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/xml"];function F(i,t){if(!i.type)return true;let a=t?t.split(",").map(e=>e.trim()).filter(Boolean):g;return a.length===0?true:a.some(e=>e.endsWith("/*")?i.type.startsWith(e.slice(0,-1)):i.type===e)}async function x(i,t){let a=new URLSearchParams({filename:i.name}),e=await fetch(`${d(t).assets}?${a.toString()}`,{method:"POST",headers:{"Content-Type":i.type||"application/octet-stream"},body:i});if(!e.ok)throw new Error(`Upload failed for ${i.name}`);let n=await e.json(),o={_id:n._id,path:n.path??"",originalFilename:n.originalFilename??i.name,size:n.size??i.size,mimeType:n.mimeType??i.type,lqip:n.lqip??"",width:n.width??0,height:n.height??0};return {pathname:o.path,lqip:o.lqip||void 0,originalFilename:o.originalFilename,size:o.size,mimeType:o.mimeType,width:o.width||void 0,height:o.height||void 0,_id:o._id,asset:o}}async function h(i,t){let{projectId:a,accept:e,maxBytes:n=4*1024*1024,onUploadStart:o}=t,l=[];for(let p of Array.from(i)){if(p.size>n){toast.error(`File size too big (max ${(n/(1024*1024)).toFixed(0)}MB): ${p.name}`);continue}if(!F(p,e)){toast.error(`Unsupported file type: ${p.name}`);continue}l.push(p);}if(l.length===0)return [];o?.();try{let p=await Promise.all(l.map(async f=>x(f,a)));return p.length>0&&toast.success(`Uploaded ${p.length} file${p.length>1?"s":""}`),p}catch(p){return console.error(p),toast.error("Upload failed. Please try again."),[]}}async function b(i){let{accept:t,multiple:a=true}=i,e=document.createElement("input");e.type="file",e.accept=t??g.join(","),e.multiple=a,e.style.display="none",document.body.appendChild(e);try{let n=await new Promise(o=>{e.addEventListener("change",()=>o(e.files),{once:!0}),e.addEventListener("cancel",()=>o(null),{once:!0}),e.click();});return !n||n.length===0?[]:h(n,i)}finally{document.body.removeChild(e);}}function q(){let i=useApolloClient();return useCallback(async t=>{let a=t.files?await h(t.files,t):await b(t);return a.length>0&&await r(i,"GetAssets").catch(e=>{console.error("Error refreshing asset lists after upload:",e);}),a},[i])}export{E as a,x as b,q as c};//# sourceMappingURL=chunk-3OBELKJU.js.map
2
+ //# sourceMappingURL=chunk-3OBELKJU.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphql-client/use-patch-entity-list.ts","../src/core/upload.ts"],"names":["usePatchEntityList","entityNameOrPlural","schema","useConfig","useCallback","patches","scheduleEntityListPatch","getEntityListQueryName","ACCEPTED_MIME_TYPES","isAcceptedMimeType","file","accept","allowed","pattern","uploadAssetFile","projectId","params","response","apiPaths","data","asset","uploadSelectedFiles","files","options","maxBytes","onUploadStart","validFiles","toast","uploads","error","openFileDialogAndUpload","multiple","input","resolve","useUploadAssets","apolloClient","useApolloClient","scheduleEntityListRefetch"],"mappings":"yPAYO,SAASA,EAAmBC,CAAAA,CAAqE,CACtG,GAAM,CAAE,oBAAA,CAAsBC,CAAO,CAAA,CAAIC,CAAAA,GAEzC,OAAOC,WAAAA,CACJC,CAAAA,EAAkC,CAC5BH,CAAAA,EAILI,GAAAA,CAAwBC,CAAAA,CAAuBN,CAAAA,CAAoBC,CAAM,CAAA,CAAGG,CAAO,EACrF,CAAA,CACA,CAACJ,CAAAA,CAAoBC,CAAM,CAC7B,CACF,CClBO,IAAMM,CAAAA,CAAsB,CACjC,YAAA,CACA,YACA,YAAA,CACA,0BAAA,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jC,CACF,CAEO,SAASE,CAAAA,EAA+F,CAC7G,IAAMC,EAAeC,eAAAA,EAAgB,CAErC,OAAOhC,WAAAA,CACL,MAAOmB,CAAAA,EAA4C,CACjD,IAAMK,EAAUL,CAAAA,CAAQ,KAAA,CACpB,MAAMF,CAAAA,CAAoBE,CAAAA,CAAQ,KAAA,CAAOA,CAAO,CAAA,CAChD,MAAMO,CAAAA,CAAwBP,CAAO,CAAA,CAEzC,OAAIK,CAAAA,CAAQ,MAAA,CAAS,CAAA,EAEnB,MAAMS,EAA0BF,CAAAA,CAAc,WAAW,CAAA,CAAE,KAAA,CAAON,CAAAA,EAAmB,CACnF,OAAA,CAAQ,KAAA,CAAM,6CAA8CA,CAAK,EACnE,CAAC,CAAA,CAGID,CACT,CAAA,CACA,CAACO,CAAY,CACf,CACF","file":"chunk-ONB3FWK5.js","sourcesContent":["import { useCallback } from 'react';\nimport { useConfig } from '../core/config/config-context';\nimport {\n getEntityListQueryName,\n scheduleEntityListPatch,\n type EntityListRowPatch,\n} from './refetch-entity-lists';\n\n/**\n * Patch active list rows for an entity without a soft-refetch.\n * Prefer this after mutations that only change row fields (e.g. tag connect/disconnect).\n */\nexport function usePatchEntityList(entityNameOrPlural: string): (patches: EntityListRowPatch[]) => void {\n const { currentProjectSchema: schema } = useConfig();\n\n return useCallback(\n (patches: EntityListRowPatch[]) => {\n if (!schema) {\n return;\n }\n\n scheduleEntityListPatch(getEntityListQueryName(entityNameOrPlural, schema), patches);\n },\n [entityNameOrPlural, schema]\n );\n}\n","import { useCallback } from 'react';\nimport { toast } from 'sonner';\nimport { useApolloClient } from '@apollo/client/react';\nimport { apiPaths } from './api-paths';\nimport { scheduleEntityListRefetch } from '../graphql-client/refetch-entity-lists';\nimport type { OrderedAssetValue } from '../graphql-client/types';\n\nexport const ACCEPTED_MIME_TYPES = [\n 'image/jpeg',\n 'image/png',\n 'image/webp',\n 'image/vnd.microsoft.icon',\n 'image/bmp',\n 'image/gif',\n 'image/tiff',\n 'image/svg+xml',\n 'image/avif',\n 'image/heic',\n 'image/heif',\n 'image/heic-sequence',\n 'image/heif-sequence',\n 'image/apng',\n 'audio/aac',\n 'audio/mpeg',\n 'audio/wav',\n 'audio/webm',\n 'audio/midi',\n 'audio/x-midi',\n 'audio/ogg',\n 'video/x-msvideo',\n 'video/mp4',\n 'video/mpeg',\n 'video/webm',\n 'video/quicktime',\n 'video/ogg',\n 'video/mp2t',\n 'video/3gpp',\n 'video/3gpp2',\n 'application/x-7z-compressed',\n 'application/zip',\n 'application/vnd.amazon.ebook',\n 'application/octet-stream',\n 'application/epub+zip',\n 'application/pdf',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'application/vnd.ms-fontobject',\n 'application/gzip',\n 'application/x-gzip',\n 'application/java-archive',\n 'application/json',\n 'application/ld+json',\n 'text/javascript',\n 'application/vnd.oasis.opendocument.presentation',\n 'application/vnd.oasis.opendocument.spreadsheet',\n 'application/vnd.oasis.opendocument.text',\n 'application/ogg',\n 'application/vnd.ms-powerpoint',\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n 'application/vnd.rar',\n 'application/x-tar',\n 'application/vnd.visio',\n 'application/xhtml+xml',\n 'application/vnd.ms-excel',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/xml',\n];\n\nexport type UploadedFileResult = {\n pathname: string;\n lqip?: string;\n size: number;\n mimeType: string;\n originalFilename: string;\n width?: number;\n height?: number;\n};\n\nexport type UploadedAssetResult = UploadedFileResult & {\n asset: OrderedAssetValue;\n _id: string;\n};\n\ntype AssetUploadResponse = {\n _id: string;\n path: string | null;\n mimeType: string | null;\n originalFilename: string | null;\n size: number | null;\n width: number | null;\n height: number | null;\n lqip: string | null;\n sha256: string | null;\n deduped: boolean;\n};\n\nexport type OpenFileDialogAndUploadOptions = {\n projectId: string | undefined;\n accept?: string;\n files?: File[] | FileList;\n multiple?: boolean;\n maxBytes?: number;\n onUploadStart?: () => void;\n};\n\nfunction isAcceptedMimeType(file: File, accept?: string): boolean {\n if (!file.type) {\n return true;\n }\n\n const allowed = accept\n ? accept\n .split(',')\n .map((pattern) => pattern.trim())\n .filter(Boolean)\n : ACCEPTED_MIME_TYPES;\n\n if (allowed.length === 0) {\n return true;\n }\n\n return allowed.some((pattern) => {\n if (pattern.endsWith('/*')) {\n return file.type.startsWith(pattern.slice(0, -1));\n }\n\n return file.type === pattern;\n });\n}\n\n/**\n * Uploads a single file to the one-shot /assets endpoint, which stores the\n * blob and creates the _asset node in a single request.\n */\nexport async function uploadAssetFile(file: File, projectId: string | undefined): Promise<UploadedAssetResult> {\n const params = new URLSearchParams({ filename: file.name });\n const response = await fetch(`${apiPaths(projectId).assets}?${params.toString()}`, {\n method: 'POST',\n headers: { 'Content-Type': file.type || 'application/octet-stream' },\n body: file,\n });\n\n if (!response.ok) {\n throw new Error(`Upload failed for ${file.name}`);\n }\n\n const data = (await response.json()) as AssetUploadResponse;\n const asset: OrderedAssetValue = {\n _id: data._id,\n path: data.path ?? '',\n originalFilename: data.originalFilename ?? file.name,\n size: data.size ?? file.size,\n mimeType: data.mimeType ?? file.type,\n lqip: data.lqip ?? '',\n width: data.width ?? 0,\n height: data.height ?? 0,\n };\n\n return {\n pathname: asset.path,\n lqip: asset.lqip || undefined,\n originalFilename: asset.originalFilename,\n size: asset.size,\n mimeType: asset.mimeType,\n width: asset.width || undefined,\n height: asset.height || undefined,\n _id: asset._id,\n asset,\n };\n}\n\nasync function uploadSelectedFiles(\n files: File[] | FileList,\n options: OpenFileDialogAndUploadOptions\n): Promise<UploadedAssetResult[]> {\n const { projectId, accept, maxBytes = 4 * 1024 * 1024, onUploadStart } = options;\n const validFiles: File[] = [];\n\n for (const file of Array.from(files)) {\n if (file.size > maxBytes) {\n toast.error(`File size too big (max ${(maxBytes / (1024 * 1024)).toFixed(0)}MB): ${file.name}`);\n\n continue;\n }\n\n if (!isAcceptedMimeType(file, accept)) {\n toast.error(`Unsupported file type: ${file.name}`);\n\n continue;\n }\n\n validFiles.push(file);\n }\n\n if (validFiles.length === 0) {\n return [];\n }\n\n onUploadStart?.();\n\n try {\n const uploads = await Promise.all(validFiles.map(async (file) => uploadAssetFile(file, projectId)));\n\n if (uploads.length > 0) {\n toast.success(`Uploaded ${uploads.length} file${uploads.length > 1 ? 's' : ''}`);\n }\n\n return uploads;\n } catch (error) {\n console.error(error);\n toast.error('Upload failed. Please try again.');\n\n return [];\n }\n}\n\n/**\n * Opens a native file picker and uploads selected files to the Flexkit assets\n * endpoint, which also creates an asset node in the database.\n * Returns a list of uploaded file results. Skips files that exceed maxBytes.\n */\nasync function openFileDialogAndUpload(options: OpenFileDialogAndUploadOptions): Promise<UploadedAssetResult[]> {\n const { accept, multiple = true } = options;\n const input = document.createElement('input');\n input.type = 'file';\n input.accept = accept ?? ACCEPTED_MIME_TYPES.join(',');\n input.multiple = multiple;\n input.style.display = 'none';\n document.body.appendChild(input);\n\n try {\n const files = await new Promise<FileList | null>((resolve) => {\n input.addEventListener('change', () => resolve(input.files), { once: true });\n input.addEventListener('cancel', () => resolve(null), { once: true });\n input.click();\n });\n\n if (!files || files.length === 0) {\n return [];\n }\n\n return uploadSelectedFiles(files, options);\n } finally {\n document.body.removeChild(input);\n }\n}\n\nexport function useUploadAssets(): (options: OpenFileDialogAndUploadOptions) => Promise<UploadedAssetResult[]> {\n const apolloClient = useApolloClient();\n\n return useCallback(\n async (options: OpenFileDialogAndUploadOptions) => {\n const uploads = options.files\n ? await uploadSelectedFiles(options.files, options)\n : await openFileDialogAndUpload(options);\n\n if (uploads.length > 0) {\n // Upload is outside Apollo; soft-refresh mounted asset lists via useEntityQuery.\n await scheduleEntityListRefetch(apolloClient, 'GetAssets').catch((error: unknown) => {\n console.error('Error refreshing asset lists after upload:', error);\n });\n }\n\n return uploads;\n },\n [apolloClient]\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/graphql-client/use-patch-entity-list.ts","../src/core/upload.ts"],"names":["usePatchEntityList","entityNameOrPlural","schema","useConfig","useCallback","patches","scheduleEntityListPatch","getEntityListQueryName","ACCEPTED_MIME_TYPES","isAcceptedMimeType","file","accept","allowed","pattern","uploadAssetFile","projectId","params","response","apiPaths","data","asset","uploadSelectedFiles","files","options","maxBytes","onUploadStart","validFiles","toast","uploads","error","openFileDialogAndUpload","multiple","input","resolve","useUploadAssets","apolloClient","useApolloClient","scheduleEntityListRefetch"],"mappings":"yPAYO,SAASA,EAAmBC,CAAAA,CAAqE,CACtG,GAAM,CAAE,oBAAA,CAAsBC,CAAO,CAAA,CAAIC,CAAAA,GAEzC,OAAOC,WAAAA,CACJC,CAAAA,EAAkC,CAC5BH,CAAAA,EAILI,GAAAA,CAAwBC,CAAAA,CAAuBN,CAAAA,CAAoBC,CAAM,CAAA,CAAGG,CAAO,EACrF,CAAA,CACA,CAACJ,CAAAA,CAAoBC,CAAM,CAC7B,CACF,CClBO,IAAMM,CAAAA,CAAsB,CACjC,YAAA,CACA,YACA,YAAA,CACA,0BAAA,CACA,WAAA,CACA,WAAA,CACA,YAAA,CACA,eAAA,CACA,YAAA,CACA,YAAA,CACA,aACA,qBAAA,CACA,qBAAA,CACA,YAAA,CACA,WAAA,CACA,YAAA,CACA,WAAA,CACA,YAAA,CACA,YAAA,CACA,eACA,WAAA,CACA,iBAAA,CACA,WAAA,CACA,YAAA,CACA,YAAA,CACA,iBAAA,CACA,WAAA,CACA,YAAA,CACA,aACA,aAAA,CACA,6BAAA,CACA,iBAAA,CACA,8BAAA,CACA,0BAAA,CACA,sBAAA,CACA,iBAAA,CACA,oBAAA,CACA,0EACA,+BAAA,CACA,kBAAA,CACA,oBAAA,CACA,0BAAA,CACA,kBAAA,CACA,qBAAA,CACA,iBAAA,CACA,iDAAA,CACA,iDACA,yCAAA,CACA,iBAAA,CACA,+BAAA,CACA,2EAAA,CACA,qBAAA,CACA,mBAAA,CACA,uBAAA,CACA,uBAAA,CACA,2BACA,mEAAA,CACA,iBACF,CAAA,CAuCA,SAASC,CAAAA,CAAmBC,CAA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,CACtB,QAAA,CAAS,IAAA,CAAK,WAAA,CAAYA,CAAK,CAAA,CAE/B,GAAI,CACF,IAAMV,CAAAA,CAAQ,MAAM,IAAI,OAAA,CAA0BW,CAAAA,EAAY,CAC5DD,CAAAA,CAAM,iBAAiB,QAAA,CAAU,IAAMC,CAAAA,CAAQD,CAAAA,CAAM,KAAK,CAAA,CAAG,CAAE,IAAA,CAAM,EAAK,CAAC,CAAA,CAC3EA,CAAAA,CAAM,gBAAA,CAAiB,QAAA,CAAU,IAAMC,CAAAA,CAAQ,IAAI,EAAG,CAAE,IAAA,CAAM,CAAA,CAAK,CAAC,CAAA,CACpED,CAAAA,CAAM,KAAA,GACR,CAAC,CAAA,CAED,OAAI,CAACV,CAAAA,EAASA,CAAAA,CAAM,MAAA,GAAW,CAAA,CACtB,GAGFD,CAAAA,CAAoBC,CAAAA,CAAOC,CAAO,CAC3C,CAAA,OAAE,CACA,QAAA,CAAS,IAAA,CAAK,YAAYS,CAAK,EACjC,CACF,CAEO,SAASE,CAAAA,EAA+F,CAC7G,IAAMC,EAAeC,eAAAA,EAAgB,CAErC,OAAOhC,WAAAA,CACL,MAAOmB,CAAAA,EAA4C,CACjD,IAAMK,EAAUL,CAAAA,CAAQ,KAAA,CACpB,MAAMF,CAAAA,CAAoBE,CAAAA,CAAQ,KAAA,CAAOA,CAAO,CAAA,CAChD,MAAMO,CAAAA,CAAwBP,CAAO,CAAA,CAEzC,OAAIK,CAAAA,CAAQ,MAAA,CAAS,CAAA,EAEnB,MAAMS,EAA0BF,CAAAA,CAAc,WAAW,CAAA,CAAE,KAAA,CAAON,CAAAA,EAAmB,CACnF,OAAA,CAAQ,KAAA,CAAM,6CAA8CA,CAAK,EACnE,CAAC,CAAA,CAGID,CACT,CAAA,CACA,CAACO,CAAY,CACf,CACF","file":"chunk-3OBELKJU.js","sourcesContent":["import { useCallback } from 'react';\nimport { useConfig } from '../core/config/config-context';\nimport {\n getEntityListQueryName,\n scheduleEntityListPatch,\n type EntityListRowPatch,\n} from './refetch-entity-lists';\n\n/**\n * Patch active list rows for an entity without a soft-refetch.\n * Prefer this after mutations that only change row fields (e.g. tag connect/disconnect).\n */\nexport function usePatchEntityList(entityNameOrPlural: string): (patches: EntityListRowPatch[]) => void {\n const { currentProjectSchema: schema } = useConfig();\n\n return useCallback(\n (patches: EntityListRowPatch[]) => {\n if (!schema) {\n return;\n }\n\n scheduleEntityListPatch(getEntityListQueryName(entityNameOrPlural, schema), patches);\n },\n [entityNameOrPlural, schema]\n );\n}\n","import { useCallback } from 'react';\nimport { toast } from 'sonner';\nimport { useApolloClient } from '@apollo/client/react';\nimport { apiPaths } from './api-paths';\nimport { scheduleEntityListRefetch } from '../graphql-client/refetch-entity-lists';\nimport type { OrderedAssetValue } from '../graphql-client/types';\n\nexport const ACCEPTED_MIME_TYPES = [\n 'image/jpeg',\n 'image/png',\n 'image/webp',\n 'image/vnd.microsoft.icon',\n 'image/bmp',\n 'image/gif',\n 'image/tiff',\n 'image/svg+xml',\n 'image/avif',\n 'image/heic',\n 'image/heif',\n 'image/heic-sequence',\n 'image/heif-sequence',\n 'image/apng',\n 'audio/aac',\n 'audio/mpeg',\n 'audio/wav',\n 'audio/webm',\n 'audio/midi',\n 'audio/x-midi',\n 'audio/ogg',\n 'video/x-msvideo',\n 'video/mp4',\n 'video/mpeg',\n 'video/webm',\n 'video/quicktime',\n 'video/ogg',\n 'video/mp2t',\n 'video/3gpp',\n 'video/3gpp2',\n 'application/x-7z-compressed',\n 'application/zip',\n 'application/vnd.amazon.ebook',\n 'application/octet-stream',\n 'application/epub+zip',\n 'application/pdf',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'application/vnd.ms-fontobject',\n 'application/gzip',\n 'application/x-gzip',\n 'application/java-archive',\n 'application/json',\n 'application/ld+json',\n 'text/javascript',\n 'application/vnd.oasis.opendocument.presentation',\n 'application/vnd.oasis.opendocument.spreadsheet',\n 'application/vnd.oasis.opendocument.text',\n 'application/ogg',\n 'application/vnd.ms-powerpoint',\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n 'application/vnd.rar',\n 'application/x-tar',\n 'application/vnd.visio',\n 'application/xhtml+xml',\n 'application/vnd.ms-excel',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/xml',\n];\n\nexport type UploadedFileResult = {\n pathname: string;\n lqip?: string;\n size: number;\n mimeType: string;\n originalFilename: string;\n width?: number;\n height?: number;\n};\n\nexport type UploadedAssetResult = UploadedFileResult & {\n asset: OrderedAssetValue;\n _id: string;\n};\n\ntype AssetUploadResponse = {\n _id: string;\n path: string | null;\n mimeType: string | null;\n originalFilename: string | null;\n size: number | null;\n width: number | null;\n height: number | null;\n lqip: string | null;\n sha256: string | null;\n deduped: boolean;\n};\n\nexport type OpenFileDialogAndUploadOptions = {\n projectId: string | undefined;\n accept?: string;\n files?: File[] | FileList;\n multiple?: boolean;\n maxBytes?: number;\n onUploadStart?: () => void;\n};\n\nfunction isAcceptedMimeType(file: File, accept?: string): boolean {\n if (!file.type) {\n return true;\n }\n\n const allowed = accept\n ? accept\n .split(',')\n .map((pattern) => pattern.trim())\n .filter(Boolean)\n : ACCEPTED_MIME_TYPES;\n\n if (allowed.length === 0) {\n return true;\n }\n\n return allowed.some((pattern) => {\n if (pattern.endsWith('/*')) {\n return file.type.startsWith(pattern.slice(0, -1));\n }\n\n return file.type === pattern;\n });\n}\n\n/**\n * Uploads a single file to the one-shot /assets endpoint, which stores the\n * blob and creates the _asset node in a single request.\n */\nexport async function uploadAssetFile(file: File, projectId: string | undefined): Promise<UploadedAssetResult> {\n const params = new URLSearchParams({ filename: file.name });\n const response = await fetch(`${apiPaths(projectId).assets}?${params.toString()}`, {\n method: 'POST',\n headers: { 'Content-Type': file.type || 'application/octet-stream' },\n body: file,\n });\n\n if (!response.ok) {\n throw new Error(`Upload failed for ${file.name}`);\n }\n\n const data = (await response.json()) as AssetUploadResponse;\n const asset: OrderedAssetValue = {\n _id: data._id,\n path: data.path ?? '',\n originalFilename: data.originalFilename ?? file.name,\n size: data.size ?? file.size,\n mimeType: data.mimeType ?? file.type,\n lqip: data.lqip ?? '',\n width: data.width ?? 0,\n height: data.height ?? 0,\n };\n\n return {\n pathname: asset.path,\n lqip: asset.lqip || undefined,\n originalFilename: asset.originalFilename,\n size: asset.size,\n mimeType: asset.mimeType,\n width: asset.width || undefined,\n height: asset.height || undefined,\n _id: asset._id,\n asset,\n };\n}\n\nasync function uploadSelectedFiles(\n files: File[] | FileList,\n options: OpenFileDialogAndUploadOptions\n): Promise<UploadedAssetResult[]> {\n const { projectId, accept, maxBytes = 4 * 1024 * 1024, onUploadStart } = options;\n const validFiles: File[] = [];\n\n for (const file of Array.from(files)) {\n if (file.size > maxBytes) {\n toast.error(`File size too big (max ${(maxBytes / (1024 * 1024)).toFixed(0)}MB): ${file.name}`);\n\n continue;\n }\n\n if (!isAcceptedMimeType(file, accept)) {\n toast.error(`Unsupported file type: ${file.name}`);\n\n continue;\n }\n\n validFiles.push(file);\n }\n\n if (validFiles.length === 0) {\n return [];\n }\n\n onUploadStart?.();\n\n try {\n const uploads = await Promise.all(validFiles.map(async (file) => uploadAssetFile(file, projectId)));\n\n if (uploads.length > 0) {\n toast.success(`Uploaded ${uploads.length} file${uploads.length > 1 ? 's' : ''}`);\n }\n\n return uploads;\n } catch (error) {\n console.error(error);\n toast.error('Upload failed. Please try again.');\n\n return [];\n }\n}\n\n/**\n * Opens a native file picker and uploads selected files to the Flexkit assets\n * endpoint, which also creates an asset node in the database.\n * Returns a list of uploaded file results. Skips files that exceed maxBytes.\n */\nasync function openFileDialogAndUpload(options: OpenFileDialogAndUploadOptions): Promise<UploadedAssetResult[]> {\n const { accept, multiple = true } = options;\n const input = document.createElement('input');\n input.type = 'file';\n input.accept = accept ?? ACCEPTED_MIME_TYPES.join(',');\n input.multiple = multiple;\n input.style.display = 'none';\n document.body.appendChild(input);\n\n try {\n const files = await new Promise<FileList | null>((resolve) => {\n input.addEventListener('change', () => resolve(input.files), { once: true });\n input.addEventListener('cancel', () => resolve(null), { once: true });\n input.click();\n });\n\n if (!files || files.length === 0) {\n return [];\n }\n\n return uploadSelectedFiles(files, options);\n } finally {\n document.body.removeChild(input);\n }\n}\n\nexport function useUploadAssets(): (options: OpenFileDialogAndUploadOptions) => Promise<UploadedAssetResult[]> {\n const apolloClient = useApolloClient();\n\n return useCallback(\n async (options: OpenFileDialogAndUploadOptions) => {\n const uploads = options.files\n ? await uploadSelectedFiles(options.files, options)\n : await openFileDialogAndUpload(options);\n\n if (uploads.length > 0) {\n // Upload is outside Apollo; soft-refresh mounted asset lists via useEntityQuery.\n await scheduleEntityListRefetch(apolloClient, 'GetAssets').catch((error: unknown) => {\n console.error('Error refreshing asset lists after upload:', error);\n });\n }\n\n return uploads;\n },\n [apolloClient]\n );\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import'./index.css';import {a,c}from'./chunk-X3SHNHHM.js';import {AlertDialog}from'radix-ui';import {jsx,jsxs}from'react/jsx-runtime';function p({...t}){return jsx(AlertDialog.Root,{"data-slot":"alert-dialog",...t})}function s({...t}){return jsx(AlertDialog.Portal,{"data-slot":"alert-dialog-portal",...t})}function d({className:t,...a$1}){return jsx(AlertDialog.Overlay,{"data-slot":"alert-dialog-overlay",className:a("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",t),...a$1})}function u({className:t,size:a$1="default",...i}){return jsxs(s,{children:[jsx(d,{}),jsx(AlertDialog.Content,{"data-slot":"alert-dialog-content","data-size":a$1,className:a("fk:group/alert-dialog-content fk:fixed fk:top-[50%] fk:left-[50%] fk:z-50 fk:grid fk:w-full fk:max-w-[calc(100%-2rem)] fk:translate-x-[-50%] fk:translate-y-[-50%] fk:gap-4 fk:rounded-lg fk:border fk:bg-background fk:p-6 fk:shadow-lg fk:duration-200 fk:data-[size=sm]:max-w-xs fk:data-[state=closed]:animate-out fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:zoom-out-95 fk:data-[state=open]:animate-in fk:data-[state=open]:fade-in-0 fk:data-[state=open]:zoom-in-95 fk:data-[size=default]:sm:max-w-lg fk:corner-squircle",t),...i})]})}function k({className:t,...a$1}){return jsx("div",{"data-slot":"alert-dialog-header",className:a("fk:grid fk:grid-rows-[auto_1fr] fk:place-items-center fk:gap-1.5 fk:text-center fk:has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] fk:has-data-[slot=alert-dialog-media]:gap-x-6 fk:sm:group-data-[size=default]/alert-dialog-content:place-items-start fk:sm:group-data-[size=default]/alert-dialog-content:text-left fk:sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),...a$1})}function P({className:t,...a$1}){return jsx("div",{"data-slot":"alert-dialog-footer",className:a("fk:flex fk:flex-col-reverse fk:gap-2 fk:group-data-[size=sm]/alert-dialog-content:grid fk:group-data-[size=sm]/alert-dialog-content:grid-cols-2 fk:sm:flex-row fk:sm:justify-end",t),...a$1})}function A({className:t,...a$1}){return jsx(AlertDialog.Title,{"data-slot":"alert-dialog-title",className:a("fk:text-lg fk:font-semibold fk:sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),...a$1})}function D({className:t,...a$1}){return jsx(AlertDialog.Description,{"data-slot":"alert-dialog-description",className:a("fk:text-sm fk:text-muted-foreground",t),...a$1})}function v({className:t,variant:a$1="default",size:i="default",...r}){return jsx(c,{variant:a$1,size:i,asChild:true,children:jsx(AlertDialog.Action,{"data-slot":"alert-dialog-action",className:a(t),...r})})}function z({className:t,variant:a$1="outline",size:i="default",...r}){return jsx(c,{variant:a$1,size:i,asChild:true,children:jsx(AlertDialog.Cancel,{"data-slot":"alert-dialog-cancel",className:a(t),...r})})}export{p as a,s as b,u as c,k as d,P as e,A as f,D as g,v as h,z as i};//# sourceMappingURL=chunk-4ZWQ44NZ.js.map
2
+ //# sourceMappingURL=chunk-4ZWQ44NZ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ui/primitives/alert-dialog.tsx"],"names":["AlertDialog","props","jsx","AlertDialogPrimitive","AlertDialogPortal","AlertDialogOverlay","className","cn","AlertDialogContent","size","jsxs","AlertDialogHeader","AlertDialogFooter","AlertDialogTitle","AlertDialogDescription","AlertDialogAction","variant","Button","AlertDialogCancel"],"mappings":"wKAOA,SAASA,CAAAA,CAAY,CAAE,GAAGC,CAAM,EAA2D,CACzF,OAAOC,GAAAA,CAACC,WAAAA,CAAqB,IAAA,CAArB,CAA0B,WAAA,CAAU,cAAA,CAAgB,GAAGF,CAAAA,CAAO,CACxE,CAMA,SAASG,CAAAA,CAAkB,CAAE,GAAGH,CAAM,EAA6D,CACjG,OAAOC,GAAAA,CAACC,WAAAA,CAAqB,MAAA,CAArB,CAA4B,WAAA,CAAU,qBAAA,CAAuB,GAAGF,CAAAA,CAAO,CACjF,CAEA,SAASI,CAAAA,CAAmB,CAAE,SAAA,CAAAC,CAAAA,CAAW,GAAGL,GAAM,CAAA,CAA8D,CAC9G,OACEC,GAAAA,CAACC,WAAAA,CAAqB,OAAA,CAArB,CACC,YAAU,sBAAA,CACV,SAAA,CAAWI,CAAAA,CACT,wJAAA,CACAD,CACF,CAAA,CACC,GAAGL,GAAAA,CACN,CAEJ,CAEA,SAASO,CAAAA,CAAmB,CAC1B,SAAA,CAAAF,CAAAA,CACA,IAAA,CAAAG,GAAAA,CAAO,UACP,GAAGR,CACL,CAAA,CAEG,CACD,OACES,IAAAA,CAACN,CAAAA,CAAA,CACC,UAAAF,GAAAA,CAACG,CAAAA,CAAA,EAAmB,CAAA,CACpBH,GAAAA,CAACC,WAAAA,CAAqB,OAAA,CAArB,CACC,YAAU,sBAAA,CACV,WAAA,CAAWM,GAAAA,CACX,SAAA,CAAWF,CAAAA,CACT,khBAAA,CACAD,CACF,CAAA,CACC,GAAGL,CAAAA,CACN,CAAA,CAAA,CACF,CAEJ,CAEA,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AAA,CAArB,CAA4B,WAAA,CAAU,qBAAA,CAAsB,SAAA,CAAWI,CAAAA,CAAGD,CAAS,CAAA,CAAI,GAAGL,CAAAA,CAAO,CAAA,CACpG,CAEJ,CAEA,SAASiB,CAAAA,CAAkB,CACzB,SAAA,CAAAZ,CAAAA,CACA,OAAA,CAAAU,GAAAA,CAAU,SAAA,CACV,IAAA,CAAAP,CAAAA,CAAO,SAAA,CACP,GAAGR,CACL,CAAA,CACiE,CAC/D,OACEC,GAAAA,CAACe,CAAAA,CAAA,CAAO,OAAA,CAASD,IAAS,IAAA,CAAMP,CAAAA,CAAM,OAAA,CAAO,IAAA,CAC3C,QAAA,CAAAP,GAAAA,CAACC,WAAAA,CAAqB,MAAA,CAArB,CAA4B,WAAA,CAAU,qBAAA,CAAsB,SAAA,CAAWI,CAAAA,CAAGD,CAAS,CAAA,CAAI,GAAGL,CAAAA,CAAO,EACpG,CAEJ","file":"chunk-2NXQF2F7.js","sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { AlertDialog as AlertDialogPrimitive } from 'radix-ui';\nimport { cn } from '../lib/utils';\nimport { Button } from './button';\n\nfunction AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {\n return <AlertDialogPrimitive.Root data-slot=\"alert-dialog\" {...props} />;\n}\n\nfunction AlertDialogTrigger({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {\n return <AlertDialogPrimitive.Trigger data-slot=\"alert-dialog-trigger\" {...props} />;\n}\n\nfunction AlertDialogPortal({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {\n return <AlertDialogPrimitive.Portal data-slot=\"alert-dialog-portal\" {...props} />;\n}\n\nfunction AlertDialogOverlay({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {\n return (\n <AlertDialogPrimitive.Overlay\n data-slot=\"alert-dialog-overlay\"\n className={cn(\n 'fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0',\n className\n )}\n {...props}\n />\n );\n}\n\nfunction AlertDialogContent({\n className,\n size = 'default',\n ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Content> & {\n size?: 'default' | 'sm';\n}) {\n return (\n <AlertDialogPortal>\n <AlertDialogOverlay />\n <AlertDialogPrimitive.Content\n data-slot=\"alert-dialog-content\"\n data-size={size}\n className={cn(\n 'fk:group/alert-dialog-content fk:fixed fk:top-[50%] fk:left-[50%] fk:z-50 fk:grid fk:w-full fk:max-w-[calc(100%-2rem)] fk:translate-x-[-50%] fk:translate-y-[-50%] fk:gap-4 fk:rounded-lg fk:border fk:bg-background fk:p-6 fk:shadow-lg fk:duration-200 fk:data-[size=sm]:max-w-xs fk:data-[state=closed]:animate-out fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:zoom-out-95 fk:data-[state=open]:animate-in fk:data-[state=open]:fade-in-0 fk:data-[state=open]:zoom-in-95 fk:data-[size=default]:sm:max-w-lg fk:corner-squircle',\n className\n )}\n {...props}\n />\n </AlertDialogPortal>\n );\n}\n\nfunction AlertDialogHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-dialog-header\"\n className={cn(\n 'fk:grid fk:grid-rows-[auto_1fr] fk:place-items-center fk:gap-1.5 fk:text-center fk:has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] fk:has-data-[slot=alert-dialog-media]:gap-x-6 fk:sm:group-data-[size=default]/alert-dialog-content:place-items-start fk:sm:group-data-[size=default]/alert-dialog-content:text-left fk:sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]',\n className\n )}\n {...props}\n />\n );\n}\n\nfunction AlertDialogFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-dialog-footer\"\n className={cn(\n 'fk:flex fk:flex-col-reverse fk:gap-2 fk:group-data-[size=sm]/alert-dialog-content:grid fk:group-data-[size=sm]/alert-dialog-content:grid-cols-2 fk:sm:flex-row fk:sm:justify-end',\n className\n )}\n {...props}\n />\n );\n}\n\nfunction AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {\n return (\n <AlertDialogPrimitive.Title\n data-slot=\"alert-dialog-title\"\n className={cn(\n 'fk:text-lg fk:font-semibold fk:sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2',\n className\n )}\n {...props}\n />\n );\n}\n\nfunction AlertDialogDescription({\n className,\n ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {\n return (\n <AlertDialogPrimitive.Description\n data-slot=\"alert-dialog-description\"\n className={cn('fk:text-sm fk:text-muted-foreground', className)}\n {...props}\n />\n );\n}\n\nfunction AlertDialogMedia({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-dialog-media\"\n className={cn(\n \"fk:mb-2 fk:inline-flex fk:size-16 fk:items-center fk:justify-center fk:rounded-md fk:bg-muted fk:sm:group-data-[size=default]/alert-dialog-content:row-span-2 fk:*:[svg:not([class*='size-'])]:size-8 fk:corner-squircle\",\n className\n )}\n {...props}\n />\n );\n}\n\nfunction AlertDialogAction({\n className,\n variant = 'default',\n size = 'default',\n ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Action> &\n Pick<React.ComponentProps<typeof Button>, 'variant' | 'size'>) {\n return (\n <Button variant={variant} size={size} asChild>\n <AlertDialogPrimitive.Action data-slot=\"alert-dialog-action\" className={cn(className)} {...props} />\n </Button>\n );\n}\n\nfunction AlertDialogCancel({\n className,\n variant = 'outline',\n size = 'default',\n ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Cancel> &\n Pick<React.ComponentProps<typeof Button>, 'variant' | 'size'>) {\n return (\n <Button variant={variant} size={size} asChild>\n <AlertDialogPrimitive.Cancel data-slot=\"alert-dialog-cancel\" className={cn(className)} {...props} />\n </Button>\n );\n}\n\nexport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogMedia,\n AlertDialogOverlay,\n AlertDialogPortal,\n AlertDialogTitle,\n AlertDialogTrigger,\n};\n"]}
1
+ {"version":3,"sources":["../src/ui/primitives/alert-dialog.tsx"],"names":["AlertDialog","props","jsx","AlertDialogPrimitive","AlertDialogPortal","AlertDialogOverlay","className","cn","AlertDialogContent","size","jsxs","AlertDialogHeader","AlertDialogFooter","AlertDialogTitle","AlertDialogDescription","AlertDialogAction","variant","Button","AlertDialogCancel"],"mappings":"sIAOA,SAASA,CAAAA,CAAY,CAAE,GAAGC,CAAM,EAA2D,CACzF,OAAOC,GAAAA,CAACC,WAAAA,CAAqB,IAAA,CAArB,CAA0B,WAAA,CAAU,cAAA,CAAgB,GAAGF,CAAAA,CAAO,CACxE,CAMA,SAASG,CAAAA,CAAkB,CAAE,GAAGH,CAAM,EAA6D,CACjG,OAAOC,GAAAA,CAACC,WAAAA,CAAqB,MAAA,CAArB,CAA4B,WAAA,CAAU,qBAAA,CAAuB,GAAGF,CAAAA,CAAO,CACjF,CAEA,SAASI,CAAAA,CAAmB,CAAE,SAAA,CAAAC,CAAAA,CAAW,GAAGL,GAAM,CAAA,CAA8D,CAC9G,OACEC,GAAAA,CAACC,WAAAA,CAAqB,OAAA,CAArB,CACC,YAAU,sBAAA,CACV,SAAA,CAAWI,CAAAA,CACT,wJAAA,CACAD,CACF,CAAA,CACC,GAAGL,GAAAA,CACN,CAEJ,CAEA,SAASO,CAAAA,CAAmB,CAC1B,SAAA,CAAAF,CAAAA,CACA,IAAA,CAAAG,GAAAA,CAAO,UACP,GAAGR,CACL,CAAA,CAEG,CACD,OACES,IAAAA,CAACN,CAAAA,CAAA,CACC,UAAAF,GAAAA,CAACG,CAAAA,CAAA,EAAmB,CAAA,CACpBH,GAAAA,CAACC,WAAAA,CAAqB,OAAA,CA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iE,CAC/D,OACEC,IAACe,CAAAA,CAAA,CAAO,OAAA,CAASD,GAAAA,CAAS,IAAA,CAAMP,CAAAA,CAAM,OAAA,CAAO,IAAA,CAC3C,SAAAP,GAAAA,CAACC,WAAAA,CAAqB,MAAA,CAArB,CAA4B,WAAA,CAAU,qBAAA,CAAsB,SAAA,CAAWI,CAAAA,CAAGD,CAAS,CAAA,CAAI,GAAGL,CAAAA,CAAO,CAAA,CACpG,CAEJ,CAEA,SAASiB,CAAAA,CAAkB,CACzB,SAAA,CAAAZ,CAAAA,CACA,OAAA,CAAAU,GAAAA,CAAU,SAAA,CACV,IAAA,CAAAP,CAAAA,CAAO,SAAA,CACP,GAAGR,CACL,CAAA,CACiE,CAC/D,OACEC,GAAAA,CAACe,CAAAA,CAAA,CAAO,OAAA,CAASD,IAAS,IAAA,CAAMP,CAAAA,CAAM,OAAA,CAAO,IAAA,CAC3C,QAAA,CAAAP,GAAAA,CAACC,WAAAA,CAAqB,MAAA,CAArB,CAA4B,WAAA,CAAU,qBAAA,CAAsB,SAAA,CAAWI,CAAAA,CAAGD,CAAS,CAAA,CAAI,GAAGL,CAAAA,CAAO,EACpG,CAEJ","file":"chunk-4ZWQ44NZ.js","sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { AlertDialog as AlertDialogPrimitive } from 'radix-ui';\nimport { cn } from '../lib/utils';\nimport { Button } from './button';\n\nfunction AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {\n return <AlertDialogPrimitive.Root data-slot=\"alert-dialog\" {...props} />;\n}\n\nfunction AlertDialogTrigger({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {\n return <AlertDialogPrimitive.Trigger data-slot=\"alert-dialog-trigger\" {...props} />;\n}\n\nfunction AlertDialogPortal({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {\n return <AlertDialogPrimitive.Portal data-slot=\"alert-dialog-portal\" {...props} />;\n}\n\nfunction AlertDialogOverlay({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {\n return (\n <AlertDialogPrimitive.Overlay\n data-slot=\"alert-dialog-overlay\"\n className={cn(\n 'fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0',\n className\n )}\n {...props}\n />\n );\n}\n\nfunction AlertDialogContent({\n className,\n size = 'default',\n ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Content> & {\n size?: 'default' | 'sm';\n}) {\n return (\n <AlertDialogPortal>\n <AlertDialogOverlay />\n <AlertDialogPrimitive.Content\n data-slot=\"alert-dialog-content\"\n data-size={size}\n className={cn(\n 'fk:group/alert-dialog-content fk:fixed fk:top-[50%] fk:left-[50%] fk:z-50 fk:grid fk:w-full fk:max-w-[calc(100%-2rem)] fk:translate-x-[-50%] fk:translate-y-[-50%] fk:gap-4 fk:rounded-lg fk:border fk:bg-background fk:p-6 fk:shadow-lg fk:duration-200 fk:data-[size=sm]:max-w-xs fk:data-[state=closed]:animate-out fk:data-[state=closed]:fade-out-0 fk:data-[state=closed]:zoom-out-95 fk:data-[state=open]:animate-in fk:data-[state=open]:fade-in-0 fk:data-[state=open]:zoom-in-95 fk:data-[size=default]:sm:max-w-lg fk:corner-squircle',\n className\n )}\n {...props}\n />\n </AlertDialogPortal>\n );\n}\n\nfunction AlertDialogHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-dialog-header\"\n className={cn(\n 'fk:grid fk:grid-rows-[auto_1fr] fk:place-items-center fk:gap-1.5 fk:text-center fk:has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] fk:has-data-[slot=alert-dialog-media]:gap-x-6 fk:sm:group-data-[size=default]/alert-dialog-content:place-items-start fk:sm:group-data-[size=default]/alert-dialog-content:text-left fk:sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]',\n className\n )}\n {...props}\n />\n );\n}\n\nfunction AlertDialogFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-dialog-footer\"\n className={cn(\n 'fk:flex fk:flex-col-reverse fk:gap-2 fk:group-data-[size=sm]/alert-dialog-content:grid fk:group-data-[size=sm]/alert-dialog-content:grid-cols-2 fk:sm:flex-row fk:sm:justify-end',\n className\n )}\n {...props}\n />\n );\n}\n\nfunction AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {\n return (\n <AlertDialogPrimitive.Title\n data-slot=\"alert-dialog-title\"\n className={cn(\n 'fk:text-lg fk:font-semibold fk:sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2',\n className\n )}\n {...props}\n />\n );\n}\n\nfunction AlertDialogDescription({\n className,\n ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {\n return (\n <AlertDialogPrimitive.Description\n data-slot=\"alert-dialog-description\"\n className={cn('fk:text-sm fk:text-muted-foreground', className)}\n {...props}\n />\n );\n}\n\nfunction AlertDialogMedia({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-dialog-media\"\n className={cn(\n \"fk:mb-2 fk:inline-flex fk:size-16 fk:items-center fk:justify-center fk:rounded-md fk:bg-muted fk:sm:group-data-[size=default]/alert-dialog-content:row-span-2 fk:*:[svg:not([class*='size-'])]:size-8 fk:corner-squircle\",\n className\n )}\n {...props}\n />\n );\n}\n\nfunction AlertDialogAction({\n className,\n variant = 'default',\n size = 'default',\n ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Action> &\n Pick<React.ComponentProps<typeof Button>, 'variant' | 'size'>) {\n return (\n <Button variant={variant} size={size} asChild>\n <AlertDialogPrimitive.Action data-slot=\"alert-dialog-action\" className={cn(className)} {...props} />\n </Button>\n );\n}\n\nfunction AlertDialogCancel({\n className,\n variant = 'outline',\n size = 'default',\n ...props\n}: React.ComponentProps<typeof AlertDialogPrimitive.Cancel> &\n Pick<React.ComponentProps<typeof Button>, 'variant' | 'size'>) {\n return (\n <Button variant={variant} size={size} asChild>\n <AlertDialogPrimitive.Cancel data-slot=\"alert-dialog-cancel\" className={cn(className)} {...props} />\n </Button>\n );\n}\n\nexport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogMedia,\n AlertDialogOverlay,\n AlertDialogPortal,\n AlertDialogTitle,\n AlertDialogTrigger,\n};\n"]}
@@ -0,0 +1,2 @@
1
+ import'./index.css';import {k,q,s,t,p}from'./chunk-S7Z6KKIN.js';import {a}from'./chunk-X3SHNHHM.js';import {Slot,Separator,ScrollArea}from'radix-ui';import {cva}from'class-variance-authority';import {jsx,jsxs}from'react/jsx-runtime';import {Command}from'cmdk';import {SearchIcon}from'lucide-react';var C=cva("fk:inline-flex fk:w-fit fk:shrink-0 fk:items-center fk:justify-center fk:gap-1 fk:overflow-hidden fk:rounded-full fk:border fk:border-transparent fk:px-2 fk:py-0.5 fk:text-xs fk:font-medium fk:whitespace-nowrap fk:transition-[color,box-shadow] fk:focus-visible:border-ring fk:focus-visible:ring-[3px] fk:focus-visible:ring-ring/50 fk:aria-invalid:border-destructive fk:aria-invalid:ring-destructive/20 fk:dark:aria-invalid:ring-destructive/40 fk:[&>svg]:pointer-events-none fk:[&>svg]:size-3 fk:corner-squircle",{variants:{variant:{default:"fk:bg-primary fk:text-primary-foreground fk:[a&]:hover:bg-primary/90",secondary:"fk:bg-secondary fk:text-secondary-foreground fk:[a&]:hover:bg-secondary/90",destructive:"fk:bg-destructive fk:text-white fk:focus-visible:ring-destructive/20 fk:dark:bg-destructive/60 fk:dark:focus-visible:ring-destructive/40 fk:[a&]:hover:bg-destructive/90",outline:"fk:border-border fk:text-foreground fk:[a&]:hover:bg-accent fk:[a&]:hover:text-accent-foreground",ghost:"fk:[a&]:hover:bg-accent fk:[a&]:hover:text-accent-foreground",link:"fk:text-primary fk:underline-offset-4 fk:[a&]:hover:underline"}},defaultVariants:{variant:"default"}});function B({className:o,variant:t="default",asChild:r=false,...n}){let l=r?Slot.Root:"span";return jsx(l,{"data-slot":"badge","data-variant":t,className:a(C({variant:t}),o),...n})}function w({className:o,...t}){return jsx(Command,{"data-slot":"command",className:a("fk:flex fk:h-full fk:w-full fk:flex-col fk:rounded-md fk:bg-popover fk:text-popover-foreground fk:corner-squircle",o),...t})}function J({title:o="Command Palette",description:t$1="Search for a command to run...",children:r,className:n,showCloseButton:l=true,...h}){return jsxs(k,{...h,children:[jsxs(q,{className:"fk:sr-only",children:[jsx(s,{children:o}),jsx(t,{children:t$1})]}),jsx(p,{className:a("fk:overflow-hidden fk:p-0",n),showCloseButton:l,children:jsx(w,{className:"fk:**:data-[slot=command-input-wrapper]:h-12 fk:**:[[cmdk-group-heading]]:px-2 fk:**:[[cmdk-group-heading]]:font-medium fk:**:[[cmdk-group-heading]]:text-muted-foreground fk:**:[[cmdk-group]]:px-2 fk:[&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 fk:[&_[cmdk-input-wrapper]_svg]:h-5 fk:[&_[cmdk-input-wrapper]_svg]:w-5 fk:**:[[cmdk-input]]:h-12 fk:**:[[cmdk-item]]:px-2 fk:**:[[cmdk-item]]:py-3 fk:[&_[cmdk-item]_svg]:h-5 fk:[&_[cmdk-item]_svg]:w-5",children:r})})]})}function K({className:o,...t}){return jsxs("div",{"data-slot":"command-input-wrapper",className:"fk:flex fk:h-9 fk:items-center fk:gap-2 fk:border-b fk:px-3",children:[jsx(SearchIcon,{className:"fk:size-4 fk:shrink-0 fk:opacity-50"}),jsx(Command.Input,{"data-slot":"command-input",className:a("fk:flex fk:h-10 fk:w-full fk:rounded-md fk:bg-transparent fk:py-3 fk:text-sm fk:outline-hidden fk:placeholder:text-muted-foreground fk:disabled:cursor-not-allowed fk:disabled:opacity-50 fk:corner-squircle",o),...t})]})}function M({className:o,...t}){return jsx(Command.List,{"data-slot":"command-list",className:a("fk:max-h-[300px] fk:scroll-py-1 fk:overflow-x-hidden fk:overflow-y-auto",o),...t})}function O({...o}){return jsx(Command.Empty,{"data-slot":"command-empty",className:"fk:py-6 fk:text-center fk:text-sm",...o})}function Q({className:o,...t}){return jsx(Command.Group,{"data-slot":"command-group",className:a("fk:overflow-hidden fk:p-1 fk:text-foreground fk:**:[[cmdk-group-heading]]:px-2 fk:**:[[cmdk-group-heading]]:py-1.5 fk:**:[[cmdk-group-heading]]:text-xs fk:**:[[cmdk-group-heading]]:font-medium fk:**:[[cmdk-group-heading]]:text-muted-foreground",o),...t})}function U({className:o,...t}){return jsx(Command.Separator,{"data-slot":"command-separator",className:a("fk:-mx-1 fk:h-px fk:bg-border",o),...t})}function W({className:o,...t}){return jsx(Command.Item,{"data-slot":"command-item",className:a("fk:relative fk:flex fk:cursor-default fk:items-center fk:gap-2 fk:rounded-sm fk:px-2 fk:py-1.5 fk:text-sm fk:outline-hidden fk:select-none fk:data-[disabled=true]:pointer-events-none fk:data-[disabled=true]:opacity-50 fk:data-[selected=true]:bg-accent fk:data-[selected=true]:text-accent-foreground fk:[&_svg]:pointer-events-none fk:[&_svg]:shrink-0 fk:[&_svg:not([class*='size-'])]:size-4 fk:[&_svg:not([class*='text-'])]:text-muted-foreground fk:corner-squircle",o),...t})}function X({className:o,...t}){return jsx("span",{"data-slot":"command-shortcut",className:a("fk:ml-auto fk:text-xs fk:tracking-widest fk:text-muted-foreground",o),...t})}function v({className:o,orientation:t="horizontal",decorative:r=true,...n}){return jsx(Separator.Root,{"data-slot":"separator",decorative:r,orientation:t,className:a("fk:shrink-0 fk:bg-border fk:data-[orientation=horizontal]:h-px fk:data-[orientation=horizontal]:w-full fk:data-[orientation=vertical]:h-full fk:data-[orientation=vertical]:w-px",o),...n})}function at({className:o,children:t,...r}){return jsxs(ScrollArea.Root,{"data-slot":"scroll-area",className:a("fk:relative",o),...r,children:[jsx(ScrollArea.Viewport,{"data-slot":"scroll-area-viewport",className:"fk:size-full fk:rounded-[inherit] fk:transition-[color,box-shadow] fk:outline-none fk:focus-visible:ring-[3px] fk:focus-visible:ring-ring/50 fk:focus-visible:outline-1 fk:corner-squircle",children:t}),jsx(N,{}),jsx(ScrollArea.Corner,{})]})}function N({className:o,orientation:t="vertical",...r}){return jsx(ScrollArea.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:t,className:a("fk:flex fk:touch-none fk:p-px fk:transition-colors fk:select-none",t==="vertical"&&"fk:h-full fk:w-2.5 fk:border-l fk:border-l-transparent",t==="horizontal"&&"fk:h-2.5 fk:flex-col fk:border-t fk:border-t-transparent",o),...r,children:jsx(ScrollArea.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"fk:relative fk:flex-1 fk:rounded-full fk:bg-border fk:corner-squircle"})})}var A=cva("fk:flex fk:w-fit fk:items-stretch fk:has-[>[data-slot=button-group]]:gap-2 fk:[&>*]:focus-visible:relative fk:[&>*]:focus-visible:z-10 fk:has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md fk:[&>[data-slot=select-trigger]:not([class*=w-])]:w-fit fk:[&>input]:flex-1",{variants:{orientation:{horizontal:"fk:[&>*:not(:first-child)]:rounded-l-none fk:[&>*:not(:first-child)]:border-l-0 fk:[&>*:not(:last-child)]:rounded-r-none",vertical:"fk:flex-col fk:[&>*:not(:first-child)]:rounded-t-none fk:[&>*:not(:first-child)]:border-t-0 fk:[&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});function mt({className:o,orientation:t,...r}){return jsx("div",{role:"group","data-slot":"button-group","data-orientation":t,className:a(A({orientation:t}),o),...r})}function ct({className:o,asChild:t=false,...r}){let n=t?Slot.Root:"div";return jsx(n,{className:a("fk:bg-muted fk:shadow-xs fk:flex fk:items-center fk:gap-2 fk:rounded-md fk:border fk:px-4 fk:text-sm fk:font-medium fk:[&_svg:not([class*=size-])]:size-4 fk:[&_svg]:pointer-events-none fk:corner-squircle",o),...r})}function kt({className:o,orientation:t="vertical",...r}){return jsx(v,{"data-slot":"button-group-separator",orientation:t,className:a("fk:bg-input fk:relative fk:!m-0 fk:self-stretch fk:data-[orientation=vertical]:h-auto",o),...r})}export{C as a,B as b,w as c,J as d,K as e,M as f,O as g,Q as h,U as i,W as j,X as k,v as l,at as m,N as n,A as o,mt as p,ct as q,kt as r};//# sourceMappingURL=chunk-5JUG4BEF.js.map
2
+ //# sourceMappingURL=chunk-5JUG4BEF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ui/primitives/badge.tsx","../src/ui/primitives/command.tsx","../src/ui/primitives/separator.tsx","../src/ui/primitives/scroll-area.tsx","../src/ui/primitives/button-group.tsx"],"names":["badgeVariants","cva","Badge","className","variant","asChild","props","Comp","Slot","jsx","cn","Command","CommandPrimitive","CommandDialog","title","description","children","showCloseButton","jsxs","Dialog","DialogHeader","DialogTitle","DialogDescription","DialogContent","CommandInput","SearchIcon","CommandList","CommandEmpty","CommandGroup","CommandSeparator","CommandItem","CommandShortcut","Separator","orientation","decorative","SeparatorPrimitive","ScrollArea","ScrollAreaPrimitive","ScrollBar","buttonGroupVariants","ButtonGroup","ButtonGroupText","ButtonGroupSeparator"],"mappings":"8SAKMA,CAAAA,CAAgBC,GAAAA,CACpB,ggBAAA,CACA,CACE,SAAU,CACR,OAAA,CAAS,CACP,OAAA,CAAS,uEACT,SAAA,CAAW,4EAAA,CACX,WAAA,CACE,0KAAA,CACF,QAAS,kGAAA,CACT,KAAA,CAAO,8DAAA,CACP,IAAA,CAAM,+DACR,CACF,CAAA,CACA,eAAA,CAAiB,CACf,QAAS,SACX,CACF,CACF,EAEA,SAASC,CAAAA,CAAM,CACb,SAAA,CAAAC,CAAAA,CACA,QAAAC,CAAAA,CAAU,SAAA,CACV,OAAA,CAAAC,CAAAA,CAAU,MACV,GAAGC,CACL,CAAA,CAA8F,CAC5F,IAAMC,CAAAA,CAAOF,CAAAA,CAAUG,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AAAA,CAAK,KAAO,KAAA,CAEnC,OACEC,GAAAA,CAACF,CAAAA,CAAA,CACC,SAAA,CAAWG,CAAAA,CACT,6MAAA,CACAP,CACF,EACC,GAAGG,CAAAA,CACN,CAEJ,CAEA,SAASoC,EAAAA,CAAqB,CAC5B,SAAA,CAAAvC,CAAAA,CACA,YAAA8B,CAAAA,CAAc,UAAA,CACd,GAAG3B,CACL,EAA2C,CACzC,OACEG,GAAAA,CAACuB,CAAAA,CAAA,CACC,WAAA,CAAU,wBAAA,CACV,WAAA,CAAaC,CAAAA,CACb,UAAWvB,CAAAA,CACT,uFAAA,CACAP,CACF,CAAA,CACC,GAAGG,EACN,CAEJ","file":"chunk-5JUG4BEF.js","sourcesContent":["import * as React from 'react';\nimport { Slot } from 'radix-ui';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from '../lib/utils';\n\nconst badgeVariants = cva(\n 'fk:inline-flex fk:w-fit fk:shrink-0 fk:items-center fk:justify-center fk:gap-1 fk:overflow-hidden fk:rounded-full fk:border fk:border-transparent fk:px-2 fk:py-0.5 fk:text-xs fk:font-medium fk:whitespace-nowrap fk:transition-[color,box-shadow] fk:focus-visible:border-ring fk:focus-visible:ring-[3px] fk:focus-visible:ring-ring/50 fk:aria-invalid:border-destructive fk:aria-invalid:ring-destructive/20 fk:dark:aria-invalid:ring-destructive/40 fk:[&>svg]:pointer-events-none fk:[&>svg]:size-3 fk:corner-squircle',\n {\n variants: {\n variant: {\n default: 'fk:bg-primary fk:text-primary-foreground fk:[a&]:hover:bg-primary/90',\n secondary: 'fk:bg-secondary fk:text-secondary-foreground fk:[a&]:hover:bg-secondary/90',\n destructive:\n 'fk:bg-destructive fk:text-white fk:focus-visible:ring-destructive/20 fk:dark:bg-destructive/60 fk:dark:focus-visible:ring-destructive/40 fk:[a&]:hover:bg-destructive/90',\n outline: 'fk:border-border fk:text-foreground fk:[a&]:hover:bg-accent fk:[a&]:hover:text-accent-foreground',\n ghost: 'fk:[a&]:hover:bg-accent fk:[a&]:hover:text-accent-foreground',\n link: 'fk:text-primary fk:underline-offset-4 fk:[a&]:hover:underline',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n }\n);\n\nfunction Badge({\n className,\n variant = 'default',\n asChild = false,\n ...props\n}: React.ComponentProps<'span'> & VariantProps<typeof badgeVariants> & { asChild?: boolean }) {\n const Comp = asChild ? Slot.Root : 'span';\n\n return (\n <Comp data-slot=\"badge\" data-variant={variant} className={cn(badgeVariants({ variant }), className)} {...props} />\n );\n}\n\nexport { Badge, badgeVariants };\n","'use client';\n\nimport * as React from 'react';\nimport { Command as CommandPrimitive } from 'cmdk';\nimport { SearchIcon } from 'lucide-react';\nimport { cn } from '../lib/utils';\nimport { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from './dialog';\n\ntype CommandChildren = React.ComponentProps<typeof CommandPrimitive>['children'];\n\nfunction Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>) {\n return (\n <CommandPrimitive\n data-slot=\"command\"\n className={cn(\n 'fk:flex fk:h-full fk:w-full fk:flex-col fk:rounded-md fk:bg-popover fk:text-popover-foreground fk:corner-squircle',\n className\n )}\n {...props}\n />\n );\n}\n\nfunction CommandDialog({\n title = 'Command Palette',\n description = 'Search for a command to run...',\n children,\n className,\n showCloseButton = true,\n ...props\n}: React.ComponentProps<typeof Dialog> & {\n title?: string;\n description?: string;\n className?: string;\n showCloseButton?: boolean;\n}) {\n return (\n <Dialog {...props}>\n <DialogHeader className=\"fk:sr-only\">\n <DialogTitle>{title}</DialogTitle>\n <DialogDescription>{description}</DialogDescription>\n </DialogHeader>\n <DialogContent className={cn('fk:overflow-hidden fk:p-0', className)} showCloseButton={showCloseButton}>\n <Command className=\"fk:**:data-[slot=command-input-wrapper]:h-12 fk:**:[[cmdk-group-heading]]:px-2 fk:**:[[cmdk-group-heading]]:font-medium fk:**:[[cmdk-group-heading]]:text-muted-foreground fk:**:[[cmdk-group]]:px-2 fk:[&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 fk:[&_[cmdk-input-wrapper]_svg]:h-5 fk:[&_[cmdk-input-wrapper]_svg]:w-5 fk:**:[[cmdk-input]]:h-12 fk:**:[[cmdk-item]]:px-2 fk:**:[[cmdk-item]]:py-3 fk:[&_[cmdk-item]_svg]:h-5 fk:[&_[cmdk-item]_svg]:w-5\">\n {children as CommandChildren}\n </Command>\n </DialogContent>\n </Dialog>\n );\n}\n\nfunction CommandInput({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Input>) {\n return (\n <div data-slot=\"command-input-wrapper\" className=\"fk:flex fk:h-9 fk:items-center fk:gap-2 fk:border-b fk:px-3\">\n <SearchIcon className=\"fk:size-4 fk:shrink-0 fk:opacity-50\" />\n <CommandPrimitive.Input\n data-slot=\"command-input\"\n className={cn(\n 'fk:flex fk:h-10 fk:w-full fk:rounded-md fk:bg-transparent fk:py-3 fk:text-sm fk:outline-hidden fk:placeholder:text-muted-foreground fk:disabled:cursor-not-allowed fk:disabled:opacity-50 fk:corner-squircle',\n className\n )}\n {...props}\n />\n </div>\n );\n}\n\nfunction CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>) {\n return (\n <CommandPrimitive.List\n data-slot=\"command-list\"\n className={cn('fk:max-h-[300px] fk:scroll-py-1 fk:overflow-x-hidden fk:overflow-y-auto', className)}\n {...props}\n />\n );\n}\n\nfunction CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>) {\n return <CommandPrimitive.Empty data-slot=\"command-empty\" className=\"fk:py-6 fk:text-center fk:text-sm\" {...props} />;\n}\n\nfunction CommandGroup({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Group>) {\n return (\n <CommandPrimitive.Group\n data-slot=\"command-group\"\n className={cn(\n 'fk:overflow-hidden fk:p-1 fk:text-foreground fk:**:[[cmdk-group-heading]]:px-2 fk:**:[[cmdk-group-heading]]:py-1.5 fk:**:[[cmdk-group-heading]]:text-xs fk:**:[[cmdk-group-heading]]:font-medium fk:**:[[cmdk-group-heading]]:text-muted-foreground',\n className\n )}\n {...props}\n />\n );\n}\n\nfunction CommandSeparator({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Separator>) {\n return (\n <CommandPrimitive.Separator\n data-slot=\"command-separator\"\n className={cn('fk:-mx-1 fk:h-px fk:bg-border', className)}\n {...props}\n />\n );\n}\n\nfunction CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>) {\n return (\n <CommandPrimitive.Item\n data-slot=\"command-item\"\n className={cn(\n \"fk:relative fk:flex fk:cursor-default fk:items-center fk:gap-2 fk:rounded-sm fk:px-2 fk:py-1.5 fk:text-sm fk:outline-hidden fk:select-none fk:data-[disabled=true]:pointer-events-none fk:data-[disabled=true]:opacity-50 fk:data-[selected=true]:bg-accent fk:data-[selected=true]:text-accent-foreground fk:[&_svg]:pointer-events-none fk:[&_svg]:shrink-0 fk:[&_svg:not([class*='size-'])]:size-4 fk:[&_svg:not([class*='text-'])]:text-muted-foreground fk:corner-squircle\",\n className\n )}\n {...props}\n />\n );\n}\n\nfunction CommandShortcut({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"command-shortcut\"\n className={cn('fk:ml-auto fk:text-xs fk:tracking-widest fk:text-muted-foreground', className)}\n {...props}\n />\n );\n}\n\nexport {\n Command,\n CommandDialog,\n CommandInput,\n CommandList,\n CommandEmpty,\n CommandGroup,\n CommandItem,\n CommandShortcut,\n CommandSeparator,\n};\n","'use client';\n\nimport * as React from 'react';\nimport { Separator as SeparatorPrimitive } from 'radix-ui';\nimport { cn } from '../lib/utils';\n\nfunction Separator({\n className,\n orientation = 'horizontal',\n decorative = true,\n ...props\n}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {\n return (\n <SeparatorPrimitive.Root\n data-slot=\"separator\"\n decorative={decorative}\n orientation={orientation}\n className={cn(\n 'fk:shrink-0 fk:bg-border fk:data-[orientation=horizontal]:h-px fk:data-[orientation=horizontal]:w-full fk:data-[orientation=vertical]:h-full fk:data-[orientation=vertical]:w-px',\n className\n )}\n {...props}\n />\n );\n}\n\nexport { Separator };\n","'use client';\n\nimport * as React from 'react';\nimport { ScrollArea as ScrollAreaPrimitive } from 'radix-ui';\nimport { cn } from '../lib/utils';\n\nfunction ScrollArea({ className, children, ...props }: React.ComponentProps<typeof ScrollAreaPrimitive.Root>) {\n return (\n <ScrollAreaPrimitive.Root data-slot=\"scroll-area\" className={cn('fk:relative', className)} {...props}>\n <ScrollAreaPrimitive.Viewport\n data-slot=\"scroll-area-viewport\"\n className=\"fk:size-full fk:rounded-[inherit] fk:transition-[color,box-shadow] fk:outline-none fk:focus-visible:ring-[3px] fk:focus-visible:ring-ring/50 fk:focus-visible:outline-1 fk:corner-squircle\"\n >\n {children}\n </ScrollAreaPrimitive.Viewport>\n <ScrollBar />\n <ScrollAreaPrimitive.Corner />\n </ScrollAreaPrimitive.Root>\n );\n}\n\nfunction ScrollBar({\n className,\n orientation = 'vertical',\n ...props\n}: React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>) {\n return (\n <ScrollAreaPrimitive.ScrollAreaScrollbar\n data-slot=\"scroll-area-scrollbar\"\n orientation={orientation}\n className={cn(\n 'fk:flex fk:touch-none fk:p-px fk:transition-colors fk:select-none',\n orientation === 'vertical' && 'fk:h-full fk:w-2.5 fk:border-l fk:border-l-transparent',\n orientation === 'horizontal' && 'fk:h-2.5 fk:flex-col fk:border-t fk:border-t-transparent',\n className\n )}\n {...props}\n >\n <ScrollAreaPrimitive.ScrollAreaThumb\n data-slot=\"scroll-area-thumb\"\n className=\"fk:relative fk:flex-1 fk:rounded-full fk:bg-border fk:corner-squircle\"\n />\n </ScrollAreaPrimitive.ScrollAreaScrollbar>\n );\n}\n\nexport { ScrollArea, ScrollBar };\n","import * as React from 'react';\nimport { Slot } from 'radix-ui';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from '../lib/utils';\nimport { Separator } from './separator';\n\nconst buttonGroupVariants = cva(\n 'fk:flex fk:w-fit fk:items-stretch fk:has-[>[data-slot=button-group]]:gap-2 fk:[&>*]:focus-visible:relative fk:[&>*]:focus-visible:z-10 fk:has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md fk:[&>[data-slot=select-trigger]:not([class*=w-])]:w-fit fk:[&>input]:flex-1',\n {\n variants: {\n orientation: {\n horizontal:\n 'fk:[&>*:not(:first-child)]:rounded-l-none fk:[&>*:not(:first-child)]:border-l-0 fk:[&>*:not(:last-child)]:rounded-r-none',\n vertical:\n 'fk:flex-col fk:[&>*:not(:first-child)]:rounded-t-none fk:[&>*:not(:first-child)]:border-t-0 fk:[&>*:not(:last-child)]:rounded-b-none',\n },\n },\n defaultVariants: {\n orientation: 'horizontal',\n },\n }\n);\n\nfunction ButtonGroup({\n className,\n orientation,\n ...props\n}: React.ComponentProps<'div'> & VariantProps<typeof buttonGroupVariants>) {\n return (\n <div\n role=\"group\"\n data-slot=\"button-group\"\n data-orientation={orientation}\n className={cn(buttonGroupVariants({ orientation }), className)}\n {...props}\n />\n );\n}\n\nfunction ButtonGroupText({\n className,\n asChild = false,\n ...props\n}: React.ComponentProps<'div'> & {\n asChild?: boolean;\n}) {\n const Comp = asChild ? Slot.Root : 'div';\n\n return (\n <Comp\n className={cn(\n 'fk:bg-muted fk:shadow-xs fk:flex fk:items-center fk:gap-2 fk:rounded-md fk:border fk:px-4 fk:text-sm fk:font-medium fk:[&_svg:not([class*=size-])]:size-4 fk:[&_svg]:pointer-events-none fk:corner-squircle',\n className\n )}\n {...props}\n />\n );\n}\n\nfunction ButtonGroupSeparator({\n className,\n orientation = 'vertical',\n ...props\n}: React.ComponentProps<typeof Separator>) {\n return (\n <Separator\n data-slot=\"button-group-separator\"\n orientation={orientation}\n className={cn(\n 'fk:bg-input fk:relative fk:!m-0 fk:self-stretch fk:data-[orientation=vertical]:h-auto',\n className\n )}\n {...props}\n />\n );\n}\n\nexport { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants };\n"]}
@@ -1,3 +1,3 @@
1
- import'./index.css';import {f as f$1}from'./chunk-HZOD2HOF.js';import {ApolloClient,InMemoryCache,defaultDataIdFromObject,from,HttpLink}from'@apollo/client';import {ApolloProvider}from'@apollo/client/react';import {ErrorLink}from'@apollo/client/link/error';import {ServerError,CombinedGraphQLErrors,CombinedProtocolErrors}from'@apollo/client/errors';import {createContext,useContext,useState,useMemo,useReducer}from'react';import {jsx}from'react/jsx-runtime';import {uniqBy,props}from'ramda';function A(r){return r?"cause"in r:false}function f(r){if(!r)return null;if(ServerError.is(r))return r;if(A(r)){let e=r.cause;if(ServerError.is(e))return e}return null}function L(r){if(!r||typeof r!="object")return null;let{message:e}=r;return typeof e=="string"?e:null}function d(r){if(!r)return null;try{return JSON.parse(r)}catch{return null}}function k(r){if(!r)return null;let e=C(r).filter(t=>!I(t));return e.length===0?null:["The deployed schema is out of sync with your local Flexkit schema.","Run `flexkit deploy` using the CLI to apply your latest schema changes.",...e.map(t=>`- ${t}`)].join(`
2
- `)}function er(r,e){return r?C(r).some(t=>t.includes(`Cannot query field "${e}"`)):false}function C(r){if(CombinedGraphQLErrors.is(r))return r.errors.filter(y).map(({message:o})=>o);let e=L(r);if(e&&a(e))return [e];let t=f(r);if(t?.statusCode!==400)return [];let n=d(t.bodyText)??P(t)??b(r);return n?Array.isArray(n.errors)?n.errors.filter(y).map(o=>o.message):typeof n.message=="string"&&a(n.message)?[n.message]:typeof n.error=="string"&&a(n.error)?[n.error]:[]:[]}function P(r){let{result:e}=r;return !e||typeof e!="object"?null:e}function b(r){if(!A(r))return null;let{cause:e}=r,t=L(e);if(t&&a(t))return {message:t};if(!e||typeof e!="object")return null;let{result:n}=e;return n&&typeof n=="object"?n:null}function y(r){if(!r||typeof r!="object")return false;let{extensions:e,message:t}=r;return e?.code==="GRAPHQL_VALIDATION_FAILED"&&typeof t=="string"?true:typeof t=="string"&&a(t)}function a(r){return r.startsWith("Cannot query field ")||r.startsWith("Unknown type ")||r.startsWith('Cannot query field "')||r.includes("GRAPHQL_VALIDATION_FAILED")}function I(r){return /Cannot query field "[_A-Za-z][_0-9A-Za-z]*Total" on type "Query"/.test(r)}var U=ApolloProvider,v=createContext(void 0);function pr(){let r=useContext(v);if(!r)throw new Error("useGraphQLError must be used within GraphQLProvider");return r}var fr={userQuery:true};function H(r){return new ErrorLink(({error:e,operation:t})=>{if(t.getContext().userQuery===true)return;let n=k(e);if(n){r(n);return}CombinedGraphQLErrors.is(e)?e.errors.forEach(({message:s,locations:i,path:c})=>{console.warn(`[GraphQL error]: Message: ${s}, Location: ${i}, Path: ${c}`);}):CombinedProtocolErrors.is(e)&&e.errors.forEach(({message:s,extensions:i})=>{console.warn(`[Protocol error]: Message: ${s}, Extensions: ${JSON.stringify(i)}`);});let o=f(e);if(o?.statusCode===400){let s=d(o.bodyText),i=null;if(s&&typeof s=="object"){let{error:c,errors:g,message:E}=s;if(typeof E=="string")i=E;else if(Array.isArray(g)){let[p]=g;if(p&&typeof p.message=="string"){let{message:D}=p;i=D;}}else typeof c=="string"?i=c:i=JSON.stringify(s);}else i=o.bodyText;r(i??"There is an error in the deployed Flexkit schema. Fix flexkit.config.ts and run flexkit deploy.");}if(o){console.warn(`[Network error]: ${o.message}`);return}e&&console.warn(`[Network error]: ${e.message}`);})}function z(r,e){return from([H(e),new HttpLink({uri:`/api/flexkit/${r}/graphql`})])}function Z(r,e){return new ApolloClient({link:z(r??"",e),cache:new InMemoryCache({dataIdFromObject:t=>t._id?t._id:defaultDataIdFromObject(t)})})}function dr({children:r}){let{currentProjectId:e}=f$1(),[t,n]=useState(null),o=useMemo(()=>({schemaErrorMessage:t,setSchemaErrorMessage:n}),[t]),s=useMemo(()=>Z(e,n),[e]);return jsx(v.Provider,{value:o,children:jsx(U,{client:s,children:r})})}var G=createContext([]),M=createContext(()=>{});function K(r,e){let t=e.type;switch(e._id||(e._id=Date.now().toString()),t){case "DeleteEntity":return uniqBy(props(["type","_id"]),[...r,e]);case "AddEntity":return uniqBy(props(["type","_id"]),[...r,e]);case "EditEntity":return uniqBy(props(["type","_id"]),[...r,e]);case "EditRelationship":return uniqBy(props(["type","_id"]),[...r,e]);case "AlertDialog":return uniqBy(props(["type","_id"]),[...r,e]);case "Dismiss":return r.filter(n=>n._id!==e._id);default:throw Error(`Unknown action: ${t}`)}}function yr({children:r}){let[e,t]=useReducer(K,[]);return jsx(G.Provider,{value:e,children:jsx(M.Provider,{value:t,children:r})})}function Ar(){return useContext(G)}function Lr(){return useContext(M)}export{f as a,d as b,k as c,er as d,pr as e,fr as f,dr as g,yr as h,Ar as i,Lr as j};//# sourceMappingURL=chunk-XV7U33XQ.js.map
3
- //# sourceMappingURL=chunk-XV7U33XQ.js.map
1
+ import'./index.css';import {f as f$1}from'./chunk-VRDTHLA3.js';import {ApolloClient,InMemoryCache,defaultDataIdFromObject,from,HttpLink}from'@apollo/client';import {ApolloProvider}from'@apollo/client/react';import {ErrorLink}from'@apollo/client/link/error';import {ServerError,CombinedGraphQLErrors,CombinedProtocolErrors}from'@apollo/client/errors';import {createContext,useContext,useState,useMemo,useReducer}from'react';import {jsx}from'react/jsx-runtime';import {uniqBy,props}from'ramda';function A(r){return r?"cause"in r:false}function f(r){if(!r)return null;if(ServerError.is(r))return r;if(A(r)){let e=r.cause;if(ServerError.is(e))return e}return null}function L(r){if(!r||typeof r!="object")return null;let{message:e}=r;return typeof e=="string"?e:null}function d(r){if(!r)return null;try{return JSON.parse(r)}catch{return null}}function k(r){if(!r)return null;let e=C(r).filter(t=>!I(t));return e.length===0?null:["The deployed schema is out of sync with your local Flexkit schema.","Run `flexkit deploy` using the CLI to apply your latest schema changes.",...e.map(t=>`- ${t}`)].join(`
2
+ `)}function er(r,e){return r?C(r).some(t=>t.includes(`Cannot query field "${e}"`)):false}function C(r){if(CombinedGraphQLErrors.is(r))return r.errors.filter(y).map(({message:o})=>o);let e=L(r);if(e&&a(e))return [e];let t=f(r);if(t?.statusCode!==400)return [];let n=d(t.bodyText)??P(t)??b(r);return n?Array.isArray(n.errors)?n.errors.filter(y).map(o=>o.message):typeof n.message=="string"&&a(n.message)?[n.message]:typeof n.error=="string"&&a(n.error)?[n.error]:[]:[]}function P(r){let{result:e}=r;return !e||typeof e!="object"?null:e}function b(r){if(!A(r))return null;let{cause:e}=r,t=L(e);if(t&&a(t))return {message:t};if(!e||typeof e!="object")return null;let{result:n}=e;return n&&typeof n=="object"?n:null}function y(r){if(!r||typeof r!="object")return false;let{extensions:e,message:t}=r;return e?.code==="GRAPHQL_VALIDATION_FAILED"&&typeof t=="string"?true:typeof t=="string"&&a(t)}function a(r){return r.startsWith("Cannot query field ")||r.startsWith("Unknown type ")||r.startsWith('Cannot query field "')||r.includes("GRAPHQL_VALIDATION_FAILED")}function I(r){return /Cannot query field "[_A-Za-z][_0-9A-Za-z]*Total" on type "Query"/.test(r)}var U=ApolloProvider,v=createContext(void 0);function pr(){let r=useContext(v);if(!r)throw new Error("useGraphQLError must be used within GraphQLProvider");return r}var fr={userQuery:true};function H(r){return new ErrorLink(({error:e,operation:t})=>{if(t.getContext().userQuery===true)return;let n=k(e);if(n){r(n);return}CombinedGraphQLErrors.is(e)?e.errors.forEach(({message:s,locations:i,path:c})=>{console.warn(`[GraphQL error]: Message: ${s}, Location: ${i}, Path: ${c}`);}):CombinedProtocolErrors.is(e)&&e.errors.forEach(({message:s,extensions:i})=>{console.warn(`[Protocol error]: Message: ${s}, Extensions: ${JSON.stringify(i)}`);});let o=f(e);if(o?.statusCode===400){let s=d(o.bodyText),i=null;if(s&&typeof s=="object"){let{error:c,errors:g,message:E}=s;if(typeof E=="string")i=E;else if(Array.isArray(g)){let[p]=g;if(p&&typeof p.message=="string"){let{message:D}=p;i=D;}}else typeof c=="string"?i=c:i=JSON.stringify(s);}else i=o.bodyText;r(i??"There is an error in the deployed Flexkit schema. Fix flexkit.config.ts and run flexkit deploy.");}if(o){console.warn(`[Network error]: ${o.message}`);return}e&&console.warn(`[Network error]: ${e.message}`);})}function z(r,e){return from([H(e),new HttpLink({uri:`/api/flexkit/${r}/graphql`})])}function Z(r,e){return new ApolloClient({link:z(r??"",e),cache:new InMemoryCache({dataIdFromObject:t=>t._id?t._id:defaultDataIdFromObject(t)})})}function dr({children:r}){let{currentProjectId:e}=f$1(),[t,n]=useState(null),o=useMemo(()=>({schemaErrorMessage:t,setSchemaErrorMessage:n}),[t]),s=useMemo(()=>Z(e,n),[e]);return jsx(v.Provider,{value:o,children:jsx(U,{client:s,children:r})})}var G=createContext([]),M=createContext(()=>{});function K(r,e){let t=e.type;switch(e._id||(e._id=Date.now().toString()),t){case "DeleteEntity":return uniqBy(props(["type","_id"]),[...r,e]);case "AddEntity":return uniqBy(props(["type","_id"]),[...r,e]);case "EditEntity":return uniqBy(props(["type","_id"]),[...r,e]);case "EditRelationship":return uniqBy(props(["type","_id"]),[...r,e]);case "AlertDialog":return uniqBy(props(["type","_id"]),[...r,e]);case "Dismiss":return r.filter(n=>n._id!==e._id);default:throw Error(`Unknown action: ${t}`)}}function yr({children:r}){let[e,t]=useReducer(K,[]);return jsx(G.Provider,{value:e,children:jsx(M.Provider,{value:t,children:r})})}function Ar(){return useContext(G)}function Lr(){return useContext(M)}export{f as a,d as b,k as c,er as d,pr as e,fr as f,dr as g,yr as h,Ar as i,Lr as j};//# sourceMappingURL=chunk-6AJRQSFO.js.map
3
+ //# sourceMappingURL=chunk-6AJRQSFO.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphql-client/error-utils.ts","../src/graphql-client/graphql-context.tsx","../src/entities/actions-context.tsx"],"names":["hasCause","error","getServerError","ServerError","possibleServerError","getErrorMessage","message","parseErrorBody","bodyText","getGraphQLSchemaMismatchMessage","messages","getGraphQLValidationMessages","isMissingCountStoreFieldMessage","isMissingGraphQLFieldError","fieldName","CombinedGraphQLErrors","isSchemaValidationError","directMessage","isSchemaValidationMessage","serverError","responseBody","getServerErrorResult","getErrorCauseResponse","item","result","cause","causeMessage","extensions","ApolloProviderCompat","ApolloProvider","GraphQLErrorContext","createContext","useGraphQLError","ctx","useContext","USER_QUERY_CONTEXT","createErrorLink","setSchemaErrorMessage","ErrorLink","operation","schemaMismatchMessage","locations","path","CombinedProtocolErrors","responseError","errors","responseMessage","firstError","firstErrorMessage","additiveLink","currentProjectId","from","HttpLink","client","ApolloClient","InMemoryCache","responseObject","defaultDataIdFromObject","GraphQLProvider","children","useConfig","schemaErrorMessage","useState","useMemo","apolloClient","jsx","ActionsContext","EntityDispatchContext","actionsReducer","actions","action","actionType","uniqBy","props","ActionsProvider","entityActions","dispatchEntityActions","useReducer","useActions","useDispatch"],"mappings":"4eAsBA,SAASA,CAAAA,CAASC,EAA2C,CAC3D,OAAKA,EAIE,OAAA,GAAYA,CAAAA,CAHV,KAIX,CAEO,SAASC,CAAAA,CAAeD,CAAAA,CAAuC,CACpE,GAAI,CAACA,CAAAA,CACH,OAAO,IAAA,CAGT,GAAIE,YAAY,EAAA,CAAGF,CAAK,EACtB,OAAOA,CAAAA,CAGT,GAAID,CAAAA,CAASC,CAAK,CAAA,CAAG,CACnB,IAAMG,CAAAA,CAAsBH,CAAAA,CAAM,KAAA,CAElC,GAAIE,YAAY,EAAA,CAAGC,CAAmB,CAAA,CACpC,OAAOA,CAEX,CAEA,OAAO,IACT,CAEA,SAASC,EAAgBJ,CAAAA,CAA+B,CACtD,GAAI,CAACA,GAAS,OAAOA,CAAAA,EAAU,QAAA,CAC7B,OAAO,KAGT,GAAM,CAAE,OAAA,CAAAK,CAAQ,EAAIL,CAAAA,CAEpB,OAAO,OAAOK,CAAAA,EAAY,SAAWA,CAAAA,CAAU,IACjD,CAEO,SAASC,EAAkBC,CAAAA,CAAwC,CACxE,GAAI,CAACA,EACH,OAAO,IAAA,CAGT,GAAI,CACF,OAAO,IAAA,CAAK,KAAA,CAAMA,CAAQ,CAC5B,CAAA,KAAQ,CACN,OAAO,IACT,CACF,CAEO,SAASC,CAAAA,CAAgCR,CAAAA,CAAkC,CAChF,GAAI,CAACA,CAAAA,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D,CAAAA,CAAQ,MAAA,CAAQ9C,CAAAA,EAASA,EAAK,GAAA,GAAQ+C,CAAAA,CAAO,GAAG,CAAA,CAEzD,QACE,MAAM,KAAA,CAAM,CAAA,gBAAA,EAAmBC,CAAoB,CAAA,CAAE,CAEzD,CACF,CAEA,SAASG,EAAAA,CAAgB,CAAE,QAAA,CAAAf,CAAS,EAAyC,CAC3E,GAAM,CAACgB,CAAAA,CAAeC,CAAqB,CAAA,CAAIC,WAAWT,CAAAA,CAAgB,EAAE,CAAA,CAE5E,OACEH,IAACC,CAAAA,CAAe,QAAA,CAAf,CAAwB,KAAA,CAAOS,CAAAA,CAC9B,QAAA,CAAAV,IAACE,CAAAA,CAAsB,QAAA,CAAtB,CAA+B,KAAA,CAAOS,CAAAA,CAAwB,SAAAjB,CAAAA,CAAS,CAAA,CAC1E,CAEJ,CAEA,SAASmB,EAAAA,EAAuB,CAC9B,OAAO5C,UAAAA,CAAWgC,CAAc,CAClC,CAEA,SAASa,IAAgC,CACvC,OAAO7C,UAAAA,CAAWiC,CAAqB,CACzC","file":"chunk-XV7U33XQ.js","sourcesContent":["import type { ErrorLike } from '@apollo/client';\nimport { CombinedGraphQLErrors, ServerError } from '@apollo/client/errors';\n\ntype ErrorWithCause = ErrorLike & { cause?: unknown };\ntype ErrorWithMessage = {\n message?: unknown;\n};\ntype ServerErrorWithResult = ServerError & {\n result?: unknown;\n};\ntype GraphQLErrorResponse = {\n error?: unknown;\n errors?: unknown;\n message?: unknown;\n};\ntype GraphQLErrorItem = {\n extensions?: {\n code?: unknown;\n };\n message?: unknown;\n};\n\nfunction hasCause(error: ErrorLike): error is ErrorWithCause {\n if (!error) {\n return false;\n }\n\n return 'cause' in (error as ErrorWithCause);\n}\n\nexport function getServerError(error?: ErrorLike): ServerError | null {\n if (!error) {\n return null;\n }\n\n if (ServerError.is(error)) {\n return error;\n }\n\n if (hasCause(error)) {\n const possibleServerError = error.cause;\n\n if (ServerError.is(possibleServerError)) {\n return possibleServerError;\n }\n }\n\n return null;\n}\n\nfunction getErrorMessage(error: unknown): string | null {\n if (!error || typeof error !== 'object') {\n return null;\n }\n\n const { message } = error as ErrorWithMessage;\n\n return typeof message === 'string' ? message : null;\n}\n\nexport function parseErrorBody<T>(bodyText: string | undefined): T | null {\n if (!bodyText) {\n return null;\n }\n\n try {\n return JSON.parse(bodyText) as T;\n } catch {\n return null;\n }\n}\n\nexport function getGraphQLSchemaMismatchMessage(error?: ErrorLike): string | null {\n if (!error) {\n return null;\n }\n\n const messages = getGraphQLValidationMessages(error).filter((message) => !isMissingCountStoreFieldMessage(message));\n\n if (messages.length === 0) {\n return null;\n }\n\n return [\n 'The deployed schema is out of sync with your local Flexkit schema.',\n 'Run `flexkit deploy` using the CLI to apply your latest schema changes.',\n ...messages.map((message) => `- ${message}`),\n ].join('\\n');\n}\n\nexport function isMissingGraphQLFieldError(error: ErrorLike | undefined, fieldName: string): boolean {\n if (!error) {\n return false;\n }\n\n return getGraphQLValidationMessages(error).some((message) => {\n return message.includes(`Cannot query field \"${fieldName}\"`);\n });\n}\n\nfunction getGraphQLValidationMessages(error: ErrorLike): string[] {\n if (CombinedGraphQLErrors.is(error)) {\n return error.errors.filter(isSchemaValidationError).map(({ message }) => message);\n }\n\n const directMessage = getErrorMessage(error);\n\n if (directMessage && isSchemaValidationMessage(directMessage)) {\n return [directMessage];\n }\n\n const serverError = getServerError(error);\n\n if (serverError?.statusCode !== 400) {\n return [];\n }\n\n const responseBody =\n parseErrorBody<GraphQLErrorResponse>(serverError.bodyText) ??\n getServerErrorResult(serverError) ??\n getErrorCauseResponse(error);\n\n if (!responseBody) {\n return [];\n }\n\n if (Array.isArray(responseBody.errors)) {\n return responseBody.errors.filter(isSchemaValidationError).map((item) => item.message);\n }\n\n if (typeof responseBody.message === 'string' && isSchemaValidationMessage(responseBody.message)) {\n return [responseBody.message];\n }\n\n if (typeof responseBody.error === 'string' && isSchemaValidationMessage(responseBody.error)) {\n return [responseBody.error];\n }\n\n return [];\n}\n\nfunction getServerErrorResult(serverError: ServerError): GraphQLErrorResponse | null {\n const { result } = serverError as ServerErrorWithResult;\n\n if (!result || typeof result !== 'object') {\n return null;\n }\n\n return result as GraphQLErrorResponse;\n}\n\nfunction getErrorCauseResponse(error: ErrorLike): GraphQLErrorResponse | null {\n if (!hasCause(error)) {\n return null;\n }\n\n const { cause } = error;\n const causeMessage = getErrorMessage(cause);\n\n if (causeMessage && isSchemaValidationMessage(causeMessage)) {\n return { message: causeMessage };\n }\n\n if (!cause || typeof cause !== 'object') {\n return null;\n }\n\n const { result } = cause as { result?: unknown };\n\n if (result && typeof result === 'object') {\n return result as GraphQLErrorResponse;\n }\n\n return null;\n}\n\nfunction isSchemaValidationError(error: unknown): error is GraphQLErrorItem & { message: string } {\n if (!error || typeof error !== 'object') {\n return false;\n }\n\n const { extensions, message } = error as GraphQLErrorItem;\n const code = extensions?.code;\n\n if (code === 'GRAPHQL_VALIDATION_FAILED' && typeof message === 'string') {\n return true;\n }\n\n return typeof message === 'string' && isSchemaValidationMessage(message);\n}\n\nfunction isSchemaValidationMessage(message: string): boolean {\n return (\n message.startsWith('Cannot query field ') ||\n message.startsWith('Unknown type ') ||\n message.startsWith('Cannot query field \"') ||\n message.includes('GRAPHQL_VALIDATION_FAILED')\n );\n}\n\nfunction isMissingCountStoreFieldMessage(message: string): boolean {\n return /Cannot query field \"[_A-Za-z][_0-9A-Za-z]*Total\" on type \"Query\"/.test(message);\n}\n","'use client';\n\nimport type { JSX } from 'react';\nimport { ApolloClient, InMemoryCache, defaultDataIdFromObject, from, HttpLink } from '@apollo/client';\nimport type { ApolloLink } from '@apollo/client';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { ErrorLink } from '@apollo/client/link/error';\nimport { CombinedGraphQLErrors, CombinedProtocolErrors } from '@apollo/client/errors';\nimport { getGraphQLSchemaMismatchMessage, getServerError, parseErrorBody } from './error-utils';\nimport { useConfig } from '../core/config/config-context';\nimport React, { createContext, useContext, useMemo, useState } from 'react';\n\nconst ApolloProviderCompat = ApolloProvider as unknown as React.ComponentType<{\n children?: React.ReactNode;\n client: ApolloClient;\n}>;\n\ntype GraphQLErrorContextValue = {\n schemaErrorMessage: string | null;\n setSchemaErrorMessage: React.Dispatch<React.SetStateAction<string | null>>;\n};\n\nconst GraphQLErrorContext = createContext<GraphQLErrorContextValue | undefined>(undefined);\n\nfunction useGraphQLError(): GraphQLErrorContextValue {\n const ctx = useContext(GraphQLErrorContext);\n\n if (!ctx) {\n throw new Error('useGraphQLError must be used within GraphQLProvider');\n }\n\n return ctx;\n}\n\n/**\n * Context flag for operations the user writes themselves (the Graph app's\n * Query view): any error there, a mismatch or a 400, is a typo, not a\n * deployment that drifted from the local schema, so it must not raise the\n * schema banner. The caller shows the error itself.\n */\nexport const USER_QUERY_CONTEXT = { userQuery: true } as const;\n\nfunction createErrorLink(setSchemaErrorMessage: (msg: string | null) => void): ApolloLink {\n return new ErrorLink(({ error, operation }) => {\n if (operation.getContext().userQuery === true) {\n return;\n }\n\n const schemaMismatchMessage = getGraphQLSchemaMismatchMessage(error);\n\n if (schemaMismatchMessage) {\n setSchemaErrorMessage(schemaMismatchMessage);\n\n return;\n }\n\n if (CombinedGraphQLErrors.is(error)) {\n error.errors.forEach(({ message, locations, path }) => {\n console.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);\n });\n } else if (CombinedProtocolErrors.is(error)) {\n error.errors.forEach(({ message, extensions }) => {\n console.warn(`[Protocol error]: Message: ${message}, Extensions: ${JSON.stringify(extensions)}`);\n });\n }\n\n const serverError = getServerError(error);\n\n if (serverError?.statusCode === 400) {\n const responseBody = parseErrorBody<Record<string, unknown>>(serverError.bodyText);\n let message: string | null = null;\n\n if (responseBody && typeof responseBody === 'object') {\n const {\n error: responseError,\n errors,\n message: responseMessage,\n } = responseBody as {\n error?: unknown;\n errors?: unknown;\n message?: unknown;\n };\n\n if (typeof responseMessage === 'string') {\n message = responseMessage;\n } else if (Array.isArray(errors)) {\n const [firstError] = errors as { message?: unknown }[];\n\n if (firstError && typeof firstError.message === 'string') {\n const { message: firstErrorMessage } = firstError;\n message = firstErrorMessage;\n }\n } else if (typeof responseError === 'string') {\n message = responseError;\n } else {\n message = JSON.stringify(responseBody);\n }\n } else {\n message = serverError.bodyText;\n }\n\n setSchemaErrorMessage(\n message ?? 'There is an error in the deployed Flexkit schema. Fix flexkit.config.ts and run flexkit deploy.'\n );\n }\n\n if (serverError) {\n console.warn(`[Network error]: ${serverError.message}`);\n\n return;\n }\n\n if (error) {\n console.warn(`[Network error]: ${error.message}`);\n }\n });\n}\n\nfunction additiveLink(currentProjectId: string, setSchemaErrorMessage: (msg: string | null) => void): ApolloLink {\n return from([\n createErrorLink(setSchemaErrorMessage),\n new HttpLink({ uri: `/api/flexkit/${currentProjectId}/graphql` }),\n ]);\n}\n\nfunction client(\n currentProjectId: string | undefined,\n setSchemaErrorMessage: (msg: string | null) => void\n): ApolloClient {\n return new ApolloClient({\n link: additiveLink(currentProjectId ?? '', setSchemaErrorMessage),\n cache: new InMemoryCache({\n dataIdFromObject: (responseObject) => {\n return responseObject._id ? (responseObject._id as string) : defaultDataIdFromObject(responseObject);\n },\n }),\n });\n}\n\nexport function GraphQLProvider({ children }: { children: React.ReactNode }): JSX.Element {\n const { currentProjectId } = useConfig();\n const [schemaErrorMessage, setSchemaErrorMessage] = useState<string | null>(null);\n const ctx = useMemo(() => ({ schemaErrorMessage, setSchemaErrorMessage }), [schemaErrorMessage]);\n const apolloClient = useMemo(() => client(currentProjectId, setSchemaErrorMessage), [currentProjectId]);\n\n return (\n <GraphQLErrorContext.Provider value={ctx}>\n <ApolloProviderCompat client={apolloClient}>{children}</ApolloProviderCompat>\n </GraphQLErrorContext.Provider>\n );\n}\n\nexport { useGraphQLError };\n","'use client';\n\nimport { createContext, useContext, useReducer } from 'react';\nimport type { Dispatch, JSX, ReactNode } from 'react';\nimport { props, uniqBy } from 'ramda';\nimport type {\n Action,\n ActionAddEntity,\n ActionAlertDialog,\n ActionDeleteEntity,\n ActionEditEntity,\n ActionEditRelationship,\n} from './types';\n\nconst ActionsContext = createContext<Action[] | []>([]);\nconst EntityDispatchContext = createContext<Dispatch<Action>>(() => undefined);\n\nfunction actionsReducer(actions: Action[], action: Action): Action[] {\n const actionType = action.type;\n\n if (!action._id) {\n action._id = Date.now().toString();\n }\n\n switch (actionType) {\n case 'DeleteEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionDeleteEntity[]), action]);\n }\n case 'AddEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionAddEntity[]), action]);\n }\n case 'EditEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionEditEntity[]), action]);\n }\n case 'EditRelationship': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionEditRelationship[]), action]);\n }\n case 'AlertDialog': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionAlertDialog[]), action]);\n }\n case 'Dismiss': {\n return actions.filter((item) => item._id !== action._id);\n }\n default: {\n throw Error(`Unknown action: ${actionType as string}`);\n }\n }\n}\n\nfunction ActionsProvider({ children }: { children: ReactNode }): JSX.Element {\n const [entityActions, dispatchEntityActions] = useReducer(actionsReducer, []);\n\n return (\n <ActionsContext.Provider value={entityActions}>\n <EntityDispatchContext.Provider value={dispatchEntityActions}>{children}</EntityDispatchContext.Provider>\n </ActionsContext.Provider>\n );\n}\n\nfunction useActions(): Action[] {\n return useContext(ActionsContext);\n}\n\nfunction useDispatch(): Dispatch<Action> {\n return useContext(EntityDispatchContext);\n}\n\nexport { ActionsProvider, useActions, useDispatch };\n"]}
1
+ {"version":3,"sources":["../src/graphql-client/error-utils.ts","../src/graphql-client/graphql-context.tsx","../src/entities/actions-context.tsx"],"names":["hasCause","error","getServerError","ServerError","possibleServerError","getErrorMessage","message","parseErrorBody","bodyText","getGraphQLSchemaMismatchMessage","messages","getGraphQLValidationMessages","isMissingCountStoreFieldMessage","isMissingGraphQLFieldError","fieldName","CombinedGraphQLErrors","isSchemaValidationError","directMessage","isSchemaValidationMessage","serverError","responseBody","getServerErrorResult","getErrorCauseResponse","item","result","cause","causeMessage","extensions","ApolloProviderCompat","ApolloProvider","GraphQLErrorContext","createContext","useGraphQLError","ctx","useContext","USER_QUERY_CONTEXT","createErrorLink","setSchemaErrorMessage","ErrorLink","operation","schemaMismatchMessage","locations","path","CombinedProtocolErrors","responseError","errors","responseMessage","firstError","firstErrorMessage","additiveLink","currentProjectId","from","HttpLink","client","ApolloClient","InMemoryCache","responseObject","defaultDataIdFromObject","GraphQLProvider","children","useConfig","schemaErrorMessage","useState","useMemo","apolloClient","jsx","ActionsContext","EntityDispatchContext","actionsReducer","actions","action","actionType","uniqBy","props","ActionsProvider","entityActions","dispatchEntityActions","useReducer","useActions","useDispatch"],"mappings":"4eAsBA,SAASA,CAAAA,CAASC,EAA2C,CAC3D,OAAKA,EAIE,OAAA,GAAYA,CAAAA,CAHV,KAIX,CAEO,SAASC,CAAAA,CAAeD,CAAAA,CAAuC,CACpE,GAAI,CAACA,CAAAA,CACH,OAAO,IAAA,CAGT,GAAIE,YAAY,EAAA,CAAGF,CAAK,EACtB,OAAOA,CAAAA,CAGT,GAAID,CAAAA,CAASC,CAAK,CAAA,CAAG,CACnB,IAAMG,CAAAA,CAAsBH,CAAAA,CAAM,KAAA,CAElC,GAAIE,YAAY,EAAA,CAAGC,CAAmB,CAAA,CACpC,OAAOA,CAEX,CAEA,OAAO,IACT,CAEA,SAASC,EAAgBJ,CAAAA,CAA+B,CACtD,GAAI,CAACA,GAAS,OAAOA,CAAAA,EAAU,QAAA,CAC7B,OAAO,KAGT,GAAM,CAAE,OAAA,CAAAK,CAAQ,EAAIL,CAAAA,CAEpB,OAAO,OAAOK,CAAAA,EAAY,SAAWA,CAAAA,CAAU,IACjD,CAEO,SAASC,EAAkBC,CAAAA,CAAwC,CACxE,GAAI,CAACA,EACH,OAAO,IAAA,CAGT,GAAI,CACF,OAAO,IAAA,CAAK,KAAA,CAAMA,CAAQ,CAC5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M,CAAC,MAAA,CAAkB,KAAK,CAAC,EAAG,CAAC,GAAIJ,EAAiCC,CAAM,CAAC,EAE/F,KAAK,SAAA,CACH,OAAOD,CAAAA,CAAQ,MAAA,CAAQ9C,CAAAA,EAASA,EAAK,GAAA,GAAQ+C,CAAAA,CAAO,GAAG,CAAA,CAEzD,QACE,MAAM,KAAA,CAAM,CAAA,gBAAA,EAAmBC,CAAoB,CAAA,CAAE,CAEzD,CACF,CAEA,SAASG,EAAAA,CAAgB,CAAE,QAAA,CAAAf,CAAS,EAAyC,CAC3E,GAAM,CAACgB,CAAAA,CAAeC,CAAqB,CAAA,CAAIC,WAAWT,CAAAA,CAAgB,EAAE,CAAA,CAE5E,OACEH,IAACC,CAAAA,CAAe,QAAA,CAAf,CAAwB,KAAA,CAAOS,CAAAA,CAC9B,QAAA,CAAAV,IAACE,CAAAA,CAAsB,QAAA,CAAtB,CAA+B,KAAA,CAAOS,CAAAA,CAAwB,SAAAjB,CAAAA,CAAS,CAAA,CAC1E,CAEJ,CAEA,SAASmB,EAAAA,EAAuB,CAC9B,OAAO5C,UAAAA,CAAWgC,CAAc,CAClC,CAEA,SAASa,IAAgC,CACvC,OAAO7C,UAAAA,CAAWiC,CAAqB,CACzC","file":"chunk-6AJRQSFO.js","sourcesContent":["import type { ErrorLike } from '@apollo/client';\nimport { CombinedGraphQLErrors, ServerError } from '@apollo/client/errors';\n\ntype ErrorWithCause = ErrorLike & { cause?: unknown };\ntype ErrorWithMessage = {\n message?: unknown;\n};\ntype ServerErrorWithResult = ServerError & {\n result?: unknown;\n};\ntype GraphQLErrorResponse = {\n error?: unknown;\n errors?: unknown;\n message?: unknown;\n};\ntype GraphQLErrorItem = {\n extensions?: {\n code?: unknown;\n };\n message?: unknown;\n};\n\nfunction hasCause(error: ErrorLike): error is ErrorWithCause {\n if (!error) {\n return false;\n }\n\n return 'cause' in (error as ErrorWithCause);\n}\n\nexport function getServerError(error?: ErrorLike): ServerError | null {\n if (!error) {\n return null;\n }\n\n if (ServerError.is(error)) {\n return error;\n }\n\n if (hasCause(error)) {\n const possibleServerError = error.cause;\n\n if (ServerError.is(possibleServerError)) {\n return possibleServerError;\n }\n }\n\n return null;\n}\n\nfunction getErrorMessage(error: unknown): string | null {\n if (!error || typeof error !== 'object') {\n return null;\n }\n\n const { message } = error as ErrorWithMessage;\n\n return typeof message === 'string' ? message : null;\n}\n\nexport function parseErrorBody<T>(bodyText: string | undefined): T | null {\n if (!bodyText) {\n return null;\n }\n\n try {\n return JSON.parse(bodyText) as T;\n } catch {\n return null;\n }\n}\n\nexport function getGraphQLSchemaMismatchMessage(error?: ErrorLike): string | null {\n if (!error) {\n return null;\n }\n\n const messages = getGraphQLValidationMessages(error).filter((message) => !isMissingCountStoreFieldMessage(message));\n\n if (messages.length === 0) {\n return null;\n }\n\n return [\n 'The deployed schema is out of sync with your local Flexkit schema.',\n 'Run `flexkit deploy` using the CLI to apply your latest schema changes.',\n ...messages.map((message) => `- ${message}`),\n ].join('\\n');\n}\n\nexport function isMissingGraphQLFieldError(error: ErrorLike | undefined, fieldName: string): boolean {\n if (!error) {\n return false;\n }\n\n return getGraphQLValidationMessages(error).some((message) => {\n return message.includes(`Cannot query field \"${fieldName}\"`);\n });\n}\n\nfunction getGraphQLValidationMessages(error: ErrorLike): string[] {\n if (CombinedGraphQLErrors.is(error)) {\n return error.errors.filter(isSchemaValidationError).map(({ message }) => message);\n }\n\n const directMessage = getErrorMessage(error);\n\n if (directMessage && isSchemaValidationMessage(directMessage)) {\n return [directMessage];\n }\n\n const serverError = getServerError(error);\n\n if (serverError?.statusCode !== 400) {\n return [];\n }\n\n const responseBody =\n parseErrorBody<GraphQLErrorResponse>(serverError.bodyText) ??\n getServerErrorResult(serverError) ??\n getErrorCauseResponse(error);\n\n if (!responseBody) {\n return [];\n }\n\n if (Array.isArray(responseBody.errors)) {\n return responseBody.errors.filter(isSchemaValidationError).map((item) => item.message);\n }\n\n if (typeof responseBody.message === 'string' && isSchemaValidationMessage(responseBody.message)) {\n return [responseBody.message];\n }\n\n if (typeof responseBody.error === 'string' && isSchemaValidationMessage(responseBody.error)) {\n return [responseBody.error];\n }\n\n return [];\n}\n\nfunction getServerErrorResult(serverError: ServerError): GraphQLErrorResponse | null {\n const { result } = serverError as ServerErrorWithResult;\n\n if (!result || typeof result !== 'object') {\n return null;\n }\n\n return result as GraphQLErrorResponse;\n}\n\nfunction getErrorCauseResponse(error: ErrorLike): GraphQLErrorResponse | null {\n if (!hasCause(error)) {\n return null;\n }\n\n const { cause } = error;\n const causeMessage = getErrorMessage(cause);\n\n if (causeMessage && isSchemaValidationMessage(causeMessage)) {\n return { message: causeMessage };\n }\n\n if (!cause || typeof cause !== 'object') {\n return null;\n }\n\n const { result } = cause as { result?: unknown };\n\n if (result && typeof result === 'object') {\n return result as GraphQLErrorResponse;\n }\n\n return null;\n}\n\nfunction isSchemaValidationError(error: unknown): error is GraphQLErrorItem & { message: string } {\n if (!error || typeof error !== 'object') {\n return false;\n }\n\n const { extensions, message } = error as GraphQLErrorItem;\n const code = extensions?.code;\n\n if (code === 'GRAPHQL_VALIDATION_FAILED' && typeof message === 'string') {\n return true;\n }\n\n return typeof message === 'string' && isSchemaValidationMessage(message);\n}\n\nfunction isSchemaValidationMessage(message: string): boolean {\n return (\n message.startsWith('Cannot query field ') ||\n message.startsWith('Unknown type ') ||\n message.startsWith('Cannot query field \"') ||\n message.includes('GRAPHQL_VALIDATION_FAILED')\n );\n}\n\nfunction isMissingCountStoreFieldMessage(message: string): boolean {\n return /Cannot query field \"[_A-Za-z][_0-9A-Za-z]*Total\" on type \"Query\"/.test(message);\n}\n","'use client';\n\nimport type { JSX } from 'react';\nimport { ApolloClient, InMemoryCache, defaultDataIdFromObject, from, HttpLink } from '@apollo/client';\nimport type { ApolloLink } from '@apollo/client';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { ErrorLink } from '@apollo/client/link/error';\nimport { CombinedGraphQLErrors, CombinedProtocolErrors } from '@apollo/client/errors';\nimport { getGraphQLSchemaMismatchMessage, getServerError, parseErrorBody } from './error-utils';\nimport { useConfig } from '../core/config/config-context';\nimport React, { createContext, useContext, useMemo, useState } from 'react';\n\nconst ApolloProviderCompat = ApolloProvider as unknown as React.ComponentType<{\n children?: React.ReactNode;\n client: ApolloClient;\n}>;\n\ntype GraphQLErrorContextValue = {\n schemaErrorMessage: string | null;\n setSchemaErrorMessage: React.Dispatch<React.SetStateAction<string | null>>;\n};\n\nconst GraphQLErrorContext = createContext<GraphQLErrorContextValue | undefined>(undefined);\n\nfunction useGraphQLError(): GraphQLErrorContextValue {\n const ctx = useContext(GraphQLErrorContext);\n\n if (!ctx) {\n throw new Error('useGraphQLError must be used within GraphQLProvider');\n }\n\n return ctx;\n}\n\n/**\n * Context flag for operations the user writes themselves (the Graph app's\n * Query view): any error there, a mismatch or a 400, is a typo, not a\n * deployment that drifted from the local schema, so it must not raise the\n * schema banner. The caller shows the error itself.\n */\nexport const USER_QUERY_CONTEXT = { userQuery: true } as const;\n\nfunction createErrorLink(setSchemaErrorMessage: (msg: string | null) => void): ApolloLink {\n return new ErrorLink(({ error, operation }) => {\n if (operation.getContext().userQuery === true) {\n return;\n }\n\n const schemaMismatchMessage = getGraphQLSchemaMismatchMessage(error);\n\n if (schemaMismatchMessage) {\n setSchemaErrorMessage(schemaMismatchMessage);\n\n return;\n }\n\n if (CombinedGraphQLErrors.is(error)) {\n error.errors.forEach(({ message, locations, path }) => {\n console.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);\n });\n } else if (CombinedProtocolErrors.is(error)) {\n error.errors.forEach(({ message, extensions }) => {\n console.warn(`[Protocol error]: Message: ${message}, Extensions: ${JSON.stringify(extensions)}`);\n });\n }\n\n const serverError = getServerError(error);\n\n if (serverError?.statusCode === 400) {\n const responseBody = parseErrorBody<Record<string, unknown>>(serverError.bodyText);\n let message: string | null = null;\n\n if (responseBody && typeof responseBody === 'object') {\n const {\n error: responseError,\n errors,\n message: responseMessage,\n } = responseBody as {\n error?: unknown;\n errors?: unknown;\n message?: unknown;\n };\n\n if (typeof responseMessage === 'string') {\n message = responseMessage;\n } else if (Array.isArray(errors)) {\n const [firstError] = errors as { message?: unknown }[];\n\n if (firstError && typeof firstError.message === 'string') {\n const { message: firstErrorMessage } = firstError;\n message = firstErrorMessage;\n }\n } else if (typeof responseError === 'string') {\n message = responseError;\n } else {\n message = JSON.stringify(responseBody);\n }\n } else {\n message = serverError.bodyText;\n }\n\n setSchemaErrorMessage(\n message ?? 'There is an error in the deployed Flexkit schema. Fix flexkit.config.ts and run flexkit deploy.'\n );\n }\n\n if (serverError) {\n console.warn(`[Network error]: ${serverError.message}`);\n\n return;\n }\n\n if (error) {\n console.warn(`[Network error]: ${error.message}`);\n }\n });\n}\n\nfunction additiveLink(currentProjectId: string, setSchemaErrorMessage: (msg: string | null) => void): ApolloLink {\n return from([\n createErrorLink(setSchemaErrorMessage),\n new HttpLink({ uri: `/api/flexkit/${currentProjectId}/graphql` }),\n ]);\n}\n\nfunction client(\n currentProjectId: string | undefined,\n setSchemaErrorMessage: (msg: string | null) => void\n): ApolloClient {\n return new ApolloClient({\n link: additiveLink(currentProjectId ?? '', setSchemaErrorMessage),\n cache: new InMemoryCache({\n dataIdFromObject: (responseObject) => {\n return responseObject._id ? (responseObject._id as string) : defaultDataIdFromObject(responseObject);\n },\n }),\n });\n}\n\nexport function GraphQLProvider({ children }: { children: React.ReactNode }): JSX.Element {\n const { currentProjectId } = useConfig();\n const [schemaErrorMessage, setSchemaErrorMessage] = useState<string | null>(null);\n const ctx = useMemo(() => ({ schemaErrorMessage, setSchemaErrorMessage }), [schemaErrorMessage]);\n const apolloClient = useMemo(() => client(currentProjectId, setSchemaErrorMessage), [currentProjectId]);\n\n return (\n <GraphQLErrorContext.Provider value={ctx}>\n <ApolloProviderCompat client={apolloClient}>{children}</ApolloProviderCompat>\n </GraphQLErrorContext.Provider>\n );\n}\n\nexport { useGraphQLError };\n","'use client';\n\nimport { createContext, useContext, useReducer } from 'react';\nimport type { Dispatch, JSX, ReactNode } from 'react';\nimport { props, uniqBy } from 'ramda';\nimport type {\n Action,\n ActionAddEntity,\n ActionAlertDialog,\n ActionDeleteEntity,\n ActionEditEntity,\n ActionEditRelationship,\n} from './types';\n\nconst ActionsContext = createContext<Action[] | []>([]);\nconst EntityDispatchContext = createContext<Dispatch<Action>>(() => undefined);\n\nfunction actionsReducer(actions: Action[], action: Action): Action[] {\n const actionType = action.type;\n\n if (!action._id) {\n action._id = Date.now().toString();\n }\n\n switch (actionType) {\n case 'DeleteEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionDeleteEntity[]), action]);\n }\n case 'AddEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionAddEntity[]), action]);\n }\n case 'EditEntity': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionEditEntity[]), action]);\n }\n case 'EditRelationship': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionEditRelationship[]), action]);\n }\n case 'AlertDialog': {\n return uniqBy(props(['type' as string, '_id']), [...(actions as ActionAlertDialog[]), action]);\n }\n case 'Dismiss': {\n return actions.filter((item) => item._id !== action._id);\n }\n default: {\n throw Error(`Unknown action: ${actionType as string}`);\n }\n }\n}\n\nfunction ActionsProvider({ children }: { children: ReactNode }): JSX.Element {\n const [entityActions, dispatchEntityActions] = useReducer(actionsReducer, []);\n\n return (\n <ActionsContext.Provider value={entityActions}>\n <EntityDispatchContext.Provider value={dispatchEntityActions}>{children}</EntityDispatchContext.Provider>\n </ActionsContext.Provider>\n );\n}\n\nfunction useActions(): Action[] {\n return useContext(ActionsContext);\n}\n\nfunction useDispatch(): Dispatch<Action> {\n return useContext(EntityDispatchContext);\n}\n\nexport { ActionsProvider, useActions, useDispatch };\n"]}
@@ -0,0 +1,2 @@
1
+ import'./index.css';import {a}from'./chunk-QSTWBKPN.js';import {a as a$1,d}from'./chunk-WU2KCXBC.js';import {f,d as d$2}from'./chunk-U6VZY3V2.js';import {f as f$1}from'./chunk-VRDTHLA3.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-7JA6SI5H.js.map
2
+ //# sourceMappingURL=chunk-7JA6SI5H.js.map