@fluidgrids/fe-sdk 0.0.0-stage → 2026.1203.7

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 (323) hide show
  1. package/README.md +564 -2
  2. package/dist/ActivityOptionsFields-C2u-hY2U.js +142 -0
  3. package/dist/AiStudioPage-B_hNTj-_.js +1137 -0
  4. package/dist/ApprovalInboxPage-ClITra3n.js +1312 -0
  5. package/dist/ChoiceSelect-LkK-uS9J.js +65 -0
  6. package/dist/ConfirmActionDialog-DHWTDRbp.js +31 -0
  7. package/dist/ConnectionFormDialog-C0kDgcrZ.js +153 -0
  8. package/dist/CreateFluidgridsTagDocument-Dtp9KPLJ.js +1055 -0
  9. package/dist/DataSinkDashboardPage-b4ezeqa6.js +278 -0
  10. package/dist/DataTablesPage-C1d9YGHz.js +5575 -0
  11. package/dist/DateTimeField-B1qR4ruo.js +51 -0
  12. package/dist/Disclosure-BNKij7-v.js +45 -0
  13. package/dist/ElementLibraryPage-8jNO6YmE.js +2256 -0
  14. package/dist/ElementLibrarySequenceDocument-B-W8SPzn.js +3979 -0
  15. package/dist/EnsureThemeProvider-BvlNjAd0.js +24 -0
  16. package/dist/EntityTagBadge-1OlP6p0c.js +25 -0
  17. package/dist/EntityTagPicker-BBrU5cE0.js +137 -0
  18. package/dist/ExecuteStepDocument-B4j1mdRT.js +189 -0
  19. package/dist/ExecutionDetailDocument-D6QuM-kp.js +875 -0
  20. package/dist/ExecutionDetailPage-D4CBtFdo.js +12217 -0
  21. package/dist/ExecutionDetailPage-DvQ667OE.d.ts +10 -0
  22. package/dist/ExecutionStatusBadge-BsDVor9t.js +221 -0
  23. package/dist/ExecutionsListDocument-Dan7ZiqB.js +459 -0
  24. package/dist/ExecutionsListPage-B3XT8ITL.js +4307 -0
  25. package/dist/FailureTriagePanel-DOJMaJ0n.js +1285 -0
  26. package/dist/FileDownloadUrlDocument-CVOYKcL5.js +92 -0
  27. package/dist/FluidGridsDocsLink-bX0Hnhxr.js +66 -0
  28. package/dist/FluidGridsMark-CE2blT7K.js +74 -0
  29. package/dist/HeldLoadRegion-BtTxbvOW.js +34 -0
  30. package/dist/HistoryPage-BLoRpJ1R.d.ts +6 -0
  31. package/dist/HistoryPage-BSBISXoj.js +2835 -0
  32. package/dist/Icon-BtQ0HXLh.js +160 -0
  33. package/dist/InsightsPage-D7ybj8N9.js +11245 -0
  34. package/dist/IsolationSetting-vy911E8b.js +1153 -0
  35. package/dist/LibraryParts-DOeNgR8A.js +413 -0
  36. package/dist/ManagedAiPolicyAuthority-BxwJ3ptd.js +40 -0
  37. package/dist/ManagedAiPolicyAuthority-DM3t3wNr.d.ts +18 -0
  38. package/dist/ManagedAiPolicyAuthorityContext-CNkxIOZ1.js +10 -0
  39. package/dist/McpTriggerServers-BCPCAOWB.js +459 -0
  40. package/dist/MissingNodesInstallModal-rO_SEDrC.js +224 -0
  41. package/dist/NavigationV2Provider-DCDt35eG.js +17 -0
  42. package/dist/NodeSchemaIntrospectionDocument-C1vAIcHd.js +95 -0
  43. package/dist/NodesPage-DEbnz9iU.d.ts +6 -0
  44. package/dist/NodesPage-O7KeeKtd.js +653 -0
  45. package/dist/OfflineIcon-TwMKYWjA.js +207 -0
  46. package/dist/OpenTemplateAsCodeButton-BhWJWIF3.js +94 -0
  47. package/dist/PaidTemplateConfirm-_G3ag6S4.js +28 -0
  48. package/dist/PublishCustomNodeAction-CIySbK4c.js +134 -0
  49. package/dist/RecordTaskDialog-BkpCDvhR.js +2078 -0
  50. package/dist/RunActionsMenu-DodOgIQm.js +59 -0
  51. package/dist/RunnerStatusPill-C1v967iq.js +24 -0
  52. package/dist/RunnersPage-dB0RSdY_.js +1929 -0
  53. package/dist/SandboxRuntimeExhaustedNotice-BFOIF93C.js +120 -0
  54. package/dist/SchedulesPage-DPWr1yvf.js +1607 -0
  55. package/dist/SearchBox-BGtYjvfs.js +49 -0
  56. package/dist/SequenceEditor-CFiHeHkR.js +497 -0
  57. package/dist/SettingsPage-0CQBNPZV.js +8695 -0
  58. package/dist/StewardPages-DAJhepen.js +47 -0
  59. package/dist/StewardRunImportPanel-Kva2DO0u.js +2844 -0
  60. package/dist/StoreTemplateCardCompact-CHn5kP7A.js +2166 -0
  61. package/dist/TagFilterSelect-CyA8QrS7.js +42 -0
  62. package/dist/TaskQueuesPage-DdnDCyat.js +3571 -0
  63. package/dist/TechnicalDetails-B0Oi4aZw.js +19 -0
  64. package/dist/TemplateConfigurationModal-CdvCYJLM.js +332 -0
  65. package/dist/TemplateDetailPanel-CbiKciuB.js +222 -0
  66. package/dist/TemplatePreview-cx7-NOeG.js +868 -0
  67. package/dist/TemplatesPage-BG3H-6v6.d.ts +10 -0
  68. package/dist/TemplatesPage-BVQpGYIV.js +3251 -0
  69. package/dist/TerminateExecutionDocument-B_HKNVrN.js +581 -0
  70. package/dist/TranslationBridge-Bd4aJKMs.d.ts +11 -0
  71. package/dist/TranslationBridge-Da-TPgQm.js +68 -0
  72. package/dist/TriggerWorkflowDocument-D9Km2Vv2.js +460 -0
  73. package/dist/UiSequencePickerSequenceDocument-BSYnSDV7.js +607 -0
  74. package/dist/UiStepScreenshot-Qh4QMyUp.js +146 -0
  75. package/dist/UsageTimeSeriesDocument-DcInx9-z.js +177 -0
  76. package/dist/VariablesPage-ChfGuW22.js +2243 -0
  77. package/dist/VersionDiffDialog-Bd2AeUwf.js +1702 -0
  78. package/dist/VersionLifecycleBar-BBeWVtz-.js +143 -0
  79. package/dist/WebhookDeliveriesPage-D66bua0j.js +1563 -0
  80. package/dist/WorkflowBuilder-B6wQD1TK.js +539 -0
  81. package/dist/WorkflowBuilder-DR4ku8Tr.js +1611 -0
  82. package/dist/WorkflowDefinitionDocument-DZLbTPUZ.js +321 -0
  83. package/dist/WorkflowEmbed-BXfFGy0i.js +708 -0
  84. package/dist/WorkflowEmbed-Cbqe1s1z.d.ts +6 -0
  85. package/dist/WorkflowPinnedDataDocument-BODT5omd.js +782 -0
  86. package/dist/WorkflowProposalCard-BruukdeF.js +96 -0
  87. package/dist/WorkflowProposalDocument-BdUbsrd0.js +620 -0
  88. package/dist/WorkflowSearchRedirect-C7zJ2MKH.js +40 -0
  89. package/dist/WorkflowSettingsDrawer-MVU1BKfY.d.ts +18 -0
  90. package/dist/WorkflowSettingsDrawer-gazs97WR.js +196 -0
  91. package/dist/WorkflowShareDialog-e8jJtLjU.js +469 -0
  92. package/dist/WorkflowVersionsDocument-DRVOp8Uj.js +3213 -0
  93. package/dist/WorkflowsList--hR2_8gf.js +4593 -0
  94. package/dist/WorkflowsList-CcNDQge5.d.ts +6 -0
  95. package/dist/WorkflowsListPageDocument-CnzcQm_o.js +934 -0
  96. package/dist/addonCatalog-CbZS4deh.js +58 -0
  97. package/dist/addonCatalog-sjlonAmR.d.ts +15 -0
  98. package/dist/addons.d.ts +3 -0
  99. package/dist/addons.js +4 -0
  100. package/dist/agent-form-Bfvm32j1.js +83 -0
  101. package/dist/agent-tools.d.ts +3 -0
  102. package/dist/agent-tools.js +5 -0
  103. package/dist/agentTools-CyL7DLOF.js +320 -0
  104. package/dist/ai-usage-BrxDgvdR.js +240 -0
  105. package/dist/aiCreditsBridge-BuE92tKo.js +49 -0
  106. package/dist/api-BKq-nIOZ.js +2286 -0
  107. package/dist/api-Ol7I8NxE.js +8289 -0
  108. package/dist/apollo-type-policies.d.ts +11 -0
  109. package/dist/apollo-type-policies.js +64 -0
  110. package/dist/askAboutBridge-ByYsQams.js +106 -0
  111. package/dist/askQuestions-Cmx7VnMm.js +742 -0
  112. package/dist/assert-rules-lfYEMc99.js +318 -0
  113. package/dist/assistant.d.ts +94 -0
  114. package/dist/assistant.js +99 -0
  115. package/dist/attach-node-helpers-HDKQOtrD.js +32 -0
  116. package/dist/badge-CXfPhoMH.js +26 -0
  117. package/dist/basil.generated-BK-EHbwN.js +10 -0
  118. package/dist/browser-steps-DMpS5TyB.js +533 -0
  119. package/dist/builderTimings-pvGnK1m-.js +510 -0
  120. package/dist/button-DG7y_FVJ.js +48 -0
  121. package/dist/canvasNoteTools-BxuP_AYO.js +137 -0
  122. package/dist/card-Bomy_1UG.js +44 -0
  123. package/dist/catalogGrid-BOrfMgi-.js +41 -0
  124. package/dist/channel-CPyQ1NR1.js +212 -0
  125. package/dist/chips-CvNrYJZa.js +27 -0
  126. package/dist/client-holder-C0M5Cfwl.js +68 -0
  127. package/dist/cn-QqidFIgr.js +10 -0
  128. package/dist/code-editor-diagnostics-Zr0cIcx1.js +46 -0
  129. package/dist/code-editor-field-x_JrY8KR.js +113 -0
  130. package/dist/codec-client-DPuD6mw7.js +515 -0
  131. package/dist/conditionBuilder-DwfEF0Q-.js +1144 -0
  132. package/dist/config-DO68jw5k.js +322 -0
  133. package/dist/constants-DgbVc24O.d.ts +296 -0
  134. package/dist/constants-DlRnHBfQ.js +217 -0
  135. package/dist/convert-browser-action-pfecelF7.js +347 -0
  136. package/dist/convert-dialog-B_o22NiJ.js +382 -0
  137. package/dist/create-workflow-first-Azg3JUdX.js +120 -0
  138. package/dist/definition-canvas-Bsda-rDT.js +31 -0
  139. package/dist/dialog-BVd152GS.js +94 -0
  140. package/dist/durable-nodes-BXyYCLxT.js +91 -0
  141. package/dist/duration-CDb7-mT_.js +33 -0
  142. package/dist/edge-mapper-wEAdGVU2.js +4477 -0
  143. package/dist/element-library-DkSlg_VE.js +727 -0
  144. package/dist/entities-I_0kio3q.js +38 -0
  145. package/dist/error-advice-QLr5NCm7.js +65 -0
  146. package/dist/errors-ClKb5sEt.js +188 -0
  147. package/dist/executions.d.ts +3 -0
  148. package/dist/executions.js +5 -0
  149. package/dist/feature-flags-B2qetXKd.js +385 -0
  150. package/dist/field-label-DPZRmE_B.js +153 -0
  151. package/dist/firstWorkflow-C_h0KMB2.js +133 -0
  152. package/dist/flags.d.ts +3 -0
  153. package/dist/flags.js +4 -0
  154. package/dist/flow-builder-DIvLOhz0.js +28038 -0
  155. package/dist/flow-store-holder-CUN7Terz.js +52 -0
  156. package/dist/fluent.generated-CA_e6-4l.js +14 -0
  157. package/dist/fluidgridsEvents-bbEQbwU6.js +175 -0
  158. package/dist/fluidgridsTheme-DUhvOgoy.js +297 -0
  159. package/dist/global-client-BQPuFrFa.js +433 -0
  160. package/dist/global-operations-BG6YgxrM.js +136 -0
  161. package/dist/graphql-types-UTYtujY9.js +21358 -0
  162. package/dist/history.d.ts +3 -0
  163. package/dist/history.js +4 -0
  164. package/dist/index-AoJAa5vU.d.ts +164958 -0
  165. package/dist/index-DEMT3iAM.d.ts +120 -0
  166. package/dist/index-ROZzNGyY.d.ts +76 -0
  167. package/dist/index.d.ts +20 -0
  168. package/dist/index.js +8123 -0
  169. package/dist/ion.generated-mbajjcAg.js +10 -0
  170. package/dist/label-Lzb8ZXf_.js +29 -0
  171. package/dist/labels-rXd9gYQz.js +1236 -0
  172. package/dist/liveCanvas-D5ytXDp8.js +103 -0
  173. package/dist/logos.generated-X6_0kjVR.js +21 -0
  174. package/dist/logs-panel-Cw0DkG0l.js +468 -0
  175. package/dist/lucide.generated-B6NVd3GT.js +29 -0
  176. package/dist/marksStore-a9oIMMot.js +175 -0
  177. package/dist/mcp-trigger-D0nRdvq5.js +307 -0
  178. package/dist/mdi.generated-D1BV74d6.js +292 -0
  179. package/dist/menus-CU3hDGYl.js +160 -0
  180. package/dist/mynaui.generated-DMWr5cXz.js +66 -0
  181. package/dist/navigation-v2.d.ts +3 -0
  182. package/dist/navigation-v2.js +5 -0
  183. package/dist/node-detail-view-Cgm5H1P-.js +1372 -0
  184. package/dist/node-editor-tab-body-CZ0fVuVP.js +187 -0
  185. package/dist/node-operation-selection-CdV3KI_V.js +3534 -0
  186. package/dist/node-registry-refresh-s3okf83X.js +27 -0
  187. package/dist/node-role-TMbnkmeP.js +132 -0
  188. package/dist/node-type-icon-BZa8n4iG.js +33 -0
  189. package/dist/nodes.d.ts +3 -0
  190. package/dist/nodes.js +4 -0
  191. package/dist/notesKey-5EaREBGA.js +12 -0
  192. package/dist/observability.d.ts +3 -0
  193. package/dist/observability.js +5 -0
  194. package/dist/offset-pages-zghoClB3.js +55 -0
  195. package/dist/operations-BBmT9ToP.js +663 -0
  196. package/dist/operations-WxRJWeqO.js +3133 -0
  197. package/dist/output-files-Ba8bu5lv.js +196 -0
  198. package/dist/page-operation-DrWuhd6Y.js +129 -0
  199. package/dist/page-twins.d.ts +13 -0
  200. package/dist/page-twins.js +186 -0
  201. package/dist/pageControlSpecs-DZJ9K37m.js +134 -0
  202. package/dist/pageControlsBridge-0pX9s-3k.js +54 -0
  203. package/dist/pageControlsBridge-DAuT3w7L.d.ts +36 -0
  204. package/dist/panels-PfBBAToE.js +346 -0
  205. package/dist/parts-B7fBcw-B.js +346 -0
  206. package/dist/popover-Dms9Vz3j.js +3389 -0
  207. package/dist/preloadable-lazy-Pp47mqQ9.js +65 -0
  208. package/dist/proactive.d.ts +66 -0
  209. package/dist/proactive.js +237 -0
  210. package/dist/quick-config-panel-DFd77xho.js +451 -0
  211. package/dist/quota-DeA_CJ2e.js +175 -0
  212. package/dist/quota.d.ts +3 -0
  213. package/dist/quota.js +4 -0
  214. package/dist/read-only-context-Dt9N9SIG.js +18 -0
  215. package/dist/relative-time-Dxt8ZIIu.js +55 -0
  216. package/dist/results-CwK_yDxK.js +325 -0
  217. package/dist/rolldown-runtime-hDbaFkMy.js +18 -0
  218. package/dist/route-data.d.ts +12 -0
  219. package/dist/route-data.js +69 -0
  220. package/dist/route-match-C-0_EnAt.d.ts +5 -0
  221. package/dist/route-match-DMkUICYV.js +41 -0
  222. package/dist/route-preload-C4DlGoCd.js +120 -0
  223. package/dist/run-display-UjLAoYqQ.js +81 -0
  224. package/dist/run-history-arGiHzGU.js +285 -0
  225. package/dist/run-list-links-DJn4Mf1T.js +98 -0
  226. package/dist/run-mode-USmM0-Uo.js +82 -0
  227. package/dist/run-parity-CWXqEJqM.js +144 -0
  228. package/dist/runsQuota-B6SyTbne.js +100 -0
  229. package/dist/runsQuota-DsniKiSg.d.ts +20 -0
  230. package/dist/safe-expression-Cw7-SCsm.js +1251 -0
  231. package/dist/save-status-store-C7nEYpfb.js +631 -0
  232. package/dist/schedule-panel-B4GYXzXQ.js +13774 -0
  233. package/dist/schedule-rules-ggVKRkBH.js +358 -0
  234. package/dist/secrets-Re_wSiE3.js +153 -0
  235. package/dist/settings.d.ts +4 -0
  236. package/dist/settings.js +6 -0
  237. package/dist/shared-DAWGGMSM.js +177 -0
  238. package/dist/sidebar-node-editor-6eSSgCzc.js +178 -0
  239. package/dist/solar.generated-CGYuUQAC.js +10 -0
  240. package/dist/stableTabbedDialog-BBhrfXGe.js +20 -0
  241. package/dist/start-url-CT6Yz96K.js +24 -0
  242. package/dist/status-CessxGpm.js +55 -0
  243. package/dist/store-icon-OctYp5zP.js +155 -0
  244. package/dist/styles-WGmTnZ2n.js +26 -0
  245. package/dist/styles.css +139 -0
  246. package/dist/svg-spinners.generated-CIPT7IhM.js +10 -0
  247. package/dist/template-code-CzN6JWNV.js +191 -0
  248. package/dist/template-graph-DLF9dygU.js +20 -0
  249. package/dist/template-preview-DcIIKOOL.js +32 -0
  250. package/dist/template-price-CdUHZRMF.js +40 -0
  251. package/dist/templates.d.ts +3 -0
  252. package/dist/templates.js +5 -0
  253. package/dist/theme-provider-CntfC4_i.js +23 -0
  254. package/dist/transient-DgZfhDfN.js +57 -0
  255. package/dist/typed-calls-C5tO03wq.js +26 -0
  256. package/dist/ui-script-By74Guk3.js +1094 -0
  257. package/dist/ui-script-editor-CqPu2bCN.js +2447 -0
  258. package/dist/ui-step-fix-8uM2_Hft.js +67 -0
  259. package/dist/ui-step-fix-store-CcO1FdRx.js +19 -0
  260. package/dist/ui-step-run-context-o7bLE6KP.js +46 -0
  261. package/dist/ui-target-editor-D2JhB_lD.js +673 -0
  262. package/dist/uiMarkTools-CSznnO1i.js +1054 -0
  263. package/dist/upgradePrompt-BAFBKKW5.js +72 -0
  264. package/dist/use-bare-node-registry-O6mKJO_n.js +11498 -0
  265. package/dist/use-browser-available-hj8wc3Kb.js +241 -0
  266. package/dist/use-edge-mapper-schemas-Bonofxow.js +496 -0
  267. package/dist/use-extension-bridge-B9ZreOkQ.js +608 -0
  268. package/dist/use-mobile-BTqCUjzS.js +27 -0
  269. package/dist/use-sdk-query-C697xZVv.js +116 -0
  270. package/dist/use-workflow-code-editor-CFoRFrZ5.js +753 -0
  271. package/dist/useActionParam-B2tU2BlY.js +85 -0
  272. package/dist/useAgentTokenStream-Bko_J0d0.js +4217 -0
  273. package/dist/useBrowserClients-3v95-gSh.js +103 -0
  274. package/dist/useCodeWorkflowInsights-w0tz9Ap_.js +600 -0
  275. package/dist/useConnections-DsgEJs05.js +439 -0
  276. package/dist/useDebouncedValue-BFekcv6n.js +18 -0
  277. package/dist/useDurableParity-8fnMZmBc.js +1787 -0
  278. package/dist/useEntityTags-D0spL6Ut.js +460 -0
  279. package/dist/useExecutions-2u5nGJJk.js +681 -0
  280. package/dist/useFluidGridsAnalytics-VM8lAi2x.js +238 -0
  281. package/dist/useGlobalStoreClient-BTdhkA2I.js +24 -0
  282. package/dist/useHumanRequests-zlYDp3l1.js +221 -0
  283. package/dist/useNavigationV2-C2WeqN7d.js +29 -0
  284. package/dist/useNavigationV2-DANUmg12.d.ts +9 -0
  285. package/dist/useObservability-BRlQ0tOA.js +285 -0
  286. package/dist/useRequestedProposal-B7uPXfZB.js +51 -0
  287. package/dist/useRunHistory-CXCMUPyf.js +2759 -0
  288. package/dist/useRunLive-D0JvVZT2.js +1060 -0
  289. package/dist/useRunnerList-Dbi59i1K.js +446 -0
  290. package/dist/useRunners-URUc5quU.js +173 -0
  291. package/dist/useRunsPage-DG656UCK.js +2709 -0
  292. package/dist/useVariables-BIelxcWr.js +463 -0
  293. package/dist/useVersionHistoryData-CTjqVw7l.js +292 -0
  294. package/dist/useWorkflowCodeExport-pqxyLHD1.js +522 -0
  295. package/dist/useWorkflowListExport-hcZNvTaB.js +232 -0
  296. package/dist/useWorkflowOrganization-CpBbOrs7.js +1772 -0
  297. package/dist/useWorkflowProposal-BH0VdNMA.js +3280 -0
  298. package/dist/useWorkflows-Cvg-Z_IE.js +1606 -0
  299. package/dist/utils-fvBb5qOD.js +89 -0
  300. package/dist/webhook-deliveries-AvQujaZy.js +99 -0
  301. package/dist/workflow-builder-CJygVkVv.d.ts +2 -0
  302. package/dist/workflow-builder.d.ts +3 -0
  303. package/dist/workflow-builder.js +8 -0
  304. package/dist/workflow-code-transfer-Bsy0JKAZ.js +323 -0
  305. package/dist/workflow-embed.d.ts +3 -0
  306. package/dist/workflow-embed.js +4 -0
  307. package/dist/workflow-git-sync--K9ZsPDC.js +263 -0
  308. package/dist/workflow-host.d.ts +6 -0
  309. package/dist/workflow-host.js +11 -0
  310. package/dist/workflow-pages-D-7ByLTB.d.ts +68 -0
  311. package/dist/workflow-pages.d.ts +3 -0
  312. package/dist/workflow-pages.js +115 -0
  313. package/dist/workflow-preview-canvas-CO8yzdE3.js +848 -0
  314. package/dist/workflow-preview.d.ts +65 -0
  315. package/dist/workflow-preview.js +4 -0
  316. package/dist/workflow-route.d.ts +33 -0
  317. package/dist/workflow-route.js +4 -0
  318. package/dist/workflow-save-state-D0l-DkLf.js +767 -0
  319. package/dist/workflow-transfer-CQnQC-ke.js +104 -0
  320. package/dist/workflowRouteData-BkfVOc-O.js +169 -0
  321. package/dist/workflows-list.d.ts +10 -0
  322. package/dist/workflows-list.js +5 -0
  323. package/package.json +320 -4
@@ -0,0 +1,2166 @@
1
+ "use client";
2
+ import { r as getFluidGridsConfig } from "./config-DO68jw5k.js";
3
+ import { n as getGlobalStoreClient } from "./global-client-BQPuFrFa.js";
4
+ import { s as throwIfResultError, t as describeOperationError } from "./errors-ClKb5sEt.js";
5
+ import { n as getFluidGridsClient } from "./client-holder-C0M5Cfwl.js";
6
+ import { r as useTr } from "./TranslationBridge-Da-TPgQm.js";
7
+ import { n as FluidGridsContext, t as useFluidGridsAnalytics } from "./useFluidGridsAnalytics-VM8lAi2x.js";
8
+ import { t as cn } from "./cn-QqidFIgr.js";
9
+ import { C as GetMyNodeInstallationsDocument, d as getAvailableNode, f as getNodeConfig, o as ensureInstalledNodeTypesLoaded, u as ensureRegistryNodeTypesLoaded } from "./use-bare-node-registry-O6mKJO_n.js";
10
+ import { n as storeIconCandidates, t as StoreIcon } from "./store-icon-OctYp5zP.js";
11
+ import { s as isNodeTypeHiddenFromPalette } from "./durable-nodes-BXyYCLxT.js";
12
+ import { _ as usePhaseDFlags } from "./feature-flags-B2qetXKd.js";
13
+ import { u as DeleteWorkflowDefinitionDocument } from "./WorkflowVersionsDocument-DRVOp8Uj.js";
14
+ import { l as findQuotaRefusal } from "./quota-DeA_CJ2e.js";
15
+ import { c as emitWorkflowCreated, n as emitNodeInstalled, o as emitTemplateUsed } from "./fluidgridsEvents-bbEQbwU6.js";
16
+ import { n as InstallWorkflowNodeDocument } from "./global-operations-BG6YgxrM.js";
17
+ import { i as SdkPermissionButton, t as FLUIDGRIDS_PERMISSIONS } from "./constants-DlRnHBfQ.js";
18
+ import { t as useGlobalStoreClient } from "./useGlobalStoreClient-BTdhkA2I.js";
19
+ import { c as templateInstallSource } from "./template-code-CzN6JWNV.js";
20
+ import { n as isPaidTemplate, t as formatTemplatePrice } from "./template-price-CdUHZRMF.js";
21
+ import { Suspense, lazy, useCallback, useContext, useMemo, useState } from "react";
22
+ import { Link } from "react-router";
23
+ import { useQuery } from "@apollo/client/react";
24
+ import { gql } from "@apollo/client/core";
25
+ import { jsx, jsxs } from "react/jsx-runtime";
26
+ import { Sparkles, Star, Workflow } from "lucide-react";
27
+ import { toast } from "sonner";
28
+ import { parsePageParam } from "@burdenoff/fe-libs/ui";
29
+ import { useEventBus } from "@burdenoff/fe-libs/shared/events";
30
+ import { Button as Button$1 } from "@burdenoff/fe-libs/button";
31
+
32
+ // src/generated/documents/global/BrowseWorkflowTemplatesDocument.ts
33
+ const BrowseWorkflowTemplatesDocument = {
34
+ "kind": "Document",
35
+ "definitions": [{
36
+ "kind": "OperationDefinition",
37
+ "operation": "query",
38
+ "name": {
39
+ "kind": "Name",
40
+ "value": "BrowseWorkflowTemplates"
41
+ },
42
+ "variableDefinitions": [{
43
+ "kind": "VariableDefinition",
44
+ "variable": {
45
+ "kind": "Variable",
46
+ "name": {
47
+ "kind": "Name",
48
+ "value": "input"
49
+ }
50
+ },
51
+ "type": {
52
+ "kind": "NonNullType",
53
+ "type": {
54
+ "kind": "NamedType",
55
+ "name": {
56
+ "kind": "Name",
57
+ "value": "BrowseStoreInput"
58
+ }
59
+ }
60
+ },
61
+ "directives": []
62
+ }],
63
+ "directives": [],
64
+ "selectionSet": {
65
+ "kind": "SelectionSet",
66
+ "selections": [{
67
+ "kind": "Field",
68
+ "name": {
69
+ "kind": "Name",
70
+ "value": "browseStore"
71
+ },
72
+ "arguments": [{
73
+ "kind": "Argument",
74
+ "name": {
75
+ "kind": "Name",
76
+ "value": "input"
77
+ },
78
+ "value": {
79
+ "kind": "Variable",
80
+ "name": {
81
+ "kind": "Name",
82
+ "value": "input"
83
+ }
84
+ }
85
+ }],
86
+ "directives": [],
87
+ "selectionSet": {
88
+ "kind": "SelectionSet",
89
+ "selections": [
90
+ {
91
+ "kind": "Field",
92
+ "name": {
93
+ "kind": "Name",
94
+ "value": "products"
95
+ },
96
+ "arguments": [],
97
+ "directives": [],
98
+ "selectionSet": {
99
+ "kind": "SelectionSet",
100
+ "selections": [
101
+ {
102
+ "kind": "Field",
103
+ "name": {
104
+ "kind": "Name",
105
+ "value": "id"
106
+ },
107
+ "arguments": [],
108
+ "directives": []
109
+ },
110
+ {
111
+ "kind": "Field",
112
+ "name": {
113
+ "kind": "Name",
114
+ "value": "name"
115
+ },
116
+ "arguments": [],
117
+ "directives": []
118
+ },
119
+ {
120
+ "kind": "Field",
121
+ "name": {
122
+ "kind": "Name",
123
+ "value": "slug"
124
+ },
125
+ "arguments": [],
126
+ "directives": []
127
+ },
128
+ {
129
+ "kind": "Field",
130
+ "name": {
131
+ "kind": "Name",
132
+ "value": "type"
133
+ },
134
+ "arguments": [],
135
+ "directives": []
136
+ },
137
+ {
138
+ "kind": "Field",
139
+ "name": {
140
+ "kind": "Name",
141
+ "value": "subType"
142
+ },
143
+ "arguments": [],
144
+ "directives": []
145
+ },
146
+ {
147
+ "kind": "Field",
148
+ "name": {
149
+ "kind": "Name",
150
+ "value": "description"
151
+ },
152
+ "arguments": [],
153
+ "directives": []
154
+ },
155
+ {
156
+ "kind": "Field",
157
+ "name": {
158
+ "kind": "Name",
159
+ "value": "longDescription"
160
+ },
161
+ "arguments": [],
162
+ "directives": []
163
+ },
164
+ {
165
+ "kind": "Field",
166
+ "name": {
167
+ "kind": "Name",
168
+ "value": "icon"
169
+ },
170
+ "arguments": [],
171
+ "directives": []
172
+ },
173
+ {
174
+ "kind": "Field",
175
+ "name": {
176
+ "kind": "Name",
177
+ "value": "iconUrl"
178
+ },
179
+ "arguments": [],
180
+ "directives": []
181
+ },
182
+ {
183
+ "kind": "Field",
184
+ "name": {
185
+ "kind": "Name",
186
+ "value": "screenshots"
187
+ },
188
+ "arguments": [],
189
+ "directives": []
190
+ },
191
+ {
192
+ "kind": "Field",
193
+ "name": {
194
+ "kind": "Name",
195
+ "value": "videoUrls"
196
+ },
197
+ "arguments": [],
198
+ "directives": []
199
+ },
200
+ {
201
+ "kind": "Field",
202
+ "name": {
203
+ "kind": "Name",
204
+ "value": "rating"
205
+ },
206
+ "arguments": [],
207
+ "directives": []
208
+ },
209
+ {
210
+ "kind": "Field",
211
+ "name": {
212
+ "kind": "Name",
213
+ "value": "reviewCount"
214
+ },
215
+ "arguments": [],
216
+ "directives": []
217
+ },
218
+ {
219
+ "kind": "Field",
220
+ "name": {
221
+ "kind": "Name",
222
+ "value": "downloads"
223
+ },
224
+ "arguments": [],
225
+ "directives": []
226
+ },
227
+ {
228
+ "kind": "Field",
229
+ "name": {
230
+ "kind": "Name",
231
+ "value": "viewCount"
232
+ },
233
+ "arguments": [],
234
+ "directives": []
235
+ },
236
+ {
237
+ "kind": "Field",
238
+ "name": {
239
+ "kind": "Name",
240
+ "value": "price"
241
+ },
242
+ "arguments": [],
243
+ "directives": []
244
+ },
245
+ {
246
+ "kind": "Field",
247
+ "name": {
248
+ "kind": "Name",
249
+ "value": "pricingModel"
250
+ },
251
+ "arguments": [],
252
+ "directives": []
253
+ },
254
+ {
255
+ "kind": "Field",
256
+ "name": {
257
+ "kind": "Name",
258
+ "value": "currency"
259
+ },
260
+ "arguments": [],
261
+ "directives": []
262
+ },
263
+ {
264
+ "kind": "Field",
265
+ "name": {
266
+ "kind": "Name",
267
+ "value": "featured"
268
+ },
269
+ "arguments": [],
270
+ "directives": []
271
+ },
272
+ {
273
+ "kind": "Field",
274
+ "name": {
275
+ "kind": "Name",
276
+ "value": "manifestVersion"
277
+ },
278
+ "arguments": [],
279
+ "directives": []
280
+ },
281
+ {
282
+ "kind": "Field",
283
+ "name": {
284
+ "kind": "Name",
285
+ "value": "authorName"
286
+ },
287
+ "arguments": [],
288
+ "directives": []
289
+ },
290
+ {
291
+ "kind": "Field",
292
+ "name": {
293
+ "kind": "Name",
294
+ "value": "license"
295
+ },
296
+ "arguments": [],
297
+ "directives": []
298
+ },
299
+ {
300
+ "kind": "Field",
301
+ "name": {
302
+ "kind": "Name",
303
+ "value": "category"
304
+ },
305
+ "arguments": [],
306
+ "directives": []
307
+ },
308
+ {
309
+ "kind": "Field",
310
+ "name": {
311
+ "kind": "Name",
312
+ "value": "tags"
313
+ },
314
+ "arguments": [],
315
+ "directives": []
316
+ },
317
+ {
318
+ "kind": "Field",
319
+ "name": {
320
+ "kind": "Name",
321
+ "value": "compatibleProducts"
322
+ },
323
+ "arguments": [],
324
+ "directives": []
325
+ },
326
+ {
327
+ "kind": "Field",
328
+ "name": {
329
+ "kind": "Name",
330
+ "value": "zipFileUrl"
331
+ },
332
+ "arguments": [],
333
+ "directives": []
334
+ },
335
+ {
336
+ "kind": "Field",
337
+ "name": {
338
+ "kind": "Name",
339
+ "value": "isPurchased"
340
+ },
341
+ "arguments": [],
342
+ "directives": []
343
+ },
344
+ {
345
+ "kind": "Field",
346
+ "name": {
347
+ "kind": "Name",
348
+ "value": "publisher"
349
+ },
350
+ "arguments": [],
351
+ "directives": [],
352
+ "selectionSet": {
353
+ "kind": "SelectionSet",
354
+ "selections": [
355
+ {
356
+ "kind": "Field",
357
+ "name": {
358
+ "kind": "Name",
359
+ "value": "id"
360
+ },
361
+ "arguments": [],
362
+ "directives": []
363
+ },
364
+ {
365
+ "kind": "Field",
366
+ "name": {
367
+ "kind": "Name",
368
+ "value": "name"
369
+ },
370
+ "arguments": [],
371
+ "directives": []
372
+ },
373
+ {
374
+ "kind": "Field",
375
+ "name": {
376
+ "kind": "Name",
377
+ "value": "email"
378
+ },
379
+ "arguments": [],
380
+ "directives": []
381
+ },
382
+ {
383
+ "kind": "Field",
384
+ "name": {
385
+ "kind": "Name",
386
+ "value": "websiteUrl"
387
+ },
388
+ "arguments": [],
389
+ "directives": []
390
+ },
391
+ {
392
+ "kind": "Field",
393
+ "name": {
394
+ "kind": "Name",
395
+ "value": "logoUrl"
396
+ },
397
+ "arguments": [],
398
+ "directives": []
399
+ },
400
+ {
401
+ "kind": "Field",
402
+ "name": {
403
+ "kind": "Name",
404
+ "value": "isVerified"
405
+ },
406
+ "arguments": [],
407
+ "directives": []
408
+ }
409
+ ]
410
+ }
411
+ },
412
+ {
413
+ "kind": "Field",
414
+ "name": {
415
+ "kind": "Name",
416
+ "value": "createdAt"
417
+ },
418
+ "arguments": [],
419
+ "directives": []
420
+ },
421
+ {
422
+ "kind": "Field",
423
+ "name": {
424
+ "kind": "Name",
425
+ "value": "updatedAt"
426
+ },
427
+ "arguments": [],
428
+ "directives": []
429
+ },
430
+ {
431
+ "kind": "Field",
432
+ "name": {
433
+ "kind": "Name",
434
+ "value": "publishedAt"
435
+ },
436
+ "arguments": [],
437
+ "directives": []
438
+ }
439
+ ]
440
+ }
441
+ },
442
+ {
443
+ "kind": "Field",
444
+ "name": {
445
+ "kind": "Name",
446
+ "value": "totalCount"
447
+ },
448
+ "arguments": [],
449
+ "directives": []
450
+ },
451
+ {
452
+ "kind": "Field",
453
+ "name": {
454
+ "kind": "Name",
455
+ "value": "hasMore"
456
+ },
457
+ "arguments": [],
458
+ "directives": []
459
+ },
460
+ {
461
+ "kind": "Field",
462
+ "name": {
463
+ "kind": "Name",
464
+ "value": "nextCursor"
465
+ },
466
+ "arguments": [],
467
+ "directives": []
468
+ }
469
+ ]
470
+ }
471
+ }]
472
+ }
473
+ }]
474
+ };
475
+
476
+ // src/generated/documents/global/StoreNodeProductsByTypeDocument.ts
477
+ const StoreNodeProductsByTypeDocument = {
478
+ "kind": "Document",
479
+ "definitions": [{
480
+ "kind": "OperationDefinition",
481
+ "operation": "query",
482
+ "name": {
483
+ "kind": "Name",
484
+ "value": "StoreNodeProductsByType"
485
+ },
486
+ "variableDefinitions": [{
487
+ "kind": "VariableDefinition",
488
+ "variable": {
489
+ "kind": "Variable",
490
+ "name": {
491
+ "kind": "Name",
492
+ "value": "nodeTypes"
493
+ }
494
+ },
495
+ "type": {
496
+ "kind": "NonNullType",
497
+ "type": {
498
+ "kind": "ListType",
499
+ "type": {
500
+ "kind": "NonNullType",
501
+ "type": {
502
+ "kind": "NamedType",
503
+ "name": {
504
+ "kind": "Name",
505
+ "value": "String"
506
+ }
507
+ }
508
+ }
509
+ }
510
+ },
511
+ "directives": []
512
+ }, {
513
+ "kind": "VariableDefinition",
514
+ "variable": {
515
+ "kind": "Variable",
516
+ "name": {
517
+ "kind": "Name",
518
+ "value": "compatibleWith"
519
+ }
520
+ },
521
+ "type": {
522
+ "kind": "NamedType",
523
+ "name": {
524
+ "kind": "Name",
525
+ "value": "String"
526
+ }
527
+ },
528
+ "directives": []
529
+ }],
530
+ "directives": [],
531
+ "selectionSet": {
532
+ "kind": "SelectionSet",
533
+ "selections": [{
534
+ "kind": "Field",
535
+ "name": {
536
+ "kind": "Name",
537
+ "value": "storeNodeProductsByType"
538
+ },
539
+ "arguments": [{
540
+ "kind": "Argument",
541
+ "name": {
542
+ "kind": "Name",
543
+ "value": "nodeTypes"
544
+ },
545
+ "value": {
546
+ "kind": "Variable",
547
+ "name": {
548
+ "kind": "Name",
549
+ "value": "nodeTypes"
550
+ }
551
+ }
552
+ }, {
553
+ "kind": "Argument",
554
+ "name": {
555
+ "kind": "Name",
556
+ "value": "compatibleWith"
557
+ },
558
+ "value": {
559
+ "kind": "Variable",
560
+ "name": {
561
+ "kind": "Name",
562
+ "value": "compatibleWith"
563
+ }
564
+ }
565
+ }],
566
+ "directives": [],
567
+ "selectionSet": {
568
+ "kind": "SelectionSet",
569
+ "selections": [
570
+ {
571
+ "kind": "Field",
572
+ "name": {
573
+ "kind": "Name",
574
+ "value": "id"
575
+ },
576
+ "arguments": [],
577
+ "directives": []
578
+ },
579
+ {
580
+ "kind": "Field",
581
+ "name": {
582
+ "kind": "Name",
583
+ "value": "productId"
584
+ },
585
+ "arguments": [],
586
+ "directives": []
587
+ },
588
+ {
589
+ "kind": "Field",
590
+ "name": {
591
+ "kind": "Name",
592
+ "value": "name"
593
+ },
594
+ "arguments": [],
595
+ "directives": []
596
+ },
597
+ {
598
+ "kind": "Field",
599
+ "name": {
600
+ "kind": "Name",
601
+ "value": "nodeType"
602
+ },
603
+ "arguments": [],
604
+ "directives": []
605
+ },
606
+ {
607
+ "kind": "Field",
608
+ "name": {
609
+ "kind": "Name",
610
+ "value": "nodeVersion"
611
+ },
612
+ "arguments": [],
613
+ "directives": []
614
+ },
615
+ {
616
+ "kind": "Field",
617
+ "name": {
618
+ "kind": "Name",
619
+ "value": "manifestVersion"
620
+ },
621
+ "arguments": [],
622
+ "directives": []
623
+ },
624
+ {
625
+ "kind": "Field",
626
+ "name": {
627
+ "kind": "Name",
628
+ "value": "pricingModel"
629
+ },
630
+ "arguments": [],
631
+ "directives": []
632
+ },
633
+ {
634
+ "kind": "Field",
635
+ "name": {
636
+ "kind": "Name",
637
+ "value": "downloads"
638
+ },
639
+ "arguments": [],
640
+ "directives": []
641
+ },
642
+ {
643
+ "kind": "Field",
644
+ "name": {
645
+ "kind": "Name",
646
+ "value": "publishedAt"
647
+ },
648
+ "arguments": [],
649
+ "directives": []
650
+ }
651
+ ]
652
+ }
653
+ }]
654
+ }
655
+ }]
656
+ };
657
+
658
+ // src/hooks/store/store-context-headers.ts
659
+ /**
660
+ * Context headers of a store query. The workspace token goes with it as
661
+ * `x-workspace-authorization`: the global gateway ignores a client-sent
662
+ * `x-workspace-id` and derives the workspace from that verified token, and
663
+ * without a workspace the store never lists the nodes a workspace has to opt
664
+ * into, such as the durable-function nodes (BOFF-9905).
665
+ */
666
+ function storeContextHeaders(input) {
667
+ const headers = {};
668
+ if (input.organizationId) headers["x-organization-id"] = input.organizationId;
669
+ if (input.workspaceId) headers["x-workspace-id"] = input.workspaceId;
670
+ if (input.workspaceToken) headers["x-workspace-authorization"] = `Bearer ${input.workspaceToken}`;
671
+ return headers;
672
+ }
673
+
674
+ // src/hooks/store/useInstalledNodes.ts
675
+ /**
676
+ * Hook to get installed nodes for the current workspace
677
+ *
678
+ * Fetches installations from the Store service to show "Already Installed" status
679
+ * in the Store popup and display installed count.
680
+ */
681
+ function useInstalledNodes() {
682
+ const client = useGlobalStoreClient();
683
+ const workspaceId = useContext(FluidGridsContext)?.workspaceId ?? getFluidGridsConfig().workspaceId;
684
+ const { data, loading, error, refetch } = useQuery(GetMyNodeInstallationsDocument, {
685
+ client,
686
+ variables: {
687
+ workspaceId: workspaceId || "",
688
+ limit: 100,
689
+ offset: 0
690
+ },
691
+ skip: !workspaceId,
692
+ fetchPolicy: "cache-and-network"
693
+ });
694
+ const installations = data?.myStoreAppInstallations?.items || [];
695
+ const activeInstallations = installations.filter((item) => item.status === "ACTIVE");
696
+ return {
697
+ installations,
698
+ installedAppIds: new Set(activeInstallations.map((item) => item.productId)),
699
+ installationsMap: new Map(activeInstallations.map((item) => [item.productId, {
700
+ installedVersion: item.version ?? void 0,
701
+ installationId: item.id,
702
+ installedAt: item.installedAt
703
+ }])),
704
+ deprecatedInstallations: activeInstallations.filter((item) => item.productStatus === "UNLISTED"),
705
+ installedNodeTypes: /* @__PURE__ */ new Set(),
706
+ totalCount: data?.myStoreAppInstallations?.total || 0,
707
+ loading,
708
+ error,
709
+ refetch
710
+ };
711
+ }
712
+
713
+ // src/builder/components/flow-builder/components/store/store-node-availability.ts
714
+ /**
715
+ * Operations a user may actually pick for a node type: adapter operations
716
+ * (supplyModel/supplyTool/…) and `internal` ones (the AI Agent's planStep) are
717
+ * executor plumbing, chosen automatically, and must not count as user choices.
718
+ */
719
+ function userSelectableOperationCount(nodeType) {
720
+ if (!nodeType) return 0;
721
+ return (getNodeConfig(nodeType)?.operations ?? []).filter((op) => !op.isAdapterOperation && !op.internal).length;
722
+ }
723
+ /**
724
+ * Resolve the workflow node type for a store node.
725
+ *
726
+ * Installed nodes can fall back to the historical slug-based type when older
727
+ * manifests did not yet include `manifest.nodeType`.
728
+ */
729
+ function getStoreNodeType(node, isInstalled) {
730
+ const listedNodeType = node.nodeType?.trim();
731
+ if (listedNodeType) return listedNodeType;
732
+ return node.manifest?.nodeType ?? (isInstalled ? `store/${node.slug}` : void 0);
733
+ }
734
+ /**
735
+ * A node is considered prebuilt when it is already present in the workflow
736
+ * registry/available nodes list even though the workspace does not have a store
737
+ * installation record for it.
738
+ */
739
+ function getStoreNodeAvailability(node, isInstalled, options = {}) {
740
+ const nodeType = getStoreNodeType(node, isInstalled);
741
+ if (isNodeTypeHiddenFromPalette(nodeType, options.durableFunctionsEnabled)) return {
742
+ nodeType,
743
+ isPrebuilt: false,
744
+ isDraggable: false,
745
+ isHidden: true
746
+ };
747
+ const isInternalBuiltin = !!nodeType && nodeType.startsWith("internal:");
748
+ const registered = getAvailableNode(nodeType);
749
+ const isRegistryBacked = !!registered && (registered.publishType === "BUILTIN" || registered.publishType === void 0);
750
+ const isPrebuilt = !isInstalled && (isInternalBuiltin || isRegistryBacked);
751
+ return {
752
+ nodeType,
753
+ isPrebuilt,
754
+ isDraggable: !!nodeType && (isInstalled || isPrebuilt) && userSelectableOperationCount(nodeType) <= 1,
755
+ isHidden: false
756
+ };
757
+ }
758
+ /**
759
+ * The icon the registry carries for a node type, from the node's manifest.
760
+ *
761
+ * Listings for the built-in nodes are seeded without an icon, so every one of
762
+ * them rendered as a letter tile in the Node Store while the canvas showed the
763
+ * node's real icon (BOFF-7651). A listing without its own icon falls back to
764
+ * this one.
765
+ */
766
+ function registeredNodeIcon(nodeType) {
767
+ if (!nodeType) return null;
768
+ return getAvailableNode(nodeType)?.icon || null;
769
+ }
770
+ /**
771
+ * Every icon a store listing can show, best first: the store's
772
+ * browser-ready `iconUrl`, then the raw listing `icon`, then the icon the
773
+ * node registers in its manifest. The icon component walks this list when an
774
+ * image fails to load, ending at the caller's letter tile, so an expired
775
+ * presigned link or a dead third-party URL never shows a broken image.
776
+ *
777
+ * The store listings draw these offline (see `StoreIcon`): a raw name is only
778
+ * drawn when it is in the bundled set, and otherwise the letter tile is shown
779
+ * instead of a request to the Iconify API. The store renders a listing's own
780
+ * icon into `iconUrl`; built-in listings have no icon, so they rely on the
781
+ * manifest icon, and every built-in manifest name is bundled (see
782
+ * `src/icons/builtin-node-icons.ts`).
783
+ */
784
+ function storeNodeIconCandidates(listing, nodeType) {
785
+ return storeIconCandidates([
786
+ listing.iconUrl,
787
+ listing.icon,
788
+ registeredNodeIcon(nodeType)
789
+ ]);
790
+ }
791
+ /**
792
+ * The version to show for a store node: the node's own version from its
793
+ * manifest (`nodeVersion`, then `identity.version`), falling back to the
794
+ * product's `manifestVersion`. The product field is usually the manifest
795
+ * *format* version ("1.0"), so showing it read as "v1.0" for every node
796
+ * (BOFF-11456).
797
+ */
798
+ function storeNodeDisplayVersion(manifest, manifestVersion) {
799
+ const record = typeof manifest === "string" ? parseManifest(manifest) : manifest;
800
+ if (typeof record === "object" && record !== null) {
801
+ const { nodeVersion, identity } = record;
802
+ if (typeof nodeVersion === "string" && nodeVersion.trim()) return nodeVersion.trim();
803
+ const identityVersion = identity?.version;
804
+ if (typeof identityVersion === "string" && identityVersion.trim()) return identityVersion.trim();
805
+ }
806
+ return manifestVersion?.trim() || void 0;
807
+ }
808
+ const MAJOR_MINOR_ONLY = /^\d+\.\d+$/;
809
+ /**
810
+ * Node versions are full semver: node images are tagged `major.minor.patch`
811
+ * and the sandbox picks one by the exact version a workflow node pins. A bare
812
+ * `major.minor` (the manifest format version, "1.0") therefore means
813
+ * `major.minor.0` (BOFF-11496). Other values come back trimmed.
814
+ */
815
+ function canonicalNodeVersion(version) {
816
+ const trimmed = version.trim();
817
+ return MAJOR_MINOR_ONLY.test(trimmed) ? `${trimmed}.0` : trimmed;
818
+ }
819
+ /**
820
+ * The version to show for a store listing: the store's `nodeVersion`, else the
821
+ * version in a full manifest, else the product's `manifestVersion` (see
822
+ * storeNodeDisplayVersion).
823
+ */
824
+ function storeProductDisplayVersion(product) {
825
+ const listed = product.nodeVersion?.trim();
826
+ if (listed) return listed;
827
+ return storeNodeDisplayVersion(product.manifest, product.manifestVersion);
828
+ }
829
+ /** The version a store listing installs as (see storeNodeInstallVersion). */
830
+ function storeProductInstallVersion(product) {
831
+ return canonicalNodeVersion(storeProductDisplayVersion(product) ?? "1.0.0");
832
+ }
833
+ /**
834
+ * Whether an installed store node has a newer version than the listing (see
835
+ * isStoreNodeUpdateAvailable).
836
+ */
837
+ function isStoreProductUpdateAvailable(installedVersion, product) {
838
+ if (!installedVersion?.trim()) return false;
839
+ const latest = storeProductDisplayVersion(product);
840
+ if (!latest) return false;
841
+ return canonicalNodeVersion(installedVersion) !== canonicalNodeVersion(latest);
842
+ }
843
+ function parseManifest(text) {
844
+ try {
845
+ return JSON.parse(text);
846
+ } catch {
847
+ return;
848
+ }
849
+ }
850
+ /**
851
+ * Whether a store product must be left out of the builder's store listings
852
+ * because it is a gated node (durable-function or run-control) whose flag is
853
+ * off.
854
+ * Fails closed when `durableFunctionsEnabled` is omitted.
855
+ */
856
+ function isStoreNodeHiddenFromPalette(node, durableFunctionsEnabled = false) {
857
+ return isNodeTypeHiddenFromPalette(getStoreNodeType(node, false), durableFunctionsEnabled);
858
+ }
859
+ /**
860
+ * Drops the store products that must stay hidden from the builder. Returns
861
+ * the input array itself when nothing is hidden.
862
+ */
863
+ function filterStoreNodesForPalette(nodes, durableFunctionsEnabled = false) {
864
+ const hidden = (node) => isStoreNodeHiddenFromPalette(node, durableFunctionsEnabled);
865
+ if (!nodes.some(hidden)) return nodes;
866
+ return nodes.filter((node) => !hidden(node));
867
+ }
868
+
869
+ // src/hooks/store/useWorkflowTemplates.ts
870
+ /**
871
+ * Hook to browse workflow templates from the Store
872
+ *
873
+ * Fetches WORKFLOW type products from the global store service
874
+ * with rich preview data (screenshots, videos, etc.)
875
+ *
876
+ * @param searchTerm - Optional search query
877
+ * @param limit - Number of templates per page (default: 20)
878
+ * @param enabled - Whether to enable the query (default: true). Set to false to skip the query.
879
+ * @param category - Optional store category to filter by (exact match)
880
+ */
881
+ function useWorkflowTemplates(searchTerm, limit = 20, enabled = true, category) {
882
+ const client = useGlobalStoreClient();
883
+ const context = useContext(FluidGridsContext);
884
+ const workspaceId = context?.workspaceId ?? getFluidGridsConfig().workspaceId;
885
+ const organizationId = context?.organizationId;
886
+ const contextHeaders = useMemo(() => {
887
+ const headers = {};
888
+ if (organizationId) headers["x-organization-id"] = organizationId;
889
+ if (workspaceId) headers["x-workspace-id"] = workspaceId;
890
+ return headers;
891
+ }, [organizationId, workspaceId]);
892
+ const buildVariables = (offset) => ({ input: {
893
+ filter: {
894
+ type: "WORKFLOW",
895
+ status: "PUBLISHED",
896
+ search: searchTerm,
897
+ ...category ? { category } : {}
898
+ },
899
+ pagination: {
900
+ limit,
901
+ offset
902
+ },
903
+ sortBy: searchTerm ? "RELEVANCE" : "NEWEST"
904
+ } });
905
+ const { data, loading, error, fetchMore, refetch } = useQuery(BrowseWorkflowTemplatesDocument, {
906
+ client,
907
+ variables: buildVariables(0),
908
+ fetchPolicy: "cache-and-network",
909
+ skip: !enabled,
910
+ context: Object.keys(contextHeaders).length > 0 ? { headers: contextHeaders } : void 0
911
+ });
912
+ const templates = data?.browseStore?.products || [];
913
+ const totalCount = data?.browseStore?.totalCount || 0;
914
+ const hasMore = data?.browseStore?.hasMore || false;
915
+ const loadMore = () => {
916
+ if (!hasMore || loading) return;
917
+ return fetchMore({
918
+ variables: buildVariables(templates.length),
919
+ context: Object.keys(contextHeaders).length > 0 ? { headers: contextHeaders } : void 0,
920
+ updateQuery: (prev, { fetchMoreResult }) => {
921
+ if (!fetchMoreResult) return prev;
922
+ return { browseStore: {
923
+ ...fetchMoreResult.browseStore,
924
+ products: [...prev.browseStore?.products || [], ...fetchMoreResult.browseStore?.products || []]
925
+ } };
926
+ }
927
+ });
928
+ };
929
+ return {
930
+ templates,
931
+ totalCount,
932
+ hasMore,
933
+ loading,
934
+ error,
935
+ loadMore,
936
+ refetch
937
+ };
938
+ }
939
+
940
+ // src/hooks/store/useTemplateDetail.ts
941
+ const GET_WORKFLOW_TEMPLATE_DETAIL = gql`
942
+ query GetWorkflowTemplateDetail($id: ID!) {
943
+ product(id: $id) {
944
+ id
945
+ name
946
+ slug
947
+ type
948
+ description
949
+ longDescription
950
+ icon
951
+ screenshots
952
+ videoUrls
953
+ rating
954
+ reviewCount
955
+ downloads
956
+ viewCount
957
+ price
958
+ pricingModel
959
+ currency
960
+ featured
961
+ content
962
+ manifest
963
+ manifestVersion
964
+ authorName
965
+ license
966
+ category
967
+ tags
968
+ compatibleProducts
969
+ publisher {
970
+ id
971
+ name
972
+ email
973
+ websiteUrl
974
+ logoUrl
975
+ isVerified
976
+ }
977
+ createdAt
978
+ updatedAt
979
+ publishedAt
980
+ }
981
+ }
982
+ `;
983
+ /**
984
+ * Hook to lazily fetch full details of a workflow template from the store.
985
+ *
986
+ * Unlike `useWorkflowTemplates` which fetches browse-level metadata,
987
+ * this hook fetches the full product detail including the `content` field
988
+ * which contains the workflow definitionJson.
989
+ *
990
+ * Uses a manual query (not useQuery) to only fetch when explicitly requested.
991
+ */
992
+ function useTemplateDetail() {
993
+ const client = useGlobalStoreClient();
994
+ const [loading, setLoading] = useState(false);
995
+ const [error, setError] = useState(null);
996
+ const context = useContext(FluidGridsContext);
997
+ const workspaceId = context?.workspaceId ?? getFluidGridsConfig().workspaceId;
998
+ const organizationId = context?.organizationId;
999
+ const contextHeaders = useMemo(() => {
1000
+ const headers = {};
1001
+ if (organizationId) headers["x-organization-id"] = organizationId;
1002
+ if (workspaceId) headers["x-workspace-id"] = workspaceId;
1003
+ return headers;
1004
+ }, [organizationId, workspaceId]);
1005
+ return {
1006
+ fetchTemplateDetail: useCallback(async (templateId) => {
1007
+ setLoading(true);
1008
+ setError(null);
1009
+ try {
1010
+ const result = await client.query({
1011
+ query: GET_WORKFLOW_TEMPLATE_DETAIL,
1012
+ variables: { id: templateId },
1013
+ fetchPolicy: "network-only",
1014
+ context: Object.keys(contextHeaders).length > 0 ? { headers: contextHeaders } : void 0
1015
+ });
1016
+ if (result.error) throw result.error;
1017
+ return result.data?.product ?? null;
1018
+ } catch (err) {
1019
+ const fetchError = err instanceof Error ? err : /* @__PURE__ */ new Error("Failed to fetch template detail");
1020
+ setError(fetchError);
1021
+ console.error("[useTemplateDetail] Error:", err);
1022
+ return null;
1023
+ } finally {
1024
+ setLoading(false);
1025
+ }
1026
+ }, [client, contextHeaders]),
1027
+ loading,
1028
+ error
1029
+ };
1030
+ }
1031
+
1032
+ // src/utils/template-input-applicator.ts
1033
+ /**
1034
+ * Template Input Applicator
1035
+ *
1036
+ * Walks a workflow definitionJson and replaces ${variableName} placeholders
1037
+ * with user-provided values. Used during template import to apply
1038
+ * user-configurable inputs before creating the workflow.
1039
+ */
1040
+ /**
1041
+ * Deep-clone an object using structured clone.
1042
+ * Falls back to JSON parse/stringify for environments without structuredClone.
1043
+ */
1044
+ function deepClone(obj) {
1045
+ if (typeof structuredClone === "function") return structuredClone(obj);
1046
+ return JSON.parse(JSON.stringify(obj));
1047
+ }
1048
+ /**
1049
+ * Apply template input values to a definitionJson by replacing
1050
+ * ${variableName} placeholders in string values throughout the object tree.
1051
+ *
1052
+ * @param definitionJson - The workflow definition JSON to process
1053
+ * @param inputs - Map of variable names to user-provided values
1054
+ * @returns A new definitionJson with placeholders replaced
1055
+ *
1056
+ * @example
1057
+ * ```ts
1058
+ * const definition = {
1059
+ * nodes: [{
1060
+ * data: { url: "${slack_webhook_url}", message: "Hello ${name}" }
1061
+ * }]
1062
+ * };
1063
+ * const result = applyTemplateInputs(definition, {
1064
+ * slack_webhook_url: "https://hooks.slack.com/...",
1065
+ * name: "World"
1066
+ * });
1067
+ * // result.nodes[0].data.url === "https://hooks.slack.com/..."
1068
+ * // result.nodes[0].data.message === "Hello World"
1069
+ * ```
1070
+ */
1071
+ function applyTemplateInputs(definitionJson, inputs) {
1072
+ if (!inputs || Object.keys(inputs).length === 0) return definitionJson;
1073
+ return walkAndReplace(deepClone(definitionJson), inputs);
1074
+ }
1075
+ /**
1076
+ * Recursively walk an object/array and replace ${variableName} placeholders
1077
+ * in string values.
1078
+ */
1079
+ function walkAndReplace(obj, inputs) {
1080
+ if (typeof obj === "string") return replaceVariables(obj, inputs);
1081
+ if (Array.isArray(obj)) return obj.map((item) => walkAndReplace(item, inputs));
1082
+ if (obj !== null && typeof obj === "object") {
1083
+ const result = {};
1084
+ for (const [key, value] of Object.entries(obj)) result[key] = walkAndReplace(value, inputs);
1085
+ return result;
1086
+ }
1087
+ return obj;
1088
+ }
1089
+ /**
1090
+ * Replace ${variableName} patterns in a string with provided values.
1091
+ *
1092
+ * Supports:
1093
+ * - ${variableName} — standard replacement
1094
+ * - ${variableName || 'default'} — fallback to default if variable not provided
1095
+ */
1096
+ function replaceVariables(str, inputs) {
1097
+ return str.replace(/\$\{([^}]+)\}/g, (_match, expression) => {
1098
+ const trimmed = expression.trim();
1099
+ const fallbackMatch = trimmed.match(/^(\w+)\s*\|\|\s*['"]?(.+?)['"]?$/);
1100
+ if (fallbackMatch) {
1101
+ const varName = fallbackMatch[1];
1102
+ const fallback = fallbackMatch[2];
1103
+ if (varName in inputs) return String(inputs[varName]);
1104
+ return fallback;
1105
+ }
1106
+ if (trimmed in inputs) return String(inputs[trimmed]);
1107
+ return _match;
1108
+ });
1109
+ }
1110
+
1111
+ // src/utils/template-import-flow.ts
1112
+ function isRecord(value) {
1113
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1114
+ }
1115
+ function graphOf(value) {
1116
+ if (!Array.isArray(value.nodes)) return null;
1117
+ return {
1118
+ nodes: value.nodes,
1119
+ edges: Array.isArray(value.edges) ? value.edges : [],
1120
+ name: typeof value.name === "string" ? value.name : void 0
1121
+ };
1122
+ }
1123
+ /**
1124
+ * The canvas of a WORKFLOW product that keeps it in its manifest instead of
1125
+ * `content.definitionJson`: either a flat `{ nodes, edges }` manifest, or the
1126
+ * Store Listing JSON editor's `manifest.jsonContent` string. Null when the
1127
+ * manifest holds neither.
1128
+ */
1129
+ function manifestTemplateGraph(manifest) {
1130
+ if (!isRecord(manifest)) return null;
1131
+ const direct = graphOf(manifest);
1132
+ if (direct) return direct;
1133
+ if (typeof manifest.jsonContent !== "string") return null;
1134
+ try {
1135
+ const parsed = JSON.parse(manifest.jsonContent);
1136
+ return isRecord(parsed) ? graphOf(parsed) : null;
1137
+ } catch {
1138
+ return null;
1139
+ }
1140
+ }
1141
+ /**
1142
+ * The template content a product carries: `content` when it holds a
1143
+ * `definitionJson`, otherwise a content built from the manifest's canvas,
1144
+ * with its required nodes worked out by `requiredNodeTypesOf` (a failed
1145
+ * lookup leaves them empty, which skips the node check). Null when the
1146
+ * product has no workflow at all.
1147
+ */
1148
+ async function resolveTemplateContent(product, requiredNodeTypesOf) {
1149
+ const content = product.content;
1150
+ if (content?.definitionJson) return content;
1151
+ const graph = manifestTemplateGraph(product.manifest);
1152
+ if (!graph) return null;
1153
+ let requiredNodeTypes = [];
1154
+ try {
1155
+ requiredNodeTypes = await requiredNodeTypesOf(graph.nodes);
1156
+ } catch {
1157
+ requiredNodeTypes = [];
1158
+ }
1159
+ return {
1160
+ definitionJson: {
1161
+ nodes: graph.nodes,
1162
+ edges: graph.edges
1163
+ },
1164
+ requiredNodeTypes,
1165
+ defaultWorkflowName: graph.name ?? product.name
1166
+ };
1167
+ }
1168
+ /**
1169
+ * The canvas to create a copy from. Some templates store a whole API
1170
+ * response as their definition (`{ data: { workflowDefinition: {
1171
+ * definitionJson } } }`); the canvas is the inner `definitionJson`.
1172
+ */
1173
+ function unwrapTemplateDefinition(definitionJson) {
1174
+ const data = definitionJson.data;
1175
+ if (!isRecord(data)) return definitionJson;
1176
+ const nested = isRecord(data.workflowDefinition) ? data.workflowDefinition.definitionJson : void 0;
1177
+ return isRecord(nested) ? nested : definitionJson;
1178
+ }
1179
+ /**
1180
+ * Whether "Use this template" must stop at the configuration dialog before
1181
+ * creating the copy: the template asks for inputs or connections, or one of
1182
+ * its nodes is not installed (free to install, paid, or not offered by the
1183
+ * store at all).
1184
+ */
1185
+ function needsTemplateConfiguration(content, nodeCheck) {
1186
+ return (content.requiredInputs?.length ?? 0) > 0 || (content.requiredCredentialTypes?.length ?? 0) > 0 || nodeCheck.missing.length > 0 || nodeCheck.missingPaid.length > 0 || (nodeCheck.unavailable?.length ?? 0) > 0 || (nodeCheck.needsUpdate?.length ?? 0) > 0;
1187
+ }
1188
+ /**
1189
+ * The free nodes to install before the copy is created: the missing ones and
1190
+ * the ones installed in an older version than the template needs (installing
1191
+ * the required version updates them, BOFF-12017).
1192
+ */
1193
+ function nodesToInstall(nodeCheck) {
1194
+ return [...nodeCheck?.missing ?? [], ...nodeCheck?.needsUpdate ?? []].filter((node) => !!node.storeProductId);
1195
+ }
1196
+ /**
1197
+ * Install nodes one at a time, in order, reporting progress before each.
1198
+ * One at a time on purpose: the dialog shows "installing i of n", and every
1199
+ * install writes the same workspace's installation records in the store.
1200
+ * A failed install is reported to `onFailure` and the rest still run, so the
1201
+ * copy can be created; the user installs the node later from the Node Store.
1202
+ * Resolves to the node types that installed.
1203
+ */
1204
+ async function installNodesInOrder(nodes, install, onProgress, onFailure) {
1205
+ const installed = [];
1206
+ await nodes.reduce((previous, node, index) => previous.then(async () => {
1207
+ onProgress({
1208
+ current: index + 1,
1209
+ total: nodes.length,
1210
+ nodeName: node.displayName || node.nodeType
1211
+ });
1212
+ try {
1213
+ await install(node);
1214
+ installed.push(node.nodeType);
1215
+ } catch (error) {
1216
+ onFailure(node, error);
1217
+ }
1218
+ }), Promise.resolve());
1219
+ return installed;
1220
+ }
1221
+
1222
+ // src/utils/template-companions.ts
1223
+ const REF_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
1224
+ /**
1225
+ * The companions of a template, checked: every ref a placeholder name, used once, and not one of
1226
+ * the template's own input names (the input would silently replace the companion's key).
1227
+ */
1228
+ function templateCompanions(content) {
1229
+ const companions = content.companionWorkflows ?? [];
1230
+ const inputNames = new Set((content.requiredInputs ?? []).map((input) => input.name));
1231
+ const seen = /* @__PURE__ */ new Set();
1232
+ for (const companion of companions) {
1233
+ if (!REF_PATTERN.test(companion.ref)) throw new Error(`The template's workflow "${companion.name}" has an invalid reference "${companion.ref}"`);
1234
+ if (seen.has(companion.ref) || inputNames.has(companion.ref)) throw new Error(`The template uses the reference "${companion.ref}" more than once`);
1235
+ if (!companion.definitionJson) throw new Error(`The template's workflow "${companion.name}" has no definition`);
1236
+ seen.add(companion.ref);
1237
+ }
1238
+ return companions;
1239
+ }
1240
+ /** A definition with the user's inputs and the companions created so far filled in. */
1241
+ function withTemplateValues(definition, inputs, companionKeys) {
1242
+ return applyTemplateInputs(definition, {
1243
+ ...inputs ?? {},
1244
+ ...companionKeys
1245
+ });
1246
+ }
1247
+ /** The name a companion is created under: the main workflow's name says which import it is from. */
1248
+ function companionWorkflowName(mainName, companion) {
1249
+ return `${mainName}: ${companion.name}`;
1250
+ }
1251
+ /**
1252
+ * Create a template's workflows: its companions first, in order, then its own workflow with every
1253
+ * `${ref}` replaced by the key of the companion created for it. When any of them fails, the
1254
+ * companions already created are removed (best effort) and the error is thrown, so a failed
1255
+ * import leaves nothing behind.
1256
+ */
1257
+ async function createTemplateWorkflows(params) {
1258
+ const companionKeys = {};
1259
+ const created = [];
1260
+ try {
1261
+ for (const companion of params.companions) {
1262
+ const { workflow } = await params.create({
1263
+ definitionJson: withTemplateValues(unwrapTemplateDefinition(deepClone(companion.definitionJson)), params.templateInputs, companionKeys),
1264
+ name: companionWorkflowName(params.mainName, companion),
1265
+ description: companion.description,
1266
+ main: false
1267
+ });
1268
+ companionKeys[companion.ref] = workflow.workflowKey;
1269
+ created.push(workflow.workflowKey);
1270
+ }
1271
+ return {
1272
+ ...await params.create({
1273
+ ...params.mainDefinition ? { definitionJson: withTemplateValues(params.mainDefinition, void 0, companionKeys) } : {},
1274
+ name: params.mainName,
1275
+ description: params.mainDescription,
1276
+ main: true
1277
+ }),
1278
+ companionKeys
1279
+ };
1280
+ } catch (error) {
1281
+ for (const workflowKey of created) try {
1282
+ await params.remove(workflowKey);
1283
+ } catch (removeError) {
1284
+ params.onRemoveFailed?.(workflowKey, removeError);
1285
+ }
1286
+ throw error;
1287
+ }
1288
+ }
1289
+ /**
1290
+ * The workflow an `importWorkflowTemplate` mutation result created. Throws with the service's
1291
+ * message when it created none.
1292
+ */
1293
+ function importedWorkflowOf(data) {
1294
+ const imported = data?.importWorkflowTemplate;
1295
+ if (!imported?.success || !imported.workflow) throw new Error(imported?.message || "Failed to create workflow from template");
1296
+ return {
1297
+ workflow: imported.workflow,
1298
+ ...imported.message ? { message: imported.message } : {}
1299
+ };
1300
+ }
1301
+
1302
+ // src/hooks/store/useImportWorkflowTemplate.ts
1303
+ const IMPORT_WORKFLOW_TEMPLATE = gql`
1304
+ mutation ImportWorkflowTemplate($input: ImportWorkflowTemplateInput!) {
1305
+ importWorkflowTemplate(input: $input) {
1306
+ success
1307
+ message
1308
+ workflow {
1309
+ id
1310
+ workflowKey
1311
+ version
1312
+ name
1313
+ description
1314
+ status
1315
+ definitionJson
1316
+ tags
1317
+ category
1318
+ icon
1319
+ createdAt
1320
+ }
1321
+ }
1322
+ }
1323
+ `;
1324
+ const RECORD_DOWNLOAD = gql`
1325
+ mutation RecordDownload($productId: String!) {
1326
+ recordDownload(productId: $productId) {
1327
+ id
1328
+ downloadedAt
1329
+ }
1330
+ }
1331
+ `;
1332
+ const WORKFLOW_DEFINITIONS = gql`
1333
+ query WorkflowDefinitions($input: ListWorkflowDefinitionsInput!) {
1334
+ workflowDefinitions(input: $input) {
1335
+ items {
1336
+ id
1337
+ workflowKey
1338
+ name
1339
+ version
1340
+ status
1341
+ }
1342
+ total
1343
+ hasMore
1344
+ }
1345
+ }
1346
+ `;
1347
+ /**
1348
+ * Hook to orchestrate importing a workflow template from the store.
1349
+ *
1350
+ * It fetches template detail, parses content and creates the copy:
1351
+ * 1. Fetch full template detail from global store (lazy load content)
1352
+ * 2. Apply user-provided template inputs to definitionJson
1353
+ * 3. Create workflow via importWorkflowTemplate mutation (workspace gateway)
1354
+ * 4. Record the download and the installation in the store
1355
+ *
1356
+ * The node check, the configuration dialog and installing missing nodes are
1357
+ * done by `useTemplateImportFlow`, which every "Use this template" button
1358
+ * goes through (BOFF-11153).
1359
+ */
1360
+ function useImportWorkflowTemplate() {
1361
+ const [importing, setImporting] = useState(false);
1362
+ const [error, setError] = useState(null);
1363
+ const { fetchTemplateDetail, loading: fetchingDetail } = useTemplateDetail();
1364
+ const globalClient = useGlobalStoreClient();
1365
+ const context = useContext(FluidGridsContext);
1366
+ const workspaceId = context?.workspaceId ?? getFluidGridsConfig().workspaceId;
1367
+ const bus = useEventBus();
1368
+ const { codeTemplatesDurable } = usePhaseDFlags();
1369
+ const getTemplateDetail = useCallback(async (templateId) => {
1370
+ return fetchTemplateDetail(templateId);
1371
+ }, [fetchTemplateDetail]);
1372
+ /**
1373
+ * Parse the template content from a StoreProduct.
1374
+ * Returns null if the product doesn't have valid workflow template content.
1375
+ */
1376
+ const parseTemplateContent = useCallback((template) => {
1377
+ try {
1378
+ const content = template.content;
1379
+ if (!content?.definitionJson) {
1380
+ console.warn("[useImportWorkflowTemplate] Template has no definitionJson in content:", template.id);
1381
+ return null;
1382
+ }
1383
+ return content;
1384
+ } catch {
1385
+ console.error("[useImportWorkflowTemplate] Failed to parse template content:", template.id);
1386
+ return null;
1387
+ }
1388
+ }, []);
1389
+ return {
1390
+ /** Fetch full template content from store (lazy load) */
1391
+ getTemplateDetail,
1392
+ /** Parse WorkflowTemplateContent from a StoreProduct */
1393
+ parseTemplateContent,
1394
+ /** Full import: apply inputs -> create workflow -> record analytics */
1395
+ importTemplate: useCallback(async (template, options) => {
1396
+ setImporting(true);
1397
+ setError(null);
1398
+ try {
1399
+ const content = options?.content ?? parseTemplateContent(template);
1400
+ if (!content) throw new Error("Template does not contain valid workflow definition data");
1401
+ const installSource = templateInstallSource(content, codeTemplatesDurable);
1402
+ let definitionJson = unwrapTemplateDefinition(deepClone(content.definitionJson));
1403
+ if (options?.templateInputs && !installSource) definitionJson = applyTemplateInputs(definitionJson, options.templateInputs);
1404
+ const config = getFluidGridsConfig();
1405
+ const importContext = {
1406
+ ...options?.context || {},
1407
+ ...config.productId ? { productId: config.productId } : {},
1408
+ ...config.productName ? { productName: config.productName } : {}
1409
+ };
1410
+ const workflowName = options?.name || content.defaultWorkflowName || template.name;
1411
+ const tags = content.defaultTags || template.tags || [];
1412
+ const category = content.defaultCategory || template.category || void 0;
1413
+ const client = getFluidGridsClient();
1414
+ const importResult = await createTemplateWorkflows({
1415
+ companions: installSource ? [] : templateCompanions(content),
1416
+ mainDefinition: installSource ? null : definitionJson,
1417
+ mainName: workflowName,
1418
+ mainDescription: options?.description || template.description,
1419
+ templateInputs: options?.templateInputs,
1420
+ create: async (input) => importedWorkflowOf(throwIfResultError(await client.mutate({
1421
+ mutation: IMPORT_WORKFLOW_TEMPLATE,
1422
+ variables: { input: {
1423
+ ...input.definitionJson ? { definitionJson: input.definitionJson } : { source: installSource },
1424
+ name: input.name,
1425
+ description: input.description,
1426
+ sourceTemplateId: template.id,
1427
+ sourceTemplateName: template.name,
1428
+ tags,
1429
+ category,
1430
+ icon: template.icon || void 0,
1431
+ projectId: options?.projectId,
1432
+ context: importContext
1433
+ } },
1434
+ ...input.main ? { refetchQueries: [WORKFLOW_DEFINITIONS] } : {}
1435
+ })).data),
1436
+ remove: async (workflowKey) => {
1437
+ throwIfResultError(await client.mutate({
1438
+ mutation: DeleteWorkflowDefinitionDocument,
1439
+ variables: { workflowKey }
1440
+ }));
1441
+ },
1442
+ onRemoveFailed: (workflowKey) => console.warn("[useImportWorkflowTemplate] Could not remove a workflow of the failed import:", workflowKey)
1443
+ });
1444
+ definitionJson = withTemplateValues(definitionJson, void 0, importResult.companionKeys);
1445
+ let installRecorded = false;
1446
+ try {
1447
+ throwIfResultError(await globalClient.mutate({
1448
+ mutation: InstallWorkflowNodeDocument,
1449
+ variables: { input: {
1450
+ productId: template.id,
1451
+ workspaceId,
1452
+ organizationId: context?.tenantId ?? getFluidGridsConfig().tenantId,
1453
+ version: template.manifestVersion || "1.0.0",
1454
+ manifest: template.manifest,
1455
+ metadata: {
1456
+ type: "WORKFLOW",
1457
+ sourceTemplateId: template.id,
1458
+ sourceTemplateName: template.name,
1459
+ importedWorkflowKey: importResult.workflow.workflowKey,
1460
+ importedWorkflowVersion: importResult.workflow.version
1461
+ }
1462
+ } }
1463
+ }));
1464
+ installRecorded = true;
1465
+ } catch {
1466
+ console.warn("[useImportWorkflowTemplate] Failed to record app installation");
1467
+ }
1468
+ if (!installRecorded) try {
1469
+ throwIfResultError(await globalClient.mutate({
1470
+ mutation: RECORD_DOWNLOAD,
1471
+ variables: { productId: template.id }
1472
+ }));
1473
+ } catch {
1474
+ console.warn("[useImportWorkflowTemplate] Failed to record store download");
1475
+ }
1476
+ emitWorkflowCreated(bus, {
1477
+ workspaceId,
1478
+ workflowId: importResult.workflow.id,
1479
+ source: "template",
1480
+ definition: installSource ? importResult.workflow.definitionJson : definitionJson
1481
+ });
1482
+ emitTemplateUsed(bus, {
1483
+ workspaceId,
1484
+ templateId: template.id,
1485
+ category: content.defaultCategory || template.category
1486
+ });
1487
+ return {
1488
+ success: true,
1489
+ workflow: importResult.workflow,
1490
+ companionWorkflowKeys: importResult.companionKeys,
1491
+ message: importResult.message || "Template imported successfully",
1492
+ installedNodes: [],
1493
+ requiredCredentials: content.requiredCredentialTypes || []
1494
+ };
1495
+ } catch (err) {
1496
+ const importError = err instanceof Error ? err : /* @__PURE__ */ new Error("Template import failed");
1497
+ const message = describeOperationError(err, importError.message);
1498
+ setError(importError);
1499
+ console.error("[useImportWorkflowTemplate] Import failed:", err);
1500
+ return {
1501
+ success: false,
1502
+ workflow: null,
1503
+ message,
1504
+ installedNodes: [],
1505
+ requiredCredentials: [],
1506
+ error: importError
1507
+ };
1508
+ } finally {
1509
+ setImporting(false);
1510
+ }
1511
+ }, [
1512
+ parseTemplateContent,
1513
+ globalClient,
1514
+ workspaceId,
1515
+ context?.tenantId,
1516
+ bus,
1517
+ codeTemplatesDurable
1518
+ ]),
1519
+ /** Whether we're fetching template detail */
1520
+ fetchingDetail,
1521
+ /** Whether we're importing */
1522
+ importing,
1523
+ /** Last error */
1524
+ error
1525
+ };
1526
+ }
1527
+
1528
+ // src/utils/workflow-node-check.ts
1529
+ /**
1530
+ * Workflow node dependency checking.
1531
+ *
1532
+ * Shared logic for detecting node types used by a workflow that are not
1533
+ * installed in the current workspace, resolving them to store products, and
1534
+ * classifying them as installed / missing (free installable) / missingPaid /
1535
+ * unavailable (not offered by the store, so nothing can install them).
1536
+ *
1537
+ * Used by:
1538
+ * - Template import flow (desktop-sidebar-fragment)
1539
+ * - Shared-workflow copy flow (WorkflowItem)
1540
+ * - AI-assistant-created workflow open flow (WorkflowItem)
1541
+ */
1542
+ /**
1543
+ * Canvas-only node types: they live on the React Flow canvas but are never
1544
+ * executed, never registered in NODE_CONFIGS and never published to the store.
1545
+ *
1546
+ * They must be excluded from the dependency check. A sticky note reaching it
1547
+ * was reported as `sticky-note v1.0 — Not installed` in the Missing Nodes
1548
+ * dialog on every open of an affected workflow, and because no store product
1549
+ * backs it the Install action could only ever be a no-op (BOFF-7267).
1550
+ *
1551
+ * Kept as a literal set rather than importing STICKY_NOTE_TYPE from the
1552
+ * builder so this module stays free of builder-component imports.
1553
+ */
1554
+ const CANVAS_ONLY_NODE_TYPES = /* @__PURE__ */ new Set(["sticky-note"]);
1555
+ /**
1556
+ * Resolve the set of unique executable node types used by a workflow.
1557
+ *
1558
+ * Canvas-only annotations (see CANVAS_ONLY_NODE_TYPES) are skipped: they carry
1559
+ * no dependency, so including them produces a permanently unsatisfiable
1560
+ * "missing node".
1561
+ */
1562
+ function getWorkflowNodeTypes(nodes) {
1563
+ return [...new Set(nodes.map((n) => n.type).filter((t) => Boolean(t)).filter((t) => !CANVAS_ONLY_NODE_TYPES.has(t)))];
1564
+ }
1565
+ /**
1566
+ * Node types per store lookup: global-store-svc answers for at most 100 at a
1567
+ * time. A workflow misses far fewer; more are asked in parallel requests.
1568
+ */
1569
+ const STORE_NODE_LOOKUP_BATCH_SIZE = 100;
1570
+ /** The store context of FluidGrids node products, as the Node Store browses them. */
1571
+ const STORE_NODE_PRODUCT_CONTEXT = "fluidgrids";
1572
+ /**
1573
+ * The store products that offer any of `nodeTypes`, at most
1574
+ * `STORE_NODE_LOOKUP_BATCH_SIZE` types per request, the requests in parallel.
1575
+ * Blank and repeated types are asked once.
1576
+ */
1577
+ async function fetchStoreNodeProducts(nodeTypes, fetchProducts) {
1578
+ const wanted = [...new Set(nodeTypes.filter(Boolean))];
1579
+ const batches = [];
1580
+ for (let i = 0; i < wanted.length; i += 100) batches.push(wanted.slice(i, i + 100));
1581
+ return (await Promise.all(batches.map(fetchProducts))).flatMap((products) => [...products ?? []]);
1582
+ }
1583
+ function publishedAtMs(product) {
1584
+ const ms = product.publishedAt ? Date.parse(product.publishedAt) : NaN;
1585
+ return Number.isNaN(ms) ? Number.NEGATIVE_INFINITY : ms;
1586
+ }
1587
+ /**
1588
+ * Order two store products that offer the same nodeType; a negative result
1589
+ * means `a` is the better match.
1590
+ *
1591
+ * 1. A product linked to a devportal application (`productId` set) wins. Only
1592
+ * those have an installable published version; the unlinked rows are
1593
+ * orphaned seed rows such as `app-gmail-reader-001` that cannot install.
1594
+ * 2. Then more downloads, 3. then the most recently published, 4. then the
1595
+ * product id, so the choice never depends on the order the store returned.
1596
+ */
1597
+ function compareStoreNodeCandidates(a, b) {
1598
+ const aLinked = Boolean(a.productId);
1599
+ if (aLinked !== Boolean(b.productId)) return aLinked ? -1 : 1;
1600
+ const downloads = (b.downloads ?? 0) - (a.downloads ?? 0);
1601
+ if (downloads !== 0) return downloads;
1602
+ const aPublished = publishedAtMs(a);
1603
+ const bPublished = publishedAtMs(b);
1604
+ if (aPublished !== bPublished) return aPublished > bPublished ? -1 : 1;
1605
+ if (a.id === b.id) return 0;
1606
+ return a.id < b.id ? -1 : 1;
1607
+ }
1608
+ /**
1609
+ * Map nodeType -> best store product (see compareStoreNodeCandidates).
1610
+ * Pure function, independent of the order of `products`.
1611
+ */
1612
+ function buildStoreNodeTypeMap(products) {
1613
+ const nodeTypeToProduct = /* @__PURE__ */ new Map();
1614
+ for (const product of products) {
1615
+ const nodeType = product.nodeType?.trim();
1616
+ if (!nodeType) continue;
1617
+ const current = nodeTypeToProduct.get(nodeType);
1618
+ if (!current || compareStoreNodeCandidates(product, current) < 0) nodeTypeToProduct.set(nodeType, product);
1619
+ }
1620
+ return nodeTypeToProduct;
1621
+ }
1622
+ /**
1623
+ * Ask the global store which products offer `nodeTypes` and map each type to the
1624
+ * best one (see compareStoreNodeCandidates). Only the asked types travel: the
1625
+ * check used to page through the whole node catalog for them (BOFF-11754).
1626
+ */
1627
+ async function fetchStoreNodeTypeMap(nodeTypes) {
1628
+ const storeClient = getGlobalStoreClient();
1629
+ if (!storeClient || nodeTypes.length === 0) return /* @__PURE__ */ new Map();
1630
+ return buildStoreNodeTypeMap(await fetchStoreNodeProducts(nodeTypes, async (batch) => {
1631
+ return (await storeClient.query({
1632
+ query: StoreNodeProductsByTypeDocument,
1633
+ variables: {
1634
+ nodeTypes: batch,
1635
+ compatibleWith: STORE_NODE_PRODUCT_CONTEXT
1636
+ },
1637
+ fetchPolicy: "cache-first"
1638
+ })).data?.storeNodeProductsByType;
1639
+ }));
1640
+ }
1641
+ /**
1642
+ * One required-node entry of a template (BOFF-11496): a type the registry
1643
+ * already has is BUILTIN at its registry version; any other type is a STORE
1644
+ * node at the node's own version from its store product. Versions are
1645
+ * canonical, never the product's manifest format version ("1.0").
1646
+ */
1647
+ function requiredNodeEntry(type, registered, product) {
1648
+ if (registered) return {
1649
+ nodeType: type,
1650
+ nodeVersion: canonicalNodeVersion(registered.version || "1.0.0"),
1651
+ publishType: "BUILTIN",
1652
+ displayName: type
1653
+ };
1654
+ return {
1655
+ nodeType: type,
1656
+ nodeVersion: storeProductInstallVersion(product ?? {}),
1657
+ publishType: "STORE",
1658
+ storeProductId: product?.id,
1659
+ displayName: product?.name ?? type,
1660
+ requiresPurchase: product !== void 0 && product.pricingModel !== "FREE"
1661
+ };
1662
+ }
1663
+ /**
1664
+ * Build the list of required node types for a workflow.
1665
+ *
1666
+ * - BUILTIN / already-installed types are marked BUILTIN.
1667
+ * - Missing types are looked up in the store; if found, they are marked STORE
1668
+ * with storeProductId and requiresPurchase.
1669
+ * - Missing types not found in the store are still reported as STORE without
1670
+ * a storeProductId so the UI can show "not installed".
1671
+ */
1672
+ async function buildRequiredNodeTypes(nodes) {
1673
+ const workflowNodeTypes = getWorkflowNodeTypes(nodes);
1674
+ if (workflowNodeTypes.length === 0) return [];
1675
+ const isRegistered = (type) => !!getNodeConfig(type);
1676
+ await ensureRegistryNodeTypesLoaded(workflowNodeTypes);
1677
+ const missingTypes = workflowNodeTypes.filter((type) => !isRegistered(type));
1678
+ let nodeTypeToProduct = /* @__PURE__ */ new Map();
1679
+ if (missingTypes.length > 0) [, nodeTypeToProduct] = await Promise.all([ensureInstalledNodeTypesLoaded(missingTypes), fetchStoreNodeTypeMap(missingTypes)]);
1680
+ return workflowNodeTypes.map((type) => {
1681
+ const registered = getNodeConfig(type);
1682
+ return requiredNodeEntry(type, registered ? { version: registered.defaultData.version } : void 0, nodeTypeToProduct.get(type));
1683
+ });
1684
+ }
1685
+ /**
1686
+ * Compare two node versions by their numeric dotted parts (`1.1` equals
1687
+ * `1.1.0`; a pre-release or build suffix is ignored). Negative when `a` is
1688
+ * older than `b`, positive when newer, 0 when equal or when either has no
1689
+ * numeric part.
1690
+ */
1691
+ function compareNodeVersions(a, b) {
1692
+ const parts = (v) => {
1693
+ const nums = canonicalNodeVersion(v).trim().replace(/^v/i, "").split(/[-+]/)[0].split(".").map((p) => Number.parseInt(p, 10));
1694
+ return nums.length > 0 && nums.every((n) => Number.isFinite(n)) ? nums : null;
1695
+ };
1696
+ const pa = parts(a);
1697
+ const pb = parts(b);
1698
+ if (!pa || !pb) return 0;
1699
+ for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
1700
+ const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
1701
+ if (diff !== 0) return diff;
1702
+ }
1703
+ return 0;
1704
+ }
1705
+ /**
1706
+ * Whether an installed node is older than the version the entry requires
1707
+ * (BOFF-12017). An entry with no `nodeVersion`, or an installation whose
1708
+ * version is unknown, is satisfied by any version.
1709
+ */
1710
+ function isOutdated(node, installedVersions) {
1711
+ if (!node.storeProductId || !node.nodeVersion || !installedVersions) return false;
1712
+ const installedVersion = installedVersions.get(node.storeProductId)?.installedVersion;
1713
+ if (!installedVersion) return false;
1714
+ return compareNodeVersions(installedVersion, node.nodeVersion) < 0;
1715
+ }
1716
+ /**
1717
+ * Classify required nodes against the set of installed store app IDs and,
1718
+ * when `installedVersions` is given, the installed versions: a node whose
1719
+ * installed version is older than the entry's `nodeVersion` goes to
1720
+ * `needsUpdate` instead of `installed` (BOFF-12017).
1721
+ *
1722
+ * Pure function — easy to unit test.
1723
+ */
1724
+ function buildNodeCheck(requiredNodeTypes, installedAppIds, installedVersions) {
1725
+ const present = requiredNodeTypes.filter((n) => n.publishType === "BUILTIN" || n.storeProductId && installedAppIds.has(n.storeProductId));
1726
+ const needsUpdate = present.filter((n) => n.publishType !== "BUILTIN" && isOutdated(n, installedVersions));
1727
+ const installed = present.filter((n) => !needsUpdate.includes(n));
1728
+ const notInstalled = requiredNodeTypes.filter((n) => n.publishType !== "BUILTIN" && (!n.storeProductId || !installedAppIds.has(n.storeProductId)));
1729
+ const unavailable = notInstalled.filter((n) => !n.storeProductId);
1730
+ const installable = notInstalled.filter((n) => !!n.storeProductId);
1731
+ const missing = installable.filter((n) => !n.requiresPurchase);
1732
+ const missingPaid = installable.filter((n) => !!n.requiresPurchase);
1733
+ return {
1734
+ installed,
1735
+ missing,
1736
+ missingPaid,
1737
+ unavailable,
1738
+ needsUpdate,
1739
+ canImport: missingPaid.length === 0
1740
+ };
1741
+ }
1742
+
1743
+ // src/utils/dismiss-toast.ts
1744
+ /** Resolves on the next zero-delay timer. */
1745
+ function nextTimer() {
1746
+ return new Promise((resolve) => setTimeout(resolve, 0));
1747
+ }
1748
+ /**
1749
+ * Dismiss a toast that may have been created a moment ago.
1750
+ *
1751
+ * sonner adds a toast to the screen on a zero-delay timer, but delivers a
1752
+ * dismissal on animation frames. A dismissal sent while the add is still
1753
+ * queued (the work finished fast, or the main thread was busy rendering) is
1754
+ * applied first, finds nothing to remove, and the toast then appears and
1755
+ * stays: "Loading template..." stuck on the template preview page
1756
+ * (BOFF-11153). Timers of equal delay fire in the order they were set, so
1757
+ * waiting one zero-delay timer runs after the queued add, and the dismissal
1758
+ * then lands on the toast.
1759
+ *
1760
+ * Where a toast is followed by another message, replace it through the same
1761
+ * `id` instead (`toast.success(…, { id })`); that goes through the same
1762
+ * queue as the add and needs no dismissal.
1763
+ */
1764
+ async function dismissToastWhenShown(id) {
1765
+ await nextTimer();
1766
+ toast.dismiss(id);
1767
+ }
1768
+
1769
+ // src/hooks/store/useTemplateImportFlow.tsx
1770
+ const LazyTemplateConfigurationModal = lazy(() => import("./TemplateConfigurationModal-CdvCYJLM.js").then((m) => ({ default: m.TemplateConfigurationModal })));
1771
+ /**
1772
+ * "Use this template", the same everywhere it is offered: the builder's
1773
+ * template panel, the Templates page and the template preview page
1774
+ * (BOFF-11153). Before this, only the builder panel checked the template's
1775
+ * nodes and asked for its inputs; the two pages created the copy directly.
1776
+ *
1777
+ * 1. Load the template's full detail and resolve its content.
1778
+ * 2. Check its required nodes against the workspace's installed nodes.
1779
+ * 3. When it asks for inputs or connections, or a node is not installed,
1780
+ * show the configuration dialog; otherwise go straight on.
1781
+ * 4. Install the missing free nodes, create the copy with the user's inputs,
1782
+ * and open it (`onImported`).
1783
+ */
1784
+ function useTemplateImportFlow({ onImported, onQuotaRefusal, onQuotaExhausted }) {
1785
+ const tr = useTr();
1786
+ const { bus, workspaceId } = useFluidGridsAnalytics();
1787
+ const { installedAppIds, installationsMap, refetch: refetchInstalled } = useInstalledNodes();
1788
+ const { getTemplateDetail, importTemplate } = useImportWorkflowTemplate();
1789
+ const [pending, setPending] = useState(null);
1790
+ const [busy, setBusy] = useState(false);
1791
+ const [installProgress, setInstallProgress] = useState(null);
1792
+ const installMissingNodes = useCallback(async (nodeCheck) => {
1793
+ const nodes = nodesToInstall(nodeCheck);
1794
+ const storeClient = getGlobalStoreClient();
1795
+ if (nodes.length === 0 || !storeClient) return;
1796
+ const config = getFluidGridsConfig();
1797
+ await installNodesInOrder(nodes, async (node) => {
1798
+ throwIfResultError(await storeClient.mutate({
1799
+ mutation: InstallWorkflowNodeDocument,
1800
+ variables: { input: {
1801
+ productId: node.storeProductId ?? "",
1802
+ workspaceId: config.workspaceId,
1803
+ organizationId: config.tenantId,
1804
+ version: node.nodeVersion,
1805
+ manifest: null
1806
+ } }
1807
+ }));
1808
+ emitNodeInstalled(bus, {
1809
+ workspaceId,
1810
+ nodeType: node.nodeType,
1811
+ source: "store"
1812
+ });
1813
+ }, setInstallProgress, (node, err) => console.warn(`[useTemplateImportFlow] Failed to install node ${node.nodeType}:`, err));
1814
+ setInstallProgress(null);
1815
+ await refetchInstalled?.().catch(() => void 0);
1816
+ }, [
1817
+ bus,
1818
+ refetchInstalled,
1819
+ workspaceId
1820
+ ]);
1821
+ const createCopy = useCallback(async (template, content, nodeCheck, overrides) => {
1822
+ setBusy(true);
1823
+ try {
1824
+ await installMissingNodes(nodeCheck);
1825
+ toast.loading(tr("fluidgrids.builder.desktopSidebar.creatingWorkflowToast", "Creating workflow..."), { id: "template-import" });
1826
+ const result = await importTemplate(template, {
1827
+ content,
1828
+ name: overrides?.name,
1829
+ templateInputs: overrides?.templateInputs
1830
+ });
1831
+ if (result.success && result.workflow) {
1832
+ toast.success(tr("fluidgrids.builder.desktopSidebar.workflowCreatedToast", "Workflow created from template!"), {
1833
+ id: "template-import",
1834
+ description: tr("fluidgrids.pages.templatePreview.importSuccessDescription", "\"{{name}}\" is ready to edit", { name: result.workflow.name })
1835
+ });
1836
+ if ((content.requiredCredentialTypes?.length ?? 0) > 0) toast.info(tr("fluidgrids.builder.desktopSidebar.credentialsNeededToast", "Credentials needed"), {
1837
+ description: tr("fluidgrids.builder.desktopSidebar.credentialsNeededDescription", "Connect {{types}} in Connected apps", { types: (content.requiredCredentialTypes ?? []).join(", ") }),
1838
+ duration: 6e3
1839
+ });
1840
+ onImported(result.workflow);
1841
+ return true;
1842
+ }
1843
+ const quotaRefusal = findQuotaRefusal(result.error?.cause) ?? findQuotaRefusal(result.error);
1844
+ const onQuota = onQuotaRefusal ?? (onQuotaExhausted ? () => onQuotaExhausted() : void 0);
1845
+ if (quotaRefusal && onQuota) {
1846
+ await dismissToastWhenShown("template-import");
1847
+ onQuota(quotaRefusal);
1848
+ return false;
1849
+ }
1850
+ toast.error(tr("fluidgrids.builder.desktopSidebar.importTemplateErrorToast", "Failed to import template"), {
1851
+ id: "template-import",
1852
+ description: (result.error ? describeOperationError(result.error, result.message) : result.message) || tr("fluidgrids.builder.desktopSidebar.importTemplateErrorFallback", "Unknown error during import")
1853
+ });
1854
+ return false;
1855
+ } catch (err) {
1856
+ toast.error(tr("fluidgrids.builder.desktopSidebar.importFailedToast", "Import failed"), {
1857
+ id: "template-import",
1858
+ description: err instanceof Error ? err.message : tr("fluidgrids.builder.desktopSidebar.importFailedFallback", "Unknown error")
1859
+ });
1860
+ return false;
1861
+ } finally {
1862
+ setInstallProgress(null);
1863
+ setBusy(false);
1864
+ }
1865
+ }, [
1866
+ importTemplate,
1867
+ installMissingNodes,
1868
+ onImported,
1869
+ onQuotaExhausted,
1870
+ onQuotaRefusal,
1871
+ tr
1872
+ ]);
1873
+ const start = useCallback(async (template) => {
1874
+ setBusy(true);
1875
+ toast.loading(tr("fluidgrids.builder.desktopSidebar.loadingTemplateToast", "Loading template..."), { id: "template-load" });
1876
+ try {
1877
+ const full = await getTemplateDetail(template.id);
1878
+ if (!full) {
1879
+ toast.error(tr("fluidgrids.builder.desktopSidebar.templateDetailsErrorToast", "Failed to load template details"), { id: "template-load" });
1880
+ return;
1881
+ }
1882
+ const content = await resolveTemplateContent(full, buildRequiredNodeTypes);
1883
+ if (!content) {
1884
+ toast.error(tr("fluidgrids.builder.desktopSidebar.invalidTemplateDataToast", "Template does not contain valid workflow data"), { id: "template-load" });
1885
+ return;
1886
+ }
1887
+ await dismissToastWhenShown("template-load");
1888
+ const nodeCheck = buildNodeCheck(content.requiredNodeTypes ?? [], installedAppIds, installationsMap);
1889
+ if (needsTemplateConfiguration(content, nodeCheck)) {
1890
+ setPending({
1891
+ template: full,
1892
+ content,
1893
+ nodeCheck
1894
+ });
1895
+ return;
1896
+ }
1897
+ await createCopy(full, content, nodeCheck);
1898
+ } catch (err) {
1899
+ toast.error(tr("fluidgrids.builder.desktopSidebar.genericErrorToast", "Something went wrong"), {
1900
+ id: "template-load",
1901
+ description: err instanceof Error ? err.message : tr("fluidgrids.builder.desktopSidebar.genericErrorFallback", "Failed to process template")
1902
+ });
1903
+ } finally {
1904
+ setBusy(false);
1905
+ }
1906
+ }, [
1907
+ createCopy,
1908
+ getTemplateDetail,
1909
+ installedAppIds,
1910
+ installationsMap,
1911
+ tr
1912
+ ]);
1913
+ const confirm = useCallback(async (config) => {
1914
+ if (!pending?.nodeCheck.canImport) return;
1915
+ if (await createCopy(pending.template, pending.content, pending.nodeCheck, config)) setPending(null);
1916
+ }, [createCopy, pending]);
1917
+ return {
1918
+ start,
1919
+ dialog: pending ? /* @__PURE__ */ jsx(Suspense, {
1920
+ fallback: null,
1921
+ children: /* @__PURE__ */ jsx(LazyTemplateConfigurationModal, {
1922
+ open: true,
1923
+ onOpenChange: (open) => {
1924
+ if (!open && !busy) setPending(null);
1925
+ },
1926
+ template: pending.template,
1927
+ content: pending.content,
1928
+ nodeCheckResult: pending.nodeCheck,
1929
+ onConfirm: confirm,
1930
+ importing: busy,
1931
+ installProgress
1932
+ })
1933
+ }) : null,
1934
+ busy
1935
+ };
1936
+ }
1937
+
1938
+ // src/modules/templates/utils/store-gallery.ts
1939
+ const SORT_BY = {
1940
+ newest: "NEWEST",
1941
+ "most-used": "DOWNLOADS",
1942
+ name: "NAME_ASC",
1943
+ featured: "FEATURED",
1944
+ "top-rated": "RATING",
1945
+ relevance: "RELEVANCE"
1946
+ };
1947
+ /** The sorts a person can pick, in menu order (Best match is added by search). */
1948
+ const PICKABLE_SORTS = [
1949
+ "newest",
1950
+ "most-used",
1951
+ "name",
1952
+ "featured",
1953
+ "top-rated"
1954
+ ];
1955
+ /** `?sort=` as a pickable sort, or null (nothing picked). */
1956
+ function parseSortParam(raw) {
1957
+ return PICKABLE_SORTS.find((sort) => sort === raw) ?? null;
1958
+ }
1959
+ /**
1960
+ * The sort in effect: the person's pick, else Best match while searching,
1961
+ * else Newest.
1962
+ */
1963
+ function effectiveSort(picked, searching) {
1964
+ return picked ?? (searching ? "relevance" : "newest");
1965
+ }
1966
+ function storeSortBy(sort) {
1967
+ return SORT_BY[sort];
1968
+ }
1969
+ /** The menu's options: Best match first, only while a search is active. */
1970
+ function sortOptions(searching) {
1971
+ return searching ? ["relevance", ...PICKABLE_SORTS] : [...PICKABLE_SORTS];
1972
+ }
1973
+ /**
1974
+ * Each label is a literal `tr()` call: the app's word extractor reads keys
1975
+ * statically, so a key built at run time would never be translated.
1976
+ */
1977
+ function sortLabel(tr, sort) {
1978
+ switch (sort) {
1979
+ case "newest": return tr("fluidgrids.templates.sort.newest", "Newest");
1980
+ case "most-used": return tr("fluidgrids.templates.sort.mostUsed", "Most used");
1981
+ case "name": return tr("fluidgrids.templates.sort.name", "Name A–Z");
1982
+ case "featured": return tr("fluidgrids.templates.sort.featured", "Featured");
1983
+ case "top-rated": return tr("fluidgrids.templates.sort.topRated", "Top rated");
1984
+ case "relevance": return tr("fluidgrids.templates.sort.bestMatch", "Best match");
1985
+ }
1986
+ }
1987
+ function readGalleryUrl(params) {
1988
+ return {
1989
+ category: params.get("category")?.trim() || "all",
1990
+ sort: parseSortParam(params.get("sort")),
1991
+ page: parsePageParam(params.get("page"))
1992
+ };
1993
+ }
1994
+ /**
1995
+ * The query string after a change. Defaults are left out (`all`, no sort,
1996
+ * page 1), other parameters are kept, and any change except a page change
1997
+ * returns to page 1.
1998
+ */
1999
+ function withGalleryState(params, patch) {
2000
+ const next = new URLSearchParams(params);
2001
+ const resetsPage = patch.page === void 0;
2002
+ if (patch.category !== void 0) {
2003
+ if (patch.category === "all" || !patch.category.trim()) next.delete("category");
2004
+ else next.set("category", patch.category);
2005
+ }
2006
+ if ("sort" in patch) {
2007
+ if (patch.sort) next.set("sort", patch.sort);
2008
+ else next.delete("sort");
2009
+ }
2010
+ const page = resetsPage ? 1 : patch.page;
2011
+ if (page === void 0 || page <= 1) next.delete("page");
2012
+ else next.set("page", String(page));
2013
+ return next;
2014
+ }
2015
+ /** "customer-success" → "Customer success". */
2016
+ function humanizeCategory(value) {
2017
+ const text = value.replace(/[-_]+/g, " ").trim();
2018
+ return text.charAt(0).toUpperCase() + text.slice(1);
2019
+ }
2020
+ /**
2021
+ * The gallery's name for a store category. Its own keys (the older
2022
+ * `fluidgrids.templates.categories.*` defaults differ between v1 and v2), each a
2023
+ * literal `tr()` call so the app's word extractor finds it; a category this list
2024
+ * does not know keeps today's humanised name.
2025
+ */
2026
+ function storeCategoryLabel(tr, value) {
2027
+ switch (value) {
2028
+ case "integration": return tr("fluidgrids.templates.storeCategory.integration", "Connect apps");
2029
+ case "communication": return tr("fluidgrids.templates.storeCategory.communication", "Communication");
2030
+ case "ai": return tr("fluidgrids.templates.storeCategory.ai", "AI");
2031
+ case "data": return tr("fluidgrids.templates.storeCategory.data", "Data");
2032
+ case "flow": return tr("fluidgrids.templates.storeCategory.flow", "Logic & flow");
2033
+ case "data-processing": return tr("fluidgrids.templates.storeCategory.dataProcessing", "Data & spreadsheets");
2034
+ case "ai-ml": return tr("fluidgrids.templates.storeCategory.aiMl", "AI & ML");
2035
+ case "automation": return tr("fluidgrids.templates.storeCategory.automation", "Automation");
2036
+ case "devops": return tr("fluidgrids.templates.storeCategory.devops", "DevOps");
2037
+ case "finance": return tr("fluidgrids.templates.storeCategory.finance", "Finance");
2038
+ case "sales": return tr("fluidgrids.templates.storeCategory.sales", "Sales");
2039
+ case "marketing": return tr("fluidgrids.templates.storeCategory.marketing", "Marketing");
2040
+ case "productivity": return tr("fluidgrids.templates.storeCategory.productivity", "Productivity");
2041
+ case "support": return tr("fluidgrids.templates.storeCategory.support", "Support");
2042
+ default: return humanizeCategory(value);
2043
+ }
2044
+ }
2045
+
2046
+ // src/modules/templates/components/StoreTemplateCardCompact.tsx
2047
+ /**
2048
+ * The Templates gallery's compact card (Navigation v2, BOFF-14754): logo and
2049
+ * title, two lines of description, then the category and a secondary "Use"
2050
+ * button. The whole card opens the preview through the title's stretched link;
2051
+ * "Use" sits above it. The builder's Workflow Templates picker uses the same
2052
+ * card with `onPreview`: the title is then a button that opens the picker's
2053
+ * side panel instead of a link to the preview page.
2054
+ */
2055
+ /** The title's stretched hit area: the whole card opens the preview. */
2056
+ const STRETCHED_TITLE_CLASS = "text-left outline-none after:absolute after:inset-0 after:rounded-[inherit] after:content-[''] focus-visible:after:ring-2 focus-visible:after:ring-accent-glow";
2057
+ /** The template's own first screenshot, when it has one that loads. */
2058
+ function ScreenshotStrip({ src }) {
2059
+ const [failed, setFailed] = useState(false);
2060
+ if (failed) return null;
2061
+ return /* @__PURE__ */ jsx("img", {
2062
+ src,
2063
+ alt: "",
2064
+ loading: "lazy",
2065
+ decoding: "async",
2066
+ onError: () => setFailed(true),
2067
+ className: "-mx-3.5 -mt-3.5 mb-0.5 h-28 w-[calc(100%+1.75rem)] max-w-none rounded-t-[inherit] object-cover max-sm:hidden",
2068
+ "data-testid": "store-template-screenshot"
2069
+ });
2070
+ }
2071
+ function StoreTemplateCardCompact({ template, previewTo, onPreview, onUseTemplate, selected = false }) {
2072
+ const tr = useTr();
2073
+ const icons = template;
2074
+ const logo = storeIconCandidates([icons.iconUrl, icons.icon]);
2075
+ const screenshot = storeIconCandidates(template.screenshots ?? []).find((source) => source.kind === "image");
2076
+ const paid = isPaidTemplate(template);
2077
+ return /* @__PURE__ */ jsxs("article", {
2078
+ className: cn("group relative flex min-w-0 flex-col gap-2.5 rounded-xl border border-border-subtle bg-bg-elevated p-3.5", "max-sm:grid max-sm:grid-cols-[40px_minmax(0,1fr)_auto] max-sm:items-center max-sm:gap-x-3 max-sm:gap-y-0.5 max-sm:p-3 max-sm:[grid-template-areas:'logo_title_use'_'logo_desc_use'_'logo_cat_use']", "transition-[transform,box-shadow,border-color] motion-reduce:transition-none motion-safe:duration-[var(--motion-duration-fast)]", "hover:border-accent-glow/45 hover:shadow-[var(--shadow-pop)] motion-safe:hover:-translate-y-0.5", "focus-within:border-accent-glow/45", selected && "border-accent-glow/60 shadow-[var(--shadow-pop)]"),
2079
+ "data-testid": "store-template-card",
2080
+ "data-selected": selected || void 0,
2081
+ children: [
2082
+ screenshot?.kind === "image" && /* @__PURE__ */ jsx(ScreenshotStrip, { src: screenshot.src }),
2083
+ /* @__PURE__ */ jsxs("div", {
2084
+ className: "flex items-start gap-3 max-sm:contents",
2085
+ children: [/* @__PURE__ */ jsx("span", {
2086
+ className: "flex size-10 flex-none max-sm:self-start max-sm:[grid-area:logo] items-center justify-center overflow-hidden rounded-[11px] border border-border-subtle bg-bg-elevated dark:bg-text-primary/90",
2087
+ children: /* @__PURE__ */ jsx(StoreIcon, {
2088
+ candidates: logo,
2089
+ alt: "",
2090
+ imageClassName: "size-[26px] object-contain",
2091
+ iconClassName: "text-text-primary dark:text-bg-canvas",
2092
+ iconSize: 26,
2093
+ offline: true,
2094
+ fallback: /* @__PURE__ */ jsx("span", {
2095
+ className: "flex size-full items-center justify-center bg-bg-sunken text-accent-glow",
2096
+ "data-testid": "store-template-logo-fallback",
2097
+ children: /* @__PURE__ */ jsx(Workflow, {
2098
+ className: "size-5",
2099
+ "aria-hidden": "true"
2100
+ })
2101
+ })
2102
+ })
2103
+ }), /* @__PURE__ */ jsx("h3", {
2104
+ className: "line-clamp-2 text-[14.5px] font-semibold leading-snug text-text-primary max-sm:[grid-area:title]",
2105
+ children: onPreview ? /* @__PURE__ */ jsx("button", {
2106
+ type: "button",
2107
+ className: STRETCHED_TITLE_CLASS,
2108
+ "aria-pressed": selected,
2109
+ onClick: () => onPreview(template),
2110
+ children: template.name
2111
+ }) : /* @__PURE__ */ jsx(Link, {
2112
+ to: previewTo,
2113
+ className: STRETCHED_TITLE_CLASS,
2114
+ children: template.name
2115
+ })
2116
+ })]
2117
+ }),
2118
+ /* @__PURE__ */ jsx("p", {
2119
+ className: "line-clamp-2 min-h-[2.9em] text-[13px] leading-snug text-text-secondary max-sm:min-h-0 max-sm:line-clamp-1 max-sm:text-[12.5px] max-sm:[grid-area:desc]",
2120
+ children: template.description || tr("fluidgrids.templates.templatesPage.cardNoDescription", "No description provided.")
2121
+ }),
2122
+ /* @__PURE__ */ jsxs("div", {
2123
+ className: "mt-auto flex items-center justify-between gap-2 max-sm:contents",
2124
+ children: [/* @__PURE__ */ jsxs("div", {
2125
+ className: "flex min-w-0 flex-1 items-center gap-2 max-sm:[grid-area:cat]",
2126
+ children: [
2127
+ template.category && /* @__PURE__ */ jsx("span", {
2128
+ className: "min-w-0 truncate rounded-full border border-accent-glow/20 bg-accent-glow/10 px-2 py-0.5 text-xs text-text-secondary",
2129
+ children: storeCategoryLabel(tr, template.category)
2130
+ }),
2131
+ template.featured && /* @__PURE__ */ jsxs("span", {
2132
+ className: "inline-flex items-center gap-1 whitespace-nowrap text-xs font-medium text-text-secondary",
2133
+ children: [/* @__PURE__ */ jsx(Star, {
2134
+ className: "size-3 fill-current text-status-warning-text",
2135
+ "aria-hidden": "true"
2136
+ }), tr("fluidgrids.builder.templateCard.featuredBadge", "Featured")]
2137
+ }),
2138
+ paid && /* @__PURE__ */ jsx("span", {
2139
+ className: "text-xs font-semibold text-text-primary",
2140
+ children: formatTemplatePrice(template.price, template.currency)
2141
+ })
2142
+ ]
2143
+ }), /* @__PURE__ */ jsx("div", {
2144
+ className: "flex flex-none max-sm:self-center max-sm:[grid-area:use]",
2145
+ children: /* @__PURE__ */ jsx(SdkPermissionButton, {
2146
+ permission: FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE,
2147
+ deniedTooltip: tr("fluidgrids.templates.useDeniedTooltip", "You don't have permission to create workflows from templates"),
2148
+ children: /* @__PURE__ */ jsxs(Button$1, {
2149
+ variant: "outline",
2150
+ size: "sm",
2151
+ className: "relative z-10 h-8 gap-1.5 px-3 max-sm:h-9 text-[13px] font-semibold text-text-secondary hover:border-accent-glow/50 hover:bg-accent-glow/10 hover:text-text-primary",
2152
+ "aria-label": tr("fluidgrids.templates.gallery.useAria", "Use template: {{name}}", { name: template.name }),
2153
+ onClick: () => onUseTemplate(template),
2154
+ children: [/* @__PURE__ */ jsx(Sparkles, {
2155
+ className: "size-3.5 text-accent-glow",
2156
+ "aria-hidden": "true"
2157
+ }), tr("fluidgrids.templates.gallery.use", "Use")]
2158
+ })
2159
+ })
2160
+ })]
2161
+ })
2162
+ ]
2163
+ });
2164
+ }
2165
+
2166
+ export { storeContextHeaders as C, useInstalledNodes as S, getStoreNodeType as _, sortOptions as a, storeProductDisplayVersion as b, withGalleryState as c, buildRequiredNodeTypes as d, getWorkflowNodeTypes as f, getStoreNodeAvailability as g, filterStoreNodesForPalette as h, sortLabel as i, useTemplateImportFlow as l, useWorkflowTemplates as m, effectiveSort as n, storeCategoryLabel as o, useImportWorkflowTemplate as p, readGalleryUrl as r, storeSortBy as s, StoreTemplateCardCompact as t, buildNodeCheck as u, isStoreProductUpdateAvailable as v, BrowseWorkflowTemplatesDocument as w, storeProductInstallVersion as x, storeNodeIconCandidates as y };