@decaf-ts/as-graph 0.7.0 → 0.8.0

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 (383) hide show
  1. package/README.md +92 -12
  2. package/assets/i18n/en.json +1519 -130
  3. package/dist/as-graph.cjs +1 -1
  4. package/dist/as-graph.cjs.map +1 -1
  5. package/dist/as-graph.js +1 -1
  6. package/dist/as-graph.js.map +1 -1
  7. package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs +13 -0
  8. package/lib/cjs/dagster/DagsterGraphExecutionBackend.cjs.map +1 -1
  9. package/lib/cjs/dagster/capabilities.cjs +5 -0
  10. package/lib/cjs/dagster/capabilities.cjs.map +1 -1
  11. package/lib/cjs/engine/execution/GraphCodeMode.cjs +42 -0
  12. package/lib/cjs/engine/execution/GraphCodeMode.cjs.map +1 -1
  13. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs +35 -4
  14. package/lib/cjs/engine/execution/GraphExecutionEngine.cjs.map +1 -1
  15. package/lib/cjs/engine/validation/GraphNodeInstanceValidator.cjs +29 -1
  16. package/lib/cjs/engine/validation/GraphNodeInstanceValidator.cjs.map +1 -1
  17. package/lib/cjs/engine/validation/GraphWorkflowDocumentValidator.cjs +6 -2
  18. package/lib/cjs/engine/validation/GraphWorkflowDocumentValidator.cjs.map +1 -1
  19. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs +41 -9
  20. package/lib/cjs/mastra/MastraWorkflowCompiler.cjs.map +1 -1
  21. package/lib/cjs/nest/graph/GraphEngineController.cjs +18 -0
  22. package/lib/cjs/nest/graph/GraphEngineController.cjs.map +1 -1
  23. package/lib/cjs/nest/graph/GraphNodeCatalogueController.cjs +14 -0
  24. package/lib/cjs/nest/graph/GraphNodeCatalogueController.cjs.map +1 -1
  25. package/lib/cjs/nest/graph/GraphRunController.cjs +17 -0
  26. package/lib/cjs/nest/graph/GraphRunController.cjs.map +1 -1
  27. package/lib/cjs/nest/graph/GraphWorkflowController.cjs +34 -5
  28. package/lib/cjs/nest/graph/GraphWorkflowController.cjs.map +1 -1
  29. package/lib/cjs/node/comms/discord/node.cjs +384 -0
  30. package/lib/cjs/node/comms/discord/node.cjs.map +1 -0
  31. package/lib/cjs/node/comms/outlook/node.cjs +395 -0
  32. package/lib/cjs/node/comms/outlook/node.cjs.map +1 -0
  33. package/lib/cjs/node/comms/whatsapp/node.cjs +341 -0
  34. package/lib/cjs/node/comms/whatsapp/node.cjs.map +1 -0
  35. package/lib/cjs/node/data/aggregate/node.cjs +196 -0
  36. package/lib/cjs/node/data/aggregate/node.cjs.map +1 -0
  37. package/lib/cjs/node/data/compare-datasets/node.cjs +331 -0
  38. package/lib/cjs/node/data/compare-datasets/node.cjs.map +1 -0
  39. package/lib/cjs/node/data/item-lists/node.cjs +416 -0
  40. package/lib/cjs/node/data/item-lists/node.cjs.map +1 -0
  41. package/lib/cjs/node/data/remove-duplicates/node.cjs +141 -0
  42. package/lib/cjs/node/data/remove-duplicates/node.cjs.map +1 -0
  43. package/lib/cjs/node/data/summarize/node.cjs +155 -0
  44. package/lib/cjs/node/data/summarize/node.cjs.map +1 -0
  45. package/lib/cjs/node/data/support.cjs +5 -0
  46. package/lib/cjs/node/data/support.cjs.map +1 -1
  47. package/lib/cjs/node/data/transform-utils.cjs +719 -0
  48. package/lib/cjs/node/data/transform-utils.cjs.map +1 -0
  49. package/lib/cjs/node/index.cjs +216 -110
  50. package/lib/cjs/node/index.cjs.map +1 -1
  51. package/lib/cjs/node/io/confluence/node.cjs +253 -0
  52. package/lib/cjs/node/io/confluence/node.cjs.map +1 -0
  53. package/lib/cjs/node/io/convert-to-file/node.cjs +349 -0
  54. package/lib/cjs/node/io/convert-to-file/node.cjs.map +1 -0
  55. package/lib/cjs/node/io/file-support.cjs +311 -0
  56. package/lib/cjs/node/io/file-support.cjs.map +1 -0
  57. package/lib/cjs/node/io/google-calendar/node.cjs +359 -0
  58. package/lib/cjs/node/io/google-calendar/node.cjs.map +1 -0
  59. package/lib/cjs/node/io/google-docs/node.cjs +272 -0
  60. package/lib/cjs/node/io/google-docs/node.cjs.map +1 -0
  61. package/lib/cjs/node/io/html/node.cjs +275 -0
  62. package/lib/cjs/node/io/html/node.cjs.map +1 -0
  63. package/lib/cjs/node/io/html-extract/node.cjs +162 -0
  64. package/lib/cjs/node/io/html-extract/node.cjs.map +1 -0
  65. package/lib/cjs/node/io/html-support.cjs +246 -0
  66. package/lib/cjs/node/io/html-support.cjs.map +1 -0
  67. package/lib/cjs/node/io/jira/node.cjs +351 -0
  68. package/lib/cjs/node/io/jira/node.cjs.map +1 -0
  69. package/lib/cjs/node/io/markdown/node.cjs +229 -0
  70. package/lib/cjs/node/io/markdown/node.cjs.map +1 -0
  71. package/lib/cjs/node/io/microsoft-excel/node.cjs +261 -0
  72. package/lib/cjs/node/io/microsoft-excel/node.cjs.map +1 -0
  73. package/lib/cjs/node/io/microsoft-sharepoint/node.cjs +274 -0
  74. package/lib/cjs/node/io/microsoft-sharepoint/node.cjs.map +1 -0
  75. package/lib/cjs/node/io/read-binary-file/node.cjs +114 -0
  76. package/lib/cjs/node/io/read-binary-file/node.cjs.map +1 -0
  77. package/lib/cjs/node/io/read-binary-files/node.cjs +113 -0
  78. package/lib/cjs/node/io/read-binary-files/node.cjs.map +1 -0
  79. package/lib/cjs/node/io/write-binary-file/node.cjs +164 -0
  80. package/lib/cjs/node/io/write-binary-file/node.cjs.map +1 -0
  81. package/lib/cjs/node/io/xml/node.cjs +322 -0
  82. package/lib/cjs/node/io/xml/node.cjs.map +1 -0
  83. package/lib/cjs/node/manifests.cjs +137 -79
  84. package/lib/cjs/node/manifests.cjs.map +1 -1
  85. package/lib/cjs/node/storage/rabbitmq/node.cjs +252 -0
  86. package/lib/cjs/node/storage/rabbitmq/node.cjs.map +1 -0
  87. package/lib/cjs/node/triggers/error/node.cjs +108 -0
  88. package/lib/cjs/node/triggers/error/node.cjs.map +1 -0
  89. package/lib/cjs/node/triggers/postgres/node.cjs +244 -0
  90. package/lib/cjs/node/triggers/postgres/node.cjs.map +1 -0
  91. package/lib/cjs/node/triggers/rabbitmq/node.cjs +284 -0
  92. package/lib/cjs/node/triggers/rabbitmq/node.cjs.map +1 -0
  93. package/lib/cjs/node/triggers/redis/node.cjs +233 -0
  94. package/lib/cjs/node/triggers/redis/node.cjs.map +1 -0
  95. package/lib/cjs/node/triggers/sse/node.cjs +196 -0
  96. package/lib/cjs/node/triggers/sse/node.cjs.map +1 -0
  97. package/lib/cjs/node/triggers/support.cjs +107 -0
  98. package/lib/cjs/node/triggers/support.cjs.map +1 -0
  99. package/lib/cjs/node/triggers/workflow/node.cjs +193 -0
  100. package/lib/cjs/node/triggers/workflow/node.cjs.map +1 -0
  101. package/lib/cjs/shared/graph/catalog/GraphValueSchemaDerivation.cjs +20 -3
  102. package/lib/cjs/shared/graph/catalog/GraphValueSchemaDerivation.cjs.map +1 -1
  103. package/lib/cjs/workflows/boundary-value.workflow.cjs +38 -0
  104. package/lib/cjs/workflows/boundary-value.workflow.cjs.map +1 -0
  105. package/lib/cjs/workflows/builders.cjs +47 -0
  106. package/lib/cjs/workflows/builders.cjs.map +1 -0
  107. package/lib/cjs/workflows/chat-agent.workflow.cjs +40 -0
  108. package/lib/cjs/workflows/chat-agent.workflow.cjs.map +1 -0
  109. package/lib/cjs/workflows/error-boundary.workflow.cjs +54 -0
  110. package/lib/cjs/workflows/error-boundary.workflow.cjs.map +1 -0
  111. package/lib/cjs/workflows/event-map.workflow.cjs +37 -0
  112. package/lib/cjs/workflows/event-map.workflow.cjs.map +1 -0
  113. package/lib/cjs/workflows/foreach-break.workflow.cjs +58 -0
  114. package/lib/cjs/workflows/foreach-break.workflow.cjs.map +1 -0
  115. package/lib/cjs/workflows/human-approval.workflow.cjs +44 -0
  116. package/lib/cjs/workflows/human-approval.workflow.cjs.map +1 -0
  117. package/lib/cjs/workflows/if-switch.workflow.cjs +66 -0
  118. package/lib/cjs/workflows/if-switch.workflow.cjs.map +1 -0
  119. package/lib/cjs/workflows/index.cjs +135 -0
  120. package/lib/cjs/workflows/index.cjs.map +1 -0
  121. package/lib/cjs/workflows/loops-while-until.workflow.cjs +76 -0
  122. package/lib/cjs/workflows/loops-while-until.workflow.cjs.map +1 -0
  123. package/lib/cjs/workflows/manual-log.workflow.cjs +52 -0
  124. package/lib/cjs/workflows/manual-log.workflow.cjs.map +1 -0
  125. package/lib/cjs/workflows/schedule-code.workflow.cjs +42 -0
  126. package/lib/cjs/workflows/schedule-code.workflow.cjs.map +1 -0
  127. package/lib/cjs/workflows/types.cjs +4 -0
  128. package/lib/cjs/workflows/types.cjs.map +1 -0
  129. package/lib/cjs/workflows/value-templates.workflow.cjs +43 -0
  130. package/lib/cjs/workflows/value-templates.workflow.cjs.map +1 -0
  131. package/lib/cjs/workflows/webhook-form.workflow.cjs +48 -0
  132. package/lib/cjs/workflows/webhook-form.workflow.cjs.map +1 -0
  133. package/lib/esm/dagster/DagsterGraphExecutionBackend.js +13 -0
  134. package/lib/esm/dagster/DagsterGraphExecutionBackend.js.map +1 -1
  135. package/lib/esm/dagster/capabilities.js +5 -0
  136. package/lib/esm/dagster/capabilities.js.map +1 -1
  137. package/lib/esm/engine/execution/GraphCodeMode.js +40 -0
  138. package/lib/esm/engine/execution/GraphCodeMode.js.map +1 -1
  139. package/lib/esm/engine/execution/GraphExecutionBackend.js.map +1 -1
  140. package/lib/esm/engine/execution/GraphExecutionEngine.js +36 -5
  141. package/lib/esm/engine/execution/GraphExecutionEngine.js.map +1 -1
  142. package/lib/esm/engine/validation/GraphNodeInstanceValidator.js +29 -1
  143. package/lib/esm/engine/validation/GraphNodeInstanceValidator.js.map +1 -1
  144. package/lib/esm/engine/validation/GraphWorkflowDocumentValidator.js +6 -2
  145. package/lib/esm/engine/validation/GraphWorkflowDocumentValidator.js.map +1 -1
  146. package/lib/esm/mastra/MastraMemory.js.map +1 -1
  147. package/lib/esm/mastra/MastraWorkflowCompiler.js +41 -9
  148. package/lib/esm/mastra/MastraWorkflowCompiler.js.map +1 -1
  149. package/lib/esm/nest/graph/GraphEngineController.js +19 -1
  150. package/lib/esm/nest/graph/GraphEngineController.js.map +1 -1
  151. package/lib/esm/nest/graph/GraphNodeCatalogueController.js +15 -1
  152. package/lib/esm/nest/graph/GraphNodeCatalogueController.js.map +1 -1
  153. package/lib/esm/nest/graph/GraphRunController.js +18 -1
  154. package/lib/esm/nest/graph/GraphRunController.js.map +1 -1
  155. package/lib/esm/nest/graph/GraphWorkflowController.js +35 -6
  156. package/lib/esm/nest/graph/GraphWorkflowController.js.map +1 -1
  157. package/lib/esm/node/comms/discord/node.js +375 -0
  158. package/lib/esm/node/comms/discord/node.js.map +1 -0
  159. package/lib/esm/node/comms/outlook/node.js +386 -0
  160. package/lib/esm/node/comms/outlook/node.js.map +1 -0
  161. package/lib/esm/node/comms/whatsapp/node.js +332 -0
  162. package/lib/esm/node/comms/whatsapp/node.js.map +1 -0
  163. package/lib/esm/node/data/aggregate/node.js +187 -0
  164. package/lib/esm/node/data/aggregate/node.js.map +1 -0
  165. package/lib/esm/node/data/compare-datasets/node.js +322 -0
  166. package/lib/esm/node/data/compare-datasets/node.js.map +1 -0
  167. package/lib/esm/node/data/item-lists/node.js +407 -0
  168. package/lib/esm/node/data/item-lists/node.js.map +1 -0
  169. package/lib/esm/node/data/remove-duplicates/node.js +132 -0
  170. package/lib/esm/node/data/remove-duplicates/node.js.map +1 -0
  171. package/lib/esm/node/data/summarize/node.js +146 -0
  172. package/lib/esm/node/data/summarize/node.js.map +1 -0
  173. package/lib/esm/node/data/support.js +5 -1
  174. package/lib/esm/node/data/support.js.map +1 -1
  175. package/lib/esm/node/data/transform-utils.js +702 -0
  176. package/lib/esm/node/data/transform-utils.js.map +1 -0
  177. package/lib/esm/node/index.js +110 -4
  178. package/lib/esm/node/index.js.map +1 -1
  179. package/lib/esm/node/io/confluence/node.js +244 -0
  180. package/lib/esm/node/io/confluence/node.js.map +1 -0
  181. package/lib/esm/node/io/convert-to-file/node.js +340 -0
  182. package/lib/esm/node/io/convert-to-file/node.js.map +1 -0
  183. package/lib/esm/node/io/file-support.js +299 -0
  184. package/lib/esm/node/io/file-support.js.map +1 -0
  185. package/lib/esm/node/io/google-calendar/node.js +350 -0
  186. package/lib/esm/node/io/google-calendar/node.js.map +1 -0
  187. package/lib/esm/node/io/google-docs/node.js +263 -0
  188. package/lib/esm/node/io/google-docs/node.js.map +1 -0
  189. package/lib/esm/node/io/html/node.js +266 -0
  190. package/lib/esm/node/io/html/node.js.map +1 -0
  191. package/lib/esm/node/io/html-extract/node.js +153 -0
  192. package/lib/esm/node/io/html-extract/node.js.map +1 -0
  193. package/lib/esm/node/io/html-support.js +206 -0
  194. package/lib/esm/node/io/html-support.js.map +1 -0
  195. package/lib/esm/node/io/jira/node.js +342 -0
  196. package/lib/esm/node/io/jira/node.js.map +1 -0
  197. package/lib/esm/node/io/markdown/node.js +217 -0
  198. package/lib/esm/node/io/markdown/node.js.map +1 -0
  199. package/lib/esm/node/io/microsoft-excel/node.js +252 -0
  200. package/lib/esm/node/io/microsoft-excel/node.js.map +1 -0
  201. package/lib/esm/node/io/microsoft-sharepoint/node.js +265 -0
  202. package/lib/esm/node/io/microsoft-sharepoint/node.js.map +1 -0
  203. package/lib/esm/node/io/read-binary-file/node.js +105 -0
  204. package/lib/esm/node/io/read-binary-file/node.js.map +1 -0
  205. package/lib/esm/node/io/read-binary-files/node.js +104 -0
  206. package/lib/esm/node/io/read-binary-files/node.js.map +1 -0
  207. package/lib/esm/node/io/write-binary-file/node.js +155 -0
  208. package/lib/esm/node/io/write-binary-file/node.js.map +1 -0
  209. package/lib/esm/node/io/xml/node.js +313 -0
  210. package/lib/esm/node/io/xml/node.js.map +1 -0
  211. package/lib/esm/node/manifests.js +58 -0
  212. package/lib/esm/node/manifests.js.map +1 -1
  213. package/lib/esm/node/storage/rabbitmq/node.js +243 -0
  214. package/lib/esm/node/storage/rabbitmq/node.js.map +1 -0
  215. package/lib/esm/node/triggers/error/node.js +99 -0
  216. package/lib/esm/node/triggers/error/node.js.map +1 -0
  217. package/lib/esm/node/triggers/postgres/node.js +235 -0
  218. package/lib/esm/node/triggers/postgres/node.js.map +1 -0
  219. package/lib/esm/node/triggers/rabbitmq/node.js +275 -0
  220. package/lib/esm/node/triggers/rabbitmq/node.js.map +1 -0
  221. package/lib/esm/node/triggers/redis/node.js +224 -0
  222. package/lib/esm/node/triggers/redis/node.js.map +1 -0
  223. package/lib/esm/node/triggers/sse/node.js +187 -0
  224. package/lib/esm/node/triggers/sse/node.js.map +1 -0
  225. package/lib/esm/node/triggers/support.js +99 -0
  226. package/lib/esm/node/triggers/support.js.map +1 -0
  227. package/lib/esm/node/triggers/workflow/node.js +184 -0
  228. package/lib/esm/node/triggers/workflow/node.js.map +1 -0
  229. package/lib/esm/shared/graph/catalog/GraphValueSchemaDerivation.js +20 -3
  230. package/lib/esm/shared/graph/catalog/GraphValueSchemaDerivation.js.map +1 -1
  231. package/lib/esm/workflows/boundary-value.workflow.js +34 -0
  232. package/lib/esm/workflows/boundary-value.workflow.js.map +1 -0
  233. package/lib/esm/workflows/builders.js +40 -0
  234. package/lib/esm/workflows/builders.js.map +1 -0
  235. package/lib/esm/workflows/chat-agent.workflow.js +36 -0
  236. package/lib/esm/workflows/chat-agent.workflow.js.map +1 -0
  237. package/lib/esm/workflows/error-boundary.workflow.js +50 -0
  238. package/lib/esm/workflows/error-boundary.workflow.js.map +1 -0
  239. package/lib/esm/workflows/event-map.workflow.js +33 -0
  240. package/lib/esm/workflows/event-map.workflow.js.map +1 -0
  241. package/lib/esm/workflows/foreach-break.workflow.js +54 -0
  242. package/lib/esm/workflows/foreach-break.workflow.js.map +1 -0
  243. package/lib/esm/workflows/human-approval.workflow.js +40 -0
  244. package/lib/esm/workflows/human-approval.workflow.js.map +1 -0
  245. package/lib/esm/workflows/if-switch.workflow.js +62 -0
  246. package/lib/esm/workflows/if-switch.workflow.js.map +1 -0
  247. package/lib/esm/workflows/index.js +116 -0
  248. package/lib/esm/workflows/index.js.map +1 -0
  249. package/lib/esm/workflows/loops-while-until.workflow.js +72 -0
  250. package/lib/esm/workflows/loops-while-until.workflow.js.map +1 -0
  251. package/lib/esm/workflows/manual-log.workflow.js +48 -0
  252. package/lib/esm/workflows/manual-log.workflow.js.map +1 -0
  253. package/lib/esm/workflows/schedule-code.workflow.js +38 -0
  254. package/lib/esm/workflows/schedule-code.workflow.js.map +1 -0
  255. package/lib/esm/workflows/types.js +2 -0
  256. package/lib/esm/workflows/types.js.map +1 -0
  257. package/lib/esm/workflows/value-templates.workflow.js +39 -0
  258. package/lib/esm/workflows/value-templates.workflow.js.map +1 -0
  259. package/lib/esm/workflows/webhook-form.workflow.js +44 -0
  260. package/lib/esm/workflows/webhook-form.workflow.js.map +1 -0
  261. package/lib/types/dagster/DagsterGraphExecutionBackend.d.cts +7 -0
  262. package/lib/types/dagster/DagsterGraphExecutionBackend.d.mts +7 -0
  263. package/lib/types/engine/execution/GraphCodeMode.d.cts +46 -0
  264. package/lib/types/engine/execution/GraphCodeMode.d.mts +46 -0
  265. package/lib/types/engine/execution/GraphExecutionBackend.d.cts +21 -0
  266. package/lib/types/engine/execution/GraphExecutionBackend.d.mts +21 -0
  267. package/lib/types/engine/execution/GraphExecutionEngine.d.cts +28 -3
  268. package/lib/types/engine/execution/GraphExecutionEngine.d.mts +28 -3
  269. package/lib/types/engine/validation/GraphNodeInstanceValidator.d.cts +11 -1
  270. package/lib/types/engine/validation/GraphNodeInstanceValidator.d.mts +11 -1
  271. package/lib/types/engine/validation/GraphWorkflowDocumentValidator.d.cts +7 -0
  272. package/lib/types/engine/validation/GraphWorkflowDocumentValidator.d.mts +7 -0
  273. package/lib/types/mastra/MastraWorkflowCompiler.d.cts +23 -8
  274. package/lib/types/mastra/MastraWorkflowCompiler.d.mts +23 -8
  275. package/lib/types/nest/graph/GraphEngineController.d.cts +19 -0
  276. package/lib/types/nest/graph/GraphEngineController.d.mts +19 -0
  277. package/lib/types/nest/graph/GraphNodeCatalogueController.d.cts +13 -0
  278. package/lib/types/nest/graph/GraphNodeCatalogueController.d.mts +13 -0
  279. package/lib/types/nest/graph/GraphRunController.d.cts +16 -0
  280. package/lib/types/nest/graph/GraphRunController.d.mts +16 -0
  281. package/lib/types/nest/graph/GraphWorkflowController.d.cts +26 -3
  282. package/lib/types/nest/graph/GraphWorkflowController.d.mts +26 -3
  283. package/lib/types/node/comms/discord/node.d.cts +67 -0
  284. package/lib/types/node/comms/discord/node.d.mts +67 -0
  285. package/lib/types/node/comms/outlook/node.d.cts +77 -0
  286. package/lib/types/node/comms/outlook/node.d.mts +77 -0
  287. package/lib/types/node/comms/whatsapp/node.d.cts +71 -0
  288. package/lib/types/node/comms/whatsapp/node.d.mts +71 -0
  289. package/lib/types/node/data/aggregate/node.d.cts +58 -0
  290. package/lib/types/node/data/aggregate/node.d.mts +58 -0
  291. package/lib/types/node/data/compare-datasets/node.d.cts +72 -0
  292. package/lib/types/node/data/compare-datasets/node.d.mts +72 -0
  293. package/lib/types/node/data/item-lists/node.d.cts +92 -0
  294. package/lib/types/node/data/item-lists/node.d.mts +92 -0
  295. package/lib/types/node/data/remove-duplicates/node.d.cts +47 -0
  296. package/lib/types/node/data/remove-duplicates/node.d.mts +47 -0
  297. package/lib/types/node/data/summarize/node.d.cts +44 -0
  298. package/lib/types/node/data/summarize/node.d.mts +44 -0
  299. package/lib/types/node/data/support.d.cts +13 -0
  300. package/lib/types/node/data/support.d.mts +13 -0
  301. package/lib/types/node/data/transform-utils.d.cts +236 -0
  302. package/lib/types/node/data/transform-utils.d.mts +236 -0
  303. package/lib/types/node/index.d.cts +54 -6
  304. package/lib/types/node/index.d.mts +54 -6
  305. package/lib/types/node/io/confluence/node.d.cts +49 -0
  306. package/lib/types/node/io/confluence/node.d.mts +49 -0
  307. package/lib/types/node/io/convert-to-file/node.d.cts +75 -0
  308. package/lib/types/node/io/convert-to-file/node.d.mts +75 -0
  309. package/lib/types/node/io/file-support.d.cts +118 -0
  310. package/lib/types/node/io/file-support.d.mts +118 -0
  311. package/lib/types/node/io/google-calendar/node.d.cts +65 -0
  312. package/lib/types/node/io/google-calendar/node.d.mts +65 -0
  313. package/lib/types/node/io/google-docs/node.d.cts +51 -0
  314. package/lib/types/node/io/google-docs/node.d.mts +51 -0
  315. package/lib/types/node/io/html/node.d.cts +68 -0
  316. package/lib/types/node/io/html/node.d.mts +68 -0
  317. package/lib/types/node/io/html-extract/node.d.cts +42 -0
  318. package/lib/types/node/io/html-extract/node.d.mts +42 -0
  319. package/lib/types/node/io/html-support.d.cts +69 -0
  320. package/lib/types/node/io/html-support.d.mts +69 -0
  321. package/lib/types/node/io/jira/node.d.cts +57 -0
  322. package/lib/types/node/io/jira/node.d.mts +57 -0
  323. package/lib/types/node/io/markdown/node.d.cts +61 -0
  324. package/lib/types/node/io/markdown/node.d.mts +61 -0
  325. package/lib/types/node/io/microsoft-excel/node.d.cts +45 -0
  326. package/lib/types/node/io/microsoft-excel/node.d.mts +45 -0
  327. package/lib/types/node/io/microsoft-sharepoint/node.d.cts +47 -0
  328. package/lib/types/node/io/microsoft-sharepoint/node.d.mts +47 -0
  329. package/lib/types/node/io/read-binary-file/node.d.cts +45 -0
  330. package/lib/types/node/io/read-binary-file/node.d.mts +45 -0
  331. package/lib/types/node/io/read-binary-files/node.d.cts +41 -0
  332. package/lib/types/node/io/read-binary-files/node.d.mts +41 -0
  333. package/lib/types/node/io/write-binary-file/node.d.cts +55 -0
  334. package/lib/types/node/io/write-binary-file/node.d.mts +55 -0
  335. package/lib/types/node/io/xml/node.d.cts +67 -0
  336. package/lib/types/node/io/xml/node.d.mts +67 -0
  337. package/lib/types/node/storage/rabbitmq/node.d.cts +55 -0
  338. package/lib/types/node/storage/rabbitmq/node.d.mts +55 -0
  339. package/lib/types/node/triggers/error/node.d.cts +34 -0
  340. package/lib/types/node/triggers/error/node.d.mts +34 -0
  341. package/lib/types/node/triggers/postgres/node.d.cts +54 -0
  342. package/lib/types/node/triggers/postgres/node.d.mts +54 -0
  343. package/lib/types/node/triggers/rabbitmq/node.d.cts +59 -0
  344. package/lib/types/node/triggers/rabbitmq/node.d.mts +59 -0
  345. package/lib/types/node/triggers/redis/node.d.cts +53 -0
  346. package/lib/types/node/triggers/redis/node.d.mts +53 -0
  347. package/lib/types/node/triggers/sse/node.d.cts +43 -0
  348. package/lib/types/node/triggers/sse/node.d.mts +43 -0
  349. package/lib/types/node/triggers/support.d.cts +41 -0
  350. package/lib/types/node/triggers/support.d.mts +41 -0
  351. package/lib/types/node/triggers/workflow/node.d.cts +46 -0
  352. package/lib/types/node/triggers/workflow/node.d.mts +46 -0
  353. package/lib/types/workflows/boundary-value.workflow.d.cts +3 -0
  354. package/lib/types/workflows/boundary-value.workflow.d.mts +3 -0
  355. package/lib/types/workflows/builders.d.cts +31 -0
  356. package/lib/types/workflows/builders.d.mts +31 -0
  357. package/lib/types/workflows/chat-agent.workflow.d.cts +3 -0
  358. package/lib/types/workflows/chat-agent.workflow.d.mts +3 -0
  359. package/lib/types/workflows/error-boundary.workflow.d.cts +3 -0
  360. package/lib/types/workflows/error-boundary.workflow.d.mts +3 -0
  361. package/lib/types/workflows/event-map.workflow.d.cts +3 -0
  362. package/lib/types/workflows/event-map.workflow.d.mts +3 -0
  363. package/lib/types/workflows/foreach-break.workflow.d.cts +3 -0
  364. package/lib/types/workflows/foreach-break.workflow.d.mts +3 -0
  365. package/lib/types/workflows/human-approval.workflow.d.cts +3 -0
  366. package/lib/types/workflows/human-approval.workflow.d.mts +3 -0
  367. package/lib/types/workflows/if-switch.workflow.d.cts +3 -0
  368. package/lib/types/workflows/if-switch.workflow.d.mts +3 -0
  369. package/lib/types/workflows/index.d.cts +37 -0
  370. package/lib/types/workflows/index.d.mts +37 -0
  371. package/lib/types/workflows/loops-while-until.workflow.d.cts +3 -0
  372. package/lib/types/workflows/loops-while-until.workflow.d.mts +3 -0
  373. package/lib/types/workflows/manual-log.workflow.d.cts +3 -0
  374. package/lib/types/workflows/manual-log.workflow.d.mts +3 -0
  375. package/lib/types/workflows/schedule-code.workflow.d.cts +3 -0
  376. package/lib/types/workflows/schedule-code.workflow.d.mts +3 -0
  377. package/lib/types/workflows/types.d.cts +32 -0
  378. package/lib/types/workflows/types.d.mts +32 -0
  379. package/lib/types/workflows/value-templates.workflow.d.cts +16 -0
  380. package/lib/types/workflows/value-templates.workflow.d.mts +16 -0
  381. package/lib/types/workflows/webhook-form.workflow.d.cts +3 -0
  382. package/lib/types/workflows/webhook-form.workflow.d.mts +3 -0
  383. package/package.json +247 -25
package/dist/as-graph.js CHANGED
@@ -1,2 +1,2 @@
1
- import{logParameterRegistry as e,Logging as t,LoggedEnvironment as o}from"@decaf-ts/logging";import{RenderingEngine as r,uimodel as n,uielement as i,uilistprop as a,uilistmodel as s,hidden as d}from"@decaf-ts/ui-decorators";import{Metadata as l,Decoration as c,apply as p,metadata as u,propMetadata as h,description as g,prop as f,DefaultFlavour as y}from"@decaf-ts/decoration";import{ValidationKeys as m,Model as b,required as w,type as v,date as x,model as I,option as A,min as _,max as O}from"@decaf-ts/decorator-validation";import{ValidationError as E,InternalError as k,NotFoundError as S}from"@decaf-ts/db-decorators";import{__decorate as R,__metadata as C}from"tslib";import{pk as N,column as T,index as D,table as P,BaseModel as j,noValidateOnUpdate as $,ForbiddenError as L,Context as M,repository as G,Repository as U,AuthorizationError as F,service as B,Service as H,Condition as q,OrderDirection as W,ClientBasedService as K,Adapter as V,ModelService as z}from"@decaf-ts/core";import Q from"isolated-vm";import*as J from"acorn";import*as X from"acorn-walk";import*as Y from"typescript";import{randomUUID as Z,createHash as ee}from"node:crypto";import{dirname as te,resolve as oe,relative as re,sep as ne,isAbsolute as ie}from"node:path";import{homedir as ae}from"node:os";import{realpathSync as se}from"node:fs";import{realpath as de,readFile as le,mkdir as ce,appendFile as pe,writeFile as ue}from"node:fs/promises";import{TypeORMAdapter as he}from"@decaf-ts/for-typeorm";import{RedisAdapter as ge}from"@decaf-ts/integrations/redis";import{collectToBuffer as fe}from"@decaf-ts/integrations/blob";import{S3BlobStoreService as ye}from"@decaf-ts/integrations/blob/s3";import{bootWithoutEnvironment as me}from"@decaf-ts/integrations/shared/http";import{GcsBlobStoreService as be}from"@decaf-ts/integrations/blob/gcp";import{AzureBlobStoreService as we}from"@decaf-ts/integrations/blob/azure";import{SlackService as ve}from"@decaf-ts/integrations/comms/slack";import{TelegramService as xe}from"@decaf-ts/integrations/comms/telegram";import{TeamsService as Ie}from"@decaf-ts/integrations/comms/teams";import{GmailService as Ae}from"@decaf-ts/integrations/comms/gmail";import{EmailService as _e}from"@decaf-ts/integrations/comms/email";import{GoogleSheetsService as Oe}from"@decaf-ts/integrations/io/google-sheets";import{AirtableService as Ee}from"@decaf-ts/integrations/io/airtable";import{SpreadsheetService as ke}from"@decaf-ts/integrations/io/spreadsheet";import{GraphqlService as Se}from"@decaf-ts/integrations/io/graphql";import{GithubService as Re}from"@decaf-ts/integrations/devops/github";import{GitlabService as Ce}from"@decaf-ts/integrations/devops/gitlab";import{CryptoService as Ne}from"@decaf-ts/crypto/integration/services/crypto";import{sign as Te,verify as De,decodeJwtPayload as Pe}from"@decaf-ts/crypto/jwt";import{exec as je}from"node:child_process";import{Ssh2SftpService as $e}from"@decaf-ts/integrations/sftp";import"@mastra/core/storage";import"@mastra/memory";import"@mastra/libsql";import"@mastra/pg";var Le,Me;m.REQUIRED,m.MIN,m.MIN_LENGTH,m.MAX,m.MAX_LENGTH,m.PATTERN,m.URL,m.STEP,m.DATE,m.EMAIL,m.PASSWORD,m.EQUALS,m.DIFF,m.LESS_THAN,m.LESS_THAN_OR_EQUAL,m.GREATER_THAN,m.GREATER_THAN_OR_EQUAL,(e=>{e.GRAPH="graph",e.NODE="graph.node",e.EDGE="graph.edge",e.PORT="graph.port",e.STATE="graph.state"})(Le||(Le={})),(e=>{e.INPUT="input",e.OUTPUT="output",e.CONNECTION="connection"})(Me||(Me={}));const Ge={};function Ue(e,t={}){let o=e.width??96,r=e.height??96;for(const n of e.sizeRules??[]){if("parameterCount"!==n.type)continue;const e=t[n.parameter]??0;e>0&&("width"===n.dimension?o+=e*n.perItem:r+=e*n.perItem)}return{width:o,height:r}}function Fe(e,t){Ge[e]=t}function Be(e,t,o){const r=t?Ge[t]:void 0;return r?.color?r.color:e||"#64748b"}function He(e,t,o){const r=t?Ge[t]:void 0;return r?.icon?r.icon:e||"ti-pointer"}const qe=["skip","passThroughFirstInput","emitDefaults"];function We(e){return qe.includes(e)}var Ke,Ve,ze,Qe;(e=>{e.PENDING="pending",e.PLANNING="planning",e.RUNNING="running",e.SUCCEEDED="succeeded",e.FAILED="failed",e.SKIPPED="skipped",e.CANCELLED="cancelled",e.CACHED="cached"})(Ke||(Ke={})),(e=>{e.IDLE="idle",e.RUNNING="running",e.BLOCKED="blocked",e.SUCCEEDED="succeeded",e.FAILED="failed",e.SKIPPED="skipped"})(Ve||(Ve={})),(e=>{e.NODE_ID="nodeId",e.WORKFLOW_ID="workflowId",e.RUN_ID="runId",e.USER="user",e.ROLES="roles",e.NAMESPACES="namespaces",e.ORGANIZATION="organization",e.IP="ip"})(ze||(ze={})),(e=>{e.WORKFLOW_STARTED="workflow.started",e.WORKFLOW_PLANNED="workflow.planned",e.WORKFLOW_COMPLETED="workflow.completed",e.WORKFLOW_FAILED="workflow.failed",e.WORKFLOW_CANCELLED="workflow.cancelled",e.WORKFLOW_SUSPENDED="workflow.suspended",e.WORKFLOW_RESUMED="workflow.resumed",e.NODE_QUEUED="node.queued",e.NODE_STARTED="node.started",e.NODE_OUTPUT="node.output",e.NODE_COMPLETED="node.completed",e.NODE_FAILED="node.failed",e.NODE_SKIPPED="node.skipped",e.NODE_CACHE_HIT="node.cacheHit",e.NODE_PINNED="node.pinned",e.NODE_UNPINNED="node.unpinned",e.NODE_STATE_CHANGED="node.stateChanged",e.EDGE_VALUE_ROUTED="edge.valueRouted",e.EDGE_STATE_CHANGED="edge.stateChanged",e.GRAPH_RUN_LOG="graph.run.log",e.LOOP_STARTED="loop.started",e.LOOP_ITERATION_STARTED="loop.iteration.started",e.LOOP_ITERATION_COMPLETED="loop.iteration.completed",e.LOOP_CONDITION_EVALUATED="loop.condition.evaluated",e.LOOP_COMPLETED="loop.completed",e.LOOP_LIMIT_REACHED="loop.limitReached",e.VALIDATION_STARTED="validation.started",e.VALIDATION_FAILED="validation.failed",e.VALIDATION_COMPLETED="validation.completed",e.STORE_READ="store.read",e.STORE_WRITE="store.write",e.STORE_DELETE="store.delete"})(Qe||(Qe={}));const Je={maxRequestBytes:4e6,maxConcurrentRuns:32,maxEventsPerRun:1e4,maxEventPayloadBytes:256e3,executionTimeoutMs:6e5,eventReplayWindowMs:3e5},Xe=[Qe.WORKFLOW_COMPLETED,Qe.WORKFLOW_FAILED,Qe.WORKFLOW_CANCELLED];function Ye(e){return Xe.includes(e)}function Ze(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function et(e){if(!e||"object"!=typeof e)return;const t=e.auth;return t&&"object"==typeof t&&!Array.isArray(t)?(e=>{if(!e)return;const t=Ze(e.namespaces),o=Ze(e.roles);if(!t&&!o)return;const r={};return t&&(r.namespaces=t),o&&(r.roles=o),r})(t):void 0}function tt(e){const t=l.constr(e);if("function"==typeof t)return t;const o=e.constructor;return"function"==typeof o?o:e}function ot(e){if(null!=e)return"string"==typeof e?e:e+""}function rt(e,t,o){return ot(e?.props?.label??e?.props?.name)??ot(t?.name)??o??""}function nt(e,t,o){const r=st(e,t);if(r?.model&&"function"==typeof r.model&&b.isModel(r.model))return r.model;const n=l.type(e,t);if("function"==typeof n&&b.isModel(n))return n;const i=l.getPropDesignTypes?.(e,t)?.designTypes||[];for(const e of i)if("function"==typeof e&&b.isModel(e))return e;const a=o?.[m.TYPE]?.customTypes||[];for(const e of a)if("function"==typeof e&&b.isModel(e))return e}function it(e,t){const o=[t,e.path??e.property].filter(Boolean).join(".");return{...e,path:o,children:e.children?.map(e=>it(e,o))}}function at(e){const t=tt(e);return l.get(t,Le.NODE)}function st(e,t){const o=tt(e);return l.get(o,l.key(Le.PORT,t+""))}function dt(e,t,o,r=new Set){const n=st(e,t);if(!n?.schema)return;const i=nt(e,t,l.validationFor(e,t));if(!i)return;if(r.has(i))return[];const a=new Set(r);return a.add(e),a.add(i),pt(i,a).filter(e=>e.direction===o)}function lt(e,t,o=new Set){const r=st(e,t);if(!r)return;const n=l.validationFor(e,t),i=nt(e,t,n);if(r.schema&&i)return;const a=b.uiElementOf(e,t)||void 0,s=b.uiDecorationOf(e,t,"uiprop"),d=l.type(e,t),c=ot(r.type??n?.[m.TYPE]?.customTypes?.[0]?.name??a?.props?.type??s?.type??d?.name),p=(r.expand||i&&!o.has(i))&&i?(()=>{const r=new Set(o);return r.add(e),r.add(i),pt(i,r).map(e=>it(e,t))})():void 0;return{property:t,path:t,direction:r.direction,name:t,label:rt(a,s,t),type:c?.toLowerCase(),required:!!n?.[m.REQUIRED],hidden:!!b.uiIsHidden(e,t),designType:d?.name,element:a,prop:s,validation:n,graph:r,connectionRules:r.connectionRules,composite:!!p?.length,children:p,model:i?.name}}function ct(e){return pt(tt(e))}function pt(e,t=new Set){const o=l.properties(e)||[],r=[];for(const n of o){const o=n+"",i=st(e,o);if(i?.schema){const n=dt(e,o,i.direction,t);if(n){r.push(...n);continue}}const a=lt(e,o,t);a&&r.push(a)}return r}function ut(e){return e.flatMap(e=>e.children&&e.children.length?ut(e.children):[e])}function ht(e){const t=tt(e),o=b.uiModelOf(t),r=at(t)||{},n=o?.tag||t.name,i=ct(t),a=((e,t)=>{const o=t.portGroups||[],r=new Map(o.map(e=>[e.property,e])),n=[],i=l.properties(e)||[];for(const t of i){const o=t+"",i=st(e,o);if(!i?.schema)continue;if(!nt(e,o,l.validationFor(e,o)))continue;const a=r.get(o);n.push(a?{...a,toggle:a.toggle??"all"}:{property:o,toggle:"all"})}for(const e of o)n.some(t=>t.property===e.property)||n.push(e);return n.length?n:void 0})(t,r),s=r.namespaces?.length?r.namespaces:(e=>{if(null==e)return[];let t,o=e;try{o=l.constr(e)}catch{o=e}try{t=l.get(o,"auth-namespace")}catch{t=void 0}return Ze(t)??[]})(t),d=s.length?s:void 0;return{name:t.name,tag:n,kind:r.kind||n,category:r.category,color:r.color,effectiveColor:Be(r.color,r.category),group:r.group,height:r.height,icon:r.icon,effectiveIcon:He(r.icon,r.category),labels:r.labels||[],maxChildren:r.maxChildren,minWidth:r.minWidth,width:r.width,shape:r.shape,cornerRadius:r.cornerRadius,sizeRules:r.sizeRules,props:o?.props,ui:o,graph:r,ports:i,portGroups:a,namespaces:d}}const gt=new Set,ft=new Set;function yt(e,t,o){return c.for(Le.NODE).define({decorator:(e,t,o)=>{const r={kind:t?.kind||e,...t};return t=>{const i=p(n(e,o),u(Le.NODE,r))(t);var a;return a=t,gt.add(a),i}},args:[e,t,o]}).apply()}function mt(e,t){return c.for(Le.PORT).define({decorator:(e,t)=>(o,r)=>{const n={direction:e,...t};return p(h(l.key(Le.PORT,r),n))(o,r)},args:[e,t]}).apply()}function bt(e){return mt(Me.INPUT,{...e,schema:!0})}function wt(e){return mt(Me.OUTPUT,{...e,schema:!0})}function vt(e){return mt(Me.CONNECTION,e)}r.prototype.renderAsNode=(e,t,...o)=>ht(e),l.nodes=(()=>[...gt]).bind(l),l.workflows=(()=>[...ft]).bind(l);const xt=["__proto__","prototype","constructor"];function It(e){return xt.includes(e)}function At(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function _t(e){return null===e||"string"==typeof e||"number"==typeof e&&Number.isFinite(e)||"boolean"==typeof e}function Ot(e){return!!_t(e)||(Array.isArray(e)?e.every(e=>Ot(e)):!!At(e)&&Reflect.ownKeys(e).every(t=>"string"==typeof t&&!It(t)&&Ot(e[t])))}function Et(e){if(void 0===e)return!1;if("number"==typeof e)return Number.isFinite(e);if("function"==typeof e)return!1;if(Ot(e))return!0;if(Array.isArray(e))return e.every(e=>Et(e));if(At(e)){const t=Reflect.ownKeys(e);for(const o of t){if("string"!=typeof o)return!1;if(It(o))return!1;if(!Et(e[o]))return!1}return!0}return!1}function kt(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>kt(e));const t={};for(const[o,r]of Object.entries(e))t[o]=kt(r);return t}const St={string:"string",char:"string",text:"string",textarea:"string",radio:"string",select:"string",number:"number",integer:"number",float:"number",double:"number",decimal:"number",boolean:"boolean",bool:"boolean",checkbox:"boolean",array:"array",list:"array",set:"array",object:"object",model:"model",any:"any",unknown:"any",enum:"enum"},Rt={date:"date",datetime:"date-time","date-time":"date-time",duration:"duration"};function Ct(e){return e?St[e.toLowerCase()]??"any":"any"}function Nt(e,t){const o=e[t];if(o&&"object"==typeof o)return o.value}function Tt(e,t){const o=Nt(e,t);return"number"==typeof o&&Number.isFinite(o)?o:void 0}function Dt(e,t,o){const r=e??{},n=(e=>{const t=Nt(e,m.ENUM);if(Array.isArray(t)&&t.every(_t))return t})(r);if(n)return{type:"enum",values:n};const i=(e=>{const t=e[m.TYPE],o=t?.customTypes?.[0],r="function"==typeof o?o.name:o?.name;if(r)return r})(r)??o;return i?{type:"model",name:i}:((e,t)=>{switch(Ct(e)){case"string":{const t=(e=>{if(e)return Rt[e.toLowerCase()]})(e);return void 0!==t?{type:"string",format:t}:{type:"string"}}case"number":{const o={type:"number"};e&&"integer"===e.toLowerCase()&&(o.integer=!0);const r=Tt(t,m.MIN),n=Tt(t,m.MAX);return void 0!==r&&(o.min=r),void 0!==n&&(o.max=n),o}case"boolean":return{type:"boolean"};case"array":return((e,t)=>{const o={type:"array",items:Pt(e,t)},r=Tt(e,m.MIN),n=Tt(e,m.MAX);return void 0!==r&&(o.minItems=r),void 0!==n&&(o.maxItems=n),o})(t,e);case"object":return{type:"object",properties:{}};case"enum":return{type:"enum",values:[]};case"model":return{type:"model",name:e??"any"};default:return{type:"any"}}})(t,r)}function Pt(e,t){if((e=>{const t=e[m.LIST];return!!t?.clazz?.length})(e))return{type:"model",name:jt(e)};const o=Nt(e,m.TYPE);if("string"==typeof o){const e=Ct(o);return"model"===e?{type:"model",name:o}:{type:e}}if(t&&"array"!==t){const e=Ct(t);return"model"===e?{type:"model",name:t}:{type:e}}return{type:"any"}}function jt(e){const t=e[m.LIST],o=t?.clazz?.[0];if("function"!=typeof o)return"any";if(o.name)return o.name;try{const e=o();if("function"==typeof e&&e.name)return e.name}catch{return"any"}return"any"}function $t(e){return"workflow"===e.scope}function Lt(e){return"node"===e.scope}function Mt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"workflow"===t.scope?"string"==typeof t.port&&2===Reflect.ownKeys(t).length:"node"===t.scope&&"string"==typeof t.nodeId&&"string"==typeof t.port&&3===Reflect.ownKeys(t).length}function Gt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e.mode;if("edge"===t)return 1===Reflect.ownKeys(e).length;if("literal"===t){const t=e.value;return 2===Object.keys(e).length&&Ot(t)}return"expression"===t&&2===Object.keys(e).length&&"string"==typeof e.expression}const Ut=["any","string","number","boolean","array","object","enum","model"];function Ft(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&(e=>Ut.includes(e))(e.type)}function Bt(e,t={seen:[]}){if(t.seen.includes(e))throw new E(`Document '${(e=>{const t=e?.id;return"string"==typeof t?t:"<unnamed document>"})(e)}' contains a loop body that references itself (cyclic document)`);if("string"!=typeof e.id||!e.id)throw new E("Document 'id' is required and must be a non-empty string");if("string"!=typeof e.name||!e.name)throw new E("Document 'name' is required and must be a non-empty string");const o=new Set;for(const t of[...e.inputs,...e.outputs]){if("string"!=typeof t.id||!t.id)throw new E("Workflow port 'id' is required and must be a non-empty string");if(o.has(t.id))throw new E(`Workflow port '${t.id}' is declared more than once; workflow port ids must be unique`);if(void 0!==t.schema&&!Ft(t.schema))throw new E(`Workflow port '${t.id}' schema must be a valid GraphValueSchema`);o.add(t.id)}const r={seen:[...t.seen,e]},n=new Set;for(const t of e.nodes)Ht(t,n);for(const t of e.nodes)t.loop&&qt(t,t.loop,r),t.errorBoundary&&Wt(t,t.errorBoundary,r);const i=new Set;for(const t of e.edges)Vt(t,i);for(const t of e.edges)zt(t.source,0,o,n,`Edge '${t.id}' source`),zt(t.target,0,o,n,`Edge '${t.id}' target`);if(void 0!==e.settings&&!Et(e.settings))throw new E("Document settings must be JSON-safe (a map of JSON-safe values)");if(void 0!==e.metadata&&!Et(e.metadata))throw new E("Document metadata must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed");if(void 0!==e.ui&&!Et(e.ui))throw new E("Document ui must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed")}function Ht(e,t){if("string"!=typeof e.id||!e.id)throw new E("Node 'id' is required and must be a non-empty string");if(t.has(e.id))throw new E(`Node id '${e.id}' is declared more than once; node ids must be unique`);if("string"!=typeof e.kind||!e.kind)throw new E(`Node '${e.id}' must declare a non-empty string 'kind'`);if(void 0===e.parameters||null===e.parameters)throw new E(`Node '${e.id}' parameters must be present (an empty object when there are none)`);if(t.add(e.id),e.inputBindings)for(const[t,o]of Object.entries(e.inputBindings)){if(It(t))throw new E(`Node '${e.id}' input binding key '${t}' is not allowed (unsafe prototype-pollutant key)`);if(!Gt(o))throw new E(`Node '${e.id}' input binding for '${t}' must be a valid GraphInputBinding (edge, literal, or expression)`);if("literal"===o.mode&&!Et(o.value))throw new E(`Node '${e.id}' literal binding for '${t}' must contain JSON-safe values`);if("expression"===o.mode&&!o.expression)throw new E(`Node '${e.id}' expression binding for '${t}' must contain a non-empty expression`)}if(e.outputBindings)for(const[t,o]of Object.entries(e.outputBindings)){if(It(t))throw new E(`Node '${e.id}' output binding key '${t}' is not allowed (unsafe prototype-pollutant key)`);if(!o||"object"!=typeof o||Array.isArray(o))throw new E(`Node '${e.id}' output binding for '${t}' must be an object with enabled and alias settings`)}if(!Et(e.parameters))throw new E(`Node '${e.id}' parameters must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`);if(void 0!==e.state){if(!e.state||"object"!=typeof e.state||Array.isArray(e.state))throw new E(`Node '${e.id}' state must be an object when present`);if(!Et(e.state))throw new E(`Node '${e.id}' state must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`)}}function qt(e,t,o){if(!t.body||"object"!=typeof t.body)throw new E(`Node '${e.id}' loop configuration requires a body document`);if(Bt(t.body,o),!(void 0===t.maxIterations||Number.isFinite(t.maxIterations)&&t.maxIterations>0))throw new E(`Node '${e.id}' loop maxIterations must be a positive number`);if(void 0!==t.timeoutMs&&("number"!=typeof t.timeoutMs||0>=t.timeoutMs))throw new E(`Node '${e.id}' loop timeoutMs must be a positive number in milliseconds`);if(void 0!==t.concurrency&&("number"!=typeof t.concurrency||0>=t.concurrency))throw new E(`Node '${e.id}' loop concurrency must be a positive number`);for(const o of[t.inputMappings,t.outputMappings])if(o)for(const[t,r]of Object.entries(o)){if(It(t))throw new E(`Node '${e.id}' loop mapping key '${t}' is not allowed (unsafe prototype-pollutant key)`);Kt(r,e.id,t)}}function Wt(e,t,o){if(!t.try||"object"!=typeof t.try)throw new E(`Node '${e.id}' error-boundary configuration requires a try body document`);Bt(t.try,o);for(const[r,n]of[["catch",t.catch],["finally",t.finally]])if(void 0!==n){if(!n||"object"!=typeof n)throw new E(`Node '${e.id}' error-boundary ${r} body must be a document`);Bt(n,o)}}function Kt(e,t,o){if(!e||"object"!=typeof e)throw new E(`Node '${t}' loop mapping '${o}' must reference a workflow port, node port, literal, or expression`);switch(e.source){case"workflow":if("string"!=typeof e.port||!e.port)throw new E(`Node '${t}' loop mapping '${o}' referencing a workflow must reference a port identifier`);break;case"node":if("string"!=typeof e.nodeId||!e.nodeId||"string"!=typeof e.port||!e.port)throw new E(`Node '${t}' loop mapping '${o}' referencing a node must reference a node id and a port`);break;case"literal":if(!Et(e.value))throw new E(`Node '${t}' loop mapping '${o}' literal references must be JSON-safe values`);break;case"expression":if("string"!=typeof e.expression||!e.expression)throw new E(`Node '${t}' loop mapping '${o}' expression references must be non-empty expressions`);break;default:throw new E(`Node '${t}' loop mapping '${o}' must use a workflow, node, literal, or expression reference source`)}}function Vt(e,t){if("string"!=typeof e.id||!e.id)throw new E("Edge 'id' is required and must be a non-empty string");if(t.has(e.id))throw new E(`Edge id '${e.id}' is declared more than once; edge ids must be unique`);if(!Mt(e.source))throw new E(`Edge '${e.id}' source endpoint is not a valid GraphEndpoint`);if(!Mt(e.target))throw new E(`Edge '${e.id}' target endpoint is not a valid GraphEndpoint`);if("data"!==e.type&&"connection"!==e.type)throw new E(`Edge '${e.id}' type '${e.type+""}' is not a valid edge type (data or connection are allowed)`);if(t.add(e.id),!Et(e))throw new E(`Edge '${e.id}' contains values that are not JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`)}function zt(e,t,o,r,n){if($t(e)){if(!o.has(e.port))throw new E(`${n} references workflow port '${e.port}' which is not declared on the document`)}else if(Lt(e)){if(!r.has(e.nodeId))throw new E(`${n} references node '${e.nodeId}' which is not part of the document`);if("string"!=typeof e.port||!e.port)throw new E(n+" node endpoints must reference a non-empty port identifier")}}const Qt=["expression","template"],Jt=["javascript","typescript","json","text"];function Xt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return!(!(e=>Qt.includes(e))(t.mode)||"string"!=typeof t.expression||!t.expression||void 0!==t.language&&!(e=>Jt.includes(e))(t.language)||void 0!==t.metadata&&!Ot(t.metadata))}function Yt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.id&&"string"==typeof t.name&&Array.isArray(t.inputs)&&Array.isArray(t.outputs)&&Array.isArray(t.nodes)&&Array.isArray(t.edges)}function Zt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.type&&(void 0===t.required||"boolean"==typeof t.required)&&(void 0===t.displayName||"string"==typeof t.displayName)&&(void 0===t.allowedOperations||Array.isArray(t.allowedOperations)&&t.allowedOperations.every(e=>"string"==typeof e))}const eo=["trigger","loop","branching","stateful","retryable","cancellable","parallel","resource"];function to(e){return eo.includes(e)}function oo(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.kind&&"object"==typeof t.display&&Array.isArray(t.inputs)&&Array.isArray(t.outputs)&&Array.isArray(t.parameters)}function ro(e){if(!oo(e))throw new E("Graph node manifest does not conform to the required shape");if(!Et(e))throw new E("Graph node manifest contains values that are not JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys or unsafe prototype keys are not allowed on manifests")}function no(e){return ro(e),kt(e)}function io(e){if(!oo(e))throw new E("Serialized graph node manifest does not conform to the required shape");return kt(e)}const ao=["loadOptions","listSearch","resourceLocator","resourceMapping","validateParameter","action"];function so(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.name&&(e=>ao.includes(e))(t.type)&&(void 0===t.parameter||"string"==typeof t.parameter)&&(void 0===t.dependencies||Array.isArray(t.dependencies)&&t.dependencies.every(e=>"string"==typeof e))}function lo(e){const t=e.element?.props?.value,o=t??e.prop?.value??e.validation?.defaultValue;if(void 0!==o&&"function"!=typeof o&&Et(o))try{return JSON.parse(JSON.stringify(o))}catch{return}}function co(e){if(e.type&&e.type in Rt)return{type:"string",format:Rt[e.type]};const t=(e=>{for(const t of[e.graph?.type,e.element?.props?.type,e.prop?.type])if("string"==typeof t&&"any"!==Ct(t))return t})(e);return t?Dt((e=>{if(!e)return;const t=Object.entries(e).filter(([e])=>e!==m.TYPE);return Object.fromEntries(t)})(e.validation),t):Dt(e.validation,e.type,e.model)}function po(e){const t={};for(const[o,r]of Object.entries(e.graph?.metadata??{}))Et(r)&&(t[o]=JSON.parse(JSON.stringify(r)));return Object.keys(t).length?t:void 0}function uo(e){switch(e){case"output":return"output";case"connection":return"connection";default:return"input"}}function ho(e){const t=e.graph?.handle;return"connection"!==e.direction&&"string"==typeof t&&t?t:e.path??e.property}const go=["top","bottom","left","right"],fo=["start","center","end"];function yo(e,t){const o={id:ho(e),label:e.label,direction:uo(e.direction),schema:co(e)};e.required&&(o.required=!0),e.hidden&&(o.hidden=!0);const r=e.graph?.category;"string"==typeof r&&(o.category=r);const n=(e=>{const t=e.graph?.zone;if(!t||"object"!=typeof t||Array.isArray(t))return;const o=t,r=o.side;if("string"!=typeof r||!go.includes(r))return;const n={side:r},i=o.align;"string"==typeof i&&fo.includes(i)&&(n.align=i);const a=o.order;return"number"==typeof a&&Number.isFinite(a)&&(n.order=a),n})(e);n&&(o.zone=n),!0===e.graph?.userControlled&&(o.configurable=!0);const i=e.graph?.handle;"string"==typeof i&&(o.handle=i);const a=Eo(e.graph?.connectionRules)??t;a&&(o.connectionPolicy=a);const s=(e=>{const t=e.element;if(!t||!Et(t))return;const o=t.tag;if("string"!=typeof o)return;const r=t.props;return{tag:o,serialize:!0===t.serialize,props:r&&"object"==typeof r&&!Array.isArray(r)?kt(r):{}}})(e);s&&(o.element=s);const d=po(e);return d&&(o.metadata=d),o}function mo(e){const t={type:"string",id:ho(e),label:e.label,required:e.required};if(e.hidden)return((e,t)=>{const o={...t,type:"hidden"},r=lo(e);return void 0!==r&&(o.defaultValue=r),bo(o)})(e,t);const o=lo(e);void 0!==o&&(t.defaultValue=o);const r=(e=>{const t=e.element?.props?.placeholder??e.prop?.placeholder;return"string"==typeof t?t:void 0})(e);r&&(t.placeholder=r);const n=po(e);if(n&&(t.metadata=n),(e=>{const t=xo(e);return"code"===t||"code-editor"===t})(e))return bo({...t,type:"code",language:_o(e)});const i=co(e);switch(i.type){case"number":{const o={...t,type:"number",integer:i.integer,min:i.min,max:i.max},r=vo(e.validation?.step);return void 0!==r&&(o.step=r),bo(o)}case"boolean":return bo({...t,type:"boolean"});case"enum":return bo({...t,type:"options",options:i.values.map(e=>({value:e,label:e+""}))});case"array":{const e={...t,type:"collection"};return void 0!==i.maxItems&&(e.maxItems=i.maxItems),bo(e)}case"object":case"model":return bo({...t,type:"object"});default:return bo({...t,type:"string",multiline:!!Io(e)||void 0,pattern:wo(e.validation?.pattern),minLength:vo(e.validation?.minlength),maxLength:vo(e.validation?.maxlength)})}}function bo(e){const t=e;for(const e of Object.keys(t))void 0===t[e]&&delete t[e];return e}function wo(e){const t=e?.value;return"string"==typeof t?t:void 0}function vo(e){const t=e?.value;return"number"==typeof t&&Number.isFinite(t)?t:void 0}function xo(e){const t=e.element?.tag;return"string"==typeof t&&t?t:void 0}function Io(e){return"textarea"===xo(e)||"textarea"===(e=>{const t=e.element?.props?.type;return"string"==typeof t?t:void 0})(e)}const Ao=["javascript","typescript","json","text"];function _o(e){const t=e.element?.props?.language;return"string"==typeof t&&Ao.includes(t)?t:"javascript"}function Oo(e,t){const o={name:t.name??e.name},r=e.graph?.metadata?.description??void 0;"string"==typeof r&&r&&(o.description=r);const n=t.category??e.category;"string"==typeof n&&n&&(o.category=n),"string"==typeof e.group&&e.group&&(o.group=e.group),Array.isArray(e.labels)&&(o.labels=e.labels.slice());const i=((e,t)=>{if(t.icon)return t.icon;const o=e.effectiveIcon??e.icon;return"string"==typeof o?{type:"catalogue",name:o}:{type:"catalogue",name:"ph:circuitry"}})(e,t);return i&&(o.icon=i),"string"==typeof e.color&&e.color&&(o.color=e.color),"number"==typeof e.width&&Number.isFinite(e.width)&&(o.width=e.width),"number"==typeof e.minWidth&&Number.isFinite(e.minWidth)&&(o.minWidth=e.minWidth),"number"==typeof e.height&&Number.isFinite(e.height)&&(o.height=e.height),"string"==typeof e.shape&&(o.shape=e.shape),"number"==typeof e.cornerRadius&&Number.isFinite(e.cornerRadius)&&(o.cornerRadius=e.cornerRadius),Array.isArray(e.sizeRules)&&(o.sizeRules=e.sizeRules),o}function Eo(e){if(!e)return;const t=e,o={};"boolean"==typeof t.allowSelf&&(o.allowSelf=t.allowSelf),"boolean"==typeof t.allowMultiple&&(o.allowMultiple=t.allowMultiple);const r=t.allowedKinds;Array.isArray(r)&&r.every(e=>"string"==typeof e)&&(o.allowedNodeKinds=r);const n=t.blockedKinds;Array.isArray(n)&&n.every(e=>"string"==typeof e)&&(o.blockedNodeKinds=n);const i=t.allowedPortCategories;Array.isArray(i)&&i.every(e=>"string"==typeof e)&&(o.allowedPortCategories=i);const a=t.maxConnections;return"number"==typeof a&&Number.isFinite(a)&&(o.maxConnections=a),Object.keys(o).length?o:void 0}function ko(e,t={}){const o="function"==typeof e?e:e.constructor;if(!at(o))throw new E(`Node '${o?.name??e+""}' is not decorated with @node and cannot produce a manifest`);const r=ht(o),n=ut(ct(o)),i=[],a=[],s=[],d=[],l=Eo(r.graph?.connectionRules);for(const e of n)("connection"===e.direction?s:"output"===e.direction?a:i).push(yo(e,l)),"input"===e.direction&&d.push(mo(e));const c={kind:t.kind??r.kind??r.name,display:Oo(r,t),inputs:i,outputs:a,parameters:d};return s.length&&(c.connections=s),r.namespaces?.length&&(c.namespaces=r.namespaces.slice()),ro(c),c}var So,Ro;(e=>{e.READABILITY="readability",e.COMPACTNESS="compactness",e.BALANCED="balanced"})(So||(So={})),(e=>{e.TIGHT="tight",e.NORMAL="normal",e.COMFORTABLE="comfortable"})(Ro||(Ro={})),Ro.TIGHT,Ro.NORMAL,Ro.COMFORTABLE,So.READABILITY,Ro.COMFORTABLE,So.COMPACTNESS,Ro.TIGHT,So.BALANCED,Ro.NORMAL;let Co=class extends j{constructor(e){super(e)}};R([N({type:String,generated:!1}),g("Unique graph run id"),i("ngx-decaf-crud-field",{label:"graph.run.id.label",readonly:!0}),C("design:type",String)],Co.prototype,"runId",void 0),R([T(),w(),D(),g("Workflow document id the run executes"),a("workflowId"),i("ngx-decaf-crud-field",{label:"graph.run.workflowId.label"}),C("design:type",String)],Co.prototype,"workflowId",void 0),R([T(),g("Owning user; absent for anonymous callers"),i("ngx-decaf-crud-field",{label:"graph.run.owner.label"}),C("design:type",String)],Co.prototype,"owner",void 0),R([T(),w(),v(String),D(),g("Current run lifecycle status"),a("status"),i("ngx-decaf-crud-field",{label:"graph.run.status.label",readonly:!0}),C("design:type",String)],Co.prototype,"status",void 0),R([T(),g("Fingerprint of the executed document"),i("ngx-decaf-crud-field",{label:"graph.run.fingerprint.label",readonly:!0}),C("design:type",String)],Co.prototype,"documentFingerprint",void 0),R([T(),f(),g("Workflow input values keyed by input port id"),C("design:type",Object)],Co.prototype,"inputs",void 0),R([T(),f(),g("Execution result, present on successful completion"),C("design:type",Object)],Co.prototype,"result",void 0),R([T(),f(),g("Structured error payload, present on failure"),C("design:type",Object)],Co.prototype,"error",void 0),R([x(),T(),g("Run creation timestamp"),C("design:type",Date)],Co.prototype,"createdAt",void 0),R([x(),T(),g("Execution start timestamp, once it has started"),C("design:type",Date)],Co.prototype,"startedAt",void 0),R([x(),T(),g("Terminal-state timestamp, once the run has finished"),C("design:type",Date)],Co.prototype,"finishedAt",void 0),Co=R([s("ngx-decaf-list-item",{icon:"ti-player-play"}),n("ngx-decaf-crud-form"),g("Persistable graph run lifecycle record"),P("graph_run"),I(),C("design:paramtypes",[Object])],Co);let No=class extends j{constructor(e){super(e)}};R([N({type:String,generated:!1}),C("design:type",String)],No.prototype,"workflowId",void 0),R([T(),C("design:type",String)],No.prototype,"name",void 0),R([T(),C("design:type",Object)],No.prototype,"document",void 0),R([T(),C("design:type",String)],No.prototype,"owner",void 0),R([T(),C("design:type",Object)],No.prototype,"snapshot",void 0),R([$(),C("design:type",Date)],No.prototype,"createdAt",void 0),No=R([P("graph_workflow"),I(),C("design:paramtypes",[Object])],No);let To=class extends j{constructor(e){super(e)}};R([N({type:String,generated:!1}),C("design:type",String)],To.prototype,"kind",void 0),R([T(),D(),C("design:type",String)],To.prototype,"name",void 0),R([T(),D(),C("design:type",String)],To.prototype,"category",void 0),R([T(),C("design:type",String)],To.prototype,"group",void 0),R([T(),C("design:type",String)],To.prototype,"description",void 0),R([T(),C("design:type",Object)],To.prototype,"manifest",void 0),R([$(),C("design:type",Date)],To.prototype,"createdAt",void 0),To=R([P("graph_node"),I(),C("design:paramtypes",[Object])],To),Fe("Trigger",{color:"#3b82f6",icon:"ti-bolt"}),Fe("Flow Control",{color:"#f59e0b",icon:"ti-arrows-split-2"}),Fe("Utility",{color:"#0d9488",icon:"ti-tool"}),Fe("Loop",{color:"#eab308",icon:"ti-repeat"}),Fe("Workflow",{color:"#f97316",icon:"ti-sitemap"}),Fe("Pipeline",{color:"#0ea5e9",icon:"ti-git-merge"}),Fe("Node",{color:"#8b5cf6",icon:"ti-point-filled"}),Fe("Agent",{color:"#7c3aed",icon:"ti-robot"}),Fe("Data",{color:"#8b5cf6",icon:"ti-table"}),Fe("IO",{color:"#0ea5e9",icon:"ti-world-www"}),Fe("Storage",{color:"#0f766e",icon:"ti-database"}),Fe("DevOps",{color:"#475569",icon:"ti-terminal-2"}),Fe("Comms",{color:"#d946ef",icon:"ti-message-circle"}),Fe("model",{color:"#3b82f6",icon:"ti-cpu"}),Fe("memory",{color:"#10b981",icon:"ti-database"}),Fe("workspace",{color:"#f59e0b",icon:"ti-folder"}),Fe("tools",{color:"#0ea5e9",icon:"ti-tools"}),Fe("hooks",{color:"#f97316",icon:"ti-webhook"}),Fe("skill",{color:"#8b5cf6",icon:"ti-bulb"}),Fe("sandbox",{color:"#14b8a6",icon:"ti-box"}),Fe("scorers",{color:"#ec4899",icon:"ti-star"}),Fe("embedding",{color:"#6366f1",icon:"ti-vector"});const Do=new Set;function Po(e,t){return e.config[t]}function jo(e){return Array.isArray(e)?e.map(e=>e+"").join(", "):e+""}(()=>{const t=[{key:ze.NODE_ID,shouldInclude:e=>null!=Po(e,ze.NODE_ID),render:e=>Po(e,ze.NODE_ID)+""},{key:ze.WORKFLOW_ID,shouldInclude:e=>null!=Po(e,ze.WORKFLOW_ID),render:e=>Po(e,ze.WORKFLOW_ID)+""},{key:ze.RUN_ID,shouldInclude:e=>null!=Po(e,ze.RUN_ID),render:e=>Po(e,ze.RUN_ID)+""},{key:ze.USER,shouldInclude:e=>null!=Po(e,ze.USER),render:e=>Po(e,ze.USER)+""},{key:ze.ROLES,shouldInclude(e){const t=Po(e,ze.ROLES);return Array.isArray(t)&&t.length>0},render:e=>jo(Po(e,ze.ROLES))},{key:ze.NAMESPACES,shouldInclude(e){const t=Po(e,ze.NAMESPACES);return Array.isArray(t)&&t.length>0},render:e=>jo(Po(e,ze.NAMESPACES))},{key:ze.ORGANIZATION,shouldInclude:e=>null!=Po(e,ze.ORGANIZATION),render:e=>Po(e,ze.ORGANIZATION)+""},{key:ze.IP,shouldInclude:e=>null!=Po(e,ze.IP),render:e=>Po(e,ze.IP)+""}];for(const o of t)Do.has(o.key)||(e.register(o),Do.add(o.key))})();const $o="$workflow",Lo="local",Mo="GRAPH_LOCAL_UNSUPPORTED_NODE_KIND",Go=4,Uo=100,Fo=1e3,Bo=1e3,Ho=1e4,qo=3e4,Wo=3e5,Ko=10485760,Vo=5,zo=6e4,Qo=3e4,Jo=1048576,Xo=10,Yo=1e3,Zo=1e4,er=1048576,tr=1e4,or="graph.pinnable";var rr,nr;(e=>{e.MANUAL="manual",e.AUTOMATIC="automatic",e.DISABLED="disabled"})(rr||(rr={})),(e=>{e.TRUTHY="truthy",e.FALSY="falsy",e.EQUALS="equals",e.NOT_EQUALS="notEquals",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.EXISTS="exists",e.CUSTOM="custom"})(nr||(nr={}));const ir={FOREACH:"core.loop.foreach",WHILE:"core.loop.while",UNTIL:"core.loop.until"};class ar extends k{constructor(e,t="GRAPH_EXECUTION_ERROR",o){super(e,ar.name,500),this.graphCode=t,this.details=o,this.name=this.constructor.name}}class sr extends ar{constructor(e){super("Graph workflow contains an unsupported cycle","GRAPH_CYCLE_ERROR",e)}}class dr extends ar{constructor(e,t){super(e,"GRAPH_INPUT_ERROR",t)}}class lr extends ar{constructor(e,t){super(e,"GRAPH_LOOP_LIMIT_ERROR",t)}}class cr extends ar{constructor(e,t){super(e,"GRAPH_PINNING_ERROR",t)}}class pr extends ar{constructor(e,t){super(e,"GRAPH_PORT_ERROR",t)}}class ur extends ar{constructor(e,t){super(e,"GRAPH_STORE_ERROR",t)}}class hr extends ar{constructor(e,t){super(e,"GRAPH_TOPOLOGY_ERROR",t)}}class gr extends ar{constructor(e){super("Break signal","GRAPH_BREAK_SIGNAL",{value:e}),this.isBreakSignal=!0,this.name="GraphBreakSignal"}}class fr extends ar{constructor(e){super(`Graph run '${e}' was cancelled`,"GRAPH_RUN_CANCELLED",{runId:e}),this.name=fr.name}}class yr extends E{constructor(e){super(`Graph workflow document rejected with ${e.length} issue(s): ${e.map(e=>`${e.code} at ${e.path} (${e.message})`).join("; ")}`),this.name=yr.name,this.issues=e}}class mr{constructor(){this.observers=new Set}observe(e){return this.observers.add(e),()=>this.unObserve(e)}unObserve(e){this.observers.delete(e)}async updateObservers(e){await Promise.all(Array.from(this.observers).map(async t=>{try{await Promise.resolve(t.refresh(e))}catch{}}))}}class br{constructor(){this.sequence=0}create(e){return{...e,id:this.createEventId(),sequence:++this.sequence,timestamp:new Date}}createEventId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new ar("Cannot generate a graph event id: crypto.randomUUID is unavailable in this runtime","GRAPH_EVENT_ID_ERROR",{runtime:typeof globalThis.crypto});return e.randomUUID()}}function wr(e){if("string"!=typeof e)return;const t=e.trim();if(!t)return;const o=t.split(".");if(3!==o.length)return;const r=o[0].trim(),n=o[2].trim(),i=o[1].split(",").map(e=>e.trim()).filter(e=>e.length>0);return r&&n&&0!==i.length?{organization:r,departments:i,role:n}:void 0}function vr(e){return`${e.organization}.${e.departments.join(",")}.${e.role}`}function xr(e){if(!e||"string"!=typeof e.namespace||!e.parts)return!1;const t=wr(e.namespace);return!!t&&vr(t)===vr(e.parts)}function Ir(e,t){const o="string"==typeof e?e.trim():"";if(o){if(t)for(const e of t)if(e&&e.namespace===o&&xr(e))return e.parts;return wr(o)}}function Ar(e,t,o={},r){const n=Ir(e,r),i=Ir(t,r);return!(!n||!i)&&n.organization===i.organization&&n.role===i.role&&("exact"===(o.mode??"inherit")?n.departments.length===i.departments.length&&n.departments.every((e,t)=>e===i.departments[t]):n.departments.length<=i.departments.length&&n.departments.every((e,t)=>e===i.departments[t]))}function _r(e,t,o={},r){return e.filter(e=>!t.some(t=>Ar(t,e,o,r)))}function Or(e){return e.filter(e=>void 0===wr(e))}function Er(e,t){const o=new Set;for(const r of e){const e=Ir(r,t);e&&o.add(e.role)}return[...o]}function kr(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function Sr(e,t){try{const o=e.cache;if(o&&void 0!==o[t]&&null!==o[t])return o[t]}catch{}try{return e.get(t)}catch{return}}function Rr(e){if(!e)return{};const t={},o=e.user;"string"==typeof o&&o&&(t.user=o);const r=e.organization;"string"==typeof r&&r&&(t.organization=r);const n=e.ip;"string"==typeof n&&n&&(t.ip=n);const i=kr(e.roles);i&&(t.roles=i);const a=kr(e.namespaces);return a&&(t.namespaces=a,t.namespaceCache=Nr(a)),t}function Cr(e){return e?Rr({user:Sr(e,"user"),organization:Sr(e,"organization"),ip:Sr(e,"ip"),roles:Sr(e,"roles"),namespaces:Sr(e,"namespaces")}):{}}function Nr(e){const t=[];for(const o of e){const e=wr(o);e&&t.push({namespace:o,parts:e})}return t}function Tr(...e){const t={};for(const o of e)o&&(void 0!==o.user&&(t.user=o.user),void 0!==o.organization&&(t.organization=o.organization),void 0!==o.ip&&(t.ip=o.ip),void 0!==o.roles&&(t.roles=o.roles),void 0!==o.namespaces&&(t.namespaces=o.namespaces),void 0!==o.namespaces?t.namespaceCache=o.namespaceCache??Nr(o.namespaces):void 0!==o.namespaceCache&&(t.namespaceCache=o.namespaceCache));return t}class Dr{constructor(e={}){this.options=e}get enabled(){return!0===this.options.enabled}validate(e,o,r,n){if(!this.enabled)return;const i=n??this.options.logger??t.for("GraphAuth"),a=e.id||e.name||o.workflowId,s=et(e.metadata);this.assertGranted(`workflow '${a}'`,s?.namespaces??[],r,s?.roles??[],i);for(const e of o.nodes)this.assertGranted(`node '${e.id}'`,e.manifest.namespaces??[],r,[],i)}validateWorkflowRead(e,o,r){if(!this.enabled)return;const n=r??this.options.logger??t.for("GraphAuth"),i=et(e.metadata);this.assertGranted(`workflow '${e.id||e.name}'`,i?.namespaces??[],o,i?.roles??[],n)}assertGranted(e,t,o,r,n){const i=o.namespaces??[],a=_r(t,i,this.options.match,o.namespaceCache),s=Er(i,o.namespaceCache),d=r.filter(e=>!s.includes(e));if(0===a.length&&0===d.length)return;const l=[...new Set([...Or(t),...Or(i)])],c=[];throw a.length&&c.push("namespace(s) "+a.join(", ")),d.length&&c.push("role(s) "+d.join(", ")),n.warn(`Graph access denied for ${e} for user ${o.user??"anonymous"}: missing ${c.join(" and ")}${l.length?`; malformed namespace(s) ${l.join(", ")} failed closed`:""}`),new L(`Access to ${e} requires ${c.join(" and ")}`)}}class Pr{constructor(e){this.services=e}async resolve(e,t,o,r,n){if(!e){if(o)throw new ar(`${r} node requires a credential of type '${t}'`,"GRAPH_CREDENTIAL_MISSING",{credentialType:t});return}if(e.credentialType&&e.credentialType!==t)throw new ar(`${r} node credential has type '${e.credentialType}' but requires '${t}'`,"GRAPH_CREDENTIAL_TYPE_MISMATCH",{credentialId:e.credentialId,credentialType:e.credentialType});let i;try{i=await this.services.credentialService.getCredential(e.credentialId,n)}catch(t){throw new ar(`${r} node credential '${e.credentialId}' could not be resolved`,"GRAPH_CREDENTIAL_NOT_FOUND",{credentialId:e.credentialId,cause:t instanceof Error?t.message:t+""})}if(!1===i.enabled)throw new ar(`${r} node credential '${e.credentialId}' is disabled`,"GRAPH_CREDENTIAL_DISABLED",{credentialId:e.credentialId});if((e=>{if(!e)return!1;const t=e instanceof Date?e.getTime():Date.parse(e);return Number.isFinite(t)&&Date.now()>=t})(i.expiresAt))throw new ar(`${r} node credential '${e.credentialId}' has expired`,"GRAPH_CREDENTIAL_EXPIRED",{credentialId:e.credentialId});if(i.credentialType&&i.credentialType!==t)throw new ar(`${r} node credential '${e.credentialId}' has type '${i.credentialType}' but requires '${t}'`,"GRAPH_CREDENTIAL_TYPE_MISMATCH",{credentialId:e.credentialId,credentialType:i.credentialType});const a=this.secretServiceFor(i.provider,r),s=await a.retrieve(i.secretName,{},n);return await(this.services.credentialService.markCredentialUsed?.(e.credentialId,n).catch(()=>{})),(e=>{if(null!=e)return"string"==typeof e?e:e instanceof Uint8Array?(new TextDecoder).decode(e):"object"!=typeof e||Array.isArray(e)?e+"":e})(s)}secretServiceFor(e,t){if("model"===e)return this.services.modelSecretService;if("filesystem"===e){if(!this.services.fsSecretService)throw new ar(`${t} node credential provider '${e}' requires a configured filesystem secret service`,"GRAPH_CREDENTIAL_SERVICE_UNAVAILABLE",{provider:e});return this.services.fsSecretService}throw new ar(`${t} node credential provider '${e}' is not supported`,"GRAPH_CREDENTIAL_PROVIDER_UNSUPPORTED",{provider:e})}}async function jr(e,t,o,r,n,i="credentialRef"){const a=t?.[i];if(!a){if(!r)return;throw new ar(`${n} node requires a credential of type '${o}'`,"GRAPH_CREDENTIAL_MISSING",{credentialType:o})}const s=e?.engine,d=s?.nodeCredentials;if(!d)throw new ar(n+" node requires ctx-bound credential services, but the engine has none configured","GRAPH_CREDENTIAL_SERVICE_UNAVAILABLE",{node:n,credentialType:o});return d.resolve(a,o,r,n,e)}class $r{constructor(e){this.baseOptions=e,this.inner=t.for("GraphRun").for(this.attributeConfig(e))}attributeConfig(e){return{[ze.NODE_ID]:e.nodeId,[ze.WORKFLOW_ID]:e.workflowId,[ze.RUN_ID]:e.runId,[ze.USER]:e.user??null,[ze.ROLES]:e.roles,[ze.NAMESPACES]:e.namespaces,[ze.ORGANIZATION]:e.organization,[ze.IP]:e.ip}}emit(e,t,o){const r="string"==typeof t?t:t instanceof Error?t.message:t+"",n={level:e,message:r,timestamp:(new Date).toISOString(),runId:this.baseOptions.runId,workflowId:this.baseOptions.workflowId,nodeId:this.baseOptions.nodeId,user:this.baseOptions.user??null};void 0!==this.baseOptions.roles&&(n.roles=this.baseOptions.roles),void 0!==this.baseOptions.namespaces&&(n.namespaces=this.baseOptions.namespaces),void 0!==this.baseOptions.organization&&(n.organization=this.baseOptions.organization),void 0!==this.baseOptions.ip&&(n.ip=this.baseOptions.ip),void 0!==o&&(n.payload=o),this.baseOptions.forward({type:Qe.GRAPH_RUN_LOG,payload:n}).catch(()=>{}),{benchmark:(e,t)=>this.inner.benchmark(e,t),fatal:(e,t)=>this.inner.fatal(e,t),critical:(e,t)=>this.inner.critical(e,t),silly:(e,t)=>this.inner.silly(e,t),trace:(e,t)=>this.inner.trace(e,t),verbose:(e,t)=>this.inner.verbose(e,t),info:(e,t)=>this.inner.info(e,t),warn:(e,t)=>this.inner.warn(e,t),error:(e,t)=>this.inner.error(e,t),debug:(e,t)=>this.inner.debug(e,t)}[e](r,o)}benchmark(e,t){this.emit("benchmark",e,t)}fatal(e,t,o){this.emit("fatal",e,t??o)}critical(e,t,o){this.emit("critical",e,t??o)}silly(e,t,o){this.emit("silly",e,"object"==typeof t?t:o)}trace(e,t){this.emit("trace",e,t)}verbose(e,t,o){this.emit("verbose",e,"object"==typeof t?t:o)}info(e,t){this.emit("info",e,t)}error(e,t,o){this.emit("error",e,t??o)}warn(e,t){this.emit("warn",e,t)}debug(e,t){this.emit("debug",e,t)}action(e,t,o){this.inner.action(e,t,o)}setConfig(){}for(e,t,...o){return this}clear(){return this}get root(){return this.inner.root}}function Lr(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}class Mr extends M{constructor(e,t,o,r,n,i,a,s,d={},l,c,p){super(),this.runId=e,this.parentRunId=t,this.workflowId=o,this.document=r,this.node=n,this.manifest=i,this.path=a,this.emitFn=s,this.metadata=d,this.engine=l,this.abortSignal=c,this.limits=p;const u=Rr(d);this.accumulate({...u,operation:"execute"});const h="string"==typeof d?.user?d.user:null;this.runLogger=new $r({runId:e,workflowId:o,nodeId:n.id,user:h,roles:Lr(d?.roles),namespaces:Lr(d?.namespaces),organization:"string"==typeof d?.organization?d.organization:void 0,ip:"string"==typeof d?.ip?d.ip:void 0,forward:async e=>{await this.emit(e)}})}get logger(){return this.runLogger}get auth(){return Cr(this)}async emit(e){await this.emitFn({...e,runId:this.runId,parentRunId:this.parentRunId,workflowId:this.workflowId,nodeId:this.node.id,path:e.path??this.path})}async progress(e){await this.emit({type:Qe.NODE_OUTPUT,payload:e})}async log(e,t){await this.emit({type:Qe.NODE_OUTPUT,payload:{message:e,payload:t}})}}class Gr{constructor(e,t,o,r){this.nodeResults=new Map,this.events=[],this.activeDataEdges=new Set,this.runId=e,this.plan=t,this.valueStore=o,this.eventFactory=r,this.startedAt=new Date}recordNodeResult(e){this.nodeResults.set(e.nodeId,e)}activateDataEdge(e){this.activeDataEdges.add(e)}isDataEdgeActive(e){return this.activeDataEdges.has(e)}appendEvent(e){this.events.push(e)}finish(){this.finishedAt=new Date}}function Ur(e,t,o,r,n){const i=e.valueStore.getWorkflowValues(),a={};for(const[t,o]of e.nodeResults)a[t]=o;const s=[...e.events];return{runId:e.runId,workflowId:t.id||t.name,status:r,document:t,inputs:{...o},outputs:i,nodeResults:a,events:s,startedAt:e.startedAt,finishedAt:e.finishedAt,metadata:n}}class Fr{constructor(e,t,o){this.emitter=e,this.eventFactory=t,this.options=o}get engine(){return this.options.engine}get codeSandboxEvaluator(){return this.options.codeSandboxEvaluator}get frame(){return this._frame}bindFrame(e){this._frame=e}async emit(e){const t=this.eventFactory.create({id:"",sequence:0,timestamp:new Date,runId:this.options.runId,parentRunId:this.options.parentRunId,workflowId:this.options.workflowId,type:Qe.NODE_OUTPUT,path:this.options.path??[],...e});this._frame?.appendEvent(t),await this.emitter.updateObservers(t)}async updateObservers(e){await this.emitter.updateObservers(e)}}function Br(e){const t=e.capabilities;return{codeMode:t?.codeMode??e.codeMode,workflows:{list:t?.workflows?.list??("function"==typeof e.listWorkflows?"supported":"not_supported"),get:t?.workflows?.get??("function"==typeof e.getWorkflow?"supported":"not_supported")}}}class Hr{static{this._cache={}}static register(e,t){return Hr._cache[e]=t,t}static get(e){const t=e??Hr._currentFlavour;if(t)return Hr._cache[t]}static getOrFail(e){const t=Hr.get(e);if(!t)throw new ar(`No graph execution backend registered under '${e}'`,"GRAPH_EXECUTION_BACKEND_NOT_REGISTERED");return t}static get current(){return Hr.get()}static get currentFlavour(){return Hr._currentFlavour??Lo}static setCurrent(e){Hr._currentFlavour=e}static list(){return Object.entries(Hr._cache).map(([e,t])=>({flavour:e,backend:t}))}static unregister(e){e&&(delete Hr._cache[e],Hr._currentFlavour===e&&(Hr._currentFlavour=void 0))}static clear(){for(const e of Object.keys(Hr._cache))delete Hr._cache[e];Hr._currentFlavour=void 0}}class qr{evaluate(e,t){switch(e.op){case"eq":return this.resolveValue(e.left,t)===this.resolveValue(e.right,t);case"neq":return this.resolveValue(e.left,t)!==this.resolveValue(e.right,t);case"gt":return Number(this.resolveValue(e.left,t))>Number(this.resolveValue(e.right,t));case"gte":return Number(this.resolveValue(e.left,t))>=Number(this.resolveValue(e.right,t));case"lt":return Number(this.resolveValue(e.left,t))<Number(this.resolveValue(e.right,t));case"lte":return Number(this.resolveValue(e.left,t))<=Number(this.resolveValue(e.right,t));case"and":return e.conditions.every(e=>this.evaluate(e,t));case"or":return e.conditions.some(e=>this.evaluate(e,t));case"not":return!this.evaluate(e.condition,t);case"exists":return void 0!==this.resolveValue(e.value,t)&&null!==this.resolveValue(e.value,t);default:throw new ar(`Unknown ConditionExpression op '${e.op}'`,"GRAPH_UNKNOWN_CONDITION_OP",{expr:e})}}resolveValue(e,t){if("const"in e)return e.const;if("path"in e&&!("step"in e))return this.resolvePath(e.path,t);if("step"in e&&"path"in e){const o=t?.nodes;if(o&&"object"==typeof o){const t=o[e.step];return this.resolvePath(e.path,t)}return this.resolvePath(e.path,t)}throw new ar("Invalid ExprValue: must have `const`, `path`, or `step`+`path`","GRAPH_INVALID_EXPR_VALUE",{ref:e})}resolvePath(e,t){if(!e)return t;const o=e.split(".");let r=t;for(const e of o){if(null==r)return;r=r[e]}return r}}function Wr(e){return"object"==typeof e&&null!==e&&"type"in e&&"code"===e.type}function Kr(e){return"object"==typeof e&&null!==e&&"op"in e&&"string"==typeof e.op}async function Vr(e,t,o){const r=o.engine?.codeSandboxEvaluator;if(!r)throw new ar("Code conditions require a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{code:e.code});await o.log("Evaluating code condition",{language:e.language??"javascript"});const n=o.metadata;return!!await r.evaluate({code:e.code,language:e.language,input:t,vars:n?.vars??void 0,item:n?.item,index:n?.index,nodes:n?.nodes??void 0,logger:o.logger,abortSignal:o.abortSignal})}function zr(e,t,o){if(Kr(e))return(new qr).evaluate(e,t);throw((e,t)=>new ar(`Unknown ${t??"flow"} condition type \u2014 must be ConditionExpression (op) or CodeCondition (type: 'code')`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:e}))(e,o)}async function Qr(e,t,o){return Wr(e)?Vr(e,t.input,o):zr(e,t.state,t.label)}function Jr(e,t,o,r){if(e&&"object"==typeof e&&!r.has(e))if(r.add(e),Wr(e))o.push({nodeId:t,kind:"code-condition"});else if(Xt(e))o.push({nodeId:t,kind:"value-template"});else if((e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"expression"===t.source&&"string"==typeof t.expression})(e))o.push({nodeId:t,kind:"expression-binding"});else if((e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.id&&"string"==typeof t.name&&Array.isArray(t.nodes)&&Array.isArray(t.edges)})(e))Yr(e,o,r);else if(Array.isArray(e))for(const n of e)Jr(n,t,o,r);else for(const n of Object.keys(e))Jr(e[n],t,o,r)}function Xr(e,t,o){const r=e.id;"core.utility.code"===e.kind&&t.push({nodeId:r,kind:"code-node",detail:e.kind});const n=e.inputBindings??{};for(const[e,o]of Object.entries(n))o&&"expression"===o.mode&&t.push({nodeId:r,kind:"expression-binding",detail:e});Jr(e.parameters,r,t,o),Jr(e.metadata,r,t,o),Jr(e.state,r,t,o),Jr(e.loop,r,t,o)}function Yr(e,t,o){for(const r of e.nodes??[])Xr(r,t,o)}function Zr(e){const t=[];return Yr(e,t,new Set),t}function en(e){return Zr(e).length>0}const tn="core.agent";function on(e,t){if(!t)return{valid:!0};switch(t.type){case"any":default:return{valid:!0};case"string":return"string"!=typeof e?rn("string"):{valid:!0};case"number":return"number"==typeof e&&Number.isFinite(e)?t.integer&&!Number.isInteger(e)?{valid:!1,message:"expected an integer number"}:void 0!==t.min&&e<t.min?{valid:!1,message:"expected a number >= "+t.min}:void 0!==t.max&&e>t.max?{valid:!1,message:"expected a number <= "+t.max}:{valid:!0}:rn("number");case"boolean":return"boolean"!=typeof e?rn("boolean"):{valid:!0};case"array":if(!Array.isArray(e))return rn("array");if(void 0!==t.minItems&&e.length<t.minItems)return{valid:!1,message:`expected at least ${t.minItems} items`};if(void 0!==t.maxItems&&e.length>t.maxItems)return{valid:!1,message:`expected at most ${t.maxItems} items`};for(const o of e){const e=on(o,t.items);if(!e.valid)return e}return{valid:!0};case"object":case"model":{if(null===e||"object"!=typeof e||Array.isArray(e))return rn(t.type);const o=t,r=o.properties;if(!r)return{valid:!0};for(const[t,o]of Object.entries(r))if(t in e){const r=on(e[t],o);if(!r.valid)return{valid:!1,message:`property '${t}': ${r.message}`}}if(o.required)for(const t of o.required)if(!(t in e))return{valid:!1,message:`missing required property '${t}'`};if(!1===o.additionalProperties)for(const t of Object.keys(e))if(!(t in r))return{valid:!1,message:`unexpected property '${t}'`};return{valid:!0}}case"enum":return t.values.some(t=>t===e)?{valid:!0}:{valid:!1,message:"value is not one of the enum values"}}}function rn(e){return{valid:!1,message:`expected a ${e} value`}}function nn(e){if("string"==typeof e)return e.length>0;if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.credentialId&&t.credentialId.length>0&&(void 0===t.credentialType||"string"==typeof t.credentialType)}const an=new Set(["loop"]),sn=["secret","secrets","password","passwd","token","accessToken","refreshToken","apiKey","api_key","privateKey","credentials","authorization","proxy-authorization","x-api-key","x-auth-token","cookie","set-cookie"];class dn{validate(e,t,o,r,n){this.validateParameters(e,t,o,r,n),this.validateMetadataKeys(e,t,o,r),this.validateDisabledBehavior(e,o,r),this.validateBindingShapes(e,t,o,r)}validateParameters(e,t,o,r,n){const i=!0===t.policies?.allowUndeclaredParameters,a=new Map(t.parameters.map(e=>[e.id,e]));for(const[n,s]of Object.entries(e.parameters??{})){const d=a.get(n);if(!d){i||o.push({code:"parameter.undeclared",path:`${r}.parameters.${n}`,message:`Node '${e.id}' sets parameter '${n}' which is not declared by kind '${t.kind}'`,nodeId:e.id,details:{kind:t.kind}});continue}if(void 0===s){o.push({code:"parameter.invalid",path:`${r}.parameters.${n}`,message:`Node '${e.id}' parameter '${n}' must not be undefined`,nodeId:e.id});continue}const l=this.checkParameterValue(s,d);l.valid||o.push({code:"parameter.type-mismatch",path:`${r}.parameters.${n}`,message:`Node '${e.id}' parameter '${n}' is invalid: ${l.message}`,nodeId:e.id,details:{expectedType:d.type}})}for(const i of t.parameters)void 0===(e.parameters??{})[i.id]&&(this.isParameterSatisfiedByInput(e,i.id,n)||(!0===i.required||(i.validation??[]).some(e=>"required"===e.kind))&&void 0===i.defaultValue&&o.push({code:"parameter.required-missing",path:`${r}.parameters.${i.id}`,message:`Node '${e.id}' is missing required parameter '${i.id}' declared by kind '${t.kind}'`,nodeId:e.id}))}isParameterSatisfiedByInput(e,t,o){return void 0!==(e.inputBindings??{})[t]||!0===o?.has(t)}checkParameterValue(e,t){if(Xt(e))return{valid:!0};switch(t.type){case"string":case"code":case"expression":return"string"!=typeof e?rn("string"):{valid:!0};case"number":return"number"==typeof e&&Number.isFinite(e)?{valid:!0}:rn("number");case"boolean":return"boolean"!=typeof e?rn("boolean"):{valid:!0};case"options":{const o=t.options;return o&&o.length&&!o.some(t=>t.value===e)?{valid:!1,message:"value is not one of the declared options"}:{valid:!0}}case"collection":return Array.isArray(e)?{valid:!0}:rn("array");case"object":case"resourceLocator":return null===e||"object"!=typeof e||Array.isArray(e)?rn("object"):{valid:!0};case"credential":return nn(e)?t.credentialType&&"object"==typeof e&&void 0!==e.credentialType&&e.credentialType!==t.credentialType?{valid:!1,message:`credential type '${e.credentialType}' does not match the declared type '${t.credentialType}'`}:{valid:!0}:{valid:!1,message:"credential parameters must hold a credential reference (credentialId), never a secret"};default:return{valid:!0}}}validateMetadataKeys(e,t,o,r){const n=t.metadata?.allowedInstanceMetadataKeys;for(const i of Object.keys(e.metadata??{}))an.has(i)?o.push({code:"metadata.key-not-allowed",path:`${r}.metadata.${i}`,message:`Node '${e.id}' metadata key '${i}' is reserved and must not be set directly`,nodeId:e.id}):Array.isArray(n)&&!n.includes(i)&&o.push({code:"metadata.key-not-allowed",path:`${r}.metadata.${i}`,message:`Node '${e.id}' metadata key '${i}' is not in the allowed metadata keys of kind '${t.kind}'`,nodeId:e.id})}validateDisabledBehavior(e,t,o){!0!==e.disabled&&!1!==e.disabled&&void 0!==e.disabled&&t.push({code:"disabled.invalid",path:o+".disabled",message:`Node '${e.id}' disabled flag must be a boolean`,nodeId:e.id});const r=(e.metadata??{}).disabledBehavior;void 0===r||We(r)||t.push({code:"disabled.invalid-behavior",path:o+".metadata.disabledBehavior",message:`Node '${e.id}' disabled behavior '${r+""}' is not one of: ${qe.join(", ")}`,nodeId:e.id})}validateBindingShapes(e,t,o,r){for(const[n,i]of Object.entries(e.inputBindings??{})){if("literal"===i.mode){const a=t.inputs.find(e=>e.id===n);if(a?.schema){const t=on(i.value,a.schema);t.valid||o.push({code:"binding.literal-invalid",path:`${r}.inputBindings.${n}`,message:`Node '${e.id}' literal binding for '${n}' is schema-invalid: ${t.message}`,nodeId:e.id})}}"expression"!==i.mode||"string"==typeof i.expression&&i.expression.trim()||o.push({code:"binding.expression-invalid",path:`${r}.inputBindings.${n}`,message:`Node '${e.id}' expression binding for '${n}' must contain a non-empty expression`,nodeId:e.id})}}validateBindingSatisfaction(e,t,o,r,n,i={}){const a=new Set(o.filter(e=>"data"===e.type).map(e=>e.targetPort)),s=new Set(Object.entries(e.inputBindings??{}).map(([e])=>e));for(const t of a){const o=(e.inputBindings??{})[t];o&&"literal"===o.mode&&!0!==i.allowLiteralAndEdgeBindings&&r.push({code:"binding.conflict",path:`${n}.inputBindings.${t}`,message:`Node '${e.id}' input '${t}' has both an incoming edge and a literal binding`,nodeId:e.id})}for(const o of t.inputs)!0===o.required&&(a.has(o.id)||s.has(o.id)||void 0===(e.parameters??{})[o.id]&&r.push({code:"topology.required-input-unsatisfiable",path:n+".parameters",message:`Node '${e.id}' required input '${o.id}' has no incoming edge or binding`,nodeId:e.id,details:{port:o.id}}))}static disabledBehaviorOf(e,t){const o=(e.metadata??{}).disabledBehavior;if(We(o))return o;const r=t?.disabledBehavior;return We(r)?r:"skip"}}let ln=class extends j{constructor(e){super(e)}};function cn(e){return[e.namespace??"default",e.workflowId,e.nodeId,e.version??"default",e.fingerprint].join(":")}function pn(e){return new ln({id:cn(e.key),workflowId:e.key.workflowId,nodeId:e.key.nodeId,fingerprint:e.key.fingerprint,...void 0!==e.key.namespace?{namespace:e.key.namespace}:{},...void 0!==e.key.version?{version:e.key.version}:{},pinned:e.pinned,outputs:e.outputs,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),...e.expiresAt?{expiresAt:new Date(e.expiresAt)}:{},...e.metadata?{metadata:e.metadata}:{}})}function un(e){return{key:{workflowId:e.workflowId,nodeId:e.nodeId,fingerprint:e.fingerprint,...void 0!==e.namespace?{namespace:e.namespace}:{},...void 0!==e.version?{version:e.version}:{}},outputs:e.outputs,pinned:e.pinned,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString(),...e.expiresAt?{expiresAt:e.expiresAt.toISOString()}:{},...e.metadata?{metadata:e.metadata}:{}}}R([N({type:String,generated:!1}),C("design:type",String)],ln.prototype,"id",void 0),R([T(),D(),C("design:type",String)],ln.prototype,"workflowId",void 0),R([T(),D(),C("design:type",String)],ln.prototype,"nodeId",void 0),R([T(),C("design:type",String)],ln.prototype,"fingerprint",void 0),R([T(),C("design:type",String)],ln.prototype,"namespace",void 0),R([T(),C("design:type",String)],ln.prototype,"version",void 0),R([T(),C("design:type",Boolean)],ln.prototype,"pinned",void 0),R([T(),C("design:type",Object)],ln.prototype,"outputs",void 0),R([T(),C("design:type",Date)],ln.prototype,"createdAt",void 0),R([T(),C("design:type",Date)],ln.prototype,"updatedAt",void 0),R([T(),C("design:type",Date)],ln.prototype,"expiresAt",void 0),R([T(),C("design:type",Object)],ln.prototype,"metadata",void 0),ln=R([P("graph_value"),I(),C("design:paramtypes",[Object])],ln);let hn=class extends U{constructor(e){super(e,ln,!0),this.runtimeValues=new Map}seedWorkflowInputs(e){this.runtimeValues.set($o,{...e})}setNodeOutputs(e,t){this.runtimeValues.set(e,{...t})}getPort(e,t){return this.runtimeValues.get(e)?.[t]}hasPort(e,t){return Object.prototype.hasOwnProperty.call(this.runtimeValues.get(e)??{},t)}setWorkflowOutput(e,t){const o=this.runtimeValues.get($o)??{};o[e]=t,this.runtimeValues.set($o,o)}getWorkflowValues(){return{...this.runtimeValues.get($o)??{}}}snapshot(){return Object.fromEntries(this.runtimeValues.entries())}async readCached(e,...t){try{return un(await this.read(cn(e),...t))}catch{return}}async writeCached(e,t,...o){const r=cn(e);let n;try{n=await this.read(r,...o)}catch{n=void 0}n?await this.update(Object.assign(n,pn(t)),...o):await this.create(pn(t),...o)}async deleteCached(e,...t){try{await this.delete(cn(e),...t)}catch{}}async hasCached(e,...t){return void 0!==await this.readCached(e,...t)}async listCached(e,...t){return(await this.select().execute(...t)).map(e=>un(e)).filter(t=>((e,t)=>!(void 0!==t.workflowId&&e.workflowId!==t.workflowId||void 0!==t.nodeId&&e.nodeId!==t.nodeId||void 0!==t.namespace&&e.namespace!==t.namespace||void 0!==t.version&&e.version!==t.version||void 0!==t.fingerprint&&e.fingerprint!==t.fingerprint))(t.key,e))}async clearRun(e,...t){const o=await this.select().execute(...t);for(const e of o)await this.delete(e.id,...t)}readRuntimeValues(e){return this.runtimeValues.get(e)}writeRuntimeValues(e,t){this.runtimeValues.set(e,{...t})}getAdapter(){return this.adapter}};function gn(e){return new(0,U.forModel(ln,e.alias).constructor)(e)}hn=R([G(ln,y),C("design:paramtypes",[Function])],hn);class fn{static upstreamNodes(e,t,o=!1){const r=new Set,n=[e];for(;n.length;){const e=n.pop(),i=t.get(e)??[];for(const e of i)!o&&this.isBoundary(e.sourceNodeId)||r.has(e.sourceNodeId)||(r.add(e.sourceNodeId),n.push(e.sourceNodeId))}return r}static downstreamNodes(e,t,o=!1){const r=new Set,n=[e];for(;n.length;){const e=n.pop(),i=t.get(e)??[];for(const e of i)!o&&this.isBoundary(e.targetNodeId)||r.has(e.targetNodeId)||(r.add(e.targetNodeId),n.push(e.targetNodeId))}return r}static isBoundary(e){return"$workflow"===e}}class yn{constructor(e,t,o){this.store=e,this.policy=t,this.dependencyResolver=o}async pinNode(e){const t=e.plan,o=e.includeDependencies??!0?this.dependencyResolver.getPinSet(t,e.nodeId):new Set([e.nodeId]);for(const e of o){const o=t.nodes.find(t=>t.id===e);if(!o)throw new cr(`Node '${e}' not found in plan`);if(!this.policy.canPin(o))throw new cr(`Node '${e}' is not pinnable`,{nodeId:e})}const r=this.topologicalOrder(t,o);for(const o of r){const r=t.nodes.find(e=>e.id===o),n=e.result.nodeResults[o];if(!n||!n.outputs)throw new cr(`Node '${o}' has no completed output to pin`);const i=n.inputs??{},a=this.dependencyFingerprints(t,o,e.result),s=this.createValueKey(e.document.id,r,i,a),d=(new Date).toISOString(),l={key:s,outputs:n.outputs,pinned:!0,createdAt:d,updatedAt:d,metadata:{...e.result.metadata,nodeId:o}};await this.store.writeCached(s,l)}}async unpinNode(e){const t={workflowId:e.document.id,nodeId:e.nodeId,fingerprint:e.fingerprint,namespace:e.namespace};await this.store.deleteCached(t)}async readPinnedValue(e,t,o,r,n){const i=this.createValueKey(e,t,o,r,n),a=await this.store.readCached(i);if(a&&a.pinned){if(a.expiresAt&&new Date(a.expiresAt)<new Date)return;return a}}createValueKey(e,t,o,r,n){return{workflowId:e,nodeId:t.id,fingerprint:this.computeFingerprint(e,t,o,r),namespace:n}}computeFingerprint(e,t,o,r){const n={workflowId:e,nodeId:t.id,nodeKind:t.kind,parameters:this.stableSerialize(t.instance.parameters??{}),inputBindings:this.stableSerialize(t.instance.inputBindings??{}),metadata:this.stableSerialize(this.relevantMetadata(t)),inputs:this.stableSerialize(o),dependencyFingerprints:this.stableSerialize(r)},i=this.stableSerialize(n);return this.simpleHash(i)}relevantMetadata(e){const t={...e.metadata??{}};return delete t.ui,delete t.position,delete t.visual,t}topologicalOrder(e,t){const o=[],r=new Set,n=i=>{if(r.has(i))return;r.add(i);const a=fn.upstreamNodes(i,e.incomingByNode,!1);for(const e of a)t.has(e)&&n(e);o.push(i)};for(const e of t)n(e);return o}dependencyFingerprints(e,t,o){const r=this.dependencyResolver.getDependencies(e,t),n={};for(const t of r){const r=e.nodes.find(e=>e.id===t);if(r){const i=o.nodeResults[t],a=i?.inputs??{},s=this.dependencyFingerprints(e,t,o);n[t]=this.computeFingerprint(e.workflowId,r,a,s)}}return n}stableSerialize(e){return null===e||"object"!=typeof e?JSON.stringify(e):Array.isArray(e)?`[${e.map(e=>this.stableSerialize(e)).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${this.stableSerialize(e[t])}`).join(",")}}`}simpleHash(e){let t=0;for(let o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o),t|=0;return`fp_${Math.abs(t).toString(16).padStart(8,"0")}_${e.length}`}}const mn={enabled:!0,strategy:"manual",includeDependencies:!0};function bn(e){return!0===e?.enabled&&"disabled"!==e.strategy}class wn{canPin(e){return bn(this.getPinningMetadata(e))}shouldUsePinnedValue(e){const t=this.getPinningMetadata(e);return!0===t.enabled&&"disabled"!==t.strategy}shouldAutoPin(e){const t=this.getPinningMetadata(e);return!0===t.enabled&&"automatic"===t.strategy}getPinningMetadata(e){const t=e.manifest.metadata?.pinnable??e.metadata?.pinnable;return t?{...mn,...t}:{...mn,enabled:!1}}}class vn{getDependencies(e,t){return fn.upstreamNodes(t,e.incomingByNode,!1)}getPinSet(e,t){const o=this.getDependencies(e,t);return o.add(t),o}}class xn{constructor(){this.local=!0,this.codeMode="hostSide",Hr.register(Lo,this)}async initialize(e){this.valueAdapter=e.valueAdapter,this.codeSandboxEvaluator=e.codeSandboxEvaluator,this.workflowStore=e.workflowStore,this.engine=e.engine}get capabilities(){const e=this.workflowStore?"supported":"not_supported";return{codeMode:this.codeMode,workflows:{list:e,get:e}}}async listWorkflows(...e){const t=this.workflowStore;if(!t)throw new ar("LocalGraphExecutionBackend has no workflowStore configured; workflow listing is not supported","GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED");return(await t.listWorkflows(...e)).map(e=>({id:e.workflowId,...void 0!==e.name?{name:e.name}:{},...void 0!==e.updatedAt&&null!==e.updatedAt?{updatedAt:e.updatedAt}:{}}))}async getWorkflow(e,...t){const o=this.workflowStore;if(!o)throw new ar("LocalGraphExecutionBackend has no workflowStore configured; workflow lookup is not supported","GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED");const r=await o.getDocument(e,...t);return this.engine&&this.engine.assertWorkflowReadAccess(r,(e=>Cr((e=>{for(let t=e.length-1;t>=0;t-=1){const o=e[t];if(!o||"object"!=typeof o)continue;const r=o;if("function"==typeof r.get&&"function"==typeof r.accumulate&&void 0!==r.cache)return o}})(e)))(t)),r}async seedWorkflows(e,...t){const o=this.workflowStore,r=o?.seedDocument??o?.saveDocument;if(!o||"function"!=typeof r)throw new ar("LocalGraphExecutionBackend has no writable workflowStore configured; workflow seeding is not supported","GRAPH_BACKEND_SEED_NOT_SUPPORTED");const n=[];for(const i of e)null!==await r.call(o,i.id,i,...t)&&n.push({id:i.id,...void 0!==i.name?{name:i.name}:{}});return n}async execute(e){const{document:t,plan:o,inputs:r,options:n,events:i}=e,a=i,s=a.frame;if(!s)throw new ar("LocalGraphExecutionBackend requires the frame-bound event sink created by GraphExecutionEngine","GRAPH_EXECUTION_FRAME_MISSING");const d=s.valueStore,l=s.runId,c=n.path??[],p=async e=>{await a.emit(e)};try{for(const e of o.layers)this.assertNotAborted(n),await this.executeLayer(s,o,e.nodes,n,p);this.assertNotAborted(n);const e=[...s.nodeResults.values()].find(e=>e.status===Ke.FAILED);if(e?.error)throw new ar(e.error.message,e.error.code??"GRAPH_EXECUTION_ERROR",e.error.details);return s.finish(),await a.emit({type:Qe.WORKFLOW_COMPLETED,runId:l,parentRunId:n.parentRunId,workflowId:o.workflowId,path:c,status:Ke.SUCCEEDED,payload:{outputs:d.getWorkflowValues()}}),Ur(s,t,r,Ke.SUCCEEDED,n.metadata)}catch(e){if(e instanceof gr)throw s.finish(),e;s.finish();const i=this.toErrorPayload(e);return e instanceof fr||!0===n.abortSignal?.aborted?(await a.emit({type:Qe.WORKFLOW_CANCELLED,runId:l,parentRunId:n.parentRunId,workflowId:o.workflowId,path:c,status:Ke.CANCELLED,error:i}),Ur(s,t,r,Ke.CANCELLED,n.metadata)):(await a.emit({type:Qe.WORKFLOW_FAILED,runId:l,parentRunId:n.parentRunId,workflowId:o.workflowId,path:c,status:Ke.FAILED,error:i}),Ur(s,t,r,Ke.FAILED,n.metadata))}}async executeLayer(e,t,o,r,n){const i=Math.max(1,r.concurrency??4),a=[...o];for(;a.length>0;){const o=a.splice(0,i);await Promise.all(o.map(o=>this.executeNode(e,t,o,r,n)))}}async executeNode(e,t,o,r,n){if(this.assertNotAborted(r),!this.isNodeActivated(e,t,o))return void await this.skipInactiveNode(e,t,o,r,n);if(!0===o.instance.disabled)return void await this.executeDisabledNode(e,t,o,r,n);const i=new Date,a=[...r.path??[],o.id];await n({type:Qe.NODE_STARTED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.RUNNING}),this.emitNodeStateChanged(e,t,o,a,Ve.RUNNING,Ke.RUNNING,n);const s=await this.resolveNodeInputs(e,t,o,r);if(r.usePinnedValues){const r=await this.tryPinnedValue(e,t,o,s);if(r){e.valueStore.setNodeOutputs(o.id,r.outputs),this.routeOutgoingEdges(e,t,o,r.outputs,n);const d=new Date,l={nodeId:o.id,status:Ke.CACHED,inputs:s,outputs:r.outputs,startedAt:i,finishedAt:d,fromCache:!0,pinned:!0,events:[]};return e.recordNodeResult(l),await n({type:Qe.NODE_CACHE_HIT,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.CACHED,payload:{outputs:r.outputs}}),await n({type:Qe.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.SUCCEEDED,payload:{outputs:r.outputs,fromCache:!0}}),void this.emitNodeStateChanged(e,t,o,a,Ve.SUCCEEDED,Ke.SUCCEEDED,n)}}try{const d=new Mr(e.runId,r.parentRunId,t.workflowId,t.resolved.document,o.instance,o.manifest,a,n,r.metadata,this.engine,r.abortSignal,this.executionLimits(r)),l=await this.resolveNodeParameters(o,s,r),c={nodeId:o.id,kind:o.kind,inputs:s,parameters:l,credentials:this.collectCredentials(o),metadata:o.instance.metadata},p=await this.invokeExecutor(o,c,d),u=this.validateNodeOutputs(o,p??{});e.valueStore.setNodeOutputs(o.id,u),this.routeOutgoingEdges(e,t,o,u,n);const h=new Date,g={nodeId:o.id,status:Ke.SUCCEEDED,inputs:s,outputs:u,startedAt:i,finishedAt:h,events:[]};e.recordNodeResult(g),await n({type:Qe.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.SUCCEEDED,payload:{outputs:u}}),this.emitNodeStateChanged(e,t,o,a,Ve.SUCCEEDED,Ke.SUCCEEDED,n)}catch(d){if(d instanceof gr)throw d;const l=new Date,c=this.toErrorPayload(d),p={nodeId:o.id,status:Ke.FAILED,inputs:s,error:c,startedAt:i,finishedAt:l,events:[]};if(e.recordNodeResult(p),await n({type:Qe.NODE_FAILED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.FAILED,error:c}),this.emitNodeStateChanged(e,t,o,a,Ve.FAILED,Ke.FAILED,n),r.failFast??!0)throw d}}isNodeActivated(e,t,o){const r=(t.incomingByNode.get(o.id)??[]).filter(e=>"data"===e.type);return 0===r.length||r.some(t=>t.sourceNodeId===$o||e.isDataEdgeActive(t.id))}async skipInactiveNode(e,t,o,r,n){const i=new Date,a=[...r.path??[],o.id];await n({type:Qe.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.SKIPPED,payload:{reason:"branchNotSelected"}});const s={nodeId:o.id,status:Ke.SKIPPED,inputs:{},startedAt:i,finishedAt:new Date,events:[]};e.recordNodeResult(s),this.emitNodeStateChanged(e,t,o,a,Ve.SKIPPED,Ke.SKIPPED,n)}async executeDisabledNode(e,t,o,r,n){const i=new Date,a=[...r.path??[],o.id],s=dn.disabledBehaviorOf(o.instance,t.resolved.document.settings);if(await n({type:Qe.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:Ke.SKIPPED,payload:{disabled:!0,behavior:s}}),"skip"===s){const r={nodeId:o.id,status:Ke.SKIPPED,inputs:{},startedAt:i,finishedAt:new Date,events:[]};return e.recordNodeResult(r),void this.emitNodeStateChanged(e,t,o,a,Ve.SKIPPED,Ke.SKIPPED,n)}const d=await this.resolveNodeInputs(e,t,o,r);let l;if("passThroughFirstInput"===s){const r=(t.incomingByNode.get(o.id)??[]).find(e=>"data"===e.type),n=o.manifest.outputs[0]?.id??"value",i=r?e.valueStore.getPort(r.sourceNodeId,r.sourcePort):Object.values(d)[0];l={[n]:i}}else{l={};for(const e of o.manifest.outputs)l[e.id]=e.metadata?.defaultValue}e.valueStore.setNodeOutputs(o.id,l),this.routeOutgoingEdges(e,t,o,l,n);const c={nodeId:o.id,status:Ke.SUCCEEDED,inputs:d,outputs:l,startedAt:i,finishedAt:new Date,events:[]};e.recordNodeResult(c),this.emitNodeStateChanged(e,t,o,a,Ve.SUCCEEDED,Ke.SUCCEEDED,n)}async invokeExecutor(e,t,o){if((r=e.kind)===tn||r.startsWith(tn+"."))throw new ar(`Node '${e.id}' of kind '${e.kind}' requires the mastra engine, which the local backend does not provide`,Mo,{nodeId:e.id,kind:e.kind,backend:Lo});var r;return await e.executor.execute(t,o)}validateNodeOutputs(e,t){const o=e.manifest;if(!0===o.policies?.allowUnknownOutputs)return t;const r=new Set(o.outputs.map(e=>e.id)),n=Object.keys(t).filter(e=>!r.has(e));if(n.length>0)throw new ar(`Node '${e.id}' of kind '${e.kind}' produced unknown output(s): ${n.join(", ")}`,"GRAPH_OUTPUT_VALIDATION_FAILED",{nodeId:e.id,unknownOutputs:n});const i=o.outputs.filter(e=>!0===e.required&&!(e.id in t)).map(e=>e.id);if(i.length>0)throw new ar(`Node '${e.id}' of kind '${e.kind}' did not produce required output(s): ${i.join(", ")}`,"GRAPH_OUTPUT_VALIDATION_FAILED",{nodeId:e.id,missingRequired:i});return t}collectCredentials(e){const t={};for(const o of e.manifest.parameters){if("credential"!==o.type)continue;const r=(e.instance.parameters??{})[o.id];"string"==typeof r&&r.length>0?t[o.id]={credentialId:r,credentialType:o.credentialType??""}:nn(r)&&(t[o.id]={credentialId:r.credentialId,credentialType:r.credentialType})}const o=(e.instance.metadata??{}).credentials;if(o&&"object"==typeof o&&!Array.isArray(o))for(const[e,r]of Object.entries(o)){const o=r;"string"==typeof o&&o.length>0?t[e]={credentialId:o,credentialType:""}:nn(o)&&(t[e]={credentialId:o.credentialId,credentialType:o.credentialType})}return t}async resolveNodeInputs(e,t,o,r){const n={},i=(t.incomingByNode.get(o.id)??[]).filter(e=>"data"===e.type),a=new Map;for(const e of i){const t=a.get(e.targetPort)??[];t.push(e),a.set(e.targetPort,t)}for(const[t,o]of a)if(1===o.length)n[t]=e.valueStore.getPort(o[0].sourceNodeId,o[0].sourcePort);else{let r,i=!1;for(const t of o){const o=e.valueStore.getPort(t.sourceNodeId,t.sourcePort);n[t.sourcePort]=o,void 0!==o&&(r=o,i=!0)}i&&void 0===n[t]&&(n[t]=r)}const s=o.instance.inputBindings??{};for(const e of o.manifest.inputs){const t=s[e.id];if("literal"===t?.mode)n[e.id]=t.value;else if("expression"===t?.mode)n[e.id]=await this.evaluateExpressionBinding(o,t.expression,n,r);else if(void 0===n[e.id]){const t=e.metadata?.defaultValue;void 0!==t&&(n[e.id]=t)}}return n}async resolveNodeParameters(e,t,o){const r=e.instance.parameters??{},n={};for(const[i,a]of Object.entries(r))n[i]=Xt(a)?await this.evaluateValueTemplate(a,e,t,o):a;return n}async evaluateValueTemplate(e,t,o,r){const n=this.codeSandboxEvaluator;if(!n)throw new ar(`Value template on node '${t.id}' requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator`,"GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{nodeId:t.id});const i=e.language??("expression"===e.mode?"javascript":"text"),a="template"===e.mode?(e=>`\`${e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\{\{\s*([\s\S]*?)\s*\}\}/g,(e,t)=>`\${${t}}`)}\``)(e.expression):e.expression,s=r.metadata;return await n.evaluate({code:a,language:"typescript"===i?"typescript":"javascript",input:o,vars:s?.vars??void 0,item:s?.item,index:s?.index,abortSignal:r.abortSignal})}async evaluateExpressionBinding(e,t,o,r){const n=this.codeSandboxEvaluator;if(!n)throw new ar(`Expression binding on node '${e.id}' requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator`,"GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{nodeId:e.id,expression:t});const i=r.metadata;return await n.evaluate({code:t,language:"javascript",input:o,vars:i?.vars??void 0,item:i?.item,index:i?.index,abortSignal:r.abortSignal})}async tryPinnedValue(e,t,o,r){if(!(new wn).shouldUsePinnedValue(o))return;const n=this.createPinningService(e),i=this.computeDependencyFingerprints(e,t,o.id);return n.readPinnedValue(t.workflowId,o,r,i)}computeDependencyFingerprints(e,t,o){const r=this.createPinningService(e),n=(new vn).getDependencies(t,o),i={};for(const o of n){const n=t.nodes.find(e=>e.id===o);if(n){const a=e.nodeResults.get(o),s=a?.inputs??{},d=this.computeDependencyFingerprints(e,t,o);i[o]=r.computeFingerprint(t.workflowId,n,s,d)}}return i}routeOutgoingEdges(e,t,o,r,n){const i=(t.outgoingByNode.get(o.id)??[]).filter(e=>"data"===e.type);for(const a of i){if(!Object.prototype.hasOwnProperty.call(r,a.sourcePort))continue;const i=r[a.sourcePort];e.activateDataEdge(a.id),a.targetNodeId===$o&&e.valueStore.setWorkflowOutput(a.targetPort,i),this.emitEdgeStateChanged(e,t,o,a,Ve.SUCCEEDED,Ke.SUCCEEDED,n),n({type:Qe.EDGE_VALUE_ROUTED,runId:e.runId,workflowId:t.workflowId,edgeId:a.id,nodeId:o.id,path:[],payload:{edge:a,value:i}}).catch(()=>{})}}emitNodeStateChanged(e,t,o,r,n,i,a){a({type:Qe.NODE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:r,status:i,payload:{nodeId:o.id,state:n,runId:e.runId,workflowId:t.workflowId,status:i}}).catch(()=>{})}emitEdgeStateChanged(e,t,o,r,n,i,a){a({type:Qe.EDGE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,edgeId:r.id,nodeId:o.id,path:[],status:i,payload:{edgeId:r.id,state:n,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,status:i}}).catch(()=>{})}createPinningService(e){const t=gn(e.valueStore.getAdapter()??this.valueAdapter);return new yn(t,new wn,new vn)}executionLimits(e){return{maxLoopIterations:e.maxLoopIterations??Bo,maxForeachIterations:e.maxForeachIterations??Ho}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new fr(e.runId??"unknown")}toErrorPayload(e){return e instanceof Error?{name:e.name,message:e.message,stack:e.stack,code:e.graphCode??("number"==typeof e.code?e.code+"":e.code)}:{name:"UnknownError",message:e+""}}}class In{constructor(e){this.catalogue=e}async resolveNodes(e,t,o,...r){const n=new Map;for(const[i,a]of e.entries()){const e=`nodes[${i}]`;if(this.catalogue.has(a.kind,...r))try{const e=await this.catalogue.resolveManifest(a.kind,a,o,...r),t=this.catalogue.getExecutor(a.kind,...r);n.set(a.id,{instance:a,manifest:e,executor:t})}catch(o){t.push({code:"kind.resolution-failed",path:e+".kind",message:`Node '${a.id}' kind '${a.kind}' failed to resolve: ${o.message}`,nodeId:a.id,details:{kind:a.kind}})}else t.push({code:"kind.unknown",path:e+".kind",message:`Node '${a.id}' references kind '${a.kind}' which is not registered in the backend catalogue`,nodeId:a.id,details:{kind:a.kind}})}return n}validateEffectivePorts(e,t,o,r){const n=!0===t.policies?.allowUndeclaredParameters,i=new Set(t.inputs.map(e=>e.id)),a=new Set(t.outputs.map(e=>e.id));for(const a of Object.keys(e.inputBindings??{}))n||i.has(a)||o.push({code:"binding.unknown-port",path:`${r}.inputBindings.${a}`,message:`Node '${e.id}' input binding '${a}' does not refer to an effective input port of kind '${t.kind}'`,nodeId:e.id,details:{effectiveInputs:[...i]}});for(const i of Object.keys(e.outputBindings??{}))n||a.has(i)||o.push({code:"binding.unknown-port",path:`${r}.outputBindings.${i}`,message:`Node '${e.id}' output binding '${i}' does not refer to an effective output port of kind '${t.kind}'`,nodeId:e.id,details:{effectiveOutputs:[...a]}})}}function An(e,t,o="$"){const r=new Set;for(const t of e.edges)"node"===t.source.scope&&r.add(t.source.nodeId),"node"===t.target.scope&&r.add(t.target.nodeId);for(const n of e.nodes){r.has(n.id)||t.push({code:"topology.loose-node",path:`${o}.nodes[${n.id}]`,message:`Node '${n.id}' is connected to nothing; every node must participate in at least one edge`,nodeId:n.id});const e=n.loop?.body;e&&An(e,t,`${o}.nodes[${n.id}].loop.body`)}}class _n{resolveEdges(e,t,o){const r=new Set(e.inputs.map(e=>e.id)),n=new Set(e.outputs.map(e=>e.id)),i=[];for(const[a,s]of(e.edges??[]).entries()){const e=`edges[${a}]`,d=this.resolveEndpoint(s,"source",t,r,n,o,e),l=this.resolveEndpoint(s,"target",t,r,n,o,e);if(!d||!l)continue;if(!this.validateDirectionAndType(s,d,l,t,o,e))continue;const c={id:s.id,type:s.type,sourceNodeId:d.nodeId,sourcePort:d.port,targetNodeId:l.nodeId,targetPort:l.port,metadata:s.metadata,edge:s};void 0!==s.label&&(c.label=s.label),i.push(c)}return i}resolveEndpoint(e,t,o,r,n,i,a){const s=e[t];return $t(s)?("source"===t?r.has(s.port):n.has(s.port))?{nodeId:$o,port:s.port}:void i.push({code:"edge.unknown-port",path:`${a}.${t}`,message:`Edge '${e.id}' ${t} references workflow port '${s.port}' which is not declared on the document boundary`,edgeId:e.id,details:{scope:"workflow",port:s.port}}):Lt(s)?o.get(s.nodeId)?{nodeId:s.nodeId,port:s.port}:void i.push({code:"edge.unknown-node",path:`${a}.${t}`,message:`Edge '${e.id}' ${t} references node '${s.nodeId}' which is not part of the document or did not resolve`,edgeId:e.id,nodeId:s.nodeId}):void i.push({code:"edge.invalid-endpoint",path:`${a}.${t}`,message:`Edge '${e.id}' ${t} endpoint is not a valid GraphEndpoint`,edgeId:e.id})}validateDirectionAndType(e,t,o,r,n,i){let a=!0;const s=t.nodeId===$o?void 0:r.get(t.nodeId),d=o.nodeId===$o?void 0:r.get(o.nodeId),l=e=>!0===e?.manifest.policies?.allowUndeclaredParameters;if("data"===e.type)!s||l(s)||this.hasPortDirection(s,t.port,"output")||(this.pushPortIssue(e,"source",t,s,n,i),a=!1),!d||l(d)||this.hasPortDirection(d,o.port,"input")||(this.pushPortIssue(e,"target",o,d,n,i),a=!1);else{if(!s||!d)return n.push({code:"edge.boundary-routing",path:i,message:`Connection edge '${e.id}' must connect two node connection ports; the workflow boundary only routes data`,edgeId:e.id}),!1;if(!(l(s)||l(d)||this.hasPortDirection(s,t.port,"connection")&&this.hasPortDirection(d,o.port,"connection")))return n.push({code:"edge.type-mismatch",path:i,message:`Connection edge '${e.id}' endpoints must both be connection ports`,edgeId:e.id,details:{sourcePort:t.port,targetPort:o.port}}),!1}return a}hasPortDirection(e,t,o){return("input"===o?e.manifest.inputs:"output"===o?e.manifest.outputs:e.manifest.connections??[]).some(e=>e.id===t)}pushPortIssue(e,t,o,r,n,i){const a="source"===t?"output":"input";n.push({code:"data"===e.type?"edge.invalid-direction":"edge.type-mismatch",path:`${i}.${t}`,message:`Edge '${e.id}' ${t} port '${o.port}' on node '${o.nodeId}' is not an ${a} port of kind '${r.manifest.kind}'`,edgeId:e.id,nodeId:o.nodeId,details:{port:o.port,expected:a}})}}class On{validate(e,t){this.validateDuplicates(e.edges,t),this.validatePolicies(e,t)}validateDuplicates(e,t){const o=new Map;for(const r of e){const e=`${r.sourceNodeId}:${r.sourcePort}->${r.targetNodeId}:${r.targetPort}`,n=o.get(e);n?t.push({code:"connection.duplicate-edge",path:`edges[${r.id}]`,message:`Edge '${r.id}' duplicates the routing of edge '${n.id}' (${e})`,edgeId:r.id,details:{duplicateOf:n.id,routing:e}}):o.set(e,r)}}validatePolicies(e,t){const o=new Map;for(const t of e.edges){if("connection"!==t.type)continue;const e=`${t.targetNodeId}:${t.targetPort}`,r=o.get(e)??[];r.push(t),o.set(e,r)}for(const o of e.edges){if("connection"!==o.type)continue;const r=e.nodeById.get(o.targetNodeId),n=r?.manifest.connections?.find(e=>e.id===o.targetPort)?.connectionPolicy;this.validateEdgePolicy(o,e.nodeById,n,t),this.validateCategoryMatch(o,e.nodeById,t)}for(const[r,n]of o){const o=r.lastIndexOf(":"),i=r.slice(0,o),a=r.slice(o+1),s=e.nodeById.get(i),d=s?.manifest.connections?.find(e=>e.id===a)?.connectionPolicy;if(!d)continue;const l=void 0!==d.maxConnections?d.maxConnections:!1===d.allowMultiple?1:1/0;n.length>l&&t.push({code:"connection.max-connections",path:`edges[${n[n.length-1].id}]`,message:`Connection port '${a}' on node '${i}' accepts at most ${l} connection(s) but has ${n.length}`,nodeId:i,edgeId:n[n.length-1].id,details:{port:a,max:l,actual:n.length}})}}validateCategoryMatch(e,t,o){const r=t.get(e.sourceNodeId),n=t.get(e.targetNodeId),i=r?.manifest.connections?.find(t=>t.id===e.sourcePort)?.category,a=n?.manifest.connections?.find(t=>t.id===e.targetPort)?.category;i&&a&&i!==a&&o.push({code:"connection.category-mismatch",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' joins source port '${e.sourcePort}' (category '${i}') to target port '${e.targetPort}' (category '${a}'); connection categories must match`,edgeId:e.id,nodeId:e.sourceNodeId,details:{sourceCategory:i,targetCategory:a}})}validateEdgePolicy(e,t,o,r){if(e.sourceNodeId===e.targetNodeId&&!o?.allowSelf)return void r.push({code:"connection.self-connection",path:`edges[${e.id}]`,message:`Edge '${e.id}' connects node '${e.sourceNodeId}' to itself, which the target port policy does not allow`,edgeId:e.id,nodeId:e.sourceNodeId});if(!o)return;const n=t.get(e.sourceNodeId),i=n?.manifest.kind;if(!o.allowedNodeKinds?.length||i&&o.allowedNodeKinds.includes(i)||r.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source kind '${i??"unknown"}' is not in the allowed node kinds of target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{allowedNodeKinds:o.allowedNodeKinds}}),i&&o.blockedNodeKinds?.includes(i)&&r.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source kind '${i}' is blocked by target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{blockedNodeKinds:o.blockedNodeKinds}}),o.allowedPortCategories?.length){const t=n?.manifest.connections?.find(t=>t.id===e.sourcePort)?.category;t&&o.allowedPortCategories.includes(t)||r.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source port '${e.sourcePort}' category '${t??"unknown"}' is not in the allowed port categories of target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{allowedPortCategories:o.allowedPortCategories}})}}}class En{constructor(e){this.authorizer=e}async validate(e,t,o,r){const n=this.collectReferences(e,t);for(const i of t.credentials??[]){const a=n.find(e=>void 0===e.credentialType||e.credentialType===i.type);if(a){if(this.checkType(a,i))o.push({code:"credential.type-mismatch",path:r,message:`Node '${e.id}' credential '${a.credentialId}' has type '${a.credentialType}' but kind '${t.kind}' requires '${i.type}'`,nodeId:e.id,details:{credentialType:a.credentialType??"",requiredType:i.type}});else if(this.authorizer){if(!await this.authorizer.hasCredential(a)){o.push({code:"credential.not-found",path:r,message:`Node '${e.id}' references credential '${a.credentialId}' which does not exist`,nodeId:e.id,details:{credentialId:a.credentialId}});continue}await this.authorizer.authorize(a,i)||o.push({code:"credential.unauthorized",path:r,message:`Node '${e.id}' is not authorized to use credential '${a.credentialId}'`,nodeId:e.id,details:{credentialId:a.credentialId}})}}else!1!==i.required&&o.push({code:"credential.missing",path:r,message:`Node '${e.id}' does not provide the required credential of type '${i.type}'`,nodeId:e.id,details:{credentialType:i.type}})}this.scanPlainSecrets(e,o,r)}collectReferences(e,t){const o=[];for(const r of t.parameters){if("credential"!==r.type)continue;const t=(e.parameters??{})[r.id];nn(t)&&o.push(this.normalize(t,r.credentialType))}const r=(e.metadata??{}).credentials;if(r&&"object"==typeof r&&!Array.isArray(r))for(const e of Object.values(r))nn(e)&&o.push(this.normalize(e));return o}normalize(e,t){return"string"==typeof e?{credentialId:e,credentialType:t??""}:{credentialId:e.credentialId,credentialType:e.credentialType??t??""}}checkType(e,t){return void 0!==e.credentialType&&e.credentialType!==t.type}scanPlainSecrets(e,t,o){const r=new Set(sn.map(e=>e.toLowerCase()));for(const[n,i]of Object.entries(e.parameters??{}))this.scanPlainSecretValue(i,[n],e,o+".parameters",r,t);for(const[n,i]of Object.entries(e.metadata??{}))this.scanPlainSecretValue(i,[n],e,o+".metadata",r,t)}scanPlainSecretValue(e,t,o,r,n,i,a=0){const s=t[t.length-1];if(n.has(s.toLowerCase()))i.push({code:"credential.plain-secret",path:`${r}.${t.join(".")}`,message:`Node '${o.id}' carries plain secret material in '${t.join(".")}'; workflow documents may only hold credential references`,nodeId:o.id});else if(8>a&&null!==e)if(Array.isArray(e))for(const s of e)this.scanPlainSecretValue(s,[...t,"[]"],o,r,n,i,a+1);else if("object"==typeof e)for(const[s,d]of Object.entries(e))this.scanPlainSecretValue(d,[...t,s],o,r,n,i,a+1)}}class kn extends E{constructor(e,t=[]){super(e),this.issues=t,this.name=kn.name}}class Sn extends E{constructor(e,t){super(e),this.edgeId=t,this.name=Sn.name}}class Rn extends F{constructor(e){super(e),this.name=Rn.name}}const Cn={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},Nn=["node","definition","executor","execute","ports","component"];function Tn(e){if(!e||"object"!=typeof e)return!1;const t=e;return Yt(t.document)&&Array.isArray(t.nodes)&&Array.isArray(t.edges)&&t.nodeById instanceof Map&&t.incomingByNode instanceof Map&&t.outgoingByNode instanceof Map&&t.nodes.every(e=>null!==e&&"object"==typeof e&&"object"==typeof e.instance&&"object"==typeof e.manifest&&"object"==typeof e.executor)}function Dn(e,t){const o=[];for(const r of Object.keys(e))Nn.includes(r)&&o.push({code:"document.forbidden-field",path:`${t}.${r}`,message:`Field '${r}' is not accepted in a canonical workflow document: node, definition, executor, execute, ports and component fields are rejected`,details:{field:r}});return o}class Pn{constructor(e){this.options=e,this.parameterValidator=new dn,this.edgeValidator=new _n,this.connectionPolicyValidator=new On,this.nodeValidator=new In(e.catalogue),this.credentialValidator=new En(e.credentialAuthorizer)}async validateOrThrow(e,...t){const o=await this.validate(e,0,...t);if(!o.valid||!o.resolved)throw new kn(`Graph workflow document '${e.id}' failed validation with ${o.issues.length} issue(s)`,o.issues);return o.resolved}async validate(e,t=0,...o){const r=[],n={...Cn,...this.options.limits};if(!await this.validateStructure(e,n,t,r,...o))return{valid:!1,issues:r};const i=await this.nodeValidator.resolveNodes(e.nodes,r,this.options.resolutionContext,...o),a=e.nodes.filter(e=>i.has(e.id)).map(e=>i.get(e.id)),s=(e=>{const t=new Map;for(const o of e.edges??[]){if("data"!==o.type)continue;const e=o.target;if("node"!==e.scope)continue;const r=t.get(e.nodeId)??new Set;r.add(e.port),t.set(e.nodeId,r)}return t})(e);for(const e of a)this.parameterValidator.validate(e.instance,e.manifest,r,`nodes[${e.instance.id}]`,s.get(e.instance.id));for(const e of a)this.nodeValidator.validateEffectivePorts(e.instance,e.manifest,r,`nodes[${e.instance.id}]`);const d=this.edgeValidator.resolveEdges(e,i,r),l=new Map,c=new Map;for(const e of d){if(e.targetNodeId!==$o){const t=l.get(e.targetNodeId)??[];t.push(e),l.set(e.targetNodeId,t)}if(e.sourceNodeId!==$o){const t=c.get(e.sourceNodeId)??[];t.push(e),c.set(e.sourceNodeId,t)}}this.connectionPolicyValidator.validate({edges:d,nodeById:i},r),this.validateAcyclicity(a,d,e,r),An(e,r);for(const e of a)this.parameterValidator.validateBindingSatisfaction(e.instance,e.manifest,l.get(e.instance.id)??[],r,`nodes[${e.instance.id}]`,{allowLiteralAndEdgeBindings:this.options.allowLiteralAndEdgeBindings});this.validateRequiredWorkflowOutputs(e,c,r);for(const e of a)await this.credentialValidator.validate(e.instance,e.manifest,r,`nodes[${e.instance.id}]`);return this.validateCapabilities(a,r),r.length>0?{valid:!1,issues:r}:{valid:!0,issues:r,resolved:{document:e,nodes:a,edges:d,nodeById:i,incomingByNode:l,outgoingByNode:c}}}async validateStructure(e,t,o,r,...n){if(!Yt(e))return r.push({code:"document.shape",path:"$",message:"Payload is not a canonical GraphWorkflowDocument: id and name must be strings and inputs, outputs, nodes and edges must be arrays"}),!1;if(e.id&&e.id.trim()||r.push({code:"document.empty-id",path:"$.id",message:"Workflow document id must be a non-empty string"}),!Et(e))return r.push({code:"document.json-unsafe",path:"$",message:"Document contains JSON-unsafe values: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys are rejected"}),!1;r.push(...Dn(e,"$"));for(const t of[...e.inputs,...e.outputs])r.push(...Dn(t,"ports"));for(const t of e.nodes)r.push(...Dn(t,`nodes[${t.id}]`));for(const t of e.edges)r.push(...Dn(t,`edges[${t.id}]`));this.validateUniqueIds(e,r),this.validateLimits(e,t,o,r);try{Bt(e)}catch(e){r.push({code:"document.structure",path:"$",message:e instanceof Error?e.message:e+""})}return await this.validateNestedBodies(e,o,r,...n),!0}validateUniqueIds(e,t){const o=new Set,r=new Set;for(const[n,i]of[["input",e.inputs],["output",e.outputs]]){const e="input"===n?o:r;for(const o of i)e.has(o.id)?t.push({code:"document.duplicate-port-id",path:`${"input"===n?"inputs":"outputs"}[${o.id}]`,message:`Workflow ${n} port '${o.id}' is declared more than once; workflow port ids must be unique`}):e.add(o.id)}const n=new Set;for(const o of e.nodes)n.has(o.id)?t.push({code:"document.duplicate-node-id",path:`nodes[${o.id}]`,message:`Node '${o.id}' is declared more than once; node ids must be unique`,nodeId:o.id}):n.add(o.id);const i=new Set;for(const o of e.edges)i.has(o.id)?t.push({code:"document.duplicate-edge-id",path:`edges[${o.id}]`,message:`Edge '${o.id}' is declared more than once; edge ids must be unique`,edgeId:o.id}):i.add(o.id)}validateLimits(e,t,o,r){e.nodes.length>t.maxNodes&&r.push({code:"document.limit.nodes",path:"$.nodes",message:`Document declares ${e.nodes.length} nodes; at most ${t.maxNodes} are allowed`,details:{count:e.nodes.length,limit:t.maxNodes}}),e.edges.length>t.maxEdges&&r.push({code:"document.limit.edges",path:"$.edges",message:`Document declares ${e.edges.length} edges; at most ${t.maxEdges} are allowed`,details:{count:e.edges.length,limit:t.maxEdges}}),o>t.maxNestingDepth&&r.push({code:"document.limit.depth",path:"$",message:`Document nests loop bodies ${o} levels deep; at most ${t.maxNestingDepth} levels are allowed`,details:{depth:o,limit:t.maxNestingDepth}});const n=Buffer.byteLength(JSON.stringify(e),"utf8");n>t.maxDocumentBytes&&r.push({code:"document.limit.size",path:"$",message:`Document serializes to ${n} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,details:{bytes:n,limit:t.maxDocumentBytes}})}async validateNestedBodies(e,t,o,...r){for(const n of e.nodes){const e=[["loop.body",n.loop?.body],["errorBoundary.try",n.errorBoundary?.try],["errorBoundary.catch",n.errorBoundary?.catch],["errorBoundary.finally",n.errorBoundary?.finally]];for(const[i,a]of e){if(!a)continue;const e=await this.validate(a,t+1,...r);for(const t of e.issues)o.push({...t,path:`nodes[${n.id}].${i}.${t.path}`,nodeId:t.nodeId??n.id})}}}validateAcyclicity(e,t,o,r){const n=new Set(e.map(e=>e.instance.id)),i=new Map(e.map(e=>[e.instance.id,0]));for(const e of t)n.has(e.sourceNodeId)&&i.has(e.targetNodeId)&&i.set(e.targetNodeId,(i.get(e.targetNodeId)??0)+1);const a=[...i.entries()].filter(([,e])=>0===e).map(([e])=>e),s=[];for(;a.length>0;){const e=a.shift();s.push(e);for(const o of t){if(o.sourceNodeId!==e)continue;if(!i.has(o.targetNodeId))continue;const t=(i.get(o.targetNodeId)??1)-1;i.set(o.targetNodeId,t),0===t&&a.push(o.targetNodeId)}}if(s.length!==i.size){const e=[...i.keys()].filter(e=>!s.includes(e));r.push({code:"topology.cycle",path:"$.edges",message:`Workflow '${o.id}' contains an unsupported cycle involving node(s): ${e.join(", ")}`,details:{cyclicNodes:e}})}}validateRequiredWorkflowOutputs(e,t,o){const r=new Set;for(const e of t.values())for(const t of e)t.targetNodeId===$o&&r.add(t.targetPort);for(const t of e.outputs)!0===t.required&&void 0===t.defaultValue&&(r.has(t.id)||o.push({code:"topology.required-output-unsatisfiable",path:`outputs[${t.id}]`,message:`Required workflow output '${t.id}' has no incoming edge from any node`}))}validateCapabilities(e,t){for(const o of e){const e=o.manifest;for(const r of e.capabilities??[])to(r)||t.push({code:"capability.invalid",path:`nodes[${o.instance.id}]`,message:`Kind '${e.kind}' declares unknown capability '${r+""}'`,nodeId:o.instance.id,details:{capability:r+""}});!0!==e.policies?.allowUndeclaredParameters&&o.instance.loop&&((e.capabilities??[]).includes("loop")||t.push({code:"capability.loop-not-supported",path:`nodes[${o.instance.id}].loop`,message:`Node '${o.instance.id}' carries loop configuration but kind '${e.kind}' does not declare the 'loop' capability`,nodeId:o.instance.id}))}}}let jn=class extends H{constructor(){super()}async plan(e,...t){const{log:o}=(await this.logCtx(t,"plan",!0)).for(this.plan);if(o.debug(`Planning resolved workflow '${e?.document?.id??"unknown"}'`),!Tn(e))throw new hr("GraphExecutionPlanner.plan accepts only a GraphResolvedWorkflow produced by the nine-stage validation gate; raw workflow definitions and inline node definitions are rejected",{received:(r=e,r&&"object"==typeof r?{reason:"input is not a GraphResolvedWorkflow",looksLikeWorkflowDefinition:"nodes"in r&&"relations"in r&&!("nodeById"in r),hasResolvedNodes:Array.isArray(r.nodes)}:{reason:"input is not an object"})});var r;const n=this.buildPlanNodes(e),i=this.buildPlanEdges(e),a=this.buildIncomingMap(i),s=this.buildOutgoingMap(i),d=this.topologicalLayers(n,i);return{resolved:e,workflowId:e.document.id||e.document.name,nodes:n,edges:i,layers:d,incomingByNode:a,outgoingByNode:s}}buildPlanNodes(e){return e.nodes.map(e=>({id:e.instance.id,kind:e.manifest.kind,instance:e.instance,manifest:e.manifest,executor:e.executor,inputPorts:e.manifest.inputs.map(e=>e.id),outputPorts:e.manifest.outputs.map(e=>e.id),connectionPorts:(e.manifest.connections??[]).map(e=>e.id),metadata:e.instance.metadata}))}buildPlanEdges(e){return e.edges.map(e=>({id:e.id,type:e.type,sourceNodeId:e.sourceNodeId,sourcePort:e.sourcePort,targetNodeId:e.targetNodeId,targetPort:e.targetPort,...void 0!==e.label?{label:e.label}:{},metadata:e.metadata}))}buildIncomingMap(e){const t=new Map;for(const o of e){if(o.targetNodeId===$o)continue;const e=t.get(o.targetNodeId)??[];e.push(o),t.set(o.targetNodeId,e)}return t}buildOutgoingMap(e){const t=new Map;for(const o of e){if(o.sourceNodeId===$o)continue;const e=t.get(o.sourceNodeId)??[];e.push(o),t.set(o.sourceNodeId,e)}return t}topologicalLayers(e,t){const o=e.filter(e=>e.id!==$o),r=new Set(o.map(e=>e.id)),n=t.filter(e=>r.has(e.sourceNodeId)&&r.has(e.targetNodeId)),i=new Map;for(const e of o)i.set(e.id,0);for(const e of n)i.set(e.targetNodeId,(i.get(e.targetNodeId)??0)+1);const a=[],s=new Set;let d=o.filter(e=>0===(i.get(e.id)??0)),l=0;for(;d.length>0;){const e={index:l++,nodes:d};a.push(e);const t=[];for(const e of d){s.add(e.id);const r=n.filter(t=>t.sourceNodeId===e.id);for(const e of r){const r=(i.get(e.targetNodeId)??1)-1;if(i.set(e.targetNodeId,r),0===r&&!s.has(e.targetNodeId)){const r=o.find(t=>t.id===e.targetNodeId);r&&t.push(r)}}}d=t}if(s.size!==o.length){const e=o.filter(e=>!s.has(e.id)).map(e=>e.id);throw new sr({unplannedNodes:e,workflowId:o[0]?.manifest.kind})}return a}};jn=R([B(),C("design:paramtypes",[])],jn);class $n{constructor(){this.pending=new Map}register(e,t){return this.cancel(e),new Promise((o,r)=>{const n={resolve:o};void 0!==t&&Number.isFinite(t)&&t>0&&(n.timer=setTimeout(()=>{this.pending.delete(e),r(new ar(`No webhook response was produced for run '${e}' within ${t}ms`,"GRAPH_WEBHOOK_RESPONSE_TIMEOUT",{runId:e,timeoutMs:t}))},t),n.timer.unref?.()),this.pending.set(e,n)})}has(e){return this.pending.has(e)}deliver(e,t){const o=this.pending.get(e);return!!o&&(o.timer&&clearTimeout(o.timer),this.pending.delete(e),o.resolve(t),!0)}cancel(e){const t=this.pending.get(e);t&&(t.timer&&clearTimeout(t.timer),this.pending.delete(e))}clear(){for(const e of[...this.pending.keys()])this.cancel(e)}}let Ln=class extends j{constructor(e){super(e)}};R([N({type:String,generated:!1}),C("design:type",String)],Ln.prototype,"id",void 0),R([T(),D(),C("design:type",String)],Ln.prototype,"tableName",void 0),R([T(),D(),C("design:type",String)],Ln.prototype,"rowId",void 0),R([T(),C("design:type",Object)],Ln.prototype,"data",void 0),R([T(),C("design:type",Date)],Ln.prototype,"createdAt",void 0),R([T(),C("design:type",Date)],Ln.prototype,"updatedAt",void 0),Ln=R([P("graph_data_table"),I(),C("design:paramtypes",[Object])],Ln);const Mn=/^[A-Za-z0-9_.-]+$/;function Gn(e,t){return`${e}:${t}`}function Un(e){if(!e||e.length>128||!Mn.test(e))throw new ar(`Data table name '${e}' is invalid`,"GRAPH_DATA_TABLE_INVALID_NAME",{tableName:e})}function Fn(e){if(!e||e.length>256)throw new ar(`Data table row id '${e}' is invalid`,"GRAPH_DATA_TABLE_INVALID_ROW_ID",{rowId:e})}function Bn(e){let t;try{t=JSON.stringify(e)}catch{throw new ar("Data table row payload is not JSON-serializable","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{limitBytes:er})}if(void 0===t)throw new ar("Data table row payload is not JSON-serializable","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{limitBytes:er});const o=Buffer.byteLength(t,"utf8");if(o>er)throw new ar("Data table row payload exceeds the 1048576-byte limit","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{bytes:o,limitBytes:er})}function Hn(e){return{...e.data,id:e.rowId}}let qn=class extends U{constructor(e){super(e,Ln,!0)}async insertRow(e,t,o,...r){Un(e),Fn(t),Bn(o),await this.assertRowCapacity(e,...r);const n=new Date,i=new Ln({id:Gn(e,t),tableName:e,rowId:t,data:{...o},createdAt:n,updatedAt:n});return Hn(await this.create(i,...r))}async upsertRow(e,t,o,...r){if(Un(e),Fn(t),Bn(o),!await this.readRow(e,t,...r))return this.insertRow(e,t,o,...r);const n=await this.read(Gn(e,t),...r);return n.data={...o},n.updatedAt=new Date,Hn(await this.update(n,...r))}async readRow(e,t,...o){Un(e),Fn(t);try{return Hn(await this.read(Gn(e,t),...o))}catch{return}}async listRows(e,t,...o){Un(e);const r=void 0!==t&&Number.isFinite(t)&&t>=0?Math.floor(t):tr;if(0===r)return[];const n=Math.min(r,tr);return(await this.select().where(q.attr("tableName").eq(e)).orderBy("rowId",W.ASC).limit(n).execute(...o)).map(Hn)}async assertRowCapacity(e,...t){if((await this.listRows(e,Zo,...t)).length>=Zo)throw new ar(`Data table '${e}' reached the 10000-row limit`,"GRAPH_DATA_TABLE_ROW_LIMIT_EXCEEDED",{tableName:e,limit:Zo})}async deleteRow(e,t,...o){Un(e),Fn(t);try{return await this.delete(Gn(e,t),...o),!0}catch{return!1}}async clearTable(e,...t){const o=await this.listRows(e,void 0,...t);for(const r of o)await this.deleteRow(e,r.id+"",...t);return o.length}};function Wn(e){return new(0,U.forModel(Ln,e.alias).constructor)(e)}qn=R([G(Ln,y),C("design:paramtypes",[Function])],qn);const Kn=new Set(["engine","valueAdapter","codeSandboxEvaluator","workflowStore"]);function Vn(e){for(let t=e.length-1;t>=0;t-=1){const o=e[t];if(!o||"object"!=typeof o)continue;const r=o;if("function"==typeof r.get&&"function"==typeof r.accumulate&&void 0!==r.cache)return Cr(o)}return{}}function zn(e,t){const o={};for(const[r,n]of Object.entries(e??{}))Kn.has(r)&&!t.has(r)||(o[r]=n);return o}class Qn extends K{constructor(){super(),this.webhookResponseRegistry=new $n,this.runSubWorkflowDepth=new Map,this.runRootId=new Map,this.rootChildRunCounts=new Map}async initialize(...e){const t=e[0];if(!t||"object"!=typeof t||!t.registry)return this._config=void 0,this._client=void 0,{config:void 0,client:void 0};const o=t.catalogue??t.registry.catalog,r=t.valueAdapter??V.current;if(!r)throw new ar("GraphExecutionEngine requires a Decaf adapter for cached/pinned values: pass `valueAdapter` or configure one via `Adapter.setCurrent(...)`","GRAPH_VALUE_ADAPTER_MISSING");const n=t.backend??Hr.current??new xn,i={registry:t.registry,catalogue:o,planner:t.planner??new jn,backend:n,valueAdapter:r,eventEmitter:t.eventEmitter??new mr,documentValidator:t.documentValidator??new Pn({catalogue:o,limits:t.documentLimits,credentialAuthorizer:t.credentialAuthorizer}),authValidator:new Dr({enabled:!0===t.authEnabled,...t.authMatch?{match:t.authMatch}:{}}),...t.codeSandboxEvaluator?{codeSandboxEvaluator:t.codeSandboxEvaluator}:{},...t.nodeCredentials?{nodeCredentials:new Pr(t.nodeCredentials)}:{}};this._config=t,this._client=i;const a=new Set(["engine","valueAdapter"]);t.codeSandboxEvaluator&&a.add("codeSandboxEvaluator"),t.workflowStore&&a.add("workflowStore");const s=zn(n.config,a);if(await n.initialize({...s,valueAdapter:r,...t.codeSandboxEvaluator?{codeSandboxEvaluator:t.codeSandboxEvaluator}:{},...t.workflowStore?{workflowStore:t.workflowStore}:{},engine:this}),t.seedWorkflows&&t.seedWorkflows.length>0){const o=n.seedWorkflows;if("function"!=typeof o)throw new ar(`Graph execution backend '${n.constructor?.name??"GraphExecutionBackend"}' does not support workflow seeding`,"GRAPH_BACKEND_SEED_NOT_SUPPORTED",{backend:n.constructor?.name??"GraphExecutionBackend"});await o.call(n,t.seedWorkflows,...e.slice(1))}return await(t.onEngineCreated?.(this)),{config:t,client:i}}get codeSandboxEvaluator(){return this.client.codeSandboxEvaluator}get nodeCredentials(){return this.client.nodeCredentials}get dataTableStore(){return this.dataTableRepository||(this.dataTableRepository=Wn(this.valueAdapter)),this.dataTableRepository}get webhookResponses(){return this.webhookResponseRegistry}get emitter(){return this.client.eventEmitter}get planner(){return this.client.planner}get valueAdapter(){return this.client.valueAdapter}get defaultOptions(){return this.config.defaultOptions??{}}get documentValidator(){return this.client.documentValidator}observe(e){return this.emitter.observe(e)}unObserve(e){this.emitter.unObserve(e)}async dispatchEvent(e){await this.emitter.updateObservers(e)}async execute(e,t={},o={},...r){const{log:n,ctx:i}=(await this.logCtx(r,"execute",!0)).for(this.execute);n.debug(`Executing workflow '${e.id||e.name}'`);const a=this.mergeOptions(o);this.assertNotAborted(a);const s=Tr(Cr(i),a.auth);a.auth=s,a.metadata={...a.metadata??{},...s};const d=a.runId??this.generateRunId();a.runId=d;const l=a.path??[];this.enterExecutionBudget(d,a);try{const o=new br,c=gn(this.valueAdapter);c.seedWorkflowInputs(this.withWorkflowInputDefaults(e,t));const p=new Fr(this.emitter,o,{runId:d,parentRunId:a.parentRunId,workflowId:e.id||e.name,path:l,engine:this,...this.codeSandboxEvaluator?{codeSandboxEvaluator:this.codeSandboxEvaluator}:{}});await p.emit({type:Qe.VALIDATION_STARTED,status:Ke.PLANNING});const u=await this.documentValidator.validate(e,0,i);if(!u.valid||!u.resolved)throw await p.emit({type:Qe.VALIDATION_FAILED,status:Ke.FAILED,payload:{issues:u.issues}}),new kn(`Graph workflow document '${e.id}' failed validation with ${u.issues.length} issue(s)`,u.issues);await p.emit({type:Qe.VALIDATION_COMPLETED,status:Ke.PLANNING,payload:{issues:u.issues.length}}),this.assertNotAborted(a);const h=await this.planner.plan(u.resolved);this.client.authValidator.validate(e,h,s,n),n.debug(`Authorized workflow '${e.id||e.name}' for user ${s.user??"anonymous"}`),this.assertCodeModeSupported(e);const g=new Gr(d,h,c,o);return p.bindFrame(g),await p.emit({type:Qe.WORKFLOW_STARTED,runId:d,parentRunId:a.parentRunId,workflowId:h.workflowId,path:l,status:Ke.RUNNING,payload:{inputs:t}}),await p.emit({type:Qe.WORKFLOW_PLANNED,runId:d,parentRunId:a.parentRunId,workflowId:h.workflowId,path:l,status:Ke.PLANNING,payload:{layers:h.layers.length,nodes:h.nodes.length}}),await this.client.backend.execute({document:e,plan:h,inputs:t,options:a,events:p},...r)}finally{this.releaseExecutionBudget(d)}}get backend(){return this.client.backend}get backendCapabilities(){return Br(this.client.backend)}async listWorkflows(...e){const t=this.client.backend;if("supported"!==Br(t).workflows.list||"function"!=typeof t.listWorkflows)throw new ar(`Graph execution backend '${this.backendName}' does not support workflow listing`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:this.backendName});return await t.listWorkflows(...e)}async getWorkflow(e,...t){const o=this.client.backend;if("supported"!==Br(o).workflows.get||"function"!=typeof o.getWorkflow)throw new ar(`Graph execution backend '${this.backendName}' does not support workflow lookup`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:this.backendName,workflowId:e});const r=await o.getWorkflow(e,...t);return this.assertWorkflowReadAccess(r,Vn(t)),r}assertWorkflowReadAccess(e,t,o){this.client.authValidator.validateWorkflowRead(e,t,o)}async listEngineWorkflows(e,...t){const o=Hr.getOrFail(e);if("supported"!==Br(o).workflows.list||"function"!=typeof o.listWorkflows)throw new ar(`Graph execution backend '${e}' does not support workflow listing`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:e});return await o.listWorkflows(...t)}async getEngineWorkflow(e,t,...o){const r=Hr.getOrFail(e);if("supported"!==Br(r).workflows.get||"function"!=typeof r.getWorkflow)throw new ar(`Graph execution backend '${e}' does not support workflow lookup`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:e,workflowId:t});const n=await r.getWorkflow(t,...o);return this.assertWorkflowReadAccess(n,Vn(o)),n}get backendName(){return this.client.backend.constructor?.name??"GraphExecutionBackend"}assertCodeModeSupported(e){const t=this.client.backend;if(t.local)return;const o=Zr(e);if(0!==o.length){if("unsupported"===t.codeMode)throw new ar(`Graph execution backend '${this.backendName}' does not support code-mode workflows`,"GRAPH_CODE_MODE_UNSUPPORTED_BACKEND",{backend:this.backendName,surfaces:o});if(!this.codeSandboxEvaluator)throw new ar("Code-mode workflows require a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{backend:this.backendName,surfaces:o})}}async pinNode(e){const t=this.createPinningService();await t.pinNode(e),await this.emitPinningEvent(e.nodeId,Qe.NODE_PINNED)}async unpinNode(e){const t=this.createPinningService();await t.unpinNode(e),await this.emitPinningEvent(e.nodeId,Qe.NODE_UNPINNED)}createPinningService(){const e=gn(this.valueAdapter);return new yn(e,new wn,new vn)}async emitPinningEvent(e,t){const o=(new br).create({id:"",sequence:0,timestamp:new Date,runId:"pinning",workflowId:"",type:t,nodeId:e,path:[]});await this.emitter.updateObservers(o)}withWorkflowInputDefaults(e,t){const o={...t};for(const t of e.inputs)void 0===o[t.id]&&void 0!==t.defaultValue&&(o[t.id]=t.defaultValue);return o}mergeOptions(e){return{concurrency:4,failFast:!0,validateInputs:!0,validateOutputs:!0,maxLoopIterations:Bo,maxForeachIterations:Ho,usePinnedValues:!0,writeThroughCache:!1,path:[],metadata:{},...this.defaultOptions,...e}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new fr(e.runId??"unknown")}enterExecutionBudget(e,t){const o=t.parentRunId,r=t.path??[],n="subworkflow"===r[r.length-1],i=r.filter(e=>"subworkflow"===e).length,a=o?this.runSubWorkflowDepth.get(o)??Math.max(0,i-(n?1:0)):0,s=o?a+(n?1:0):0,d=t.maxSubWorkflowDepth??10;if(s>d)throw new ar(`Graph run '${e}' exceeds the maximum sub-workflow depth of ${d}`,"GRAPH_SUB_WORKFLOW_DEPTH_EXCEEDED",{runId:e,parentRunId:o,depth:s,maxDepth:d});if(!o)return this.runSubWorkflowDepth.set(e,s),this.runRootId.set(e,e),void this.rootChildRunCounts.set(e,0);const l=this.runRootId.get(o)??o,c=t.maxChildRuns??1e3;let p=this.rootChildRunCounts.get(l)??0;if(n){if(p+=1,p>c)throw new ar(`Graph run '${l}' exceeds the maximum of ${c} sub-workflow child runs`,"GRAPH_SUB_WORKFLOW_CHILD_LIMIT_EXCEEDED",{runId:e,rootRunId:l,parentRunId:o,childCount:p,maxChildren:c});this.rootChildRunCounts.set(l,p)}this.runSubWorkflowDepth.set(e,s),this.runRootId.set(e,l)}releaseExecutionBudget(e){const t=this.runRootId.get(e);this.runSubWorkflowDepth.delete(e),this.runRootId.delete(e),t===e&&this.rootChildRunCounts.delete(e)}generateRunId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new ar("Cannot generate a graph run id: crypto.randomUUID is unavailable in this runtime","GRAPH_RUN_ID_ERROR",{runtime:typeof globalThis.crypto});return e.randomUUID()}}const Jn=new Set(["process","require","module","exports","global","globalThis","Function","eval","fetch","XMLHttpRequest","WebSocket","Worker","Deno","Bun","__dispatch"]);class Xn extends K{constructor(){super()}async initialize(...e){const t=e[0]??{},o=t&&"object"==typeof t?t:{};return this._config=o,this._client=Q,{config:o,client:Q}}get defaultTimeoutMs(){return this.config.timeoutMs??1e3}get defaultMemoryMb(){return this.config.memoryMb??32}async evaluate(e,...t){(await this.logCtx(t,"evaluate",!0)).for(this.evaluate);const o=e.code;if(!o||"string"!=typeof o||0===o.trim().length)throw new ar("Code sandbox received empty code","GRAPH_CODE_SANDBOX_EMPTY_CODE");const r=((e,t)=>"javascript"===t?e:Y.transpileModule(e,{compilerOptions:{target:Y.ScriptTarget.ES2022,module:Y.ModuleKind.None,strict:!0,noEmitHelpers:!0,importHelpers:!1}}).outputText.replace(/^"use strict";\s*/,""))(o,e.language??"javascript");(e=>{if(e.length>1e5)throw new ar("Code exceeds the maximum length of 100000 characters","GRAPH_CODE_SANDBOX_CODE_TOO_LONG",{length:e.length});let t;try{t=J.parse(`async function __validate() {\n${e}\n}`,{ecmaVersion:"latest",sourceType:"script"})}catch{try{t=J.parse(e,{ecmaVersion:"latest",sourceType:"module"})}catch(t){throw new ar("Code failed to parse: "+t.message,"GRAPH_CODE_SANDBOX_PARSE_ERROR",{code:e,error:t.message})}}X.full(t,e=>{const t=e;if("ImportDeclaration"===t.type)throw new ar("Imports are not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"import"});if("ExportNamedDeclaration"===t.type||"ExportDefaultDeclaration"===t.type)throw new ar("Exports are not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"export"});if("Identifier"===t.type&&"string"==typeof t.name&&Jn.has(t.name))throw new ar(`Identifier "${t.name}" is not allowed in Code nodes.`,"GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:t.name});if("NewExpression"===t.type&&"Function"===t.callee?.name)throw new ar("new Function() is not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"Function"});if("CallExpression"===t.type&&"eval"===t.callee?.name)throw new ar("eval() is not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"eval"})})})(r);const n=!(e=>/\breturn\b[\s;]/.test(e))(r),i=n?r.replace(/[\s;]+$/,""):r,a={$input:e.input??{},$vars:e.vars??{},$item:e.item,$index:e.index,$node:e.nodes??{},$output:void 0},s=Object.keys(a),d=n?`return (${i});`:i,l=`"use strict";\nasync function __userFunction(${s.join(", ")}) {\n${d}\n}\n__userFunction(${s.join(", ")}).then(function(__r) { return JSON.stringify({ v: __r }); });`,c=new Q.Isolate({memoryLimit:this.defaultMemoryMb}),p=await c.createContext();try{const t=p.global;e.logger&&await this.injectConsole(p,e.logger);for(const[e,o]of Object.entries(a))await t.set(e,new Q.ExternalCopy(void 0===o?null:o).copyInto());let o;try{o=await c.compileScript(l,{filename:"graph-code-node.js"})}catch(e){if(!n)throw new ar("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:r,error:e.message});{const e=i,t=`"use strict";\nasync function __userFunction(${s.join(", ")}) {\n${e}\n}\n__userFunction(${s.join(", ")}).then(function(__r) { return JSON.stringify({ v: __r }); });`;try{o=await c.compileScript(t,{filename:"graph-code-node.js"})}catch(e){throw new ar("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:r,error:e.message})}}}const d=e.timeoutMs??this.defaultTimeoutMs;let u;try{u=await this.runBounded(o,p,d,e.abortSignal)}catch(e){if(e instanceof ar)throw e;const t=e.message;if(t.includes("timed out")||t.includes("timeout"))throw new ar(`Code execution timed out after ${d} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:d});if(t.includes("memory")||t.includes("heap"))throw new ar(`Code exceeded the memory limit of ${this.defaultMemoryMb} MB`,"GRAPH_CODE_SANDBOX_MEMORY_LIMIT",{memoryMb:this.defaultMemoryMb});throw new ar("Code execution failed: "+t,"GRAPH_CODE_SANDBOX_RUNTIME_ERROR",{code:r,error:t})}if("string"!=typeof u)throw new ar("Code sandbox returned an unexpected non-string result","GRAPH_CODE_SANDBOX_UNEXPECTED_RESULT",{result:u});return JSON.parse(u).v}finally{p.release(),c.dispose()}}async runBounded(e,t,o,r){const n=e.run(t,{timeout:o,promise:!0});n.catch(()=>{});const i=[n];let a,s;try{return i.push(new Promise((e,t)=>{a=setTimeout(()=>{t(new ar(`Code execution timed out after ${o} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:o}))},o+100)})),r&&i.push(new Promise((e,t)=>{const n=()=>{const e="timeout"===r.reason;t(new ar(e?`Code execution timed out after ${o} ms`:"Code execution aborted",e?"GRAPH_CODE_SANDBOX_TIMEOUT":"GRAPH_CODE_SANDBOX_ABORTED",{timeoutMs:o,reason:r.reason}))};r.aborted?n():(r.addEventListener("abort",n,{once:!0}),s=()=>r.removeEventListener("abort",n))})),await Promise.race(i)}finally{a&&clearTimeout(a),s?.()}}async injectConsole(e,t){const o=new Q.Reference((e,o)=>{let r;try{r=JSON.parse(o)}catch{r=[o]}const n=r.map(e=>"string"==typeof e?e:JSON.stringify(e)).join(" "),i=1===r.length?r[0]:r;switch(e){case"log":case"info":default:t.info(n,i);break;case"warn":t.warn(n,i);break;case"error":t.error(n,i);break;case"debug":case"dir":case"dirxml":case"table":t.debug(n,i);break;case"trace":t.trace(n,i);break;case"group":case"groupCollapsed":t.debug("[group] "+n,i);break;case"groupEnd":t.debug("[groupEnd]",void 0);break;case"time":case"timeEnd":case"timeLog":case"count":case"countReset":t.debug(`[${e}] ${n}`,i);break;case"assert":r[0]||t.error("Assertion failed: "+n,i);case"clear":}});await e.evalClosure("\n function __ser() {\n var out = [];\n for (var i = 0; i < arguments.length; i++) {\n var a = arguments[i];\n try { out.push(typeof a === 'object' ? JSON.parse(JSON.stringify(a)) : a); }\n catch (e) { out.push(String(a)); }\n }\n return JSON.stringify(out);\n }\n function __call(level) {\n return function() {\n $0.applySync(undefined, [level, __ser.apply(null, arguments)]);\n };\n }\n globalThis.console = {\n log: __call('log'),\n info: __call('info'),\n warn: __call('warn'),\n error: __call('error'),\n debug: __call('debug'),\n trace: __call('trace'),\n dir: __call('dir'),\n dirxml: __call('dirxml'),\n table: __call('table'),\n group: __call('group'),\n groupCollapsed: __call('groupCollapsed'),\n groupEnd: __call('groupEnd'),\n time: __call('time'),\n timeEnd: __call('timeEnd'),\n timeLog: __call('timeLog'),\n assert: __call('assert'),\n count: __call('count'),\n countReset: __call('countReset'),\n clear: __call('clear')\n };\n ",[o]),o.release()}}class Yn extends k{constructor(e){super(e,Yn.name,500)}}class Zn extends S{constructor(e){super(e),this.name=Zn.name}}class ei extends S{constructor(e){super(e),this.name=ei.name}}class ti{constructor(e,t,o={}){this.kind=e,this.declarations=new Map,this.implementations=new Map;for(const e of t){if("string"!=typeof e?.name||!e.name)throw new Yn(`Method declaration for kind '${this.kind}' is missing a name`);if(this.declarations.has(e.name))throw new Yn(`Kind '${this.kind}' declares duplicate method '${e.name}'`);this.declarations.set(e.name,e)}for(const[e,t]of Object.entries(o)){if("function"!=typeof t)throw new Yn(`Method implementation '${e}' for kind '${this.kind}' is not a function`);if(!this.declarations.has(e))throw new Yn(`Kind '${this.kind}' implements method '${e}' which is not declared by its manifest`);this.implementations.set(e,t)}for(const e of this.declarations.keys())if(!this.implementations.has(e))throw new Yn(`Kind '${this.kind}' declares method '${e}' with no implementation`)}has(e){return this.declarations.has(e)}getDeclaration(e){const t=this.declarations.get(e);if(!t)throw new ei(`Kind '${this.kind}' does not declare method '${e}'`);return t}get(e){return this.getDeclaration(e),this.implementations.get(e)}list(){return[...this.declarations.values()].sort((e,t)=>e.name<t.name?-1:e.name>t.name?1:0)}}function oi(e,t){if(!t)return;let o=e;for(const e of t.split(".")){if(!o||"object"!=typeof o)return;o=o[e]}return o}function ri(e,t,o){const r=oi(t,e.itemIdPath),n=e.itemLabelPath?oi(t,e.itemLabelPath):void 0;return{id:"string"==typeof r&&r||"number"==typeof r&&Number.isFinite(r)&&r+""||o+"",label:"string"==typeof n?n:void 0}}function ni(e,t){switch(t){case"input":return e.inputs;case"output":return e.outputs;default:return e.connections}}function ii(e,t){const o={inputs:[],outputs:[],connections:[]},r={input:new Set((e.inputs??[]).map(e=>e.id)),output:new Set((e.outputs??[]).map(e=>e.id)),connection:new Set((e.connections??[]).map(e=>e.id))},n=(e,t)=>{const o=r[e];return!o.has(t)&&(o.add(t),!0)};for(const r of e.dynamicPorts??[])if("repeatFromParameter"===r.type){const e=t[r.parameter];if(!Array.isArray(e))continue;const i=ni(o,r.direction);e.forEach((e,t)=>{const{id:o,label:a}=ri(r,e,t),s=(d={id:o,index:t,label:a??o},r.portIdTemplate.replaceAll("${id}",d.id).replaceAll("${index}",d.index+"").replaceAll("${label}",d.label));var d;if(!n(r.direction,s))return;const l=r.defaultPort?kt(r.defaultPort):{id:s,label:a??s,direction:r.direction};l.id=s,l.direction=r.direction,a&&(l.label=a),i.push(l)})}else if("togglePort"===r.type){if(t[r.parameter]!==r.equals)continue;const e=kt(r.port);if(!n(e.direction,e.id))continue;ni(o,e.direction).push(e)}return o}function ai(e,t){const o=ii(e,t),r={kind:e.kind,display:e.display,inputs:[...e.inputs,...o.inputs],outputs:[...e.outputs,...o.outputs],parameters:e.parameters},n=[...e.connections??[],...o.connections];return n.length&&(r.connections=n),e.dynamicPorts?.length&&(r.dynamicPorts=e.dynamicPorts),e.credentials?.length&&(r.credentials=e.credentials),e.capabilities?.length&&(r.capabilities=e.capabilities),e.policies&&(r.policies=e.policies),e.metadata&&(r.metadata=e.metadata),e.namespaces?.length&&(r.namespaces=e.namespaces),kt(r)}class si{async resolve(e,t,o,r,n){if(o){const i=await o(r,n);if(!(e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.kind&&"object"==typeof t.display&&null!==t.display&&Array.isArray(t.inputs)&&Array.isArray(t.outputs)&&Array.isArray(t.parameters)})(i))throw new Yn(`resolveManifest provider for kind '${e}' returned a value that does not conform to GraphResolvedNodeManifest`);if(!Et(i))throw new Yn(`resolveManifest provider for kind '${e}' returned a non-JSON-safe resolved manifest`);const a=kt(i);return!a.namespaces?.length&&t.namespaces?.length&&(a.namespaces=t.namespaces.slice()),a}return ai(t,r.parameters??{})}}const di=["edge","literal","expression"];function li(e){return di.includes(e)}function ci(e,t,o){if("string"!=typeof o||!o)throw new Yn(`Manifest for kind '${e}' has a ${t} with an empty port id`);if(It(o))throw new Yn(`Manifest for kind '${e}' has a ${t} with unsafe port id '${o}'`)}let pi=class extends H{constructor(){super(),this.entries=new Map,this.resolver=new si,this.fallbackContext=new M}withContext(e){return e[e.length-1]instanceof M?e:[this.fallbackContext]}register(e,t={},...o){const{log:r}=this.logCtx(this.withContext(o),"register").for(this.register);r.debug(`Registering graph node kind '${e?.manifest?.kind??"unknown"}'`),(e=>{if(!e||"object"!=typeof e)throw new Yn("Graph node registration is required");if(!e.manifest||"object"!=typeof e.manifest)throw new Yn("Graph node registration is missing a manifest");if(!e.executor||"function"!=typeof e.executor.execute)throw new Yn(`Graph node registration for kind '${e.manifest?.kind+""}' is missing an executor`)})(e);const n=e.manifest;if("string"!=typeof n.kind||!n.kind.trim())throw new Yn("Graph node manifest kind is required and must be a non-empty string");const i=n.kind;if(this.entries.has(i)&&!t.replace)throw new Yn(`Graph node kind '${i}' is already registered; pass { replace: true } to replace it`);try{ro(n)}catch(e){throw new Yn(`Manifest for kind '${i}' is not JSON-serializable: ${e.message}`)}((e,t)=>{const o=[["input",t.inputs],["output",t.outputs],["connection",t.connections??[]]];for(const[t,r]of o){const o=new Set;for(const n of r){if(ci(e,t+" port",n?.id),o.has(n.id))throw new Yn(`Manifest for kind '${e}' declares duplicate static ${t} port id '${n.id}'`);if(o.add(n.id),void 0!==n.defaultMode&&!li(n.defaultMode))throw new Yn(`Manifest for kind '${e}' declares invalid default binding mode '${n.defaultMode+""}' on ${t} port '${n.id}'`)}}})(i,n);const a=((e,t)=>{const o=new Set;for(const r of t.parameters){const t=r?.id;if("string"!=typeof t||!t)throw new Yn(`Manifest for kind '${e}' has a parameter with an empty id`);if(It(t))throw new Yn(`Manifest for kind '${e}' has a parameter with unsafe id '${t}'`);if(o.has(t))throw new Yn(`Manifest for kind '${e}' declares duplicate parameter id '${t}'`);o.add(t)}return o})(i,n);((e,t,o)=>{for(const r of t.dynamicPorts??[]){if(!r||"string"!=typeof r.parameter||!r.parameter)throw new Yn(`Manifest for kind '${e}' has a dynamic-port rule without a parameter reference`);if(!o.has(r.parameter))throw new Yn(`Manifest for kind '${e}' has a dynamic-port rule referencing missing parameter '${r.parameter}'`);if("togglePort"===r.type){if(!r.port)throw new Yn(`Manifest for kind '${e}' has a togglePort rule without a port`);ci(e,"togglePort rule port",r.port.id)}if("repeatFromParameter"===r.type&&"string"!=typeof r.portIdTemplate)throw new Yn(`Manifest for kind '${e}' has a repeatFromParameter rule without a portIdTemplate`)}})(i,n,a),((e,t)=>{for(const o of t.credentials??[]){if(!Zt(o))throw new Yn(`Manifest for kind '${e}' has a malformed credential requirement`);if(!o.type)throw new Yn(`Manifest for kind '${e}' has a credential requirement with an empty type`)}})(i,n),((e,t)=>{for(const o of t.methods??[])if(!so(o))throw new Yn(`Manifest for kind '${e}' has a malformed method declaration`)})(i,n);const s=new ti(i,n.methods??[],e.methods??{});return this.entries.set(i,{registration:e,methods:s,placeholderManifest:!1}),this}registerExecutor(e,t,...o){const{log:r}=this.logCtx(this.withContext(o),"registerExecutor").for(this.registerExecutor);if(r.debug(`Registering graph executor for kind '${e}'`),"string"!=typeof e||!e.trim())throw new Yn("Graph executor kind is required");if(!t||"function"!=typeof t.execute)throw new Yn(`Executor registered for kind '${e}' is missing an execute method`);const n=this.entries.get(e);if(n)return n.registration={...n.registration,executor:t},this;const i={kind:e,display:{name:e},inputs:[],outputs:[],parameters:[],policies:{allowUndeclaredParameters:!0,allowUnknownOutputs:!0}};return this.entries.set(e,{registration:{manifest:i,executor:t},methods:new ti(e,[],{}),placeholderManifest:!0}),this}unregister(e,...t){const{log:o}=this.logCtx(this.withContext(t),"unregister").for(this.unregister);return o.debug(`Unregistering graph node kind '${e}'`),this.entries.delete(e),this}has(e,...t){return this.logCtx(this.withContext(t),"has").for(this.has),this.entries.has(e)}entry(e){const t=this.entries.get(e);if(!t)throw new Zn(`No graph node kind '${e}' is registered in the catalogue`);return t}getManifest(e,...t){return this.logCtx(this.withContext(t),"getManifest").for(this.getManifest),kt(this.entry(e).registration.manifest)}getExecutor(e,...t){return this.logCtx(this.withContext(t),"getExecutor").for(this.getExecutor),this.entry(e).registration.executor}getMethodDeclaration(e,t,...o){return this.logCtx(this.withContext(o),"getMethodDeclaration").for(this.getMethodDeclaration),this.entry(e).methods.getDeclaration(t)}getMethod(e,t,...o){return this.logCtx(this.withContext(o),"getMethod").for(this.getMethod),this.entry(e).methods.getDeclaration(t),this.entry(e).methods.get(t)}listMethodDeclarations(e,...t){return this.logCtx(this.withContext(t),"listMethodDeclarations").for(this.listMethodDeclarations),this.entry(e).methods.list()}listManifests(e,...t){this.logCtx(this.withContext(t),"listManifests").for(this.listManifests);const o=[...this.entries.keys()].sort(),r=e?.categories?.length?new Set(e.categories):void 0,n=e?.kinds?.length?new Set(e.kinds):void 0,i=[];for(const e of o){if(n&&!n.has(e))continue;const o=this.getManifest(e,...t);r&&!r.has(o.display.category??"")||i.push(o)}return i}listKinds(...e){return this.logCtx(this.withContext(e),"listKinds").for(this.listKinds),[...this.entries.keys()].sort()}get size(){return this.entries.size}async resolveManifest(e,t,o,...r){this.logCtx(this.withContext(r),"resolveManifest").for(this.resolveManifest);const n=this.entry(e);return this.resolver.resolve(e,n.registration.manifest,n.registration.resolveManifest,t,o)}};pi=R([B(),C("design:paramtypes",[])],pi);let ui=class extends H{constructor(e=new pi){super(),this.catalogue=e}get catalog(){return this.catalogue}register(e,t,...o){const{log:r}=this.logCtx(o,"register").for(this.register);if(r.debug(`Registering graph executor for kind '${e}'`),!e)throw new ar("Graph executor kind is required");return this.catalogue.registerExecutor(e,t,...o),this}unregister(e,...t){const{log:o}=this.logCtx(t,"unregister").for(this.unregister);return o.debug(`Unregistering graph executor for kind '${e}'`),this.catalogue.unregister(e,...t),this}has(e,...t){return this.logCtx(t,"has").for(this.has),this.catalogue.has(e,...t)}resolve(e,...t){this.logCtx(t,"resolve").for(this.resolve);try{return this.catalogue.getExecutor(e,...t)}catch(t){if(t instanceof Zn)throw new ar(`No graph executor registered for kind '${e}'`,"GRAPH_EXECUTOR_NOT_FOUND",{kind:e});throw t}}};ui=R([B(),C("design:paramtypes",[pi])],ui);let hi=class extends H{constructor(e,t){super(),this.registry=e,this.defaultExecutor=t}resolve(e,...t){const{log:o}=this.logCtx(t,"resolve").for(this.resolve);return o.debug(`Resolving graph executor for kind '${e}'`),this.registry.has(e,...t)?this.registry.resolve(e,...t):this.defaultExecutor?this.defaultExecutor:this.registry.resolve(e,...t)}};function gi(e){return e}function fi(e){return e.methods??[]}function yi(e){if(!e)return;const t={...e.metadata??{},...e.parameters??{},...e.state??{}};return e.loop&&(t.loop=e.loop),t}hi=R([B(),C("design:paramtypes",[Function,Object])],hi);class mi extends b{constructor(e){super(),b.fromModel(this,e)}execute(e,t){throw new ar(`Graph node kind '${this.constructor.name}' does not implement execute`,"GRAPH_NODE_EXECUTE_NOT_IMPLEMENTED",{kind:this.constructor.name})}static applyMetadata(e){return null}static instantiate(e){return new this(e)}}let bi=class extends mi{execute(e,t){throw new gr(e.inputs.value)}};function wi(e){return e instanceof Error?{name:e.name,message:e.message,stack:e.stack,code:e.graphCode??("number"==typeof e.code?e.code+"":e.code)}:{name:"UnknownError",message:e+""}}R([w(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.break.fields.value.label",placeholder:"graph.node.flow_control.break.fields.value.placeholder",type:"textarea"}),bt({handle:"value"}),C("design:type",Object)],bi.prototype,"value",void 0),bi=R([yt("core.flow.break",{kind:"core.flow.break",category:"Flow Control",color:"#f59e0b",icon:"ti-square-arrow-right",width:96,height:96,labels:["flow","break","loop","control"],metadata:{title:"graph.node.flow_control.break.name",description:"graph.node.flow_control.break.description"}}),I()],bi);let vi=class extends mi{async execute(e,t){const o=t.node.errorBoundary;if(!o?.try)return{result:e.inputs.value??e.inputs};const r=t.engine;if(!r)throw new ar("errorBoundary node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");try{const n=await r.execute(o.try,e.inputs,{parentRunId:t.runId,path:[...t.path,"try"]}),i=Object.values(n.nodeResults).find(e=>e.status===Ke.FAILED);if(i)throw new ar(i.error?.message??"error boundary try body failed",i.error?.code??"GRAPH_ERROR_BOUNDARY",i.error?.details);return{result:n.outputs.result??n.outputs}}catch(n){let i=n;if(o.catch){const a=await r.execute(o.catch,{...e.inputs,error:wi(n)},{parentRunId:t.runId,path:[...t.path,"catch"]});i=a.outputs.error??a.outputs}return{error:i}}finally{o.finally&&await r.execute(o.finally,e.inputs,{parentRunId:t.runId,path:[...t.path,"finally"]})}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.error_boundary.fields.value.label",placeholder:"graph.node.flow_control.error_boundary.fields.value.placeholder",type:"textarea"}),bt({handle:"value"}),C("design:type",Object)],vi.prototype,"value",void 0),R([wt({handle:"result"}),C("design:type",Object)],vi.prototype,"result",void 0),R([wt({handle:"error"}),C("design:type",Object)],vi.prototype,"error",void 0),vi=R([yt("core.flow.errorBoundary",{kind:"core.flow.errorBoundary",category:"Flow Control",color:"#f59e0b",icon:"ti-shield-check",width:96,height:96,labels:["flow","error","try-catch"],metadata:{title:"graph.node.flow_control.error_boundary.name",description:"graph.node.flow_control.error_boundary.description",finally:!1}}),I()],vi);let xi=class extends mi{execute(e){const t=e.inputs.value??e.inputs;return!1===this.approved?{rejected:t}:{approved:t}}};R([w(),bt({handle:"value"}),C("design:type",Object)],xi.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.human_approval.fields.message.label",placeholder:"graph.node.flow_control.human_approval.fields.message.placeholder",type:"textarea"}),bt({handle:"message",userControlled:!0}),C("design:type",String)],xi.prototype,"message",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.human_approval.fields.approved.label",type:"checkbox"}),bt({handle:"approved",userControlled:!0}),C("design:type",Boolean)],xi.prototype,"approved",void 0),R([wt({handle:"approved"}),C("design:type",Object)],xi.prototype,"approvedOut",void 0),R([wt({handle:"rejected"}),C("design:type",Object)],xi.prototype,"rejectedOut",void 0),xi=R([yt("core.flow.humanApproval",{kind:"core.flow.humanApproval",category:"Flow Control",color:"#f59e0b",icon:"ti-user-check",width:96,height:96,labels:["flow","approval","suspend"],metadata:{title:"graph.node.flow_control.human_approval.name",description:"graph.node.flow_control.human_approval.description",approvers:[],timeoutMs:864e5}}),I()],xi);let Ii=class extends mi{execute(e,t){const o=e.inputs,r=o.value??o;if(!this.condition)throw new ar("If node has no condition configured","GRAPH_IF_NO_CONDITION",{input:o});if(Wr(this.condition))return Vr(this.condition,o,t).then(e=>this.route(e,r));const n=zr(this.condition,((e,t)=>t===e||"object"!=typeof t||null===t||Array.isArray(t)?e:{...t,...e})(o,r),"if");return this.route(n,r)}route(e,t){if(e)return{then:t};if(!0===this.else)return{else:t};throw new ar("If node condition evaluated to false and the else branch is disabled","GRAPH_IF_ELSE_DISABLED",{condition:this.condition})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.value.label",placeholder:"graph.node.flow_control.if.fields.value.placeholder",type:"textarea"}),bt({handle:"value"}),C("design:type",Object)],Ii.prototype,"value",void 0),R([w(),wt({handle:"then"}),C("design:type",Object)],Ii.prototype,"then",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.condition.label",placeholder:"graph.node.flow_control.if.fields.condition.placeholder",type:"code"}),bt({handle:"condition",userControlled:!0,type:"object"}),C("design:type",Object)],Ii.prototype,"condition",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.else.label",type:"checkbox"}),bt({handle:"else",userControlled:!0}),C("design:type",Boolean)],Ii.prototype,"else",void 0),Ii=R([yt("core.flow.if",{kind:"core.flow.if",category:"Flow Control",color:"#f59e0b",icon:"ti-arrows-split-2",width:96,height:96,labels:["flow","conditional","branch"],metadata:{title:"graph.node.flow_control.if.name",description:"graph.node.flow_control.if.description"}}),I()],Ii);let Ai=class extends mi{async execute(e,t){const o=((e,t)=>{const o={cases:t.cases??[],defaultPort:t.defaultPort??"default",hasDefault:!0===t.hasDefault},r=e.node.metadata?.switch;return r&&Array.isArray(r.cases)?{cases:r.cases,defaultPort:r.defaultPort??o.defaultPort,hasDefault:!0===r.hasDefault||o.hasDefault}:o})(t,this),r=o.cases,n=e.inputs,i=n.value??n,a=((e,t)=>t===e||"object"!=typeof t||null===t||Array.isArray(t)?e:{...t,...e})(n,i);for(const e of r)if(await Qr(e.condition,{input:n,state:a,label:"switch case"},t))return{[e.outputPort]:i};if(!0!==o.hasDefault)throw new ar("No switch case matched and default port is not enabled","GRAPH_SWITCH_NO_MATCH",{cases:r.map(e=>e.id)});const s=o.defaultPort??"default";return{[s]:i}}static applyMetadata(e){const t=ht(this),o=e.defaultPort??"default",r=!0===e.hasDefault,n=t.ports.filter(t=>!e.cases.some(e=>e.outputPort===t.property)),i=n.filter(e=>e.property!==o),a=n.find(e=>e.property===o),s=[...i,...e.cases.map(e=>({property:e.outputPort,name:e.label,direction:Me.OUTPUT,label:e.label,required:!1,hidden:!1,path:e.outputPort}))];return r&&a&&s.push(a),{ports:s,size:Ue(t,{cases:e.cases.length}),dataPatch:{switchMetadata:e}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.value.label",placeholder:"graph.node.flow_control.switch.fields.value.placeholder",type:"textarea"}),bt({handle:"value"}),C("design:type",Object)],Ai.prototype,"value",void 0),R([w(),wt({handle:"default"}),C("design:type",Object)],Ai.prototype,"default",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.cases.label",type:"collection"}),C("design:type",Object)],Ai.prototype,"cases",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.hasDefault.label",type:"checkbox"}),C("design:type",Boolean)],Ai.prototype,"hasDefault",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.defaultPort.label",type:"text"}),C("design:type",String)],Ai.prototype,"defaultPort",void 0),Ai=R([yt("core.flow.switch",{kind:"core.flow.switch",category:"Flow Control",color:"#f59e0b",icon:"ti-arrows-shuffle",width:120,height:140,sizeRules:[{type:"parameterCount",parameter:"cases",dimension:"height",perItem:24}],labels:["flow","switch","multi-branch"],metadata:{title:"graph.node.flow_control.switch.name",description:"graph.node.flow_control.switch.description"}}),I()],Ai);const _i={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},Oi=o.accumulate({graph:{workflows:{limits:{..._i},allowAnonymousAccess:!1},execution:{maxCodeTimeoutMs:qo}}}),Ei=1e3;function ki(e,t){const o="number"==typeof t?t:Number(t),r=Number.isFinite(o)&&o>0?o:qo,n="number"==typeof e?e:Number(e);return Number.isFinite(n)&&n>0?Math.min(Math.floor(n),r):1e3}const Si=["javascript","typescript"],Ri="javascript";let Ci=class extends b{constructor(){super(...arguments),this.language=Ri}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.language.label",type:"select"}),A([...Si]),v(String),C("design:type",String)],Ci.prototype,"language",void 0),R([w(),i("code-editor",{label:"graph.node.utility.code.fields.code.label",placeholder:"graph.node.utility.code.fields.code.placeholder"}),bt({handle:"code"}),C("design:type",String)],Ci.prototype,"code",void 0),R([d(),bt({handle:"data"}),C("design:type",Object)],Ci.prototype,"data",void 0),Ci=R([I()],Ci);let Ni=class extends mi{async execute(e,t){const o=e.inputs,r=this.input,n=o.code??e.parameters?.code??r?.code??this.defaultCode,i=r?.language??Ri;if(!n||"string"!=typeof n||0===n.trim().length)throw new dr("Code node has no code to execute (input.code is empty)",{input:o});const a=t.engine?.codeSandboxEvaluator;if(!a)throw new ar("Code node execution requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{code:n});const s=Oi.graph.execution?.maxCodeTimeoutMs,d="number"==typeof s&&Number.isFinite(s)&&s>0?s:qo,l=ki(this.timeoutMs,d),c=t.metadata,p={code:n,language:i,input:o,vars:c?.vars??void 0,item:c?.item,index:c?.index,nodes:c?.nodes??void 0,logger:t.logger,timeoutMs:l,abortSignal:t.abortSignal};await t.log("Executing code node",{language:i,length:n.length,timeoutMs:l});const u=await a.evaluate(p);return await t.log("Code node executed",{hasResult:void 0!==u}),{result:u}}};R([w(),bt({handle:"input",model:Ci}),C("design:type",Ci)],Ni.prototype,"input",void 0),R([_(1),O(qo),i("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.timeoutMs.label",type:"number"}),bt({handle:"timeoutMs"}),C("design:type",Number)],Ni.prototype,"timeoutMs",void 0),R([i("code-editor",{label:"graph.node.utility.code.fields.defaultCode.label",placeholder:"graph.node.utility.code.fields.defaultCode.placeholder"}),bt({handle:"defaultCode",userControlled:!0}),C("design:type",String)],Ni.prototype,"defaultCode",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Ni.prototype,"result",void 0),Ni=R([yt("core.utility.code",{kind:"core.utility.code",category:"Utility",color:"#0d9488",icon:"ti-code",width:96,height:96,labels:["utility","code","sandbox","transform"],metadata:{title:"graph.node.utility.code.name",description:"graph.node.utility.code.description"}}),I()],Ni);let Ti=class extends mi{execute(e){return{value:e.inputs.value??e.inputs}}};R([w(),bt({handle:"value"}),C("design:type",Object)],Ti.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.utility.delay.fields.timeoutMs.label",type:"number"}),bt({handle:"timeoutMs"}),C("design:type",Number)],Ti.prototype,"timeoutMs",void 0),R([w(),wt({handle:"value"}),C("design:type",Object)],Ti.prototype,"valueOut",void 0),Ti=R([yt("core.flow.delay",{kind:"core.flow.delay",category:"Utility",color:"#0d9488",icon:"ti-clock-hour-4",width:96,height:96,labels:["flow","delay","wait"],metadata:{title:"graph.node.utility.delay.name",description:"graph.node.utility.delay.description"}}),I()],Ti);let Di=class extends mi{execute(e,t){const o=e.inputs.value,r=this.level??"info";return t.logger[r](this.message??"Log node",{value:o}),{value:o}}};R([w(),bt({handle:"value"}),C("design:type",Object)],Di.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.utility.log.fields.message.label",placeholder:"graph.node.utility.log.fields.message.placeholder",type:"textarea"}),bt({handle:"message"}),C("design:type",String)],Di.prototype,"message",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.utility.log.fields.level.label",placeholder:"graph.node.utility.log.fields.level.placeholder",type:"text"}),bt({handle:"level",userControlled:!0}),C("design:type",String)],Di.prototype,"level",void 0),R([w(),wt({handle:"value"}),C("design:type",Object)],Di.prototype,"valueOut",void 0),Di=R([yt("core.flow.log",{kind:"core.flow.log",category:"Utility",color:"#0d9488",icon:"ti-terminal",width:96,height:96,labels:["flow","log","debug","utility"],metadata:{title:"graph.node.utility.log.name",description:"graph.node.utility.log.description"}}),I()],Di);let Pi=class extends mi{execute(e){return{result:{mapped:e.inputs.value??e.inputs}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.utility.map.fields.value.label",placeholder:"graph.node.utility.map.fields.value.placeholder",type:"textarea"}),bt({handle:"value"}),C("design:type",Object)],Pi.prototype,"value",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Pi.prototype,"result",void 0),Pi=R([yt("core.utility.map",{kind:"core.utility.map",category:"Utility",color:"#0d9488",icon:"ti-arrows-right-left",width:96,height:96,labels:["utility","map","transform"],metadata:{title:"graph.node.utility.map.name",description:"graph.node.utility.map.description",mapper:{}}}),I()],Pi);let ji=class extends mi{execute(e,t){const o=e.inputs.value,r=this.level??"info";return t.logger[r](this.message??"Log node",{value:o}),{value:o}}};R([w(),bt({handle:"value"}),C("design:type",Object)],ji.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.utility.utility_log.fields.message.label",placeholder:"graph.node.utility.utility_log.fields.message.placeholder",type:"textarea"}),bt({handle:"message"}),C("design:type",String)],ji.prototype,"message",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.utility.utility_log.fields.level.label",placeholder:"graph.node.utility.utility_log.fields.level.placeholder"}),bt({handle:"level",userControlled:!0,type:"string"}),C("design:type",String)],ji.prototype,"level",void 0),R([w(),wt({handle:"value"}),C("design:type",Object)],ji.prototype,"valueOut",void 0),ji=R([yt("core.utility.log",{kind:"core.utility.log",category:"Utility",color:"#0d9488",icon:"ti-terminal",width:96,height:96,labels:["utility","log","debug","observability"],metadata:{title:"graph.node.utility.utility_log.name",description:"graph.node.utility.utility_log.description"}}),I()],ji);const $i=new Set(["__proto__","constructor","prototype"]);function Li(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Mi(e){return null==e?[]:(Array.isArray(e)?e:[e]).filter(e=>null!=e)}function Gi(e,t){if($i.has(t))throw new ar(`Graph data path '${e}' contains the reserved segment '${t}'`,"GRAPH_DATA_UNSAFE_PATH",{path:e,segment:t})}function Ui(e,t){return t?(e=>{const t=(e=>e.split(".").map(e=>e.trim()).filter(e=>e.length>0))(e);for(const o of t)Gi(e,o);return t})(e):(Gi(e,e),[e])}function Fi(e,t,o=!0){if(!t)return e;const r=Ui(t,o);let n=e;for(const e of r){if(!Li(n))return;n=n[e]}return n}function Bi(e,t,o,r=!0){const n=Ui(t,r);if(0===n.length)return;let i=e;for(let e=0;e<n.length-1;e++){const t=n[e],o=i[t];if(Li(o))i=o;else{const e={};i[t]=e,i=e}}i[n[n.length-1]]=o}function Hi(e,t,o=!0){const r=Ui(t,o);if(0===r.length)return;let n=e;for(let e=0;e<r.length-1;e++){const t=n[r[e]];if(!Li(t))return;n=t}delete n[r[r.length-1]]}function qi(e,t="json"){if(null==e)return e;switch(t){case"string":return e+"";case"number":{const t=Number(e);if(!Number.isFinite(t))throw new ar(`Value '${e+""}' cannot be converted to a number`,"GRAPH_DATA_INVALID_NUMBER",{value:e});return t}case"boolean":return"string"==typeof e?"true"===e||"1"===e:!!e;case"array":return Array.isArray(e)?e:[e];case"object":return Li(e)?e:{};default:if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return e}}}function Wi(e,t,o="auto"){const r=null==e,n=null==t;return r&&n?0:r?1:n?-1:"string"===o?(e+"").localeCompare(t+""):"number"===o?Number(e)-Number(t):"date"===o?new Date(e).getTime()-new Date(t).getTime():"number"==typeof e&&"number"==typeof t?e-t:"boolean"==typeof e&&"boolean"==typeof t?Number(e)-Number(t):(e+"").localeCompare(t+"")}function Ki(e,t){if(!t||"iso"===t)return e.toISOString();const o=(e,t=2)=>(e+"").padStart(t,"0"),r={yyyy:e.getUTCFullYear()+"",yy:(e.getUTCFullYear()+"").slice(-2),MM:o(e.getUTCMonth()+1),M:e.getUTCMonth()+1+"",dd:o(e.getUTCDate()),d:e.getUTCDate()+"",HH:o(e.getUTCHours()),H:e.getUTCHours()+"",mm:o(e.getUTCMinutes()),m:e.getUTCMinutes()+"",ss:o(e.getUTCSeconds()),s:e.getUTCSeconds()+"",SSS:o(e.getUTCMilliseconds(),3)};return t.replace(/yyyy|yy|MM|M|dd|d|HH|H|mm|m|ss|s|SSS/g,e=>r[e]??e)}function Vi(e,t,o){const r=new Date(e.getTime());switch(o){case"seconds":r.setUTCSeconds(r.getUTCSeconds()+t);break;case"minutes":r.setUTCMinutes(r.getUTCMinutes()+t);break;case"hours":r.setUTCHours(r.getUTCHours()+t);break;case"days":r.setUTCDate(r.getUTCDate()+t);break;case"weeks":r.setUTCDate(r.getUTCDate()+7*t);break;case"months":r.setUTCMonth(r.getUTCMonth()+t);break;case"years":r.setUTCFullYear(r.getUTCFullYear()+t)}return r}function zi(e){if(e instanceof Date){if(Number.isNaN(e.getTime()))throw new ar("Date value is invalid","GRAPH_DATA_INVALID_DATE",{value:e});return e}if("number"==typeof e){const t=new Date(e);if(!Number.isNaN(t.getTime()))return t}if("string"==typeof e&&e.trim().length>0){const t=new Date(e);if(!Number.isNaN(t.getTime()))return t}throw new ar("Date & Time node requires a valid date value","GRAPH_DATA_INVALID_DATE",{value:e})}function Qi(e){return"undefined"!=typeof Buffer&&Buffer.isBuffer(e)||e instanceof Uint8Array||e instanceof ArrayBuffer}let Ji=class extends mi{constructor(){super(...arguments),this.operation="current",this.amount=0,this.unit="days"}execute(e){const t=e.inputs.value??this.value;if(Array.isArray(t)){const e=t.filter(e=>null!=e).map(e=>this.convert(e));return{result:e.map(e=>e.result),iso:e.map(e=>e.iso),timestamp:e.map(e=>e.timestamp)}}const o=this.convert(t);return{result:o.result,iso:o.iso,timestamp:o.timestamp}}convert(e){let t;switch(this.operation){case"current":t=new Date;break;case"add":t=Vi(zi(e),this.amount??0,this.unit??"days");break;case"subtract":t=Vi(zi(e),-(this.amount??0),this.unit??"days");break;case"parse":case"format":t=zi(e);break;default:throw new ar(`Unsupported Date & Time operation '${this.operation+""}'`,"GRAPH_DATE_TIME_UNSUPPORTED_OPERATION",{operation:this.operation})}return{result:Ki(t,this.format),iso:t.toISOString(),timestamp:t.getTime()}}};R([bt({handle:"value"}),C("design:type",Object)],Ji.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Ji.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.format.label",placeholder:"graph.node.data.date_time.fields.format.placeholder",type:"text"}),bt({handle:"format",userControlled:!0}),C("design:type",String)],Ji.prototype,"format",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.amount.label",type:"number"}),bt({handle:"amount",userControlled:!0}),C("design:type",Number)],Ji.prototype,"amount",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.unit.label",type:"select"}),bt({handle:"unit",userControlled:!0}),C("design:type",String)],Ji.prototype,"unit",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Ji.prototype,"result",void 0),R([wt({handle:"iso"}),C("design:type",String)],Ji.prototype,"iso",void 0),R([wt({handle:"timestamp"}),C("design:type",Number)],Ji.prototype,"timestamp",void 0),Ji=R([yt("core.data.dateTime",{kind:"core.data.dateTime",category:"Data",color:"#8b5cf6",icon:"ti-calendar-time",width:96,height:96,labels:["data","date","time"],metadata:{title:"graph.node.data.date_time.name",description:"graph.node.data.date_time.description"}}),I()],Ji);let Xi=class extends mi{constructor(){super(...arguments),this.operation="insert",this.tableName="default"}async execute(e,t){const o=t.engine?.dataTableStore;if(!o)throw new ar("Data table node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");if(!this.tableName)throw new ar("Data table node requires a table name","GRAPH_DATA_TABLE_NAME_REQUIRED");switch(this.operation){case"insert":return{result:await this.insertRows(e,o,t)};case"upsert":return{result:await this.upsertRows(e,o,t)};case"get":if(!this.rowId)throw new ar("Data table 'get' requires a row id","GRAPH_DATA_TABLE_ROW_ID_REQUIRED");return{result:await o.readRow(this.tableName,this.rowId,t)??null};case"list":{const e=await o.listRows(this.tableName,this.limit,t);return{result:e,count:e.length}}case"delete":{if(!this.rowId)throw new ar("Data table 'delete' requires a row id","GRAPH_DATA_TABLE_ROW_ID_REQUIRED");const e=await o.deleteRow(this.tableName,this.rowId,t);return{result:e,count:e?1:0}}case"clear":{const e=await o.clearTable(this.tableName,t);return{result:e,count:e}}default:throw new ar(`Unsupported data table operation '${this.operation+""}'`,"GRAPH_DATA_TABLE_UNSUPPORTED_OPERATION",{operation:this.operation})}}rowsOf(e){const t=Mi(e.inputs.value).filter(Li);return t.length>0?t:Li(this.row)?[this.row]:[]}async insertRows(e,t,o){const r=this.rowsOf(e),n=[];for(const e of r){const r=this.rowId??this.rowIdOf(e)??Z();n.push(await t.insertRow(this.tableName,r,e,o))}return n}async upsertRows(e,t,o){const r=this.rowsOf(e),n=[];for(const e of r){const r=this.rowId??this.rowIdOf(e)??Z();n.push(await t.upsertRow(this.tableName,r,e,o))}return n}rowIdOf(e){const t=e[this.rowIdField||"id"];return"string"==typeof t&&t.length>0?t:"number"==typeof t?t+"":void 0}};function Yi(e,t){return Li(t)?{...e,...t,item:t}:{...e,item:t}}R([bt({handle:"value"}),C("design:type",Object)],Xi.prototype,"value",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Xi.prototype,"operation",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.tableName.label",placeholder:"graph.node.data.data_table.fields.tableName.placeholder",type:"text"}),bt({handle:"tableName",userControlled:!0}),C("design:type",String)],Xi.prototype,"tableName",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.rowId.label",placeholder:"graph.node.data.data_table.fields.rowId.placeholder",type:"text"}),bt({handle:"rowId",userControlled:!0}),C("design:type",String)],Xi.prototype,"rowId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.rowIdField.label",placeholder:"graph.node.data.data_table.fields.rowIdField.placeholder",type:"text"}),bt({handle:"rowIdField",userControlled:!0}),C("design:type",String)],Xi.prototype,"rowIdField",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.row.label",type:"json"}),bt({handle:"row",userControlled:!0,type:"object"}),C("design:type",Object)],Xi.prototype,"row",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],Xi.prototype,"limit",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Xi.prototype,"result",void 0),R([wt({handle:"count"}),C("design:type",Number)],Xi.prototype,"count",void 0),Xi=R([yt("core.data.dataTable",{kind:"core.data.dataTable",category:"Data",color:"#8b5cf6",icon:"ti-table",width:96,height:96,labels:["data","table","persistence"],metadata:{title:"graph.node.data.data_table.name",description:"graph.node.data.data_table.description"}}),I()],Xi);let Zi=class extends mi{constructor(){super(...arguments),this.negate=!1}async execute(e,t){if(!this.condition)throw new ar("Filter node has no condition configured","GRAPH_FILTER_NO_CONDITION");const o=Mi(e.inputs.value),r=[];for(let n=0;n<o.length;n++){const i=o[n];await Qr(this.condition,{input:{...e.inputs,item:i,index:n},state:Yi(e.inputs,i),label:"filter"},t)!==(!0===this.negate)&&r.push(i)}return{result:r}}};R([w(),bt({handle:"value"}),C("design:type",Object)],Zi.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.filter.fields.condition.label",placeholder:"graph.node.data.filter.fields.condition.placeholder",type:"code"}),bt({handle:"condition",userControlled:!0,type:"object"}),C("design:type",Object)],Zi.prototype,"condition",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.filter.fields.negate.label",type:"checkbox"}),bt({handle:"negate",userControlled:!0}),C("design:type",Boolean)],Zi.prototype,"negate",void 0),R([w(),wt({handle:"result"}),C("design:type",Array)],Zi.prototype,"result",void 0),Zi=R([yt("core.data.filter",{kind:"core.data.filter",category:"Data",color:"#8b5cf6",icon:"ti-filter",width:96,height:96,labels:["data","filter","condition"],metadata:{title:"graph.node.data.filter.name",description:"graph.node.data.filter.description"}}),I()],Zi);let ea=class extends mi{constructor(){super(...arguments),this.maxItems=1,this.keep="firstItems"}execute(e){const t=Mi(e.inputs.value),o=Math.max(0,Math.floor(Number(this.maxItems??1)));return o<t.length?"lastItems"===this.keep?{result:t.slice(t.length-o)}:{result:t.slice(0,o)}:{result:t}}};function ta(e,t,o){const r={...e};for(const[e,n]of Object.entries(t))"keepFirst"===o&&Object.prototype.hasOwnProperty.call(r,e)||(r[e]=n);return r}R([w(),bt({handle:"value"}),C("design:type",Object)],ea.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.limit.fields.maxItems.label",type:"number"}),bt({handle:"maxItems",userControlled:!0}),C("design:type",Number)],ea.prototype,"maxItems",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.limit.fields.keep.label",type:"select"}),bt({handle:"keep",userControlled:!0}),C("design:type",String)],ea.prototype,"keep",void 0),R([w(),wt({handle:"result"}),C("design:type",Array)],ea.prototype,"result",void 0),ea=R([yt("core.data.limit",{kind:"core.data.limit",category:"Data",color:"#8b5cf6",icon:"ti-arrows-bar-to-line",width:96,height:96,labels:["data","limit","slice"],metadata:{title:"graph.node.data.limit.name",description:"graph.node.data.limit.description"}}),I()],ea);let oa=class extends mi{constructor(){super(...arguments),this.mode="append",this.combineBy="position",this.joinMode="inner",this.clashHandling="keepFirst"}execute(e){const t=Mi(e.inputs.input),o=Mi(e.inputs.input2);if("append"===this.mode)return{result:[...t,...o]};if("fields"===this.combineBy)return{result:this.mergeByFields(t,o)};const r=Math.max(t.length,o.length),n=[];for(let e=0;r>e;e++){if(e>=t.length){if("inner"===this.joinMode||"left"===this.joinMode)continue;n.push(o[e]);continue}if(e>=o.length){if("inner"===this.joinMode||"right"===this.joinMode)continue;n.push(t[e]);continue}const r=t[e],i=o[e];Li(r)&&Li(i)?n.push(ta(r,i,this.clashHandling)):n.push([r,i])}return{result:n}}mergeByFields(e,t){const o=this.joinField;if(!o)throw new ar("Merge node in 'fields' mode requires a join field","GRAPH_MERGE_JOIN_FIELD_REQUIRED");const r=new Map;for(const e of t){if(!Li(e))continue;const t=Fi(e,o);if(null==t)continue;const n=r.get(t);r.set(t,n?ta(n,e,this.clashHandling):e)}const n=[],i=new Set;for(const t of e){if(!Li(t)){"inner"!==this.joinMode&&"right"!==this.joinMode&&n.push(t);continue}const e=Fi(t,o),a=r.get(e);a?(i.add(e),n.push(ta(t,a,this.clashHandling))):"inner"!==this.joinMode&&"right"!==this.joinMode&&n.push(t)}if("right"===this.joinMode||"outer"===this.joinMode)for(const[e,t]of r)i.has(e)||n.push(t);return n}};function ra(e,t,o){const r={...e};for(const e of t){if(!e||!e.from||!e.to||e.from===e.to)continue;const t=Fi(r,e.from,o);void 0!==t&&(Hi(r,e.from,o),Bi(r,e.to,t,o))}return r}R([w(),bt({handle:"input"}),C("design:type",Object)],oa.prototype,"input",void 0),R([bt({handle:"input2"}),C("design:type",Object)],oa.prototype,"input2",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.mode.label",type:"select"}),bt({handle:"mode",userControlled:!0}),C("design:type",String)],oa.prototype,"mode",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.combineBy.label",type:"select"}),bt({handle:"combineBy",userControlled:!0}),C("design:type",String)],oa.prototype,"combineBy",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.joinMode.label",type:"select"}),bt({handle:"joinMode",userControlled:!0}),C("design:type",String)],oa.prototype,"joinMode",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.joinField.label",placeholder:"graph.node.data.merge.fields.joinField.placeholder",type:"text"}),bt({handle:"joinField",userControlled:!0}),C("design:type",String)],oa.prototype,"joinField",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.clashHandling.label",type:"select"}),bt({handle:"clashHandling",userControlled:!0}),C("design:type",String)],oa.prototype,"clashHandling",void 0),R([w(),wt({handle:"result"}),C("design:type",Array)],oa.prototype,"result",void 0),oa=R([yt("core.data.merge",{kind:"core.data.merge",category:"Data",color:"#8b5cf6",icon:"ti-git-merge",width:96,height:96,labels:["data","merge","join"],metadata:{title:"graph.node.data.merge.name",description:"graph.node.data.merge.description"}}),I()],oa);let na=class extends mi{constructor(){super(...arguments),this.renames=[],this.dotNotation=!0}execute(e){const t=(this.renames??[]).filter(e=>e&&"string"==typeof e.from&&"string"==typeof e.to),o=e.inputs.value,r=!1!==this.dotNotation;return Array.isArray(o)?{result:o.filter(e=>null!=e).map(e=>Li(e)?ra(e,t,r):e)}:Li(o)?{result:ra(o,t,r)}:{result:Mi(o)}}};R([w(),bt({handle:"value"}),C("design:type",Object)],na.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.rename_keys.fields.renames.label",placeholder:"graph.node.data.rename_keys.fields.renames.placeholder",type:"collection"}),bt({handle:"renames",userControlled:!0,type:"array"}),C("design:type",Array)],na.prototype,"renames",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.rename_keys.fields.dotNotation.label",type:"checkbox"}),bt({handle:"dotNotation",userControlled:!0}),C("design:type",Boolean)],na.prototype,"dotNotation",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],na.prototype,"result",void 0),na=R([yt("core.data.renameKeys",{kind:"core.data.renameKeys",category:"Data",color:"#8b5cf6",icon:"ti-key",width:96,height:96,labels:["data","rename","keys"],metadata:{title:"graph.node.data.rename_keys.name",description:"graph.node.data.rename_keys.description"}}),I()],na);let ia=class extends mi{constructor(){super(...arguments),this.assignments=[],this.includeOtherFields=!0,this.dotNotation=!0}execute(e){const t=e.inputs.value;return Array.isArray(t)?{result:t.filter(e=>null!=e).map(e=>this.applyTo(e))}:{result:this.applyTo(t)}}applyTo(e){const t=this.includeOtherFields?Li(e)?{...e}:void 0===e?{}:{value:e}:{};for(const e of this.assignments??[]){if(!e||"string"!=typeof e.name)continue;const o=qi(e.value,e.type??"json");null!=o&&Bi(t,e.name,o,!1!==this.dotNotation)}return t}};R([w(),bt({handle:"value"}),C("design:type",Object)],ia.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.set.fields.assignments.label",placeholder:"graph.node.data.set.fields.assignments.placeholder",type:"collection"}),bt({handle:"assignments",userControlled:!0,type:"array"}),C("design:type",Array)],ia.prototype,"assignments",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.set.fields.includeOtherFields.label",type:"checkbox"}),bt({handle:"includeOtherFields",userControlled:!0}),C("design:type",Boolean)],ia.prototype,"includeOtherFields",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.set.fields.dotNotation.label",type:"checkbox"}),bt({handle:"dotNotation",userControlled:!0}),C("design:type",Boolean)],ia.prototype,"dotNotation",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],ia.prototype,"result",void 0),ia=R([yt("core.data.set",{kind:"core.data.set",category:"Data",color:"#8b5cf6",icon:"ti-adjustments-horizontal",width:96,height:96,labels:["data","set","assign"],metadata:{title:"graph.node.data.set.name",description:"graph.node.data.set.description"}}),I()],ia);let aa=class extends mi{constructor(){super(...arguments),this.sortFields=[],this.valueType="auto",this.dotNotation=!0}execute(e){const t=[...Mi(e.inputs.value)],o=(this.sortFields??[]).filter(e=>e&&"string"==typeof e.field);return 0===o.length||t.sort((e,t)=>{for(const r of o){const o=Wi(Fi(e,r.field,!1!==this.dotNotation),Fi(t,r.field,!1!==this.dotNotation),this.valueType??"auto");if(0!==o)return"desc"===r.direction?-o:o}return 0}),{result:t}}};R([w(),bt({handle:"value"}),C("design:type",Object)],aa.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.sort.fields.sortFields.label",placeholder:"graph.node.data.sort.fields.sortFields.placeholder",type:"collection"}),bt({handle:"sortFields",userControlled:!0,type:"array"}),C("design:type",Array)],aa.prototype,"sortFields",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.sort.fields.valueType.label",type:"select"}),bt({handle:"valueType",userControlled:!0}),C("design:type",String)],aa.prototype,"valueType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.sort.fields.dotNotation.label",type:"checkbox"}),bt({handle:"dotNotation",userControlled:!0}),C("design:type",Boolean)],aa.prototype,"dotNotation",void 0),R([w(),wt({handle:"result"}),C("design:type",Array)],aa.prototype,"result",void 0),aa=R([yt("core.data.sort",{kind:"core.data.sort",category:"Data",color:"#8b5cf6",icon:"ti-sort-ascending",width:96,height:96,labels:["data","sort","order"],metadata:{title:"graph.node.data.sort.name",description:"graph.node.data.sort.description"}}),I()],aa);let sa=class extends mi{constructor(){super(...arguments),this.field="",this.include="noOtherFields"}execute(e){if(!this.field)throw new ar("Split Out node requires a field name","GRAPH_SPLIT_OUT_FIELD_REQUIRED");const t=Mi(e.inputs.value),o=[];for(const e of t){const t=Fi(e,this.field,!0);if(null==t)continue;const r=Array.isArray(t)?t:[t];for(const t of r){if(null==t)continue;if("allOtherFields"!==this.include){o.push(t);continue}const r=this.destinationField||this.field,n=Li(e)?{...e}:{};Hi(n,this.field,!0),Bi(n,r,t,!0),o.push(n)}}return{result:o}}};function da(e,t){if("string"==typeof e){if(e.startsWith("data:")){const t=e.indexOf(",");if(t>=0)return Buffer.from(e.slice(t+1),"base64").toString("utf8")}return"base64"===t?Buffer.from(e,"base64").toString("utf8"):e}if(Qi(e))return(Buffer.isBuffer(e)?e:Buffer.from(e instanceof ArrayBuffer?new Uint8Array(e):e)).toString("utf8");if(Li(e)){if("string"==typeof e.data)return da(e.data,t);if("string"==typeof e.content)return da(e.content,t);throw new ar("Extract from File node received an object without file content","GRAPH_EXTRACT_FROM_FILE_INVALID_INPUT")}throw new ar("Extract from File node requires a file payload","GRAPH_EXTRACT_FROM_FILE_INVALID_INPUT",{valueType:typeof e})}R([w(),bt({handle:"value"}),C("design:type",Object)],sa.prototype,"value",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.data.split_out.fields.field.label",placeholder:"graph.node.data.split_out.fields.field.placeholder",type:"text"}),bt({handle:"field",userControlled:!0}),C("design:type",String)],sa.prototype,"field",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.split_out.fields.include.label",type:"select"}),bt({handle:"include",userControlled:!0}),C("design:type",String)],sa.prototype,"include",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.data.split_out.fields.destinationField.label",placeholder:"graph.node.data.split_out.fields.destinationField.placeholder",type:"text"}),bt({handle:"destinationField",userControlled:!0}),C("design:type",String)],sa.prototype,"destinationField",void 0),R([w(),wt({handle:"result"}),C("design:type",Array)],sa.prototype,"result",void 0),sa=R([yt("core.data.splitOut",{kind:"core.data.splitOut",category:"Data",color:"#8b5cf6",icon:"ti-arrows-split-2",width:96,height:96,labels:["data","split","array"],metadata:{title:"graph.node.data.split_out.name",description:"graph.node.data.split_out.description"}}),I()],sa);let la=class extends mi{constructor(){super(...arguments),this.format="json",this.encoding="utf8",this.delimiter=",",this.headerRow=!0}execute(e){const t=da(e.inputs.value,this.encoding??"utf8");switch(this.format){case"json":try{return{result:JSON.parse(t)}}catch(e){throw new ar("Extract from File node could not parse JSON: "+(e instanceof Error?e.message:e+""),"GRAPH_EXTRACT_FROM_FILE_INVALID_JSON")}case"csv":{const e=((e,t,o)=>{const r=((e,t)=>{const o=[];let r=[],n="",i=!1;for(let a=0;a<e.length;a++){const s=e[a];i?'"'===s?'"'===e[a+1]?(n+='"',a++):i=!1:n+=s:'"'!==s?s!==t?"\n"!==s?"\r"!==s&&(n+=s):(r.push(n),o.push(r),r=[],n=""):(r.push(n),n=""):i=!0}return(n.length>0||r.length>0)&&(r.push(n),o.push(r)),o.filter(e=>e.length>1||(e[0]??"").trim().length>0)})(e,t);if(0===r.length)return[];const n=o?r[0]:r[0].map((e,t)=>"column"+t);return(o?r.slice(1):r).map(e=>{const t={};for(let o=0;o<n.length;o++)t[n[o]]=e[o]??"";return t})})(t,this.delimiter||",",!1!==this.headerRow);return{result:e,rows:e.length}}case"text":return{result:t};default:throw new ar(`Unsupported file extraction format '${this.format+""}'`,"GRAPH_EXTRACT_FROM_FILE_UNSUPPORTED_FORMAT",{format:this.format})}}};R([w(),bt({handle:"value"}),C("design:type",Object)],la.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.format.label",type:"select"}),bt({handle:"format",userControlled:!0}),C("design:type",String)],la.prototype,"format",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.encoding.label",type:"select"}),bt({handle:"encoding",userControlled:!0}),C("design:type",String)],la.prototype,"encoding",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.delimiter.label",type:"text"}),bt({handle:"delimiter",userControlled:!0}),C("design:type",String)],la.prototype,"delimiter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.headerRow.label",type:"checkbox"}),bt({handle:"headerRow",userControlled:!0}),C("design:type",Boolean)],la.prototype,"headerRow",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],la.prototype,"result",void 0),R([wt({handle:"rows"}),C("design:type",Number)],la.prototype,"rows",void 0),la=R([yt("core.io.extractFromFile",{kind:"core.io.extractFromFile",category:"IO",color:"#0ea5e9",icon:"ti-file-import",width:96,height:96,labels:["io","file","extract"],metadata:{title:"graph.node.io.extract_from_file.name",description:"graph.node.io.extract_from_file.description"}}),I()],la);const ca=new Set(["http:","https:"]);let pa=class extends mi{constructor(){super(...arguments),this.url="",this.method="GET",this.responseFormat="json",this.failOnError=!1}async execute(e,t){if(!this.url)throw new ar("HTTP Request node requires a URL","GRAPH_HTTP_URL_REQUIRED");let o;try{o=new URL(this.url)}catch{throw new ar(`HTTP Request node URL '${this.url}' is invalid`,"GRAPH_HTTP_INVALID_URL",{url:this.url})}if(!ca.has(o.protocol))throw new ar(`HTTP Request node protocol '${o.protocol}' is not allowed`,"GRAPH_HTTP_PROTOCOL_NOT_ALLOWED",{protocol:o.protocol});this.appendQuery(o);const r=this.method??"GET",n={};for(const[e,t]of Object.entries(this.headers??{}))"string"==typeof t&&e.trim().length>0&&(n[e.trim()]=t);const i=this.resolveBody(e,r);void 0!==i&&void 0===n["content-type"]&&(n["content-type"]="application/json");const a=this.resolveTimeoutMs(),s=new AbortController,d=setTimeout(()=>s.abort(),a);d.unref?.();const l=()=>s.abort();t.abortSignal?.addEventListener("abort",l,{once:!0});try{const{response:e,url:t}=await this.fetchFollowingRedirects(o,{method:r,headers:n,body:i,signal:s.signal}),a=await this.readCappedResponseText(e),d=Object.fromEntries(e.headers.entries()),l="text"===this.responseFormat?a:this.parseResponse(a);if(!0===this.failOnError&&!e.ok)throw new ar("HTTP Request node received status "+e.status,"GRAPH_HTTP_REQUEST_FAILED",{status:e.status,url:t.toString()});return{result:l,status:e.status,headers:d}}catch(e){if(e instanceof ar)throw e;if(s.signal.aborted)throw new ar(`HTTP Request node timed out after ${a}ms`,"GRAPH_HTTP_REQUEST_TIMEOUT",{url:o.toString(),timeoutMs:a});throw new ar("HTTP Request node failed: "+(e instanceof Error?e.message:e+""),"GRAPH_HTTP_REQUEST_FAILED",{url:o.toString()})}finally{clearTimeout(d),t.abortSignal?.removeEventListener("abort",l)}}resolveTimeoutMs(){const e=Number(this.timeoutMs);return Number.isFinite(e)&&e>0?Math.min(e,Wo):3e4}async fetchFollowingRedirects(e,t){let o=e,r=t;for(let e=0;5>=e;e++){const t=await fetch(o,{...r,redirect:"manual"});if(!this.isRedirectStatus(t.status))return{response:t,url:o};const n=t.headers.get("location");if(!n)return{response:t,url:o};if(5===e)throw await this.discardResponseBody(t),new ar("HTTP Request node exceeded the maximum of 5 redirects","GRAPH_HTTP_TOO_MANY_REDIRECTS",{url:o.toString(),maxRedirects:5});let i;try{i=new URL(n,o)}catch{throw await this.discardResponseBody(t),new ar(`HTTP Request node redirect target '${n}' is invalid`,"GRAPH_HTTP_INVALID_URL",{location:n})}if(!ca.has(i.protocol))throw await this.discardResponseBody(t),new ar(`HTTP Request node redirect protocol '${i.protocol}' is not allowed`,"GRAPH_HTTP_PROTOCOL_NOT_ALLOWED",{protocol:i.protocol,url:i.toString()});if(await this.discardResponseBody(t),303===t.status){r={...r,method:"GET",body:void 0};const e={...r.headers};for(const t of Object.keys(e))"content-type"===t.toLowerCase()&&delete e[t];r={...r,headers:e}}o=i}return{response:void 0,url:o}}isRedirectStatus(e){return 301===e||302===e||303===e||307===e||308===e}async discardResponseBody(e){try{await(e.body?.cancel())}catch{}}async readCappedResponseText(e){if(!e.body)return"";const t=e.body.getReader(),o=[];let r=0;try{for(;;){const{done:e,value:n}=await t.read();if(e)break;if(n){if(r+=n.byteLength,r>Ko){try{await t.cancel()}catch{}throw new ar("HTTP Request node response body exceeds the 10485760-byte limit","GRAPH_HTTP_RESPONSE_TOO_LARGE",{limitBytes:Ko})}o.push(n)}}}finally{t.releaseLock?.()}return Buffer.concat(o.map(e=>Buffer.from(e))).toString("utf8")}appendQuery(e){for(const[t,o]of Object.entries(this.query??{}))if(null!=o)if(Array.isArray(o))for(const r of o)null!=r&&e.searchParams.append(t,r+"");else e.searchParams.append(t,o+"")}resolveBody(e,t){if("GET"===t||"HEAD"===t)return;const o=void 0!==this.body?this.body:e.inputs.value;return null!=o?"string"==typeof o||"undefined"!=typeof Buffer&&Buffer.isBuffer(o)||o instanceof Uint8Array?o:JSON.stringify(o):void 0}parseResponse(e){if(0===e.length)return null;try{return JSON.parse(e)}catch{return e}}};function ua(e,t){if("string"==typeof e){if(e.startsWith("data:")){const t=e.indexOf(",");return Buffer.from(e.slice(t+1),"base64")}return"base64"===t?Buffer.from(e,"base64"):Buffer.from(e,"utf8")}if(Li(e)){const o=e.data??e.content;if(void 0!==o)return ua(o,t)}if(Qi(e))return Buffer.isBuffer(e)?e:Buffer.from(e instanceof ArrayBuffer?new Uint8Array(e):e);throw new ar("Read PDF node requires a PDF file payload","GRAPH_READ_PDF_INVALID_INPUT",{valueType:typeof e})}R([bt({handle:"value"}),C("design:type",Object)],pa.prototype,"value",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.url.label",placeholder:"graph.node.io.http_request.fields.url.placeholder",type:"text"}),bt({handle:"url",userControlled:!0}),C("design:type",String)],pa.prototype,"url",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.method.label",type:"select"}),bt({handle:"method",userControlled:!0}),C("design:type",String)],pa.prototype,"method",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.headers.label",type:"json"}),bt({handle:"headers",userControlled:!0,type:"object"}),C("design:type",Object)],pa.prototype,"headers",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.query.label",type:"json"}),bt({handle:"query",userControlled:!0,type:"object"}),C("design:type",Object)],pa.prototype,"query",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.body.label",type:"json"}),bt({handle:"body",userControlled:!0,type:"object"}),C("design:type",Object)],pa.prototype,"body",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.responseFormat.label",type:"select"}),bt({handle:"responseFormat",userControlled:!0}),C("design:type",String)],pa.prototype,"responseFormat",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.timeoutMs.label",type:"number"}),bt({handle:"timeoutMs",userControlled:!0}),C("design:type",Number)],pa.prototype,"timeoutMs",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.failOnError.label",type:"checkbox"}),bt({handle:"failOnError",userControlled:!0}),C("design:type",Boolean)],pa.prototype,"failOnError",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],pa.prototype,"result",void 0),R([wt({handle:"status"}),C("design:type",Number)],pa.prototype,"status",void 0),R([wt({handle:"headers"}),C("design:type",Object)],pa.prototype,"headersOut",void 0),pa=R([yt("core.io.httpRequest",{kind:"core.io.httpRequest",category:"IO",color:"#0ea5e9",icon:"ti-world-www",width:96,height:96,labels:["io","http","request"],metadata:{title:"graph.node.io.http_request.name",description:"graph.node.io.http_request.description"}}),I()],pa);let ha=class extends mi{constructor(){super(...arguments),this.encoding="utf8"}async execute(e){const t=ua(e.inputs.value,this.encoding??"utf8");let o;try{o=await(import("pdf-parse"))}catch(e){throw new ar("Read PDF node requires the 'pdf-parse' dependency: "+(e instanceof Error?e.message:e+""),"GRAPH_READ_PDF_DEPENDENCY_MISSING")}const r=o.PDFParse;if(!r)throw new ar("Read PDF node could not resolve the PDF parser","GRAPH_READ_PDF_DEPENDENCY_MISSING");const n=new r({data:t,...this.password?{password:this.password}:{}});try{const e=await n.getText(),t=e.text??"",o=(e.pages??[]).map((e,t)=>({pageNumber:t+1,text:e.text??""}));return{result:t,pages:o}}catch(e){throw new ar("Read PDF node failed to extract text: "+(e instanceof Error?e.message:e+""),"GRAPH_READ_PDF_FAILED")}finally{await(n.destroy?.())}}};R([w(),bt({handle:"value"}),C("design:type",Object)],ha.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_pdf.fields.encoding.label",type:"select"}),bt({handle:"encoding",userControlled:!0}),C("design:type",String)],ha.prototype,"encoding",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_pdf.fields.password.label",placeholder:"graph.node.io.read_pdf.fields.password.placeholder",type:"password"}),bt({handle:"password",userControlled:!0}),C("design:type",String)],ha.prototype,"password",void 0),R([w(),wt({handle:"result"}),C("design:type",String)],ha.prototype,"result",void 0),R([wt({handle:"pages"}),C("design:type",Array)],ha.prototype,"pages",void 0),ha=R([yt("core.io.readPDF",{kind:"core.io.readPDF",category:"IO",color:"#0ea5e9",icon:"ti-file-type-pdf",width:96,height:96,labels:["io","pdf","extract"],metadata:{title:"graph.node.io.read_pdf.name",description:"graph.node.io.read_pdf.description"}}),I()],ha);const ga=new Set(["workdocs"]);function fa(){return["/etc","/proc","/root",oe(ae(),".ssh")]}function ya(e,t){const o=re(e,t);return""===o||!o.startsWith("..")&&!ie(o)}function ma(e,t,o){if(!ya(e,t))throw new ar(`Read/Write Files from Disk node path '${o}' resolves outside the configured file IO base`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:o,base:e});for(const e of fa())if(ya(e,t))throw new ar(`Read/Write Files from Disk node path '${o}' targets a forbidden directory`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:o});const r=re(e,t).split(ne).filter(Boolean);for(const e of r)if(ga.has(e.toLowerCase()))throw new ar(`Read/Write Files from Disk node path '${o}' targets a forbidden directory`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:o,segment:e})}async function ba(e){let t=e;for(;;)try{return await de(t)}catch{const e=te(t);if(e===t)return;t=e}}let wa=class extends mi{constructor(){super(...arguments),this.operation="read",this.path="",this.encoding="utf8",this.append=!1,this.createDirectories=!1}async execute(e){if(!this.path)throw new ar("Read/Write Files from Disk node requires a path","GRAPH_READ_WRITE_FILE_PATH_REQUIRED");if(this.path.includes("\0"))throw new ar("Read/Write Files from Disk node path contains a NUL byte","GRAPH_READ_WRITE_FILE_INVALID_PATH",{path:this.path});const{base:t,candidate:o}=(e=>{const t=(()=>{const e=process.env.GRAPH_FILE_IO_BASE?.trim(),t=oe(e&&e.length>0?e:process.cwd());try{return se(t)}catch{return t}})();(e=>{if(!ie(e))return;const t=oe(e);for(const o of fa())if(ya(o,t))throw new ar(`Read/Write Files from Disk node path '${e}' targets a forbidden directory`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:e})})(e);const o=e.replace(/^[/\\]+/,""),r=oe(t,o);return ma(t,r,e),{base:t,candidate:r}})(this.path);if("read"===this.operation){let e;try{e=await de(o)}catch{throw new ar(`Read/Write Files from Disk node path '${this.path}' does not exist`,"GRAPH_READ_WRITE_FILE_INVALID_PATH",{path:this.path})}ma(t,e,this.path);const r=await le(e);return{result:"base64"===this.encoding?r.toString("base64"):r.toString("utf8"),bytes:r.byteLength}}const r=void 0!==this.content?this.content:e.inputs.value;if(null==r)throw new ar("Read/Write Files from Disk node requires content to write","GRAPH_READ_WRITE_FILE_CONTENT_REQUIRED");const n="string"==typeof r?"base64"===this.encoding?Buffer.from(r,"base64"):Buffer.from(r,"utf8"):Buffer.isBuffer(r)?r:r instanceof Uint8Array?Buffer.from(r):Buffer.from(r+"","utf8"),i=await ba(o);i&&ma(t,i,this.path),this.createDirectories&&await ce(te(o),{recursive:!0}),ma(t,await de(te(o)),this.path);const a=await ba(o);return a&&ma(t,a,this.path),this.append?await pe(o,n):await ue(o,n),{result:{path:this.path,bytes:n.byteLength},bytes:n.byteLength}}};R([bt({handle:"value"}),C("design:type",Object)],wa.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],wa.prototype,"operation",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.path.label",placeholder:"graph.node.io.read_write_file.fields.path.placeholder",type:"text"}),bt({handle:"path",userControlled:!0}),C("design:type",String)],wa.prototype,"path",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.encoding.label",type:"select"}),bt({handle:"encoding",userControlled:!0}),C("design:type",String)],wa.prototype,"encoding",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.content.label",type:"textarea"}),bt({handle:"content",userControlled:!0}),C("design:type",String)],wa.prototype,"content",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.append.label",type:"checkbox"}),bt({handle:"append",userControlled:!0}),C("design:type",Boolean)],wa.prototype,"append",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.createDirectories.label",type:"checkbox"}),bt({handle:"createDirectories",userControlled:!0}),C("design:type",Boolean)],wa.prototype,"createDirectories",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],wa.prototype,"result",void 0),R([wt({handle:"bytes"}),C("design:type",Number)],wa.prototype,"bytes",void 0),wa=R([yt("core.io.readWriteFile",{kind:"core.io.readWriteFile",category:"IO",color:"#0ea5e9",icon:"ti-device-floppy",width:96,height:96,labels:["io","file","disk"],metadata:{title:"graph.node.io.read_write_file.name",description:"graph.node.io.read_write_file.description"}}),I()],wa);let va=class extends mi{constructor(){super(...arguments),this.respondWith="firstIncomingItem",this.responseCode=200}async execute(e,t){const o=this.resolveBody(e),r={};for(const[e,t]of Object.entries(this.responseHeaders??{}))"string"==typeof t&&e.trim().length>0&&(r[e.trim()]=t);null!=o&&"string"!=typeof o&&void 0===r["content-type"]&&(r["content-type"]="application/json");const n={statusCode:this.responseCode??200,headers:r,body:o,runId:t.runId,respondedAt:(new Date).toISOString()},i=t.engine?.webhookResponses.deliver(t.runId,n)??!1;return await t.progress({...n,delivered:i}),{response:n,delivered:i}}resolveBody(e){const t=e.inputs.value;switch(this.respondWith){case"noData":return null;case"allIncomingItems":return Mi(t);case"firstIncomingItem":return Mi(t)[0]??null;case"text":return void 0===this.responseBody?null==t?"":t+"":this.responseBody+"";default:if("string"==typeof this.responseBody)try{return JSON.parse(this.responseBody)}catch{return this.responseBody}return void 0!==this.responseBody?this.responseBody:t??null}}};function xa(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:void 0}function Ia(e){return"string"==typeof e&&e.trim().length>0?e.trim():void 0}function Aa(e,t=!1){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===e.toLowerCase())return!0;if("false"===e.toLowerCase())return!1}return t}function _a(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e&&e.trim().length>0){const t=Number(e);return Number.isFinite(t)?t:void 0}}function Oa(e){return Array.isArray(e)?e:void 0}function Ea(e,t){try{const t=xa(e);if(t)return t;const o=xa(JSON.parse(e));if(!o)throw Error("not an object");return o}catch{throw new ar(t+" node credential must contain a JSON object","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:t})}}function ka(e,t){if(e){if("string"!=typeof e)return Array.isArray(e)?void 0:e;if(e.trim().startsWith("{"))try{const t=xa(JSON.parse(e));if(!t)throw Error("not an object");return t}catch{throw new ar(t+" node credential must contain a JSON object","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:t})}}}function Sa(e,t,o){const r=ka(e,o);return r?Ia(r[t]):"token"===t&&"string"==typeof e?Ia(e):void 0}function Ra(e,t){return Sa(e,"token",t)}function Ca(e,t,o){if("string"==typeof e)return Ia(e);const r=ka(e,o);if(r)for(const e of Array.isArray(t)?t:[t]){const t=Ia(r[e]);if(t)return t}}R([bt({handle:"value"}),C("design:type",Object)],va.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.respondWith.label",type:"select"}),bt({handle:"respondWith",userControlled:!0}),C("design:type",String)],va.prototype,"respondWith",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.responseCode.label",type:"number"}),bt({handle:"responseCode",userControlled:!0}),C("design:type",Number)],va.prototype,"responseCode",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.responseHeaders.label",type:"json"}),bt({handle:"responseHeaders",userControlled:!0,type:"object"}),C("design:type",Object)],va.prototype,"responseHeaders",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.responseBody.label",type:"json"}),bt({handle:"responseBody",userControlled:!0,type:"object"}),C("design:type",Object)],va.prototype,"responseBody",void 0),R([w(),wt({handle:"response"}),C("design:type",Object)],va.prototype,"response",void 0),R([wt({handle:"delivered"}),C("design:type",Boolean)],va.prototype,"delivered",void 0),va=R([yt("core.io.respondToWebhook",{kind:"core.io.respondToWebhook",category:"IO",color:"#0ea5e9",icon:"ti-corner-up-left",width:96,height:96,labels:["io","webhook","response"],metadata:{title:"graph.node.io.respond_to_webhook.name",description:"graph.node.io.respond_to_webhook.description"}}),I()],va);const Na={postgres:5432,mysql:3306,mssql:1433};class Ta extends mi{constructor(){super(...arguments),this.ssl=!1,this.acceptSelfSigned=!1}dataSourceOptions(e,t,o,r,n){const i=Aa(this.ssl,!1),a=Aa(this.acceptSelfSigned,!1),s={host:e,port:t,database:o,username:r,password:n,entities:[],synchronize:!1};return"postgres"===this.driver?{...s,type:"postgres",ssl:!!i&&{rejectUnauthorized:!a}}:"mysql"===this.driver?{...s,type:"mysql",ssl:i?{}:void 0}:{...s,type:"mssql",options:{encrypt:i,trustServerCertificate:!i}}}async execute(e,t){const o=this.constructor.name,r=this.sql?.trim();if(!r)throw new ar(o+" node requires a SQL statement","GRAPH_DATABASE_SQL_REQUIRED");const n=this.host?.trim(),i=this.database?.trim(),a=this.username?.trim();if(!n||!i||!a)throw new ar(o+" node requires host, database, and username","GRAPH_DATABASE_CONNECTION_REQUIRED");const s=Ca(await jr(t,e.credentials,this.credentialType,!1,o),["password","secret","token"],o),d=Oa(this.parameters)??(Array.isArray(e.inputs.value)?e.inputs.value:[]),l=`as-graph-${this.driver}-${Date.now()}-${Math.random().toString(36).slice(2)}`,c=new he(this.dataSourceOptions(n,_a(this.port)??Na[this.driver],i,a,s),l),p=new M;try{await c.initialize(p);const e=await c.raw({query:r,values:d},!0,p),{rows:t,rowCount:o}=(e=>{if(Array.isArray(e))return{rows:e,rowCount:e.length};const t=xa(e);if(!t)return{rows:[],rowCount:0};if(Array.isArray(t.recordsets)){const e=t.recordsets.flat(),o=t.rowsAffected;return{rows:e,rowCount:Array.isArray(o)?o.reduce((e,t)=>e+Number(t||0),0):e.length}}if(Array.isArray(t.rows)){const e=t.rows;return{rows:e,rowCount:_a(t.rowCount)??e.length}}if(Array.isArray(t.recordset)){const e=t.recordset;return{rows:e,rowCount:e.length}}if(Array.isArray(t.data)){const e=t.data;return{rows:e,rowCount:_a(t.count)??e.length}}return{rows:[],rowCount:_a(t.affectedRows)??0}})(e);return{result:t,rows:t,rowCount:o}}catch(e){if(e instanceof ar)throw e;throw new ar(`${o} node query failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_DATABASE_QUERY_FAILED",{driver:this.driver})}finally{await c.shutdown().catch(()=>{}),V.unregister(l)}}}R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.host.label",type:"string"}),bt({handle:"host",userControlled:!0}),C("design:type",String)],Ta.prototype,"host",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.port.label",type:"number"}),bt({handle:"port",userControlled:!0}),C("design:type",Number)],Ta.prototype,"port",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.database.label",type:"string"}),bt({handle:"database",userControlled:!0}),C("design:type",String)],Ta.prototype,"database",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.username.label",type:"string"}),bt({handle:"username",userControlled:!0}),C("design:type",String)],Ta.prototype,"username",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.ssl.label",type:"boolean"}),bt({handle:"ssl",userControlled:!0}),C("design:type",Boolean)],Ta.prototype,"ssl",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.acceptSelfSigned.label",type:"boolean"}),bt({handle:"acceptSelfSigned",userControlled:!0}),C("design:type",Boolean)],Ta.prototype,"acceptSelfSigned",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sql.label",type:"textarea"}),bt({handle:"sql",userControlled:!0}),C("design:type",String)],Ta.prototype,"sql",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.parameters.label",type:"array"}),bt({handle:"parameters",userControlled:!0}),C("design:type",Array)],Ta.prototype,"parameters",void 0),R([bt({handle:"value"}),C("design:type",Object)],Ta.prototype,"value",void 0),R([w(),wt({handle:"result",type:"array"}),C("design:type",Array)],Ta.prototype,"result",void 0),R([wt({handle:"rows",type:"array"}),C("design:type",Array)],Ta.prototype,"rows",void 0),R([wt({handle:"rowCount",type:"number"}),C("design:type",Number)],Ta.prototype,"rowCount",void 0);let Da=class extends Ta{constructor(){super(...arguments),this.driver="postgres",this.credentialType="postgres"}};Da=R([yt("core.storage.postgres",{kind:"core.storage.postgres",category:"Storage",color:"#336791",icon:"ti-database",width:96,height:96,labels:["storage","database","postgres","sql"],metadata:{title:"graph.node.storage.postgres.name",description:"graph.node.storage.postgres.description"}}),I()],Da);let Pa=class extends Ta{constructor(){super(...arguments),this.driver="mysql",this.credentialType="mysql"}};Pa=R([yt("core.storage.mySql",{kind:"core.storage.mySql",category:"Storage",color:"#00758f",icon:"ti-database",width:96,height:96,labels:["storage","database","mysql","sql"],metadata:{title:"graph.node.storage.my_sql.name",description:"graph.node.storage.my_sql.description"}}),I()],Pa);let ja=class extends Ta{constructor(){super(...arguments),this.driver="mssql",this.credentialType="mssql"}};ja=R([yt("core.storage.microsoftSql",{kind:"core.storage.microsoftSql",category:"Storage",color:"#cc2927",icon:"ti-database",width:96,height:96,labels:["storage","database","mssql","sqlserver","sql"],metadata:{title:"graph.node.storage.microsoft_sql.name",description:"graph.node.storage.microsoft_sql.description"}}),I()],ja);const $a=["get","set","delete","incr","keys","llen","lpop","rpop","lpush","rpush","publish","info"];function La(e){if(null===e)return null;try{return JSON.parse(e)}catch{return e}}function Ma(e){return"string"==typeof e?e:null==e?"":JSON.stringify(e)}let Ga=class extends mi{constructor(){super(...arguments),this.operation="get",this.tls=!1}async execute(e,t){const o=$a.includes(this.operation)?this.operation:"get",r=Ca(await jr(t,e.credentials,"redis",!1,"Redis"),["password","secret","token"],"Redis"),n=Ia(this.host)??"localhost",i=_a(this.port)??6379,a=Ia(this.key),s=Ia(this.prefix),d=e=>s?`${s}:${e}`:e,l=Ia(this.pattern),c=Ia(this.channel),p=this.value??e.inputs.value;if(!("info"===o||a||"keys"===o&&l||"publish"===o&&c))throw new ar(`Redis node operation '${o}' requires a key`,"GRAPH_REDIS_KEY_REQUIRED",{operation:o});const u=`as-graph-redis-${Date.now()}-${Math.random().toString(36).slice(2)}`,h=new ge({host:n,port:i,username:Ia(this.username),password:r,database:_a(this.database),tls:!!this.tls||void 0},u);try{await h.initialize();const e=h.client;switch(o){case"get":return{result:La(await e.get(d(a)))};case"set":{const t=_a(this.ttlSeconds);return{result:await e.set(d(a),Ma(p),t&&t>0?{EX:Math.floor(t)}:void 0)}}case"delete":{const t=await e.del(d(a));return{result:t,count:t}}case"incr":{const t=await e.incr(d(a));return{result:t,count:t}}case"keys":{const t=await e.keys(d(l??a??"*"));return{result:t,count:t.length}}case"llen":{const t=await e.lLen(d(a));return{result:t,count:t}}case"lpop":return{result:La(await e.lPop(d(a)))};case"rpop":return{result:La(await e.rPop(d(a)))};case"lpush":{const t=await e.lPush(d(a),Ma(p));return{result:t,count:t}}case"rpush":{const t=await e.rPush(d(a),Ma(p));return{result:t,count:t}}case"publish":{const t=await e.publish(c??a,Ma(p));return{result:t,count:t}}default:return{result:await e.info(Ia(this.section))}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Redis node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_REDIS_OPERATION_FAILED",{operation:o})}finally{await h.shutdown().catch(()=>{}),V.unregister(u)}}};R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Ga.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.host.label",type:"string"}),bt({handle:"host",userControlled:!0}),C("design:type",String)],Ga.prototype,"host",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.port.label",type:"number"}),bt({handle:"port",userControlled:!0}),C("design:type",Number)],Ga.prototype,"port",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.username.label",type:"string"}),bt({handle:"username",userControlled:!0}),C("design:type",String)],Ga.prototype,"username",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.database.label",type:"number"}),bt({handle:"database",userControlled:!0}),C("design:type",Number)],Ga.prototype,"database",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.tls.label",type:"boolean"}),bt({handle:"tls",userControlled:!0}),C("design:type",Boolean)],Ga.prototype,"tls",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.prefix.label",type:"string"}),bt({handle:"prefix",userControlled:!0}),C("design:type",String)],Ga.prototype,"prefix",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.key.label",type:"string"}),bt({handle:"key",userControlled:!0}),C("design:type",String)],Ga.prototype,"key",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.value.label",type:"textarea"}),bt({handle:"value",userControlled:!0}),C("design:type",Object)],Ga.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.ttlSeconds.label",type:"number"}),bt({handle:"ttlSeconds",userControlled:!0}),C("design:type",Number)],Ga.prototype,"ttlSeconds",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.pattern.label",type:"string"}),bt({handle:"pattern",userControlled:!0}),C("design:type",String)],Ga.prototype,"pattern",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.channel.label",type:"string"}),bt({handle:"channel",userControlled:!0}),C("design:type",String)],Ga.prototype,"channel",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.section.label",type:"string"}),bt({handle:"section",userControlled:!0}),C("design:type",String)],Ga.prototype,"section",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Ga.prototype,"result",void 0),R([wt({handle:"value"}),C("design:type",Object)],Ga.prototype,"valueOutput",void 0),R([wt({handle:"count",type:"number"}),C("design:type",Number)],Ga.prototype,"count",void 0),Ga=R([yt("core.storage.redis",{kind:"core.storage.redis",category:"Storage",color:"#dc382d",icon:"ti-brand-redis",width:96,height:96,labels:["storage","redis","cache","keyvalue"],metadata:{title:"graph.node.storage.redis.name",description:"graph.node.storage.redis.description"}}),I()],Ga);const Ua=["put","get","delete","list","stat","has","url","copy"];class Fa extends mi{constructor(){super(...arguments),this.operation="get",this.encoding="utf8",this.urlOperation="get"}async execute(e,t){const o=this.constructor.name,r=Ua.includes(this.operation)?this.operation:"get",n=Ia(this.key);if("list"!==r&&!n)throw new ar(`${o} node operation '${r}' requires a key`,"GRAPH_BLOB_KEY_REQUIRED",{operation:r});const i=await jr(t,e.credentials,this.credentialType,!1,o),a=await this.createService(i);try{switch(r){case"put":{const t=this.content??e.inputs.value,r=xa(this.metadataValues),i=await a.put(n,((e,t,o)=>{if("string"==typeof e)return"base64"===t?Buffer.from(e,"base64"):Buffer.from(e,"utf8");if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(null==e)return Buffer.alloc(0);try{return Buffer.from(JSON.stringify(e),"utf8")}catch{throw new ar(o+" node cannot encode the blob payload","GRAPH_BLOB_INVALID_PAYLOAD")}})(t,this.encoding,o),{contentType:Ia(this.contentType),metadata:r?Object.fromEntries(Object.entries(r).map(([e,t])=>[e,t+""])):void 0});return{result:i}}case"get":{const e=await a.get(n),t=await fe(e.value),o="base64"===this.encoding?t.toString("base64"):t.toString("utf8");return{result:{key:e.key,uri:e.uri,provider:e.provider,sourceId:e.sourceId,metadata:e.metadata},value:o,contentLength:t.length,contentType:e.metadata.contentType}}case"delete":return await a.delete(n),{result:{key:n,deleted:!0}};case"list":{const e=_a(this.limit);return{result:await a.list({prefix:Ia(this.prefix),limit:void 0===e?void 0:Math.max(0,Math.floor(e)),cursor:Ia(this.cursor)})}}case"stat":return{result:await a.stat(n)};case"has":return{result:await a.has(n)};case"url":{const e=_a(this.expiresInSeconds);return{result:await a.url(n,{operation:this.urlOperation,expiresInSeconds:void 0===e?void 0:Math.max(0,Math.floor(e)),contentType:Ia(this.contentType)})}}case"copy":{const e=Ia(this.targetKey);if(!e)throw new ar(o+" node copy operation requires a targetKey","GRAPH_BLOB_TARGET_KEY_REQUIRED");return{result:await a.copy(n,e,{contentType:Ia(this.contentType)})}}default:throw new ar(`${o} node operation '${r}' is not supported`,"GRAPH_BLOB_OPERATION_NOT_SUPPORTED",{operation:r})}}catch(e){if(e instanceof ar)throw e;throw new ar(`${o} node operation '${r}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_BLOB_OPERATION_FAILED",{operation:r})}finally{await a.shutdown().catch(()=>{})}}}R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Fa.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.key.label",type:"string"}),bt({handle:"key",userControlled:!0}),C("design:type",String)],Fa.prototype,"key",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.targetKey.label",type:"string"}),bt({handle:"targetKey",userControlled:!0}),C("design:type",String)],Fa.prototype,"targetKey",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.content.label",type:"textarea"}),bt({handle:"content",userControlled:!0}),C("design:type",Object)],Fa.prototype,"content",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.contentType.label",type:"string"}),bt({handle:"contentType",userControlled:!0}),C("design:type",String)],Fa.prototype,"contentType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.encoding.label",type:"select"}),bt({handle:"encoding",userControlled:!0}),C("design:type",String)],Fa.prototype,"encoding",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.metadataValues.label",type:"object"}),bt({handle:"metadataValues",userControlled:!0}),C("design:type",Object)],Fa.prototype,"metadataValues",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.prefix.label",type:"string"}),bt({handle:"prefix",userControlled:!0}),C("design:type",String)],Fa.prototype,"prefix",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.cursor.label",type:"string"}),bt({handle:"cursor",userControlled:!0}),C("design:type",String)],Fa.prototype,"cursor",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],Fa.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.urlOperation.label",type:"select"}),bt({handle:"urlOperation",userControlled:!0}),C("design:type",String)],Fa.prototype,"urlOperation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.expiresInSeconds.label",type:"number"}),bt({handle:"expiresInSeconds",userControlled:!0}),C("design:type",Number)],Fa.prototype,"expiresInSeconds",void 0),R([bt({handle:"value"}),C("design:type",Object)],Fa.prototype,"value",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Fa.prototype,"result",void 0),R([wt({handle:"value"}),C("design:type",String)],Fa.prototype,"valueOutput",void 0),R([wt({handle:"contentLength",type:"number"}),C("design:type",Number)],Fa.prototype,"contentLength",void 0),R([wt({handle:"contentType"}),C("design:type",String)],Fa.prototype,"contentTypeOutput",void 0);class Ba extends Fa{constructor(){super(...arguments),this.credentialType="s3",this.forcePathStyle=!1}async createService(e){const t=Ia(this.bucket);if(!t)throw new ar("S3 node requires a bucket","GRAPH_BLOB_BUCKET_REQUIRED");const o=new ye;return await me(o,((e,t)=>{const o=e?Ea(e,"S3"):void 0;return{provider:"s3",bucket:t.bucket,sourceId:t.sourceId,region:t.region,endpoint:t.endpoint,prefix:t.prefix,forcePathStyle:t.forcePathStyle,credentials:o&&"string"==typeof o.accessKeyId?{accessKeyId:o.accessKeyId,secretAccessKey:(o.secretAccessKey??"")+"",sessionToken:Ia(o.sessionToken)}:void 0}})(e,{bucket:t,sourceId:Ia(this.sourceId)??"graph",region:Ia(this.region),endpoint:Ia(this.endpoint),prefix:Ia(this.prefix),forcePathStyle:this.forcePathStyle})),o}}R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.bucket.label",type:"string"}),bt({handle:"bucket",userControlled:!0}),C("design:type",String)],Ba.prototype,"bucket",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sourceId.label",type:"string"}),bt({handle:"sourceId",userControlled:!0}),C("design:type",String)],Ba.prototype,"sourceId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.region.label",type:"string"}),bt({handle:"region",userControlled:!0}),C("design:type",String)],Ba.prototype,"region",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.endpoint.label",type:"string"}),bt({handle:"endpoint",userControlled:!0}),C("design:type",String)],Ba.prototype,"endpoint",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.forcePathStyle.label",type:"boolean"}),bt({handle:"forcePathStyle",userControlled:!0}),C("design:type",Boolean)],Ba.prototype,"forcePathStyle",void 0);let Ha=class extends Ba{};Ha=R([yt("core.storage.s3",{kind:"core.storage.s3",category:"Storage",color:"#e25444",icon:"ti-bucket",width:96,height:96,labels:["storage","s3","blob","aws"],metadata:{title:"graph.node.storage.s3.name",description:"graph.node.storage.s3.description"}}),I()],Ha);let qa=class extends Ba{};qa=R([yt("core.storage.awsS3",{kind:"core.storage.awsS3",category:"Storage",color:"#ff9900",icon:"ti-brand-aws",width:96,height:96,labels:["storage","s3","blob","aws"],metadata:{title:"graph.node.storage.aws_s3.name",description:"graph.node.storage.aws_s3.description"}}),I()],qa);let Wa=class extends Fa{constructor(){super(...arguments),this.credentialType="gcs"}async createService(e){const t=Ia(this.bucket);if(!t)throw new ar("Google Cloud Storage node requires a bucket","GRAPH_BLOB_BUCKET_REQUIRED");const o={provider:"gcs",bucket:t,sourceId:Ia(this.sourceId)??"graph",projectId:Ia(this.projectId),apiEndpoint:Ia(this.apiEndpoint),prefix:Ia(this.prefix),credentials:e?Ea(e,"Google Cloud Storage"):void 0},r=new be;return await me(r,o),r}};function Ka(e){if(!e)return;if("string"!=typeof e)return Ia(e.connectionString);const t=e.trim();return t.startsWith("{")?Ia(Ea(t,"Azure Storage").connectionString):t}R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.bucket.label",type:"string"}),bt({handle:"bucket",userControlled:!0}),C("design:type",String)],Wa.prototype,"bucket",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sourceId.label",type:"string"}),bt({handle:"sourceId",userControlled:!0}),C("design:type",String)],Wa.prototype,"sourceId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.projectId.label",type:"string"}),bt({handle:"projectId",userControlled:!0}),C("design:type",String)],Wa.prototype,"projectId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.apiEndpoint.label",type:"string"}),bt({handle:"apiEndpoint",userControlled:!0}),C("design:type",String)],Wa.prototype,"apiEndpoint",void 0),Wa=R([yt("core.storage.googleCloudStorage",{kind:"core.storage.googleCloudStorage",category:"Storage",color:"#4285f4",icon:"ti-brand-google-cloud",width:96,height:96,labels:["storage","gcs","blob","google"],metadata:{title:"graph.node.storage.google_cloud_storage.name",description:"graph.node.storage.google_cloud_storage.description"}}),I()],Wa);let Va=class extends Fa{constructor(){super(...arguments),this.credentialType="azure-blob"}async createService(e){const t=Ia(this.container);if(!t)throw new ar("Azure Storage node requires a container","GRAPH_BLOB_CONTAINER_REQUIRED");const o={provider:"azure-blob",container:t,sourceId:Ia(this.sourceId)??"graph",accountName:Ia(this.accountName),endpoint:Ia(this.endpoint),prefix:Ia(this.prefix),connectionString:Ka(e)},r=new we;return await me(r,o),r}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.container.label",type:"string"}),bt({handle:"container",userControlled:!0}),C("design:type",String)],Va.prototype,"container",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sourceId.label",type:"string"}),bt({handle:"sourceId",userControlled:!0}),C("design:type",String)],Va.prototype,"sourceId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.accountName.label",type:"string"}),bt({handle:"accountName",userControlled:!0}),C("design:type",String)],Va.prototype,"accountName",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.endpoint.label",type:"string"}),bt({handle:"endpoint",userControlled:!0}),C("design:type",String)],Va.prototype,"endpoint",void 0),Va=R([yt("core.storage.azureStorage",{kind:"core.storage.azureStorage",category:"Storage",color:"#0078d4",icon:"ti-brand-azure",width:96,height:96,labels:["storage","azure","blob"],metadata:{title:"graph.node.storage.azure_storage.name",description:"graph.node.storage.azure_storage.description"}}),I()],Va);const za=["postMessage","listConversations","getConversation","getUser"];let Qa=class extends mi{constructor(){super(...arguments),this.operation="postMessage"}async execute(e,t){const o=za.includes(this.operation)?this.operation:"postMessage";if(!this.operation)throw new ar("Slack node requires an operation","GRAPH_SLACK_OPERATION_REQUIRED");const r=Ra(await jr(t,e.credentials,"slack",!1,"Slack"),"Slack"),n=new ve;try{switch(await me(n,{token:r,baseUrl:this.baseUrl}),o){case"postMessage":{const t=this.channel,o=this.text??(e.inputs.value??"")+"";if(!t||!o)throw new ar("Slack postMessage requires a channel and text","GRAPH_SLACK_MESSAGE_REQUIRED");const r=await n.postMessage({channel:t,text:o,blocks:Oa(this.blocks),threadTs:this.threadTs,replyBroadcast:this.replyBroadcast,unfurlLinks:this.unfurlLinks,unfurlMedia:this.unfurlMedia});return{result:r,channel:r.channel,ts:r.ts}}case"listConversations":return{result:await n.listConversations({limit:_a(this.limit),cursor:this.cursor,types:this.types,excludeArchived:this.excludeArchived})};case"getConversation":{if(!this.channel)throw new ar("Slack getConversation requires a channel","GRAPH_SLACK_CHANNEL_REQUIRED");const e=await n.getConversation(this.channel);return{result:e,channel:e.id}}default:if(!this.userId)throw new ar("Slack getUser requires a user ID","GRAPH_SLACK_USER_REQUIRED");return{result:await n.getUser(this.userId)}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Slack node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_SLACK_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Qa.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.channel.label",type:"string"}),bt({handle:"channel",userControlled:!0}),C("design:type",String)],Qa.prototype,"channel",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.text.label",type:"textarea"}),bt({handle:"text",userControlled:!0}),C("design:type",String)],Qa.prototype,"text",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.blocks.label",type:"json"}),bt({handle:"blocks",userControlled:!0}),C("design:type",Array)],Qa.prototype,"blocks",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.threadTs.label",type:"string"}),bt({handle:"threadTs",userControlled:!0}),C("design:type",String)],Qa.prototype,"threadTs",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],Qa.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.cursor.label",type:"string"}),bt({handle:"cursor",userControlled:!0}),C("design:type",String)],Qa.prototype,"cursor",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.types.label",type:"string"}),bt({handle:"types",userControlled:!0}),C("design:type",String)],Qa.prototype,"types",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.userId.label",type:"string"}),bt({handle:"userId",userControlled:!0}),C("design:type",String)],Qa.prototype,"userId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],Qa.prototype,"baseUrl",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.excludeArchived.label",type:"boolean"}),bt({handle:"excludeArchived",userControlled:!0}),C("design:type",Boolean)],Qa.prototype,"excludeArchived",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.replyBroadcast.label",type:"boolean"}),bt({handle:"replyBroadcast",userControlled:!0}),C("design:type",Boolean)],Qa.prototype,"replyBroadcast",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.unfurlLinks.label",type:"boolean"}),bt({handle:"unfurlLinks",userControlled:!0}),C("design:type",Boolean)],Qa.prototype,"unfurlLinks",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.unfurlMedia.label",type:"boolean"}),bt({handle:"unfurlMedia",userControlled:!0}),C("design:type",Boolean)],Qa.prototype,"unfurlMedia",void 0),R([wt({handle:"result"}),C("design:type",Object)],Qa.prototype,"result",void 0),R([wt({handle:"channel",type:"string"}),C("design:type",String)],Qa.prototype,"resultChannel",void 0),R([wt({handle:"ts",type:"string"}),C("design:type",String)],Qa.prototype,"resultTs",void 0),Qa=R([yt("core.comms.slack",{kind:"core.comms.slack",category:"Comms",color:"#4a154b",icon:"ti-brand-slack",width:96,height:96,labels:["comms","slack","messaging","chat"],metadata:{title:"graph.node.comms.slack.name",description:"graph.node.comms.slack.description"}}),I()],Qa);const Ja=["sendMessage","getMe","getUpdates","sendChatAction"];let Xa=class extends mi{constructor(){super(...arguments),this.operation="sendMessage"}async execute(e,t){if(!this.operation)throw new ar("Telegram node requires an operation","GRAPH_TELEGRAM_OPERATION_REQUIRED");const o=Ja.includes(this.operation)?this.operation:"sendMessage",r=Ra(await jr(t,e.credentials,"telegram",!1,"Telegram"),"Telegram"),n=new xe;try{switch(await me(n,{token:r,baseUrl:this.baseUrl}),o){case"sendMessage":{const t=this.chatId,o=this.text??(e.inputs.value??"")+"";if(null==t||!o)throw new ar("Telegram sendMessage requires a chat ID and text","GRAPH_TELEGRAM_MESSAGE_REQUIRED");const r=await n.sendMessage({chatId:t,text:o,parseMode:this.parseMode,disableNotification:this.disableNotification,disablePreview:this.disablePreview,replyToMessageId:_a(this.replyToMessageId),messageThreadId:_a(this.messageThreadId)});return{result:r,messageId:_a(r?.message_id)}}case"getMe":return{result:await n.getMe()};case"getUpdates":return{result:await n.getUpdates({offset:_a(this.offset),limit:_a(this.limit),timeoutSeconds:_a(this.timeoutSeconds)})};default:if(void 0===this.chatId||null===this.chatId)throw new ar("Telegram sendChatAction requires a chat ID","GRAPH_TELEGRAM_CHAT_REQUIRED");return{result:await n.sendChatAction(this.chatId,this.action??"typing")}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Telegram node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_TELEGRAM_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Xa.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.chatId.label",type:"string"}),bt({handle:"chatId",userControlled:!0}),C("design:type",Object)],Xa.prototype,"chatId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.text.label",type:"textarea"}),bt({handle:"text",userControlled:!0}),C("design:type",String)],Xa.prototype,"text",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.parseMode.label",type:"select"}),bt({handle:"parseMode",userControlled:!0}),C("design:type",String)],Xa.prototype,"parseMode",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.disableNotification.label",type:"boolean"}),bt({handle:"disableNotification",userControlled:!0}),C("design:type",Boolean)],Xa.prototype,"disableNotification",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.disablePreview.label",type:"boolean"}),bt({handle:"disablePreview",userControlled:!0}),C("design:type",Boolean)],Xa.prototype,"disablePreview",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.replyToMessageId.label",type:"number"}),bt({handle:"replyToMessageId",userControlled:!0}),C("design:type",Number)],Xa.prototype,"replyToMessageId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.messageThreadId.label",type:"number"}),bt({handle:"messageThreadId",userControlled:!0}),C("design:type",Number)],Xa.prototype,"messageThreadId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.offset.label",type:"number"}),bt({handle:"offset",userControlled:!0}),C("design:type",Number)],Xa.prototype,"offset",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],Xa.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.timeoutSeconds.label",type:"number"}),bt({handle:"timeoutSeconds",userControlled:!0}),C("design:type",Number)],Xa.prototype,"timeoutSeconds",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.action.label",type:"string"}),bt({handle:"action",userControlled:!0}),C("design:type",String)],Xa.prototype,"action",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],Xa.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],Xa.prototype,"result",void 0),R([wt({handle:"messageId",type:"number"}),C("design:type",Number)],Xa.prototype,"messageId",void 0),Xa=R([yt("core.comms.telegram",{kind:"core.comms.telegram",category:"Comms",color:"#229ed9",icon:"ti-brand-telegram",width:96,height:96,labels:["comms","telegram","messaging","bot"],metadata:{title:"graph.node.comms.telegram.name",description:"graph.node.comms.telegram.description"}}),I()],Xa);const Ya=["sendWebhook","sendChannelMessage","listTeams","listChannels"];let Za=class extends mi{constructor(){super(...arguments),this.operation="sendWebhook"}async execute(e,t){if(!this.operation)throw new ar("Microsoft Teams node requires an operation","GRAPH_TEAMS_OPERATION_REQUIRED");const o=Ya.includes(this.operation)?this.operation:"sendWebhook",r=await jr(t,e.credentials,"teams",!1,"Microsoft Teams"),n=new Ie;try{switch(await me(n,{token:Sa(r,"token","Microsoft Teams"),webhookUrl:Sa(r,"webhookUrl","Microsoft Teams"),baseUrl:this.baseUrl}),o){case"sendWebhook":{const t=this.text??(e.inputs.value??"")+"";if(!t)throw new ar("Microsoft Teams sendWebhook requires text","GRAPH_TEAMS_TEXT_REQUIRED");return{result:await n.sendWebhook({text:t,title:this.title,markdown:this.markdown})}}case"sendChannelMessage":if(!this.teamId||!this.channelId||!this.content)throw new ar("Microsoft Teams sendChannelMessage requires teamId, channelId, and content","GRAPH_TEAMS_CHANNEL_MESSAGE_REQUIRED");return{result:await n.sendChannelMessage({teamId:this.teamId,channelId:this.channelId,content:this.content,contentType:this.contentType})};case"listTeams":return{result:await n.listTeams(_a(this.limit))};default:if(!this.teamId)throw new ar("Microsoft Teams listChannels requires a teamId","GRAPH_TEAMS_TEAM_REQUIRED");return{result:await n.listChannels(this.teamId)}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Microsoft Teams node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_TEAMS_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Za.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.text.label",type:"textarea"}),bt({handle:"text",userControlled:!0}),C("design:type",String)],Za.prototype,"text",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.title.label",type:"string"}),bt({handle:"title",userControlled:!0}),C("design:type",String)],Za.prototype,"title",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.markdown.label",type:"boolean"}),bt({handle:"markdown",userControlled:!0}),C("design:type",Boolean)],Za.prototype,"markdown",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.teamId.label",type:"string"}),bt({handle:"teamId",userControlled:!0}),C("design:type",String)],Za.prototype,"teamId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.channelId.label",type:"string"}),bt({handle:"channelId",userControlled:!0}),C("design:type",String)],Za.prototype,"channelId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.content.label",type:"textarea"}),bt({handle:"content",userControlled:!0}),C("design:type",String)],Za.prototype,"content",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.contentType.label",type:"select"}),bt({handle:"contentType",userControlled:!0}),C("design:type",String)],Za.prototype,"contentType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],Za.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],Za.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],Za.prototype,"result",void 0),Za=R([yt("core.comms.teams",{kind:"core.comms.teams",category:"Comms",color:"#6264a7",icon:"ti-brand-teams",width:96,height:96,labels:["comms","teams","microsoft","messaging"],metadata:{title:"graph.node.comms.teams.name",description:"graph.node.comms.teams.description"}}),I()],Za);const es=["send","list","get","labels"];let ts=class extends mi{constructor(){super(...arguments),this.operation="send"}async execute(e,t){if(!this.operation)throw new ar("Gmail node requires an operation","GRAPH_GMAIL_OPERATION_REQUIRED");const o=es.includes(this.operation)?this.operation:"send",r=await jr(t,e.credentials,"gmail",!1,"Gmail"),n=new Ae;try{switch(await me(n,{token:Ra(r,"Gmail"),userId:this.userId??Sa(r,"userId","Gmail"),baseUrl:this.baseUrl}),o){case"send":{const t=this.from??Sa(r,"from","Gmail");if(!t||!this.to||!this.subject)throw new ar("Gmail send requires from, to, and subject","GRAPH_GMAIL_MESSAGE_REQUIRED");const o=await n.send({from:t,to:this.to,cc:this.cc,bcc:this.bcc,subject:this.subject,text:this.text??(e.inputs.value??"")+"",html:this.html,replyTo:this.replyTo});return{result:o,id:o.id}}case"list":return{result:await n.listMessages({query:this.query,maxResults:_a(this.maxResults),pageToken:this.pageToken,labelIds:Oa(this.labelIds)?.map(String)})};case"get":if(!this.messageId)throw new ar("Gmail get requires a message ID","GRAPH_GMAIL_MESSAGE_ID_REQUIRED");return{result:await n.getMessage(this.messageId,this.format??"full")};default:return{result:await n.listLabels()}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Gmail node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GMAIL_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],ts.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.userId.label",type:"string"}),bt({handle:"userId",userControlled:!0}),C("design:type",String)],ts.prototype,"userId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.from.label",type:"string"}),bt({handle:"from",userControlled:!0}),C("design:type",String)],ts.prototype,"from",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.to.label",type:"string"}),bt({handle:"to",userControlled:!0}),C("design:type",Object)],ts.prototype,"to",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.cc.label",type:"string"}),bt({handle:"cc",userControlled:!0}),C("design:type",Object)],ts.prototype,"cc",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.bcc.label",type:"string"}),bt({handle:"bcc",userControlled:!0}),C("design:type",Object)],ts.prototype,"bcc",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.subject.label",type:"string"}),bt({handle:"subject",userControlled:!0}),C("design:type",String)],ts.prototype,"subject",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.text.label",type:"textarea"}),bt({handle:"text",userControlled:!0}),C("design:type",String)],ts.prototype,"text",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.html.label",type:"textarea"}),bt({handle:"html",userControlled:!0}),C("design:type",String)],ts.prototype,"html",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.replyTo.label",type:"string"}),bt({handle:"replyTo",userControlled:!0}),C("design:type",String)],ts.prototype,"replyTo",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.query.label",type:"string"}),bt({handle:"query",userControlled:!0}),C("design:type",String)],ts.prototype,"query",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.maxResults.label",type:"number"}),bt({handle:"maxResults",userControlled:!0}),C("design:type",Number)],ts.prototype,"maxResults",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.pageToken.label",type:"string"}),bt({handle:"pageToken",userControlled:!0}),C("design:type",String)],ts.prototype,"pageToken",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.labelIds.label",type:"json"}),bt({handle:"labelIds",userControlled:!0}),C("design:type",Array)],ts.prototype,"labelIds",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.messageId.label",type:"string"}),bt({handle:"messageId",userControlled:!0}),C("design:type",String)],ts.prototype,"messageId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.format.label",type:"select"}),bt({handle:"format",userControlled:!0}),C("design:type",String)],ts.prototype,"format",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],ts.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],ts.prototype,"result",void 0),R([wt({handle:"id",type:"string"}),C("design:type",String)],ts.prototype,"id",void 0),ts=R([yt("core.comms.gmail",{kind:"core.comms.gmail",category:"Comms",color:"#ea4335",icon:"ti-brand-google",width:96,height:96,labels:["comms","gmail","email","google"],metadata:{title:"graph.node.comms.gmail.name",description:"graph.node.comms.gmail.description"}}),I()],ts);const os=["send","listInbox","listImap"];let rs=class extends mi{constructor(){super(...arguments),this.operation="send"}async execute(e,t){if(!this.operation)throw new ar("Email Send node requires an operation","GRAPH_EMAIL_OPERATION_REQUIRED");const o=os.includes(this.operation)?this.operation:"send",r=await jr(t,e.credentials,"email",!1,"Email"),n=ka(r,"Email"),i=r&&!n?r:void 0,a=new _e;try{switch(await me(a,{provider:this.provider??n?.provider,host:this.host??this.asCredentialString(n,"host"),port:_a(this.port)??_a(n?.port),secure:this.secure??Aa(n?.secure,!1),username:this.username??this.asCredentialString(n,"username"),password:this.asCredentialString(n,"password"),from:this.from??this.asCredentialString(n,"from"),token:i??this.asCredentialString(n,"token"),graphBaseUrl:this.graphBaseUrl??this.asCredentialString(n,"graphBaseUrl"),baseUrl:this.baseUrl}),o){case"send":{if(!this.to||!this.subject)throw new ar("Email Send send requires to and subject","GRAPH_EMAIL_MESSAGE_REQUIRED");const t=await a.send({from:this.from??this.asCredentialString(n,"from")??"",to:this.to,cc:this.cc,bcc:this.bcc,subject:this.subject,text:this.text??(e.inputs.value??"")+"",html:this.html,replyTo:this.replyTo});return{result:t,messageId:t.messageId}}case"listInbox":return{result:await a.listInbox({mailbox:this.mailbox,limit:_a(this.limit),since:this.since,subject:this.subjectFilter})};default:return{result:await a.listImapMessages({mailbox:this.mailbox,limit:_a(this.limit),since:this.since,subject:this.subjectFilter})}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Email node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_EMAIL_OPERATION_FAILED",{operation:o})}finally{await a.shutdown().catch(()=>{})}}asCredentialString(e,t){const o=e?.[t];return"string"==typeof o&&o.trim().length>0?o.trim():void 0}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],rs.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.provider.label",type:"select"}),bt({handle:"provider",userControlled:!0}),C("design:type",String)],rs.prototype,"provider",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.host.label",type:"string"}),bt({handle:"host",userControlled:!0}),C("design:type",String)],rs.prototype,"host",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.port.label",type:"number"}),bt({handle:"port",userControlled:!0}),C("design:type",Number)],rs.prototype,"port",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.secure.label",type:"boolean"}),bt({handle:"secure",userControlled:!0}),C("design:type",Boolean)],rs.prototype,"secure",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.username.label",type:"string"}),bt({handle:"username",userControlled:!0}),C("design:type",String)],rs.prototype,"username",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.from.label",type:"string"}),bt({handle:"from",userControlled:!0}),C("design:type",String)],rs.prototype,"from",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.to.label",type:"string"}),bt({handle:"to",userControlled:!0}),C("design:type",Object)],rs.prototype,"to",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.cc.label",type:"string"}),bt({handle:"cc",userControlled:!0}),C("design:type",Object)],rs.prototype,"cc",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.bcc.label",type:"string"}),bt({handle:"bcc",userControlled:!0}),C("design:type",Object)],rs.prototype,"bcc",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.subject.label",type:"string"}),bt({handle:"subject",userControlled:!0}),C("design:type",String)],rs.prototype,"subject",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.text.label",type:"textarea"}),bt({handle:"text",userControlled:!0}),C("design:type",String)],rs.prototype,"text",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.html.label",type:"textarea"}),bt({handle:"html",userControlled:!0}),C("design:type",String)],rs.prototype,"html",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.replyTo.label",type:"string"}),bt({handle:"replyTo",userControlled:!0}),C("design:type",String)],rs.prototype,"replyTo",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.mailbox.label",type:"string"}),bt({handle:"mailbox",userControlled:!0}),C("design:type",String)],rs.prototype,"mailbox",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],rs.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.since.label",type:"string"}),bt({handle:"since",userControlled:!0}),C("design:type",String)],rs.prototype,"since",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.subjectFilter.label",type:"string"}),bt({handle:"subjectFilter",userControlled:!0}),C("design:type",String)],rs.prototype,"subjectFilter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.graphBaseUrl.label",type:"string"}),bt({handle:"graphBaseUrl",userControlled:!0}),C("design:type",String)],rs.prototype,"graphBaseUrl",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],rs.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],rs.prototype,"result",void 0),R([wt({handle:"messageId",type:"string"}),C("design:type",String)],rs.prototype,"messageId",void 0),rs=R([yt("core.comms.emailSend",{kind:"core.comms.emailSend",category:"Comms",color:"#0f766e",icon:"ti-mail",width:96,height:96,labels:["comms","email","smtp","imap"],metadata:{title:"graph.node.comms.email_send.name",description:"graph.node.comms.email_send.description"}}),I()],rs);const ns=["get","update","append","clear","create"];let is=class extends mi{constructor(){super(...arguments),this.operation="get"}async execute(e,t){if(!this.operation)throw new ar("Google Sheets node requires an operation","GRAPH_GOOGLE_SHEETS_OPERATION_REQUIRED");const o=ns.includes(this.operation)?this.operation:"get",r=await jr(t,e.credentials,"google-sheets",!1,"Google Sheets"),n=new Oe;try{switch(await me(n,{token:Sa(r,"token","Google Sheets"),apiKey:Sa(r,"apiKey","Google Sheets"),baseUrl:this.baseUrl}),o){case"get":{const e=await n.getValues(this.requireSpreadsheet(),this.requireRange());return{result:e,values:e.values,spreadsheetId:e.spreadsheetId,range:e.range}}case"update":case"append":{const e=this.requireValues(),t={spreadsheetId:this.requireSpreadsheet(),range:this.requireRange(),values:e,valueInputOption:this.valueInputOption??"USER_ENTERED"},r="update"===o?await n.updateValues(t):await n.appendValues(t);return{result:r,values:r.values,spreadsheetId:r.spreadsheetId,range:r.range}}case"clear":{const e=await n.clearValues(this.requireSpreadsheet(),this.requireRange());return{result:e,spreadsheetId:e.spreadsheetId,range:e.clearedRange}}default:{if(!this.title)throw new ar("Google Sheets create requires a title","GRAPH_GOOGLE_SHEETS_TITLE_REQUIRED");const e=await n.createSpreadsheet(this.title);return{result:e,spreadsheetId:e.spreadsheetId}}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Google Sheets node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GOOGLE_SHEETS_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}requireSpreadsheet(){if(!this.spreadsheetId)throw new ar("Google Sheets node requires a spreadsheet ID","GRAPH_GOOGLE_SHEETS_SPREADSHEET_REQUIRED");return this.spreadsheetId}requireRange(){if(!this.range)throw new ar("Google Sheets node requires a range","GRAPH_GOOGLE_SHEETS_RANGE_REQUIRED");return this.range}requireValues(){if(!Array.isArray(this.values)||!this.values.every(e=>Array.isArray(e)))throw new ar("Google Sheets node requires values as an array of rows","GRAPH_GOOGLE_SHEETS_VALUES_REQUIRED");return this.values}};R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],is.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.spreadsheetId.label",type:"string"}),bt({handle:"spreadsheetId",userControlled:!0}),C("design:type",String)],is.prototype,"spreadsheetId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.range.label",type:"string"}),bt({handle:"range",userControlled:!0}),C("design:type",String)],is.prototype,"range",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.values.label",type:"json"}),bt({handle:"values",userControlled:!0}),C("design:type",Array)],is.prototype,"values",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.valueInputOption.label",type:"select"}),bt({handle:"valueInputOption",userControlled:!0}),C("design:type",String)],is.prototype,"valueInputOption",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.title.label",type:"string"}),bt({handle:"title",userControlled:!0}),C("design:type",String)],is.prototype,"title",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],is.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],is.prototype,"result",void 0),R([wt({handle:"values",type:"array"}),C("design:type",Array)],is.prototype,"outputValues",void 0),R([wt({handle:"spreadsheetId",type:"string"}),C("design:type",String)],is.prototype,"outputSpreadsheetId",void 0),R([wt({handle:"range",type:"string"}),C("design:type",String)],is.prototype,"outputRange",void 0),is=R([yt("core.io.googleSheets",{kind:"core.io.googleSheets",category:"IO",color:"#0f9d58",icon:"ti-brand-google",width:96,height:96,labels:["io","google","sheets","spreadsheet"],metadata:{title:"graph.node.io.google_sheets.name",description:"graph.node.io.google_sheets.description"}}),I()],is);const as=["list","get","create","update","delete"];let ss=class extends mi{constructor(){super(...arguments),this.operation="list"}async execute(e,t){if(!this.operation)throw new ar("Airtable node requires an operation","GRAPH_AIRTABLE_OPERATION_REQUIRED");const o=as.includes(this.operation)?this.operation:"list",r=await jr(t,e.credentials,"airtable",!1,"Airtable"),n=new Ee;try{switch(await me(n,{token:Sa(r,"token","Airtable"),baseId:this.baseId??Sa(r,"baseId","Airtable"),baseUrl:this.baseUrl}),o){case"list":{const e=await n.listRecords({table:this.requireTable(),view:this.view,filterByFormula:this.filterByFormula,maxRecords:_a(this.maxRecords),pageSize:_a(this.pageSize),offset:this.offset,fields:Array.isArray(this.fields)?this.fields.map(String):void 0,sort:this.sortField?[{field:this.sortField,direction:this.sortDirection}]:void 0});return{result:e,records:e.records,offset:e.offset}}case"get":{const e=await n.getRecord(this.requireTable(),this.requireRecordId());return{result:e,records:[e]}}case"create":{const e=await n.createRecord({table:this.requireTable(),fields:this.requireRecordFields(),typecast:this.typecast});return{result:e,records:[e]}}case"update":{const e=await n.updateRecord({table:this.requireTable(),recordId:this.requireRecordId(),fields:this.requireRecordFields(),typecast:this.typecast});return{result:e,records:[e]}}default:return{result:await n.deleteRecord(this.requireTable(),this.requireRecordId())}}}catch(e){if(e instanceof ar)throw e;throw new ar(`Airtable node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_AIRTABLE_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}requireTable(){if(!this.table)throw new ar("Airtable node requires a table","GRAPH_AIRTABLE_TABLE_REQUIRED");return this.table}requireRecordId(){if(!this.recordId)throw new ar("Airtable node requires a record ID","GRAPH_AIRTABLE_RECORD_REQUIRED");return this.recordId}requireRecordFields(){const e=xa(this.recordFields);if(!e)throw new ar("Airtable node requires recordFields as an object","GRAPH_AIRTABLE_FIELDS_REQUIRED");return e}};R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],ss.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.baseId.label",type:"string"}),bt({handle:"baseId",userControlled:!0}),C("design:type",String)],ss.prototype,"baseId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.table.label",type:"string"}),bt({handle:"table",userControlled:!0}),C("design:type",String)],ss.prototype,"table",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.recordId.label",type:"string"}),bt({handle:"recordId",userControlled:!0}),C("design:type",String)],ss.prototype,"recordId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.recordFields.label",type:"json"}),bt({handle:"recordFields",userControlled:!0}),C("design:type",Object)],ss.prototype,"recordFields",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.typecast.label",type:"boolean"}),bt({handle:"typecast",userControlled:!0}),C("design:type",Boolean)],ss.prototype,"typecast",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.view.label",type:"string"}),bt({handle:"view",userControlled:!0}),C("design:type",String)],ss.prototype,"view",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.filterByFormula.label",type:"string"}),bt({handle:"filterByFormula",userControlled:!0}),C("design:type",String)],ss.prototype,"filterByFormula",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.fields.label",type:"json"}),bt({handle:"fields",userControlled:!0}),C("design:type",Array)],ss.prototype,"fields",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.sortField.label",type:"string"}),bt({handle:"sortField",userControlled:!0}),C("design:type",String)],ss.prototype,"sortField",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.sortDirection.label",type:"select"}),bt({handle:"sortDirection",userControlled:!0}),C("design:type",String)],ss.prototype,"sortDirection",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.maxRecords.label",type:"number"}),bt({handle:"maxRecords",userControlled:!0}),C("design:type",Number)],ss.prototype,"maxRecords",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.pageSize.label",type:"number"}),bt({handle:"pageSize",userControlled:!0}),C("design:type",Number)],ss.prototype,"pageSize",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.offset.label",type:"string"}),bt({handle:"offset",userControlled:!0}),C("design:type",String)],ss.prototype,"offset",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],ss.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],ss.prototype,"result",void 0),R([wt({handle:"records",type:"array"}),C("design:type",Array)],ss.prototype,"records",void 0),R([wt({handle:"offset",type:"string"}),C("design:type",String)],ss.prototype,"nextOffset",void 0),ss=R([yt("core.io.airtable",{kind:"core.io.airtable",category:"IO",color:"#fcb400",icon:"ti-table",width:96,height:96,labels:["io","airtable","database","records"],metadata:{title:"graph.node.io.airtable.name",description:"graph.node.io.airtable.description"}}),I()],ss);const ds=["parse","write"];let ls=class extends mi{constructor(){super(...arguments),this.spreadsheets=new ke,this.operation="parse"}async execute(e){const t=ds.includes(this.operation)?this.operation:"parse";try{if("parse"===t){const t=this.content??e.inputs.value;if("string"!=typeof t)throw new ar("Spreadsheet File parse requires text content","GRAPH_SPREADSHEET_CONTENT_REQUIRED");const o=this.spreadsheets.parse(t,{format:this.format,delimiter:this.delimiter,header:this.hasHeader});return{result:o,content:t,rows:o.rows,header:o.header}}const o=Array.isArray(this.rows)?this.rows:Array.isArray(e.inputs.value)?e.inputs.value:void 0;if(!o)throw new ar("Spreadsheet File write requires rows as an array of arrays","GRAPH_SPREADSHEET_ROWS_REQUIRED");const r=this.spreadsheets.serialize(o,{format:this.format,delimiter:this.delimiter,header:Oa(this.header)?.map(String)});return{result:r,content:r}}catch(e){if(e instanceof ar)throw e;throw new ar(`Spreadsheet File node operation '${t}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_SPREADSHEET_OPERATION_FAILED",{operation:t})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],ls.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.format.label",type:"select"}),bt({handle:"format",userControlled:!0}),C("design:type",String)],ls.prototype,"format",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.delimiter.label",type:"string"}),bt({handle:"delimiter",userControlled:!0}),C("design:type",String)],ls.prototype,"delimiter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.content.label",type:"textarea"}),bt({handle:"content",userControlled:!0}),C("design:type",String)],ls.prototype,"content",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.rows.label",type:"json"}),bt({handle:"rows",userControlled:!0}),C("design:type",Array)],ls.prototype,"rows",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.header.label",type:"json"}),bt({handle:"header",userControlled:!0}),C("design:type",Array)],ls.prototype,"header",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.hasHeader.label",type:"boolean"}),bt({handle:"hasHeader",userControlled:!0}),C("design:type",Boolean)],ls.prototype,"hasHeader",void 0),R([wt({handle:"result"}),C("design:type",Object)],ls.prototype,"result",void 0),R([wt({handle:"content",type:"string"}),C("design:type",String)],ls.prototype,"outputContent",void 0),R([wt({handle:"rows",type:"array"}),C("design:type",Array)],ls.prototype,"outputRows",void 0),R([wt({handle:"header",type:"array"}),C("design:type",Array)],ls.prototype,"outputHeader",void 0),ls=R([yt("core.io.spreadsheetFile",{kind:"core.io.spreadsheetFile",category:"IO",color:"#217346",icon:"ti-file-spreadsheet",width:96,height:96,labels:["io","spreadsheet","csv","tsv","json"],metadata:{title:"graph.node.io.spreadsheet_file.name",description:"graph.node.io.spreadsheet_file.description"}}),I()],ls);const cs=["query","mutation"];let ps=class extends mi{constructor(){super(...arguments),this.operation="query"}async execute(e,t){if(!this.operation)throw new ar("GraphQL node requires an operation","GRAPH_GRAPHQL_OPERATION_REQUIRED");const o=cs.includes(this.operation)?this.operation:"query",r=this.query??(e.inputs.value??"")+"";if(!r)throw new ar("GraphQL node requires a query document","GRAPH_GRAPHQL_QUERY_REQUIRED");const n=await jr(t,e.credentials,"graphql",!1,"GraphQL"),i=new Se;try{await me(i,{endpoint:this.endpoint??Sa(n,"endpoint","GraphQL"),token:Sa(n,"token","GraphQL")});const e=await i.request({query:r,variables:xa(this.variables),operationName:this.operationName});return e.errors&&e.errors.length>0?{result:e.data,errors:e.errors}:{result:e.data}}catch(e){if(e instanceof ar)throw e;throw new ar(`GraphQL node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GRAPHQL_OPERATION_FAILED",{operation:o})}finally{await i.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],ps.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.endpoint.label",type:"string"}),bt({handle:"endpoint",userControlled:!0}),C("design:type",String)],ps.prototype,"endpoint",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.query.label",type:"textarea"}),bt({handle:"query",userControlled:!0}),C("design:type",String)],ps.prototype,"query",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.variables.label",type:"json"}),bt({handle:"variables",userControlled:!0}),C("design:type",Object)],ps.prototype,"variables",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.operationName.label",type:"string"}),bt({handle:"operationName",userControlled:!0}),C("design:type",String)],ps.prototype,"operationName",void 0),R([wt({handle:"result"}),C("design:type",Object)],ps.prototype,"result",void 0),R([wt({handle:"errors",type:"array"}),C("design:type",Array)],ps.prototype,"errors",void 0),ps=R([yt("core.io.graphql",{kind:"core.io.graphql",category:"IO",color:"#e10098",icon:"ti-api",width:96,height:96,labels:["io","graphql","api","query"],metadata:{title:"graph.node.io.graphql.name",description:"graph.node.io.graphql.description"}}),I()],ps);const us=["getRepo","listIssues","createIssue","commentIssue","listPullRequests"];let hs=class extends mi{constructor(){super(...arguments),this.operation="getRepo"}async execute(e,t){if(!this.operation)throw new ar("GitHub node requires an operation","GRAPH_GITHUB_OPERATION_REQUIRED");const o=us.includes(this.operation)?this.operation:"getRepo",r=await jr(t,e.credentials,"github",!1,"GitHub"),n=new Re;try{switch(await me(n,{token:Ra(r,"GitHub"),owner:this.owner,repo:this.repo,baseUrl:this.baseUrl}),o){case"getRepo":return{result:await n.getRepository({owner:this.owner,repo:this.repo})};case"listIssues":return{result:await n.listIssues({owner:this.owner,repo:this.repo,state:this.state,limit:_a(this.limit),page:_a(this.page),labels:this.labels?.join(",")})};case"createIssue":{if(!this.title)throw new ar("GitHub createIssue requires a title","GRAPH_GITHUB_TITLE_REQUIRED");const t=await n.createIssue({owner:this.owner,repo:this.repo,title:this.title,body:this.body??(e.inputs.value??"")+"",labels:Oa(this.labels)?.map(String),assignees:Oa(this.assignees)?.map(String)});return{result:t,number:t.number,url:t.htmlUrl}}case"commentIssue":{const e=_a(this.number);if(!e||!this.body)throw new ar("GitHub commentIssue requires an issue number and body","GRAPH_GITHUB_COMMENT_REQUIRED");const t=await n.commentOnIssue({owner:this.owner,repo:this.repo,number:e,body:this.body});return{result:t,number:e,url:t.htmlUrl}}default:return{result:await n.listPullRequests({owner:this.owner,repo:this.repo,state:this.state,limit:_a(this.limit),page:_a(this.page)})}}}catch(e){if(e instanceof ar)throw e;throw new ar(`GitHub node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GITHUB_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],hs.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.owner.label",type:"string"}),bt({handle:"owner",userControlled:!0}),C("design:type",String)],hs.prototype,"owner",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.repo.label",type:"string"}),bt({handle:"repo",userControlled:!0}),C("design:type",String)],hs.prototype,"repo",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.number.label",type:"number"}),bt({handle:"number",userControlled:!0}),C("design:type",Number)],hs.prototype,"number",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.title.label",type:"string"}),bt({handle:"title",userControlled:!0}),C("design:type",String)],hs.prototype,"title",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.body.label",type:"textarea"}),bt({handle:"body",userControlled:!0}),C("design:type",String)],hs.prototype,"body",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.labels.label",type:"json"}),bt({handle:"labels",userControlled:!0}),C("design:type",Array)],hs.prototype,"labels",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.assignees.label",type:"json"}),bt({handle:"assignees",userControlled:!0}),C("design:type",Array)],hs.prototype,"assignees",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.state.label",type:"select"}),bt({handle:"state",userControlled:!0}),C("design:type",String)],hs.prototype,"state",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],hs.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.page.label",type:"number"}),bt({handle:"page",userControlled:!0}),C("design:type",Number)],hs.prototype,"page",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],hs.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],hs.prototype,"result",void 0),R([wt({handle:"number",type:"number"}),C("design:type",Number)],hs.prototype,"issueNumber",void 0),R([wt({handle:"url",type:"string"}),C("design:type",String)],hs.prototype,"url",void 0),hs=R([yt("core.devops.github",{kind:"core.devops.github",category:"DevOps",color:"#24292f",icon:"ti-brand-github",width:96,height:96,labels:["devops","github","git","issues"],metadata:{title:"graph.node.devops.github.name",description:"graph.node.devops.github.description"}}),I()],hs);const gs=["getProject","listIssues","createIssue","commentIssue","listMergeRequests"];let fs=class extends mi{constructor(){super(...arguments),this.operation="getProject"}async execute(e,t){if(!this.operation)throw new ar("GitLab node requires an operation","GRAPH_GITLAB_OPERATION_REQUIRED");const o=gs.includes(this.operation)?this.operation:"getProject",r=await jr(t,e.credentials,"gitlab",!1,"GitLab"),n=new Ce;try{switch(await me(n,{token:Ra(r,"GitLab"),projectId:this.projectId,baseUrl:this.baseUrl}),o){case"getProject":return{result:await n.getProject(this.projectId)};case"listIssues":return{result:await n.listIssues({projectId:this.projectId,state:this.state,limit:_a(this.limit),page:_a(this.page),labels:Oa(this.labels)?.map(String).join(","),search:this.search})};case"createIssue":{if(!this.title)throw new ar("GitLab createIssue requires a title","GRAPH_GITLAB_TITLE_REQUIRED");const t=await n.createIssue({projectId:this.projectId,title:this.title,description:this.body??(e.inputs.value??"")+"",labels:Oa(this.labels)?.map(String).join(","),assigneeIds:Oa(this.assigneeIds)?.map(Number)});return{result:t,iid:t.iid,url:t.webUrl}}case"commentIssue":{const e=_a(this.iid);if(!e||!this.body)throw new ar("GitLab commentIssue requires an issue IID and body","GRAPH_GITLAB_COMMENT_REQUIRED");const t=await n.commentOnIssue({projectId:this.projectId,iid:e,body:this.body});return{result:t,iid:e,url:t.webUrl}}default:return{result:await n.listMergeRequests({projectId:this.projectId,state:this.state,limit:_a(this.limit),page:_a(this.page),search:this.search})}}}catch(e){if(e instanceof ar)throw e;throw new ar(`GitLab node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GITLAB_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],fs.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.projectId.label",type:"string"}),bt({handle:"projectId",userControlled:!0}),C("design:type",String)],fs.prototype,"projectId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.iid.label",type:"number"}),bt({handle:"iid",userControlled:!0}),C("design:type",Number)],fs.prototype,"iid",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.title.label",type:"string"}),bt({handle:"title",userControlled:!0}),C("design:type",String)],fs.prototype,"title",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.body.label",type:"textarea"}),bt({handle:"body",userControlled:!0}),C("design:type",String)],fs.prototype,"body",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.labels.label",type:"json"}),bt({handle:"labels",userControlled:!0}),C("design:type",Array)],fs.prototype,"labels",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.assigneeIds.label",type:"json"}),bt({handle:"assigneeIds",userControlled:!0}),C("design:type",Array)],fs.prototype,"assigneeIds",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.state.label",type:"select"}),bt({handle:"state",userControlled:!0}),C("design:type",String)],fs.prototype,"state",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.search.label",type:"string"}),bt({handle:"search",userControlled:!0}),C("design:type",String)],fs.prototype,"search",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.limit.label",type:"number"}),bt({handle:"limit",userControlled:!0}),C("design:type",Number)],fs.prototype,"limit",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.page.label",type:"number"}),bt({handle:"page",userControlled:!0}),C("design:type",Number)],fs.prototype,"page",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.baseUrl.label",type:"string"}),bt({handle:"baseUrl",userControlled:!0}),C("design:type",String)],fs.prototype,"baseUrl",void 0),R([wt({handle:"result"}),C("design:type",Object)],fs.prototype,"result",void 0),R([wt({handle:"iid",type:"number"}),C("design:type",Number)],fs.prototype,"issueIid",void 0),R([wt({handle:"url",type:"string"}),C("design:type",String)],fs.prototype,"url",void 0),fs=R([yt("core.devops.gitlab",{kind:"core.devops.gitlab",category:"DevOps",color:"#fc6d26",icon:"ti-brand-gitlab",width:96,height:96,labels:["devops","gitlab","git","issues"],metadata:{title:"graph.node.devops.gitlab.name",description:"graph.node.devops.gitlab.description"}}),I()],fs);const ys={MD5:"md5",SHA1:"sha1",SHA256:"sha256",SHA384:"sha384",SHA512:"sha512","SHA3-256":"sha3-256","SHA3-384":"sha3-384","SHA3-512":"sha3-512"},ms=["hash","hmac","encrypt","decrypt","sign","verify","generate"];let bs=class extends mi{constructor(){super(...arguments),this.operation="hash",this.algorithm="SHA256",this.encoding="hex",this.keyType="rsa"}async execute(e,t){const o="Crypto",r=async r=>{const n=Ca(await jr(t,e.credentials,"crypto",!0,o),r,o);if(!n)throw new ar(o+" node credential must contain the required key material","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:o});return n},n=ms.includes(this.operation)?this.operation:"hash",i=ys[this.algorithm]??ys.SHA256,a="base64"===this.encoding?"base64":"hex",s=()=>((e,t)=>{if("string"==typeof e)return e;if(null==e)throw new ar(t+" node requires a payload","GRAPH_CRYPTO_PAYLOAD_REQUIRED");try{return JSON.stringify(e)}catch{throw new ar(t+" node cannot serialize the payload","GRAPH_CRYPTO_INVALID_PAYLOAD")}})(this.payload??e.inputs.value,o),d=new Ne;await d.boot();const l=d.client;try{switch(n){case"hash":return{result:l.createHash(i).update(s()).digest(a)};case"hmac":{const e=await r(["secret","key","password","token"]);return{result:l.createHmac(i,e).update(s()).digest(a)}}case"encrypt":{const e=await r(["secret","key","password","token"]);return{result:await d.encrypt(s(),e),encodings:["base64"]}}case"decrypt":{const e=await r(["secret","key","password","token"]),t=Ia(this.encryptedData);if(!t)throw new ar("Crypto node decrypt requires encryptedData","GRAPH_CRYPTO_ENCRYPTED_DATA_REQUIRED");const o=Ia(this.salt);if(!o)throw new ar("Crypto node decrypt requires the encryption salt","GRAPH_CRYPTO_SALT_REQUIRED");return{result:await d.decrypt(t,e,o)}}case"sign":{const e=await r(["privateKey","key","secret","token"]);return{result:l.createSign(i).update(s()).sign(e,a)}}case"verify":{const e=Ia(this.publicKey)??await r(["publicKey","key","secret","token"]),t=Ia(this.signature);if(!t)throw new ar("Crypto node verify requires a signature","GRAPH_CRYPTO_SIGNATURE_REQUIRED");return{result:l.createVerify(i).update(s()).verify(e,t,a)}}case"generate":{const e=this.keyType??"rsa";return"ed25519"===e?{result:l.generateKeyPairSync("ed25519",{publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}})}:"ec"===e?{result:l.generateKeyPairSync("ec",{namedCurve:Ia(this.namedCurve)??"prime256v1",publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}})}:{result:l.generateKeyPairSync("rsa",{modulusLength:Math.max(2048,Math.floor(this.modulusLength??2048)),publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}})}}default:throw new ar(`Crypto node operation '${n}' is not supported`,"GRAPH_CRYPTO_OPERATION_NOT_SUPPORTED",{operation:n})}}catch(e){if(e instanceof ar)throw e;throw new ar(`Crypto node operation '${n}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_CRYPTO_OPERATION_FAILED",{operation:n})}finally{await d.shutdown().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],bs.prototype,"operation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.algorithm.label",type:"select"}),bt({handle:"algorithm",userControlled:!0}),C("design:type",String)],bs.prototype,"algorithm",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.encoding.label",type:"select"}),bt({handle:"encoding",userControlled:!0}),C("design:type",String)],bs.prototype,"encoding",void 0),R([bt({handle:"value"}),C("design:type",Object)],bs.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.payload.label",type:"textarea"}),bt({handle:"payload",userControlled:!0}),C("design:type",Object)],bs.prototype,"payload",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.encryptedData.label",type:"textarea"}),bt({handle:"encryptedData",userControlled:!0}),C("design:type",String)],bs.prototype,"encryptedData",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.salt.label",type:"string"}),bt({handle:"salt",userControlled:!0}),C("design:type",String)],bs.prototype,"salt",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.publicKey.label",type:"textarea"}),bt({handle:"publicKey",userControlled:!0}),C("design:type",String)],bs.prototype,"publicKey",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.signature.label",type:"textarea"}),bt({handle:"signature",userControlled:!0}),C("design:type",String)],bs.prototype,"signature",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.keyType.label",type:"select"}),bt({handle:"keyType",userControlled:!0}),C("design:type",String)],bs.prototype,"keyType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.modulusLength.label",type:"number"}),bt({handle:"modulusLength",userControlled:!0}),C("design:type",Number)],bs.prototype,"modulusLength",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.namedCurve.label",type:"string"}),bt({handle:"namedCurve",userControlled:!0}),C("design:type",String)],bs.prototype,"namedCurve",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],bs.prototype,"result",void 0),R([wt({handle:"encodings",type:"array"}),C("design:type",Array)],bs.prototype,"encodings",void 0),bs=R([yt("core.devops.crypto",{kind:"core.devops.crypto",category:"DevOps",color:"#7c3aed",icon:"ti-lock",width:96,height:96,labels:["devops","crypto","hash","encrypt","sign"],metadata:{title:"graph.node.devops.crypto.name",description:"graph.node.devops.crypto.description"}}),I()],bs);const ws=["sign","verify","decode"];let vs=class extends mi{constructor(){super(...arguments),this.operation="decode"}async execute(e,t){const o=ws.includes(this.operation)?this.operation:"decode",r=Ia(this.token)??Ia(e.inputs.value);if("sign"!==o&&!r)throw new ar(`JWT node operation '${o}' requires a token`,"GRAPH_JWT_TOKEN_REQUIRED",{operation:o});try{if("sign"===o){const o=await jr(t,e.credentials,"jwt",!0,"JWT"),r=(e=>{if("string"==typeof e&&e.trim().startsWith("{"))try{return xa(JSON.parse(e))??{}}catch{throw new ar("JWT node claims must be a JSON object","GRAPH_JWT_INVALID_CLAIMS")}const t=xa(e);if(!t)throw new ar("JWT node sign operation requires claims","GRAPH_JWT_CLAIMS_REQUIRED");return t})(this.claims??e.inputs.value),n={secret:o,expiry:Ia(this.expiry)??"1h"},i=await Te(r,n);return{result:i,token:i}}if("verify"===o){const o=await jr(t,e.credentials,"jwt",!1,"JWT"),n=Ia(this.verifyUrl);if(!o&&!n)throw new ar("JWT node verify requires a secret credential or verifyUrl","GRAPH_JWT_VERIFICATION_NOT_CONFIGURED");const i=await De(r,{secret:"string"==typeof o?o:Ia(o?.secret),verifyUrl:n,clockToleranceSeconds:_a(this.clockToleranceSeconds)});return{result:i,payload:i}}const n=Pe(r);return{result:n??null,payload:n??null}}catch(e){if(e instanceof ar)throw e;throw new ar(`JWT node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_JWT_OPERATION_FAILED",{operation:o})}}};function xs(e,t="utf8"){const o=Buffer.isBuffer(e)?e:Buffer.from(e??"",t);return o.length>Jo?{value:o.subarray(0,Jo).toString(t),truncated:!0}:{value:o.toString(t),truncated:!1}}R([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],vs.prototype,"operation",void 0),R([bt({handle:"value"}),C("design:type",Object)],vs.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.token.label",type:"textarea"}),bt({handle:"token",userControlled:!0}),C("design:type",String)],vs.prototype,"token",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.claims.label",type:"object"}),bt({handle:"claims",userControlled:!0}),C("design:type",Object)],vs.prototype,"claims",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.expiry.label",type:"string"}),bt({handle:"expiry",userControlled:!0}),C("design:type",String)],vs.prototype,"expiry",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.verifyUrl.label",type:"string"}),bt({handle:"verifyUrl",userControlled:!0}),C("design:type",String)],vs.prototype,"verifyUrl",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.clockToleranceSeconds.label",type:"number"}),bt({handle:"clockToleranceSeconds",userControlled:!0}),C("design:type",Number)],vs.prototype,"clockToleranceSeconds",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],vs.prototype,"result",void 0),R([wt({handle:"token"}),C("design:type",String)],vs.prototype,"tokenOutput",void 0),R([wt({handle:"payload"}),C("design:type",Object)],vs.prototype,"payload",void 0),vs=R([yt("core.devops.jwt",{kind:"core.devops.jwt",category:"DevOps",color:"#0f766e",icon:"ti-key",width:96,height:96,labels:["devops","jwt","token","auth"],metadata:{title:"graph.node.devops.jwt.name",description:"graph.node.devops.jwt.description"}}),I()],vs);let Is=class extends mi{constructor(){super(...arguments),this.failOnError=!1}async execute(e,t){const o=Ia(this.command);if(!o)throw new ar("Execute Command node requires a command","GRAPH_EXECUTE_COMMAND_REQUIRED");const r=Math.min(6e4,Math.max(1,Math.floor(_a(this.timeoutMs)??3e4))),n=await new Promise(e=>{je(o,{timeout:r,maxBuffer:Jo,cwd:Ia(this.cwd),shell:Ia(this.shell),signal:t.abortSignal,windowsHide:!0},(t,o,r)=>{const n=xs(o),i=xs(r),a=t?.code;e({stdout:n.value,stderr:i.value,exitCode:"number"==typeof a?a:t?null:0,error:t??void 0,truncated:n.truncated||i.truncated})})});if(n.error&&this.failOnError)throw new ar("Execute Command node command failed: "+n.error.message,"GRAPH_EXECUTE_COMMAND_FAILED",{exitCode:n.exitCode});return{result:{stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode,truncated:n.truncated},stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.command.label",type:"textarea"}),bt({handle:"command",userControlled:!0}),C("design:type",String)],Is.prototype,"command",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.cwd.label",type:"string"}),bt({handle:"cwd",userControlled:!0}),C("design:type",String)],Is.prototype,"cwd",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.shell.label",type:"string"}),bt({handle:"shell",userControlled:!0}),C("design:type",String)],Is.prototype,"shell",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.timeoutMs.label",type:"number"}),bt({handle:"timeoutMs",userControlled:!0}),C("design:type",Number)],Is.prototype,"timeoutMs",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.failOnError.label",type:"boolean"}),bt({handle:"failOnError",userControlled:!0}),C("design:type",Boolean)],Is.prototype,"failOnError",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Is.prototype,"result",void 0),R([wt({handle:"stdout"}),C("design:type",String)],Is.prototype,"stdout",void 0),R([wt({handle:"stderr"}),C("design:type",String)],Is.prototype,"stderr",void 0),R([wt({handle:"exitCode",type:"number"}),C("design:type",Object)],Is.prototype,"exitCode",void 0),Is=R([yt("core.devops.executeCommand",{kind:"core.devops.executeCommand",category:"DevOps",color:"#334155",icon:"ti-terminal-2",width:96,height:96,labels:["devops","shell","command","process"],metadata:{title:"graph.node.devops.execute_command.name",description:"graph.node.devops.execute_command.description"}}),I()],Is);const As=["list","download","delete"];function _s(e){if(!e)return{};if("string"!=typeof e)return{password:Ia(e.password),privateKey:Ia(e.privateKey),passphrase:Ia(e.passphrase)};if(!e.trim().startsWith("{"))return{password:e};const t=Ea(e,"FTP");return{password:Ia(t.password),privateKey:Ia(t.privateKey),passphrase:Ia(t.passphrase)}}let Os=class extends mi{constructor(){super(...arguments),this.operation="list",this.encoding="utf8"}async execute(e,t){const o=Ia(this.host),r=Ia(this.username);if(!o||!r)throw new ar("FTP node requires host and username","GRAPH_FTP_CONNECTION_REQUIRED");const n=As.includes(this.operation)?this.operation:"list",i=Ia(this.path);if("list"!==n&&!i)throw new ar(`FTP node operation '${n}' requires a path`,"GRAPH_FTP_PATH_REQUIRED",{operation:n});const a=await jr(t,e.credentials,"sftp",!1,"FTP"),s={provider:"ssh2",sourceId:Ia(this.sourceId)??"graph",host:o,port:_a(this.port)??22,username:r,remotePath:Ia(this.remotePath),..._s(a)},d=new $e;try{if(await d.initialize(s),"list"===n)return{result:await d.list(i)};if("delete"===n)return await d.delete(i),{result:{path:i,deleted:!0}};const e=await d.fetch(i);return{result:{path:e.path,name:e.name,size:e.size},content:"base64"===this.encoding?e.content.toString("base64"):e.content.toString("utf8"),size:e.size}}catch(e){if(e instanceof ar)throw e;throw new ar(`FTP node operation '${n}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_FTP_OPERATION_FAILED",{operation:n})}finally{await d.close().catch(()=>{})}}};R([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.operation.label",type:"select"}),bt({handle:"operation",userControlled:!0}),C("design:type",String)],Os.prototype,"operation",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.host.label",type:"string"}),bt({handle:"host",userControlled:!0}),C("design:type",String)],Os.prototype,"host",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.port.label",type:"number"}),bt({handle:"port",userControlled:!0}),C("design:type",Number)],Os.prototype,"port",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.username.label",type:"string"}),bt({handle:"username",userControlled:!0}),C("design:type",String)],Os.prototype,"username",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.sourceId.label",type:"string"}),bt({handle:"sourceId",userControlled:!0}),C("design:type",String)],Os.prototype,"sourceId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.remotePath.label",type:"string"}),bt({handle:"remotePath",userControlled:!0}),C("design:type",String)],Os.prototype,"remotePath",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.path.label",type:"string"}),bt({handle:"path",userControlled:!0}),C("design:type",String)],Os.prototype,"path",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.encoding.label",type:"select"}),bt({handle:"encoding",userControlled:!0}),C("design:type",String)],Os.prototype,"encoding",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Os.prototype,"result",void 0),R([wt({handle:"content"}),C("design:type",String)],Os.prototype,"content",void 0),R([wt({handle:"size",type:"number"}),C("design:type",Number)],Os.prototype,"size",void 0),Os=R([yt("core.devops.ftp",{kind:"core.devops.ftp",category:"DevOps",color:"#0ea5e9",icon:"ti-folder-symlink",width:96,height:96,labels:["devops","ftp","sftp","files"],metadata:{title:"graph.node.devops.ftp.name",description:"graph.node.devops.ftp.description"}}),I()],Os);let Es=class extends mi{constructor(){super(...arguments),this.mode="once",this.inputPort="value"}async execute(e,t){const o=t.engine;if(!o)throw new ar("Execute Sub-workflow node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");const r=await this.documentOf(o,t),n=this.inputPort||"value",i=e.inputs.value??e.inputs.input;if("perItem"===this.mode){const e=[];let a,s;for(const d of Mi(i)){const i=await o.execute(r,{[n]:d},{parentRunId:t.runId,path:[...t.path,"subworkflow"],auth:t.auth,metadata:{...t.metadata,item:d}},t);e.push(i.outputs.result??i.outputs),a=i.outputs,s=i.runId}return{result:e,outputs:a,childRunId:s}}const a=await o.execute(r,{[n]:i},{parentRunId:t.runId,path:[...t.path,"subworkflow"],auth:t.auth,metadata:t.metadata},t);return{result:a.outputs.result??a.outputs,outputs:a.outputs,childRunId:a.runId}}async documentOf(e,t){if(Li(o=this.workflow)&&"string"==typeof o.id&&Array.isArray(o.nodes)&&Array.isArray(o.edges))return this.workflow;var o;const r=this.workflowId;if(!r)throw new ar("Execute Sub-workflow node requires a workflow id or an inline workflow document","GRAPH_SUB_WORKFLOW_REQUIRED");try{return await e.getWorkflow(r,t)}catch(e){throw new ar(`Execute Sub-workflow node could not resolve workflow '${r}': ${e instanceof Error?e.message:e+""}`,"GRAPH_SUB_WORKFLOW_NOT_FOUND",{workflowId:r})}}};R([bt({handle:"value"}),C("design:type",Object)],Es.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.workflowId.label",placeholder:"graph.node.flow_control.execute_sub_workflow.fields.workflowId.placeholder",type:"text"}),bt({handle:"workflowId",userControlled:!0}),C("design:type",String)],Es.prototype,"workflowId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.workflow.label",type:"json"}),bt({handle:"workflow",userControlled:!0,type:"object"}),C("design:type",Object)],Es.prototype,"workflow",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.mode.label",type:"select"}),bt({handle:"mode",userControlled:!0}),C("design:type",String)],Es.prototype,"mode",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.inputPort.label",placeholder:"graph.node.flow_control.execute_sub_workflow.fields.inputPort.placeholder",type:"text"}),bt({handle:"inputPort",userControlled:!0}),C("design:type",String)],Es.prototype,"inputPort",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],Es.prototype,"result",void 0),R([wt({handle:"outputs"}),C("design:type",Object)],Es.prototype,"outputs",void 0),R([wt({handle:"childRunId"}),C("design:type",String)],Es.prototype,"childRunId",void 0),Es=R([yt("core.flow.executeSubWorkflow",{kind:"core.flow.executeSubWorkflow",category:"Flow Control",color:"#f59e0b",icon:"ti-subtask",width:96,height:96,labels:["flow","workflow","subworkflow"],metadata:{title:"graph.node.flow_control.execute_sub_workflow.name",description:"graph.node.flow_control.execute_sub_workflow.description"}}),I()],Es);let ks=class extends mi{execute(e){const t=e.inputs.payload;return{result:void 0!==t?t:e.inputs.value??e.inputs}}};R([bt({handle:"payload"}),C("design:type",Object)],ks.prototype,"payload",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.trigger.execute_workflow.fields.schema.label",placeholder:"graph.node.trigger.execute_workflow.fields.schema.placeholder",type:"json"}),bt({handle:"schema",userControlled:!0,type:"object"}),C("design:type",Object)],ks.prototype,"schema",void 0),R([w(),wt({handle:"result"}),C("design:type",Object)],ks.prototype,"result",void 0),ks=R([yt("core.trigger.executeWorkflow",{kind:"core.trigger.executeWorkflow",category:"Trigger",color:"#3b82f6",icon:"ti-player-play",width:96,height:96,labels:["trigger","workflow","subworkflow"],metadata:{title:"graph.node.trigger.execute_workflow.name",description:"graph.node.trigger.execute_workflow.description",trigger:{type:"executeWorkflow"}}}),I()],ks);let Ss=class extends mi{execute(e){return{message:e.inputs.message??null,sessionId:e.inputs.sessionId??null,userId:e.inputs.userId??null}}};R([w(),wt({handle:"message"}),C("design:type",String)],Ss.prototype,"message",void 0),R([w(),wt({handle:"sessionId"}),C("design:type",String)],Ss.prototype,"sessionId",void 0),R([w(),wt({handle:"userId"}),C("design:type",String)],Ss.prototype,"userId",void 0),Ss=R([yt("core.trigger.chat",{kind:"core.trigger.chat",category:"Trigger",color:"#3b82f6",icon:"ti-message-circle",width:96,height:96,labels:["trigger","chat","entrypoint"],metadata:{title:"graph.node.trigger.chat.name",description:"graph.node.trigger.chat.description",trigger:{type:"chat"}}}),I()],Ss);let Rs=class extends mi{execute(e){return{payload:e.inputs.payload??null}}};R([w(),wt({handle:"payload"}),C("design:type",Object)],Rs.prototype,"payload",void 0),Rs=R([yt("core.trigger.event",{kind:"core.trigger.event",category:"Trigger",color:"#3b82f6",icon:"ti-broadcast",width:96,height:96,labels:["trigger","event","bus"],metadata:{title:"graph.node.trigger.event.name",description:"graph.node.trigger.event.description",trigger:{type:"event",topic:"default"}}}),I()],Rs);let Cs=class extends mi{execute(e){return{payload:e.inputs.payload??null}}};R([w(),bt({handle:"schema"}),i("ngx-decaf-model-builder",{label:"graph.node.trigger.form.fields.schema.label",placeholder:"graph.node.trigger.form.fields.schema.placeholder"}),C("design:type",Object)],Cs.prototype,"schema",void 0),R([w(),wt({handle:"payload"}),C("design:type",Object)],Cs.prototype,"payload",void 0),Cs=R([yt("core.trigger.form",{kind:"core.trigger.form",category:"Trigger",color:"#3b82f6",icon:"ti-forms",width:96,height:96,labels:["trigger","form","public"],metadata:{title:"graph.node.trigger.form.name",description:"graph.node.trigger.form.description",trigger:{type:"form",fields:[]}}}),I()],Cs);let Ns=class extends mi{execute(e){return{payload:e.inputs.payload??null}}};R([w(),wt({handle:"payload"}),C("design:type",Object)],Ns.prototype,"payload",void 0),Ns=R([yt("core.trigger.manual",{kind:"core.trigger.manual",category:"Trigger",color:"#3b82f6",icon:"ti-hand-click",width:96,height:96,labels:["trigger","manual","entrypoint"],metadata:{title:"graph.node.trigger.manual.name",description:"graph.node.trigger.manual.description",trigger:{type:"manual",inputSchema:{}}}}),I()],Ns);let Ts=class extends mi{execute(e){return{payload:e.inputs.payload??null}}};R([w(),bt({handle:"cron"}),i("app-cron-selector-field",{label:"graph.node.trigger.schedule.fields.cron.label",placeholder:"graph.node.trigger.schedule.fields.cron.placeholder"}),C("design:type",String)],Ts.prototype,"cron",void 0),R([w(),wt({handle:"payload"}),C("design:type",Object)],Ts.prototype,"payload",void 0),Ts=R([yt("core.trigger.schedule",{kind:"core.trigger.schedule",category:"Trigger",color:"#3b82f6",icon:"ti-calendar-time",width:96,height:96,labels:["trigger","schedule","cron"],metadata:{title:"graph.node.trigger.schedule.name",description:"graph.node.trigger.schedule.description",trigger:{type:"schedule",schedule:"0 * * * *",timezone:"UTC"}}}),I()],Ts);let Ds=class extends mi{execute(e){return{payload:e.inputs.payload??null}}};R([w(),bt({handle:"schema"}),i("ngx-decaf-model-builder",{label:"graph.node.trigger.webhook.fields.schema.label",placeholder:"graph.node.trigger.webhook.fields.schema.placeholder"}),C("design:type",Object)],Ds.prototype,"schema",void 0),R([w(),wt({handle:"payload"}),C("design:type",Object)],Ds.prototype,"payload",void 0),Ds=R([yt("core.trigger.webhook",{kind:"core.trigger.webhook",category:"Trigger",color:"#3b82f6",icon:"ti-webhook",width:96,height:96,labels:["trigger","webhook","http"],metadata:{title:"graph.node.trigger.webhook.name",description:"graph.node.trigger.webhook.description",trigger:{type:"webhook",path:"/webhook",method:"POST",auth:"none",responseMode:"onReceived"}}}),I()],Ds);const Ps={memory:"memory",scorers:"scorers",embedding:"embedding",hooks:"hooks",sandbox:"sandbox",tools:"tools",skill:"skill",inputProcessors:"inputProcessors",outputProcessors:"outputProcessors"},js=["memory","scorers","embedding","hooks","sandbox","tools","skill","inputProcessors","outputProcessors"];let $s=class extends mi{execute(e){throw new ar("Node kind 'core.agent' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent",backend:"local"})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.prompt.label",placeholder:"graph.node.agent.agent.fields.prompt.placeholder",type:"textarea"}),bt({handle:"prompt"}),C("design:type",String)],$s.prototype,"prompt",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.name.label",placeholder:"graph.node.agent.agent.fields.name.placeholder",type:"text"}),bt({handle:"name",userControlled:!0}),C("design:type",String)],$s.prototype,"name",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.description.label",type:"textarea"}),bt({handle:"description",userControlled:!0}),C("design:type",String)],$s.prototype,"description",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.instructions.label",placeholder:"graph.node.agent.agent.fields.instructions.placeholder",type:"textarea"}),bt({handle:"instructions",userControlled:!0}),C("design:type",String)],$s.prototype,"instructions",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.skillsFormat.label",type:"select"}),bt({handle:"skillsFormat",userControlled:!0}),C("design:type",String)],$s.prototype,"skillsFormat",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.maxRetries.label",type:"number"}),bt({handle:"maxRetries",userControlled:!0}),C("design:type",Number)],$s.prototype,"maxRetries",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],$s.prototype,"modelAdapter",void 0),R([i("ngx-decaf-model-builder",{label:"graph.node.agent.agent.fields.structuredOutput.label"}),bt({handle:"structuredOutput",userControlled:!0,type:"object"}),C("design:type",Object)],$s.prototype,"structuredOutput",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.agentOptions.label",type:"object"}),bt({handle:"agentOptions",userControlled:!0,type:"object"}),C("design:type",Object)],$s.prototype,"agentOptions",void 0),R([w(),wt({handle:"response"}),C("design:type",String)],$s.prototype,"response",void 0),R([w(),wt({handle:"actions"}),C("design:type",Array)],$s.prototype,"actions",void 0),R([vt({category:"memory",handle:"memory",zone:{side:"bottom",align:"start",order:0}}),C("design:type",Object)],$s.prototype,"memory",void 0),R([vt({category:"scorers",handle:"scorers",zone:{side:"top",align:"end",order:0}}),C("design:type",Object)],$s.prototype,"scorers",void 0),R([vt({category:"embedding",handle:"embedding",zone:{side:"bottom",align:"end",order:0}}),C("design:type",Object)],$s.prototype,"embedding",void 0),R([vt({category:"hooks",handle:"hooks",zone:{side:"top",align:"center",order:0}}),C("design:type",Object)],$s.prototype,"hooks",void 0),R([vt({category:"sandbox",handle:"sandbox",zone:{side:"top",align:"center",order:1}}),C("design:type",Object)],$s.prototype,"sandbox",void 0),R([vt({category:"tools",handle:"tools",zone:{side:"bottom",align:"center",order:0}}),C("design:type",Object)],$s.prototype,"tools",void 0),R([vt({category:"skill",handle:"skill",zone:{side:"bottom",align:"center",order:1}}),C("design:type",Object)],$s.prototype,"skill",void 0),R([vt({category:"inputProcessors",handle:"inputProcessors",zone:{side:"top",align:"center",order:2}}),C("design:type",Object)],$s.prototype,"inputProcessors",void 0),R([vt({category:"outputProcessors",handle:"outputProcessors",zone:{side:"bottom",align:"center",order:2}}),C("design:type",Object)],$s.prototype,"outputProcessors",void 0),R([vt({category:"model",handle:"model",zone:{side:"bottom",align:"start",order:1}}),C("design:type",Object)],$s.prototype,"model",void 0),R([vt({category:"workspace",handle:"workspace",zone:{side:"bottom",align:"start",order:2}}),C("design:type",Object)],$s.prototype,"workspace",void 0),$s=R([yt("core.agent",{kind:"core.agent",category:"Agent",width:168,height:132,labels:["agent","ai","orchestrator"],metadata:{title:"graph.node.agent.agent.name",description:"graph.node.agent.agent.description",shape:"rectangle"}}),I()],$s);const Ls=[$s];let Ms=class extends mi{execute(e){return{resource:{type:"mastra.tool",toolId:this.toolId,description:this.description,input:e.inputs}}}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool.fields.toolId.label",placeholder:"graph.node.agent.tool.fields.toolId.placeholder",type:"text"}),bt({handle:"toolId",userControlled:!0}),C("design:type",String)],Ms.prototype,"toolId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool.fields.description.label",type:"textarea"}),bt({handle:"description",userControlled:!0}),C("design:type",String)],Ms.prototype,"description",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Ms.prototype,"resource",void 0),R([vt({category:"tools",handle:"tool"}),C("design:type",Object)],Ms.prototype,"tool",void 0),Ms=R([yt("core.agent.tool",{kind:"core.agent.tool",category:"Agent",width:128,height:112,labels:["agent","ai","tool"],metadata:{title:"graph.node.agent.tool.name",description:"graph.node.agent.tool.description",shape:"rectangle"}}),I()],Ms);const Gs=[Ms];let Us=class extends mi{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.tools??[],r="string"==typeof t?t:o.length?o[0]:void 0;return{selected:r,resource:r?{type:"mastra.tool",toolId:r}:null}}};R([bt({handle:"decision"}),C("design:type",Object)],Us.prototype,"decision",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool_selector.fields.tools.label",type:"text"}),bt({handle:"tools",userControlled:!0}),C("design:type",Array)],Us.prototype,"tools",void 0),R([wt({handle:"selected"}),C("design:type",Object)],Us.prototype,"selectedOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Us.prototype,"resource",void 0),R([vt({category:"tools",handle:"tool"}),C("design:type",Object)],Us.prototype,"tool",void 0),Us=R([yt("core.agent.toolSelector",{kind:"core.agent.toolSelector",category:"Agent",width:128,height:112,labels:["agent","ai","tool","selector"],metadata:{title:"graph.node.agent.tool_selector.name",description:"graph.node.agent.tool_selector.description",shape:"rectangle"}}),I()],Us);const Fs=[Us];let Bs=class extends mi{execute(e){const t=e.inputs??{};return{toolName:t.toolName??this.toolName,input:t.input,output:t.output,error:t.error,value:t.value??t}}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.hook.fields.phase.label",type:"select"}),bt({handle:"phase",userControlled:!0}),C("design:type",String)],Bs.prototype,"phase",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.hook.fields.toolName.label",type:"text"}),bt({handle:"toolName",userControlled:!0}),C("design:type",String)],Bs.prototype,"toolName",void 0),R([w(),bt({handle:"value"}),C("design:type",Object)],Bs.prototype,"value",void 0),R([w(),wt({handle:"toolName"}),C("design:type",Object)],Bs.prototype,"toolNameOut",void 0),R([wt({handle:"input"}),C("design:type",Object)],Bs.prototype,"inputOut",void 0),R([wt({handle:"output"}),C("design:type",Object)],Bs.prototype,"outputOut",void 0),R([wt({handle:"error"}),C("design:type",Object)],Bs.prototype,"errorOut",void 0),R([wt({handle:"value"}),C("design:type",Object)],Bs.prototype,"valueOut",void 0),R([vt({category:"hooks",handle:"hook"}),C("design:type",Object)],Bs.prototype,"hook",void 0),Bs=R([yt("core.agent.hook",{kind:"core.agent.hook",category:"Agent",width:128,height:112,labels:["agent","ai","hook"],metadata:{title:"graph.node.agent.hook.name",description:"graph.node.agent.hook.description",shape:"rectangle"}}),I()],Bs);const Hs=[Bs];let qs=class extends mi{execute(e){const t=e.inputs.value;return{proceed:!1,denied:!0,reason:this.reason,value:this.replacement??t}}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool_deny.fields.replacement.label",type:"textarea"}),bt({handle:"replacement",userControlled:!0}),C("design:type",Object)],qs.prototype,"replacement",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool_deny.fields.reason.label",type:"text"}),bt({handle:"reason",userControlled:!0}),C("design:type",String)],qs.prototype,"reason",void 0),R([bt({handle:"value"}),C("design:type",Object)],qs.prototype,"value",void 0),R([wt({handle:"proceed"}),C("design:type",Boolean)],qs.prototype,"proceedOut",void 0),R([wt({handle:"value"}),C("design:type",Object)],qs.prototype,"valueOut",void 0),R([wt({handle:"denied"}),C("design:type",Boolean)],qs.prototype,"deniedOut",void 0),R([wt({handle:"reason"}),C("design:type",Object)],qs.prototype,"reasonOut",void 0),qs=R([yt("core.agent.toolDeny",{kind:"core.agent.toolDeny",category:"Agent",width:112,height:96,labels:["agent","ai","hook","deny"],metadata:{title:"graph.node.agent.tool_deny.name",description:"graph.node.agent.tool_deny.description",shape:"rectangle"}}),I()],qs);const Ws=[qs];let Ks=class extends mi{execute(e){const t=e.inputs??{};return{fromAgentId:t.fromAgentId,toAgentId:t.toAgentId??this.subAgentId,input:t.input,output:t.output,error:t.error,value:t.value??t}}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.delegation_hook.fields.phase.label",type:"select"}),bt({handle:"phase",userControlled:!0}),C("design:type",String)],Ks.prototype,"phase",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.delegation_hook.fields.subAgentId.label",type:"text"}),bt({handle:"subAgentId",userControlled:!0}),C("design:type",String)],Ks.prototype,"subAgentId",void 0),R([w(),bt({handle:"value"}),C("design:type",Object)],Ks.prototype,"value",void 0),R([wt({handle:"fromAgentId"}),C("design:type",Object)],Ks.prototype,"fromAgentIdOut",void 0),R([wt({handle:"toAgentId"}),C("design:type",Object)],Ks.prototype,"toAgentIdOut",void 0),R([wt({handle:"input"}),C("design:type",Object)],Ks.prototype,"inputOut",void 0),R([wt({handle:"output"}),C("design:type",Object)],Ks.prototype,"outputOut",void 0),R([wt({handle:"error"}),C("design:type",Object)],Ks.prototype,"errorOut",void 0),R([wt({handle:"value"}),C("design:type",Object)],Ks.prototype,"valueOut",void 0),R([vt({category:"hooks",handle:"hook"}),C("design:type",Object)],Ks.prototype,"hook",void 0),Ks=R([yt("core.agent.delegationHook",{kind:"core.agent.delegationHook",category:"Agent",width:128,height:112,labels:["agent","ai","hook","delegation"],metadata:{title:"graph.node.agent.delegation_hook.name",description:"graph.node.agent.delegation_hook.description",shape:"rectangle"}}),I()],Ks);const Vs=[Ks];let zs=class extends mi{execute(e){return{resource:{type:"mastra.skill",name:this.name,description:this.description,input:e.inputs}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.skill.fields.name.label",type:"text"}),bt({handle:"name",userControlled:!0}),C("design:type",String)],zs.prototype,"name",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.skill.fields.description.label",type:"textarea"}),bt({handle:"description",userControlled:!0}),C("design:type",String)],zs.prototype,"description",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.skill.fields.instructions.label",type:"textarea"}),bt({handle:"instructions",userControlled:!0}),C("design:type",String)],zs.prototype,"instructions",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],zs.prototype,"resource",void 0),R([vt({category:"skill",handle:"skill"}),C("design:type",Object)],zs.prototype,"skill",void 0),zs=R([yt("core.agent.skill",{kind:"core.agent.skill",category:"Agent",width:128,height:112,labels:["agent","ai","skill"],metadata:{title:"graph.node.agent.skill.name",description:"graph.node.agent.skill.description",shape:"rectangle"}}),I()],zs);const Qs=[zs];let Js=class extends mi{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.skills??[],r="string"==typeof t?t:o.length?o[0]:void 0;return{selected:r,resource:r?{type:"mastra.skill",name:r}:null}}};R([bt({handle:"decision"}),C("design:type",Object)],Js.prototype,"decision",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.skill_selector.fields.skills.label",type:"text"}),bt({handle:"skills",userControlled:!0}),C("design:type",Array)],Js.prototype,"skills",void 0),R([wt({handle:"selected"}),C("design:type",Object)],Js.prototype,"selectedOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Js.prototype,"resource",void 0),R([vt({category:"skill",handle:"skill"}),C("design:type",Object)],Js.prototype,"skill",void 0),Js=R([yt("core.agent.skillSelector",{kind:"core.agent.skillSelector",category:"Agent",width:128,height:112,labels:["agent","ai","skill","selector"],metadata:{title:"graph.node.agent.skill_selector.name",description:"graph.node.agent.skill_selector.description",shape:"rectangle"}}),I()],Js);const Xs=[Js];function Ys(e){const t=Oi.graph.execution?.maxCodeTimeoutMs;return ki(e,"number"==typeof t&&Number.isFinite(t)&&t>0?t:qo)}let Zs=class extends mi{execute(e){return{resource:{type:"mastra.sandbox",workingDirectory:this.workingDirectory,isolation:this.isolation,timeoutMs:Ys(this.timeoutMs),input:e.inputs}}}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.sandbox.fields.workingDirectory.label",type:"text"}),bt({handle:"workingDirectory",userControlled:!0}),C("design:type",String)],Zs.prototype,"workingDirectory",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.sandbox.fields.isolation.label",type:"select"}),bt({handle:"isolation",userControlled:!0}),C("design:type",String)],Zs.prototype,"isolation",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.sandbox.fields.timeoutMs.label",type:"number"}),bt({handle:"timeoutMs",userControlled:!0}),C("design:type",Number)],Zs.prototype,"timeoutMs",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Zs.prototype,"resource",void 0),R([vt({category:"sandbox",handle:"sandbox"}),C("design:type",Object)],Zs.prototype,"sandbox",void 0),Zs=R([yt("core.agent.sandbox",{kind:"core.agent.sandbox",category:"Agent",width:128,height:112,labels:["agent","ai","sandbox","filesystem"],metadata:{title:"graph.node.agent.sandbox.name",description:"graph.node.agent.sandbox.description",shape:"rectangle"}}),I()],Zs);const ed=[Zs];let td=class extends mi{execute(e){return{resource:{type:"mastra.scorer",id:this.scorerId,description:this.description,scorerType:this.scorerType,input:e.inputs}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.scorer.fields.scorerId.label",type:"text"}),bt({handle:"scorerId",userControlled:!0}),C("design:type",String)],td.prototype,"scorerId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.scorer.fields.description.label",type:"textarea"}),bt({handle:"description",userControlled:!0}),C("design:type",String)],td.prototype,"description",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.scorer.fields.scorerType.label",type:"select"}),bt({handle:"scorerType",userControlled:!0}),C("design:type",String)],td.prototype,"scorerType",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],td.prototype,"resource",void 0),R([vt({category:"scorers",handle:"scorer"}),C("design:type",Object)],td.prototype,"scorer",void 0),td=R([yt("core.agent.scorer",{kind:"core.agent.scorer",category:"Agent",width:128,height:112,labels:["agent","ai","scorer","eval"],metadata:{title:"graph.node.agent.scorer.name",description:"graph.node.agent.scorer.description",shape:"rectangle"}}),I()],td);const od=[td];let rd=class extends mi{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.scorers??[],r="string"==typeof t?t:o.length?o[0]:void 0;return{selected:r,resource:r?{type:"mastra.scorer",id:r}:null}}};R([bt({handle:"decision"}),C("design:type",Object)],rd.prototype,"decision",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.scorer_selector.fields.scorers.label",type:"text"}),bt({handle:"scorers",userControlled:!0}),C("design:type",Array)],rd.prototype,"scorers",void 0),R([wt({handle:"selected"}),C("design:type",Object)],rd.prototype,"selectedOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],rd.prototype,"resource",void 0),R([vt({category:"scorers",handle:"scorer"}),C("design:type",Object)],rd.prototype,"scorer",void 0),rd=R([yt("core.agent.scorerSelector",{kind:"core.agent.scorerSelector",category:"Agent",width:128,height:112,labels:["agent","ai","scorer","selector"],metadata:{title:"graph.node.agent.scorer_selector.name",description:"graph.node.agent.scorer_selector.description",shape:"rectangle"}}),I()],rd);const nd=[rd];o.accumulate({mastra:{engine:{enabled:!0,terminalTimeoutMs:3e5},provider:{endpoint:"",model:""},credentials:{apiKeyEnv:"MASTRA_PROVIDER_API_KEY"},observability:{enabled:!0,serviceName:"as-graph-mastra",environment:"",langfuse:{endpoint:"https://cloud.langfuse.com",publicKeyEnv:"LANGFUSE_PUBLIC_KEY",secretKeyEnv:"LANGFUSE_SECRET_KEY"}},persistence:{replaysAdapter:"fs",cacheAdapter:"ram",pinsAdapter:"fs",fsRoot:"var/as-graph-mastra"}}});const id=[...sn,"connectionString","dsn","pwd","passphrase","authToken"];function ad(e,t,o,r=0){if(8>=r&&null!==e)if(Array.isArray(e))for(const n of e)ad(n,t,o,r+1);else if("object"==typeof e)for(const[n,i]of Object.entries(e)){const e=[...t,n];if(id.includes(n))throw new ar(`The '${o.provider}' ${o.surface} connection options carry plaintext credential material in '${e.join(".")}'; configs may only reference credentials by name through 'credentialRef', resolved by the host from the git-ignored .env.secret (gate C, SAA-911 F4)`,"GRAPH_MASTRA_PLAIN_CREDENTIAL_REFUSED",{provider:o.provider,id:o.id,key:n,path:e.join(".")});ad(i,e,o,r+1)}}function sd(e,t){ad(e,[],t)}const dd=["memory","libsql","pg","mongodb","upstash","cloud","d1","dynamodb","convex","astra","redis"];function ld(e){const t={type:"mastra.memory",provider:e.provider,id:e.id??e.provider};return void 0!==e.threadId&&(t.threadId=e.threadId),void 0!==e.resourceId&&(t.resourceId=e.resourceId),void 0!==e.lastMessages&&(t.lastMessages=e.lastMessages),void 0!==e.semanticRecall&&(t.semanticRecall=e.semanticRecall),void 0!==e.workingMemoryTemplate&&(t.workingMemory={enabled:!0,template:e.workingMemoryTemplate}),void 0!==e.generateTitle&&(t.generateTitle=e.generateTitle),void 0!==e.credentialRef&&(t.credentialRef=e.credentialRef),t}let cd=class extends mi{execute(e){return{resource:ld(this.configOf(e))}}configOf(e){const t=this.provider??"memory";if(!dd.includes(t))throw new ar(`Memory provider node '${e.nodeId}' declares unknown provider '${t+""}'`,"GRAPH_MASTRA_MEMORY_PROVIDER_UNKNOWN",{nodeId:e.nodeId,provider:t+""});const o=e.inputs.workingMemoryTemplate,r={provider:t};void 0!==this.memoryId&&(r.id=this.memoryId),void 0!==this.threadId&&(r.threadId=this.threadId),void 0!==this.resourceId&&(r.resourceId=this.resourceId),void 0!==this.lastMessages&&(r.lastMessages=this.lastMessages),void 0!==this.semanticRecall&&(r.semanticRecall=this.semanticRecall),void 0!==this.generateTitle&&(r.generateTitle=this.generateTitle),void 0!==this.memoryOptions&&(r.memoryOptions=this.memoryOptions),void 0!==this.connection&&(r.connection=this.connection),void 0!==this.credentialKey&&(r.credentialKey=this.credentialKey),void 0!==this.credentialRef&&(r.credentialRef=this.credentialRef);const n="string"==typeof o&&o.trim().length>0?o:this.workingMemoryTemplate;return"string"==typeof n&&n.trim().length>0&&(r.workingMemoryTemplate=n),r}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.provider.label",type:"select"}),bt({handle:"provider",userControlled:!0}),C("design:type",String)],cd.prototype,"provider",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.memoryId.label",type:"text"}),bt({handle:"memoryId",userControlled:!0}),C("design:type",String)],cd.prototype,"memoryId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.threadId.label",placeholder:"graph.node.agent.memory.fields.threadId.placeholder",type:"text"}),bt({handle:"threadId",userControlled:!0}),C("design:type",String)],cd.prototype,"threadId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.resourceId.label",type:"text"}),bt({handle:"resourceId",userControlled:!0}),C("design:type",String)],cd.prototype,"resourceId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.lastMessages.label",type:"number"}),bt({handle:"lastMessages",userControlled:!0}),C("design:type",Number)],cd.prototype,"lastMessages",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.semanticRecall.label",type:"select"}),bt({handle:"semanticRecall",userControlled:!0}),C("design:type",Boolean)],cd.prototype,"semanticRecall",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.workingMemoryTemplate.label",placeholder:"graph.node.agent.memory.fields.workingMemoryTemplate.placeholder",type:"textarea"}),bt({handle:"workingMemoryTemplate",userControlled:!0}),C("design:type",String)],cd.prototype,"workingMemoryTemplate",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.generateTitle.label",type:"select"}),bt({handle:"generateTitle",userControlled:!0}),C("design:type",Boolean)],cd.prototype,"generateTitle",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.memoryOptions.label",type:"object"}),bt({handle:"memoryOptions",userControlled:!0,type:"object"}),C("design:type",Object)],cd.prototype,"memoryOptions",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.connection.label",type:"object"}),bt({handle:"connection",userControlled:!0,type:"object"}),C("design:type",Object)],cd.prototype,"connection",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.credentialRef.label",type:"text"}),bt({handle:"credentialKey",userControlled:!0}),C("design:type",String)],cd.prototype,"credentialKey",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.credentialRef.label",type:"object"}),bt({handle:"credentialRef",userControlled:!0,type:"object"}),C("design:type",Object)],cd.prototype,"credentialRef",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],cd.prototype,"resource",void 0),R([vt({category:"memory",handle:"memory"}),C("design:type",Object)],cd.prototype,"memory",void 0),cd=R([yt("core.agent.memory",{kind:"core.agent.memory",category:"Agent",width:140,height:120,labels:["agent","ai","memory"],metadata:{title:"graph.node.agent.memory.name",description:"graph.node.agent.memory.description",shape:"rectangle"}}),I()],cd);let pd=class extends mi{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.memories??[],r="string"==typeof t?t:o.length?o[0]:void 0;return{selected:r,resource:r?{type:"mastra.memory",id:r}:null}}};R([bt({handle:"decision"}),C("design:type",Object)],pd.prototype,"decision",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory_selector.fields.memories.label",type:"text"}),bt({handle:"memories",userControlled:!0}),C("design:type",Array)],pd.prototype,"memories",void 0),R([wt({handle:"selected"}),C("design:type",Object)],pd.prototype,"selectedOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],pd.prototype,"resource",void 0),R([vt({category:"memory",handle:"memory"}),C("design:type",Object)],pd.prototype,"memory",void 0),pd=R([yt("core.agent.memorySelector",{kind:"core.agent.memorySelector",category:"Agent",width:128,height:112,labels:["agent","ai","memory","selector"],metadata:{title:"graph.node.agent.memory_selector.name",description:"graph.node.agent.memory_selector.description",shape:"rectangle"}}),I()],pd);const ud=[pd];let hd=class extends mi{execute(e){const t=this.modelAdapter??{};return{resource:{type:"mastra.embedding",provider:t.provider,modelId:t.modelId,dimension:this.dimension,batchSize:this.batchSize,input:e.inputs}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],hd.prototype,"modelAdapter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.dimension.label",type:"number"}),bt({handle:"dimension",userControlled:!0}),C("design:type",Number)],hd.prototype,"dimension",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.batchSize.label",type:"number"}),bt({handle:"batchSize",userControlled:!0}),C("design:type",Number)],hd.prototype,"batchSize",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],hd.prototype,"resource",void 0),R([vt({category:"embedding",handle:"embedding"}),C("design:type",Object)],hd.prototype,"embedding",void 0),hd=R([yt("core.agent.embedding",{kind:"core.agent.embedding",category:"Agent",width:128,height:112,labels:["agent","ai","embedding","vector"],metadata:{title:"graph.node.agent.embedding.name",description:"graph.node.agent.embedding.description",shape:"rectangle"}}),I()],hd);const gd=[hd];let fd=class extends mi{execute(e){const t=this.provider??"memory",o={type:"mastra.vectorStore",provider:t,id:this.storeId??this.indexName??t};void 0!==this.indexName&&(o.indexName=this.indexName),void 0!==this.dimension&&(o.dimension=this.dimension),void 0!==this.metric&&(o.metric=this.metric),void 0!==this.embedding&&(sd(this.embedding,{provider:t,id:this.storeId??this.indexName??t,surface:"vector store embedding"}),o.embedding=this.embedding),void 0!==this.credentialRef&&(o.credentialRef=this.credentialRef);const r=e.inputs.ids;return{resource:o,inserted:Array.isArray(r)?r:[],documents:e.inputs.documents??[]}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.provider.label",type:"select"}),bt({handle:"provider",userControlled:!0}),C("design:type",String)],fd.prototype,"provider",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.storeId.label",type:"text"}),bt({handle:"storeId",userControlled:!0}),C("design:type",String)],fd.prototype,"storeId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.indexName.label",type:"text"}),bt({handle:"indexName",userControlled:!0}),C("design:type",String)],fd.prototype,"indexName",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.dimension.label",type:"number"}),bt({handle:"dimension",userControlled:!0}),C("design:type",Number)],fd.prototype,"dimension",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.metric.label",type:"select"}),bt({handle:"metric",userControlled:!0}),C("design:type",String)],fd.prototype,"metric",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.modelAdapter.label",type:"object"}),bt({handle:"embedding",userControlled:!0,type:"object"}),C("design:type",Object)],fd.prototype,"embedding",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.connection.label",type:"object"}),bt({handle:"connection",userControlled:!0,type:"object"}),C("design:type",Object)],fd.prototype,"connection",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.credentialRef.label",type:"text"}),bt({handle:"credentialKey",userControlled:!0}),C("design:type",String)],fd.prototype,"credentialKey",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.credentialRef.label",type:"object"}),bt({handle:"credentialRef",userControlled:!0,type:"object"}),C("design:type",Object)],fd.prototype,"credentialRef",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],fd.prototype,"resource",void 0),R([wt({handle:"inserted"}),C("design:type",Object)],fd.prototype,"insertedOut",void 0),R([wt({handle:"documents"}),C("design:type",Object)],fd.prototype,"documentsOut",void 0),fd=R([yt("core.agent.vectorStore",{kind:"core.agent.vectorStore",category:"Agent",width:140,height:120,labels:["agent","ai","vector-store","rag"],metadata:{title:"graph.node.agent.vector_store.name",description:"graph.node.agent.vector_store.description",shape:"rectangle"}}),I()],fd);const yd=[fd];let md=class extends mi{execute(e){const t=e.inputs.documents;return{documents:Array.isArray(t)?t:[],resource:{type:"mastra.retriever",topK:this.topK,indexName:this.indexName,store:e.inputs.store,input:e.inputs}}}};R([w(),bt({handle:"store"}),C("design:type",Object)],md.prototype,"store",void 0),R([w(),bt({handle:"query"}),C("design:type",Object)],md.prototype,"query",void 0),R([bt({handle:"queryVector"}),C("design:type",Object)],md.prototype,"queryVector",void 0),R([bt({handle:"filter",type:"object"}),C("design:type",Object)],md.prototype,"filter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.retriever.fields.topK.label",type:"number"}),bt({handle:"topK",userControlled:!0}),C("design:type",Number)],md.prototype,"topK",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.retriever.fields.indexName.label",type:"text"}),bt({handle:"indexName",userControlled:!0}),C("design:type",String)],md.prototype,"indexName",void 0),R([w(),wt({handle:"documents"}),C("design:type",Object)],md.prototype,"documents",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],md.prototype,"resource",void 0),md=R([yt("core.agent.retriever",{kind:"core.agent.retriever",category:"Agent",width:128,height:112,labels:["agent","ai","retriever","rag"],metadata:{title:"graph.node.agent.retriever.name",description:"graph.node.agent.retriever.description",shape:"rectangle"}}),I()],md);const bd=[md],wd=1e3,vd=200;function xd(e,t,o){if("number"!=typeof e||!Number.isFinite(e))return t;const r=Math.floor(e);return o>r?t:r}function Id(e,t,o){if(e.length<=t)return e.length?[e]:[];const r=Math.max(1,t-o),n=[];for(let o=0;o<e.length;o+=r){const r=Math.min(o+t,e.length);if(n.push(e.slice(o,r)),r>=e.length)break}return n}function Ad(e,t={}){if("string"!=typeof e||0===e.length)return[];const o=t.strategy??"recursive",r=xd(t.chunkSize,1e3,1),n=xd(t.chunkOverlap,200,0),i=Math.min(n,Math.max(0,r-1));if("character"===o)return Id(e,r,i);if("token"===o){const t=e.split(/\s+/).filter(e=>e.length>0);if(0===t.length)return[];const o=Math.max(1,r-i),n=[];for(let e=0;e<t.length&&(n.push(t.slice(e,e+r).join(" ")),e+r<t.length);e+=o);return n}const a="markdown"===o?"\n#":t.separator??"\n\n",s=e.split(a),d=[];return s.forEach(e=>{const t=e.trim();t&&(t.length>r?d.push(...Id(t,r,i)):d.push(t))}),d.length?d:Id(e,r,i)}function _d(e){const t=e.documents,o=[];if("string"==typeof e.text&&o.push(e.text),Array.isArray(t))for(const e of t)"string"==typeof e?o.push(e):e&&"object"==typeof e&&"string"==typeof e.text&&o.push(e.text);return o}let Od=class extends mi{execute(e){const t=_d(e.inputs),o={strategy:this.strategy,chunkSize:this.chunkSize,chunkOverlap:this.chunkOverlap,separator:this.separator},r=t.flatMap(e=>Ad(e,o));return{chunks:r,count:r.length}}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.strategy.label",type:"select"}),bt({handle:"strategy",userControlled:!0}),C("design:type",String)],Od.prototype,"strategy",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.chunkSize.label",type:"number"}),bt({handle:"chunkSize",userControlled:!0}),C("design:type",Number)],Od.prototype,"chunkSize",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.chunkOverlap.label",type:"number"}),bt({handle:"chunkOverlap",userControlled:!0}),C("design:type",Number)],Od.prototype,"chunkOverlap",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.separator.label",type:"text"}),bt({handle:"separator",userControlled:!0}),C("design:type",String)],Od.prototype,"separator",void 0),R([w(),wt({handle:"chunks"}),C("design:type",Object)],Od.prototype,"chunks",void 0),R([wt({handle:"count"}),C("design:type",Object)],Od.prototype,"countOut",void 0),Od=R([yt("core.agent.chunking",{kind:"core.agent.chunking",category:"Agent",width:128,height:112,labels:["agent","ai","chunking","rag"],metadata:{title:"graph.node.agent.chunking.name",description:"graph.node.agent.chunking.description",shape:"rectangle"}}),I()],Od);const Ed=[Od];let kd=class extends mi{execute(e){const t=e.inputs.documents,o=Array.isArray(t)?t:[],r="number"==typeof this.topN&&this.topN>0?this.topN:void 0,n=this.modelAdapter??{};return{documents:void 0!==r?o.slice(0,r):o,resource:{type:"mastra.rerank",provider:n.provider,modelId:n.modelId,topN:r}}}};R([w(),bt({handle:"documents"}),C("design:type",Object)],kd.prototype,"documents",void 0),R([bt({handle:"query"}),C("design:type",Object)],kd.prototype,"query",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.rerank.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],kd.prototype,"modelAdapter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.rerank.fields.topN.label",type:"number"}),bt({handle:"topN",userControlled:!0}),C("design:type",Number)],kd.prototype,"topN",void 0),R([w(),wt({handle:"documents"}),C("design:type",Object)],kd.prototype,"documentsOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],kd.prototype,"resource",void 0),kd=R([yt("core.agent.rerank",{kind:"core.agent.rerank",category:"Agent",width:128,height:112,labels:["agent","ai","rerank","rag"],metadata:{title:"graph.node.agent.rerank.name",description:"graph.node.agent.rerank.description",shape:"rectangle"}}),I()],kd);const Sd=[kd];let Rd=class extends mi{execute(e){const t=this.modelAdapter??{},o=e.inputs.context??e.inputs.documents,r=Array.isArray(o)?o:[];return{text:"string"==typeof e.inputs.text?e.inputs.text:"",sourceDocuments:this.returnSourceDocuments?r:[],resource:{type:"mastra.chain.qa",provider:t.provider,modelId:t.modelId,returnSourceDocuments:this.returnSourceDocuments??!1}}}};R([w(),bt({handle:"query"}),C("design:type",Object)],Rd.prototype,"query",void 0),R([bt({handle:"context"}),C("design:type",Object)],Rd.prototype,"context",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.qa.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Rd.prototype,"modelAdapter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.qa.fields.promptTemplate.label",type:"textarea"}),bt({handle:"promptTemplate",userControlled:!0}),C("design:type",String)],Rd.prototype,"promptTemplate",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.qa.fields.returnSourceDocuments.label",type:"boolean"}),bt({handle:"returnSourceDocuments",userControlled:!0}),C("design:type",Boolean)],Rd.prototype,"returnSourceDocuments",void 0),R([w(),wt({handle:"text"}),C("design:type",Object)],Rd.prototype,"text",void 0),R([wt({handle:"sourceDocuments"}),C("design:type",Object)],Rd.prototype,"sourceDocumentsOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Rd.prototype,"resource",void 0),Rd=R([yt("core.agent.chain.qa",{kind:"core.agent.chain.qa",category:"Agent",width:128,height:112,labels:["agent","ai","chain","qa"],metadata:{title:"graph.node.agent.chain.qa.name",description:"graph.node.agent.chain.qa.description",shape:"rectangle"}}),I()],Rd);const Cd=[Rd];let Nd=class extends mi{execute(e){const t=this.modelAdapter??{};return{text:"string"==typeof e.inputs.text?e.inputs.text:"",resource:{type:"mastra.chain.basic",provider:t.provider,modelId:t.modelId,promptTemplate:this.promptTemplate}}}};R([w(),bt({handle:"input"}),C("design:type",Object)],Nd.prototype,"input",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.basic.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Nd.prototype,"modelAdapter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.basic.fields.promptTemplate.label",type:"textarea"}),bt({handle:"promptTemplate",userControlled:!0}),C("design:type",String)],Nd.prototype,"promptTemplate",void 0),R([w(),wt({handle:"text"}),C("design:type",Object)],Nd.prototype,"text",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Nd.prototype,"resource",void 0),Nd=R([yt("core.agent.chain.basic",{kind:"core.agent.chain.basic",category:"Agent",width:128,height:112,labels:["agent","ai","chain","llm"],metadata:{title:"graph.node.agent.chain.basic.name",description:"graph.node.agent.chain.basic.description",shape:"rectangle"}}),I()],Nd);const Td=[Nd];let Dd=class extends mi{execute(e){const t=this.modelAdapter??{},o=e.inputs.documents;return{text:"string"==typeof e.inputs.text?e.inputs.text:"",resource:{type:"mastra.chain.summarization",provider:t.provider,modelId:t.modelId,strategy:this.strategy??"stuff",documentCount:Array.isArray(o)?o.length:0}}}};R([w(),bt({handle:"documents"}),C("design:type",Object)],Dd.prototype,"documents",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.summarization.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Dd.prototype,"modelAdapter",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.summarization.fields.strategy.label",type:"select"}),bt({handle:"strategy",userControlled:!0}),C("design:type",String)],Dd.prototype,"strategy",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.summarization.fields.instructions.label",type:"textarea"}),bt({handle:"instructions",userControlled:!0}),C("design:type",String)],Dd.prototype,"instructions",void 0),R([w(),wt({handle:"text"}),C("design:type",Object)],Dd.prototype,"text",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Dd.prototype,"resource",void 0),Dd=R([yt("core.agent.chain.summarization",{kind:"core.agent.chain.summarization",category:"Agent",width:128,height:112,labels:["agent","ai","chain","summarization"],metadata:{title:"graph.node.agent.chain.summarization.name",description:"graph.node.agent.chain.summarization.description",shape:"rectangle"}}),I()],Dd);const Pd=[Dd];function jd(e){if("string"!=typeof e||0===e.trim().length)return null;try{return JSON.parse(e)}catch{return null}}let $d=class extends mi{execute(e){return{object:jd(e.inputs.text??e.inputs.input),resource:{type:"mastra.structuredOutputParser",strict:this.strict??!1,hasSchema:void 0!==this.structuredOutput}}}};R([w(),bt({handle:"text"}),C("design:type",Object)],$d.prototype,"text",void 0),R([i("ngx-decaf-model-builder",{label:"graph.node.agent.structured_output_parser.fields.structuredOutput.label"}),bt({handle:"structuredOutput",userControlled:!0,type:"object"}),C("design:type",Object)],$d.prototype,"structuredOutput",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.structured_output_parser.fields.strict.label",type:"boolean"}),bt({handle:"strict",userControlled:!0}),C("design:type",Boolean)],$d.prototype,"strict",void 0),R([w(),wt({handle:"object"}),C("design:type",Object)],$d.prototype,"object",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],$d.prototype,"resource",void 0),$d=R([yt("core.agent.structuredOutputParser",{kind:"core.agent.structuredOutputParser",category:"Agent",width:128,height:112,labels:["agent","ai","parser","structured-output"],metadata:{title:"graph.node.agent.structured_output_parser.name",description:"graph.node.agent.structured_output_parser.description",shape:"rectangle"}}),I()],$d);const Ld=[$d];let Md=class extends mi{execute(e){const t=this.modelAdapter??{};return{data:e.inputs.data??null,resource:{type:"mastra.informationExtractor",provider:t.provider,modelId:t.modelId,instructions:this.instructions,hasSchema:void 0!==this.structuredOutput}}}};R([w(),bt({handle:"text"}),C("design:type",Object)],Md.prototype,"text",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.information_extractor.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Md.prototype,"modelAdapter",void 0),R([i("ngx-decaf-model-builder",{label:"graph.node.agent.information_extractor.fields.structuredOutput.label"}),bt({handle:"structuredOutput",userControlled:!0,type:"object"}),C("design:type",Object)],Md.prototype,"structuredOutput",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.information_extractor.fields.instructions.label",type:"textarea"}),bt({handle:"instructions",userControlled:!0}),C("design:type",String)],Md.prototype,"instructions",void 0),R([w(),wt({handle:"data"}),C("design:type",Object)],Md.prototype,"data",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Md.prototype,"resource",void 0),Md=R([yt("core.agent.informationExtractor",{kind:"core.agent.informationExtractor",category:"Agent",width:128,height:112,labels:["agent","ai","extractor","structured-output"],metadata:{title:"graph.node.agent.information_extractor.name",description:"graph.node.agent.information_extractor.description",shape:"rectangle"}}),I()],Md);const Gd=[Md];let Ud=class extends mi{execute(e){return{output:e.inputs.input??null,resource:{type:"mastra.langchainCode",language:this.language??"javascript",mode:this.mode??"runOnce",hasCode:"string"==typeof this.code&&this.code.length>0}}}};R([w(),bt({handle:"input"}),C("design:type",Object)],Ud.prototype,"input",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.langchain_code.fields.code.label",type:"textarea"}),bt({handle:"code",userControlled:!0}),C("design:type",String)],Ud.prototype,"code",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.langchain_code.fields.language.label",type:"select"}),bt({handle:"language",userControlled:!0}),C("design:type",String)],Ud.prototype,"language",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.langchain_code.fields.mode.label",type:"select"}),bt({handle:"mode",userControlled:!0}),C("design:type",String)],Ud.prototype,"mode",void 0),R([wt({handle:"output"}),C("design:type",Object)],Ud.prototype,"outputOut",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Ud.prototype,"resource",void 0),Ud=R([yt("core.agent.langchainCode",{kind:"core.agent.langchainCode",category:"Agent",width:128,height:112,labels:["agent","ai","code","glue"],metadata:{title:"graph.node.agent.langchain_code.name",description:"graph.node.agent.langchain_code.description",shape:"rectangle"}}),I()],Ud);const Fd=[Ud],Bd=["unicodeNormalizer","languageDetector","piiDetector","promptInjectionDetector","systemPromptScrubber","tokenCostControl","modelSelection"],Hd=["tokenLimiter","toolCallFilter","regexFilter","responseCache","batchParts","providerHistoryCompat","cyberRefusalHandler","prefillErrorHandler","streamErrorRetry","unsupportedFileHandler"],qd=["moderation","piiDetector","promptInjectionDetector","regexFilter"];let Wd=class extends mi{execute(e){return{resource:{type:"mastra.inputProcessor",processorType:this.processorType,options:this.options,input:e.inputs}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.input_processor.fields.processorType.label",type:"select"}),bt({handle:"processorType",userControlled:!0}),C("design:type",Object)],Wd.prototype,"processorType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.input_processor.fields.options.label",type:"object"}),bt({handle:"options",userControlled:!0,type:"object"}),C("design:type",Object)],Wd.prototype,"options",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.input_processor.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Wd.prototype,"modelAdapter",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Wd.prototype,"resource",void 0),R([vt({category:"inputProcessors",handle:"processors"}),C("design:type",Object)],Wd.prototype,"processors",void 0),Wd=R([yt("core.agent.inputProcessor",{kind:"core.agent.inputProcessor",category:"Agent",width:128,height:112,labels:["agent","ai","processor","input"],metadata:{title:"graph.node.agent.input_processor.name",description:"graph.node.agent.input_processor.description",shape:"rectangle"}}),I()],Wd);const Kd=[Wd];let Vd=class extends mi{execute(e){return{resource:{type:"mastra.outputProcessor",processorType:this.processorType,options:this.options,input:e.inputs}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.output_processor.fields.processorType.label",type:"select"}),bt({handle:"processorType",userControlled:!0}),C("design:type",Object)],Vd.prototype,"processorType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.output_processor.fields.options.label",type:"object"}),bt({handle:"options",userControlled:!0,type:"object"}),C("design:type",Object)],Vd.prototype,"options",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Vd.prototype,"resource",void 0),R([vt({category:"outputProcessors",handle:"processors"}),C("design:type",Object)],Vd.prototype,"processors",void 0),Vd=R([yt("core.agent.outputProcessor",{kind:"core.agent.outputProcessor",category:"Agent",width:128,height:112,labels:["agent","ai","processor","output"],metadata:{title:"graph.node.agent.output_processor.name",description:"graph.node.agent.output_processor.description",shape:"rectangle"}}),I()],Vd);const zd=[Vd];let Qd=class extends mi{execute(e){return{resource:{type:"mastra.guardrail",guardrailType:this.guardrailType,strategy:this.strategy,options:this.options,input:e.inputs}}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.guardrailType.label",type:"select"}),bt({handle:"guardrailType",userControlled:!0}),C("design:type",Object)],Qd.prototype,"guardrailType",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.strategy.label",type:"select"}),bt({handle:"strategy",userControlled:!0}),C("design:type",String)],Qd.prototype,"strategy",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.options.label",type:"object"}),bt({handle:"options",userControlled:!0,type:"object"}),C("design:type",Object)],Qd.prototype,"options",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.modelAdapter.label",type:"object"}),bt({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Qd.prototype,"modelAdapter",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Qd.prototype,"resource",void 0),R([vt({category:"outputProcessors",handle:"guardrail"}),C("design:type",Object)],Qd.prototype,"guardrail",void 0),Qd=R([yt("core.agent.guardrail",{kind:"core.agent.guardrail",category:"Agent",width:128,height:112,labels:["agent","ai","guardrail","safety"],metadata:{title:"graph.node.agent.guardrail.name",description:"graph.node.agent.guardrail.description",shape:"rectangle"}}),I()],Qd);const Jd=[Qd];let Xd=class extends mi{execute(e){throw new ar("Node kind 'core.agent.hitl' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.hitl",backend:"local"})}};R([w(),bt({handle:"value"}),C("design:type",Object)],Xd.prototype,"value",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.hitl.fields.message.label",placeholder:"graph.node.agent.hitl.fields.message.placeholder",type:"textarea"}),bt({handle:"message",userControlled:!0}),C("design:type",String)],Xd.prototype,"message",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.hitl.fields.prompt.label",type:"textarea"}),bt({handle:"prompt",userControlled:!0}),C("design:type",String)],Xd.prototype,"prompt",void 0),R([w(),bt({handle:"resumeSchema"}),i("ngx-decaf-model-builder",{label:"graph.node.agent.hitl.fields.resumeSchema.label",placeholder:"graph.node.agent.hitl.fields.resumeSchema.placeholder"}),C("design:type",Object)],Xd.prototype,"resumeSchema",void 0),R([wt({handle:"approved"}),C("design:type",Object)],Xd.prototype,"approvedOut",void 0),R([wt({handle:"rejected"}),C("design:type",Object)],Xd.prototype,"rejectedOut",void 0),Xd=R([yt("core.agent.hitl",{kind:"core.agent.hitl",category:"Agent",width:128,height:112,labels:["agent","ai","hitl","suspend"],metadata:{title:"graph.node.agent.hitl.name",description:"graph.node.agent.hitl.description",shape:"rectangle"}}),I()],Xd);const Yd=[Xd];let Zd=class extends mi{execute(e){throw new ar("Node kind 'core.agent.trigger.mcp' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.trigger.mcp",backend:"local"})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.serverId.label",placeholder:"graph.node.agent.mcp_trigger.fields.serverId.placeholder",type:"text"}),bt({handle:"serverId",userControlled:!0}),C("design:type",String)],Zd.prototype,"serverId",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.title.label",type:"text"}),bt({handle:"title",userControlled:!0}),C("design:type",String)],Zd.prototype,"title",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.instructions.label",type:"textarea"}),bt({handle:"instructions",userControlled:!0}),C("design:type",String)],Zd.prototype,"instructions",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.transport.label",type:"select"}),bt({handle:"transport",userControlled:!0}),C("design:type",String)],Zd.prototype,"transport",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.authMode.label",type:"select"}),bt({handle:"authMode",userControlled:!0}),C("design:type",String)],Zd.prototype,"authMode",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.authCredentialRef.label",type:"object"}),bt({handle:"authCredentialRef",userControlled:!0,type:"object"}),C("design:type",Object)],Zd.prototype,"authCredentialRef",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.pendingCap.label",type:"number"}),bt({handle:"pendingCap",userControlled:!0}),C("design:type",Number)],Zd.prototype,"pendingCap",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.pendingTimeoutMs.label",type:"number"}),bt({handle:"pendingTimeoutMs",userControlled:!0}),C("design:type",Number)],Zd.prototype,"pendingTimeoutMs",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],Zd.prototype,"resource",void 0),Zd=R([yt("core.agent.trigger.mcp",{kind:"core.agent.trigger.mcp",category:"Agent",width:128,height:112,labels:["agent","ai","trigger","mcp","server"],metadata:{title:"graph.node.agent.mcp_trigger.name",description:"graph.node.agent.mcp_trigger.description",shape:"rectangle"}}),I()],Zd);const el=[Zd];let tl=class extends mi{execute(e){throw new ar("Node kind 'core.agent.trigger.slack' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.trigger.slack",backend:"local"})}};R([w(),wt({handle:"message"}),C("design:type",Object)],tl.prototype,"message",void 0),R([w(),wt({handle:"sessionId"}),C("design:type",Object)],tl.prototype,"sessionId",void 0),R([w(),wt({handle:"userId"}),C("design:type",Object)],tl.prototype,"userId",void 0),R([w(),wt({handle:"threadId"}),C("design:type",Object)],tl.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],tl.prototype,"resource",void 0),tl=R([yt("core.agent.trigger.slack",{kind:"core.agent.trigger.slack",category:"Agent",icon:"ti-brand-slack",width:96,height:96,labels:["agent","ai","trigger","channel","slack"],metadata:{title:"graph.node.agent.slack_trigger.name",description:"graph.node.agent.slack_trigger.description"}}),I()],tl);const ol=[tl];let rl=class extends mi{execute(e){throw new ar("Node kind 'core.agent.trigger.discord' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.trigger.discord",backend:"local"})}};R([w(),wt({handle:"message"}),C("design:type",Object)],rl.prototype,"message",void 0),R([w(),wt({handle:"sessionId"}),C("design:type",Object)],rl.prototype,"sessionId",void 0),R([w(),wt({handle:"userId"}),C("design:type",Object)],rl.prototype,"userId",void 0),R([w(),wt({handle:"threadId"}),C("design:type",Object)],rl.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],rl.prototype,"resource",void 0),rl=R([yt("core.agent.trigger.discord",{kind:"core.agent.trigger.discord",category:"Agent",icon:"ti-brand-discord",width:96,height:96,labels:["agent","ai","trigger","channel","discord"],metadata:{title:"graph.node.agent.discord_trigger.name",description:"graph.node.agent.discord_trigger.description"}}),I()],rl);const nl=[rl];let il=class extends mi{execute(e){throw new ar("Node kind 'core.agent.trigger.telegram' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.trigger.telegram",backend:"local"})}};R([w(),wt({handle:"message"}),C("design:type",Object)],il.prototype,"message",void 0),R([w(),wt({handle:"sessionId"}),C("design:type",Object)],il.prototype,"sessionId",void 0),R([w(),wt({handle:"userId"}),C("design:type",Object)],il.prototype,"userId",void 0),R([w(),wt({handle:"threadId"}),C("design:type",Object)],il.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],il.prototype,"resource",void 0),il=R([yt("core.agent.trigger.telegram",{kind:"core.agent.trigger.telegram",category:"Agent",icon:"ti-brand-telegram",width:96,height:96,labels:["agent","ai","trigger","channel","telegram"],metadata:{title:"graph.node.agent.telegram_trigger.name",description:"graph.node.agent.telegram_trigger.description"}}),I()],il);const al=[il];let sl=class extends mi{execute(e){throw new ar("Node kind 'core.agent.trigger.teams' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.trigger.teams",backend:"local"})}};R([w(),wt({handle:"message"}),C("design:type",Object)],sl.prototype,"message",void 0),R([w(),wt({handle:"sessionId"}),C("design:type",Object)],sl.prototype,"sessionId",void 0),R([w(),wt({handle:"userId"}),C("design:type",Object)],sl.prototype,"userId",void 0),R([w(),wt({handle:"threadId"}),C("design:type",Object)],sl.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],sl.prototype,"resource",void 0),sl=R([yt("core.agent.trigger.teams",{kind:"core.agent.trigger.teams",category:"Agent",icon:"ti-brand-teams",width:96,height:96,labels:["agent","ai","trigger","channel","teams"],metadata:{title:"graph.node.agent.teams_trigger.name",description:"graph.node.agent.teams_trigger.description"}}),I()],sl);const dl=[sl];let ll=class extends mi{execute(e){throw new ar("Node kind 'core.agent.response.slack' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.response.slack",backend:"local"})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.slack_response.fields.response.label",type:"textarea"}),bt({handle:"response"}),C("design:type",Object)],ll.prototype,"response",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.slack_response.fields.threadId.label",type:"text"}),bt({handle:"threadId",userControlled:!0}),C("design:type",String)],ll.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],ll.prototype,"resource",void 0),ll=R([yt("core.agent.response.slack",{kind:"core.agent.response.slack",category:"Agent",icon:"ti-brand-slack",width:96,height:96,labels:["agent","ai","response","channel","slack"],metadata:{title:"graph.node.agent.slack_response.name",description:"graph.node.agent.slack_response.description"}}),I()],ll);const cl=[ll];let pl=class extends mi{execute(e){throw new ar("Node kind 'core.agent.response.discord' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.response.discord",backend:"local"})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.discord_response.fields.response.label",type:"textarea"}),bt({handle:"response"}),C("design:type",Object)],pl.prototype,"response",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.discord_response.fields.threadId.label",type:"text"}),bt({handle:"threadId",userControlled:!0}),C("design:type",String)],pl.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],pl.prototype,"resource",void 0),pl=R([yt("core.agent.response.discord",{kind:"core.agent.response.discord",category:"Agent",icon:"ti-brand-discord",width:96,height:96,labels:["agent","ai","response","channel","discord"],metadata:{title:"graph.node.agent.discord_response.name",description:"graph.node.agent.discord_response.description"}}),I()],pl);const ul=[pl];let hl=class extends mi{execute(e){throw new ar("Node kind 'core.agent.response.telegram' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.response.telegram",backend:"local"})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.telegram_response.fields.response.label",type:"textarea"}),bt({handle:"response"}),C("design:type",Object)],hl.prototype,"response",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.telegram_response.fields.threadId.label",type:"text"}),bt({handle:"threadId",userControlled:!0}),C("design:type",String)],hl.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],hl.prototype,"resource",void 0),hl=R([yt("core.agent.response.telegram",{kind:"core.agent.response.telegram",category:"Agent",icon:"ti-brand-telegram",width:96,height:96,labels:["agent","ai","response","channel","telegram"],metadata:{title:"graph.node.agent.telegram_response.name",description:"graph.node.agent.telegram_response.description"}}),I()],hl);const gl=[hl];let fl=class extends mi{execute(e){throw new ar("Node kind 'core.agent.response.teams' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.response.teams",backend:"local"})}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.teams_response.fields.response.label",type:"textarea"}),bt({handle:"response"}),C("design:type",Object)],fl.prototype,"response",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.teams_response.fields.threadId.label",type:"text"}),bt({handle:"threadId",userControlled:!0}),C("design:type",String)],fl.prototype,"threadId",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],fl.prototype,"resource",void 0),fl=R([yt("core.agent.response.teams",{kind:"core.agent.response.teams",category:"Agent",icon:"ti-brand-teams",width:96,height:96,labels:["agent","ai","response","channel","teams"],metadata:{title:"graph.node.agent.teams_response.name",description:"graph.node.agent.teams_response.description"}}),I()],fl);const yl=[fl];let ml=class extends mi{execute(e){throw new ar("Node kind 'core.agent.voice' requires the mastra engine, which the local backend does not provide",Mo,{kind:"core.agent.voice",backend:"local"})}};R([i("ngx-decaf-crud-field",{label:"graph.node.agent.voice.fields.speaker.label",type:"text"}),bt({handle:"speaker",userControlled:!0}),C("design:type",String)],ml.prototype,"speaker",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.voice.fields.speechModel.label",type:"object"}),bt({handle:"speechModel",userControlled:!0,type:"object"}),C("design:type",Object)],ml.prototype,"speechModel",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.agent.voice.fields.listeningModel.label",type:"object"}),bt({handle:"listeningModel",userControlled:!0,type:"object"}),C("design:type",Object)],ml.prototype,"listeningModel",void 0),R([w(),wt({handle:"resource"}),C("design:type",Object)],ml.prototype,"resource",void 0),ml=R([yt("core.agent.voice",{kind:"core.agent.voice",category:"Agent",icon:"ti-volume-2",shape:"rounded",width:96,height:96,labels:["agent","ai","voice","speech"],metadata:{title:"graph.node.agent.voice.name",description:"graph.node.agent.voice.description"}}),I()],ml);const bl=[ml];function wl(e,t,o,r){const n=t??o;if(null==e)return Math.min(o,n);const i=Number(e);if(!Number.isFinite(i)||0>=i)throw new dr(r+" loop maxIterations must be a positive finite number");return Math.min(Math.floor(i),n)}function vl(e,t,o){const r=t.node.loop,n=t.metadata?.loop;if(!r?.body&&!n?.body)throw new dr(o+" node is missing loop configuration (instance.loop.body)");const i=t=>{const o=e[t]??r?.[t]??n?.[t],i=Number(o);return void 0!==o&&Number.isFinite(i)?i:void 0},a=t=>{const o=e[t]??n?.[t];return"string"==typeof o?o:void 0};return{body:r?.body??n?.body,maxIterations:i("maxIterations"),timeoutMs:i("timeoutMs"),concurrency:i("concurrency"),condition:e.condition??n?.condition,inputPort:a("inputPort"),outputPort:a("outputPort"),itemPort:a("itemPort"),resultPort:a("resultPort"),statePort:a("statePort"),slice:i("slice")}}let xl=class extends mi{async execute(e,t){const o=vl(this,t,"foreach"),r=e.inputs,n=r.items,i=wl(o.maxIterations,t.limits?.maxForeachIterations,1e3,"foreach");if(!Array.isArray(n))throw new dr("foreach input 'items' must be an array");const a=t.engine;if(!a)throw new ar("foreach node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");const s=Number(r.slice??o.slice??1),d=Number.isFinite(s)&&s>0?Math.floor(s):1,l=d>1?Math.ceil(n.length/d):n.length;if(l>i)throw new lr(`foreach exceeded max iterations (${l} > ${i})`);const c=o.itemPort??"item",p=o.resultPort??"result",u=o.statePort??"state",h=o.body,g=[];let f=r.state,y=!1;await t.emit({type:Qe.LOOP_STARTED});for(let e=0;l>e;e++){await t.emit({type:Qe.LOOP_ITERATION_STARTED,iteration:e});const o=d>1?n.slice(e*d,e*d+d):n[e],r={[c]:o,index:e};d>1&&(r.slice=o),void 0!==f&&(r[u]=f);try{const n=await a.execute(h,r,{parentRunId:t.runId,path:[...t.path,"iteration:"+e],metadata:{item:o,index:e,slice:d},auth:t.auth},t);g.push(n.outputs[p]),void 0!==n.outputs[u]&&(f=n.outputs[u])}catch(o){if(o instanceof gr){const r=o.details?.value;void 0!==r&&g.push(r),y=!0,await t.emit({type:Qe.LOOP_ITERATION_COMPLETED,iteration:e,metadata:{broken:!0}});break}throw o}await t.emit({type:Qe.LOOP_ITERATION_COMPLETED,iteration:e})}await t.emit({type:Qe.LOOP_COMPLETED,metadata:{broken:y}});const m={results:g,completed:g,iterations:g.length,broken:y};return void 0!==f&&(m[u]=f),m}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.items.label",placeholder:"graph.node.loop.foreach.fields.items.placeholder",type:"textarea"}),bt({handle:"items"}),C("design:type",Array)],xl.prototype,"items",void 0),R([w(),i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.slice.label",placeholder:"graph.node.loop.foreach.fields.slice.placeholder",type:"number"}),bt({handle:"slice"}),C("design:type",Number)],xl.prototype,"slice",void 0),R([w(),wt({handle:"item"}),C("design:type",Object)],xl.prototype,"item",void 0),R([w(),vt({handle:"loop",connectionRules:{allowSelf:!0,maxConnections:1}}),C("design:type",Object)],xl.prototype,"loop",void 0),R([w(),wt({handle:"completed"}),C("design:type",Array)],xl.prototype,"completed",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.maxIterations.label",type:"number"}),bt({handle:"maxIterations",userControlled:!0}),C("design:type",Number)],xl.prototype,"maxIterations",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.condition.label",type:"code"}),bt({handle:"condition",userControlled:!0}),C("design:type",Object)],xl.prototype,"condition",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.itemPort.label",type:"text"}),bt({handle:"itemPort",userControlled:!0}),C("design:type",String)],xl.prototype,"itemPort",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.resultPort.label",type:"text"}),bt({handle:"resultPort",userControlled:!0}),C("design:type",String)],xl.prototype,"resultPort",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.statePort.label",type:"text"}),bt({handle:"statePort",userControlled:!0}),C("design:type",String)],xl.prototype,"statePort",void 0),xl=R([yt("graph-foreach-loop-node",{kind:"core.loop.foreach",category:"Loop",color:"#eab308",icon:"ti-repeat",width:120,height:140,labels:["loop","iteration","foreach"],metadata:{title:"graph.node.loop.foreach.name",description:"graph.node.loop.foreach.description",loop:{maxIterations:100,itemPort:"item",resultPort:"result",slice:1}}}),I()],xl);class Il{constructor(){this.expressionEvaluator=new qr}evaluate(e,t){if(this.isConditionExpression(e))return this.expressionEvaluator.evaluate(e,t);const o=this.resolveValue(e.left,t),r=e.right;switch(e.type){case nr.TRUTHY:return!!o;case nr.FALSY:return!o;case nr.EQUALS:return o===r;case nr.NOT_EQUALS:return o!==r;case nr.GREATER_THAN:return Number(o)>Number(r);case nr.GREATER_THAN_OR_EQUAL:return Number(o)>=Number(r);case nr.LESS_THAN:return Number(r)>Number(o);case nr.LESS_THAN_OR_EQUAL:return Number(r)>=Number(o);case nr.EXISTS:return null!=o;case nr.CUSTOM:throw new ar("Custom condition evaluators are not supported in v1","GRAPH_CUSTOM_CONDITION_UNSUPPORTED");default:throw new ar(`Unknown condition type '${e.type}'`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:e})}}async evaluateAsync(e,t,o,r){return Wr(e)?Vr(e,r,o):this.evaluate(e,t)}resolveValue(e,t){if(!e)return t;const o=e.split(".");let r=t;for(const e of o){if(null==r)return;r=r[e]}return r}isConditionExpression(e){return"string"==typeof e.op}}let Al=class extends mi{async execute(e,t){const o=vl(this,t,"until"),r=e.inputs,n=wl(o.maxIterations,t.limits?.maxLoopIterations,100,"until"),i=o.condition;if(!i)throw new dr("until node is missing a condition");const a=o.statePort??"state",s=o.inputPort??a,d=o.outputPort??a,l=o.body,c=t.engine;if(!c)throw new ar("until node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let p=r.state,u=0;await t.emit({type:Qe.LOOP_STARTED});let h=!1;do{if(u>=n)throw await t.emit({type:Qe.LOOP_LIMIT_REACHED,iteration:u}),new lr(`until loop exceeded max iterations (${n})`);await t.emit({type:Qe.LOOP_ITERATION_STARTED,iteration:u}),p=(await c.execute(l,{[s]:p,iteration:u},{parentRunId:t.runId,path:[...t.path,"iteration:"+u],auth:t.auth},t)).outputs[d],await t.emit({type:Qe.LOOP_ITERATION_COMPLETED,iteration:u});const e=await(new Il).evaluateAsync(i,p,t,{...r,state:p});await t.emit({type:Qe.LOOP_CONDITION_EVALUATED,iteration:u,payload:{result:e}}),u++,h=e}while(!h);return await t.emit({type:Qe.LOOP_COMPLETED}),{state:p,iterations:u}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.state.label",placeholder:"graph.node.loop.until.fields.state.placeholder",type:"textarea"}),bt({handle:"state"}),C("design:type",Object)],Al.prototype,"state",void 0),R([w(),wt({handle:"state"}),C("design:type",Object)],Al.prototype,"stateOut",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.maxIterations.label",type:"number"}),bt({handle:"maxIterations",userControlled:!0}),C("design:type",Number)],Al.prototype,"maxIterations",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.condition.label",type:"code"}),bt({handle:"condition",userControlled:!0}),C("design:type",Object)],Al.prototype,"condition",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.statePort.label",type:"text"}),bt({handle:"statePort",userControlled:!0}),C("design:type",String)],Al.prototype,"statePort",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.inputPort.label",type:"text"}),bt({handle:"inputPort",userControlled:!0}),C("design:type",String)],Al.prototype,"inputPort",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.outputPort.label",type:"text"}),bt({handle:"outputPort",userControlled:!0}),C("design:type",String)],Al.prototype,"outputPort",void 0),Al=R([yt("graph-until-loop-node",{kind:"core.loop.until",category:"Loop",color:"#eab308",icon:"ti-player-stop",width:96,height:96,labels:["loop","conditional","until"],metadata:{title:"graph.node.loop.until.name",description:"graph.node.loop.until.description",loop:{maxIterations:50,statePort:"state",condition:{type:"greaterThanOrEqual",left:"iteration",right:2}}}}),I()],Al);let _l=class extends mi{async execute(e,t){const o=vl(this,t,"while"),r=e.inputs,n=wl(o.maxIterations,t.limits?.maxLoopIterations,100,"while"),i=o.condition;if(!i)throw new dr("while node is missing a condition");const a=o.statePort??"state",s=o.inputPort??a,d=o.outputPort??a,l=o.body,c=t.engine;if(!c)throw new ar("while node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let p=r.state,u=0;for(await t.emit({type:Qe.LOOP_STARTED});await(new Il).evaluateAsync(i,p,t,{...r,state:p});){if(u>=n)throw await t.emit({type:Qe.LOOP_LIMIT_REACHED,iteration:u}),new lr(`while loop exceeded max iterations (${n})`);await t.emit({type:Qe.LOOP_CONDITION_EVALUATED,iteration:u,payload:{result:!0}}),await t.emit({type:Qe.LOOP_ITERATION_STARTED,iteration:u}),p=(await c.execute(l,{[s]:p,iteration:u},{parentRunId:t.runId,path:[...t.path,"iteration:"+u],auth:t.auth},t)).outputs[d],await t.emit({type:Qe.LOOP_ITERATION_COMPLETED,iteration:u}),u++}return await t.emit({type:Qe.LOOP_COMPLETED}),{state:p,iterations:u}}};R([w(),i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.state.label",placeholder:"graph.node.loop.while.fields.state.placeholder",type:"textarea"}),bt({handle:"state"}),C("design:type",Object)],_l.prototype,"state",void 0),R([w(),wt({handle:"state"}),C("design:type",Object)],_l.prototype,"stateOut",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.maxIterations.label",type:"number"}),bt({handle:"maxIterations",userControlled:!0}),C("design:type",Number)],_l.prototype,"maxIterations",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.condition.label",type:"code"}),bt({handle:"condition",userControlled:!0}),C("design:type",Object)],_l.prototype,"condition",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.statePort.label",type:"text"}),bt({handle:"statePort",userControlled:!0}),C("design:type",String)],_l.prototype,"statePort",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.inputPort.label",type:"text"}),bt({handle:"inputPort",userControlled:!0}),C("design:type",String)],_l.prototype,"inputPort",void 0),R([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.outputPort.label",type:"text"}),bt({handle:"outputPort",userControlled:!0}),C("design:type",String)],_l.prototype,"outputPort",void 0),_l=R([yt("graph-while-loop-node",{kind:"core.loop.while",category:"Loop",color:"#eab308",icon:"ti-arrows-loop",width:96,height:96,labels:["loop","conditional","while"],metadata:{title:"graph.node.loop.while.name",description:"graph.node.loop.while.description",loop:{maxIterations:50,statePort:"state",condition:{type:"lessThan",left:"iteration",right:3}}}}),I()],_l);let Ol=class extends mi{execute(e){const t=e.inputs;return{value:t?.value??null}}};R([wt({handle:"value",connectionRules:{allowMultiple:!0}}),C("design:type",Object)],Ol.prototype,"value",void 0),Ol=R([yt("graph-input-value-node",{kind:"value",category:"Boundary",color:"#0f766e",icon:"ti-circle-plus",labels:["workflow","input","value"],metadata:{title:"graph.node.boundary.input.name",description:"graph.node.boundary.input.description"}}),I()],Ol);let El=class extends mi{execute(e){return{}}};function kl(e,t,o,r={}){return{id:e,label:t,direction:o,...r}}function Sl(e){const t=e,o=at(t),r=o?.metadata?.title;return ko(t,r?{name:r}:{})}function Rl(e,t){const o=e,r=at(o),n=r?.metadata?.title;return ko(o,{...n?{name:n}:{},icon:{type:"catalogue",name:t}})}function Cl(e,t,o){const r={type:"credential",id:"credentialRef",label:o,required:!1,credentialType:t};return{...e,parameters:[...e.parameters,r],credentials:[...(e.credentials??[]).filter(e=>e.type!==t),{type:t,required:!1}]}}R([w(),bt({handle:"value"}),C("design:type",Object)],El.prototype,"value",void 0),El=R([yt("graph-output-value-node",{kind:"result",category:"Boundary",color:"#0f766e",icon:"ti-circle-minus",width:96,height:96,labels:["workflow","output","value"],metadata:{title:"graph.node.boundary.output.name",description:"graph.node.boundary.output.description"}}),I()],El);const Nl={kind:"core.loop.foreach",capabilities:["loop"],display:{name:"graph.node.loop.foreach.name",description:"graph.node.loop.foreach.description",category:"Loop",color:"#eab308",icon:{type:"catalogue",name:"ti-repeat"},width:120,height:140,labels:["loop","iteration","foreach"]},inputs:[kl("items","graph.node.loop.foreach.ports.input.items.label","input",{required:!0,schema:{type:"array",items:{type:"any"}}}),kl("slice","graph.node.loop.foreach.ports.input.slice.label","input",{schema:{type:"number",integer:!0,min:1}}),kl("state","graph.node.loop.foreach.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[kl("results","graph.node.loop.foreach.ports.output.results.label","output",{schema:{type:"array",items:{type:"any"}}}),kl("completed","graph.node.loop.foreach.ports.output.completed.label","output",{schema:{type:"array",items:{type:"any"}}}),kl("iterations","graph.node.loop.foreach.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}}),kl("broken","graph.node.loop.foreach.ports.output.broken.label","output",{schema:{type:"boolean"}}),kl("state","graph.node.loop.foreach.ports.output.state.label","output",{schema:{type:"any"}})],parameters:[{type:"number",id:"maxIterations",label:"graph.node.loop.foreach.fields.maxIterations.label",integer:!0,min:1},{type:"object",id:"condition",label:"graph.node.loop.foreach.fields.condition.label"},{type:"string",id:"itemPort",label:"graph.node.loop.foreach.fields.itemPort.label"},{type:"string",id:"resultPort",label:"graph.node.loop.foreach.fields.resultPort.label"},{type:"string",id:"statePort",label:"graph.node.loop.foreach.fields.statePort.label"},{type:"number",id:"slice",label:"graph.node.loop.foreach.fields.slice.label",integer:!0,min:1}]},Tl={kind:"core.loop.while",capabilities:["loop"],display:{name:"graph.node.loop.while.name",description:"graph.node.loop.while.description",category:"Loop",color:"#eab308",icon:{type:"catalogue",name:"ti-arrows-loop"},width:120,height:140,labels:["loop","conditional","while"]},inputs:[kl("state","graph.node.loop.while.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[kl("state","graph.node.loop.while.ports.output.state.label","output",{schema:{type:"any"}}),kl("iterations","graph.node.loop.while.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}})],parameters:[{type:"number",id:"maxIterations",label:"graph.node.loop.while.fields.maxIterations.label",integer:!0,min:1},{type:"object",id:"condition",label:"graph.node.loop.while.fields.condition.label",required:!0},{type:"string",id:"statePort",label:"graph.node.loop.while.fields.statePort.label"},{type:"string",id:"inputPort",label:"graph.node.loop.while.fields.inputPort.label"},{type:"string",id:"outputPort",label:"graph.node.loop.while.fields.outputPort.label"}]},Dl={kind:"core.loop.until",capabilities:["loop"],display:{name:"graph.node.loop.until.name",description:"graph.node.loop.until.description",category:"Loop",color:"#eab308",icon:{type:"catalogue",name:"ti-player-stop"},width:120,height:140,labels:["loop","conditional","until"]},inputs:[kl("state","graph.node.loop.until.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[kl("state","graph.node.loop.until.ports.output.state.label","output",{schema:{type:"any"}}),kl("iterations","graph.node.loop.until.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}})],parameters:[{type:"number",id:"maxIterations",label:"graph.node.loop.until.fields.maxIterations.label",integer:!0,min:1},{type:"object",id:"condition",label:"graph.node.loop.until.fields.condition.label",required:!0},{type:"string",id:"statePort",label:"graph.node.loop.until.fields.statePort.label"},{type:"string",id:"inputPort",label:"graph.node.loop.until.fields.inputPort.label"},{type:"string",id:"outputPort",label:"graph.node.loop.until.fields.outputPort.label"}]},Pl=[Sl(Ol),Sl(El),Sl(Ji),Sl(Xi),Sl(Zi),Sl(ea),Sl(oa),Sl(na),Sl(ia),Sl(aa),Sl(sa),Sl(la),Sl(pa),Sl(ha),Sl(wa),Cl(Sl(Da),"postgres","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(Pa),"mysql","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(ja),"mssql","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(Ga),"redis","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(Ha),"s3","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(qa),"s3","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(Wa),"gcs","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(Va),"azure-blob","graph.node.storage.common.fields.credentialRef.label"),Cl(Sl(bs),"crypto","graph.node.devops.common.fields.credentialRef.label"),Cl(Sl(vs),"jwt","graph.node.devops.common.fields.credentialRef.label"),(()=>{const e=Sl(Is);return{...e,metadata:{...e.metadata??{},danger:!0,requiresOptIn:!0,dangerReason:"Executes arbitrary shell commands with the host process privileges; expose only behind an explicit operator opt-in."}}})(),Cl(Sl(Os),"sftp","graph.node.devops.common.fields.credentialRef.label"),Cl(Sl(hs),"github","graph.node.devops.common.fields.credentialRef.label"),Cl(Sl(fs),"gitlab","graph.node.devops.common.fields.credentialRef.label"),Cl(Sl(Qa),"slack","graph.node.comms.common.fields.credentialRef.label"),Cl(Sl(Xa),"telegram","graph.node.comms.common.fields.credentialRef.label"),Cl(Sl(Za),"teams","graph.node.comms.common.fields.credentialRef.label"),Cl(Sl(ts),"gmail","graph.node.comms.common.fields.credentialRef.label"),Cl(Sl(rs),"email","graph.node.comms.common.fields.credentialRef.label"),Cl(Sl(is),"google-sheets","graph.node.io.common.fields.credentialRef.label"),Cl(Sl(ss),"airtable","graph.node.io.common.fields.credentialRef.label"),Cl(Sl(ps),"graphql","graph.node.io.common.fields.credentialRef.label"),Sl(ls),Sl(va),Sl(Es),Sl(ks),Sl(Ns),Sl(Ds),Sl(Ts),Sl(Rs),Sl(Cs),Sl(Ss),(jl=Sl(Ii),{...jl,dynamicPorts:[{type:"togglePort",parameter:"else",equals:!0,port:{id:"else",label:"graph.node.flow_control.if.ports.output.else.label",direction:"output",schema:{type:"any"}}}]}),(e=>({...e,outputs:[],parameters:[...e.parameters,{type:"collection",id:"cases",label:"graph.node.flow_control.switch.fields.cases.label",required:!0,itemIdPath:"outputPort",itemLabelPath:"label"},{type:"boolean",id:"hasDefault",label:"graph.node.flow_control.switch.fields.hasDefault.label",defaultValue:!1},{type:"object",id:"switch",label:"graph.node.flow_control.switch.fields.switch.label",required:!1}],dynamicPorts:[{type:"repeatFromParameter",parameter:"cases",itemIdPath:"outputPort",itemLabelPath:"label",direction:"output",portIdTemplate:"${id}",defaultPort:{id:"case",label:"graph.node.flow_control.switch.ports.output.case.label",direction:"output",schema:{type:"any"}}},{type:"togglePort",parameter:"hasDefault",equals:!0,port:{id:"default",label:"graph.node.flow_control.switch.ports.output.default.label",direction:"output",schema:{type:"any"}}}]}))(Sl(Ai)),Sl(Pi),Sl(Ti),Sl(vi),Sl(xi),Sl(Ni),Sl(Di),Sl(ji),Sl(bi),Sl($s),Sl(Ms),Sl(Us),Sl(Bs),Sl(qs),Sl(Ks),Sl(zs),Sl(Js),Sl(Zs),Sl(td),Sl(rd),Sl(cd),Sl(pd),Sl(hd),Sl(fd),Sl(md),Sl(Od),Sl(kd),Sl(Rd),Sl(Nd),Sl(Dd),Sl($d),Sl(Md),Sl(Ud),Sl(Wd),Sl(Vd),Sl(Qd),Sl(Xd),Sl(Zd),Rl(tl,"ti-brand-slack"),Rl(rl,"ti-brand-discord"),Rl(il,"ti-brand-telegram"),Rl(sl,"ti-brand-teams"),Rl(ll,"ti-brand-slack"),Rl(pl,"ti-brand-discord"),Rl(hl,"ti-brand-telegram"),Rl(fl,"ti-brand-teams"),Rl(ml,"ti-volume-2"),Nl,Tl,Dl];var jl;const $l=Object.fromEntries(Pl.map(e=>[e.kind,e])),Ll=[Ns,Ds,Ts,Rs,Cs,Ss],Ml=[Ii,Ai,Ti,vi,xi,Di,bi],Gl=[Ni,Pi,ji],Ul=[xl,_l,Al],Fl=[Ol,El],Bl=[Ms,Us,Bs,qs,Ks,zs,Js,Zs,td,rd],Hl=[cd,pd],ql=[hd,fd,md,Od,kd,Rd,Nd,Dd,$d,Md,Ud],Wl=[Wd,Vd,Qd],Kl=[Xd,Zd],Vl=[tl,rl,il,sl,ll,pl,hl,fl,ml],zl=[ia,oa,Zi,sa,Ji,Xi,ea,aa,na],Ql=[pa,va,la,ha,wa],Jl={value:Ol,result:El,"core.trigger.manual":Ns,"core.trigger.webhook":Ds,"core.trigger.schedule":Ts,"core.trigger.event":Rs,"core.trigger.form":Cs,"core.trigger.chat":Ss,"core.flow.if":Ii,"core.flow.switch":Ai,"core.utility.map":Pi,"core.flow.delay":Ti,"core.flow.errorBoundary":vi,"core.flow.humanApproval":xi,"core.utility.code":Ni,"core.flow.log":Di,"core.utility.log":ji,"core.flow.break":bi,"core.agent":$s,"core.agent.tool":Ms,"core.agent.toolSelector":Us,"core.agent.hook":Bs,"core.agent.toolDeny":qs,"core.agent.delegationHook":Ks,"core.agent.skill":zs,"core.agent.skillSelector":Js,"core.agent.sandbox":Zs,"core.agent.scorer":td,"core.agent.scorerSelector":rd,"core.agent.memory":cd,"core.agent.memorySelector":pd,"core.agent.embedding":hd,"core.agent.vectorStore":fd,"core.agent.retriever":md,"core.agent.chunking":Od,"core.agent.rerank":kd,"core.agent.chain.qa":Rd,"core.agent.chain.basic":Nd,"core.agent.chain.summarization":Dd,"core.agent.structuredOutputParser":$d,"core.agent.informationExtractor":Md,"core.agent.langchainCode":Ud,"core.agent.inputProcessor":Wd,"core.agent.outputProcessor":Vd,"core.agent.guardrail":Qd,"core.agent.hitl":Xd,"core.agent.trigger.mcp":Zd,"core.agent.trigger.slack":tl,"core.agent.trigger.discord":rl,"core.agent.trigger.telegram":il,"core.agent.trigger.teams":sl,"core.agent.response.slack":ll,"core.agent.response.discord":pl,"core.agent.response.telegram":hl,"core.agent.response.teams":fl,"core.agent.voice":ml,"core.data.set":ia,"core.data.merge":oa,"core.data.filter":Zi,"core.data.splitOut":sa,"core.data.dateTime":Ji,"core.data.dataTable":Xi,"core.data.limit":ea,"core.data.sort":aa,"core.data.renameKeys":na,"core.io.httpRequest":pa,"core.io.respondToWebhook":va,"core.io.extractFromFile":la,"core.io.readPDF":ha,"core.io.readWriteFile":wa,"core.storage.postgres":Da,"core.storage.mySql":Pa,"core.storage.microsoftSql":ja,"core.storage.redis":Ga,"core.storage.s3":Ha,"core.storage.awsS3":qa,"core.storage.googleCloudStorage":Wa,"core.storage.azureStorage":Va,"core.devops.crypto":bs,"core.devops.jwt":vs,"core.devops.executeCommand":Is,"core.devops.ftp":Os,"core.devops.github":hs,"core.devops.gitlab":fs,"core.comms.slack":Qa,"core.comms.telegram":Xa,"core.comms.teams":Za,"core.comms.gmail":ts,"core.comms.emailSend":rs,"core.io.googleSheets":is,"core.io.airtable":ss,"core.io.spreadsheetFile":ls,"core.io.graphql":ps,"core.flow.executeSubWorkflow":Es,"core.trigger.executeWorkflow":ks,"core.loop.foreach":xl,"core.loop.while":_l,"core.loop.until":Al};function Xl(e){return{execute:(t,o)=>e.instantiate({...yi(o.node),...t.parameters,...o.node.state??{}}).execute(t,o)}}function Yl(){const e=[];for(const[t,o]of Object.entries($l)){const r=Jl[t];r&&e.push(gi({manifest:o,executor:Xl(r)}))}return e}function Zl(e,...t){for(const o of Yl())e.register(o,{},...t);return e}class ec{resolve(e){const t=this.createValidator(e);return{name:e.name,required:e.required,validate:t}}resolveAll(e){const t={};for(const o of e)t[o.name]=this.resolve(o);return t}createValidator(e){switch((e.type??e.designType??"").toLowerCase()){case"string":return e=>"string"==typeof e;case"number":return e=>"number"==typeof e;case"boolean":return e=>"boolean"==typeof e;case"date":return e=>e instanceof Date||"string"==typeof e&&!isNaN(Date.parse(e));case"array":return e=>Array.isArray(e);case"bigint":return e=>"bigint"==typeof e;default:return()=>!0}}}class tc{constructor(e){this.resolver=e}validateWorkflowInputs(e,t){this.validatePorts(e.inputs,t,"workflow input")}validateWorkflowOutputs(e,t){this.validatePorts(e.outputs,t,"workflow output")}validateNodeInputs(e,t){const o=(e.ports??[]).filter(e=>"input"===e.direction);this.validatePorts(o,t,`node '${e.name}' input`)}validateNodeOutputs(e,t){const o=(e.ports??[]).filter(e=>"output"===e.direction);this.validatePorts(o,t,`node '${e.name}' output`)}validatePorts(e,t,o){if(e)for(const r of e){const e=Object.prototype.hasOwnProperty.call(t,r.name);if(r.required&&!e)throw new dr(`Missing required ${o} port '${r.name}'`);if(e&&!this.resolver.resolve(r).validate(t[r.name]))throw new dr(`Invalid value for ${o} port '${r.name}'`)}}}const oc=["node","definition","executor","execute","ports","component"];function rc(e,t,o,r){return{code:e,path:t,message:o,...void 0!==r?.nodeId?{nodeId:r.nodeId}:{},...void 0!==r?.edgeId?{edgeId:r.edgeId}:{},...r?.details?{details:r.details}:{}}}function nc(e,t){const o=[];for(const r of Object.keys(e))oc.includes(r)&&o.push(rc("document.forbidden-field",`${t}.${r}`,`Field '${r}' is not accepted in a canonical workflow document: node, definition, executor, execute, ports and component fields are rejected at the boundary`,{details:{field:r}}));return o}function ic(e,t){t.push(...nc(e,"$")),e.inputs.forEach((e,o)=>t.push(...nc(e,`inputs[${o}]`))),e.outputs.forEach((e,o)=>t.push(...nc(e,`outputs[${o}]`)));for(const o of e.nodes)t.push(...nc(o,`nodes[${o.id}]`)),o.loop&&(t.push(...nc(o.loop,`nodes[${o.id}].loop`)),ic(o.loop.body,t));for(const o of e.edges)t.push(...nc(o,`edges[${o.id}]`))}function ac(e,t){const o=[];e.nodes.length>t.maxNodes&&o.push(rc("document.limit.nodes","$.nodes",`Document declares ${e.nodes.length} nodes; at most ${t.maxNodes} are allowed`,{details:{count:e.nodes.length,limit:t.maxNodes}})),e.edges.length>t.maxEdges&&o.push(rc("document.limit.edges","$.edges",`Document declares ${e.edges.length} edges; at most ${t.maxEdges} are allowed`,{details:{count:e.edges.length,limit:t.maxEdges}}));const r=sc(e);r>t.maxNestingDepth&&o.push(rc("document.limit.depth","$.nodes",`Document nests loop bodies ${r} levels deep; at most ${t.maxNestingDepth} levels are allowed`,{details:{depth:r,limit:t.maxNestingDepth}}));const n=Buffer.byteLength(JSON.stringify(e),"utf8");return n>t.maxDocumentBytes&&o.push(rc("document.limit.size","$",`Document serializes to ${n} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,{details:{bytes:n,limit:t.maxDocumentBytes}})),o}function sc(e,t=0){let o=t;for(const r of e.nodes)r.loop?.body&&(o=Math.max(o,sc(r.loop.body,t+1)));return o}async function dc(e,t,...o){const r=[];for(const n of e.nodes)t.has(n.kind,...o)||r.push(rc("node.unknown-kind",`nodes[${n.id}].kind`,`Node '${n.id}' references kind '${n.kind}' which is not registered in the backend catalogue`,{nodeId:n.id,details:{kind:n.kind}})),n.loop?.body&&r.push(...await dc(n.loop.body,t,...o));return r}async function lc(e,t={},...o){const r={..._i,...t.limits},n=[];if(!Yt(e))return n.push(rc("document.shape","$","Payload is not a canonical GraphWorkflowDocument: id and name must be strings and inputs, outputs, nodes and edges must be arrays")),{valid:!1,issues:n};if(!Et(e))return n.push(rc("document.json-unsafe","$","Document contains JSON-unsafe values: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys (__proto__/prototype/constructor) are rejected")),{valid:!1,issues:n};ic(e,n),n.push(...(e=>{const t=[],o=new Set;for(const r of[...e.inputs,...e.outputs])o.has(r.id)?t.push(rc("document.duplicate-port-id",`ports[${r.id}]`,`Workflow port '${r.id}' is declared more than once; workflow port ids must be unique`)):o.add(r.id);const r=new Set;for(const o of e.nodes)r.has(o.id)?t.push(rc("document.duplicate-node-id",`nodes[${o.id}]`,`Node '${o.id}' is declared more than once; node ids must be unique`,{nodeId:o.id})):r.add(o.id);const n=new Set;for(const o of e.edges)n.has(o.id)?t.push(rc("document.duplicate-edge-id",`edges[${o.id}]`,`Edge '${o.id}' is declared more than once; edge ids must be unique`,{edgeId:o.id})):n.add(o.id);return t})(e)),n.push(...ac(e,r)),An(e,n);try{Bt(e)}catch(e){const t=e instanceof E?e.message:e+"";n.push(rc("document.structure","$",t))}return t.catalogue&&n.push(...await dc(e,t.catalogue,...o)),{valid:0===n.length,issues:n}}class cc{constructor(e,t){this.iteration=e,this.metadata=t}}function pc(e,t,o={}){const r=e?.owner??null;return!r||r===t||(null==t||""===t)&&!0===o.allowAnonymousAccess}function uc(e,t){return(e?.owner??null)===(t??null)}function hc(e,t,o){if(!uc(e,t))throw new L(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function gc(e,t,o){if(!pc(e,t,o))throw new L(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function fc(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>fc(e)).join(",")}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${fc(t[e])}`).join(",")}}`}function yc(e){return ee("sha256").update(fc(e)).digest("hex")}class mc{constructor(e={}){this.events=new Map,this.listeners=new Map,this.limits={...Je,...e}}async append(e){let t=this.events.get(e.runId);t||(t=[],this.events.set(e.runId,t)),t.push(e),this.enforceRetention(t);for(const t of this.listeners.get(e.runId)??[])try{t(e)}catch{}}async listAfter(e,t){const o=this.events.get(e);return o?o.filter(e=>e.sequence>t):[]}subscribe(e,t){let o=this.listeners.get(e);return o||(o=new Set,this.listeners.set(e,o)),o.add(t),()=>{o.delete(t),0===o.size&&this.listeners.delete(e)}}release(e){this.events.delete(e),this.listeners.delete(e)}enforceRetention(e){const t=this.limits.maxEventsPerRun;for(;e.length>t;){const t=e.findIndex(e=>!Ye(e.type));if(-1===t)break;e.splice(t,1)}}}function bc(e){return new Co({runId:e.runId,workflowId:e.workflowId,...e.ownerUser?{owner:e.ownerUser}:{},status:e.status,...e.documentFingerprint?{documentFingerprint:e.documentFingerprint}:{},...void 0!==e.result?{result:wc(e.result)}:{},...e.error?{error:wc(e.error)}:{},createdAt:new Date(e.createdAt),...e.startedAt?{startedAt:new Date(e.startedAt)}:{},...e.finishedAt?{finishedAt:new Date(e.finishedAt)}:{}})}function wc(e){if(null!=e)return JSON.parse(JSON.stringify(e))}class vc{constructor(){this.runs=new Map}async saveRun(e){this.runs.set(e.runId,{...e})}async readRun(e){const t=this.runs.get(e);return t?{...t}:null}async listRuns(e){return[...this.runs.values()].filter(t=>t.workflowId===e).map(e=>bc(e))}release(e){this.runs.delete(e)}}class xc{constructor(e,t={}){this.sequences=new Map,this.chains=new Map,this.store=e,this.limits={...Je,...t}}async publish(e){const t=e.runId,o=(this.sequences.get(t)??0)+1;this.sequences.set(t,o);const r={...e,payload:this.limitPayload(e.payload),sequence:o,timestamp:(new Date).toISOString()},n=(this.chains.get(t)??Promise.resolve()).then(()=>this.store.append(r));return this.chains.set(t,n.catch(()=>{})),await n,r}lastSequence(e){return this.sequences.get(e)??0}release(e){this.sequences.delete(e),this.chains.delete(e)}limitPayload(e){if(void 0===e)return;let t;try{t=JSON.stringify(e)}catch{return{nonSerializable:!0}}return t.length>this.limits.maxEventPayloadBytes?{truncated:!0,reason:"event payload exceeds the configured byte limit",bytes:t.length}:e}}class Ic{constructor(e,t,o,r={},n={}){this.controllers=new Map,this.completions=new Map,this.timeouts=new Map,this.engine=e,this.runStore=t,this.publisher=o,this.hooks=r,this.limits={...Je,...n}}begin(e){const t=this.controllers.get(e);if(t)return t;const o=new AbortController;return this.controllers.set(e,o),o}abort(e,t){const o=this.controllers.get(e);return!!o&&(o.signal.aborted||o.abort(t),!0)}isAborted(e){return!0===this.controllers.get(e)?.signal.aborted}abortReason(e){const t=this.controllers.get(e)?.signal;if(t?.aborted)return"timeout"===t.reason?"timeout":"user"}waitFor(e){return this.completions.get(e)}schedule(e,t,o,...r){const n=this.completions.get(e.runId);if(n)return n;const i=this.runExecution({...e},t,o,...r).catch(async t=>{const o=Ac(t);try{await this.emitTerminal({...e},Qe.WORKFLOW_FAILED,o)}catch{}return await this.finalize({...e},"failed",void 0,o,...r)});return this.completions.set(e.runId,i),i}release(e){this.controllers.delete(e),this.completions.delete(e);const t=this.timeouts.get(e);t&&(clearTimeout(t),this.timeouts.delete(e)),this.publisher.release(e)}armTimeout(e){const t=setTimeout(()=>{this.timeouts.delete(e),this.abort(e,"timeout")},this.limits.executionTimeoutMs);this.timeouts.set(e,t)}async runExecution(e,t,o,...r){const n=e.runId;let i,a,s=!1;const d=this.engine.observe({refresh:async t=>{t.runId===n&&(t.error&&(i=t.error),Ye((await this.publisher.publish(this.envelopeOf(e,t))).type)?s=!0:t.type===Qe.WORKFLOW_STARTED&&"validating"===e.status&&(e.status="running",await this.persist(e,...r)))}});this.armTimeout(n);try{if(this.isAborted(n)){const t={name:"GraphRunCancelledError",message:`Graph run '${n}' was cancelled before execution started`,code:"GRAPH_RUN_CANCELLED"};return i=t,await this.emitTerminal(e,Qe.WORKFLOW_CANCELLED,t),s=!0,await this.finalize(e,"cancelled",void 0,t,...r)}let d,l;e.status="validating",e.startedAt=(new Date).toISOString(),await this.persist(e,...r);try{({document:d,fingerprint:l}=await t(...r)),e.documentFingerprint=l,await this.persist(e,...r)}catch(t){const o=Ac(t);return i=o,s||(await this.emitTerminal(e,Qe.WORKFLOW_FAILED,o),s=!0),await this.finalize(e,"failed",void 0,o,...r)}if(this.isAborted(n)){const t={name:"GraphRunCancelledError",message:`Graph run '${n}' was cancelled before execution started`,code:"GRAPH_RUN_CANCELLED"};return i=t,s||(await this.emitTerminal(e,Qe.WORKFLOW_CANCELLED,t),s=!0),await this.finalize(e,"cancelled",void 0,t,...r)}try{a=await this.engine.execute(d,o,{runId:n,abortSignal:this.controllers.get(n)?.signal,metadata:{documentFingerprint:l}},...r)}catch(e){i=Ac(e)}const c=this.abortReason(n);let p,u;return"timeout"===c?(p="failed",u=i??{name:"GraphRunTimeoutError",message:`Graph run '${n}' exceeded the configured execution timeout of ${this.limits.executionTimeoutMs}ms`,code:"GRAPH_RUN_TIMEOUT"}):"user"===c?(p="cancelled",u=i):a?.status===Ke.SUCCEEDED?p="succeeded":a?.status===Ke.CANCELLED?(p="cancelled",u=i):(p="failed",u=i??Ac(new ar(a?`Graph run '${n}' failed`:`Graph run '${n}' failed without a result`,"GRAPH_RUN_FAILED",{runId:n}))),s||await this.emitTerminal(e,"succeeded"===p?Qe.WORKFLOW_COMPLETED:"cancelled"===p?Qe.WORKFLOW_CANCELLED:Qe.WORKFLOW_FAILED,u),await this.finalize(e,p,a,u,...r)}finally{d();const e=this.timeouts.get(n);e&&(clearTimeout(e),this.timeouts.delete(n))}}async emitTerminal(e,t,o){await this.publisher.publish({runId:e.runId,workflowId:e.workflowId,type:t,error:o})}async finalize(e,t,o,r,...n){e.status=t,o&&(e.result=o),r&&(e.error=r),e.startedAt||(e.startedAt=(new Date).toISOString()),e.finishedAt=(new Date).toISOString(),await this.persist(e,...n);try{await(this.hooks.onRunCompleted?.(e,o))}catch{}return e}async persist(e,...t){await this.runStore.saveRun({...e},...t)}envelopeOf(e,t){return{runId:e.runId,workflowId:t.workflowId??e.workflowId,type:t.type,nodeId:t.nodeId,edgeId:t.edgeId,payload:void 0===t.payload?void 0:Ot(t.payload)?t.payload:{nonSerializable:!0},error:t.error,parentRunId:t.parentRunId,path:t.path}}}function Ac(e){return e instanceof Error?{name:e.name,message:e.message,stack:e.stack,code:e.graphCode??("number"==typeof e.code?e.code+"":e.code)}:{name:"UnknownError",message:e+""}}class _c{constructor(e,t,o,r={}){this.activeByCaller=new Map,this.callerKeysByRun=new Map,this.releaseTimers=new Map,this.engine=e,this.runStore=t,this.eventStore=o,this.publisher=new xc(o,r.limits),this.executor=new Ic(e,t,this.publisher,{onRunCompleted:r.onRunCompleted},r.limits),this.options={...r,limits:{...Je,...r.limits}}}get limits(){return this.options.limits}async createRun(e,t,o,...r){this.validateCreateRequest(e);const n=e.workflowId??e.workflow?.id??"";if(!n)throw new E("Graph run request must carry a workflow document with an id or a saved workflowId");if(e.workflowId&&!this.options.documentResolver)throw new E("Graph run requests by workflowId require a document resolver");const i=o??t??"anonymous",a=this.activeByCaller.get(i)??new Set;if(a.size>=this.options.limits.maxConcurrentRuns)throw new E(`Graph run rejected: the configured limit of ${this.options.limits.maxConcurrentRuns} concurrent runs per caller is exhausted`);const s=this.generateRunId(),d={runId:s,workflowId:n,ownerUser:t,status:"queued",createdAt:(new Date).toISOString()};this.executor.begin(s),await this.runStore.saveRun({...d},...r);const l=this.documentProviderFor(e,t);return a.add(s),this.activeByCaller.set(i,a),this.callerKeysByRun.set(s,i),this.executor.schedule(d,l,e.inputs??{},...r).catch(()=>{}).finally(()=>this.finishActiveRun(s)),d}async getRun(e,t,...o){const r=await this.runStore.readRun(e,...o);if(!r)throw new S(`No graph run found for runId '${e}'`);return this.assertOwnership(r,t),r}async listRunsByWorkflow(e,t,...o){return(await this.runStore.listRuns(e,...o)).filter(e=>pc({owner:e.owner},t,{allowAnonymousAccess:!0===this.options.allowAnonymousAccess})).sort((e,t)=>{const o=e.updatedAt instanceof Date?e.updatedAt.getTime():NaN,r=t.updatedAt instanceof Date?t.updatedAt.getTime():NaN;return(Number.isFinite(r)?r:0)-(Number.isFinite(o)?o:0)})}async cancelRun(e,t,...o){const r=await this.runStore.readRun(e,...o);if(!r)throw new S(`No graph run found for runId '${e}'`);return this.assertWriteOwnership(r,t),"succeeded"===(n=r.status)||"failed"===n||"cancelled"===n||(this.executor.abort(e,"user"),r.status="cancelled",r.finishedAt=(new Date).toISOString(),await this.runStore.saveRun({...r},...o)),r;var n}async resumeRun(e,t,o,...r){const n=await this.runStore.readRun(e,...r);if(!n)throw new S(`No graph run found for runId '${e}'`);this.assertWriteOwnership(n,o);const i=this.engine.backend,a=i.resume;if("function"!=typeof a)throw new ar(`Graph execution backend '${i.constructor?.name??"GraphExecutionBackend"}' does not support resume`,"GRAPH_RESUME_UNSUPPORTED_BACKEND",{runId:e});let s;try{s=await a.call(i,e,t,...r)}catch(e){throw(d=e)instanceof ar?new ar(d.message,d.graphCode):d}var d;const l={...s,runId:e,caller:o};return await this.publisher.publish({runId:e,workflowId:n.workflowId,type:Qe.WORKFLOW_RESUMED,payload:l}),l}async listEvents(e,t,o,...r){return await this.getRun(e,o,...r),this.eventStore.listAfter(e,t)}async subscribeEvents(e,t,o,...r){return await this.getRun(e,t,...r),this.eventStore.subscribe(e,o)}subscribeRunEvents(e,t){return this.eventStore.subscribe(e.runId,t)}async waitForRun(e,t,...o){const r=this.executor.waitFor(e);return r&&await r,this.getRun(e,t,...o)}async executeAndWait(e,t,o,...r){const n=await this.createRun(e,t,o,...r);return this.waitForRun(n.runId,t,...r)}release(e){this.finishActiveRun(e);const t=this.releaseTimers.get(e);t&&(clearTimeout(t),this.releaseTimers.delete(e)),this.executor.release(e),this.eventStore.release?.(e)}finishActiveRun(e){const t=this.callerKeysByRun.get(e);if(void 0!==t){this.callerKeysByRun.delete(e);const o=this.activeByCaller.get(t);o&&(o.delete(e),0===o.size&&this.activeByCaller.delete(t))}if(this.releaseTimers.has(e))return;const o=setTimeout(()=>{this.releaseTimers.delete(e),this.release(e)},this.options.limits.eventReplayWindowMs);o.unref?.(),this.releaseTimers.set(e,o)}validateCreateRequest(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new E("Graph run request must be an object carrying either a workflow document or a workflowId plus inputs");const t=void 0!==e.workflow,o=void 0!==e.workflowId;if(t&&o)throw new E("Graph run request is ambiguous: supply either an unsaved workflow document or a saved workflowId, not both");if(!t&&!o)throw new E("Graph run request must supply either an unsaved workflow document or a saved workflowId");if(t&&!Yt(e.workflow))throw new E("Graph run request carries a payload that is not a canonical GraphWorkflowDocument");if(void 0!==e.inputs&&!Et(e.inputs))throw new E("Graph run inputs must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys (__proto__/prototype/constructor) are rejected");const r=(e=>{try{return JSON.stringify(e)?.length??0}catch{return Number.MAX_SAFE_INTEGER}})(e);if(r>this.options.limits.maxRequestBytes)throw new E(`Graph run request of ${r} bytes exceeds the configured limit of ${this.options.limits.maxRequestBytes} bytes`)}documentProviderFor(e,t){if(e.workflow){const t=e.workflow;return async()=>({document:t,fingerprint:yc(t)})}const o=e.workflowId;return async(...e)=>{const r=this.options.documentResolver;if(!r)throw new E("Graph run requests by workflowId require a document resolver");const n=await r.resolve(o,t,...e);return{document:n,fingerprint:yc(n)}}}assertOwnership(e,t){gc({owner:e.ownerUser},t,{allowAnonymousAccess:!0===this.options.allowAnonymousAccess,resourceKind:"Graph run",resourceId:e.runId})}assertWriteOwnership(e,t){hc({owner:e.ownerUser},t,{resourceKind:"Graph run",resourceId:e.runId})}generateRunId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new ur("Cannot generate a graph run id: crypto.randomUUID is unavailable in this runtime",{runtime:typeof globalThis.crypto});return e.randomUUID()}}function Oc(e){if(!e)return;let t;try{t=e.cache?.user}catch{t=void 0}if(null==t)try{t=e.get("user")}catch{t=void 0}return"string"==typeof t&&t.length>0?t:void 0}function Ec(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&Yt(e.document)&&!Yt(e)}function kc(e){return JSON.parse(JSON.stringify(e))}function Sc(e){if(null==e)return 0;let t;try{t=e.getTime()}catch{return 0}return Number.isFinite(t)?t:0}let Rc=class extends z{constructor(e){super(No),this.catalogue=e}get limits(){return{..._i,...Oi.graph.workflows.limits??{}}}get allowAnonymousAccess(){return!0===Oi.graph.workflows.allowAnonymousAccess}async saveDocument(e,t,...o){const{ctx:r,ctxArgs:n}=(await this.logCtx(o,"saveDocument",!0)).for(this.saveDocument);if(!Yt(t))throw new E("Payload is not a canonical GraphWorkflowDocument: id and name must be strings and inputs, outputs, nodes and edges must be arrays");if(t.id!==e)throw new E(`Document id '${t.id}' does not match the workflow id '${e}' from the request path`);const i=await this.validateDocument(t,r);if(!i.valid)throw new yr(i.issues);const a=Oc(r),s=await this.readExistingForWrite(e,n);s&&this.assertWriteOwnership(e,s,a);const d=new Date;if(s)return s.name=t.name,s.document=kc(t),s.updatedAt=d,this.update(s,...n);const l=new No({workflowId:e,name:t.name,document:kc(t),...a?{owner:a}:{},updatedAt:d});return this.create(l,...n)}async seedDocument(e,t,...o){const{log:r,ctxArgs:n}=(await this.logCtx(o,"seedDocument",!0)).for(this.seedDocument);try{return await this.saveDocument(e,t,...n)}catch(t){if(t instanceof L)return r.warn(`Skipping boot seed of graph workflow '${e}': an existing row is owned by another user`),null;throw t}}async getDocument(e,...t){const{ctx:o,ctxArgs:r}=(await this.logCtx(t,"getDocument",!0)).for(this.getDocument);let n;try{n=await this.read(e,...r)}catch{n=null}if(!n)throw new S(`No graph workflow found for workflowId '${e}'`);if(this.assertOwnership(e,n,Oc(o)),n.document)return kc(n.document);throw new S(`Graph workflow '${e}' has no canonical document; legacy definition/state snapshots are no longer supported (DECAF-50 \xa74.26 R2-2)`)}async listWorkflows(...e){const{ctx:t,ctxArgs:o}=(await this.logCtx(e,"listWorkflows",!0)).for(this.listWorkflows),r=await this.listBy("workflowId",W.ASC,...o),n=Oc(t);return r.filter(e=>pc(e,n,{allowAnonymousAccess:this.allowAnonymousAccess})).sort((e,t)=>Sc(t.updatedAt)-Sc(e.updatedAt))}async assertAccess(e,...t){const{ctx:o,ctxArgs:r}=(await this.logCtx(t,"assertAccess",!0)).for(this.assertAccess);let n;try{n=await this.read(e,...r)}catch{n=null}if(!n)throw new S(`No graph workflow found for workflowId '${e}'`);return this.assertOwnership(e,n,Oc(o)),n}async validateDocument(e,...t){const{ctx:o}=(await this.logCtx(t,"validateDocument",!0)).for(this.validateDocument);return await lc(e,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o)}async saveSnapshot(e,t,...o){const{ctx:r,ctxArgs:n}=(await this.logCtx(o,"saveSnapshot",!0)).for(this.saveSnapshot);if(!Et(t))throw new E("Workflow snapshot payload must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys (__proto__/prototype/constructor) are rejected");if(!Ec(t))throw new E("Workflow snapshots must wrap a canonical GraphWorkflowDocument ({ document, editor?, metadata? }): legacy definition/state snapshots are no longer accepted; save canonical documents via PUT /graph/workflows/{workflowId}");const i=Oc(r),a=await this.readExistingForWrite(e,n);a&&this.assertWriteOwnership(e,a,i);const s=new Date;if(a)return a.snapshot=t,await this.applyCanonicalWrapper(a,t,r),a.updatedAt=s,this.update(a,...n);const d=new No({workflowId:e,snapshot:t,...i?{owner:i}:{},updatedAt:s});return await this.applyCanonicalWrapper(d,t,r),this.create(d,...n)}async loadSnapshot(e,...t){const{ctx:o,ctxArgs:r}=(await this.logCtx(t,"loadSnapshot",!0)).for(this.loadSnapshot);try{const t=await this.read(e,...r);return this.assertOwnership(e,t,Oc(o)),t}catch{return null}}async readExistingForWrite(e,t){try{return await this.read(e,...t)}catch(e){if(e instanceof S)return null;throw e}}assertOwnership(e,t,o){gc(t??null,o??null,{allowAnonymousAccess:this.allowAnonymousAccess,resourceKind:"Graph workflow",resourceId:e})}assertWriteOwnership(e,t,o){hc(t??null,o??null,{resourceKind:"Graph workflow",resourceId:e})}async applyCanonicalWrapper(e,t,o){if(!Ec(t))return;if(t.document.id!==e.workflowId)throw new E(`Document id '${t.document.id}' does not match the workflow id '${e.workflowId}' from the request path`);const r=await lc(t.document,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o);if(!r.valid)throw new yr(r.issues);e.document=kc(t.document),e.name=t.document.name}};Rc=R([B(No),C("design:paramtypes",[Function])],Rc);let Cc=class extends z{constructor(){super(Co)}async saveRun(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"saveRun",!0)).for(this.saveRun),r=bc(e);let n;try{n=await super.read(e.runId,...o)}catch{n=null}if(n)return n.workflowId=r.workflowId,n.owner=r.owner,n.status=r.status,n.documentFingerprint=r.documentFingerprint,n.result=r.result,n.error=r.error,n.startedAt=r.startedAt,n.finishedAt=r.finishedAt,void await this.update(n,...o);await this.create(r,...o)}async readRun(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"readRun",!0)).for(this.readRun);try{return(e=>{const t=e.result;return{runId:e.runId,workflowId:e.workflowId,ownerUser:e.owner??null,status:(o=e.status,"string"==typeof o&&["queued","validating","running","succeeded","failed","cancelled"].includes(o)?e.status:"failed"),createdAt:e.createdAt.toISOString(),...e.startedAt?{startedAt:e.startedAt.toISOString()}:{},...e.finishedAt?{finishedAt:e.finishedAt.toISOString()}:{},...t?{result:t}:{},...e.error?{error:e.error}:{},...e.documentFingerprint?{documentFingerprint:e.documentFingerprint}:{}};var o})(await super.read(e,...o))}catch{return null}}async listRuns(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"listRuns",!0)).for(this.listRuns);return await this.findBy("workflowId",e,...o)}};Cc=R([B(Co),C("design:paramtypes",[])],Cc);let Nc=class extends z{constructor(){super(To)}async upsertManifest(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"upsertManifest",!0)).for(this.upsertManifest),r=(e=>new To({kind:e.kind,name:e.display?.name,category:e.display?.category,group:e.display?.group,description:e.display?.description,manifest:io(no(e))}))(e);let n;try{n=await this.read(r.kind,...o)}catch{n=void 0}return n?(n.name=r.name,n.category=r.category,n.group=r.group,n.description=r.description,n.manifest=r.manifest,await this.update(n,...o)):await this.create(r,...o)}async syncFromCatalogue(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"syncFromCatalogue",!0)).for(this.syncFromCatalogue),r=e.listManifests(void 0,...o),n=[];for(const e of r)n.push(await this.upsertManifest(e,...o));return n}async listNodes(...e){const{ctxArgs:t}=(await this.logCtx(e,"listNodes",!0)).for(this.listNodes);return await this.listBy("kind",W.ASC,...t)}async listManifests(...e){return(await this.listNodes(...e)).map(e=>(e=>{if(!e.manifest)throw new E(`Graph node row '${e.kind}' has no manifest to convert`);return io(no(e.manifest))})(e))}async getNode(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"getNode",!0)).for(this.getNode);try{return await this.read(e,...o)}catch{throw new S(`Graph node kind '${e}' is not registered`)}}};Nc=R([B(To),C("design:paramtypes",[])],Nc);class Tc{map(e){const t={};for(const[o,r]of Object.entries(e.nodeResults))t[o]={status:r.status,startedAt:r.startedAt?.toISOString(),finishedAt:r.finishedAt?.toISOString(),error:r.error,outputs:r.outputs,fromCache:r.fromCache,pinned:r.pinned};const o={};for(const t of e.events)t.edgeId&&"edge.valueRouted"===t.type&&(o[t.edgeId]={status:Ke.SUCCEEDED,lastValue:t.payload?.value,updatedAt:t.timestamp.toISOString()});const r=[...e.events];return{runId:e.runId,status:e.status,nodes:t,edges:o,outputs:e.outputs,events:r}}}export{Nd as AgentBasicChainNode,Od as AgentChunkingNode,Ks as AgentDelegationHookNode,hd as AgentEmbeddingNode,Qd as AgentGuardrailNode,Xd as AgentHitlNode,Bs as AgentHookNode,Md as AgentInformationExtractorNode,Wd as AgentInputProcessorNode,Ud as AgentLangChainCodeNode,cd as AgentMemoryNode,pd as AgentMemorySelectorNode,$s as AgentNode,Vd as AgentOutputProcessorNode,Rd as AgentQaChainNode,kd as AgentRerankNode,md as AgentRetrieverNode,Zs as AgentSandboxNode,td as AgentScorerNode,rd as AgentScorerSelectorNode,zs as AgentSkillNode,Js as AgentSkillSelectorNode,$d as AgentStructuredOutputParserNode,Dd as AgentSummarizationChainNode,qs as AgentToolDenyNode,Ms as AgentToolNode,Us as AgentToolSelectorNode,fd as AgentVectorStoreNode,ml as AgentVoiceNode,ss as AirtableNode,qa as AwsS3StorageNode,Va as AzureStorageNode,bi as BreakFlowNode,Ss as ChatTriggerNode,Ci as CodeInputSchema,Ni as CodeNode,qr as ConditionExpressionEvaluator,bs as CryptoNode,_i as DEFAULT_GRAPH_WORKFLOW_DOCUMENT_LIMITS,Cn as DEFAULT_GRAPH_WORKFLOW_VALIDATION_LIMITS,mn as DEFAULT_PINNING_METADATA,vd as DEFAULT_RAG_CHUNK_OVERLAP,wd as DEFAULT_RAG_CHUNK_SIZE,Xi as DataTableNode,Ji as DateTimeNode,Ti as DelayFlowNode,pl as DiscordChannelResponseNode,rl as DiscordChannelTriggerNode,rs as EmailSendNode,vi as ErrorBoundaryFlowNode,Rs as EventTriggerNode,Is as ExecuteCommandNode,Es as ExecuteSubWorkflowNode,ks as ExecuteWorkflowTriggerNode,la as ExtractFromFileNode,Zi as FilterNode,Cs as FormTriggerNode,Os as FtpNode,Td as GRAPH_AGENT_BASIC_CHAIN_NODES,Ed as GRAPH_AGENT_CHUNKING_NODES,Vs as GRAPH_AGENT_DELEGATION_HOOK_NODES,ul as GRAPH_AGENT_DISCORD_RESPONSE_NODES,nl as GRAPH_AGENT_DISCORD_TRIGGER_NODES,gd as GRAPH_AGENT_EMBEDDING_NODES,Bl as GRAPH_AGENT_FAMILY_NODES,Jd as GRAPH_AGENT_GUARDRAIL_NODES,Yd as GRAPH_AGENT_HITL_NODES,Hs as GRAPH_AGENT_HOOK_NODES,Gd as GRAPH_AGENT_INFORMATION_EXTRACTOR_NODES,Kd as GRAPH_AGENT_INPUT_PROCESSOR_NODES,Fd as GRAPH_AGENT_LANGCHAIN_CODE_NODES,Kl as GRAPH_AGENT_M5_NODES,Vl as GRAPH_AGENT_M6_NODES,el as GRAPH_AGENT_MCP_TRIGGER_NODES,Hl as GRAPH_AGENT_MEMORY_NODES,ud as GRAPH_AGENT_MEMORY_SELECTOR_NODES,Ls as GRAPH_AGENT_NODES,zd as GRAPH_AGENT_OUTPUT_PROCESSOR_NODES,Wl as GRAPH_AGENT_PROCESSOR_NODES,Cd as GRAPH_AGENT_QA_CHAIN_NODES,ql as GRAPH_AGENT_RAG_NODES,Sd as GRAPH_AGENT_RERANK_NODES,bd as GRAPH_AGENT_RETRIEVER_NODES,ed as GRAPH_AGENT_SANDBOX_NODES,od as GRAPH_AGENT_SCORER_NODES,nd as GRAPH_AGENT_SCORER_SELECTOR_NODES,Qs as GRAPH_AGENT_SKILL_NODES,Xs as GRAPH_AGENT_SKILL_SELECTOR_NODES,cl as GRAPH_AGENT_SLACK_RESPONSE_NODES,ol as GRAPH_AGENT_SLACK_TRIGGER_NODES,Ld as GRAPH_AGENT_STRUCTURED_OUTPUT_PARSER_NODES,Pd as GRAPH_AGENT_SUMMARIZATION_CHAIN_NODES,yl as GRAPH_AGENT_TEAMS_RESPONSE_NODES,dl as GRAPH_AGENT_TEAMS_TRIGGER_NODES,gl as GRAPH_AGENT_TELEGRAM_RESPONSE_NODES,al as GRAPH_AGENT_TELEGRAM_TRIGGER_NODES,Ws as GRAPH_AGENT_TOOL_DENY_NODES,Gs as GRAPH_AGENT_TOOL_NODES,Fs as GRAPH_AGENT_TOOL_SELECTOR_NODES,yd as GRAPH_AGENT_VECTOR_STORE_NODES,bl as GRAPH_AGENT_VOICE_NODES,Fl as GRAPH_BOUNDARY_NODES,Jl as GRAPH_BUILT_IN_NODE_CLASSES_BY_KIND,Pl as GRAPH_BUILT_IN_NODE_MANIFESTS,$l as GRAPH_BUILT_IN_NODE_MANIFESTS_BY_KIND,Ri as GRAPH_CODE_DEFAULT_LANGUAGE,Ei as GRAPH_CODE_DEFAULT_TIMEOUT_MS,Si as GRAPH_CODE_LANGUAGES,qo as GRAPH_CODE_MAX_TIMEOUT_MS,zl as GRAPH_DATA_NODES,tr as GRAPH_DATA_TABLE_MAX_LIST_ROWS,Zo as GRAPH_DATA_TABLE_MAX_ROWS,er as GRAPH_DATA_TABLE_MAX_ROW_BYTES,Go as GRAPH_DEFAULT_CONCURRENCY,Fo as GRAPH_DEFAULT_MAX_FOREACH_ITERATIONS,Uo as GRAPH_DEFAULT_MAX_LOOP_ITERATIONS,Nn as GRAPH_DOCUMENT_FORBIDDEN_FIELD_KEYS,Qo as GRAPH_EXECUTE_COMMAND_DEFAULT_TIMEOUT_MS,Jo as GRAPH_EXECUTE_COMMAND_MAX_OUTPUT_BYTES,zo as GRAPH_EXECUTE_COMMAND_MAX_TIMEOUT_MS,Ml as GRAPH_FLOW_CONTROL_NODES,Vo as GRAPH_HTTP_MAX_REDIRECTS,Ko as GRAPH_HTTP_MAX_RESPONSE_BYTES,Wo as GRAPH_HTTP_MAX_TIMEOUT_MS,Ql as GRAPH_IO_NODES,Lo as GRAPH_LOCAL_EXECUTION_BACKEND,Mo as GRAPH_LOCAL_UNSUPPORTED_NODE_KIND,ir as GRAPH_LOOP_KIND,Ul as GRAPH_LOOP_NODES,Yo as GRAPH_MAX_CHILD_RUNS,Ho as GRAPH_MAX_FOREACH_ITERATIONS,Bo as GRAPH_MAX_LOOP_ITERATIONS,Xo as GRAPH_MAX_SUB_WORKFLOW_DEPTH,or as GRAPH_PINNING_METADATA_KEY,sn as GRAPH_PLAIN_SECRET_KEYS,Ll as GRAPH_TRIGGER_NODES,Gl as GRAPH_UTILITY_NODES,$o as GRAPH_WORKFLOW_BOUNDARY,oc as GRAPH_WORKFLOW_FORBIDDEN_FIELD_KEYS,hs as GithubNode,fs as GitlabNode,ts as GmailNode,Wa as GoogleCloudStorageNode,is as GoogleSheetsNode,Dr as GraphAuthValidator,gr as GraphBreakSignal,Il as GraphConditionEvaluator,nr as GraphConditionType,On as GraphConnectionPolicyValidator,Sn as GraphConnectionValidationError,Rn as GraphCredentialAuthorizationError,En as GraphCredentialReferenceValidator,sr as GraphCycleError,Ln as GraphDataTableModel,qn as GraphDataTableRepository,kn as GraphDocumentValidationError,_n as GraphEdgeInstanceValidator,Fr as GraphEngineEventSink,Oi as GraphEnvironment,Hr as GraphExecutionBackendRegistry,Mr as GraphExecutionContext,Qn as GraphExecutionEngine,ar as GraphExecutionError,mr as GraphExecutionEventEmitter,br as GraphExecutionEventFactory,Gr as GraphExecutionFrame,jn as GraphExecutionPlanner,Tc as GraphExecutionSnapshotMapper,xl as GraphForeachLoopNode,dr as GraphInputError,Ol as GraphInputValueNode,cc as GraphLoopExecutionContext,lr as GraphLoopLimitError,mi as GraphNode,pi as GraphNodeCatalogue,Pr as GraphNodeCredentialResolver,ui as GraphNodeExecutorRegistry,hi as GraphNodeExecutorResolver,In as GraphNodeInstanceValidator,si as GraphNodeManifestResolver,ei as GraphNodeMethodNotFoundError,ti as GraphNodeMethodRegistry,Nc as GraphNodeModelService,Zn as GraphNodeNotFoundError,Yn as GraphNodeRegistrationError,El as GraphOutputValueNode,dn as GraphParameterValidator,vn as GraphPinningDependencyResolver,cr as GraphPinningError,wn as GraphPinningPolicy,yn as GraphPinningService,rr as GraphPinningStrategy,pr as GraphPortError,ec as GraphPortSchemaResolver,fr as GraphRunCancelledError,xc as GraphRunEventPublisher,Ic as GraphRunExecutor,Cc as GraphRunModelService,_c as GraphRunService,ur as GraphStoreError,fn as GraphTopology,hr as GraphTopologyError,Al as GraphUntilLoopNode,ln as GraphValueModel,hn as GraphValueRepository,tc as GraphValueValidator,$n as GraphWebhookResponseRegistry,_l as GraphWhileLoopNode,yr as GraphWorkflowDocumentRejectedError,Pn as GraphWorkflowDocumentValidator,Rc as GraphWorkflowService,ps as GraphqlNode,pa as HttpRequestNode,xi as HumanApprovalFlowNode,Ii as IfFlowNode,mc as InMemoryGraphRunEventStore,vc as InMemoryGraphRunStore,Xn as IsolatedVmCodeSandboxEvaluator,vs as JwtNode,ea as LimitNode,xn as LocalGraphExecutionBackend,Di as LogFlowNode,Ps as MASTRA_AGENT_ZONE,js as MASTRA_AGENT_ZONES,qd as MASTRA_GUARDRAIL_TYPES,Bd as MASTRA_INPUT_PROCESSOR_TYPES,Hd as MASTRA_OUTPUT_PROCESSOR_TYPES,Ns as ManualTriggerNode,Pi as MapNode,Zd as McpServerTriggerNode,oa as MergeNode,ja as MicrosoftSqlNode,Pa as MySqlNode,Da as PostgresNode,ha as ReadPDFNode,wa as ReadWriteFileNode,Ga as RedisNode,na as RenameKeysNode,va as RespondToWebhookNode,Ba as S3Node,Ha as S3StorageNode,Ts as ScheduleTriggerNode,ia as SetNode,ll as SlackChannelResponseNode,tl as SlackChannelTriggerNode,Qa as SlackNode,aa as SortNode,sa as SplitOutNode,ls as SpreadsheetFileNode,Ai as SwitchFlowNode,fl as TeamsChannelResponseNode,sl as TeamsChannelTriggerNode,Za as TeamsNode,hl as TelegramChannelResponseNode,il as TelegramChannelTriggerNode,Xa as TelegramNode,ji as UtilityLogNode,Ds as WebhookTriggerNode,gc as assertGraphResourceOwnership,hc as assertGraphResourceWriteOwnership,Ur as buildGraphExecutionResult,Yl as builtInGraphNodeRegistrations,pc as canAccessGraphResource,uc as canAccessGraphResourcePayload,on as checkGraphValueAgainstSchema,Ad as chunkText,ki as clampGraphCodeTimeoutMs,Ys as clampSandboxTimeoutMs,An as collectLooseNodeIssues,vr as composeGraphNamespace,Wn as createGraphDataTableRepository,gn as createGraphValueRepository,fi as declaredGraphNodeMethods,wr as decomposeGraphNamespace,Nr as decomposeGraphNamespaces,gi as defineGraphNode,Zr as detectGraphCodeModeSurfaces,Vr as evaluateCodeCondition,Qr as evaluateCondition,zr as evaluateConditionSync,_d as extractChunkTexts,Or as findMalformedGraphNamespaces,_r as findUngrantedGraphNamespaces,Rr as graphAuthDataFromRecord,Cr as graphAuthDataOf,en as graphDocumentHasCodeMode,Ar as graphNamespaceCovers,Ir as graphNamespacePartsOf,yi as graphNodeConfig,Er as graphRolesFromNamespaces,yc as graphRunDocumentFingerprint,Oc as graphWorkflowOwnerOf,Wr as isCodeCondition,Kr as isConditionExpression,nn as isGraphCredentialReferenceLike,xr as isGraphNamespaceCacheEntryValid,Tn as isGraphResolvedWorkflow,bn as isPinnable,Tr as mergeGraphAuthData,Zl as registerBuiltInGraphNodes,Br as resolveGraphBackendCapabilities,ii as resolveGraphDynamicPorts,ai as resolveGraphNodeManifest,jr as resolveNodeCredential,cn as serializeGraphValueKey,zn as stripFacadeOwnedBackendConfig,lc as validateGraphWorkflowDocumentAtBoundary};
1
+ import{logParameterRegistry as e,Logging as t,LoggedEnvironment as o}from"@decaf-ts/logging";import{RenderingEngine as r,uimodel as n,uielement as i,uilistprop as a,uilistmodel as s,hidden as d}from"@decaf-ts/ui-decorators";import{Metadata as l,Decoration as c,apply as p,metadata as u,propMetadata as g,description as h,prop as f,DefaultFlavour as y}from"@decaf-ts/decoration";import{ValidationKeys as m,Model as b,required as w,type as v,date as x,model as I,option as _,min as E,max as A}from"@decaf-ts/decorator-validation";import{ValidationError as S,InternalError as R,NotFoundError as O}from"@decaf-ts/db-decorators";import{__decorate as k,__metadata as C}from"tslib";import{pk as N,column as T,index as P,table as D,BaseModel as j,noValidateOnUpdate as L,ForbiddenError as M,Context as G,repository as U,Repository as $,AuthorizationError as F,service as H,Service as B,Condition as q,OrderDirection as W,ClientBasedService as K,Adapter as V,ModelService as z}from"@decaf-ts/core";import Q from"isolated-vm";import*as J from"acorn";import*as X from"acorn-walk";import*as Y from"typescript";import{randomUUID as Z,createHash as ee}from"node:crypto";import{dirname as te,resolve as oe,relative as re,sep as ne,isAbsolute as ie,extname as ae,basename as se}from"node:path";import{homedir as de}from"node:os";import{realpathSync as le}from"node:fs";import{realpath as ce,readFile as pe,mkdir as ue,appendFile as ge,writeFile as he,glob as fe}from"node:fs/promises";import{TypeORMAdapter as ye}from"@decaf-ts/for-typeorm";import{RedisAdapter as me}from"@decaf-ts/integrations/redis";import{connect as be}from"amqplib";import{collectToBuffer as we}from"@decaf-ts/integrations/blob";import{S3BlobStoreService as ve}from"@decaf-ts/integrations/blob/s3";import{bootWithoutEnvironment as xe}from"@decaf-ts/integrations/shared/http";import{GcsBlobStoreService as Ie}from"@decaf-ts/integrations/blob/gcp";import{AzureBlobStoreService as _e}from"@decaf-ts/integrations/blob/azure";import{SlackService as Ee}from"@decaf-ts/integrations/comms/slack";import{TelegramService as Ae}from"@decaf-ts/integrations/comms/telegram";import{TeamsService as Se}from"@decaf-ts/integrations/comms/teams";import{GmailService as Re}from"@decaf-ts/integrations/comms/gmail";import{EmailService as Oe}from"@decaf-ts/integrations/comms/email";import{DiscordService as ke}from"@decaf-ts/integrations/comms/discord";import{WhatsAppService as Ce}from"@decaf-ts/integrations/comms/whatsapp";import{MicrosoftOutlookService as Ne}from"@decaf-ts/integrations/comms/outlook";import{GoogleSheetsService as Te}from"@decaf-ts/integrations/io/google-sheets";import{AirtableService as Pe}from"@decaf-ts/integrations/io/airtable";import{SpreadsheetService as De}from"@decaf-ts/integrations/io/spreadsheet";import{GraphqlService as je}from"@decaf-ts/integrations/io/graphql";import{MicrosoftExcelService as Le}from"@decaf-ts/integrations/io/microsoft-excel";import{ConfluenceService as Me}from"@decaf-ts/integrations/io/confluence";import{JiraService as Ge}from"@decaf-ts/integrations/io/jira";import{GoogleDocsService as Ue}from"@decaf-ts/integrations/io/google-docs";import{MicrosoftSharePointService as $e}from"@decaf-ts/integrations/io/microsoft-sharepoint";import{GoogleCalendarService as Fe}from"@decaf-ts/integrations/calendar/google-calendar";import*as He from"cheerio";import{convert as Be}from"html-to-text";import{marked as qe}from"marked";import We from"turndown";import{Parser as Ke,Builder as Ve}from"xml2js";import{GithubService as ze}from"@decaf-ts/integrations/devops/github";import{GitlabService as Qe}from"@decaf-ts/integrations/devops/gitlab";import{CryptoService as Je}from"@decaf-ts/crypto/integration/services/crypto";import{sign as Xe,verify as Ye,decodeJwtPayload as Ze}from"@decaf-ts/crypto/jwt";import{exec as et}from"node:child_process";import{Ssh2SftpService as tt}from"@decaf-ts/integrations/sftp";import{EventSource as ot}from"eventsource";import{Client as rt}from"pg";import"@mastra/core/storage";import"@mastra/memory";import"@mastra/libsql";import"@mastra/pg";var nt,it;m.REQUIRED,m.MIN,m.MIN_LENGTH,m.MAX,m.MAX_LENGTH,m.PATTERN,m.URL,m.STEP,m.DATE,m.EMAIL,m.PASSWORD,m.EQUALS,m.DIFF,m.LESS_THAN,m.LESS_THAN_OR_EQUAL,m.GREATER_THAN,m.GREATER_THAN_OR_EQUAL,(e=>{e.GRAPH="graph",e.NODE="graph.node",e.EDGE="graph.edge",e.PORT="graph.port",e.STATE="graph.state"})(nt||(nt={})),(e=>{e.INPUT="input",e.OUTPUT="output",e.CONNECTION="connection"})(it||(it={}));const at={};function st(e,t={}){let o=e.width??96,r=e.height??96;for(const n of e.sizeRules??[]){if("parameterCount"!==n.type)continue;const e=t[n.parameter]??0;e>0&&("width"===n.dimension?o+=e*n.perItem:r+=e*n.perItem)}return{width:o,height:r}}function dt(e,t){at[e]=t}function lt(e,t,o){const r=t?at[t]:void 0;return r?.color?r.color:e||"#64748b"}function ct(e,t,o){const r=t?at[t]:void 0;return r?.icon?r.icon:e||"ti-pointer"}const pt=["skip","passThroughFirstInput","emitDefaults"];function ut(e){return pt.includes(e)}var gt,ht,ft,yt;(e=>{e.PENDING="pending",e.PLANNING="planning",e.RUNNING="running",e.SUCCEEDED="succeeded",e.FAILED="failed",e.SKIPPED="skipped",e.CANCELLED="cancelled",e.CACHED="cached"})(gt||(gt={})),(e=>{e.IDLE="idle",e.RUNNING="running",e.BLOCKED="blocked",e.SUCCEEDED="succeeded",e.FAILED="failed",e.SKIPPED="skipped"})(ht||(ht={})),(e=>{e.NODE_ID="nodeId",e.WORKFLOW_ID="workflowId",e.RUN_ID="runId",e.USER="user",e.ROLES="roles",e.NAMESPACES="namespaces",e.ORGANIZATION="organization",e.IP="ip"})(ft||(ft={})),(e=>{e.WORKFLOW_STARTED="workflow.started",e.WORKFLOW_PLANNED="workflow.planned",e.WORKFLOW_COMPLETED="workflow.completed",e.WORKFLOW_FAILED="workflow.failed",e.WORKFLOW_CANCELLED="workflow.cancelled",e.WORKFLOW_SUSPENDED="workflow.suspended",e.WORKFLOW_RESUMED="workflow.resumed",e.NODE_QUEUED="node.queued",e.NODE_STARTED="node.started",e.NODE_OUTPUT="node.output",e.NODE_COMPLETED="node.completed",e.NODE_FAILED="node.failed",e.NODE_SKIPPED="node.skipped",e.NODE_CACHE_HIT="node.cacheHit",e.NODE_PINNED="node.pinned",e.NODE_UNPINNED="node.unpinned",e.NODE_STATE_CHANGED="node.stateChanged",e.EDGE_VALUE_ROUTED="edge.valueRouted",e.EDGE_STATE_CHANGED="edge.stateChanged",e.GRAPH_RUN_LOG="graph.run.log",e.LOOP_STARTED="loop.started",e.LOOP_ITERATION_STARTED="loop.iteration.started",e.LOOP_ITERATION_COMPLETED="loop.iteration.completed",e.LOOP_CONDITION_EVALUATED="loop.condition.evaluated",e.LOOP_COMPLETED="loop.completed",e.LOOP_LIMIT_REACHED="loop.limitReached",e.VALIDATION_STARTED="validation.started",e.VALIDATION_FAILED="validation.failed",e.VALIDATION_COMPLETED="validation.completed",e.STORE_READ="store.read",e.STORE_WRITE="store.write",e.STORE_DELETE="store.delete"})(yt||(yt={}));const mt={maxRequestBytes:4e6,maxConcurrentRuns:32,maxEventsPerRun:1e4,maxEventPayloadBytes:256e3,executionTimeoutMs:6e5,eventReplayWindowMs:3e5},bt=[yt.WORKFLOW_COMPLETED,yt.WORKFLOW_FAILED,yt.WORKFLOW_CANCELLED];function wt(e){return bt.includes(e)}function vt(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function xt(e){if(!e||"object"!=typeof e)return;const t=e.auth;return t&&"object"==typeof t&&!Array.isArray(t)?(e=>{if(!e)return;const t=vt(e.namespaces),o=vt(e.roles);if(!t&&!o)return;const r={};return t&&(r.namespaces=t),o&&(r.roles=o),r})(t):void 0}function It(e){const t=l.constr(e);if("function"==typeof t)return t;const o=e.constructor;return"function"==typeof o?o:e}function _t(e){if(null!=e)return"string"==typeof e?e:e+""}function Et(e,t,o){return _t(e?.props?.label??e?.props?.name)??_t(t?.name)??o??""}function At(e,t,o){const r=Ot(e,t);if(r?.model&&"function"==typeof r.model&&b.isModel(r.model))return r.model;const n=l.type(e,t);if("function"==typeof n&&b.isModel(n))return n;const i=l.getPropDesignTypes?.(e,t)?.designTypes||[];for(const e of i)if("function"==typeof e&&b.isModel(e))return e;const a=o?.[m.TYPE]?.customTypes||[];for(const e of a)if("function"==typeof e&&b.isModel(e))return e}function St(e,t){const o=[t,e.path??e.property].filter(Boolean).join(".");return{...e,path:o,children:e.children?.map(e=>St(e,o))}}function Rt(e){const t=It(e);return l.get(t,nt.NODE)}function Ot(e,t){const o=It(e);return l.get(o,l.key(nt.PORT,t+""))}function kt(e,t,o,r=new Set){const n=Ot(e,t);if(!n?.schema)return;const i=At(e,t,l.validationFor(e,t));if(!i)return;if(r.has(i))return[];const a=new Set(r);return a.add(e),a.add(i),Tt(i,a).filter(e=>e.direction===o)}function Ct(e,t,o=new Set){const r=Ot(e,t);if(!r)return;const n=l.validationFor(e,t),i=At(e,t,n);if(r.schema&&i)return;const a=b.uiElementOf(e,t)||void 0,s=b.uiDecorationOf(e,t,"uiprop"),d=l.type(e,t),c=_t(r.type??n?.[m.TYPE]?.customTypes?.[0]?.name??a?.props?.type??s?.type??d?.name),p=(r.expand||i&&!o.has(i))&&i?(()=>{const r=new Set(o);return r.add(e),r.add(i),Tt(i,r).map(e=>St(e,t))})():void 0;return{property:t,path:t,direction:r.direction,name:t,label:Et(a,s,t),type:c?.toLowerCase(),required:!!n?.[m.REQUIRED],hidden:!!b.uiIsHidden(e,t),designType:d?.name,element:a,prop:s,validation:n,graph:r,connectionRules:r.connectionRules,composite:!!p?.length,children:p,model:i?.name}}function Nt(e){return Tt(It(e))}function Tt(e,t=new Set){const o=l.properties(e)||[],r=[];for(const n of o){const o=n+"",i=Ot(e,o);if(i?.schema){const n=kt(e,o,i.direction,t);if(n){r.push(...n);continue}}const a=Ct(e,o,t);a&&r.push(a)}return r}function Pt(e){return e.flatMap(e=>e.children&&e.children.length?Pt(e.children):[e])}function Dt(e){const t=It(e),o=b.uiModelOf(t),r=Rt(t)||{},n=o?.tag||t.name,i=Nt(t),a=((e,t)=>{const o=t.portGroups||[],r=new Map(o.map(e=>[e.property,e])),n=[],i=l.properties(e)||[];for(const t of i){const o=t+"",i=Ot(e,o);if(!i?.schema)continue;if(!At(e,o,l.validationFor(e,o)))continue;const a=r.get(o);n.push(a?{...a,toggle:a.toggle??"all"}:{property:o,toggle:"all"})}for(const e of o)n.some(t=>t.property===e.property)||n.push(e);return n.length?n:void 0})(t,r),s=r.namespaces?.length?r.namespaces:(e=>{if(null==e)return[];let t,o=e;try{o=l.constr(e)}catch{o=e}try{t=l.get(o,"auth-namespace")}catch{t=void 0}return vt(t)??[]})(t),d=s.length?s:void 0;return{name:t.name,tag:n,kind:r.kind||n,category:r.category,color:r.color,effectiveColor:lt(r.color,r.category),group:r.group,height:r.height,icon:r.icon,effectiveIcon:ct(r.icon,r.category),labels:r.labels||[],maxChildren:r.maxChildren,minWidth:r.minWidth,width:r.width,shape:r.shape,cornerRadius:r.cornerRadius,sizeRules:r.sizeRules,props:o?.props,ui:o,graph:r,ports:i,portGroups:a,namespaces:d}}const jt=new Set,Lt=new Set;function Mt(e,t,o){return c.for(nt.NODE).define({decorator:(e,t,o)=>{const r={kind:t?.kind||e,...t};return t=>{const i=p(n(e,o),u(nt.NODE,r))(t);var a;return a=t,jt.add(a),i}},args:[e,t,o]}).apply()}function Gt(e,t){return c.for(nt.PORT).define({decorator:(e,t)=>(o,r)=>{const n={direction:e,...t};return p(g(l.key(nt.PORT,r),n))(o,r)},args:[e,t]}).apply()}function Ut(e){return Gt(it.INPUT,{...e,schema:!0})}function $t(e){return Gt(it.OUTPUT,{...e,schema:!0})}function Ft(e){return Gt(it.CONNECTION,e)}r.prototype.renderAsNode=(e,t,...o)=>Dt(e),l.nodes=(()=>[...jt]).bind(l),l.workflows=(()=>[...Lt]).bind(l);const Ht=["__proto__","prototype","constructor"];function Bt(e){return Ht.includes(e)}function qt(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function Wt(e){return null===e||"string"==typeof e||"number"==typeof e&&Number.isFinite(e)||"boolean"==typeof e}function Kt(e){return!!Wt(e)||(Array.isArray(e)?e.every(e=>Kt(e)):!!qt(e)&&Reflect.ownKeys(e).every(t=>"string"==typeof t&&!Bt(t)&&Kt(e[t])))}function Vt(e){if(void 0===e)return!1;if("number"==typeof e)return Number.isFinite(e);if("function"==typeof e)return!1;if(Kt(e))return!0;if(Array.isArray(e))return e.every(e=>Vt(e));if(qt(e)){const t=Reflect.ownKeys(e);for(const o of t){if("string"!=typeof o)return!1;if(Bt(o))return!1;if(!Vt(e[o]))return!1}return!0}return!1}function zt(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>zt(e));const t={};for(const[o,r]of Object.entries(e))t[o]=zt(r);return t}const Qt={string:"string",char:"string",text:"string",textarea:"string",radio:"string",select:"string",number:"number",integer:"number",float:"number",double:"number",decimal:"number",boolean:"boolean",bool:"boolean",checkbox:"boolean",array:"array",list:"array",set:"array",object:"object",model:"model",any:"any",unknown:"any",enum:"enum"},Jt={date:"date",datetime:"date-time","date-time":"date-time",duration:"duration"},Xt={string:"string",number:"number",boolean:"boolean",array:"array",object:"object",date:"date"};function Yt(e){return e?Qt[e.toLowerCase()]??"any":"any"}function Zt(e){if(e)return Jt[e.toLowerCase()]}function eo(e,t){const o=e[t];if(o&&"object"==typeof o)return o.value}function to(e,t){const o=eo(e,t);return"number"==typeof o&&Number.isFinite(o)?o:void 0}function oo(e,t,o){const r=e??{},n=(e=>{const t=eo(e,m.ENUM);if(Array.isArray(t)&&t.every(Wt))return t})(r);if(n)return{type:"enum",values:n};const i=(e=>{const t=e[m.TYPE],o=t?.customTypes?.[0],r="function"==typeof o?o.name:o?.name;if(r)return r})(r);if(i){const e=Xt[i.toLowerCase()];if(!e)return{type:"model",name:i};const t=Zt(e);return void 0!==t?{type:"string",format:t}:ro(e,r)}return o?{type:"model",name:o}:ro(t,r)}function ro(e,t){switch(Yt(e)){case"string":{const t=Zt(e);return void 0!==t?{type:"string",format:t}:{type:"string"}}case"number":{const o={type:"number"};e&&"integer"===e.toLowerCase()&&(o.integer=!0);const r=to(t,m.MIN),n=to(t,m.MAX);return void 0!==r&&(o.min=r),void 0!==n&&(o.max=n),o}case"boolean":return{type:"boolean"};case"array":return((e,t)=>{const o={type:"array",items:no(e,t)},r=to(e,m.MIN),n=to(e,m.MAX);return void 0!==r&&(o.minItems=r),void 0!==n&&(o.maxItems=n),o})(t,e);case"object":return{type:"object",properties:{}};case"enum":return{type:"enum",values:[]};case"model":return{type:"model",name:e??"any"};default:return{type:"any"}}}function no(e,t){if((e=>{const t=e[m.LIST];return!!t?.clazz?.length})(e))return{type:"model",name:io(e)};const o=eo(e,m.TYPE);if("string"==typeof o){const e=Yt(o);return"model"===e?{type:"model",name:o}:{type:e}}if(t&&"array"!==t){const e=Yt(t);return"model"===e?{type:"model",name:t}:{type:e}}return{type:"any"}}function io(e){const t=e[m.LIST],o=t?.clazz?.[0];if("function"!=typeof o)return"any";if(o.name)return o.name;try{const e=o();if("function"==typeof e&&e.name)return e.name}catch{return"any"}return"any"}function ao(e){return"workflow"===e.scope}function so(e){return"node"===e.scope}function lo(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"workflow"===t.scope?"string"==typeof t.port&&2===Reflect.ownKeys(t).length:"node"===t.scope&&"string"==typeof t.nodeId&&"string"==typeof t.port&&3===Reflect.ownKeys(t).length}function co(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e.mode;if("edge"===t)return 1===Reflect.ownKeys(e).length;if("literal"===t){const t=e.value;return 2===Object.keys(e).length&&Kt(t)}return"expression"===t&&2===Object.keys(e).length&&"string"==typeof e.expression}const po=["any","string","number","boolean","array","object","enum","model"];function uo(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&(e=>po.includes(e))(e.type)}function go(e,t={seen:[]}){if(t.seen.includes(e))throw new S(`Document '${(e=>{const t=e?.id;return"string"==typeof t?t:"<unnamed document>"})(e)}' contains a loop body that references itself (cyclic document)`);if("string"!=typeof e.id||!e.id)throw new S("Document 'id' is required and must be a non-empty string");if("string"!=typeof e.name||!e.name)throw new S("Document 'name' is required and must be a non-empty string");const o=new Set;for(const t of[...e.inputs,...e.outputs]){if("string"!=typeof t.id||!t.id)throw new S("Workflow port 'id' is required and must be a non-empty string");if(o.has(t.id))throw new S(`Workflow port '${t.id}' is declared more than once; workflow port ids must be unique`);if(void 0!==t.schema&&!uo(t.schema))throw new S(`Workflow port '${t.id}' schema must be a valid GraphValueSchema`);o.add(t.id)}const r={seen:[...t.seen,e]},n=new Set;for(const t of e.nodes)ho(t,n);for(const t of e.nodes)t.loop&&fo(t,t.loop,r),t.errorBoundary&&yo(t,t.errorBoundary,r);const i=new Set;for(const t of e.edges)bo(t,i);for(const t of e.edges)wo(t.source,0,o,n,`Edge '${t.id}' source`),wo(t.target,0,o,n,`Edge '${t.id}' target`);if(void 0!==e.settings&&!Vt(e.settings))throw new S("Document settings must be JSON-safe (a map of JSON-safe values)");if(void 0!==e.metadata&&!Vt(e.metadata))throw new S("Document metadata must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed");if(void 0!==e.ui&&!Vt(e.ui))throw new S("Document ui must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed")}function ho(e,t){if("string"!=typeof e.id||!e.id)throw new S("Node 'id' is required and must be a non-empty string");if(t.has(e.id))throw new S(`Node id '${e.id}' is declared more than once; node ids must be unique`);if("string"!=typeof e.kind||!e.kind)throw new S(`Node '${e.id}' must declare a non-empty string 'kind'`);if(void 0===e.parameters||null===e.parameters)throw new S(`Node '${e.id}' parameters must be present (an empty object when there are none)`);if(t.add(e.id),e.inputBindings)for(const[t,o]of Object.entries(e.inputBindings)){if(Bt(t))throw new S(`Node '${e.id}' input binding key '${t}' is not allowed (unsafe prototype-pollutant key)`);if(!co(o))throw new S(`Node '${e.id}' input binding for '${t}' must be a valid GraphInputBinding (edge, literal, or expression)`);if("literal"===o.mode&&!Vt(o.value))throw new S(`Node '${e.id}' literal binding for '${t}' must contain JSON-safe values`);if("expression"===o.mode&&!o.expression)throw new S(`Node '${e.id}' expression binding for '${t}' must contain a non-empty expression`)}if(e.outputBindings)for(const[t,o]of Object.entries(e.outputBindings)){if(Bt(t))throw new S(`Node '${e.id}' output binding key '${t}' is not allowed (unsafe prototype-pollutant key)`);if(!o||"object"!=typeof o||Array.isArray(o))throw new S(`Node '${e.id}' output binding for '${t}' must be an object with enabled and alias settings`)}if(!Vt(e.parameters))throw new S(`Node '${e.id}' parameters must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`);if(void 0!==e.state){if(!e.state||"object"!=typeof e.state||Array.isArray(e.state))throw new S(`Node '${e.id}' state must be an object when present`);if(!Vt(e.state))throw new S(`Node '${e.id}' state must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`)}}function fo(e,t,o){if(!t.body||"object"!=typeof t.body)throw new S(`Node '${e.id}' loop configuration requires a body document`);if(go(t.body,o),!(void 0===t.maxIterations||Number.isFinite(t.maxIterations)&&t.maxIterations>0))throw new S(`Node '${e.id}' loop maxIterations must be a positive number`);if(void 0!==t.timeoutMs&&("number"!=typeof t.timeoutMs||0>=t.timeoutMs))throw new S(`Node '${e.id}' loop timeoutMs must be a positive number in milliseconds`);if(void 0!==t.concurrency&&("number"!=typeof t.concurrency||0>=t.concurrency))throw new S(`Node '${e.id}' loop concurrency must be a positive number`);for(const o of[t.inputMappings,t.outputMappings])if(o)for(const[t,r]of Object.entries(o)){if(Bt(t))throw new S(`Node '${e.id}' loop mapping key '${t}' is not allowed (unsafe prototype-pollutant key)`);mo(r,e.id,t)}}function yo(e,t,o){if(!t.try||"object"!=typeof t.try)throw new S(`Node '${e.id}' error-boundary configuration requires a try body document`);go(t.try,o);for(const[r,n]of[["catch",t.catch],["finally",t.finally]])if(void 0!==n){if(!n||"object"!=typeof n)throw new S(`Node '${e.id}' error-boundary ${r} body must be a document`);go(n,o)}}function mo(e,t,o){if(!e||"object"!=typeof e)throw new S(`Node '${t}' loop mapping '${o}' must reference a workflow port, node port, literal, or expression`);switch(e.source){case"workflow":if("string"!=typeof e.port||!e.port)throw new S(`Node '${t}' loop mapping '${o}' referencing a workflow must reference a port identifier`);break;case"node":if("string"!=typeof e.nodeId||!e.nodeId||"string"!=typeof e.port||!e.port)throw new S(`Node '${t}' loop mapping '${o}' referencing a node must reference a node id and a port`);break;case"literal":if(!Vt(e.value))throw new S(`Node '${t}' loop mapping '${o}' literal references must be JSON-safe values`);break;case"expression":if("string"!=typeof e.expression||!e.expression)throw new S(`Node '${t}' loop mapping '${o}' expression references must be non-empty expressions`);break;default:throw new S(`Node '${t}' loop mapping '${o}' must use a workflow, node, literal, or expression reference source`)}}function bo(e,t){if("string"!=typeof e.id||!e.id)throw new S("Edge 'id' is required and must be a non-empty string");if(t.has(e.id))throw new S(`Edge id '${e.id}' is declared more than once; edge ids must be unique`);if(!lo(e.source))throw new S(`Edge '${e.id}' source endpoint is not a valid GraphEndpoint`);if(!lo(e.target))throw new S(`Edge '${e.id}' target endpoint is not a valid GraphEndpoint`);if("data"!==e.type&&"connection"!==e.type)throw new S(`Edge '${e.id}' type '${e.type+""}' is not a valid edge type (data or connection are allowed)`);if(t.add(e.id),!Vt(e))throw new S(`Edge '${e.id}' contains values that are not JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys, or unsafe prototype keys are not allowed`)}function wo(e,t,o,r,n){if(ao(e)){if(!o.has(e.port))throw new S(`${n} references workflow port '${e.port}' which is not declared on the document`)}else if(so(e)){if(!r.has(e.nodeId))throw new S(`${n} references node '${e.nodeId}' which is not part of the document`);if("string"!=typeof e.port||!e.port)throw new S(n+" node endpoints must reference a non-empty port identifier")}}const vo=["expression","template"],xo=["javascript","typescript","json","text"];function Io(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return!(!(e=>vo.includes(e))(t.mode)||"string"!=typeof t.expression||!t.expression||void 0!==t.language&&!(e=>xo.includes(e))(t.language)||void 0!==t.metadata&&!Kt(t.metadata))}function _o(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.id&&"string"==typeof t.name&&Array.isArray(t.inputs)&&Array.isArray(t.outputs)&&Array.isArray(t.nodes)&&Array.isArray(t.edges)}function Eo(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.type&&(void 0===t.required||"boolean"==typeof t.required)&&(void 0===t.displayName||"string"==typeof t.displayName)&&(void 0===t.allowedOperations||Array.isArray(t.allowedOperations)&&t.allowedOperations.every(e=>"string"==typeof e))}const Ao=["trigger","loop","branching","stateful","retryable","cancellable","parallel","resource"];function So(e){return Ao.includes(e)}function Ro(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.kind&&"object"==typeof t.display&&Array.isArray(t.inputs)&&Array.isArray(t.outputs)&&Array.isArray(t.parameters)}function Oo(e){if(!Ro(e))throw new S("Graph node manifest does not conform to the required shape");if(!Vt(e))throw new S("Graph node manifest contains values that are not JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys or unsafe prototype keys are not allowed on manifests")}function ko(e){return Oo(e),zt(e)}function Co(e){if(!Ro(e))throw new S("Serialized graph node manifest does not conform to the required shape");return zt(e)}const No=["loadOptions","listSearch","resourceLocator","resourceMapping","validateParameter","action"];function To(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.name&&(e=>No.includes(e))(t.type)&&(void 0===t.parameter||"string"==typeof t.parameter)&&(void 0===t.dependencies||Array.isArray(t.dependencies)&&t.dependencies.every(e=>"string"==typeof e))}function Po(e){const t=e.element?.props?.value,o=t??e.prop?.value??e.validation?.defaultValue;if(void 0!==o&&"function"!=typeof o&&Vt(o))try{return JSON.parse(JSON.stringify(o))}catch{return}}function Do(e){if(e.type&&e.type in Jt)return{type:"string",format:Jt[e.type]};const t=(e=>{for(const t of[e.graph?.type,e.element?.props?.type,e.prop?.type])if("string"==typeof t&&"any"!==Yt(t))return t})(e);return t?oo((e=>{if(!e)return;const t=Object.entries(e).filter(([e])=>e!==m.TYPE);return Object.fromEntries(t)})(e.validation),t):oo(e.validation,e.type,e.model)}function jo(e){const t={};for(const[o,r]of Object.entries(e.graph?.metadata??{}))Vt(r)&&(t[o]=JSON.parse(JSON.stringify(r)));return Object.keys(t).length?t:void 0}function Lo(e){switch(e){case"output":return"output";case"connection":return"connection";default:return"input"}}function Mo(e){const t=e.graph?.handle;return"connection"!==e.direction&&"string"==typeof t&&t?t:e.path??e.property}const Go=["top","bottom","left","right"],Uo=["start","center","end"];function $o(e,t){const o={id:Mo(e),label:e.label,direction:Lo(e.direction),schema:Do(e)};e.required&&(o.required=!0),e.hidden&&(o.hidden=!0);const r=e.graph?.category;"string"==typeof r&&(o.category=r);const n=(e=>{const t=e.graph?.zone;if(!t||"object"!=typeof t||Array.isArray(t))return;const o=t,r=o.side;if("string"!=typeof r||!Go.includes(r))return;const n={side:r},i=o.align;"string"==typeof i&&Uo.includes(i)&&(n.align=i);const a=o.order;return"number"==typeof a&&Number.isFinite(a)&&(n.order=a),n})(e);n&&(o.zone=n),!0===e.graph?.userControlled&&(o.configurable=!0);const i=e.graph?.handle;"string"==typeof i&&(o.handle=i);const a=Jo(e.graph?.connectionRules)??t;a&&(o.connectionPolicy=a);const s=(e=>{const t=e.element;if(!t||!Vt(t))return;const o=t.tag;if("string"!=typeof o)return;const r=t.props;return{tag:o,serialize:!0===t.serialize,props:r&&"object"==typeof r&&!Array.isArray(r)?zt(r):{}}})(e);s&&(o.element=s);const d=jo(e);return d&&(o.metadata=d),o}function Fo(e){const t={type:"string",id:Mo(e),label:e.label,required:e.required};if(e.hidden)return((e,t)=>{const o={...t,type:"hidden"},r=Po(e);return void 0!==r&&(o.defaultValue=r),Ho(o)})(e,t);const o=Po(e);void 0!==o&&(t.defaultValue=o);const r=(e=>{const t=e.element?.props?.placeholder??e.prop?.placeholder;return"string"==typeof t?t:void 0})(e);r&&(t.placeholder=r);const n=jo(e);if(n&&(t.metadata=n),(e=>{const t=Wo(e);return"code"===t||"code-editor"===t})(e))return Ho({...t,type:"code",language:zo(e)});const i=Do(e);switch(i.type){case"number":{const o={...t,type:"number",integer:i.integer,min:i.min,max:i.max},r=qo(e.validation?.step);return void 0!==r&&(o.step=r),Ho(o)}case"boolean":return Ho({...t,type:"boolean"});case"enum":return Ho({...t,type:"options",options:i.values.map(e=>({value:e,label:e+""}))});case"array":{const e={...t,type:"collection"};return void 0!==i.maxItems&&(e.maxItems=i.maxItems),Ho(e)}case"object":case"model":return Ho({...t,type:"object"});default:return Ho({...t,type:"string",multiline:!!Ko(e)||void 0,pattern:Bo(e.validation?.pattern),minLength:qo(e.validation?.minlength),maxLength:qo(e.validation?.maxlength)})}}function Ho(e){const t=e;for(const e of Object.keys(t))void 0===t[e]&&delete t[e];return e}function Bo(e){const t=e?.value;return"string"==typeof t?t:void 0}function qo(e){const t=e?.value;return"number"==typeof t&&Number.isFinite(t)?t:void 0}function Wo(e){const t=e.element?.tag;return"string"==typeof t&&t?t:void 0}function Ko(e){return"textarea"===Wo(e)||"textarea"===(e=>{const t=e.element?.props?.type;return"string"==typeof t?t:void 0})(e)}const Vo=["javascript","typescript","json","text"];function zo(e){const t=e.element?.props?.language;return"string"==typeof t&&Vo.includes(t)?t:"javascript"}function Qo(e,t){const o={name:t.name??e.name},r=e.graph?.metadata?.description??void 0;"string"==typeof r&&r&&(o.description=r);const n=t.category??e.category;"string"==typeof n&&n&&(o.category=n),"string"==typeof e.group&&e.group&&(o.group=e.group),Array.isArray(e.labels)&&(o.labels=e.labels.slice());const i=((e,t)=>{if(t.icon)return t.icon;const o=e.effectiveIcon??e.icon;return"string"==typeof o?{type:"catalogue",name:o}:{type:"catalogue",name:"ph:circuitry"}})(e,t);return i&&(o.icon=i),"string"==typeof e.color&&e.color&&(o.color=e.color),"number"==typeof e.width&&Number.isFinite(e.width)&&(o.width=e.width),"number"==typeof e.minWidth&&Number.isFinite(e.minWidth)&&(o.minWidth=e.minWidth),"number"==typeof e.height&&Number.isFinite(e.height)&&(o.height=e.height),"string"==typeof e.shape&&(o.shape=e.shape),"number"==typeof e.cornerRadius&&Number.isFinite(e.cornerRadius)&&(o.cornerRadius=e.cornerRadius),Array.isArray(e.sizeRules)&&(o.sizeRules=e.sizeRules),o}function Jo(e){if(!e)return;const t=e,o={};"boolean"==typeof t.allowSelf&&(o.allowSelf=t.allowSelf),"boolean"==typeof t.allowMultiple&&(o.allowMultiple=t.allowMultiple);const r=t.allowedKinds;Array.isArray(r)&&r.every(e=>"string"==typeof e)&&(o.allowedNodeKinds=r);const n=t.blockedKinds;Array.isArray(n)&&n.every(e=>"string"==typeof e)&&(o.blockedNodeKinds=n);const i=t.allowedPortCategories;Array.isArray(i)&&i.every(e=>"string"==typeof e)&&(o.allowedPortCategories=i);const a=t.maxConnections;return"number"==typeof a&&Number.isFinite(a)&&(o.maxConnections=a),Object.keys(o).length?o:void 0}function Xo(e,t={}){const o="function"==typeof e?e:e.constructor;if(!Rt(o))throw new S(`Node '${o?.name??e+""}' is not decorated with @node and cannot produce a manifest`);const r=Dt(o),n=Pt(Nt(o)),i=[],a=[],s=[],d=[],l=Jo(r.graph?.connectionRules);for(const e of n)("connection"===e.direction?s:"output"===e.direction?a:i).push($o(e,l)),"input"===e.direction&&d.push(Fo(e));const c={kind:t.kind??r.kind??r.name,display:Qo(r,t),inputs:i,outputs:a,parameters:d};return s.length&&(c.connections=s),r.namespaces?.length&&(c.namespaces=r.namespaces.slice()),Oo(c),c}var Yo,Zo;(e=>{e.READABILITY="readability",e.COMPACTNESS="compactness",e.BALANCED="balanced"})(Yo||(Yo={})),(e=>{e.TIGHT="tight",e.NORMAL="normal",e.COMFORTABLE="comfortable"})(Zo||(Zo={})),Zo.TIGHT,Zo.NORMAL,Zo.COMFORTABLE,Yo.READABILITY,Zo.COMFORTABLE,Yo.COMPACTNESS,Zo.TIGHT,Yo.BALANCED,Zo.NORMAL;let er=class extends j{constructor(e){super(e)}};k([N({type:String,generated:!1}),h("Unique graph run id"),i("ngx-decaf-crud-field",{label:"graph.run.id.label",readonly:!0}),C("design:type",String)],er.prototype,"runId",void 0),k([T(),w(),P(),h("Workflow document id the run executes"),a("workflowId"),i("ngx-decaf-crud-field",{label:"graph.run.workflowId.label"}),C("design:type",String)],er.prototype,"workflowId",void 0),k([T(),h("Owning user; absent for anonymous callers"),i("ngx-decaf-crud-field",{label:"graph.run.owner.label"}),C("design:type",String)],er.prototype,"owner",void 0),k([T(),w(),v(String),P(),h("Current run lifecycle status"),a("status"),i("ngx-decaf-crud-field",{label:"graph.run.status.label",readonly:!0}),C("design:type",String)],er.prototype,"status",void 0),k([T(),h("Fingerprint of the executed document"),i("ngx-decaf-crud-field",{label:"graph.run.fingerprint.label",readonly:!0}),C("design:type",String)],er.prototype,"documentFingerprint",void 0),k([T(),f(),h("Workflow input values keyed by input port id"),C("design:type",Object)],er.prototype,"inputs",void 0),k([T(),f(),h("Execution result, present on successful completion"),C("design:type",Object)],er.prototype,"result",void 0),k([T(),f(),h("Structured error payload, present on failure"),C("design:type",Object)],er.prototype,"error",void 0),k([x(),T(),h("Run creation timestamp"),C("design:type",Date)],er.prototype,"createdAt",void 0),k([x(),T(),h("Execution start timestamp, once it has started"),C("design:type",Date)],er.prototype,"startedAt",void 0),k([x(),T(),h("Terminal-state timestamp, once the run has finished"),C("design:type",Date)],er.prototype,"finishedAt",void 0),er=k([s("ngx-decaf-list-item",{icon:"ti-player-play"}),n("ngx-decaf-crud-form"),h("Persistable graph run lifecycle record"),D("graph_run"),I(),C("design:paramtypes",[Object])],er);let tr=class extends j{constructor(e){super(e)}};k([N({type:String,generated:!1}),C("design:type",String)],tr.prototype,"workflowId",void 0),k([T(),C("design:type",String)],tr.prototype,"name",void 0),k([T(),C("design:type",Object)],tr.prototype,"document",void 0),k([T(),C("design:type",String)],tr.prototype,"owner",void 0),k([T(),C("design:type",Object)],tr.prototype,"snapshot",void 0),k([L(),C("design:type",Date)],tr.prototype,"createdAt",void 0),tr=k([D("graph_workflow"),I(),C("design:paramtypes",[Object])],tr);let or=class extends j{constructor(e){super(e)}};k([N({type:String,generated:!1}),C("design:type",String)],or.prototype,"kind",void 0),k([T(),P(),C("design:type",String)],or.prototype,"name",void 0),k([T(),P(),C("design:type",String)],or.prototype,"category",void 0),k([T(),C("design:type",String)],or.prototype,"group",void 0),k([T(),C("design:type",String)],or.prototype,"description",void 0),k([T(),C("design:type",Object)],or.prototype,"manifest",void 0),k([L(),C("design:type",Date)],or.prototype,"createdAt",void 0),or=k([D("graph_node"),I(),C("design:paramtypes",[Object])],or),dt("Trigger",{color:"#3b82f6",icon:"ti-bolt"}),dt("Flow Control",{color:"#f59e0b",icon:"ti-arrows-split-2"}),dt("Utility",{color:"#0d9488",icon:"ti-tool"}),dt("Loop",{color:"#eab308",icon:"ti-repeat"}),dt("Workflow",{color:"#f97316",icon:"ti-sitemap"}),dt("Pipeline",{color:"#0ea5e9",icon:"ti-git-merge"}),dt("Node",{color:"#8b5cf6",icon:"ti-point-filled"}),dt("Agent",{color:"#7c3aed",icon:"ti-robot"}),dt("Data",{color:"#8b5cf6",icon:"ti-table"}),dt("IO",{color:"#0ea5e9",icon:"ti-world-www"}),dt("Storage",{color:"#0f766e",icon:"ti-database"}),dt("DevOps",{color:"#475569",icon:"ti-terminal-2"}),dt("Comms",{color:"#d946ef",icon:"ti-message-circle"}),dt("model",{color:"#3b82f6",icon:"ti-cpu"}),dt("memory",{color:"#10b981",icon:"ti-database"}),dt("workspace",{color:"#f59e0b",icon:"ti-folder"}),dt("tools",{color:"#0ea5e9",icon:"ti-tools"}),dt("hooks",{color:"#f97316",icon:"ti-webhook"}),dt("skill",{color:"#8b5cf6",icon:"ti-bulb"}),dt("sandbox",{color:"#14b8a6",icon:"ti-box"}),dt("scorers",{color:"#ec4899",icon:"ti-star"}),dt("embedding",{color:"#6366f1",icon:"ti-vector"});const rr=new Set;function nr(e,t){return e.config[t]}function ir(e){return Array.isArray(e)?e.map(e=>e+"").join(", "):e+""}(()=>{const t=[{key:ft.NODE_ID,shouldInclude:e=>null!=nr(e,ft.NODE_ID),render:e=>nr(e,ft.NODE_ID)+""},{key:ft.WORKFLOW_ID,shouldInclude:e=>null!=nr(e,ft.WORKFLOW_ID),render:e=>nr(e,ft.WORKFLOW_ID)+""},{key:ft.RUN_ID,shouldInclude:e=>null!=nr(e,ft.RUN_ID),render:e=>nr(e,ft.RUN_ID)+""},{key:ft.USER,shouldInclude:e=>null!=nr(e,ft.USER),render:e=>nr(e,ft.USER)+""},{key:ft.ROLES,shouldInclude(e){const t=nr(e,ft.ROLES);return Array.isArray(t)&&t.length>0},render:e=>ir(nr(e,ft.ROLES))},{key:ft.NAMESPACES,shouldInclude(e){const t=nr(e,ft.NAMESPACES);return Array.isArray(t)&&t.length>0},render:e=>ir(nr(e,ft.NAMESPACES))},{key:ft.ORGANIZATION,shouldInclude:e=>null!=nr(e,ft.ORGANIZATION),render:e=>nr(e,ft.ORGANIZATION)+""},{key:ft.IP,shouldInclude:e=>null!=nr(e,ft.IP),render:e=>nr(e,ft.IP)+""}];for(const o of t)rr.has(o.key)||(e.register(o),rr.add(o.key))})();const ar="$workflow",sr="local",dr="GRAPH_LOCAL_UNSUPPORTED_NODE_KIND",lr=4,cr=100,pr=1e3,ur=1e3,gr=1e4,hr=3e4,fr=3e5,yr=10485760,mr=5,br=6e4,wr=3e4,vr=1048576,xr=10,Ir=1e3,_r=1e4,Er=1048576,Ar=1e4,Sr="graph.pinnable";var Rr,Or;(e=>{e.MANUAL="manual",e.AUTOMATIC="automatic",e.DISABLED="disabled"})(Rr||(Rr={})),(e=>{e.TRUTHY="truthy",e.FALSY="falsy",e.EQUALS="equals",e.NOT_EQUALS="notEquals",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.EXISTS="exists",e.CUSTOM="custom"})(Or||(Or={}));const kr={FOREACH:"core.loop.foreach",WHILE:"core.loop.while",UNTIL:"core.loop.until"};class Cr extends R{constructor(e,t="GRAPH_EXECUTION_ERROR",o){super(e,Cr.name,500),this.graphCode=t,this.details=o,this.name=this.constructor.name}}class Nr extends Cr{constructor(e){super("Graph workflow contains an unsupported cycle","GRAPH_CYCLE_ERROR",e)}}class Tr extends Cr{constructor(e,t){super(e,"GRAPH_INPUT_ERROR",t)}}class Pr extends Cr{constructor(e,t){super(e,"GRAPH_LOOP_LIMIT_ERROR",t)}}class Dr extends Cr{constructor(e,t){super(e,"GRAPH_PINNING_ERROR",t)}}class jr extends Cr{constructor(e,t){super(e,"GRAPH_PORT_ERROR",t)}}class Lr extends Cr{constructor(e,t){super(e,"GRAPH_STORE_ERROR",t)}}class Mr extends Cr{constructor(e,t){super(e,"GRAPH_TOPOLOGY_ERROR",t)}}class Gr extends Cr{constructor(e){super("Break signal","GRAPH_BREAK_SIGNAL",{value:e}),this.isBreakSignal=!0,this.name="GraphBreakSignal"}}class Ur extends Cr{constructor(e){super(`Graph run '${e}' was cancelled`,"GRAPH_RUN_CANCELLED",{runId:e}),this.name=Ur.name}}class $r extends S{constructor(e){super(`Graph workflow document rejected with ${e.length} issue(s): ${e.map(e=>`${e.code} at ${e.path} (${e.message})`).join("; ")}`),this.name=$r.name,this.issues=e}}class Fr{constructor(){this.observers=new Set}observe(e){return this.observers.add(e),()=>this.unObserve(e)}unObserve(e){this.observers.delete(e)}async updateObservers(e){await Promise.all(Array.from(this.observers).map(async t=>{try{await Promise.resolve(t.refresh(e))}catch{}}))}}class Hr{constructor(){this.sequence=0}create(e){return{...e,id:this.createEventId(),sequence:++this.sequence,timestamp:new Date}}createEventId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new Cr("Cannot generate a graph event id: crypto.randomUUID is unavailable in this runtime","GRAPH_EVENT_ID_ERROR",{runtime:typeof globalThis.crypto});return e.randomUUID()}}function Br(e){if("string"!=typeof e)return;const t=e.trim();if(!t)return;const o=t.split(".");if(3!==o.length)return;const r=o[0].trim(),n=o[2].trim(),i=o[1].split(",").map(e=>e.trim()).filter(e=>e.length>0);return r&&n&&0!==i.length?{organization:r,departments:i,role:n}:void 0}function qr(e){return`${e.organization}.${e.departments.join(",")}.${e.role}`}function Wr(e){if(!e||"string"!=typeof e.namespace||!e.parts)return!1;const t=Br(e.namespace);return!!t&&qr(t)===qr(e.parts)}function Kr(e,t){const o="string"==typeof e?e.trim():"";if(o){if(t)for(const e of t)if(e&&e.namespace===o&&Wr(e))return e.parts;return Br(o)}}function Vr(e,t,o={},r){const n=Kr(e,r),i=Kr(t,r);return!(!n||!i)&&n.organization===i.organization&&n.role===i.role&&("exact"===(o.mode??"inherit")?n.departments.length===i.departments.length&&n.departments.every((e,t)=>e===i.departments[t]):n.departments.length<=i.departments.length&&n.departments.every((e,t)=>e===i.departments[t]))}function zr(e,t,o={},r){return e.filter(e=>!t.some(t=>Vr(t,e,o,r)))}function Qr(e){return e.filter(e=>void 0===Br(e))}function Jr(e,t){const o=new Set;for(const r of e){const e=Kr(r,t);e&&o.add(e.role)}return[...o]}function Xr(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}function Yr(e,t){try{const o=e.cache;if(o&&void 0!==o[t]&&null!==o[t])return o[t]}catch{}try{return e.get(t)}catch{return}}function Zr(e){if(!e)return{};const t={},o=e.user;"string"==typeof o&&o&&(t.user=o);const r=e.organization;"string"==typeof r&&r&&(t.organization=r);const n=e.ip;"string"==typeof n&&n&&(t.ip=n);const i=Xr(e.roles);i&&(t.roles=i);const a=Xr(e.namespaces);return a&&(t.namespaces=a,t.namespaceCache=tn(a)),t}function en(e){return e?Zr({user:Yr(e,"user"),organization:Yr(e,"organization"),ip:Yr(e,"ip"),roles:Yr(e,"roles"),namespaces:Yr(e,"namespaces")}):{}}function tn(e){const t=[];for(const o of e){const e=Br(o);e&&t.push({namespace:o,parts:e})}return t}function on(...e){const t={};for(const o of e)o&&(void 0!==o.user&&(t.user=o.user),void 0!==o.organization&&(t.organization=o.organization),void 0!==o.ip&&(t.ip=o.ip),void 0!==o.roles&&(t.roles=o.roles),void 0!==o.namespaces&&(t.namespaces=o.namespaces),void 0!==o.namespaces?t.namespaceCache=o.namespaceCache??tn(o.namespaces):void 0!==o.namespaceCache&&(t.namespaceCache=o.namespaceCache));return t}class rn{constructor(e={}){this.options=e}get enabled(){return!0===this.options.enabled}validate(e,o,r,n){if(!this.enabled)return;const i=n??this.options.logger??t.for("GraphAuth"),a=e.id||e.name||o.workflowId,s=xt(e.metadata);this.assertGranted(`workflow '${a}'`,s?.namespaces??[],r,s?.roles??[],i);for(const e of o.nodes)this.assertGranted(`node '${e.id}'`,e.manifest.namespaces??[],r,[],i)}validateWorkflowRead(e,o,r){if(!this.enabled)return;const n=r??this.options.logger??t.for("GraphAuth"),i=xt(e.metadata);this.assertGranted(`workflow '${e.id||e.name}'`,i?.namespaces??[],o,i?.roles??[],n)}assertGranted(e,t,o,r,n){const i=o.namespaces??[],a=zr(t,i,this.options.match,o.namespaceCache),s=Jr(i,o.namespaceCache),d=r.filter(e=>!s.includes(e));if(0===a.length&&0===d.length)return;const l=[...new Set([...Qr(t),...Qr(i)])],c=[];throw a.length&&c.push("namespace(s) "+a.join(", ")),d.length&&c.push("role(s) "+d.join(", ")),n.warn(`Graph access denied for ${e} for user ${o.user??"anonymous"}: missing ${c.join(" and ")}${l.length?`; malformed namespace(s) ${l.join(", ")} failed closed`:""}`),new M(`Access to ${e} requires ${c.join(" and ")}`)}}class nn{constructor(e){this.services=e}async resolve(e,t,o,r,n){if(!e){if(o)throw new Cr(`${r} node requires a credential of type '${t}'`,"GRAPH_CREDENTIAL_MISSING",{credentialType:t});return}if(e.credentialType&&e.credentialType!==t)throw new Cr(`${r} node credential has type '${e.credentialType}' but requires '${t}'`,"GRAPH_CREDENTIAL_TYPE_MISMATCH",{credentialId:e.credentialId,credentialType:e.credentialType});let i;try{i=await this.services.credentialService.getCredential(e.credentialId,n)}catch(t){throw new Cr(`${r} node credential '${e.credentialId}' could not be resolved`,"GRAPH_CREDENTIAL_NOT_FOUND",{credentialId:e.credentialId,cause:t instanceof Error?t.message:t+""})}if(!1===i.enabled)throw new Cr(`${r} node credential '${e.credentialId}' is disabled`,"GRAPH_CREDENTIAL_DISABLED",{credentialId:e.credentialId});if((e=>{if(!e)return!1;const t=e instanceof Date?e.getTime():Date.parse(e);return Number.isFinite(t)&&Date.now()>=t})(i.expiresAt))throw new Cr(`${r} node credential '${e.credentialId}' has expired`,"GRAPH_CREDENTIAL_EXPIRED",{credentialId:e.credentialId});if(i.credentialType&&i.credentialType!==t)throw new Cr(`${r} node credential '${e.credentialId}' has type '${i.credentialType}' but requires '${t}'`,"GRAPH_CREDENTIAL_TYPE_MISMATCH",{credentialId:e.credentialId,credentialType:i.credentialType});const a=this.secretServiceFor(i.provider,r),s=await a.retrieve(i.secretName,{},n);return await(this.services.credentialService.markCredentialUsed?.(e.credentialId,n).catch(()=>{})),(e=>{if(null!=e)return"string"==typeof e?e:e instanceof Uint8Array?(new TextDecoder).decode(e):"object"!=typeof e||Array.isArray(e)?e+"":e})(s)}secretServiceFor(e,t){if("model"===e)return this.services.modelSecretService;if("filesystem"===e){if(!this.services.fsSecretService)throw new Cr(`${t} node credential provider '${e}' requires a configured filesystem secret service`,"GRAPH_CREDENTIAL_SERVICE_UNAVAILABLE",{provider:e});return this.services.fsSecretService}throw new Cr(`${t} node credential provider '${e}' is not supported`,"GRAPH_CREDENTIAL_PROVIDER_UNSUPPORTED",{provider:e})}}async function an(e,t,o,r,n,i="credentialRef"){const a=t?.[i];if(!a){if(!r)return;throw new Cr(`${n} node requires a credential of type '${o}'`,"GRAPH_CREDENTIAL_MISSING",{credentialType:o})}const s=e?.engine,d=s?.nodeCredentials;if(!d)throw new Cr(n+" node requires ctx-bound credential services, but the engine has none configured","GRAPH_CREDENTIAL_SERVICE_UNAVAILABLE",{node:n,credentialType:o});return d.resolve(a,o,r,n,e)}class sn{constructor(e){this.baseOptions=e,this.inner=t.for("GraphRun").for(this.attributeConfig(e))}attributeConfig(e){return{[ft.NODE_ID]:e.nodeId,[ft.WORKFLOW_ID]:e.workflowId,[ft.RUN_ID]:e.runId,[ft.USER]:e.user??null,[ft.ROLES]:e.roles,[ft.NAMESPACES]:e.namespaces,[ft.ORGANIZATION]:e.organization,[ft.IP]:e.ip}}emit(e,t,o){const r="string"==typeof t?t:t instanceof Error?t.message:t+"",n={level:e,message:r,timestamp:(new Date).toISOString(),runId:this.baseOptions.runId,workflowId:this.baseOptions.workflowId,nodeId:this.baseOptions.nodeId,user:this.baseOptions.user??null};void 0!==this.baseOptions.roles&&(n.roles=this.baseOptions.roles),void 0!==this.baseOptions.namespaces&&(n.namespaces=this.baseOptions.namespaces),void 0!==this.baseOptions.organization&&(n.organization=this.baseOptions.organization),void 0!==this.baseOptions.ip&&(n.ip=this.baseOptions.ip),void 0!==o&&(n.payload=o),this.baseOptions.forward({type:yt.GRAPH_RUN_LOG,payload:n}).catch(()=>{}),{benchmark:(e,t)=>this.inner.benchmark(e,t),fatal:(e,t)=>this.inner.fatal(e,t),critical:(e,t)=>this.inner.critical(e,t),silly:(e,t)=>this.inner.silly(e,t),trace:(e,t)=>this.inner.trace(e,t),verbose:(e,t)=>this.inner.verbose(e,t),info:(e,t)=>this.inner.info(e,t),warn:(e,t)=>this.inner.warn(e,t),error:(e,t)=>this.inner.error(e,t),debug:(e,t)=>this.inner.debug(e,t)}[e](r,o)}benchmark(e,t){this.emit("benchmark",e,t)}fatal(e,t,o){this.emit("fatal",e,t??o)}critical(e,t,o){this.emit("critical",e,t??o)}silly(e,t,o){this.emit("silly",e,"object"==typeof t?t:o)}trace(e,t){this.emit("trace",e,t)}verbose(e,t,o){this.emit("verbose",e,"object"==typeof t?t:o)}info(e,t){this.emit("info",e,t)}error(e,t,o){this.emit("error",e,t??o)}warn(e,t){this.emit("warn",e,t)}debug(e,t){this.emit("debug",e,t)}action(e,t,o){this.inner.action(e,t,o)}setConfig(){}for(e,t,...o){return this}clear(){return this}get root(){return this.inner.root}}function dn(e){if(!Array.isArray(e))return;const t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length?t:void 0}class ln extends G{constructor(e,t,o,r,n,i,a,s,d={},l,c,p){super(),this.runId=e,this.parentRunId=t,this.workflowId=o,this.document=r,this.node=n,this.manifest=i,this.path=a,this.emitFn=s,this.metadata=d,this.engine=l,this.abortSignal=c,this.limits=p;const u=Zr(d);this.accumulate({...u,operation:"execute"});const g="string"==typeof d?.user?d.user:null;this.runLogger=new sn({runId:e,workflowId:o,nodeId:n.id,user:g,roles:dn(d?.roles),namespaces:dn(d?.namespaces),organization:"string"==typeof d?.organization?d.organization:void 0,ip:"string"==typeof d?.ip?d.ip:void 0,forward:async e=>{await this.emit(e)}})}get logger(){return this.runLogger}get auth(){return en(this)}async emit(e){await this.emitFn({...e,runId:this.runId,parentRunId:this.parentRunId,workflowId:this.workflowId,nodeId:this.node.id,path:e.path??this.path})}async progress(e){await this.emit({type:yt.NODE_OUTPUT,payload:e})}async log(e,t){await this.emit({type:yt.NODE_OUTPUT,payload:{message:e,payload:t}})}}class cn{constructor(e,t,o,r){this.nodeResults=new Map,this.events=[],this.activeDataEdges=new Set,this.runId=e,this.plan=t,this.valueStore=o,this.eventFactory=r,this.startedAt=new Date}recordNodeResult(e){this.nodeResults.set(e.nodeId,e)}activateDataEdge(e){this.activeDataEdges.add(e)}isDataEdgeActive(e){return this.activeDataEdges.has(e)}appendEvent(e){this.events.push(e)}finish(){this.finishedAt=new Date}}function pn(e,t,o,r,n){const i=e.valueStore.getWorkflowValues(),a={};for(const[t,o]of e.nodeResults)a[t]=o;const s=[...e.events];return{runId:e.runId,workflowId:t.id||t.name,status:r,document:t,inputs:{...o},outputs:i,nodeResults:a,events:s,startedAt:e.startedAt,finishedAt:e.finishedAt,metadata:n}}class un{constructor(e,t,o){this.emitter=e,this.eventFactory=t,this.options=o}get engine(){return this.options.engine}get codeSandboxEvaluator(){return this.options.codeSandboxEvaluator}get frame(){return this._frame}bindFrame(e){this._frame=e}async emit(e){const t=this.eventFactory.create({id:"",sequence:0,timestamp:new Date,runId:this.options.runId,parentRunId:this.options.parentRunId,workflowId:this.options.workflowId,type:yt.NODE_OUTPUT,path:this.options.path??[],...e});this._frame?.appendEvent(t),await this.emitter.updateObservers(t)}async updateObservers(e){await this.emitter.updateObservers(e)}}function gn(e){const t=e.capabilities;return{codeMode:t?.codeMode??e.codeMode,workflows:{list:t?.workflows?.list??("function"==typeof e.listWorkflows?"supported":"not_supported"),get:t?.workflows?.get??("function"==typeof e.getWorkflow?"supported":"not_supported")}}}class hn{static{this._cache={}}static register(e,t){return hn._cache[e]=t,t}static get(e){const t=e??hn._currentFlavour;if(t)return hn._cache[t]}static getOrFail(e){const t=hn.get(e);if(!t)throw new Cr(`No graph execution backend registered under '${e}'`,"GRAPH_EXECUTION_BACKEND_NOT_REGISTERED");return t}static get current(){return hn.get()}static get currentFlavour(){return hn._currentFlavour??sr}static setCurrent(e){hn._currentFlavour=e}static list(){return Object.entries(hn._cache).map(([e,t])=>({flavour:e,backend:t}))}static unregister(e){e&&(delete hn._cache[e],hn._currentFlavour===e&&(hn._currentFlavour=void 0))}static clear(){for(const e of Object.keys(hn._cache))delete hn._cache[e];hn._currentFlavour=void 0}}class fn{evaluate(e,t){switch(e.op){case"eq":return this.resolveValue(e.left,t)===this.resolveValue(e.right,t);case"neq":return this.resolveValue(e.left,t)!==this.resolveValue(e.right,t);case"gt":return Number(this.resolveValue(e.left,t))>Number(this.resolveValue(e.right,t));case"gte":return Number(this.resolveValue(e.left,t))>=Number(this.resolveValue(e.right,t));case"lt":return Number(this.resolveValue(e.left,t))<Number(this.resolveValue(e.right,t));case"lte":return Number(this.resolveValue(e.left,t))<=Number(this.resolveValue(e.right,t));case"and":return e.conditions.every(e=>this.evaluate(e,t));case"or":return e.conditions.some(e=>this.evaluate(e,t));case"not":return!this.evaluate(e.condition,t);case"exists":return void 0!==this.resolveValue(e.value,t)&&null!==this.resolveValue(e.value,t);default:throw new Cr(`Unknown ConditionExpression op '${e.op}'`,"GRAPH_UNKNOWN_CONDITION_OP",{expr:e})}}resolveValue(e,t){if("const"in e)return e.const;if("path"in e&&!("step"in e))return this.resolvePath(e.path,t);if("step"in e&&"path"in e){const o=t?.nodes;if(o&&"object"==typeof o){const t=o[e.step];return this.resolvePath(e.path,t)}return this.resolvePath(e.path,t)}throw new Cr("Invalid ExprValue: must have `const`, `path`, or `step`+`path`","GRAPH_INVALID_EXPR_VALUE",{ref:e})}resolvePath(e,t){if(!e)return t;const o=e.split(".");let r=t;for(const e of o){if(null==r)return;r=r[e]}return r}}function yn(e){return"object"==typeof e&&null!==e&&"type"in e&&"code"===e.type}function mn(e){return"object"==typeof e&&null!==e&&"op"in e&&"string"==typeof e.op}async function bn(e,t,o){const r=o.engine?.codeSandboxEvaluator;if(!r)throw new Cr("Code conditions require a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{code:e.code});await o.log("Evaluating code condition",{language:e.language??"javascript"});const n=o.metadata;return!!await r.evaluate({code:e.code,language:e.language,input:t,vars:n?.vars??void 0,item:n?.item,index:n?.index,nodes:n?.nodes??void 0,logger:o.logger,abortSignal:o.abortSignal})}function wn(e,t,o){if(mn(e))return(new fn).evaluate(e,t);throw((e,t)=>new Cr(`Unknown ${t??"flow"} condition type \u2014 must be ConditionExpression (op) or CodeCondition (type: 'code')`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:e}))(e,o)}async function vn(e,t,o){return yn(e)?bn(e,t.input,o):wn(e,t.state,t.label)}function xn(e,t,o,r){if(e&&"object"==typeof e&&!r.has(e))if(r.add(e),yn(e))o.push({nodeId:t,kind:"code-condition"});else if(Io(e))o.push({nodeId:t,kind:"value-template"});else if((e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"expression"===t.source&&"string"==typeof t.expression})(e))o.push({nodeId:t,kind:"expression-binding"});else if((e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.id&&"string"==typeof t.name&&Array.isArray(t.nodes)&&Array.isArray(t.edges)})(e))_n(e,o,r);else if(Array.isArray(e))for(const n of e)xn(n,t,o,r);else for(const n of Object.keys(e))xn(e[n],t,o,r)}function In(e,t,o){const r=e.id;"core.utility.code"===e.kind&&t.push({nodeId:r,kind:"code-node",detail:e.kind});const n=e.inputBindings??{};for(const[e,o]of Object.entries(n))o&&"expression"===o.mode&&t.push({nodeId:r,kind:"expression-binding",detail:e});xn(e.parameters,r,t,o),xn(e.metadata,r,t,o),xn(e.state,r,t,o),xn(e.loop,r,t,o)}function _n(e,t,o){for(const r of e.nodes??[])In(r,t,o)}function En(e){const t=[];return _n(e,t,new Set),t}function An(e){return En(e).length>0}function Sn(e){return"value-template"!==e.kind}function Rn(e){return En(e).filter(Sn)}const On="core.agent";function kn(e,t){if(!t)return{valid:!0};switch(t.type){case"any":default:return{valid:!0};case"string":return"string"!=typeof e?Cn("string"):{valid:!0};case"number":return"number"==typeof e&&Number.isFinite(e)?t.integer&&!Number.isInteger(e)?{valid:!1,message:"expected an integer number"}:void 0!==t.min&&e<t.min?{valid:!1,message:"expected a number >= "+t.min}:void 0!==t.max&&e>t.max?{valid:!1,message:"expected a number <= "+t.max}:{valid:!0}:Cn("number");case"boolean":return"boolean"!=typeof e?Cn("boolean"):{valid:!0};case"array":if(!Array.isArray(e))return Cn("array");if(void 0!==t.minItems&&e.length<t.minItems)return{valid:!1,message:`expected at least ${t.minItems} items`};if(void 0!==t.maxItems&&e.length>t.maxItems)return{valid:!1,message:`expected at most ${t.maxItems} items`};for(const o of e){const e=kn(o,t.items);if(!e.valid)return e}return{valid:!0};case"object":case"model":{if(null===e||"object"!=typeof e||Array.isArray(e))return Cn(t.type);const o=t,r=o.properties;if(!r)return{valid:!0};for(const[t,o]of Object.entries(r))if(t in e){const r=kn(e[t],o);if(!r.valid)return{valid:!1,message:`property '${t}': ${r.message}`}}if(o.required)for(const t of o.required)if(!(t in e))return{valid:!1,message:`missing required property '${t}'`};if(!1===o.additionalProperties)for(const t of Object.keys(e))if(!(t in r))return{valid:!1,message:`unexpected property '${t}'`};return{valid:!0}}case"enum":return t.values.some(t=>t===e)?{valid:!0}:{valid:!1,message:"value is not one of the enum values"}}}function Cn(e){return{valid:!1,message:`expected a ${e} value`}}function Nn(e){if("string"==typeof e)return e.length>0;if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.credentialId&&t.credentialId.length>0&&(void 0===t.credentialType||"string"==typeof t.credentialType)}const Tn=new Set(["loop"]),Pn=["secret","secrets","password","passwd","token","accessToken","refreshToken","apiKey","api_key","privateKey","credentials","authorization","proxy-authorization","x-api-key","x-auth-token","cookie","set-cookie"];class Dn{validate(e,t,o,r,n){this.validateParameters(e,t,o,r,n),this.validateMetadataKeys(e,t,o,r),this.validateDisabledBehavior(e,o,r),this.validateBindingShapes(e,t,o,r)}validateParameters(e,t,o,r,n){const i=!0===t.policies?.allowUndeclaredParameters,a=new Map(t.parameters.map(e=>[e.id,e]));for(const[n,s]of Object.entries(e.parameters??{})){const d=a.get(n);if(!d){i||o.push({code:"parameter.undeclared",path:`${r}.parameters.${n}`,message:`Node '${e.id}' sets parameter '${n}' which is not declared by kind '${t.kind}'`,nodeId:e.id,details:{kind:t.kind}});continue}if(void 0===s){o.push({code:"parameter.invalid",path:`${r}.parameters.${n}`,message:`Node '${e.id}' parameter '${n}' must not be undefined`,nodeId:e.id});continue}const l=this.checkParameterValue(s,d);l.valid||o.push({code:"parameter.type-mismatch",path:`${r}.parameters.${n}`,message:`Node '${e.id}' parameter '${n}' is invalid: ${l.message}`,nodeId:e.id,details:{expectedType:d.type}})}for(const i of t.parameters)void 0===(e.parameters??{})[i.id]&&(this.isParameterSatisfiedByInput(e,i.id,n)||(!0===i.required||(i.validation??[]).some(e=>"required"===e.kind))&&void 0===i.defaultValue&&o.push({code:"parameter.required-missing",path:`${r}.parameters.${i.id}`,message:`Node '${e.id}' is missing required parameter '${i.id}' declared by kind '${t.kind}'`,nodeId:e.id}))}isParameterSatisfiedByInput(e,t,o){return void 0!==(e.inputBindings??{})[t]||!0===o?.has(t)}checkParameterValue(e,t){if(Io(e))return{valid:!0};switch(t.type){case"string":case"code":case"expression":return"string"!=typeof e?Cn("string"):{valid:!0};case"number":return"number"==typeof e&&Number.isFinite(e)?{valid:!0}:Cn("number");case"boolean":return"boolean"!=typeof e?Cn("boolean"):{valid:!0};case"options":{const o=t.options;return o&&o.length&&!o.some(t=>t.value===e)?{valid:!1,message:"value is not one of the declared options"}:{valid:!0}}case"collection":return Array.isArray(e)?{valid:!0}:Cn("array");case"object":case"resourceLocator":return null===e||"object"!=typeof e||Array.isArray(e)?Cn("object"):{valid:!0};case"credential":return Nn(e)?t.credentialType&&"object"==typeof e&&void 0!==e.credentialType&&e.credentialType!==t.credentialType?{valid:!1,message:`credential type '${e.credentialType}' does not match the declared type '${t.credentialType}'`}:{valid:!0}:{valid:!1,message:"credential parameters must hold a credential reference (credentialId), never a secret"};default:return{valid:!0}}}validateMetadataKeys(e,t,o,r){const n=t.metadata?.allowedInstanceMetadataKeys;for(const i of Object.keys(e.metadata??{}))Tn.has(i)?o.push({code:"metadata.key-not-allowed",path:`${r}.metadata.${i}`,message:`Node '${e.id}' metadata key '${i}' is reserved and must not be set directly`,nodeId:e.id}):Array.isArray(n)&&!n.includes(i)&&o.push({code:"metadata.key-not-allowed",path:`${r}.metadata.${i}`,message:`Node '${e.id}' metadata key '${i}' is not in the allowed metadata keys of kind '${t.kind}'`,nodeId:e.id})}validateDisabledBehavior(e,t,o){!0!==e.disabled&&!1!==e.disabled&&void 0!==e.disabled&&t.push({code:"disabled.invalid",path:o+".disabled",message:`Node '${e.id}' disabled flag must be a boolean`,nodeId:e.id});const r=(e.metadata??{}).disabledBehavior;void 0===r||ut(r)||t.push({code:"disabled.invalid-behavior",path:o+".metadata.disabledBehavior",message:`Node '${e.id}' disabled behavior '${r+""}' is not one of: ${pt.join(", ")}`,nodeId:e.id})}validateBindingShapes(e,t,o,r){for(const[n,i]of Object.entries(e.inputBindings??{})){if("literal"===i.mode){const a=t.inputs.find(e=>e.id===n);if(a?.schema){const t=kn(i.value,a.schema);t.valid||o.push({code:"binding.literal-invalid",path:`${r}.inputBindings.${n}`,message:`Node '${e.id}' literal binding for '${n}' is schema-invalid: ${t.message}`,nodeId:e.id})}}"expression"!==i.mode||"string"==typeof i.expression&&i.expression.trim()||o.push({code:"binding.expression-invalid",path:`${r}.inputBindings.${n}`,message:`Node '${e.id}' expression binding for '${n}' must contain a non-empty expression`,nodeId:e.id})}}validateBindingSatisfaction(e,t,o,r,n,i={}){const a=new Set(o.filter(e=>"data"===e.type).map(e=>e.targetPort)),s=new Set(Object.entries(e.inputBindings??{}).map(([e])=>e));for(const t of a){const o=(e.inputBindings??{})[t];o&&"literal"===o.mode&&!0!==i.allowLiteralAndEdgeBindings&&r.push({code:"binding.conflict",path:`${n}.inputBindings.${t}`,message:`Node '${e.id}' input '${t}' has both an incoming edge and a literal binding`,nodeId:e.id})}for(const o of t.inputs)!0===o.required&&(a.has(o.id)||s.has(o.id)||void 0===(e.parameters??{})[o.id]&&r.push({code:"topology.required-input-unsatisfiable",path:n+".parameters",message:`Node '${e.id}' required input '${o.id}' has no incoming edge or binding`,nodeId:e.id,details:{port:o.id}}))}static disabledBehaviorOf(e,t){const o=(e.metadata??{}).disabledBehavior;if(ut(o))return o;const r=t?.disabledBehavior;return ut(r)?r:"skip"}}let jn=class extends j{constructor(e){super(e)}};function Ln(e){return[e.namespace??"default",e.workflowId,e.nodeId,e.version??"default",e.fingerprint].join(":")}function Mn(e){return new jn({id:Ln(e.key),workflowId:e.key.workflowId,nodeId:e.key.nodeId,fingerprint:e.key.fingerprint,...void 0!==e.key.namespace?{namespace:e.key.namespace}:{},...void 0!==e.key.version?{version:e.key.version}:{},pinned:e.pinned,outputs:e.outputs,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),...e.expiresAt?{expiresAt:new Date(e.expiresAt)}:{},...e.metadata?{metadata:e.metadata}:{}})}function Gn(e){return{key:{workflowId:e.workflowId,nodeId:e.nodeId,fingerprint:e.fingerprint,...void 0!==e.namespace?{namespace:e.namespace}:{},...void 0!==e.version?{version:e.version}:{}},outputs:e.outputs,pinned:e.pinned,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString(),...e.expiresAt?{expiresAt:e.expiresAt.toISOString()}:{},...e.metadata?{metadata:e.metadata}:{}}}k([N({type:String,generated:!1}),C("design:type",String)],jn.prototype,"id",void 0),k([T(),P(),C("design:type",String)],jn.prototype,"workflowId",void 0),k([T(),P(),C("design:type",String)],jn.prototype,"nodeId",void 0),k([T(),C("design:type",String)],jn.prototype,"fingerprint",void 0),k([T(),C("design:type",String)],jn.prototype,"namespace",void 0),k([T(),C("design:type",String)],jn.prototype,"version",void 0),k([T(),C("design:type",Boolean)],jn.prototype,"pinned",void 0),k([T(),C("design:type",Object)],jn.prototype,"outputs",void 0),k([T(),C("design:type",Date)],jn.prototype,"createdAt",void 0),k([T(),C("design:type",Date)],jn.prototype,"updatedAt",void 0),k([T(),C("design:type",Date)],jn.prototype,"expiresAt",void 0),k([T(),C("design:type",Object)],jn.prototype,"metadata",void 0),jn=k([D("graph_value"),I(),C("design:paramtypes",[Object])],jn);let Un=class extends ${constructor(e){super(e,jn,!0),this.runtimeValues=new Map}seedWorkflowInputs(e){this.runtimeValues.set(ar,{...e})}setNodeOutputs(e,t){this.runtimeValues.set(e,{...t})}getPort(e,t){return this.runtimeValues.get(e)?.[t]}hasPort(e,t){return Object.prototype.hasOwnProperty.call(this.runtimeValues.get(e)??{},t)}setWorkflowOutput(e,t){const o=this.runtimeValues.get(ar)??{};o[e]=t,this.runtimeValues.set(ar,o)}getWorkflowValues(){return{...this.runtimeValues.get(ar)??{}}}snapshot(){return Object.fromEntries(this.runtimeValues.entries())}async readCached(e,...t){try{return Gn(await this.read(Ln(e),...t))}catch{return}}async writeCached(e,t,...o){const r=Ln(e);let n;try{n=await this.read(r,...o)}catch{n=void 0}n?await this.update(Object.assign(n,Mn(t)),...o):await this.create(Mn(t),...o)}async deleteCached(e,...t){try{await this.delete(Ln(e),...t)}catch{}}async hasCached(e,...t){return void 0!==await this.readCached(e,...t)}async listCached(e,...t){return(await this.select().execute(...t)).map(e=>Gn(e)).filter(t=>((e,t)=>!(void 0!==t.workflowId&&e.workflowId!==t.workflowId||void 0!==t.nodeId&&e.nodeId!==t.nodeId||void 0!==t.namespace&&e.namespace!==t.namespace||void 0!==t.version&&e.version!==t.version||void 0!==t.fingerprint&&e.fingerprint!==t.fingerprint))(t.key,e))}async clearRun(e,...t){const o=await this.select().execute(...t);for(const e of o)await this.delete(e.id,...t)}readRuntimeValues(e){return this.runtimeValues.get(e)}writeRuntimeValues(e,t){this.runtimeValues.set(e,{...t})}getAdapter(){return this.adapter}};function $n(e){return new(0,$.forModel(jn,e.alias).constructor)(e)}Un=k([U(jn,y),C("design:paramtypes",[Function])],Un);class Fn{static upstreamNodes(e,t,o=!1){const r=new Set,n=[e];for(;n.length;){const e=n.pop(),i=t.get(e)??[];for(const e of i)!o&&this.isBoundary(e.sourceNodeId)||r.has(e.sourceNodeId)||(r.add(e.sourceNodeId),n.push(e.sourceNodeId))}return r}static downstreamNodes(e,t,o=!1){const r=new Set,n=[e];for(;n.length;){const e=n.pop(),i=t.get(e)??[];for(const e of i)!o&&this.isBoundary(e.targetNodeId)||r.has(e.targetNodeId)||(r.add(e.targetNodeId),n.push(e.targetNodeId))}return r}static isBoundary(e){return"$workflow"===e}}class Hn{constructor(e,t,o){this.store=e,this.policy=t,this.dependencyResolver=o}async pinNode(e){const t=e.plan,o=e.includeDependencies??!0?this.dependencyResolver.getPinSet(t,e.nodeId):new Set([e.nodeId]);for(const e of o){const o=t.nodes.find(t=>t.id===e);if(!o)throw new Dr(`Node '${e}' not found in plan`);if(!this.policy.canPin(o))throw new Dr(`Node '${e}' is not pinnable`,{nodeId:e})}const r=this.topologicalOrder(t,o);for(const o of r){const r=t.nodes.find(e=>e.id===o),n=e.result.nodeResults[o];if(!n||!n.outputs)throw new Dr(`Node '${o}' has no completed output to pin`);const i=n.inputs??{},a=this.dependencyFingerprints(t,o,e.result),s=this.createValueKey(e.document.id,r,i,a),d=(new Date).toISOString(),l={key:s,outputs:n.outputs,pinned:!0,createdAt:d,updatedAt:d,metadata:{...e.result.metadata,nodeId:o}};await this.store.writeCached(s,l)}}async unpinNode(e){const t={workflowId:e.document.id,nodeId:e.nodeId,fingerprint:e.fingerprint,namespace:e.namespace};await this.store.deleteCached(t)}async readPinnedValue(e,t,o,r,n){const i=this.createValueKey(e,t,o,r,n),a=await this.store.readCached(i);if(a&&a.pinned){if(a.expiresAt&&new Date(a.expiresAt)<new Date)return;return a}}createValueKey(e,t,o,r,n){return{workflowId:e,nodeId:t.id,fingerprint:this.computeFingerprint(e,t,o,r),namespace:n}}computeFingerprint(e,t,o,r){const n={workflowId:e,nodeId:t.id,nodeKind:t.kind,parameters:this.stableSerialize(t.instance.parameters??{}),inputBindings:this.stableSerialize(t.instance.inputBindings??{}),metadata:this.stableSerialize(this.relevantMetadata(t)),inputs:this.stableSerialize(o),dependencyFingerprints:this.stableSerialize(r)},i=this.stableSerialize(n);return this.simpleHash(i)}relevantMetadata(e){const t={...e.metadata??{}};return delete t.ui,delete t.position,delete t.visual,t}topologicalOrder(e,t){const o=[],r=new Set,n=i=>{if(r.has(i))return;r.add(i);const a=Fn.upstreamNodes(i,e.incomingByNode,!1);for(const e of a)t.has(e)&&n(e);o.push(i)};for(const e of t)n(e);return o}dependencyFingerprints(e,t,o){const r=this.dependencyResolver.getDependencies(e,t),n={};for(const t of r){const r=e.nodes.find(e=>e.id===t);if(r){const i=o.nodeResults[t],a=i?.inputs??{},s=this.dependencyFingerprints(e,t,o);n[t]=this.computeFingerprint(e.workflowId,r,a,s)}}return n}stableSerialize(e){return null===e||"object"!=typeof e?JSON.stringify(e):Array.isArray(e)?`[${e.map(e=>this.stableSerialize(e)).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${this.stableSerialize(e[t])}`).join(",")}}`}simpleHash(e){let t=0;for(let o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o),t|=0;return`fp_${Math.abs(t).toString(16).padStart(8,"0")}_${e.length}`}}const Bn={enabled:!0,strategy:"manual",includeDependencies:!0};function qn(e){return!0===e?.enabled&&"disabled"!==e.strategy}class Wn{canPin(e){return qn(this.getPinningMetadata(e))}shouldUsePinnedValue(e){const t=this.getPinningMetadata(e);return!0===t.enabled&&"disabled"!==t.strategy}shouldAutoPin(e){const t=this.getPinningMetadata(e);return!0===t.enabled&&"automatic"===t.strategy}getPinningMetadata(e){const t=e.manifest.metadata?.pinnable??e.metadata?.pinnable;return t?{...Bn,...t}:{...Bn,enabled:!1}}}class Kn{getDependencies(e,t){return Fn.upstreamNodes(t,e.incomingByNode,!1)}getPinSet(e,t){const o=this.getDependencies(e,t);return o.add(t),o}}class Vn{constructor(){this.local=!0,this.codeMode="hostSide",hn.register(sr,this)}async initialize(e){this.valueAdapter=e.valueAdapter,this.codeSandboxEvaluator=e.codeSandboxEvaluator,this.workflowStore=e.workflowStore,this.engine=e.engine}get capabilities(){const e=this.workflowStore?"supported":"not_supported";return{codeMode:this.codeMode,workflows:{list:e,get:e}}}async listWorkflows(...e){const t=this.workflowStore;if(!t)throw new Cr("LocalGraphExecutionBackend has no workflowStore configured; workflow listing is not supported","GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED");return(await t.listWorkflows(...e)).map(e=>({id:e.workflowId,...void 0!==e.name?{name:e.name}:{},...void 0!==e.updatedAt&&null!==e.updatedAt?{updatedAt:e.updatedAt}:{}}))}async getWorkflow(e,...t){const o=this.workflowStore;if(!o)throw new Cr("LocalGraphExecutionBackend has no workflowStore configured; workflow lookup is not supported","GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED");const r=await o.getDocument(e,...t);return this.engine&&this.engine.assertWorkflowReadAccess(r,(e=>en((e=>{for(let t=e.length-1;t>=0;t-=1){const o=e[t];if(!o||"object"!=typeof o)continue;const r=o;if("function"==typeof r.get&&"function"==typeof r.accumulate&&void 0!==r.cache)return o}})(e)))(t)),r}async seedWorkflows(e,...t){const o=this.workflowStore,r=o?.seedDocument??o?.saveDocument;if(!o||"function"!=typeof r)throw new Cr("LocalGraphExecutionBackend has no writable workflowStore configured; workflow seeding is not supported","GRAPH_BACKEND_SEED_NOT_SUPPORTED");const n=[];for(const i of e)null!==await r.call(o,i.id,i,...t)&&n.push({id:i.id,...void 0!==i.name?{name:i.name}:{}});return n}async execute(e){const{document:t,plan:o,inputs:r,options:n,events:i}=e,a=i,s=a.frame;if(!s)throw new Cr("LocalGraphExecutionBackend requires the frame-bound event sink created by GraphExecutionEngine","GRAPH_EXECUTION_FRAME_MISSING");const d=s.valueStore,l=s.runId,c=n.path??[],p=async e=>{await a.emit(e)};try{for(const e of o.layers)this.assertNotAborted(n),await this.executeLayer(s,o,e.nodes,n,p);this.assertNotAborted(n);const e=[...s.nodeResults.values()].find(e=>e.status===gt.FAILED);if(e?.error)throw new Cr(e.error.message,e.error.code??"GRAPH_EXECUTION_ERROR",e.error.details);return s.finish(),await a.emit({type:yt.WORKFLOW_COMPLETED,runId:l,parentRunId:n.parentRunId,workflowId:o.workflowId,path:c,status:gt.SUCCEEDED,payload:{outputs:d.getWorkflowValues()}}),pn(s,t,r,gt.SUCCEEDED,n.metadata)}catch(e){if(e instanceof Gr)throw s.finish(),e;s.finish();const i=this.toErrorPayload(e);return e instanceof Ur||!0===n.abortSignal?.aborted?(await a.emit({type:yt.WORKFLOW_CANCELLED,runId:l,parentRunId:n.parentRunId,workflowId:o.workflowId,path:c,status:gt.CANCELLED,error:i}),pn(s,t,r,gt.CANCELLED,n.metadata)):(await a.emit({type:yt.WORKFLOW_FAILED,runId:l,parentRunId:n.parentRunId,workflowId:o.workflowId,path:c,status:gt.FAILED,error:i}),pn(s,t,r,gt.FAILED,n.metadata))}}async executeLayer(e,t,o,r,n){const i=Math.max(1,r.concurrency??4),a=[...o];for(;a.length>0;){const o=a.splice(0,i);await Promise.all(o.map(o=>this.executeNode(e,t,o,r,n)))}}async executeNode(e,t,o,r,n){if(this.assertNotAborted(r),!this.isNodeActivated(e,t,o))return void await this.skipInactiveNode(e,t,o,r,n);if(!0===o.instance.disabled)return void await this.executeDisabledNode(e,t,o,r,n);const i=new Date,a=[...r.path??[],o.id];await n({type:yt.NODE_STARTED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:gt.RUNNING}),this.emitNodeStateChanged(e,t,o,a,ht.RUNNING,gt.RUNNING,n);const s=await this.resolveNodeInputs(e,t,o,r);if(r.usePinnedValues){const r=await this.tryPinnedValue(e,t,o,s);if(r){e.valueStore.setNodeOutputs(o.id,r.outputs),this.routeOutgoingEdges(e,t,o,r.outputs,n);const d=new Date,l={nodeId:o.id,status:gt.CACHED,inputs:s,outputs:r.outputs,startedAt:i,finishedAt:d,fromCache:!0,pinned:!0,events:[]};return e.recordNodeResult(l),await n({type:yt.NODE_CACHE_HIT,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:gt.CACHED,payload:{outputs:r.outputs}}),await n({type:yt.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:gt.SUCCEEDED,payload:{outputs:r.outputs,fromCache:!0}}),void this.emitNodeStateChanged(e,t,o,a,ht.SUCCEEDED,gt.SUCCEEDED,n)}}try{const d=new ln(e.runId,r.parentRunId,t.workflowId,t.resolved.document,o.instance,o.manifest,a,n,r.metadata,this.engine,r.abortSignal,this.executionLimits(r)),l=await this.resolveNodeParameters(o,s,r),c={nodeId:o.id,kind:o.kind,inputs:s,parameters:l,credentials:this.collectCredentials(o),metadata:o.instance.metadata},p=await this.invokeExecutor(o,c,d),u=this.validateNodeOutputs(o,p??{});e.valueStore.setNodeOutputs(o.id,u),this.routeOutgoingEdges(e,t,o,u,n);const g=new Date,h={nodeId:o.id,status:gt.SUCCEEDED,inputs:s,outputs:u,startedAt:i,finishedAt:g,events:[]};e.recordNodeResult(h),await n({type:yt.NODE_COMPLETED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:gt.SUCCEEDED,payload:{outputs:u}}),this.emitNodeStateChanged(e,t,o,a,ht.SUCCEEDED,gt.SUCCEEDED,n)}catch(d){if(d instanceof Gr)throw d;const l=new Date,c=this.toErrorPayload(d),p={nodeId:o.id,status:gt.FAILED,inputs:s,error:c,startedAt:i,finishedAt:l,events:[]};if(e.recordNodeResult(p),await n({type:yt.NODE_FAILED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:gt.FAILED,error:c}),this.emitNodeStateChanged(e,t,o,a,ht.FAILED,gt.FAILED,n),r.failFast??!0)throw d}}isNodeActivated(e,t,o){const r=(t.incomingByNode.get(o.id)??[]).filter(e=>"data"===e.type);return 0===r.length||r.some(t=>t.sourceNodeId===ar||e.isDataEdgeActive(t.id))}async skipInactiveNode(e,t,o,r,n){const i=new Date,a=[...r.path??[],o.id];await n({type:yt.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:gt.SKIPPED,payload:{reason:"branchNotSelected"}});const s={nodeId:o.id,status:gt.SKIPPED,inputs:{},startedAt:i,finishedAt:new Date,events:[]};e.recordNodeResult(s),this.emitNodeStateChanged(e,t,o,a,ht.SKIPPED,gt.SKIPPED,n)}async executeDisabledNode(e,t,o,r,n){const i=new Date,a=[...r.path??[],o.id],s=Dn.disabledBehaviorOf(o.instance,t.resolved.document.settings);if(await n({type:yt.NODE_SKIPPED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:a,status:gt.SKIPPED,payload:{disabled:!0,behavior:s}}),"skip"===s){const r={nodeId:o.id,status:gt.SKIPPED,inputs:{},startedAt:i,finishedAt:new Date,events:[]};return e.recordNodeResult(r),void this.emitNodeStateChanged(e,t,o,a,ht.SKIPPED,gt.SKIPPED,n)}const d=await this.resolveNodeInputs(e,t,o,r);let l;if("passThroughFirstInput"===s){const r=(t.incomingByNode.get(o.id)??[]).find(e=>"data"===e.type),n=o.manifest.outputs[0]?.id??"value",i=r?e.valueStore.getPort(r.sourceNodeId,r.sourcePort):Object.values(d)[0];l={[n]:i}}else{l={};for(const e of o.manifest.outputs)l[e.id]=e.metadata?.defaultValue}e.valueStore.setNodeOutputs(o.id,l),this.routeOutgoingEdges(e,t,o,l,n);const c={nodeId:o.id,status:gt.SUCCEEDED,inputs:d,outputs:l,startedAt:i,finishedAt:new Date,events:[]};e.recordNodeResult(c),this.emitNodeStateChanged(e,t,o,a,ht.SUCCEEDED,gt.SUCCEEDED,n)}async invokeExecutor(e,t,o){if((r=e.kind)===On||r.startsWith(On+"."))throw new Cr(`Node '${e.id}' of kind '${e.kind}' requires the mastra engine, which the local backend does not provide`,dr,{nodeId:e.id,kind:e.kind,backend:sr});var r;return await e.executor.execute(t,o)}validateNodeOutputs(e,t){const o=e.manifest;if(!0===o.policies?.allowUnknownOutputs)return t;const r=new Set(o.outputs.map(e=>e.id)),n=Object.keys(t).filter(e=>!r.has(e));if(n.length>0)throw new Cr(`Node '${e.id}' of kind '${e.kind}' produced unknown output(s): ${n.join(", ")}`,"GRAPH_OUTPUT_VALIDATION_FAILED",{nodeId:e.id,unknownOutputs:n});const i=o.outputs.filter(e=>!0===e.required&&!(e.id in t)).map(e=>e.id);if(i.length>0)throw new Cr(`Node '${e.id}' of kind '${e.kind}' did not produce required output(s): ${i.join(", ")}`,"GRAPH_OUTPUT_VALIDATION_FAILED",{nodeId:e.id,missingRequired:i});return t}collectCredentials(e){const t={};for(const o of e.manifest.parameters){if("credential"!==o.type)continue;const r=(e.instance.parameters??{})[o.id];"string"==typeof r&&r.length>0?t[o.id]={credentialId:r,credentialType:o.credentialType??""}:Nn(r)&&(t[o.id]={credentialId:r.credentialId,credentialType:r.credentialType})}const o=(e.instance.metadata??{}).credentials;if(o&&"object"==typeof o&&!Array.isArray(o))for(const[e,r]of Object.entries(o)){const o=r;"string"==typeof o&&o.length>0?t[e]={credentialId:o,credentialType:""}:Nn(o)&&(t[e]={credentialId:o.credentialId,credentialType:o.credentialType})}return t}async resolveNodeInputs(e,t,o,r){const n={},i=(t.incomingByNode.get(o.id)??[]).filter(e=>"data"===e.type),a=new Map;for(const e of i){const t=a.get(e.targetPort)??[];t.push(e),a.set(e.targetPort,t)}for(const[t,o]of a)if(1===o.length)n[t]=e.valueStore.getPort(o[0].sourceNodeId,o[0].sourcePort);else{let r,i=!1;for(const t of o){const o=e.valueStore.getPort(t.sourceNodeId,t.sourcePort);n[t.sourcePort]=o,void 0!==o&&(r=o,i=!0)}i&&void 0===n[t]&&(n[t]=r)}const s=o.instance.inputBindings??{};for(const e of o.manifest.inputs){const t=s[e.id];if("literal"===t?.mode)n[e.id]=t.value;else if("expression"===t?.mode)n[e.id]=await this.evaluateExpressionBinding(o,t.expression,n,r);else if(void 0===n[e.id]){const t=e.metadata?.defaultValue;void 0!==t&&(n[e.id]=t)}}return n}async resolveNodeParameters(e,t,o){const r=e.instance.parameters??{},n={};for(const[i,a]of Object.entries(r))n[i]=Io(a)?await this.evaluateValueTemplate(a,e,t,o):a;return n}async evaluateValueTemplate(e,t,o,r){const n=this.codeSandboxEvaluator;if(!n)throw new Cr(`Value template on node '${t.id}' requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator`,"GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{nodeId:t.id});const i=e.language??("expression"===e.mode?"javascript":"text"),a="template"===e.mode?(e=>`\`${e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\{\{\s*([\s\S]*?)\s*\}\}/g,(e,t)=>`\${${t}}`)}\``)(e.expression):e.expression,s=r.metadata;return await n.evaluate({code:a,language:"typescript"===i?"typescript":"javascript",input:o,vars:s?.vars??void 0,item:s?.item,index:s?.index,abortSignal:r.abortSignal})}async evaluateExpressionBinding(e,t,o,r){const n=this.codeSandboxEvaluator;if(!n)throw new Cr(`Expression binding on node '${e.id}' requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator`,"GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{nodeId:e.id,expression:t});const i=r.metadata;return await n.evaluate({code:t,language:"javascript",input:o,vars:i?.vars??void 0,item:i?.item,index:i?.index,abortSignal:r.abortSignal})}async tryPinnedValue(e,t,o,r){if(!(new Wn).shouldUsePinnedValue(o))return;const n=this.createPinningService(e),i=this.computeDependencyFingerprints(e,t,o.id);return n.readPinnedValue(t.workflowId,o,r,i)}computeDependencyFingerprints(e,t,o){const r=this.createPinningService(e),n=(new Kn).getDependencies(t,o),i={};for(const o of n){const n=t.nodes.find(e=>e.id===o);if(n){const a=e.nodeResults.get(o),s=a?.inputs??{},d=this.computeDependencyFingerprints(e,t,o);i[o]=r.computeFingerprint(t.workflowId,n,s,d)}}return i}routeOutgoingEdges(e,t,o,r,n){const i=(t.outgoingByNode.get(o.id)??[]).filter(e=>"data"===e.type);for(const a of i){if(!Object.prototype.hasOwnProperty.call(r,a.sourcePort))continue;const i=r[a.sourcePort];e.activateDataEdge(a.id),a.targetNodeId===ar&&e.valueStore.setWorkflowOutput(a.targetPort,i),this.emitEdgeStateChanged(e,t,o,a,ht.SUCCEEDED,gt.SUCCEEDED,n),n({type:yt.EDGE_VALUE_ROUTED,runId:e.runId,workflowId:t.workflowId,edgeId:a.id,nodeId:o.id,path:[],payload:{edge:a,value:i}}).catch(()=>{})}}emitNodeStateChanged(e,t,o,r,n,i,a){a({type:yt.NODE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,path:r,status:i,payload:{nodeId:o.id,state:n,runId:e.runId,workflowId:t.workflowId,status:i}}).catch(()=>{})}emitEdgeStateChanged(e,t,o,r,n,i,a){a({type:yt.EDGE_STATE_CHANGED,runId:e.runId,workflowId:t.workflowId,edgeId:r.id,nodeId:o.id,path:[],status:i,payload:{edgeId:r.id,state:n,runId:e.runId,workflowId:t.workflowId,nodeId:o.id,status:i}}).catch(()=>{})}createPinningService(e){const t=$n(e.valueStore.getAdapter()??this.valueAdapter);return new Hn(t,new Wn,new Kn)}executionLimits(e){return{maxLoopIterations:e.maxLoopIterations??ur,maxForeachIterations:e.maxForeachIterations??gr}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new Ur(e.runId??"unknown")}toErrorPayload(e){return e instanceof Error?{name:e.name,message:e.message,stack:e.stack,code:e.graphCode??("number"==typeof e.code?e.code+"":e.code)}:{name:"UnknownError",message:e+""}}}const zn={execute:()=>{throw new Cr("A deployment-projection node cannot be executed by the facade; the backend must bind and run the authoritative deployment artifact","GRAPH_DEPLOYMENT_PROJECTION_NOT_EXECUTABLE")}};function Qn(e){return{kind:e,display:{name:e},inputs:[],outputs:[],parameters:[],policies:{allowUndeclaredParameters:!0,allowUnknownOutputs:!0}}}class Jn{constructor(e,t={}){this.catalogue=e,this.options=t}async resolveNodes(e,t,o,...r){const n=new Map;for(const[i,a]of e.entries()){const e=`nodes[${i}]`;if(this.catalogue.has(a.kind,...r))try{const e=await this.catalogue.resolveManifest(a.kind,a,o,...r),t=this.catalogue.getExecutor(a.kind,...r);n.set(a.id,{instance:a,manifest:e,executor:t})}catch(o){t.push({code:"kind.resolution-failed",path:e+".kind",message:`Node '${a.id}' kind '${a.kind}' failed to resolve: ${o.message}`,nodeId:a.id,details:{kind:a.kind}})}else{if(!0===this.options.deploymentProjection){n.set(a.id,{instance:a,manifest:Qn(a.kind),executor:zn});continue}t.push({code:"kind.unknown",path:e+".kind",message:`Node '${a.id}' references kind '${a.kind}' which is not registered in the backend catalogue`,nodeId:a.id,details:{kind:a.kind}})}}return n}validateEffectivePorts(e,t,o,r){const n=!0===t.policies?.allowUndeclaredParameters,i=new Set(t.inputs.map(e=>e.id)),a=new Set(t.outputs.map(e=>e.id));for(const a of Object.keys(e.inputBindings??{}))n||i.has(a)||o.push({code:"binding.unknown-port",path:`${r}.inputBindings.${a}`,message:`Node '${e.id}' input binding '${a}' does not refer to an effective input port of kind '${t.kind}'`,nodeId:e.id,details:{effectiveInputs:[...i]}});for(const i of Object.keys(e.outputBindings??{}))n||a.has(i)||o.push({code:"binding.unknown-port",path:`${r}.outputBindings.${i}`,message:`Node '${e.id}' output binding '${i}' does not refer to an effective output port of kind '${t.kind}'`,nodeId:e.id,details:{effectiveOutputs:[...a]}})}}function Xn(e,t,o="$"){const r=new Set;for(const t of e.edges)"node"===t.source.scope&&r.add(t.source.nodeId),"node"===t.target.scope&&r.add(t.target.nodeId);for(const n of e.nodes){r.has(n.id)||t.push({code:"topology.loose-node",path:`${o}.nodes[${n.id}]`,message:`Node '${n.id}' is connected to nothing; every node must participate in at least one edge`,nodeId:n.id});const e=n.loop?.body;e&&Xn(e,t,`${o}.nodes[${n.id}].loop.body`)}}class Yn{resolveEdges(e,t,o){const r=new Set(e.inputs.map(e=>e.id)),n=new Set(e.outputs.map(e=>e.id)),i=[];for(const[a,s]of(e.edges??[]).entries()){const e=`edges[${a}]`,d=this.resolveEndpoint(s,"source",t,r,n,o,e),l=this.resolveEndpoint(s,"target",t,r,n,o,e);if(!d||!l)continue;if(!this.validateDirectionAndType(s,d,l,t,o,e))continue;const c={id:s.id,type:s.type,sourceNodeId:d.nodeId,sourcePort:d.port,targetNodeId:l.nodeId,targetPort:l.port,metadata:s.metadata,edge:s};void 0!==s.label&&(c.label=s.label),i.push(c)}return i}resolveEndpoint(e,t,o,r,n,i,a){const s=e[t];return ao(s)?("source"===t?r.has(s.port):n.has(s.port))?{nodeId:ar,port:s.port}:void i.push({code:"edge.unknown-port",path:`${a}.${t}`,message:`Edge '${e.id}' ${t} references workflow port '${s.port}' which is not declared on the document boundary`,edgeId:e.id,details:{scope:"workflow",port:s.port}}):so(s)?o.get(s.nodeId)?{nodeId:s.nodeId,port:s.port}:void i.push({code:"edge.unknown-node",path:`${a}.${t}`,message:`Edge '${e.id}' ${t} references node '${s.nodeId}' which is not part of the document or did not resolve`,edgeId:e.id,nodeId:s.nodeId}):void i.push({code:"edge.invalid-endpoint",path:`${a}.${t}`,message:`Edge '${e.id}' ${t} endpoint is not a valid GraphEndpoint`,edgeId:e.id})}validateDirectionAndType(e,t,o,r,n,i){let a=!0;const s=t.nodeId===ar?void 0:r.get(t.nodeId),d=o.nodeId===ar?void 0:r.get(o.nodeId),l=e=>!0===e?.manifest.policies?.allowUndeclaredParameters;if("data"===e.type)!s||l(s)||this.hasPortDirection(s,t.port,"output")||(this.pushPortIssue(e,"source",t,s,n,i),a=!1),!d||l(d)||this.hasPortDirection(d,o.port,"input")||(this.pushPortIssue(e,"target",o,d,n,i),a=!1);else{if(!s||!d)return n.push({code:"edge.boundary-routing",path:i,message:`Connection edge '${e.id}' must connect two node connection ports; the workflow boundary only routes data`,edgeId:e.id}),!1;if(!(l(s)||l(d)||this.hasPortDirection(s,t.port,"connection")&&this.hasPortDirection(d,o.port,"connection")))return n.push({code:"edge.type-mismatch",path:i,message:`Connection edge '${e.id}' endpoints must both be connection ports`,edgeId:e.id,details:{sourcePort:t.port,targetPort:o.port}}),!1}return a}hasPortDirection(e,t,o){return("input"===o?e.manifest.inputs:"output"===o?e.manifest.outputs:e.manifest.connections??[]).some(e=>e.id===t)}pushPortIssue(e,t,o,r,n,i){const a="source"===t?"output":"input";n.push({code:"data"===e.type?"edge.invalid-direction":"edge.type-mismatch",path:`${i}.${t}`,message:`Edge '${e.id}' ${t} port '${o.port}' on node '${o.nodeId}' is not an ${a} port of kind '${r.manifest.kind}'`,edgeId:e.id,nodeId:o.nodeId,details:{port:o.port,expected:a}})}}class Zn{validate(e,t){this.validateDuplicates(e.edges,t),this.validatePolicies(e,t)}validateDuplicates(e,t){const o=new Map;for(const r of e){const e=`${r.sourceNodeId}:${r.sourcePort}->${r.targetNodeId}:${r.targetPort}`,n=o.get(e);n?t.push({code:"connection.duplicate-edge",path:`edges[${r.id}]`,message:`Edge '${r.id}' duplicates the routing of edge '${n.id}' (${e})`,edgeId:r.id,details:{duplicateOf:n.id,routing:e}}):o.set(e,r)}}validatePolicies(e,t){const o=new Map;for(const t of e.edges){if("connection"!==t.type)continue;const e=`${t.targetNodeId}:${t.targetPort}`,r=o.get(e)??[];r.push(t),o.set(e,r)}for(const o of e.edges){if("connection"!==o.type)continue;const r=e.nodeById.get(o.targetNodeId),n=r?.manifest.connections?.find(e=>e.id===o.targetPort)?.connectionPolicy;this.validateEdgePolicy(o,e.nodeById,n,t),this.validateCategoryMatch(o,e.nodeById,t)}for(const[r,n]of o){const o=r.lastIndexOf(":"),i=r.slice(0,o),a=r.slice(o+1),s=e.nodeById.get(i),d=s?.manifest.connections?.find(e=>e.id===a)?.connectionPolicy;if(!d)continue;const l=void 0!==d.maxConnections?d.maxConnections:!1===d.allowMultiple?1:1/0;n.length>l&&t.push({code:"connection.max-connections",path:`edges[${n[n.length-1].id}]`,message:`Connection port '${a}' on node '${i}' accepts at most ${l} connection(s) but has ${n.length}`,nodeId:i,edgeId:n[n.length-1].id,details:{port:a,max:l,actual:n.length}})}}validateCategoryMatch(e,t,o){const r=t.get(e.sourceNodeId),n=t.get(e.targetNodeId),i=r?.manifest.connections?.find(t=>t.id===e.sourcePort)?.category,a=n?.manifest.connections?.find(t=>t.id===e.targetPort)?.category;i&&a&&i!==a&&o.push({code:"connection.category-mismatch",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' joins source port '${e.sourcePort}' (category '${i}') to target port '${e.targetPort}' (category '${a}'); connection categories must match`,edgeId:e.id,nodeId:e.sourceNodeId,details:{sourceCategory:i,targetCategory:a}})}validateEdgePolicy(e,t,o,r){if(e.sourceNodeId===e.targetNodeId&&!o?.allowSelf)return void r.push({code:"connection.self-connection",path:`edges[${e.id}]`,message:`Edge '${e.id}' connects node '${e.sourceNodeId}' to itself, which the target port policy does not allow`,edgeId:e.id,nodeId:e.sourceNodeId});if(!o)return;const n=t.get(e.sourceNodeId),i=n?.manifest.kind;if(!o.allowedNodeKinds?.length||i&&o.allowedNodeKinds.includes(i)||r.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source kind '${i??"unknown"}' is not in the allowed node kinds of target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{allowedNodeKinds:o.allowedNodeKinds}}),i&&o.blockedNodeKinds?.includes(i)&&r.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source kind '${i}' is blocked by target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{blockedNodeKinds:o.blockedNodeKinds}}),o.allowedPortCategories?.length){const t=n?.manifest.connections?.find(t=>t.id===e.sourcePort)?.category;t&&o.allowedPortCategories.includes(t)||r.push({code:"connection.policy",path:`edges[${e.id}]`,message:`Connection edge '${e.id}' source port '${e.sourcePort}' category '${t??"unknown"}' is not in the allowed port categories of target port '${e.targetPort}'`,edgeId:e.id,nodeId:e.sourceNodeId,details:{allowedPortCategories:o.allowedPortCategories}})}}}class ei{constructor(e){this.authorizer=e}async validate(e,t,o,r){const n=this.collectReferences(e,t);for(const i of t.credentials??[]){const a=n.find(e=>void 0===e.credentialType||e.credentialType===i.type);if(a){if(this.checkType(a,i))o.push({code:"credential.type-mismatch",path:r,message:`Node '${e.id}' credential '${a.credentialId}' has type '${a.credentialType}' but kind '${t.kind}' requires '${i.type}'`,nodeId:e.id,details:{credentialType:a.credentialType??"",requiredType:i.type}});else if(this.authorizer){if(!await this.authorizer.hasCredential(a)){o.push({code:"credential.not-found",path:r,message:`Node '${e.id}' references credential '${a.credentialId}' which does not exist`,nodeId:e.id,details:{credentialId:a.credentialId}});continue}await this.authorizer.authorize(a,i)||o.push({code:"credential.unauthorized",path:r,message:`Node '${e.id}' is not authorized to use credential '${a.credentialId}'`,nodeId:e.id,details:{credentialId:a.credentialId}})}}else!1!==i.required&&o.push({code:"credential.missing",path:r,message:`Node '${e.id}' does not provide the required credential of type '${i.type}'`,nodeId:e.id,details:{credentialType:i.type}})}this.scanPlainSecrets(e,o,r)}collectReferences(e,t){const o=[];for(const r of t.parameters){if("credential"!==r.type)continue;const t=(e.parameters??{})[r.id];Nn(t)&&o.push(this.normalize(t,r.credentialType))}const r=(e.metadata??{}).credentials;if(r&&"object"==typeof r&&!Array.isArray(r))for(const e of Object.values(r))Nn(e)&&o.push(this.normalize(e));return o}normalize(e,t){return"string"==typeof e?{credentialId:e,credentialType:t??""}:{credentialId:e.credentialId,credentialType:e.credentialType??t??""}}checkType(e,t){return void 0!==e.credentialType&&e.credentialType!==t.type}scanPlainSecrets(e,t,o){const r=new Set(Pn.map(e=>e.toLowerCase()));for(const[n,i]of Object.entries(e.parameters??{}))this.scanPlainSecretValue(i,[n],e,o+".parameters",r,t);for(const[n,i]of Object.entries(e.metadata??{}))this.scanPlainSecretValue(i,[n],e,o+".metadata",r,t)}scanPlainSecretValue(e,t,o,r,n,i,a=0){const s=t[t.length-1];if(n.has(s.toLowerCase()))i.push({code:"credential.plain-secret",path:`${r}.${t.join(".")}`,message:`Node '${o.id}' carries plain secret material in '${t.join(".")}'; workflow documents may only hold credential references`,nodeId:o.id});else if(8>a&&null!==e)if(Array.isArray(e))for(const s of e)this.scanPlainSecretValue(s,[...t,"[]"],o,r,n,i,a+1);else if("object"==typeof e)for(const[s,d]of Object.entries(e))this.scanPlainSecretValue(d,[...t,s],o,r,n,i,a+1)}}class ti extends S{constructor(e,t=[]){super(e),this.issues=t,this.name=ti.name}}class oi extends S{constructor(e,t){super(e),this.edgeId=t,this.name=oi.name}}class ri extends F{constructor(e){super(e),this.name=ri.name}}const ni={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},ii=["node","definition","executor","execute","ports","component"];function ai(e){if(!e||"object"!=typeof e)return!1;const t=e;return _o(t.document)&&Array.isArray(t.nodes)&&Array.isArray(t.edges)&&t.nodeById instanceof Map&&t.incomingByNode instanceof Map&&t.outgoingByNode instanceof Map&&t.nodes.every(e=>null!==e&&"object"==typeof e&&"object"==typeof e.instance&&"object"==typeof e.manifest&&"object"==typeof e.executor)}function si(e,t){const o=[];for(const r of Object.keys(e))ii.includes(r)&&o.push({code:"document.forbidden-field",path:`${t}.${r}`,message:`Field '${r}' is not accepted in a canonical workflow document: node, definition, executor, execute, ports and component fields are rejected`,details:{field:r}});return o}class di{constructor(e){this.options=e,this.parameterValidator=new Dn,this.edgeValidator=new Yn,this.connectionPolicyValidator=new Zn,this.nodeValidator=new Jn(e.catalogue,{deploymentProjection:!0===e.deploymentProjection}),this.credentialValidator=new ei(e.credentialAuthorizer)}async validateOrThrow(e,...t){const o=await this.validate(e,0,...t);if(!o.valid||!o.resolved)throw new ti(`Graph workflow document '${e.id}' failed validation with ${o.issues.length} issue(s)`,o.issues);return o.resolved}async validate(e,t=0,...o){const r=[],n={...ni,...this.options.limits};if(!await this.validateStructure(e,n,t,r,...o))return{valid:!1,issues:r};const i=await this.nodeValidator.resolveNodes(e.nodes,r,this.options.resolutionContext,...o),a=e.nodes.filter(e=>i.has(e.id)).map(e=>i.get(e.id)),s=(e=>{const t=new Map;for(const o of e.edges??[]){if("data"!==o.type)continue;const e=o.target;if("node"!==e.scope)continue;const r=t.get(e.nodeId)??new Set;r.add(e.port),t.set(e.nodeId,r)}return t})(e);for(const e of a)this.parameterValidator.validate(e.instance,e.manifest,r,`nodes[${e.instance.id}]`,s.get(e.instance.id));for(const e of a)this.nodeValidator.validateEffectivePorts(e.instance,e.manifest,r,`nodes[${e.instance.id}]`);const d=this.edgeValidator.resolveEdges(e,i,r),l=new Map,c=new Map;for(const e of d){if(e.targetNodeId!==ar){const t=l.get(e.targetNodeId)??[];t.push(e),l.set(e.targetNodeId,t)}if(e.sourceNodeId!==ar){const t=c.get(e.sourceNodeId)??[];t.push(e),c.set(e.sourceNodeId,t)}}this.connectionPolicyValidator.validate({edges:d,nodeById:i},r),this.validateAcyclicity(a,d,e,r),!0!==this.options.deploymentProjection&&Xn(e,r);for(const e of a)this.parameterValidator.validateBindingSatisfaction(e.instance,e.manifest,l.get(e.instance.id)??[],r,`nodes[${e.instance.id}]`,{allowLiteralAndEdgeBindings:this.options.allowLiteralAndEdgeBindings});this.validateRequiredWorkflowOutputs(e,c,r);for(const e of a)await this.credentialValidator.validate(e.instance,e.manifest,r,`nodes[${e.instance.id}]`);return this.validateCapabilities(a,r),r.length>0?{valid:!1,issues:r}:{valid:!0,issues:r,resolved:{document:e,nodes:a,edges:d,nodeById:i,incomingByNode:l,outgoingByNode:c}}}async validateStructure(e,t,o,r,...n){if(!_o(e))return r.push({code:"document.shape",path:"$",message:"Payload is not a canonical GraphWorkflowDocument: id and name must be strings and inputs, outputs, nodes and edges must be arrays"}),!1;if(e.id&&e.id.trim()||r.push({code:"document.empty-id",path:"$.id",message:"Workflow document id must be a non-empty string"}),!Vt(e))return r.push({code:"document.json-unsafe",path:"$",message:"Document contains JSON-unsafe values: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys are rejected"}),!1;r.push(...si(e,"$"));for(const t of[...e.inputs,...e.outputs])r.push(...si(t,"ports"));for(const t of e.nodes)r.push(...si(t,`nodes[${t.id}]`));for(const t of e.edges)r.push(...si(t,`edges[${t.id}]`));this.validateUniqueIds(e,r),this.validateLimits(e,t,o,r);try{go(e)}catch(e){r.push({code:"document.structure",path:"$",message:e instanceof Error?e.message:e+""})}return await this.validateNestedBodies(e,o,r,...n),!0}validateUniqueIds(e,t){const o=new Set,r=new Set;for(const[n,i]of[["input",e.inputs],["output",e.outputs]]){const e="input"===n?o:r;for(const o of i)e.has(o.id)?t.push({code:"document.duplicate-port-id",path:`${"input"===n?"inputs":"outputs"}[${o.id}]`,message:`Workflow ${n} port '${o.id}' is declared more than once; workflow port ids must be unique`}):e.add(o.id)}const n=new Set;for(const o of e.nodes)n.has(o.id)?t.push({code:"document.duplicate-node-id",path:`nodes[${o.id}]`,message:`Node '${o.id}' is declared more than once; node ids must be unique`,nodeId:o.id}):n.add(o.id);const i=new Set;for(const o of e.edges)i.has(o.id)?t.push({code:"document.duplicate-edge-id",path:`edges[${o.id}]`,message:`Edge '${o.id}' is declared more than once; edge ids must be unique`,edgeId:o.id}):i.add(o.id)}validateLimits(e,t,o,r){e.nodes.length>t.maxNodes&&r.push({code:"document.limit.nodes",path:"$.nodes",message:`Document declares ${e.nodes.length} nodes; at most ${t.maxNodes} are allowed`,details:{count:e.nodes.length,limit:t.maxNodes}}),e.edges.length>t.maxEdges&&r.push({code:"document.limit.edges",path:"$.edges",message:`Document declares ${e.edges.length} edges; at most ${t.maxEdges} are allowed`,details:{count:e.edges.length,limit:t.maxEdges}}),o>t.maxNestingDepth&&r.push({code:"document.limit.depth",path:"$",message:`Document nests loop bodies ${o} levels deep; at most ${t.maxNestingDepth} levels are allowed`,details:{depth:o,limit:t.maxNestingDepth}});const n=Buffer.byteLength(JSON.stringify(e),"utf8");n>t.maxDocumentBytes&&r.push({code:"document.limit.size",path:"$",message:`Document serializes to ${n} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,details:{bytes:n,limit:t.maxDocumentBytes}})}async validateNestedBodies(e,t,o,...r){for(const n of e.nodes){const e=[["loop.body",n.loop?.body],["errorBoundary.try",n.errorBoundary?.try],["errorBoundary.catch",n.errorBoundary?.catch],["errorBoundary.finally",n.errorBoundary?.finally]];for(const[i,a]of e){if(!a)continue;const e=await this.validate(a,t+1,...r);for(const t of e.issues)o.push({...t,path:`nodes[${n.id}].${i}.${t.path}`,nodeId:t.nodeId??n.id})}}}validateAcyclicity(e,t,o,r){const n=new Set(e.map(e=>e.instance.id)),i=new Map(e.map(e=>[e.instance.id,0]));for(const e of t)n.has(e.sourceNodeId)&&i.has(e.targetNodeId)&&i.set(e.targetNodeId,(i.get(e.targetNodeId)??0)+1);const a=[...i.entries()].filter(([,e])=>0===e).map(([e])=>e),s=[];for(;a.length>0;){const e=a.shift();s.push(e);for(const o of t){if(o.sourceNodeId!==e)continue;if(!i.has(o.targetNodeId))continue;const t=(i.get(o.targetNodeId)??1)-1;i.set(o.targetNodeId,t),0===t&&a.push(o.targetNodeId)}}if(s.length!==i.size){const e=[...i.keys()].filter(e=>!s.includes(e));r.push({code:"topology.cycle",path:"$.edges",message:`Workflow '${o.id}' contains an unsupported cycle involving node(s): ${e.join(", ")}`,details:{cyclicNodes:e}})}}validateRequiredWorkflowOutputs(e,t,o){const r=new Set;for(const e of t.values())for(const t of e)t.targetNodeId===ar&&r.add(t.targetPort);for(const t of e.outputs)!0===t.required&&void 0===t.defaultValue&&(r.has(t.id)||o.push({code:"topology.required-output-unsatisfiable",path:`outputs[${t.id}]`,message:`Required workflow output '${t.id}' has no incoming edge from any node`}))}validateCapabilities(e,t){for(const o of e){const e=o.manifest;for(const r of e.capabilities??[])So(r)||t.push({code:"capability.invalid",path:`nodes[${o.instance.id}]`,message:`Kind '${e.kind}' declares unknown capability '${r+""}'`,nodeId:o.instance.id,details:{capability:r+""}});!0!==e.policies?.allowUndeclaredParameters&&o.instance.loop&&((e.capabilities??[]).includes("loop")||t.push({code:"capability.loop-not-supported",path:`nodes[${o.instance.id}].loop`,message:`Node '${o.instance.id}' carries loop configuration but kind '${e.kind}' does not declare the 'loop' capability`,nodeId:o.instance.id}))}}}let li=class extends B{constructor(){super()}async plan(e,...t){const{log:o}=(await this.logCtx(t,"plan",!0)).for(this.plan);if(o.debug(`Planning resolved workflow '${e?.document?.id??"unknown"}'`),!ai(e))throw new Mr("GraphExecutionPlanner.plan accepts only a GraphResolvedWorkflow produced by the nine-stage validation gate; raw workflow definitions and inline node definitions are rejected",{received:(r=e,r&&"object"==typeof r?{reason:"input is not a GraphResolvedWorkflow",looksLikeWorkflowDefinition:"nodes"in r&&"relations"in r&&!("nodeById"in r),hasResolvedNodes:Array.isArray(r.nodes)}:{reason:"input is not an object"})});var r;const n=this.buildPlanNodes(e),i=this.buildPlanEdges(e),a=this.buildIncomingMap(i),s=this.buildOutgoingMap(i),d=this.topologicalLayers(n,i);return{resolved:e,workflowId:e.document.id||e.document.name,nodes:n,edges:i,layers:d,incomingByNode:a,outgoingByNode:s}}buildPlanNodes(e){return e.nodes.map(e=>({id:e.instance.id,kind:e.manifest.kind,instance:e.instance,manifest:e.manifest,executor:e.executor,inputPorts:e.manifest.inputs.map(e=>e.id),outputPorts:e.manifest.outputs.map(e=>e.id),connectionPorts:(e.manifest.connections??[]).map(e=>e.id),metadata:e.instance.metadata}))}buildPlanEdges(e){return e.edges.map(e=>({id:e.id,type:e.type,sourceNodeId:e.sourceNodeId,sourcePort:e.sourcePort,targetNodeId:e.targetNodeId,targetPort:e.targetPort,...void 0!==e.label?{label:e.label}:{},metadata:e.metadata}))}buildIncomingMap(e){const t=new Map;for(const o of e){if(o.targetNodeId===ar)continue;const e=t.get(o.targetNodeId)??[];e.push(o),t.set(o.targetNodeId,e)}return t}buildOutgoingMap(e){const t=new Map;for(const o of e){if(o.sourceNodeId===ar)continue;const e=t.get(o.sourceNodeId)??[];e.push(o),t.set(o.sourceNodeId,e)}return t}topologicalLayers(e,t){const o=e.filter(e=>e.id!==ar),r=new Set(o.map(e=>e.id)),n=t.filter(e=>r.has(e.sourceNodeId)&&r.has(e.targetNodeId)),i=new Map;for(const e of o)i.set(e.id,0);for(const e of n)i.set(e.targetNodeId,(i.get(e.targetNodeId)??0)+1);const a=[],s=new Set;let d=o.filter(e=>0===(i.get(e.id)??0)),l=0;for(;d.length>0;){const e={index:l++,nodes:d};a.push(e);const t=[];for(const e of d){s.add(e.id);const r=n.filter(t=>t.sourceNodeId===e.id);for(const e of r){const r=(i.get(e.targetNodeId)??1)-1;if(i.set(e.targetNodeId,r),0===r&&!s.has(e.targetNodeId)){const r=o.find(t=>t.id===e.targetNodeId);r&&t.push(r)}}}d=t}if(s.size!==o.length){const e=o.filter(e=>!s.has(e.id)).map(e=>e.id);throw new Nr({unplannedNodes:e,workflowId:o[0]?.manifest.kind})}return a}};li=k([H(),C("design:paramtypes",[])],li);class ci{constructor(){this.pending=new Map}register(e,t){return this.cancel(e),new Promise((o,r)=>{const n={resolve:o};void 0!==t&&Number.isFinite(t)&&t>0&&(n.timer=setTimeout(()=>{this.pending.delete(e),r(new Cr(`No webhook response was produced for run '${e}' within ${t}ms`,"GRAPH_WEBHOOK_RESPONSE_TIMEOUT",{runId:e,timeoutMs:t}))},t),n.timer.unref?.()),this.pending.set(e,n)})}has(e){return this.pending.has(e)}deliver(e,t){const o=this.pending.get(e);return!!o&&(o.timer&&clearTimeout(o.timer),this.pending.delete(e),o.resolve(t),!0)}cancel(e){const t=this.pending.get(e);t&&(t.timer&&clearTimeout(t.timer),this.pending.delete(e))}clear(){for(const e of[...this.pending.keys()])this.cancel(e)}}let pi=class extends j{constructor(e){super(e)}};k([N({type:String,generated:!1}),C("design:type",String)],pi.prototype,"id",void 0),k([T(),P(),C("design:type",String)],pi.prototype,"tableName",void 0),k([T(),P(),C("design:type",String)],pi.prototype,"rowId",void 0),k([T(),C("design:type",Object)],pi.prototype,"data",void 0),k([T(),C("design:type",Date)],pi.prototype,"createdAt",void 0),k([T(),C("design:type",Date)],pi.prototype,"updatedAt",void 0),pi=k([D("graph_data_table"),I(),C("design:paramtypes",[Object])],pi);const ui=/^[A-Za-z0-9_.-]+$/;function gi(e,t){return`${e}:${t}`}function hi(e){if(!e||e.length>128||!ui.test(e))throw new Cr(`Data table name '${e}' is invalid`,"GRAPH_DATA_TABLE_INVALID_NAME",{tableName:e})}function fi(e){if(!e||e.length>256)throw new Cr(`Data table row id '${e}' is invalid`,"GRAPH_DATA_TABLE_INVALID_ROW_ID",{rowId:e})}function yi(e){let t;try{t=JSON.stringify(e)}catch{throw new Cr("Data table row payload is not JSON-serializable","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{limitBytes:Er})}if(void 0===t)throw new Cr("Data table row payload is not JSON-serializable","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{limitBytes:Er});const o=Buffer.byteLength(t,"utf8");if(o>Er)throw new Cr("Data table row payload exceeds the 1048576-byte limit","GRAPH_DATA_TABLE_ROW_TOO_LARGE",{bytes:o,limitBytes:Er})}function mi(e){return{...e.data,id:e.rowId}}let bi=class extends ${constructor(e){super(e,pi,!0)}async insertRow(e,t,o,...r){hi(e),fi(t),yi(o),await this.assertRowCapacity(e,...r);const n=new Date,i=new pi({id:gi(e,t),tableName:e,rowId:t,data:{...o},createdAt:n,updatedAt:n});return mi(await this.create(i,...r))}async upsertRow(e,t,o,...r){if(hi(e),fi(t),yi(o),!await this.readRow(e,t,...r))return this.insertRow(e,t,o,...r);const n=await this.read(gi(e,t),...r);return n.data={...o},n.updatedAt=new Date,mi(await this.update(n,...r))}async readRow(e,t,...o){hi(e),fi(t);try{return mi(await this.read(gi(e,t),...o))}catch{return}}async listRows(e,t,...o){hi(e);const r=void 0!==t&&Number.isFinite(t)&&t>=0?Math.floor(t):Ar;if(0===r)return[];const n=Math.min(r,Ar);return(await this.select().where(q.attr("tableName").eq(e)).orderBy("rowId",W.ASC).limit(n).execute(...o)).map(mi)}async assertRowCapacity(e,...t){if((await this.listRows(e,_r,...t)).length>=_r)throw new Cr(`Data table '${e}' reached the 10000-row limit`,"GRAPH_DATA_TABLE_ROW_LIMIT_EXCEEDED",{tableName:e,limit:_r})}async deleteRow(e,t,...o){hi(e),fi(t);try{return await this.delete(gi(e,t),...o),!0}catch{return!1}}async clearTable(e,...t){const o=await this.listRows(e,void 0,...t);for(const r of o)await this.deleteRow(e,r.id+"",...t);return o.length}};function wi(e){return new(0,$.forModel(pi,e.alias).constructor)(e)}bi=k([U(pi,y),C("design:paramtypes",[Function])],bi);const vi=new Set(["engine","valueAdapter","codeSandboxEvaluator","workflowStore"]);function xi(e){for(let t=e.length-1;t>=0;t-=1){const o=e[t];if(!o||"object"!=typeof o)continue;const r=o;if("function"==typeof r.get&&"function"==typeof r.accumulate&&void 0!==r.cache)return en(o)}return{}}function Ii(e,t){const o={};for(const[r,n]of Object.entries(e??{}))vi.has(r)&&!t.has(r)||(o[r]=n);return o}class _i extends K{constructor(){super(),this.webhookResponseRegistry=new ci,this.runSubWorkflowDepth=new Map,this.runRootId=new Map,this.rootChildRunCounts=new Map}async initialize(...e){const t=e[0];if(!t||"object"!=typeof t||!t.registry)return this._config=void 0,this._client=void 0,{config:void 0,client:void 0};const o=t.catalogue??t.registry.catalog,r=t.valueAdapter??V.current;if(!r)throw new Cr("GraphExecutionEngine requires a Decaf adapter for cached/pinned values: pass `valueAdapter` or configure one via `Adapter.setCurrent(...)`","GRAPH_VALUE_ADAPTER_MISSING");const n=t.backend??hn.current??new Vn;if("deployment"===n.documentValidation&&n.local)throw new Cr("A local execution backend cannot declare deployment document validation: deployment projection relaxes catalogue kind resolution and must stay bound to the remote backend that owns the authoritative deployment artifact","GRAPH_DEPLOYMENT_PROJECTION_REQUIRES_REMOTE_BACKEND");const i={registry:t.registry,catalogue:o,planner:t.planner??new li,backend:n,valueAdapter:r,eventEmitter:t.eventEmitter??new Fr,documentValidator:t.documentValidator??new di({catalogue:o,limits:t.documentLimits,credentialAuthorizer:t.credentialAuthorizer,deploymentProjection:"deployment"===n.documentValidation}),authValidator:new rn({enabled:!0===t.authEnabled,...t.authMatch?{match:t.authMatch}:{}}),...t.codeSandboxEvaluator?{codeSandboxEvaluator:t.codeSandboxEvaluator}:{},...t.nodeCredentials?{nodeCredentials:new nn(t.nodeCredentials)}:{}};this._config=t,this._client=i;const a=new Set(["engine","valueAdapter"]);t.codeSandboxEvaluator&&a.add("codeSandboxEvaluator"),t.workflowStore&&a.add("workflowStore");const s=Ii(n.config,a);if(await n.initialize({...s,valueAdapter:r,...t.codeSandboxEvaluator?{codeSandboxEvaluator:t.codeSandboxEvaluator}:{},...t.workflowStore?{workflowStore:t.workflowStore}:{},engine:this}),t.seedWorkflows&&t.seedWorkflows.length>0){const o=n.seedWorkflows;if("function"!=typeof o)throw new Cr(`Graph execution backend '${n.constructor?.name??"GraphExecutionBackend"}' does not support workflow seeding`,"GRAPH_BACKEND_SEED_NOT_SUPPORTED",{backend:n.constructor?.name??"GraphExecutionBackend"});await o.call(n,t.seedWorkflows,...e.slice(1))}return await(t.onEngineCreated?.(this)),{config:t,client:i}}get codeSandboxEvaluator(){return this.client.codeSandboxEvaluator}get nodeCredentials(){return this.client.nodeCredentials}get dataTableStore(){return this.dataTableRepository||(this.dataTableRepository=wi(this.valueAdapter)),this.dataTableRepository}get webhookResponses(){return this.webhookResponseRegistry}get emitter(){return this.client.eventEmitter}get planner(){return this.client.planner}get valueAdapter(){return this.client.valueAdapter}get defaultOptions(){return this.config.defaultOptions??{}}get documentValidator(){return this.client.documentValidator}async validateWorkflowDocument(e,...t){const{ctx:o}=(await this.logCtx(t,"validateWorkflowDocument",!0)).for(this.validateWorkflowDocument);return this.documentValidator.validate(e,0,o)}observe(e){return this.emitter.observe(e)}unObserve(e){this.emitter.unObserve(e)}async dispatchEvent(e){await this.emitter.updateObservers(e)}async execute(e,t={},o={},...r){const{log:n,ctx:i}=(await this.logCtx(r,"execute",!0)).for(this.execute);n.debug(`Executing workflow '${e.id||e.name}'`);const a=this.mergeOptions(o);this.assertNotAborted(a);const s=on(en(i),a.auth);a.auth=s,a.metadata={...a.metadata??{},...s};const d=a.runId??this.generateRunId();a.runId=d;const l=a.path??[];this.enterExecutionBudget(d,a);try{const o=new Hr,c=$n(this.valueAdapter);c.seedWorkflowInputs(this.withWorkflowInputDefaults(e,t));const p=new un(this.emitter,o,{runId:d,parentRunId:a.parentRunId,workflowId:e.id||e.name,path:l,engine:this,...this.codeSandboxEvaluator?{codeSandboxEvaluator:this.codeSandboxEvaluator}:{}});await p.emit({type:yt.VALIDATION_STARTED,status:gt.PLANNING});const u=await this.documentValidator.validate(e,0,i);if(!u.valid||!u.resolved)throw await p.emit({type:yt.VALIDATION_FAILED,status:gt.FAILED,payload:{issues:u.issues}}),new ti(`Graph workflow document '${e.id}' failed validation with ${u.issues.length} issue(s)`,u.issues);await p.emit({type:yt.VALIDATION_COMPLETED,status:gt.PLANNING,payload:{issues:u.issues.length}}),this.assertNotAborted(a);const g=await this.planner.plan(u.resolved);this.client.authValidator.validate(e,g,s,n),n.debug(`Authorized workflow '${e.id||e.name}' for user ${s.user??"anonymous"}`),this.assertCodeModeSupported(e);const h=new cn(d,g,c,o);return p.bindFrame(h),await p.emit({type:yt.WORKFLOW_STARTED,runId:d,parentRunId:a.parentRunId,workflowId:g.workflowId,path:l,status:gt.RUNNING,payload:{inputs:t}}),await p.emit({type:yt.WORKFLOW_PLANNED,runId:d,parentRunId:a.parentRunId,workflowId:g.workflowId,path:l,status:gt.PLANNING,payload:{layers:g.layers.length,nodes:g.nodes.length}}),await this.client.backend.execute({document:e,plan:g,inputs:t,options:a,events:p},...r)}finally{this.releaseExecutionBudget(d)}}get backend(){return this.client.backend}get backendCapabilities(){return gn(this.client.backend)}async listWorkflows(...e){const t=this.client.backend;if("supported"!==gn(t).workflows.list||"function"!=typeof t.listWorkflows)throw new Cr(`Graph execution backend '${this.backendName}' does not support workflow listing`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:this.backendName});return await t.listWorkflows(...e)}async getWorkflow(e,...t){const o=this.client.backend;if("supported"!==gn(o).workflows.get||"function"!=typeof o.getWorkflow)throw new Cr(`Graph execution backend '${this.backendName}' does not support workflow lookup`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:this.backendName,workflowId:e});const r=await o.getWorkflow(e,...t);return this.assertWorkflowReadAccess(r,xi(t)),r}assertWorkflowReadAccess(e,t,o){this.client.authValidator.validateWorkflowRead(e,t,o)}async listEngineWorkflows(e,...t){const o=hn.getOrFail(e);if("supported"!==gn(o).workflows.list||"function"!=typeof o.listWorkflows)throw new Cr(`Graph execution backend '${e}' does not support workflow listing`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:e});return await o.listWorkflows(...t)}async getEngineWorkflow(e,t,...o){const r=hn.getOrFail(e);if("supported"!==gn(r).workflows.get||"function"!=typeof r.getWorkflow)throw new Cr(`Graph execution backend '${e}' does not support workflow lookup`,"GRAPH_BACKEND_WORKFLOWS_NOT_SUPPORTED",{backend:e,workflowId:t});const n=await r.getWorkflow(t,...o);return this.assertWorkflowReadAccess(n,xi(o)),n}get backendName(){return this.client.backend.constructor?.name??"GraphExecutionBackend"}assertCodeModeSupported(e){const t=this.client.backend;if(t.local)return;const o=Rn(e);if(0!==o.length){if("unsupported"===t.codeMode)throw new Cr(`Graph execution backend '${this.backendName}' does not support code-mode workflows`,"GRAPH_CODE_MODE_UNSUPPORTED_BACKEND",{backend:this.backendName,surfaces:o});if(!this.codeSandboxEvaluator)throw new Cr("Code-mode workflows require a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{backend:this.backendName,surfaces:o})}}async pinNode(e){const t=this.createPinningService();await t.pinNode(e),await this.emitPinningEvent(e.nodeId,yt.NODE_PINNED)}async unpinNode(e){const t=this.createPinningService();await t.unpinNode(e),await this.emitPinningEvent(e.nodeId,yt.NODE_UNPINNED)}createPinningService(){const e=$n(this.valueAdapter);return new Hn(e,new Wn,new Kn)}async emitPinningEvent(e,t){const o=(new Hr).create({id:"",sequence:0,timestamp:new Date,runId:"pinning",workflowId:"",type:t,nodeId:e,path:[]});await this.emitter.updateObservers(o)}withWorkflowInputDefaults(e,t){const o={...t};for(const t of e.inputs)void 0===o[t.id]&&void 0!==t.defaultValue&&(o[t.id]=t.defaultValue);return o}mergeOptions(e){return{concurrency:4,failFast:!0,validateInputs:!0,validateOutputs:!0,maxLoopIterations:ur,maxForeachIterations:gr,usePinnedValues:!0,writeThroughCache:!1,path:[],metadata:{},...this.defaultOptions,...e}}assertNotAborted(e){if(!0===e.abortSignal?.aborted)throw new Ur(e.runId??"unknown")}enterExecutionBudget(e,t){const o=t.parentRunId,r=t.path??[],n="subworkflow"===r[r.length-1],i=r.filter(e=>"subworkflow"===e).length,a=o?this.runSubWorkflowDepth.get(o)??Math.max(0,i-(n?1:0)):0,s=o?a+(n?1:0):0,d=t.maxSubWorkflowDepth??10;if(s>d)throw new Cr(`Graph run '${e}' exceeds the maximum sub-workflow depth of ${d}`,"GRAPH_SUB_WORKFLOW_DEPTH_EXCEEDED",{runId:e,parentRunId:o,depth:s,maxDepth:d});if(!o)return this.runSubWorkflowDepth.set(e,s),this.runRootId.set(e,e),void this.rootChildRunCounts.set(e,0);const l=this.runRootId.get(o)??o,c=t.maxChildRuns??1e3;let p=this.rootChildRunCounts.get(l)??0;if(n){if(p+=1,p>c)throw new Cr(`Graph run '${l}' exceeds the maximum of ${c} sub-workflow child runs`,"GRAPH_SUB_WORKFLOW_CHILD_LIMIT_EXCEEDED",{runId:e,rootRunId:l,parentRunId:o,childCount:p,maxChildren:c});this.rootChildRunCounts.set(l,p)}this.runSubWorkflowDepth.set(e,s),this.runRootId.set(e,l)}releaseExecutionBudget(e){const t=this.runRootId.get(e);this.runSubWorkflowDepth.delete(e),this.runRootId.delete(e),t===e&&this.rootChildRunCounts.delete(e)}generateRunId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new Cr("Cannot generate a graph run id: crypto.randomUUID is unavailable in this runtime","GRAPH_RUN_ID_ERROR",{runtime:typeof globalThis.crypto});return e.randomUUID()}}const Ei=new Set(["process","require","module","exports","global","globalThis","Function","eval","fetch","XMLHttpRequest","WebSocket","Worker","Deno","Bun","__dispatch"]);class Ai extends K{constructor(){super()}async initialize(...e){const t=e[0]??{},o=t&&"object"==typeof t?t:{};return this._config=o,this._client=Q,{config:o,client:Q}}get defaultTimeoutMs(){return this.config.timeoutMs??1e3}get defaultMemoryMb(){return this.config.memoryMb??32}async evaluate(e,...t){(await this.logCtx(t,"evaluate",!0)).for(this.evaluate);const o=e.code;if(!o||"string"!=typeof o||0===o.trim().length)throw new Cr("Code sandbox received empty code","GRAPH_CODE_SANDBOX_EMPTY_CODE");const r=((e,t)=>"javascript"===t?e:Y.transpileModule(e,{compilerOptions:{target:Y.ScriptTarget.ES2022,module:Y.ModuleKind.None,strict:!0,noEmitHelpers:!0,importHelpers:!1}}).outputText.replace(/^"use strict";\s*/,""))(o,e.language??"javascript");(e=>{if(e.length>1e5)throw new Cr("Code exceeds the maximum length of 100000 characters","GRAPH_CODE_SANDBOX_CODE_TOO_LONG",{length:e.length});let t;try{t=J.parse(`async function __validate() {\n${e}\n}`,{ecmaVersion:"latest",sourceType:"script"})}catch{try{t=J.parse(e,{ecmaVersion:"latest",sourceType:"module"})}catch(t){throw new Cr("Code failed to parse: "+t.message,"GRAPH_CODE_SANDBOX_PARSE_ERROR",{code:e,error:t.message})}}X.full(t,e=>{const t=e;if("ImportDeclaration"===t.type)throw new Cr("Imports are not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"import"});if("ExportNamedDeclaration"===t.type||"ExportDefaultDeclaration"===t.type)throw new Cr("Exports are not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"export"});if("Identifier"===t.type&&"string"==typeof t.name&&Ei.has(t.name))throw new Cr(`Identifier "${t.name}" is not allowed in Code nodes.`,"GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:t.name});if("NewExpression"===t.type&&"Function"===t.callee?.name)throw new Cr("new Function() is not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"Function"});if("CallExpression"===t.type&&"eval"===t.callee?.name)throw new Cr("eval() is not allowed in Code nodes.","GRAPH_CODE_SANDBOX_FORBIDDEN_TOKEN",{token:"eval"})})})(r);const n=!(e=>/\breturn\b[\s;]/.test(e))(r),i=n?r.replace(/[\s;]+$/,""):r,a={$input:e.input??{},$vars:e.vars??{},$item:e.item,$index:e.index,$node:e.nodes??{},$output:void 0},s=Object.keys(a),d=n?`return (${i});`:i,l=`"use strict";\nasync function __userFunction(${s.join(", ")}) {\n${d}\n}\n__userFunction(${s.join(", ")}).then(function(__r) { return JSON.stringify({ v: __r }); });`,c=new Q.Isolate({memoryLimit:this.defaultMemoryMb}),p=await c.createContext();try{const t=p.global;e.logger&&await this.injectConsole(p,e.logger);for(const[e,o]of Object.entries(a))await t.set(e,new Q.ExternalCopy(void 0===o?null:o).copyInto());let o;try{o=await c.compileScript(l,{filename:"graph-code-node.js"})}catch(e){if(!n)throw new Cr("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:r,error:e.message});{const e=i,t=`"use strict";\nasync function __userFunction(${s.join(", ")}) {\n${e}\n}\n__userFunction(${s.join(", ")}).then(function(__r) { return JSON.stringify({ v: __r }); });`;try{o=await c.compileScript(t,{filename:"graph-code-node.js"})}catch(e){throw new Cr("Code failed to compile: "+e.message,"GRAPH_CODE_SANDBOX_COMPILE_ERROR",{code:r,error:e.message})}}}const d=e.timeoutMs??this.defaultTimeoutMs;let u;try{u=await this.runBounded(o,p,d,e.abortSignal)}catch(e){if(e instanceof Cr)throw e;const t=e.message;if(t.includes("timed out")||t.includes("timeout"))throw new Cr(`Code execution timed out after ${d} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:d});if(t.includes("memory")||t.includes("heap"))throw new Cr(`Code exceeded the memory limit of ${this.defaultMemoryMb} MB`,"GRAPH_CODE_SANDBOX_MEMORY_LIMIT",{memoryMb:this.defaultMemoryMb});throw new Cr("Code execution failed: "+t,"GRAPH_CODE_SANDBOX_RUNTIME_ERROR",{code:r,error:t})}if("string"!=typeof u)throw new Cr("Code sandbox returned an unexpected non-string result","GRAPH_CODE_SANDBOX_UNEXPECTED_RESULT",{result:u});return JSON.parse(u).v}finally{p.release(),c.dispose()}}async runBounded(e,t,o,r){const n=e.run(t,{timeout:o,promise:!0});n.catch(()=>{});const i=[n];let a,s;try{return i.push(new Promise((e,t)=>{a=setTimeout(()=>{t(new Cr(`Code execution timed out after ${o} ms`,"GRAPH_CODE_SANDBOX_TIMEOUT",{timeoutMs:o}))},o+100)})),r&&i.push(new Promise((e,t)=>{const n=()=>{const e="timeout"===r.reason;t(new Cr(e?`Code execution timed out after ${o} ms`:"Code execution aborted",e?"GRAPH_CODE_SANDBOX_TIMEOUT":"GRAPH_CODE_SANDBOX_ABORTED",{timeoutMs:o,reason:r.reason}))};r.aborted?n():(r.addEventListener("abort",n,{once:!0}),s=()=>r.removeEventListener("abort",n))})),await Promise.race(i)}finally{a&&clearTimeout(a),s?.()}}async injectConsole(e,t){const o=new Q.Reference((e,o)=>{let r;try{r=JSON.parse(o)}catch{r=[o]}const n=r.map(e=>"string"==typeof e?e:JSON.stringify(e)).join(" "),i=1===r.length?r[0]:r;switch(e){case"log":case"info":default:t.info(n,i);break;case"warn":t.warn(n,i);break;case"error":t.error(n,i);break;case"debug":case"dir":case"dirxml":case"table":t.debug(n,i);break;case"trace":t.trace(n,i);break;case"group":case"groupCollapsed":t.debug("[group] "+n,i);break;case"groupEnd":t.debug("[groupEnd]",void 0);break;case"time":case"timeEnd":case"timeLog":case"count":case"countReset":t.debug(`[${e}] ${n}`,i);break;case"assert":r[0]||t.error("Assertion failed: "+n,i);case"clear":}});await e.evalClosure("\n function __ser() {\n var out = [];\n for (var i = 0; i < arguments.length; i++) {\n var a = arguments[i];\n try { out.push(typeof a === 'object' ? JSON.parse(JSON.stringify(a)) : a); }\n catch (e) { out.push(String(a)); }\n }\n return JSON.stringify(out);\n }\n function __call(level) {\n return function() {\n $0.applySync(undefined, [level, __ser.apply(null, arguments)]);\n };\n }\n globalThis.console = {\n log: __call('log'),\n info: __call('info'),\n warn: __call('warn'),\n error: __call('error'),\n debug: __call('debug'),\n trace: __call('trace'),\n dir: __call('dir'),\n dirxml: __call('dirxml'),\n table: __call('table'),\n group: __call('group'),\n groupCollapsed: __call('groupCollapsed'),\n groupEnd: __call('groupEnd'),\n time: __call('time'),\n timeEnd: __call('timeEnd'),\n timeLog: __call('timeLog'),\n assert: __call('assert'),\n count: __call('count'),\n countReset: __call('countReset'),\n clear: __call('clear')\n };\n ",[o]),o.release()}}class Si extends R{constructor(e){super(e,Si.name,500)}}class Ri extends O{constructor(e){super(e),this.name=Ri.name}}class Oi extends O{constructor(e){super(e),this.name=Oi.name}}class ki{constructor(e,t,o={}){this.kind=e,this.declarations=new Map,this.implementations=new Map;for(const e of t){if("string"!=typeof e?.name||!e.name)throw new Si(`Method declaration for kind '${this.kind}' is missing a name`);if(this.declarations.has(e.name))throw new Si(`Kind '${this.kind}' declares duplicate method '${e.name}'`);this.declarations.set(e.name,e)}for(const[e,t]of Object.entries(o)){if("function"!=typeof t)throw new Si(`Method implementation '${e}' for kind '${this.kind}' is not a function`);if(!this.declarations.has(e))throw new Si(`Kind '${this.kind}' implements method '${e}' which is not declared by its manifest`);this.implementations.set(e,t)}for(const e of this.declarations.keys())if(!this.implementations.has(e))throw new Si(`Kind '${this.kind}' declares method '${e}' with no implementation`)}has(e){return this.declarations.has(e)}getDeclaration(e){const t=this.declarations.get(e);if(!t)throw new Oi(`Kind '${this.kind}' does not declare method '${e}'`);return t}get(e){return this.getDeclaration(e),this.implementations.get(e)}list(){return[...this.declarations.values()].sort((e,t)=>e.name<t.name?-1:e.name>t.name?1:0)}}function Ci(e,t){if(!t)return;let o=e;for(const e of t.split(".")){if(!o||"object"!=typeof o)return;o=o[e]}return o}function Ni(e,t,o){const r=Ci(t,e.itemIdPath),n=e.itemLabelPath?Ci(t,e.itemLabelPath):void 0;return{id:"string"==typeof r&&r||"number"==typeof r&&Number.isFinite(r)&&r+""||o+"",label:"string"==typeof n?n:void 0}}function Ti(e,t){switch(t){case"input":return e.inputs;case"output":return e.outputs;default:return e.connections}}function Pi(e,t){const o={inputs:[],outputs:[],connections:[]},r={input:new Set((e.inputs??[]).map(e=>e.id)),output:new Set((e.outputs??[]).map(e=>e.id)),connection:new Set((e.connections??[]).map(e=>e.id))},n=(e,t)=>{const o=r[e];return!o.has(t)&&(o.add(t),!0)};for(const r of e.dynamicPorts??[])if("repeatFromParameter"===r.type){const e=t[r.parameter];if(!Array.isArray(e))continue;const i=Ti(o,r.direction);e.forEach((e,t)=>{const{id:o,label:a}=Ni(r,e,t),s=(d={id:o,index:t,label:a??o},r.portIdTemplate.replaceAll("${id}",d.id).replaceAll("${index}",d.index+"").replaceAll("${label}",d.label));var d;if(!n(r.direction,s))return;const l=r.defaultPort?zt(r.defaultPort):{id:s,label:a??s,direction:r.direction};l.id=s,l.direction=r.direction,a&&(l.label=a),i.push(l)})}else if("togglePort"===r.type){if(t[r.parameter]!==r.equals)continue;const e=zt(r.port);if(!n(e.direction,e.id))continue;Ti(o,e.direction).push(e)}return o}function Di(e,t){const o=Pi(e,t),r={kind:e.kind,display:e.display,inputs:[...e.inputs,...o.inputs],outputs:[...e.outputs,...o.outputs],parameters:e.parameters},n=[...e.connections??[],...o.connections];return n.length&&(r.connections=n),e.dynamicPorts?.length&&(r.dynamicPorts=e.dynamicPorts),e.credentials?.length&&(r.credentials=e.credentials),e.capabilities?.length&&(r.capabilities=e.capabilities),e.policies&&(r.policies=e.policies),e.metadata&&(r.metadata=e.metadata),e.namespaces?.length&&(r.namespaces=e.namespaces),zt(r)}class ji{async resolve(e,t,o,r,n){if(o){const i=await o(r,n);if(!(e=>{if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=e;return"string"==typeof t.kind&&"object"==typeof t.display&&null!==t.display&&Array.isArray(t.inputs)&&Array.isArray(t.outputs)&&Array.isArray(t.parameters)})(i))throw new Si(`resolveManifest provider for kind '${e}' returned a value that does not conform to GraphResolvedNodeManifest`);if(!Vt(i))throw new Si(`resolveManifest provider for kind '${e}' returned a non-JSON-safe resolved manifest`);const a=zt(i);return!a.namespaces?.length&&t.namespaces?.length&&(a.namespaces=t.namespaces.slice()),a}return Di(t,r.parameters??{})}}const Li=["edge","literal","expression"];function Mi(e){return Li.includes(e)}function Gi(e,t,o){if("string"!=typeof o||!o)throw new Si(`Manifest for kind '${e}' has a ${t} with an empty port id`);if(Bt(o))throw new Si(`Manifest for kind '${e}' has a ${t} with unsafe port id '${o}'`)}let Ui=class extends B{constructor(){super(),this.entries=new Map,this.resolver=new ji,this.fallbackContext=new G}withContext(e){return e[e.length-1]instanceof G?e:[this.fallbackContext]}register(e,t={},...o){const{log:r}=this.logCtx(this.withContext(o),"register").for(this.register);r.debug(`Registering graph node kind '${e?.manifest?.kind??"unknown"}'`),(e=>{if(!e||"object"!=typeof e)throw new Si("Graph node registration is required");if(!e.manifest||"object"!=typeof e.manifest)throw new Si("Graph node registration is missing a manifest");if(!e.executor||"function"!=typeof e.executor.execute)throw new Si(`Graph node registration for kind '${e.manifest?.kind+""}' is missing an executor`)})(e);const n=e.manifest;if("string"!=typeof n.kind||!n.kind.trim())throw new Si("Graph node manifest kind is required and must be a non-empty string");const i=n.kind;if(this.entries.has(i)&&!t.replace)throw new Si(`Graph node kind '${i}' is already registered; pass { replace: true } to replace it`);try{Oo(n)}catch(e){throw new Si(`Manifest for kind '${i}' is not JSON-serializable: ${e.message}`)}((e,t)=>{const o=[["input",t.inputs],["output",t.outputs],["connection",t.connections??[]]];for(const[t,r]of o){const o=new Set;for(const n of r){if(Gi(e,t+" port",n?.id),o.has(n.id))throw new Si(`Manifest for kind '${e}' declares duplicate static ${t} port id '${n.id}'`);if(o.add(n.id),void 0!==n.defaultMode&&!Mi(n.defaultMode))throw new Si(`Manifest for kind '${e}' declares invalid default binding mode '${n.defaultMode+""}' on ${t} port '${n.id}'`)}}})(i,n);const a=((e,t)=>{const o=new Set;for(const r of t.parameters){const t=r?.id;if("string"!=typeof t||!t)throw new Si(`Manifest for kind '${e}' has a parameter with an empty id`);if(Bt(t))throw new Si(`Manifest for kind '${e}' has a parameter with unsafe id '${t}'`);if(o.has(t))throw new Si(`Manifest for kind '${e}' declares duplicate parameter id '${t}'`);o.add(t)}return o})(i,n);((e,t,o)=>{for(const r of t.dynamicPorts??[]){if(!r||"string"!=typeof r.parameter||!r.parameter)throw new Si(`Manifest for kind '${e}' has a dynamic-port rule without a parameter reference`);if(!o.has(r.parameter))throw new Si(`Manifest for kind '${e}' has a dynamic-port rule referencing missing parameter '${r.parameter}'`);if("togglePort"===r.type){if(!r.port)throw new Si(`Manifest for kind '${e}' has a togglePort rule without a port`);Gi(e,"togglePort rule port",r.port.id)}if("repeatFromParameter"===r.type&&"string"!=typeof r.portIdTemplate)throw new Si(`Manifest for kind '${e}' has a repeatFromParameter rule without a portIdTemplate`)}})(i,n,a),((e,t)=>{for(const o of t.credentials??[]){if(!Eo(o))throw new Si(`Manifest for kind '${e}' has a malformed credential requirement`);if(!o.type)throw new Si(`Manifest for kind '${e}' has a credential requirement with an empty type`)}})(i,n),((e,t)=>{for(const o of t.methods??[])if(!To(o))throw new Si(`Manifest for kind '${e}' has a malformed method declaration`)})(i,n);const s=new ki(i,n.methods??[],e.methods??{});return this.entries.set(i,{registration:e,methods:s,placeholderManifest:!1}),this}registerExecutor(e,t,...o){const{log:r}=this.logCtx(this.withContext(o),"registerExecutor").for(this.registerExecutor);if(r.debug(`Registering graph executor for kind '${e}'`),"string"!=typeof e||!e.trim())throw new Si("Graph executor kind is required");if(!t||"function"!=typeof t.execute)throw new Si(`Executor registered for kind '${e}' is missing an execute method`);const n=this.entries.get(e);if(n)return n.registration={...n.registration,executor:t},this;const i={kind:e,display:{name:e},inputs:[],outputs:[],parameters:[],policies:{allowUndeclaredParameters:!0,allowUnknownOutputs:!0}};return this.entries.set(e,{registration:{manifest:i,executor:t},methods:new ki(e,[],{}),placeholderManifest:!0}),this}unregister(e,...t){const{log:o}=this.logCtx(this.withContext(t),"unregister").for(this.unregister);return o.debug(`Unregistering graph node kind '${e}'`),this.entries.delete(e),this}has(e,...t){return this.logCtx(this.withContext(t),"has").for(this.has),this.entries.has(e)}entry(e){const t=this.entries.get(e);if(!t)throw new Ri(`No graph node kind '${e}' is registered in the catalogue`);return t}getManifest(e,...t){return this.logCtx(this.withContext(t),"getManifest").for(this.getManifest),zt(this.entry(e).registration.manifest)}getExecutor(e,...t){return this.logCtx(this.withContext(t),"getExecutor").for(this.getExecutor),this.entry(e).registration.executor}getMethodDeclaration(e,t,...o){return this.logCtx(this.withContext(o),"getMethodDeclaration").for(this.getMethodDeclaration),this.entry(e).methods.getDeclaration(t)}getMethod(e,t,...o){return this.logCtx(this.withContext(o),"getMethod").for(this.getMethod),this.entry(e).methods.getDeclaration(t),this.entry(e).methods.get(t)}listMethodDeclarations(e,...t){return this.logCtx(this.withContext(t),"listMethodDeclarations").for(this.listMethodDeclarations),this.entry(e).methods.list()}listManifests(e,...t){this.logCtx(this.withContext(t),"listManifests").for(this.listManifests);const o=[...this.entries.keys()].sort(),r=e?.categories?.length?new Set(e.categories):void 0,n=e?.kinds?.length?new Set(e.kinds):void 0,i=[];for(const e of o){if(n&&!n.has(e))continue;const o=this.getManifest(e,...t);r&&!r.has(o.display.category??"")||i.push(o)}return i}listKinds(...e){return this.logCtx(this.withContext(e),"listKinds").for(this.listKinds),[...this.entries.keys()].sort()}get size(){return this.entries.size}async resolveManifest(e,t,o,...r){this.logCtx(this.withContext(r),"resolveManifest").for(this.resolveManifest);const n=this.entry(e);return this.resolver.resolve(e,n.registration.manifest,n.registration.resolveManifest,t,o)}};Ui=k([H(),C("design:paramtypes",[])],Ui);let $i=class extends B{constructor(e=new Ui){super(),this.catalogue=e}get catalog(){return this.catalogue}register(e,t,...o){const{log:r}=this.logCtx(o,"register").for(this.register);if(r.debug(`Registering graph executor for kind '${e}'`),!e)throw new Cr("Graph executor kind is required");return this.catalogue.registerExecutor(e,t,...o),this}unregister(e,...t){const{log:o}=this.logCtx(t,"unregister").for(this.unregister);return o.debug(`Unregistering graph executor for kind '${e}'`),this.catalogue.unregister(e,...t),this}has(e,...t){return this.logCtx(t,"has").for(this.has),this.catalogue.has(e,...t)}resolve(e,...t){this.logCtx(t,"resolve").for(this.resolve);try{return this.catalogue.getExecutor(e,...t)}catch(t){if(t instanceof Ri)throw new Cr(`No graph executor registered for kind '${e}'`,"GRAPH_EXECUTOR_NOT_FOUND",{kind:e});throw t}}};$i=k([H(),C("design:paramtypes",[Ui])],$i);let Fi=class extends B{constructor(e,t){super(),this.registry=e,this.defaultExecutor=t}resolve(e,...t){const{log:o}=this.logCtx(t,"resolve").for(this.resolve);return o.debug(`Resolving graph executor for kind '${e}'`),this.registry.has(e,...t)?this.registry.resolve(e,...t):this.defaultExecutor?this.defaultExecutor:this.registry.resolve(e,...t)}};function Hi(e){return e}function Bi(e){return e.methods??[]}function qi(e){if(!e)return;const t={...e.metadata??{},...e.parameters??{},...e.state??{}};return e.loop&&(t.loop=e.loop),t}Fi=k([H(),C("design:paramtypes",[Function,Object])],Fi);class Wi extends b{constructor(e){super(),b.fromModel(this,e)}execute(e,t){throw new Cr(`Graph node kind '${this.constructor.name}' does not implement execute`,"GRAPH_NODE_EXECUTE_NOT_IMPLEMENTED",{kind:this.constructor.name})}static applyMetadata(e){return null}static instantiate(e){return new this(e)}}let Ki=class extends Wi{execute(e,t){throw new Gr(e.inputs.value)}};function Vi(e){return e instanceof Error?{name:e.name,message:e.message,stack:e.stack,code:e.graphCode??("number"==typeof e.code?e.code+"":e.code)}:{name:"UnknownError",message:e+""}}k([w(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.break.fields.value.label",placeholder:"graph.node.flow_control.break.fields.value.placeholder",type:"textarea"}),Ut({handle:"value"}),C("design:type",Object)],Ki.prototype,"value",void 0),Ki=k([Mt("core.flow.break",{kind:"core.flow.break",category:"Flow Control",color:"#f59e0b",icon:"ti-square-arrow-right",width:96,height:96,labels:["flow","break","loop","control"],metadata:{title:"graph.node.flow_control.break.name",description:"graph.node.flow_control.break.description"}}),I()],Ki);let zi=class extends Wi{async execute(e,t){const o=t.node.errorBoundary;if(!o?.try)return{result:e.inputs.value??e.inputs};const r=t.engine;if(!r)throw new Cr("errorBoundary node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");try{const n=await r.execute(o.try,e.inputs,{parentRunId:t.runId,path:[...t.path,"try"]}),i=Object.values(n.nodeResults).find(e=>e.status===gt.FAILED);if(i)throw new Cr(i.error?.message??"error boundary try body failed",i.error?.code??"GRAPH_ERROR_BOUNDARY",i.error?.details);return{result:n.outputs.result??n.outputs}}catch(n){let i=n;if(o.catch){const a=await r.execute(o.catch,{...e.inputs,error:Vi(n)},{parentRunId:t.runId,path:[...t.path,"catch"]});i=a.outputs.error??a.outputs}return{error:i}}finally{o.finally&&await r.execute(o.finally,e.inputs,{parentRunId:t.runId,path:[...t.path,"finally"]})}}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.error_boundary.fields.value.label",placeholder:"graph.node.flow_control.error_boundary.fields.value.placeholder",type:"textarea"}),Ut({handle:"value"}),C("design:type",Object)],zi.prototype,"value",void 0),k([$t({handle:"result"}),C("design:type",Object)],zi.prototype,"result",void 0),k([$t({handle:"error"}),C("design:type",Object)],zi.prototype,"error",void 0),zi=k([Mt("core.flow.errorBoundary",{kind:"core.flow.errorBoundary",category:"Flow Control",color:"#f59e0b",icon:"ti-shield-check",width:96,height:96,labels:["flow","error","try-catch"],metadata:{title:"graph.node.flow_control.error_boundary.name",description:"graph.node.flow_control.error_boundary.description",finally:!1}}),I()],zi);let Qi=class extends Wi{execute(e){const t=e.inputs.value??e.inputs;return!1===this.approved?{rejected:t}:{approved:t}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],Qi.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.human_approval.fields.message.label",placeholder:"graph.node.flow_control.human_approval.fields.message.placeholder",type:"textarea"}),Ut({handle:"message",userControlled:!0}),C("design:type",String)],Qi.prototype,"message",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.human_approval.fields.approved.label",type:"checkbox"}),Ut({handle:"approved",userControlled:!0}),C("design:type",Boolean)],Qi.prototype,"approved",void 0),k([$t({handle:"approved"}),C("design:type",Object)],Qi.prototype,"approvedOut",void 0),k([$t({handle:"rejected"}),C("design:type",Object)],Qi.prototype,"rejectedOut",void 0),Qi=k([Mt("core.flow.humanApproval",{kind:"core.flow.humanApproval",category:"Flow Control",color:"#f59e0b",icon:"ti-user-check",width:96,height:96,labels:["flow","approval","suspend"],metadata:{title:"graph.node.flow_control.human_approval.name",description:"graph.node.flow_control.human_approval.description",approvers:[],timeoutMs:864e5}}),I()],Qi);let Ji=class extends Wi{execute(e,t){const o=e.inputs,r=o.value??o;if(!this.condition)throw new Cr("If node has no condition configured","GRAPH_IF_NO_CONDITION",{input:o});if(yn(this.condition))return bn(this.condition,o,t).then(e=>this.route(e,r));const n=wn(this.condition,((e,t)=>t===e||"object"!=typeof t||null===t||Array.isArray(t)?e:{...t,...e})(o,r),"if");return this.route(n,r)}route(e,t){if(e)return{then:t};if(!0===this.else)return{else:t};throw new Cr("If node condition evaluated to false and the else branch is disabled","GRAPH_IF_ELSE_DISABLED",{condition:this.condition})}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.value.label",placeholder:"graph.node.flow_control.if.fields.value.placeholder",type:"textarea"}),Ut({handle:"value"}),C("design:type",Object)],Ji.prototype,"value",void 0),k([w(),$t({handle:"then"}),C("design:type",Object)],Ji.prototype,"then",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.condition.label",placeholder:"graph.node.flow_control.if.fields.condition.placeholder",type:"code"}),Ut({handle:"condition",userControlled:!0,type:"object"}),C("design:type",Object)],Ji.prototype,"condition",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.if.fields.else.label",type:"checkbox"}),Ut({handle:"else",userControlled:!0}),C("design:type",Boolean)],Ji.prototype,"else",void 0),Ji=k([Mt("core.flow.if",{kind:"core.flow.if",category:"Flow Control",color:"#f59e0b",icon:"ti-arrows-split-2",width:96,height:96,labels:["flow","conditional","branch"],metadata:{title:"graph.node.flow_control.if.name",description:"graph.node.flow_control.if.description"}}),I()],Ji);let Xi=class extends Wi{async execute(e,t){const o=((e,t)=>{const o={cases:t.cases??[],defaultPort:t.defaultPort??"default",hasDefault:!0===t.hasDefault},r=e.node.metadata?.switch;return r&&Array.isArray(r.cases)?{cases:r.cases,defaultPort:r.defaultPort??o.defaultPort,hasDefault:!0===r.hasDefault||o.hasDefault}:o})(t,this),r=o.cases,n=e.inputs,i=n.value??n,a=((e,t)=>t===e||"object"!=typeof t||null===t||Array.isArray(t)?e:{...t,...e})(n,i);for(const e of r)if(await vn(e.condition,{input:n,state:a,label:"switch case"},t))return{[e.outputPort]:i};if(!0!==o.hasDefault)throw new Cr("No switch case matched and default port is not enabled","GRAPH_SWITCH_NO_MATCH",{cases:r.map(e=>e.id)});const s=o.defaultPort??"default";return{[s]:i}}static applyMetadata(e){const t=Dt(this),o=e.defaultPort??"default",r=!0===e.hasDefault,n=t.ports.filter(t=>!e.cases.some(e=>e.outputPort===t.property)),i=n.filter(e=>e.property!==o),a=n.find(e=>e.property===o),s=[...i,...e.cases.map(e=>({property:e.outputPort,name:e.label,direction:it.OUTPUT,label:e.label,required:!1,hidden:!1,path:e.outputPort}))];return r&&a&&s.push(a),{ports:s,size:st(t,{cases:e.cases.length}),dataPatch:{switchMetadata:e}}}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.value.label",placeholder:"graph.node.flow_control.switch.fields.value.placeholder",type:"textarea"}),Ut({handle:"value"}),C("design:type",Object)],Xi.prototype,"value",void 0),k([w(),$t({handle:"default"}),C("design:type",Object)],Xi.prototype,"default",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.cases.label",type:"collection"}),C("design:type",Object)],Xi.prototype,"cases",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.hasDefault.label",type:"checkbox"}),C("design:type",Boolean)],Xi.prototype,"hasDefault",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.switch.fields.defaultPort.label",type:"text"}),C("design:type",String)],Xi.prototype,"defaultPort",void 0),Xi=k([Mt("core.flow.switch",{kind:"core.flow.switch",category:"Flow Control",color:"#f59e0b",icon:"ti-arrows-shuffle",width:120,height:140,sizeRules:[{type:"parameterCount",parameter:"cases",dimension:"height",perItem:24}],labels:["flow","switch","multi-branch"],metadata:{title:"graph.node.flow_control.switch.name",description:"graph.node.flow_control.switch.description"}}),I()],Xi);const Yi={maxDocumentBytes:2e6,maxNestingDepth:10,maxNodes:500,maxEdges:1e3},Zi=o.accumulate({graph:{workflows:{limits:{...Yi},allowAnonymousAccess:!1},execution:{maxCodeTimeoutMs:hr}}}),ea=1e3;function ta(e,t){const o="number"==typeof t?t:Number(t),r=Number.isFinite(o)&&o>0?o:hr,n="number"==typeof e?e:Number(e);return Number.isFinite(n)&&n>0?Math.min(Math.floor(n),r):1e3}const oa=["javascript","typescript"],ra="javascript";let na=class extends b{constructor(){super(...arguments),this.language=ra}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.language.label",type:"select"}),_([...oa]),v(String),C("design:type",String)],na.prototype,"language",void 0),k([w(),i("code-editor",{label:"graph.node.utility.code.fields.code.label",placeholder:"graph.node.utility.code.fields.code.placeholder"}),Ut({handle:"code"}),C("design:type",String)],na.prototype,"code",void 0),k([d(),Ut({handle:"data"}),C("design:type",Object)],na.prototype,"data",void 0),na=k([I()],na);let ia=class extends Wi{async execute(e,t){const o=e.inputs,r=this.input,n=o.code??e.parameters?.code??r?.code??this.defaultCode,i=r?.language??ra;if(!n||"string"!=typeof n||0===n.trim().length)throw new Tr("Code node has no code to execute (input.code is empty)",{input:o});const a=t.engine?.codeSandboxEvaluator;if(!a)throw new Cr("Code node execution requires a CodeSandboxEvaluator to be registered in GraphExecutionEngineConfig.codeSandboxEvaluator","GRAPH_CODE_SANDBOX_NOT_CONFIGURED",{code:n});const s=Zi.graph.execution?.maxCodeTimeoutMs,d="number"==typeof s&&Number.isFinite(s)&&s>0?s:hr,l=ta(this.timeoutMs,d),c=t.metadata,p={code:n,language:i,input:o,vars:c?.vars??void 0,item:c?.item,index:c?.index,nodes:c?.nodes??void 0,logger:t.logger,timeoutMs:l,abortSignal:t.abortSignal};await t.log("Executing code node",{language:i,length:n.length,timeoutMs:l});const u=await a.evaluate(p);return await t.log("Code node executed",{hasResult:void 0!==u}),{result:u}}};k([w(),Ut({handle:"input",model:na}),C("design:type",na)],ia.prototype,"input",void 0),k([E(1),A(hr),i("ngx-decaf-crud-field",{label:"graph.node.utility.code.fields.timeoutMs.label",type:"number"}),Ut({handle:"timeoutMs"}),C("design:type",Number)],ia.prototype,"timeoutMs",void 0),k([i("code-editor",{label:"graph.node.utility.code.fields.defaultCode.label",placeholder:"graph.node.utility.code.fields.defaultCode.placeholder"}),Ut({handle:"defaultCode",userControlled:!0}),C("design:type",String)],ia.prototype,"defaultCode",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],ia.prototype,"result",void 0),ia=k([Mt("core.utility.code",{kind:"core.utility.code",category:"Utility",color:"#0d9488",icon:"ti-code",width:96,height:96,labels:["utility","code","sandbox","transform"],metadata:{title:"graph.node.utility.code.name",description:"graph.node.utility.code.description"}}),I()],ia);let aa=class extends Wi{execute(e){return{value:e.inputs.value??e.inputs}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],aa.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.utility.delay.fields.timeoutMs.label",type:"number"}),Ut({handle:"timeoutMs"}),C("design:type",Number)],aa.prototype,"timeoutMs",void 0),k([w(),$t({handle:"value"}),C("design:type",Object)],aa.prototype,"valueOut",void 0),aa=k([Mt("core.flow.delay",{kind:"core.flow.delay",category:"Utility",color:"#0d9488",icon:"ti-clock-hour-4",width:96,height:96,labels:["flow","delay","wait"],metadata:{title:"graph.node.utility.delay.name",description:"graph.node.utility.delay.description"}}),I()],aa);let sa=class extends Wi{execute(e,t){const o=e.inputs.value,r=this.level??"info";return t.logger[r](this.message??"Log node",{value:o}),{value:o}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],sa.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.utility.log.fields.message.label",placeholder:"graph.node.utility.log.fields.message.placeholder",type:"textarea"}),Ut({handle:"message"}),C("design:type",String)],sa.prototype,"message",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.utility.log.fields.level.label",placeholder:"graph.node.utility.log.fields.level.placeholder",type:"text"}),Ut({handle:"level",userControlled:!0}),C("design:type",String)],sa.prototype,"level",void 0),k([w(),$t({handle:"value"}),C("design:type",Object)],sa.prototype,"valueOut",void 0),sa=k([Mt("core.flow.log",{kind:"core.flow.log",category:"Utility",color:"#0d9488",icon:"ti-terminal",width:96,height:96,labels:["flow","log","debug","utility"],metadata:{title:"graph.node.utility.log.name",description:"graph.node.utility.log.description"}}),I()],sa);let da=class extends Wi{execute(e){return{result:{mapped:e.inputs.value??e.inputs}}}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.utility.map.fields.value.label",placeholder:"graph.node.utility.map.fields.value.placeholder",type:"textarea"}),Ut({handle:"value"}),C("design:type",Object)],da.prototype,"value",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],da.prototype,"result",void 0),da=k([Mt("core.utility.map",{kind:"core.utility.map",category:"Utility",color:"#0d9488",icon:"ti-arrows-right-left",width:96,height:96,labels:["utility","map","transform"],metadata:{title:"graph.node.utility.map.name",description:"graph.node.utility.map.description",mapper:{}}}),I()],da);let la=class extends Wi{execute(e,t){const o=e.inputs.value,r=this.level??"info";return t.logger[r](this.message??"Log node",{value:o}),{value:o}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],la.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.utility.utility_log.fields.message.label",placeholder:"graph.node.utility.utility_log.fields.message.placeholder",type:"textarea"}),Ut({handle:"message"}),C("design:type",String)],la.prototype,"message",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.utility.utility_log.fields.level.label",placeholder:"graph.node.utility.utility_log.fields.level.placeholder"}),Ut({handle:"level",userControlled:!0,type:"string"}),C("design:type",String)],la.prototype,"level",void 0),k([w(),$t({handle:"value"}),C("design:type",Object)],la.prototype,"valueOut",void 0),la=k([Mt("core.utility.log",{kind:"core.utility.log",category:"Utility",color:"#0d9488",icon:"ti-terminal",width:96,height:96,labels:["utility","log","debug","observability"],metadata:{title:"graph.node.utility.utility_log.name",description:"graph.node.utility.utility_log.description"}}),I()],la);const ca=new Set(["__proto__","constructor","prototype"]);function pa(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ua(e){return null==e?[]:(Array.isArray(e)?e:[e]).filter(e=>null!=e)}function ga(e,t){if(ca.has(t))throw new Cr(`Graph data path '${e}' contains the reserved segment '${t}'`,"GRAPH_DATA_UNSAFE_PATH",{path:e,segment:t})}function ha(e,t){return t?(e=>{const t=(e=>e.split(".").map(e=>e.trim()).filter(e=>e.length>0))(e);for(const o of t)ga(e,o);return t})(e):(ga(e,e),[e])}function fa(e,t,o=!0){if(!t)return e;const r=ha(t,o);let n=e;for(const e of r){if(!pa(n))return;n=n[e]}return n}function ya(e,t,o,r=!0){const n=ha(t,r);if(0===n.length)return;let i=e;for(let e=0;e<n.length-1;e++){const t=n[e],o=i[t];if(pa(o))i=o;else{const e={};i[t]=e,i=e}}i[n[n.length-1]]=o}function ma(e,t,o=!0){const r=ha(t,o);if(0===r.length)return;let n=e;for(let e=0;e<r.length-1;e++){const t=n[r[e]];if(!pa(t))return;n=t}delete n[r[r.length-1]]}function ba(e,t="json"){if(null==e)return e;switch(t){case"string":return e+"";case"number":{const t=Number(e);if(!Number.isFinite(t))throw new Cr(`Value '${e+""}' cannot be converted to a number`,"GRAPH_DATA_INVALID_NUMBER",{value:e});return t}case"boolean":return"string"==typeof e?"true"===e||"1"===e:!!e;case"array":return Array.isArray(e)?e:[e];case"object":return pa(e)?e:{};default:if("string"!=typeof e)return e;try{return JSON.parse(e)}catch{return e}}}function wa(e,t,o="auto"){const r=null==e,n=null==t;return r&&n?0:r?1:n?-1:"string"===o?(e+"").localeCompare(t+""):"number"===o?Number(e)-Number(t):"date"===o?new Date(e).getTime()-new Date(t).getTime():"number"==typeof e&&"number"==typeof t?e-t:"boolean"==typeof e&&"boolean"==typeof t?Number(e)-Number(t):(e+"").localeCompare(t+"")}function va(e,t){if(!t||"iso"===t)return e.toISOString();const o=(e,t=2)=>(e+"").padStart(t,"0"),r={yyyy:e.getUTCFullYear()+"",yy:(e.getUTCFullYear()+"").slice(-2),MM:o(e.getUTCMonth()+1),M:e.getUTCMonth()+1+"",dd:o(e.getUTCDate()),d:e.getUTCDate()+"",HH:o(e.getUTCHours()),H:e.getUTCHours()+"",mm:o(e.getUTCMinutes()),m:e.getUTCMinutes()+"",ss:o(e.getUTCSeconds()),s:e.getUTCSeconds()+"",SSS:o(e.getUTCMilliseconds(),3)};return t.replace(/yyyy|yy|MM|M|dd|d|HH|H|mm|m|ss|s|SSS/g,e=>r[e]??e)}function xa(e,t,o){const r=new Date(e.getTime());switch(o){case"seconds":r.setUTCSeconds(r.getUTCSeconds()+t);break;case"minutes":r.setUTCMinutes(r.getUTCMinutes()+t);break;case"hours":r.setUTCHours(r.getUTCHours()+t);break;case"days":r.setUTCDate(r.getUTCDate()+t);break;case"weeks":r.setUTCDate(r.getUTCDate()+7*t);break;case"months":r.setUTCMonth(r.getUTCMonth()+t);break;case"years":r.setUTCFullYear(r.getUTCFullYear()+t)}return r}function Ia(e){if(e instanceof Date){if(Number.isNaN(e.getTime()))throw new Cr("Date value is invalid","GRAPH_DATA_INVALID_DATE",{value:e});return e}if("number"==typeof e){const t=new Date(e);if(!Number.isNaN(t.getTime()))return t}if("string"==typeof e&&e.trim().length>0){const t=new Date(e);if(!Number.isNaN(t.getTime()))return t}throw new Cr("Date & Time node requires a valid date value","GRAPH_DATA_INVALID_DATE",{value:e})}function _a(e){return"undefined"!=typeof Buffer&&Buffer.isBuffer(e)||e instanceof Uint8Array||e instanceof ArrayBuffer}let Ea=class extends Wi{constructor(){super(...arguments),this.operation="current",this.amount=0,this.unit="days"}execute(e){const t=e.inputs.value??this.value;if(Array.isArray(t)){const e=t.filter(e=>null!=e).map(e=>this.convert(e));return{result:e.map(e=>e.result),iso:e.map(e=>e.iso),timestamp:e.map(e=>e.timestamp)}}const o=this.convert(t);return{result:o.result,iso:o.iso,timestamp:o.timestamp}}convert(e){let t;switch(this.operation){case"current":t=new Date;break;case"add":t=xa(Ia(e),this.amount??0,this.unit??"days");break;case"subtract":t=xa(Ia(e),-(this.amount??0),this.unit??"days");break;case"parse":case"format":t=Ia(e);break;default:throw new Cr(`Unsupported Date & Time operation '${this.operation+""}'`,"GRAPH_DATE_TIME_UNSUPPORTED_OPERATION",{operation:this.operation})}return{result:va(t,this.format),iso:t.toISOString(),timestamp:t.getTime()}}};k([Ut({handle:"value"}),C("design:type",Object)],Ea.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Ea.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.format.label",placeholder:"graph.node.data.date_time.fields.format.placeholder",type:"text"}),Ut({handle:"format",userControlled:!0}),C("design:type",String)],Ea.prototype,"format",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.amount.label",type:"number"}),Ut({handle:"amount",userControlled:!0}),C("design:type",Number)],Ea.prototype,"amount",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.date_time.fields.unit.label",type:"select"}),Ut({handle:"unit",userControlled:!0}),C("design:type",String)],Ea.prototype,"unit",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],Ea.prototype,"result",void 0),k([$t({handle:"iso"}),C("design:type",String)],Ea.prototype,"iso",void 0),k([$t({handle:"timestamp"}),C("design:type",Number)],Ea.prototype,"timestamp",void 0),Ea=k([Mt("core.data.dateTime",{kind:"core.data.dateTime",category:"Data",color:"#8b5cf6",icon:"ti-calendar-time",width:96,height:96,labels:["data","date","time"],metadata:{title:"graph.node.data.date_time.name",description:"graph.node.data.date_time.description"}}),I()],Ea);let Aa=class extends Wi{constructor(){super(...arguments),this.operation="insert",this.tableName="default"}async execute(e,t){const o=t.engine?.dataTableStore;if(!o)throw new Cr("Data table node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");if(!this.tableName)throw new Cr("Data table node requires a table name","GRAPH_DATA_TABLE_NAME_REQUIRED");switch(this.operation){case"insert":return{result:await this.insertRows(e,o,t)};case"upsert":return{result:await this.upsertRows(e,o,t)};case"get":if(!this.rowId)throw new Cr("Data table 'get' requires a row id","GRAPH_DATA_TABLE_ROW_ID_REQUIRED");return{result:await o.readRow(this.tableName,this.rowId,t)??null};case"list":{const e=await o.listRows(this.tableName,this.limit,t);return{result:e,count:e.length}}case"delete":{if(!this.rowId)throw new Cr("Data table 'delete' requires a row id","GRAPH_DATA_TABLE_ROW_ID_REQUIRED");const e=await o.deleteRow(this.tableName,this.rowId,t);return{result:e,count:e?1:0}}case"clear":{const e=await o.clearTable(this.tableName,t);return{result:e,count:e}}default:throw new Cr(`Unsupported data table operation '${this.operation+""}'`,"GRAPH_DATA_TABLE_UNSUPPORTED_OPERATION",{operation:this.operation})}}rowsOf(e){const t=ua(e.inputs.value).filter(pa);return t.length>0?t:pa(this.row)?[this.row]:[]}async insertRows(e,t,o){const r=this.rowsOf(e),n=[];for(const e of r){const r=this.rowId??this.rowIdOf(e)??Z();n.push(await t.insertRow(this.tableName,r,e,o))}return n}async upsertRows(e,t,o){const r=this.rowsOf(e),n=[];for(const e of r){const r=this.rowId??this.rowIdOf(e)??Z();n.push(await t.upsertRow(this.tableName,r,e,o))}return n}rowIdOf(e){const t=e[this.rowIdField||"id"];return"string"==typeof t&&t.length>0?t:"number"==typeof t?t+"":void 0}};function Sa(e,t){return pa(t)?{...e,...t,item:t}:{...e,item:t}}k([Ut({handle:"value"}),C("design:type",Object)],Aa.prototype,"value",void 0),k([w(),i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Aa.prototype,"operation",void 0),k([w(),i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.tableName.label",placeholder:"graph.node.data.data_table.fields.tableName.placeholder",type:"text"}),Ut({handle:"tableName",userControlled:!0}),C("design:type",String)],Aa.prototype,"tableName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.rowId.label",placeholder:"graph.node.data.data_table.fields.rowId.placeholder",type:"text"}),Ut({handle:"rowId",userControlled:!0}),C("design:type",String)],Aa.prototype,"rowId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.rowIdField.label",placeholder:"graph.node.data.data_table.fields.rowIdField.placeholder",type:"text"}),Ut({handle:"rowIdField",userControlled:!0}),C("design:type",String)],Aa.prototype,"rowIdField",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.row.label",type:"json"}),Ut({handle:"row",userControlled:!0,type:"object"}),C("design:type",Object)],Aa.prototype,"row",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.data_table.fields.limit.label",type:"number"}),Ut({handle:"limit",userControlled:!0}),C("design:type",Number)],Aa.prototype,"limit",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],Aa.prototype,"result",void 0),k([$t({handle:"count"}),C("design:type",Number)],Aa.prototype,"count",void 0),Aa=k([Mt("core.data.dataTable",{kind:"core.data.dataTable",category:"Data",color:"#8b5cf6",icon:"ti-table",width:96,height:96,labels:["data","table","persistence"],metadata:{title:"graph.node.data.data_table.name",description:"graph.node.data.data_table.description"}}),I()],Aa);let Ra=class extends Wi{constructor(){super(...arguments),this.negate=!1}async execute(e,t){if(!this.condition)throw new Cr("Filter node has no condition configured","GRAPH_FILTER_NO_CONDITION");const o=ua(e.inputs.value),r=[];for(let n=0;n<o.length;n++){const i=o[n];await vn(this.condition,{input:{...e.inputs,item:i,index:n},state:Sa(e.inputs,i),label:"filter"},t)!==(!0===this.negate)&&r.push(i)}return{result:r}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],Ra.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.filter.fields.condition.label",placeholder:"graph.node.data.filter.fields.condition.placeholder",type:"code"}),Ut({handle:"condition",userControlled:!0,type:"object"}),C("design:type",Object)],Ra.prototype,"condition",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.filter.fields.negate.label",type:"checkbox"}),Ut({handle:"negate",userControlled:!0}),C("design:type",Boolean)],Ra.prototype,"negate",void 0),k([w(),$t({handle:"result"}),C("design:type",Array)],Ra.prototype,"result",void 0),Ra=k([Mt("core.data.filter",{kind:"core.data.filter",category:"Data",color:"#8b5cf6",icon:"ti-filter",width:96,height:96,labels:["data","filter","condition"],metadata:{title:"graph.node.data.filter.name",description:"graph.node.data.filter.description"}}),I()],Ra);let Oa=class extends Wi{constructor(){super(...arguments),this.maxItems=1,this.keep="firstItems"}execute(e){const t=ua(e.inputs.value),o=Math.max(0,Math.floor(Number(this.maxItems??1)));return o<t.length?"lastItems"===this.keep?{result:t.slice(t.length-o)}:{result:t.slice(0,o)}:{result:t}}};function ka(e,t,o){const r={...e};for(const[e,n]of Object.entries(t))"keepFirst"===o&&Object.prototype.hasOwnProperty.call(r,e)||(r[e]=n);return r}k([w(),Ut({handle:"value"}),C("design:type",Object)],Oa.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.limit.fields.maxItems.label",type:"number"}),Ut({handle:"maxItems",userControlled:!0}),C("design:type",Number)],Oa.prototype,"maxItems",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.limit.fields.keep.label",type:"select"}),Ut({handle:"keep",userControlled:!0}),C("design:type",String)],Oa.prototype,"keep",void 0),k([w(),$t({handle:"result"}),C("design:type",Array)],Oa.prototype,"result",void 0),Oa=k([Mt("core.data.limit",{kind:"core.data.limit",category:"Data",color:"#8b5cf6",icon:"ti-arrows-bar-to-line",width:96,height:96,labels:["data","limit","slice"],metadata:{title:"graph.node.data.limit.name",description:"graph.node.data.limit.description"}}),I()],Oa);let Ca=class extends Wi{constructor(){super(...arguments),this.mode="append",this.combineBy="position",this.joinMode="inner",this.clashHandling="keepFirst"}execute(e){const t=ua(e.inputs.input),o=ua(e.inputs.input2);if("append"===this.mode)return{result:[...t,...o]};if("fields"===this.combineBy)return{result:this.mergeByFields(t,o)};const r=Math.max(t.length,o.length),n=[];for(let e=0;r>e;e++){if(e>=t.length){if("inner"===this.joinMode||"left"===this.joinMode)continue;n.push(o[e]);continue}if(e>=o.length){if("inner"===this.joinMode||"right"===this.joinMode)continue;n.push(t[e]);continue}const r=t[e],i=o[e];pa(r)&&pa(i)?n.push(ka(r,i,this.clashHandling)):n.push([r,i])}return{result:n}}mergeByFields(e,t){const o=this.joinField;if(!o)throw new Cr("Merge node in 'fields' mode requires a join field","GRAPH_MERGE_JOIN_FIELD_REQUIRED");const r=new Map;for(const e of t){if(!pa(e))continue;const t=fa(e,o);if(null==t)continue;const n=r.get(t);r.set(t,n?ka(n,e,this.clashHandling):e)}const n=[],i=new Set;for(const t of e){if(!pa(t)){"inner"!==this.joinMode&&"right"!==this.joinMode&&n.push(t);continue}const e=fa(t,o),a=r.get(e);a?(i.add(e),n.push(ka(t,a,this.clashHandling))):"inner"!==this.joinMode&&"right"!==this.joinMode&&n.push(t)}if("right"===this.joinMode||"outer"===this.joinMode)for(const[e,t]of r)i.has(e)||n.push(t);return n}};function Na(e,t,o){const r={...e};for(const e of t){if(!e||!e.from||!e.to||e.from===e.to)continue;const t=fa(r,e.from,o);void 0!==t&&(ma(r,e.from,o),ya(r,e.to,t,o))}return r}k([w(),Ut({handle:"input"}),C("design:type",Object)],Ca.prototype,"input",void 0),k([Ut({handle:"input2"}),C("design:type",Object)],Ca.prototype,"input2",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.mode.label",type:"select"}),Ut({handle:"mode",userControlled:!0}),C("design:type",String)],Ca.prototype,"mode",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.combineBy.label",type:"select"}),Ut({handle:"combineBy",userControlled:!0}),C("design:type",String)],Ca.prototype,"combineBy",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.joinMode.label",type:"select"}),Ut({handle:"joinMode",userControlled:!0}),C("design:type",String)],Ca.prototype,"joinMode",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.joinField.label",placeholder:"graph.node.data.merge.fields.joinField.placeholder",type:"text"}),Ut({handle:"joinField",userControlled:!0}),C("design:type",String)],Ca.prototype,"joinField",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.merge.fields.clashHandling.label",type:"select"}),Ut({handle:"clashHandling",userControlled:!0}),C("design:type",String)],Ca.prototype,"clashHandling",void 0),k([w(),$t({handle:"result"}),C("design:type",Array)],Ca.prototype,"result",void 0),Ca=k([Mt("core.data.merge",{kind:"core.data.merge",category:"Data",color:"#8b5cf6",icon:"ti-git-merge",width:96,height:96,labels:["data","merge","join"],metadata:{title:"graph.node.data.merge.name",description:"graph.node.data.merge.description"}}),I()],Ca);let Ta=class extends Wi{constructor(){super(...arguments),this.renames=[],this.dotNotation=!0}execute(e){const t=(this.renames??[]).filter(e=>e&&"string"==typeof e.from&&"string"==typeof e.to),o=e.inputs.value,r=!1!==this.dotNotation;return Array.isArray(o)?{result:o.filter(e=>null!=e).map(e=>pa(e)?Na(e,t,r):e)}:pa(o)?{result:Na(o,t,r)}:{result:ua(o)}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],Ta.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.rename_keys.fields.renames.label",placeholder:"graph.node.data.rename_keys.fields.renames.placeholder",type:"collection"}),Ut({handle:"renames",userControlled:!0,type:"array"}),C("design:type",Array)],Ta.prototype,"renames",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.rename_keys.fields.dotNotation.label",type:"checkbox"}),Ut({handle:"dotNotation",userControlled:!0}),C("design:type",Boolean)],Ta.prototype,"dotNotation",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],Ta.prototype,"result",void 0),Ta=k([Mt("core.data.renameKeys",{kind:"core.data.renameKeys",category:"Data",color:"#8b5cf6",icon:"ti-key",width:96,height:96,labels:["data","rename","keys"],metadata:{title:"graph.node.data.rename_keys.name",description:"graph.node.data.rename_keys.description"}}),I()],Ta);let Pa=class extends Wi{constructor(){super(...arguments),this.assignments=[],this.includeOtherFields=!0,this.dotNotation=!0}execute(e){const t=e.inputs.value;return Array.isArray(t)?{result:t.filter(e=>null!=e).map(e=>this.applyTo(e))}:{result:this.applyTo(t)}}applyTo(e){const t=this.includeOtherFields?pa(e)?{...e}:void 0===e?{}:{value:e}:{};for(const e of this.assignments??[]){if(!e||"string"!=typeof e.name)continue;const o=ba(e.value,e.type??"json");null!=o&&ya(t,e.name,o,!1!==this.dotNotation)}return t}};k([w(),Ut({handle:"value"}),C("design:type",Object)],Pa.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.set.fields.assignments.label",placeholder:"graph.node.data.set.fields.assignments.placeholder",type:"collection"}),Ut({handle:"assignments",userControlled:!0,type:"array"}),C("design:type",Array)],Pa.prototype,"assignments",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.set.fields.includeOtherFields.label",type:"checkbox"}),Ut({handle:"includeOtherFields",userControlled:!0}),C("design:type",Boolean)],Pa.prototype,"includeOtherFields",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.set.fields.dotNotation.label",type:"checkbox"}),Ut({handle:"dotNotation",userControlled:!0}),C("design:type",Boolean)],Pa.prototype,"dotNotation",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],Pa.prototype,"result",void 0),Pa=k([Mt("core.data.set",{kind:"core.data.set",category:"Data",color:"#8b5cf6",icon:"ti-adjustments-horizontal",width:96,height:96,labels:["data","set","assign"],metadata:{title:"graph.node.data.set.name",description:"graph.node.data.set.description"}}),I()],Pa);let Da=class extends Wi{constructor(){super(...arguments),this.sortFields=[],this.valueType="auto",this.dotNotation=!0}execute(e){const t=[...ua(e.inputs.value)],o=(this.sortFields??[]).filter(e=>e&&"string"==typeof e.field);return 0===o.length||t.sort((e,t)=>{for(const r of o){const o=wa(fa(e,r.field,!1!==this.dotNotation),fa(t,r.field,!1!==this.dotNotation),this.valueType??"auto");if(0!==o)return"desc"===r.direction?-o:o}return 0}),{result:t}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],Da.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.sort.fields.sortFields.label",placeholder:"graph.node.data.sort.fields.sortFields.placeholder",type:"collection"}),Ut({handle:"sortFields",userControlled:!0,type:"array"}),C("design:type",Array)],Da.prototype,"sortFields",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.sort.fields.valueType.label",type:"select"}),Ut({handle:"valueType",userControlled:!0}),C("design:type",String)],Da.prototype,"valueType",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.sort.fields.dotNotation.label",type:"checkbox"}),Ut({handle:"dotNotation",userControlled:!0}),C("design:type",Boolean)],Da.prototype,"dotNotation",void 0),k([w(),$t({handle:"result"}),C("design:type",Array)],Da.prototype,"result",void 0),Da=k([Mt("core.data.sort",{kind:"core.data.sort",category:"Data",color:"#8b5cf6",icon:"ti-sort-ascending",width:96,height:96,labels:["data","sort","order"],metadata:{title:"graph.node.data.sort.name",description:"graph.node.data.sort.description"}}),I()],Da);let ja=class extends Wi{constructor(){super(...arguments),this.field="",this.include="noOtherFields"}execute(e){if(!this.field)throw new Cr("Split Out node requires a field name","GRAPH_SPLIT_OUT_FIELD_REQUIRED");const t=ua(e.inputs.value),o=[];for(const e of t){const t=fa(e,this.field,!0);if(null==t)continue;const r=Array.isArray(t)?t:[t];for(const t of r){if(null==t)continue;if("allOtherFields"!==this.include){o.push(t);continue}const r=this.destinationField||this.field,n=pa(e)?{...e}:{};ma(n,this.field,!0),ya(n,r,t,!0),o.push(n)}}return{result:o}}};function La(e,t="Fields"){if(null==e)return[];if("string"==typeof e)return e.split(",").map(e=>e.trim()).filter(e=>e.length>0);if(Array.isArray(e))return e.filter(e=>"string"==typeof e).map(e=>e.trim()).filter(e=>e.length>0);throw new Cr(`The '${t}' parameter must be a comma-separated string or an array of strings`,"GRAPH_DATA_INVALID_FIELDS",{fieldName:t})}function Ma(e){return e.replace(/]/g,"").replace(/\[/g,"").replace(/"/g,"").replace(/[ .]/g,"_")}function Ga(e){const t=e=>Array.isArray(e)?e.map(t):e instanceof Date?e.toISOString():pa(e)?Object.keys(e).sort().reduce((o,r)=>(ga(r,r),o[r]=t(e[r]),o),{}):"number"==typeof e&&Number.isNaN(e)?"@NaN":void 0===e?"@undefined":"bigint"==typeof e?e.toString()+"n":e;return JSON.stringify(t(e))}function Ua(e,t){if(e===t)return!0;if("number"==typeof e&&"number"==typeof t&&Number.isNaN(e)&&Number.isNaN(t))return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,o)=>Ua(e,t[o]));if(pa(e)&&pa(t)){const o=Object.keys(e),r=Object.keys(t);return o.length===r.length&&o.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&Ua(e[o],t[o]))}return!1}function $a(e){return null==e||""===e||!1===e||(Array.isArray(e)?0===e.length:!!pa(e)&&0===Object.keys(e).length)}function Fa(e,t){if(null!==e&&null!==t&&typeof e==typeof t)return Ua(e,t);if($a(e)&&$a(t))return!0;if($a(e)&&void 0===t)return!0;if(void 0===e&&$a(t))return!0;if("number"==typeof e&&"string"==typeof t)return e.toString()===t;if("string"==typeof e&&"number"==typeof t)return e===t.toString();if(pa(e)&&"string"==typeof t)try{return Ua(e,JSON.parse(t))}catch{return!1}if("string"==typeof e&&pa(t))try{return Ua(JSON.parse(e),t)}catch{return!1}return Ua(e,t)}function Ha(e,t,o=[]){if(!pa(e)||Array.isArray(e))return o.length?[o.join(".")]:[];if(!t)return o.length?[o.join(".")]:Object.keys(e);const r=Object.keys(e);if(0===r.length)return o.length?[o.join(".")]:[];const n=[];for(const i of r){const r=e[i];if(pa(r)&&!Array.isArray(r)){const e=Ha(r,t,[...o,i]);0===e.length?n.push([...o,i].join(".")):n.push(...e)}else n.push([...o,i].join("."))}return n}function Ba(e,t,o){if(!pa(e)||Array.isArray(e))return e;const r={...e};for(const e of t)e&&ma(r,e,o);return r}function qa(e,t,o){if(!pa(e)||Array.isArray(e))return e;const r={};for(const n of t)ya(r,n,fa(e,n,o),o);return r}function Wa(e,t,o){return t.outputFieldName?t.outputFieldName:o&&e.includes(".")?e.split(".").pop()??e:e}function Ka(e,t,o={}){const r=!1!==o.dotNotation,n={},i=new Set;for(const a of t){const t=a?.field??a?.fieldToAggregate;if(!t)continue;const s=Wa(t,a,r);if(i.has(s))throw new Cr(`The '${s}' output field is used more than once`,"GRAPH_AGGREGATE_DUPLICATE_FIELD",{field:s});i.add(s);const d=[];for(const n of e){let e=fa(n,t,r);if(Array.isArray(e)&&!o.keepMissing)e=e.filter(e=>null!=e);else if(!o.keepMissing&&null==e)continue;Array.isArray(e)&&o.mergeLists?d.push(...e):d.push(e)}ya(n,s,d,r)}return n}function Va(e,t={}){const o=t.include??"allFields",r=t.fieldsToInclude??[],n=t.fieldsToExclude??[],i=[];for(const t of e){const e=pa(t)?{...t}:void 0===t?{}:{value:t},a=Object.keys(e);let s=a;"specifiedFields"===o?s=a.filter(e=>r.includes(e)):"allFieldsExcept"===o&&(s=a.filter(e=>!n.includes(e)));const d={};for(const t of s)ga(t,t),d[t]=e[t];Object.keys(d).length>0&&i.push(d)}return i}function za(e,t,o,r="auto"){const n=[...e],i=t.filter(e=>e&&"string"==typeof e.field);return 0===i.length||n.sort((e,t)=>{for(const n of i){const i=wa(fa(e,n.field,o),fa(t,n.field,o),r);if(0!==i)return"desc"===n.direction?-i:i}return 0}),n}function Qa(e,t,o={}){const r=!1!==o.dotNotation,n=[];for(const i of e){const e=fa(i,t,r);if(null==e)continue;const a=Array.isArray(e)?e:[e];for(const e of a){if(null==e)continue;if("allOtherFields"!==o.include){n.push(e);continue}const r=o.destinationField||t,a=pa(i)?{...i}:{};ma(a,t,!0),ya(a,r,e,!0),n.push(a)}}return n}function Ja(e,t={}){const o=!1!==t.dotNotation,r=t.compare??"allFields";let n;if("selectedFields"===r){if(n=La(t.fieldsToCompare,"Fields To Compare"),0===n.length)throw new Cr("No fields specified to compare on","GRAPH_REMOVE_DUPLICATES_FIELDS_REQUIRED");if(!e.some(e=>n.some(t=>void 0!==fa(e,t,o))))throw new Cr(`The fields '${n.join(", ")}' are not present in any input item`,"GRAPH_REMOVE_DUPLICATES_FIELD_MISSING",{fields:n})}else if("allFieldsExcept"===r){const r=La(t.fieldsToExclude,"Fields To Exclude");if(0===r.length)throw new Cr("No fields specified to exclude from comparison","GRAPH_REMOVE_DUPLICATES_FIELDS_REQUIRED");const i=new Set;for(const t of e)for(const e of Ha(t,o))i.add(e);n=Array.from(i).filter(e=>!r.includes(e))}else{const t=new Set;for(const r of e)for(const e of Ha(r,o))t.add(e);n=Array.from(t)}const i=[],a=[],s=new Set;for(const r of e){const e=pa(r)?Ga(n.map(e=>fa(r,e,o))):Ga(r);s.has(e)?a.push(r):(s.add(e),i.push(t.removeOtherFields?qa(r,n,o):r))}return{kept:i,discarded:a}}k([w(),Ut({handle:"value"}),C("design:type",Object)],ja.prototype,"value",void 0),k([w(),i("ngx-decaf-crud-field",{label:"graph.node.data.split_out.fields.field.label",placeholder:"graph.node.data.split_out.fields.field.placeholder",type:"text"}),Ut({handle:"field",userControlled:!0}),C("design:type",String)],ja.prototype,"field",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.split_out.fields.include.label",type:"select"}),Ut({handle:"include",userControlled:!0}),C("design:type",String)],ja.prototype,"include",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.split_out.fields.destinationField.label",placeholder:"graph.node.data.split_out.fields.destinationField.placeholder",type:"text"}),Ut({handle:"destinationField",userControlled:!0}),C("design:type",String)],ja.prototype,"destinationField",void 0),k([w(),$t({handle:"result"}),C("design:type",Array)],ja.prototype,"result",void 0),ja=k([Mt("core.data.splitOut",{kind:"core.data.splitOut",category:"Data",color:"#8b5cf6",icon:"ti-arrows-split-2",width:96,height:96,labels:["data","split","array"],metadata:{title:"graph.node.data.split_out.name",description:"graph.node.data.split_out.description"}}),I()],ja);const Xa={append:"appended_",average:"average_",concatenate:"concatenated_",count:"count_",countUnique:"unique_count_",max:"max_",min:"min_",sum:"sum_"};function Ya(e,t,o){const r=t.field??"",n=e.map(e=>r?fa(e,r,o):e),i=t.includeEmpty?n:n.filter(e=>!(e=>null==e||""===e)(e));switch(t.aggregation){case"append":return i;case"concatenate":{const e="other"===t.separator?t.customSeparator??"":t.separator??",";return i.map(e=>void 0===e?"undefined":"object"==typeof e?JSON.stringify(e):e+"").join(e)}case"average":{const e=i.filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===e.length?null:e.reduce((e,t)=>e+t,0)/e.length}case"sum":return i.filter(e=>"number"==typeof e&&Number.isFinite(e)).reduce((e,t)=>e+t,0);case"min":{let e;for(const t of i)null!=t&&""!==t&&(void 0===e||e>t)&&(e=t);return e??null}case"max":{let e;for(const t of i)null!=t&&""!==t&&(void 0===e||t>e)&&(e=t);return e??null}case"countUnique":return new Set(i.map(e=>Ga(e))).size;default:return i.length}}function Za(e,t,o){const r={};for(const n of t){const t=n.field??"",i=Ma(`${Xa[n.aggregation]??"count_"}${t}`);ga(i,i),r[i]=Ya(e,n,o)}return r}function es(e){return void 0===e?"undefined":null===e?"null":"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e?e+"":Ga(e)}function ts(e,t,o,r,n){if(o>=t.length)return[];const i=t[o],a=new Map;for(const t of e){let e=fa(t,i,r);if(e&&"object"==typeof e&&(e=JSON.stringify(e)),n&&"number"!=typeof e&&!e)continue;const o=Ga(e),s=a.get(o)??{value:e,items:[]};s.items.push(t),a.set(o,s)}const s=o===t.length-1;return Array.from(a.values()).map(e=>({field:i,value:e.value,...s?{items:e.items}:{children:ts(e.items,t,o+1,r,n)}}))}function os(e,t,o={}){const r=!1!==o.dotNotation,n=La(o.fieldsToSplitBy,"Fields To Split By"),i=o.outputFormat??"separateItems";if(!o.continueIfFieldNotFound)for(const o of t){const t=o.field??"";if(t&&!e.some(e=>void 0!==fa(e,t,r)))throw new Cr(`The field '${t}' does not exist in any items`,"GRAPH_SUMMARIZE_FIELD_NOT_FOUND",{field:t})}if(0===n.length)return[Za(e,t,r)];const a=ts(e,n,n.length>0?0:-1,r,!0===o.skipEmptySplitFields);if("singleItem"===i){const o=Za(e,t,r),n=(e,o)=>{for(const i of e){const e=Ma(i.field);ga(e,e);const a=o[e]??{};o[e]=a;const s=es(i.value);if(ga(s,s),i.children&&i.children.length>0){const e=a[s]??{};a[s]=e,n(i.children,e)}else i.items&&(a[s]=Za(i.items,t,r))}};return n(a,o),[o]}const s=[],d=(e,o,n)=>{for(const i of e){const e=[...o,i.field],a=[...n,i.value];if(i.children&&i.children.length>0)d(i.children,e,a);else if(i.items){const o=Za(i.items,t,r);e.forEach((e,t)=>{const r=Ma(e);ga(r,r),o[r]=a[t]}),s.push(o)}}};return d(a,[],[]),s}let rs=class extends Wi{constructor(){super(...arguments),this.aggregate="aggregateIndividualFields",this.fieldsToAggregate=[],this.destinationFieldName="data",this.include="allFields",this.mergeLists=!1,this.keepMissing=!1,this.disableDotNotation=!1}execute(e){const t=ua(e.inputs.value);if("aggregateAllItemData"===this.aggregate){const e=this.destinationFieldName||"data";return{result:{[e]:Va(t,{include:this.include,fieldsToInclude:La(this.fieldsToInclude,"Fields To Include"),fieldsToExclude:La(this.fieldsToExclude,"Fields To Exclude")})}}}const o=(this.fieldsToAggregate??[]).filter(e=>e&&(e.field||e.fieldToAggregate));if(0===o.length)throw new Cr("Aggregate node requires at least one field to aggregate","GRAPH_AGGREGATE_FIELDS_REQUIRED");return{result:Ka(t,o,{dotNotation:!0!==this.disableDotNotation,mergeLists:!0===this.mergeLists,keepMissing:!0===this.keepMissing})}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],rs.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.aggregate.label",type:"select"}),Ut({handle:"aggregate",userControlled:!0}),C("design:type",String)],rs.prototype,"aggregate",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.fieldsToAggregate.label",placeholder:"graph.node.data.aggregate.fields.fieldsToAggregate.placeholder",type:"collection"}),Ut({handle:"fieldsToAggregate",userControlled:!0,type:"array"}),C("design:type",Array)],rs.prototype,"fieldsToAggregate",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.destinationFieldName.label",type:"text"}),Ut({handle:"destinationFieldName",userControlled:!0}),C("design:type",String)],rs.prototype,"destinationFieldName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.include.label",type:"select"}),Ut({handle:"include",userControlled:!0}),C("design:type",String)],rs.prototype,"include",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.fieldsToInclude.label",placeholder:"graph.node.data.aggregate.fields.fieldsToInclude.placeholder",type:"text"}),Ut({handle:"fieldsToInclude",userControlled:!0}),C("design:type",Object)],rs.prototype,"fieldsToInclude",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.fieldsToExclude.label",placeholder:"graph.node.data.aggregate.fields.fieldsToExclude.placeholder",type:"text"}),Ut({handle:"fieldsToExclude",userControlled:!0}),C("design:type",Object)],rs.prototype,"fieldsToExclude",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.mergeLists.label",type:"checkbox"}),Ut({handle:"mergeLists",userControlled:!0}),C("design:type",Boolean)],rs.prototype,"mergeLists",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.keepMissing.label",type:"checkbox"}),Ut({handle:"keepMissing",userControlled:!0}),C("design:type",Boolean)],rs.prototype,"keepMissing",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.aggregate.fields.disableDotNotation.label",type:"checkbox"}),Ut({handle:"disableDotNotation",userControlled:!0}),C("design:type",Boolean)],rs.prototype,"disableDotNotation",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],rs.prototype,"result",void 0),rs=k([Mt("core.data.aggregate",{kind:"core.data.aggregate",category:"Data",color:"#8b5cf6",icon:"ti-box-multiple",width:96,height:96,labels:["data","aggregate","group"],metadata:{title:"graph.node.data.aggregate.name",description:"graph.node.data.aggregate.description"}}),I()],rs);let ns=class extends Wi{constructor(){super(...arguments),this.operation="concatenateItems",this.aggregate="aggregateIndividualFields",this.fieldsToAggregate=[],this.destinationFieldName="data",this.include="allFields",this.mergeLists=!1,this.keepMissing=!1,this.maxItems=1,this.keep="firstItems",this.compareMode="allFields",this.removeOtherFields=!1,this.sortFields=[],this.sortValueType="auto",this.field="",this.splitOutInclude="noOtherFields",this.fieldsToSummarize=[],this.outputFormat="separateItems",this.skipEmptySplitFields=!1,this.continueIfFieldNotFound=!1,this.disableDotNotation=!1}execute(e){const t=ua(e.inputs.value);switch(this.operation){case"limit":{const e=Math.max(0,Math.floor(Number(this.maxItems??1)));return{result:"lastItems"===this.keep?t.slice(Math.max(0,t.length-e)):t.slice(0,e)}}case"removeDuplicates":{const{kept:e,discarded:o}=Ja(t,{compare:this.compareMode,fieldsToExclude:this.fieldsToExclude,fieldsToCompare:this.fieldsToCompare,removeOtherFields:!0===this.removeOtherFields,dotNotation:!0!==this.disableDotNotation});return{result:e,discarded:o}}case"sort":return{result:za(t,this.sortFields??[],!0!==this.disableDotNotation,this.sortValueType??"auto")};case"splitOutItems":if(!this.field)throw new Cr("Item Lists node split out operation requires a field name","GRAPH_ITEM_LISTS_FIELD_REQUIRED");return{result:Qa(t,this.field,{include:this.splitOutInclude,destinationField:this.destinationField,dotNotation:!0!==this.disableDotNotation})};case"summarize":{const e=(this.fieldsToSummarize??[]).filter(e=>e&&"string"==typeof e.aggregation);if(0===e.length)throw new Cr("Item Lists node summarize operation requires at least one field","GRAPH_SUMMARIZE_FIELDS_REQUIRED");return{result:os(t,e,{fieldsToSplitBy:La(this.fieldsToSplitBy,"Fields To Split By"),outputFormat:this.outputFormat,skipEmptySplitFields:!0===this.skipEmptySplitFields,dotNotation:!0!==this.disableDotNotation,continueIfFieldNotFound:!0===this.continueIfFieldNotFound})}}case"concatenateItems":break;default:throw new Cr(`Item Lists operation '${this.operation+""}' is not supported`,"GRAPH_ITEM_LISTS_UNSUPPORTED_OPERATION",{operation:this.operation})}if("aggregateAllItemData"===this.aggregate){const e=this.destinationFieldName||"data";return{result:{[e]:Va(t,{include:this.include,fieldsToInclude:La(this.fieldsToInclude,"Fields To Include"),fieldsToExclude:La(this.fieldsToExclude,"Fields To Exclude")})}}}const o=(this.fieldsToAggregate??[]).filter(e=>e&&(e.field||e.fieldToAggregate));if(0===o.length)throw new Cr("Item Lists node concatenate operation requires at least one field","GRAPH_AGGREGATE_FIELDS_REQUIRED");return{result:Ka(t,o,{dotNotation:!0!==this.disableDotNotation,mergeLists:!0===this.mergeLists,keepMissing:!0===this.keepMissing})}}};function is(e){const t=e?.field1??e?.fieldA,o=e?.field2??e?.fieldB;if(t&&o)return{a:t,b:o}}function as(e){return pa(e)?Object.keys(e):[]}function ss(e,t,o,r){const n=pa(e)?e:{value:e},i=pa(t)?t:{value:t},a={};for(const e of o)a[e.a]=fa(n,e.a,r.dotNotation);const s=Array.from(new Set([...as(n),...as(i)])),d={},l={};for(const e of s){if(r.skipFields.includes(e))continue;const t=fa(n,e,r.dotNotation),o=fa(i,e,r.dotNotation);r.equals(t,o)?d[e]=t:l[e]={inputA:t,inputB:o}}return{keys:a,same:d,different:l}}k([w(),Ut({handle:"value"}),C("design:type",Object)],ns.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],ns.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.aggregate.label",type:"select"}),Ut({handle:"aggregate",userControlled:!0}),C("design:type",String)],ns.prototype,"aggregate",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.fieldsToAggregate.label",placeholder:"graph.node.data.item_lists.fields.fieldsToAggregate.placeholder",type:"collection"}),Ut({handle:"fieldsToAggregate",userControlled:!0,type:"array"}),C("design:type",Array)],ns.prototype,"fieldsToAggregate",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.destinationFieldName.label",type:"text"}),Ut({handle:"destinationFieldName",userControlled:!0}),C("design:type",String)],ns.prototype,"destinationFieldName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.include.label",type:"select"}),Ut({handle:"include",userControlled:!0}),C("design:type",String)],ns.prototype,"include",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.fieldsToInclude.label",placeholder:"graph.node.data.item_lists.fields.fieldsToInclude.placeholder",type:"text"}),Ut({handle:"fieldsToInclude",userControlled:!0}),C("design:type",Object)],ns.prototype,"fieldsToInclude",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.fieldsToExclude.label",placeholder:"graph.node.data.item_lists.fields.fieldsToExclude.placeholder",type:"text"}),Ut({handle:"fieldsToExclude",userControlled:!0}),C("design:type",Object)],ns.prototype,"fieldsToExclude",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.mergeLists.label",type:"checkbox"}),Ut({handle:"mergeLists",userControlled:!0}),C("design:type",Boolean)],ns.prototype,"mergeLists",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.keepMissing.label",type:"checkbox"}),Ut({handle:"keepMissing",userControlled:!0}),C("design:type",Boolean)],ns.prototype,"keepMissing",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.maxItems.label",type:"number"}),Ut({handle:"maxItems",userControlled:!0}),C("design:type",Number)],ns.prototype,"maxItems",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.keep.label",type:"select"}),Ut({handle:"keep",userControlled:!0}),C("design:type",String)],ns.prototype,"keep",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.compareMode.label",type:"select"}),Ut({handle:"compareMode",userControlled:!0}),C("design:type",String)],ns.prototype,"compareMode",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.fieldsToCompare.label",placeholder:"graph.node.data.item_lists.fields.fieldsToCompare.placeholder",type:"text"}),Ut({handle:"fieldsToCompare",userControlled:!0}),C("design:type",Object)],ns.prototype,"fieldsToCompare",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.removeOtherFields.label",type:"checkbox"}),Ut({handle:"removeOtherFields",userControlled:!0}),C("design:type",Boolean)],ns.prototype,"removeOtherFields",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.sortFields.label",placeholder:"graph.node.data.item_lists.fields.sortFields.placeholder",type:"collection"}),Ut({handle:"sortFields",userControlled:!0,type:"array"}),C("design:type",Array)],ns.prototype,"sortFields",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.sortValueType.label",type:"select"}),Ut({handle:"sortValueType",userControlled:!0}),C("design:type",String)],ns.prototype,"sortValueType",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.field.label",placeholder:"graph.node.data.item_lists.fields.field.placeholder",type:"text"}),Ut({handle:"field",userControlled:!0}),C("design:type",String)],ns.prototype,"field",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.splitOutInclude.label",type:"select"}),Ut({handle:"splitOutInclude",userControlled:!0}),C("design:type",String)],ns.prototype,"splitOutInclude",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.destinationField.label",placeholder:"graph.node.data.item_lists.fields.destinationField.placeholder",type:"text"}),Ut({handle:"destinationField",userControlled:!0}),C("design:type",String)],ns.prototype,"destinationField",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.fieldsToSummarize.label",placeholder:"graph.node.data.item_lists.fields.fieldsToSummarize.placeholder",type:"collection"}),Ut({handle:"fieldsToSummarize",userControlled:!0,type:"array"}),C("design:type",Array)],ns.prototype,"fieldsToSummarize",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.fieldsToSplitBy.label",placeholder:"graph.node.data.item_lists.fields.fieldsToSplitBy.placeholder",type:"text"}),Ut({handle:"fieldsToSplitBy",userControlled:!0}),C("design:type",Object)],ns.prototype,"fieldsToSplitBy",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.outputFormat.label",type:"select"}),Ut({handle:"outputFormat",userControlled:!0}),C("design:type",String)],ns.prototype,"outputFormat",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.skipEmptySplitFields.label",type:"checkbox"}),Ut({handle:"skipEmptySplitFields",userControlled:!0}),C("design:type",Boolean)],ns.prototype,"skipEmptySplitFields",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.continueIfFieldNotFound.label",type:"checkbox"}),Ut({handle:"continueIfFieldNotFound",userControlled:!0}),C("design:type",Boolean)],ns.prototype,"continueIfFieldNotFound",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.item_lists.fields.disableDotNotation.label",type:"checkbox"}),Ut({handle:"disableDotNotation",userControlled:!0}),C("design:type",Boolean)],ns.prototype,"disableDotNotation",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],ns.prototype,"result",void 0),k([$t({handle:"discarded"}),C("design:type",Array)],ns.prototype,"discarded",void 0),ns=k([Mt("core.data.itemLists",{kind:"core.data.itemLists",category:"Data",color:"#8b5cf6",icon:"ti-list-details",width:96,height:96,labels:["data","list","items","transform"],metadata:{title:"graph.node.data.item_lists.name",description:"graph.node.data.item_lists.description"}}),I()],ns);let ds=class extends Wi{constructor(){super(...arguments),this.fieldsToMatch=[],this.resolve="includeBoth",this.multipleMatches="first",this.fuzzyCompare=!1,this.preferWhenMix="input1",this.disableDotNotation=!1}execute(e){const t=(this.fieldsToMatch??[]).map(is).filter(e=>void 0!==e);if(0===t.length)throw new Cr("Compare Datasets node requires at least one pair of fields to match on","GRAPH_COMPARE_DATASETS_MATCH_FIELDS_REQUIRED");const o=!0!==this.disableDotNotation,r=this.fuzzyCompare?Fa:Ua,n=La(this.skipFields,"Fields to Skip"),i=La(this.exceptWhenMix,"For Everything Except"),a=ua(e.inputs.input),s=ua(e.inputs.input2),d="all"===this.multipleMatches?"all":"first",l=this.resolve??"includeBoth",c=[],p=[],u=[],g=[],h=new Set;for(const e of a){if(t.map(t=>({field:t.b,value:fa(e,t.a,o)})).some(e=>void 0===e.value)){c.push(e);continue}const a=[];for(let n=0;n<s.length;n++){const i=s[n];if(t.every(t=>r(fa(e,t.a,o),fa(i,t.b,o)))&&(a.push({item:i,index:n}),"first"===d))break}if(0===a.length){c.push(e);continue}let g;for(const s of a){h.add(s.index);const a=Ba(e,n,o),d=Ba(s.item,n,o);if(r(a,d))void 0===g&&(g=this.fuzzyCompare&&"preferInput2"===l?s.item:e);else switch(l){case"preferInput1":u.push(e);break;case"preferInput2":u.push(s.item);break;case"mix":{const t="input2"===this.preferWhenMix?s.item:e,r="input2"===this.preferWhenMix?e:s.item;if(0===i.length){u.push(t);break}const n=pa(t)?{...t}:{value:t},a=pa(r)?r:{value:r};for(const e of i){const t=fa(a,e,o);if(!o){n[e]=t;continue}const r=e.split(".").filter(Boolean);let i=n;for(let e=0;e<r.length-1;e++){const t=i[r[e]];if(pa(t))i=t;else{const t={};i[r[e]]=t,i=t}}i[r[r.length-1]]=t}u.push(n);break}default:u.push(ss(e,s.item,t,{skipFields:n,dotNotation:o,equals:r}))}}void 0!==g&&p.push(g)}return s.forEach((e,t)=>{h.has(t)||g.push(e)}),{onlyInA:c,same:p,different:u,onlyInB:g}}};k([w(),Ut({handle:"input"}),C("design:type",Object)],ds.prototype,"input",void 0),k([w(),Ut({handle:"input2"}),C("design:type",Object)],ds.prototype,"input2",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.fieldsToMatch.label",placeholder:"graph.node.data.compare_datasets.fields.fieldsToMatch.placeholder",type:"collection"}),Ut({handle:"fieldsToMatch",userControlled:!0,type:"array"}),C("design:type",Array)],ds.prototype,"fieldsToMatch",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.resolve.label",type:"select"}),Ut({handle:"resolve",userControlled:!0}),C("design:type",String)],ds.prototype,"resolve",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.multipleMatches.label",type:"select"}),Ut({handle:"multipleMatches",userControlled:!0}),C("design:type",String)],ds.prototype,"multipleMatches",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.fuzzyCompare.label",type:"checkbox"}),Ut({handle:"fuzzyCompare",userControlled:!0}),C("design:type",Boolean)],ds.prototype,"fuzzyCompare",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.preferWhenMix.label",type:"select"}),Ut({handle:"preferWhenMix",userControlled:!0}),C("design:type",String)],ds.prototype,"preferWhenMix",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.exceptWhenMix.label",placeholder:"graph.node.data.compare_datasets.fields.exceptWhenMix.placeholder",type:"text"}),Ut({handle:"exceptWhenMix",userControlled:!0}),C("design:type",Object)],ds.prototype,"exceptWhenMix",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.skipFields.label",placeholder:"graph.node.data.compare_datasets.fields.skipFields.placeholder",type:"text"}),Ut({handle:"skipFields",userControlled:!0}),C("design:type",Object)],ds.prototype,"skipFields",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.compare_datasets.fields.disableDotNotation.label",type:"checkbox"}),Ut({handle:"disableDotNotation",userControlled:!0}),C("design:type",Boolean)],ds.prototype,"disableDotNotation",void 0),k([w(),$t({handle:"onlyInA"}),C("design:type",Array)],ds.prototype,"onlyInA",void 0),k([$t({handle:"same"}),C("design:type",Array)],ds.prototype,"same",void 0),k([$t({handle:"different"}),C("design:type",Array)],ds.prototype,"different",void 0),k([$t({handle:"onlyInB"}),C("design:type",Array)],ds.prototype,"onlyInB",void 0),ds=k([Mt("core.data.compareDatasets",{kind:"core.data.compareDatasets",category:"Data",color:"#8b5cf6",icon:"ti-git-compare",width:96,height:96,labels:["data","compare","diff","datasets"],metadata:{title:"graph.node.data.compare_datasets.name",description:"graph.node.data.compare_datasets.description"}}),I()],ds);let ls=class extends Wi{constructor(){super(...arguments),this.fieldsToSummarize=[],this.outputFormat="separateItems",this.skipEmptySplitFields=!1,this.disableDotNotation=!1,this.continueIfFieldNotFound=!1}execute(e){const t=ua(e.inputs.value),o=(this.fieldsToSummarize??[]).filter(e=>e&&"string"==typeof e.aggregation);if(0===o.length)throw new Cr("Summarize node requires at least one field to summarize","GRAPH_SUMMARIZE_FIELDS_REQUIRED");return{result:os(t,o,{fieldsToSplitBy:La(this.fieldsToSplitBy,"Fields To Split By"),outputFormat:this.outputFormat,skipEmptySplitFields:!0===this.skipEmptySplitFields,dotNotation:!0!==this.disableDotNotation,continueIfFieldNotFound:!0===this.continueIfFieldNotFound})}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],ls.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.summarize.fields.fieldsToSummarize.label",placeholder:"graph.node.data.summarize.fields.fieldsToSummarize.placeholder",type:"collection"}),Ut({handle:"fieldsToSummarize",userControlled:!0,type:"array"}),C("design:type",Array)],ls.prototype,"fieldsToSummarize",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.summarize.fields.fieldsToSplitBy.label",placeholder:"graph.node.data.summarize.fields.fieldsToSplitBy.placeholder",type:"text"}),Ut({handle:"fieldsToSplitBy",userControlled:!0}),C("design:type",Object)],ls.prototype,"fieldsToSplitBy",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.summarize.fields.outputFormat.label",type:"select"}),Ut({handle:"outputFormat",userControlled:!0}),C("design:type",String)],ls.prototype,"outputFormat",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.summarize.fields.skipEmptySplitFields.label",type:"checkbox"}),Ut({handle:"skipEmptySplitFields",userControlled:!0}),C("design:type",Boolean)],ls.prototype,"skipEmptySplitFields",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.summarize.fields.disableDotNotation.label",type:"checkbox"}),Ut({handle:"disableDotNotation",userControlled:!0}),C("design:type",Boolean)],ls.prototype,"disableDotNotation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.summarize.fields.continueIfFieldNotFound.label",type:"checkbox"}),Ut({handle:"continueIfFieldNotFound",userControlled:!0}),C("design:type",Boolean)],ls.prototype,"continueIfFieldNotFound",void 0),k([w(),$t({handle:"result"}),C("design:type",Array)],ls.prototype,"result",void 0),ls=k([Mt("core.data.summarize",{kind:"core.data.summarize",category:"Data",color:"#8b5cf6",icon:"ti-chart-dots",width:96,height:96,labels:["data","summarize","pivot","aggregate"],metadata:{title:"graph.node.data.summarize.name",description:"graph.node.data.summarize.description"}}),I()],ls);let cs=class extends Wi{constructor(){super(...arguments),this.compareMode="allFields",this.removeOtherFields=!1,this.disableDotNotation=!1}execute(e){const t=ua(e.inputs.value),{kept:o,discarded:r}=Ja(t,{compare:this.compareMode,fieldsToExclude:this.fieldsToExclude,fieldsToCompare:this.fieldsToCompare,removeOtherFields:!0===this.removeOtherFields,dotNotation:!0!==this.disableDotNotation});return{result:o,discarded:r}}};function ps(e,t){if("string"==typeof e){if(e.startsWith("data:")){const t=e.indexOf(",");if(t>=0)return Buffer.from(e.slice(t+1),"base64").toString("utf8")}return"base64"===t?Buffer.from(e,"base64").toString("utf8"):e}if(_a(e))return(Buffer.isBuffer(e)?e:Buffer.from(e instanceof ArrayBuffer?new Uint8Array(e):e)).toString("utf8");if(pa(e)){if("string"==typeof e.data)return ps(e.data,t);if("string"==typeof e.content)return ps(e.content,t);throw new Cr("Extract from File node received an object without file content","GRAPH_EXTRACT_FROM_FILE_INVALID_INPUT")}throw new Cr("Extract from File node requires a file payload","GRAPH_EXTRACT_FROM_FILE_INVALID_INPUT",{valueType:typeof e})}k([w(),Ut({handle:"value"}),C("design:type",Object)],cs.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.remove_duplicates.fields.compareMode.label",type:"select"}),Ut({handle:"compareMode",userControlled:!0}),C("design:type",String)],cs.prototype,"compareMode",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.remove_duplicates.fields.fieldsToCompare.label",placeholder:"graph.node.data.remove_duplicates.fields.fieldsToCompare.placeholder",type:"text"}),Ut({handle:"fieldsToCompare",userControlled:!0}),C("design:type",Object)],cs.prototype,"fieldsToCompare",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.remove_duplicates.fields.fieldsToExclude.label",placeholder:"graph.node.data.remove_duplicates.fields.fieldsToExclude.placeholder",type:"text"}),Ut({handle:"fieldsToExclude",userControlled:!0}),C("design:type",Object)],cs.prototype,"fieldsToExclude",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.remove_duplicates.fields.removeOtherFields.label",type:"checkbox"}),Ut({handle:"removeOtherFields",userControlled:!0}),C("design:type",Boolean)],cs.prototype,"removeOtherFields",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.data.remove_duplicates.fields.disableDotNotation.label",type:"checkbox"}),Ut({handle:"disableDotNotation",userControlled:!0}),C("design:type",Boolean)],cs.prototype,"disableDotNotation",void 0),k([w(),$t({handle:"result"}),C("design:type",Array)],cs.prototype,"result",void 0),k([$t({handle:"discarded"}),C("design:type",Array)],cs.prototype,"discarded",void 0),cs=k([Mt("core.data.removeDuplicates",{kind:"core.data.removeDuplicates",category:"Data",color:"#8b5cf6",icon:"ti-copy-off",width:96,height:96,labels:["data","dedupe","duplicates","unique"],metadata:{title:"graph.node.data.remove_duplicates.name",description:"graph.node.data.remove_duplicates.description"}}),I()],cs);let us=class extends Wi{constructor(){super(...arguments),this.format="json",this.encoding="utf8",this.delimiter=",",this.headerRow=!0}execute(e){const t=ps(e.inputs.value,this.encoding??"utf8");switch(this.format){case"json":try{return{result:JSON.parse(t)}}catch(e){throw new Cr("Extract from File node could not parse JSON: "+(e instanceof Error?e.message:e+""),"GRAPH_EXTRACT_FROM_FILE_INVALID_JSON")}case"csv":{const e=((e,t,o)=>{const r=((e,t)=>{const o=[];let r=[],n="",i=!1;for(let a=0;a<e.length;a++){const s=e[a];i?'"'===s?'"'===e[a+1]?(n+='"',a++):i=!1:n+=s:'"'!==s?s!==t?"\n"!==s?"\r"!==s&&(n+=s):(r.push(n),o.push(r),r=[],n=""):(r.push(n),n=""):i=!0}return(n.length>0||r.length>0)&&(r.push(n),o.push(r)),o.filter(e=>e.length>1||(e[0]??"").trim().length>0)})(e,t);if(0===r.length)return[];const n=o?r[0]:r[0].map((e,t)=>"column"+t);return(o?r.slice(1):r).map(e=>{const t={};for(let o=0;o<n.length;o++)t[n[o]]=e[o]??"";return t})})(t,this.delimiter||",",!1!==this.headerRow);return{result:e,rows:e.length}}case"text":return{result:t};default:throw new Cr(`Unsupported file extraction format '${this.format+""}'`,"GRAPH_EXTRACT_FROM_FILE_UNSUPPORTED_FORMAT",{format:this.format})}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],us.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.format.label",type:"select"}),Ut({handle:"format",userControlled:!0}),C("design:type",String)],us.prototype,"format",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.encoding.label",type:"select"}),Ut({handle:"encoding",userControlled:!0}),C("design:type",String)],us.prototype,"encoding",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.delimiter.label",type:"text"}),Ut({handle:"delimiter",userControlled:!0}),C("design:type",String)],us.prototype,"delimiter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.extract_from_file.fields.headerRow.label",type:"checkbox"}),Ut({handle:"headerRow",userControlled:!0}),C("design:type",Boolean)],us.prototype,"headerRow",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],us.prototype,"result",void 0),k([$t({handle:"rows"}),C("design:type",Number)],us.prototype,"rows",void 0),us=k([Mt("core.io.extractFromFile",{kind:"core.io.extractFromFile",category:"IO",color:"#0ea5e9",icon:"ti-file-import",width:96,height:96,labels:["io","file","extract"],metadata:{title:"graph.node.io.extract_from_file.name",description:"graph.node.io.extract_from_file.description"}}),I()],us);const gs=new Set(["http:","https:"]);let hs=class extends Wi{constructor(){super(...arguments),this.url="",this.method="GET",this.responseFormat="json",this.failOnError=!1}async execute(e,t){if(!this.url)throw new Cr("HTTP Request node requires a URL","GRAPH_HTTP_URL_REQUIRED");let o;try{o=new URL(this.url)}catch{throw new Cr(`HTTP Request node URL '${this.url}' is invalid`,"GRAPH_HTTP_INVALID_URL",{url:this.url})}if(!gs.has(o.protocol))throw new Cr(`HTTP Request node protocol '${o.protocol}' is not allowed`,"GRAPH_HTTP_PROTOCOL_NOT_ALLOWED",{protocol:o.protocol});this.appendQuery(o);const r=this.method??"GET",n={};for(const[e,t]of Object.entries(this.headers??{}))"string"==typeof t&&e.trim().length>0&&(n[e.trim()]=t);const i=this.resolveBody(e,r);void 0!==i&&void 0===n["content-type"]&&(n["content-type"]="application/json");const a=this.resolveTimeoutMs(),s=new AbortController,d=setTimeout(()=>s.abort(),a);d.unref?.();const l=()=>s.abort();t.abortSignal?.addEventListener("abort",l,{once:!0});try{const{response:e,url:t}=await this.fetchFollowingRedirects(o,{method:r,headers:n,body:i,signal:s.signal}),a=await this.readCappedResponseText(e),d=Object.fromEntries(e.headers.entries()),l="text"===this.responseFormat?a:this.parseResponse(a);if(!0===this.failOnError&&!e.ok)throw new Cr("HTTP Request node received status "+e.status,"GRAPH_HTTP_REQUEST_FAILED",{status:e.status,url:t.toString()});return{result:l,status:e.status,headers:d}}catch(e){if(e instanceof Cr)throw e;if(s.signal.aborted)throw new Cr(`HTTP Request node timed out after ${a}ms`,"GRAPH_HTTP_REQUEST_TIMEOUT",{url:o.toString(),timeoutMs:a});throw new Cr("HTTP Request node failed: "+(e instanceof Error?e.message:e+""),"GRAPH_HTTP_REQUEST_FAILED",{url:o.toString()})}finally{clearTimeout(d),t.abortSignal?.removeEventListener("abort",l)}}resolveTimeoutMs(){const e=Number(this.timeoutMs);return Number.isFinite(e)&&e>0?Math.min(e,fr):3e4}async fetchFollowingRedirects(e,t){let o=e,r=t;for(let e=0;5>=e;e++){const t=await fetch(o,{...r,redirect:"manual"});if(!this.isRedirectStatus(t.status))return{response:t,url:o};const n=t.headers.get("location");if(!n)return{response:t,url:o};if(5===e)throw await this.discardResponseBody(t),new Cr("HTTP Request node exceeded the maximum of 5 redirects","GRAPH_HTTP_TOO_MANY_REDIRECTS",{url:o.toString(),maxRedirects:5});let i;try{i=new URL(n,o)}catch{throw await this.discardResponseBody(t),new Cr(`HTTP Request node redirect target '${n}' is invalid`,"GRAPH_HTTP_INVALID_URL",{location:n})}if(!gs.has(i.protocol))throw await this.discardResponseBody(t),new Cr(`HTTP Request node redirect protocol '${i.protocol}' is not allowed`,"GRAPH_HTTP_PROTOCOL_NOT_ALLOWED",{protocol:i.protocol,url:i.toString()});if(await this.discardResponseBody(t),303===t.status){r={...r,method:"GET",body:void 0};const e={...r.headers};for(const t of Object.keys(e))"content-type"===t.toLowerCase()&&delete e[t];r={...r,headers:e}}o=i}return{response:void 0,url:o}}isRedirectStatus(e){return 301===e||302===e||303===e||307===e||308===e}async discardResponseBody(e){try{await(e.body?.cancel())}catch{}}async readCappedResponseText(e){if(!e.body)return"";const t=e.body.getReader(),o=[];let r=0;try{for(;;){const{done:e,value:n}=await t.read();if(e)break;if(n){if(r+=n.byteLength,r>yr){try{await t.cancel()}catch{}throw new Cr("HTTP Request node response body exceeds the 10485760-byte limit","GRAPH_HTTP_RESPONSE_TOO_LARGE",{limitBytes:yr})}o.push(n)}}}finally{t.releaseLock?.()}return Buffer.concat(o.map(e=>Buffer.from(e))).toString("utf8")}appendQuery(e){for(const[t,o]of Object.entries(this.query??{}))if(null!=o)if(Array.isArray(o))for(const r of o)null!=r&&e.searchParams.append(t,r+"");else e.searchParams.append(t,o+"")}resolveBody(e,t){if("GET"===t||"HEAD"===t)return;const o=void 0!==this.body?this.body:e.inputs.value;return null!=o?"string"==typeof o||"undefined"!=typeof Buffer&&Buffer.isBuffer(o)||o instanceof Uint8Array?o:JSON.stringify(o):void 0}parseResponse(e){if(0===e.length)return null;try{return JSON.parse(e)}catch{return e}}};function fs(e,t){if("string"==typeof e){if(e.startsWith("data:")){const t=e.indexOf(",");return Buffer.from(e.slice(t+1),"base64")}return"base64"===t?Buffer.from(e,"base64"):Buffer.from(e,"utf8")}if(pa(e)){const o=e.data??e.content;if(void 0!==o)return fs(o,t)}if(_a(e))return Buffer.isBuffer(e)?e:Buffer.from(e instanceof ArrayBuffer?new Uint8Array(e):e);throw new Cr("Read PDF node requires a PDF file payload","GRAPH_READ_PDF_INVALID_INPUT",{valueType:typeof e})}k([Ut({handle:"value"}),C("design:type",Object)],hs.prototype,"value",void 0),k([w(),i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.url.label",placeholder:"graph.node.io.http_request.fields.url.placeholder",type:"text"}),Ut({handle:"url",userControlled:!0}),C("design:type",String)],hs.prototype,"url",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.method.label",type:"select"}),Ut({handle:"method",userControlled:!0}),C("design:type",String)],hs.prototype,"method",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.headers.label",type:"json"}),Ut({handle:"headers",userControlled:!0,type:"object"}),C("design:type",Object)],hs.prototype,"headers",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.query.label",type:"json"}),Ut({handle:"query",userControlled:!0,type:"object"}),C("design:type",Object)],hs.prototype,"query",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.body.label",type:"json"}),Ut({handle:"body",userControlled:!0,type:"object"}),C("design:type",Object)],hs.prototype,"body",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.responseFormat.label",type:"select"}),Ut({handle:"responseFormat",userControlled:!0}),C("design:type",String)],hs.prototype,"responseFormat",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.timeoutMs.label",type:"number"}),Ut({handle:"timeoutMs",userControlled:!0}),C("design:type",Number)],hs.prototype,"timeoutMs",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.http_request.fields.failOnError.label",type:"checkbox"}),Ut({handle:"failOnError",userControlled:!0}),C("design:type",Boolean)],hs.prototype,"failOnError",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],hs.prototype,"result",void 0),k([$t({handle:"status"}),C("design:type",Number)],hs.prototype,"status",void 0),k([$t({handle:"headers"}),C("design:type",Object)],hs.prototype,"headersOut",void 0),hs=k([Mt("core.io.httpRequest",{kind:"core.io.httpRequest",category:"IO",color:"#0ea5e9",icon:"ti-world-www",width:96,height:96,labels:["io","http","request"],metadata:{title:"graph.node.io.http_request.name",description:"graph.node.io.http_request.description"}}),I()],hs);let ys=class extends Wi{constructor(){super(...arguments),this.encoding="utf8"}async execute(e){const t=fs(e.inputs.value,this.encoding??"utf8");let o;try{o=await(import("pdf-parse"))}catch(e){throw new Cr("Read PDF node requires the 'pdf-parse' dependency: "+(e instanceof Error?e.message:e+""),"GRAPH_READ_PDF_DEPENDENCY_MISSING")}const r=o.PDFParse;if(!r)throw new Cr("Read PDF node could not resolve the PDF parser","GRAPH_READ_PDF_DEPENDENCY_MISSING");const n=new r({data:t,...this.password?{password:this.password}:{}});try{const e=await n.getText(),t=e.text??"",o=(e.pages??[]).map((e,t)=>({pageNumber:t+1,text:e.text??""}));return{result:t,pages:o}}catch(e){throw new Cr("Read PDF node failed to extract text: "+(e instanceof Error?e.message:e+""),"GRAPH_READ_PDF_FAILED")}finally{await(n.destroy?.())}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],ys.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.read_pdf.fields.encoding.label",type:"select"}),Ut({handle:"encoding",userControlled:!0}),C("design:type",String)],ys.prototype,"encoding",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.read_pdf.fields.password.label",placeholder:"graph.node.io.read_pdf.fields.password.placeholder",type:"password"}),Ut({handle:"password",userControlled:!0}),C("design:type",String)],ys.prototype,"password",void 0),k([w(),$t({handle:"result"}),C("design:type",String)],ys.prototype,"result",void 0),k([$t({handle:"pages"}),C("design:type",Array)],ys.prototype,"pages",void 0),ys=k([Mt("core.io.readPDF",{kind:"core.io.readPDF",category:"IO",color:"#0ea5e9",icon:"ti-file-type-pdf",width:96,height:96,labels:["io","pdf","extract"],metadata:{title:"graph.node.io.read_pdf.name",description:"graph.node.io.read_pdf.description"}}),I()],ys);const ms=new Set(["workdocs"]);function bs(){return["/etc","/proc","/root",oe(de(),".ssh")]}function ws(e,t){const o=re(e,t);return""===o||!o.startsWith("..")&&!ie(o)}function vs(e,t,o){if(!ws(e,t))throw new Cr(`Read/Write Files from Disk node path '${o}' resolves outside the configured file IO base`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:o,base:e});for(const e of bs())if(ws(e,t))throw new Cr(`Read/Write Files from Disk node path '${o}' targets a forbidden directory`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:o});const r=re(e,t).split(ne).filter(Boolean);for(const e of r)if(ms.has(e.toLowerCase()))throw new Cr(`Read/Write Files from Disk node path '${o}' targets a forbidden directory`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:o,segment:e})}async function xs(e){let t=e;for(;;)try{return await ce(t)}catch{const e=te(t);if(e===t)return;t=e}}let Is=class extends Wi{constructor(){super(...arguments),this.operation="read",this.path="",this.encoding="utf8",this.append=!1,this.createDirectories=!1}async execute(e){if(!this.path)throw new Cr("Read/Write Files from Disk node requires a path","GRAPH_READ_WRITE_FILE_PATH_REQUIRED");if(this.path.includes("\0"))throw new Cr("Read/Write Files from Disk node path contains a NUL byte","GRAPH_READ_WRITE_FILE_INVALID_PATH",{path:this.path});const{base:t,candidate:o}=(e=>{const t=(()=>{const e=process.env.GRAPH_FILE_IO_BASE?.trim(),t=oe(e&&e.length>0?e:process.cwd());try{return le(t)}catch{return t}})();(e=>{if(!ie(e))return;const t=oe(e);for(const o of bs())if(ws(o,t))throw new Cr(`Read/Write Files from Disk node path '${e}' targets a forbidden directory`,"GRAPH_READ_WRITE_FILE_PATH_FORBIDDEN",{path:e})})(e);const o=e.replace(/^[/\\]+/,""),r=oe(t,o);return vs(t,r,e),{base:t,candidate:r}})(this.path);if("read"===this.operation){let e;try{e=await ce(o)}catch{throw new Cr(`Read/Write Files from Disk node path '${this.path}' does not exist`,"GRAPH_READ_WRITE_FILE_INVALID_PATH",{path:this.path})}vs(t,e,this.path);const r=await pe(e);return{result:"base64"===this.encoding?r.toString("base64"):r.toString("utf8"),bytes:r.byteLength}}const r=void 0!==this.content?this.content:e.inputs.value;if(null==r)throw new Cr("Read/Write Files from Disk node requires content to write","GRAPH_READ_WRITE_FILE_CONTENT_REQUIRED");const n="string"==typeof r?"base64"===this.encoding?Buffer.from(r,"base64"):Buffer.from(r,"utf8"):Buffer.isBuffer(r)?r:r instanceof Uint8Array?Buffer.from(r):Buffer.from(r+"","utf8"),i=await xs(o);i&&vs(t,i,this.path),this.createDirectories&&await ue(te(o),{recursive:!0}),vs(t,await ce(te(o)),this.path);const a=await xs(o);return a&&vs(t,a,this.path),this.append?await ge(o,n):await he(o,n),{result:{path:this.path,bytes:n.byteLength},bytes:n.byteLength}}};k([Ut({handle:"value"}),C("design:type",Object)],Is.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Is.prototype,"operation",void 0),k([w(),i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.path.label",placeholder:"graph.node.io.read_write_file.fields.path.placeholder",type:"text"}),Ut({handle:"path",userControlled:!0}),C("design:type",String)],Is.prototype,"path",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.encoding.label",type:"select"}),Ut({handle:"encoding",userControlled:!0}),C("design:type",String)],Is.prototype,"encoding",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.content.label",type:"textarea"}),Ut({handle:"content",userControlled:!0}),C("design:type",String)],Is.prototype,"content",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.append.label",type:"checkbox"}),Ut({handle:"append",userControlled:!0}),C("design:type",Boolean)],Is.prototype,"append",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.read_write_file.fields.createDirectories.label",type:"checkbox"}),Ut({handle:"createDirectories",userControlled:!0}),C("design:type",Boolean)],Is.prototype,"createDirectories",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],Is.prototype,"result",void 0),k([$t({handle:"bytes"}),C("design:type",Number)],Is.prototype,"bytes",void 0),Is=k([Mt("core.io.readWriteFile",{kind:"core.io.readWriteFile",category:"IO",color:"#0ea5e9",icon:"ti-device-floppy",width:96,height:96,labels:["io","file","disk"],metadata:{title:"graph.node.io.read_write_file.name",description:"graph.node.io.read_write_file.description"}}),I()],Is);let _s=class extends Wi{constructor(){super(...arguments),this.respondWith="firstIncomingItem",this.responseCode=200}async execute(e,t){const o=this.resolveBody(e),r={};for(const[e,t]of Object.entries(this.responseHeaders??{}))"string"==typeof t&&e.trim().length>0&&(r[e.trim()]=t);null!=o&&"string"!=typeof o&&void 0===r["content-type"]&&(r["content-type"]="application/json");const n={statusCode:this.responseCode??200,headers:r,body:o,runId:t.runId,respondedAt:(new Date).toISOString()},i=t.engine?.webhookResponses.deliver(t.runId,n)??!1;return await t.progress({...n,delivered:i}),{response:n,delivered:i}}resolveBody(e){const t=e.inputs.value;switch(this.respondWith){case"noData":return null;case"allIncomingItems":return ua(t);case"firstIncomingItem":return ua(t)[0]??null;case"text":return void 0===this.responseBody?null==t?"":t+"":this.responseBody+"";default:if("string"==typeof this.responseBody)try{return JSON.parse(this.responseBody)}catch{return this.responseBody}return void 0!==this.responseBody?this.responseBody:t??null}}};function Es(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:void 0}function As(e){return"string"==typeof e&&e.trim().length>0?e.trim():void 0}function Ss(e,t=!1){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===e.toLowerCase())return!0;if("false"===e.toLowerCase())return!1}return t}function Rs(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e&&e.trim().length>0){const t=Number(e);return Number.isFinite(t)?t:void 0}}function Os(e){return Array.isArray(e)?e:void 0}function ks(e,t){try{const t=Es(e);if(t)return t;const o=Es(JSON.parse(e));if(!o)throw Error("not an object");return o}catch{throw new Cr(t+" node credential must contain a JSON object","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:t})}}function Cs(e,t){if(e){if("string"!=typeof e)return Array.isArray(e)?void 0:e;if(e.trim().startsWith("{"))try{const t=Es(JSON.parse(e));if(!t)throw Error("not an object");return t}catch{throw new Cr(t+" node credential must contain a JSON object","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:t})}}}function Ns(e,t,o){const r=Cs(e,o);return r?As(r[t]):"token"===t&&"string"==typeof e?As(e):void 0}function Ts(e,t){return Ns(e,"token",t)}function Ps(e,t,o){if("string"==typeof e)return As(e);const r=Cs(e,o);if(r)for(const e of Array.isArray(t)?t:[t]){const t=As(r[e]);if(t)return t}}k([Ut({handle:"value"}),C("design:type",Object)],_s.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.respondWith.label",type:"select"}),Ut({handle:"respondWith",userControlled:!0}),C("design:type",String)],_s.prototype,"respondWith",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.responseCode.label",type:"number"}),Ut({handle:"responseCode",userControlled:!0}),C("design:type",Number)],_s.prototype,"responseCode",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.responseHeaders.label",type:"json"}),Ut({handle:"responseHeaders",userControlled:!0,type:"object"}),C("design:type",Object)],_s.prototype,"responseHeaders",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.respond_to_webhook.fields.responseBody.label",type:"json"}),Ut({handle:"responseBody",userControlled:!0,type:"object"}),C("design:type",Object)],_s.prototype,"responseBody",void 0),k([w(),$t({handle:"response"}),C("design:type",Object)],_s.prototype,"response",void 0),k([$t({handle:"delivered"}),C("design:type",Boolean)],_s.prototype,"delivered",void 0),_s=k([Mt("core.io.respondToWebhook",{kind:"core.io.respondToWebhook",category:"IO",color:"#0ea5e9",icon:"ti-corner-up-left",width:96,height:96,labels:["io","webhook","response"],metadata:{title:"graph.node.io.respond_to_webhook.name",description:"graph.node.io.respond_to_webhook.description"}}),I()],_s);const Ds={postgres:5432,mysql:3306,mssql:1433};class js extends Wi{constructor(){super(...arguments),this.ssl=!1,this.acceptSelfSigned=!1}dataSourceOptions(e,t,o,r,n){const i=Ss(this.ssl,!1),a=Ss(this.acceptSelfSigned,!1),s={host:e,port:t,database:o,username:r,password:n,entities:[],synchronize:!1};return"postgres"===this.driver?{...s,type:"postgres",ssl:!!i&&{rejectUnauthorized:!a}}:"mysql"===this.driver?{...s,type:"mysql",ssl:i?{}:void 0}:{...s,type:"mssql",options:{encrypt:i,trustServerCertificate:!i}}}async execute(e,t){const o=this.constructor.name,r=this.sql?.trim();if(!r)throw new Cr(o+" node requires a SQL statement","GRAPH_DATABASE_SQL_REQUIRED");const n=this.host?.trim(),i=this.database?.trim(),a=this.username?.trim();if(!n||!i||!a)throw new Cr(o+" node requires host, database, and username","GRAPH_DATABASE_CONNECTION_REQUIRED");const s=Ps(await an(t,e.credentials,this.credentialType,!1,o),["password","secret","token"],o),d=Os(this.parameters)??(Array.isArray(e.inputs.value)?e.inputs.value:[]),l=`as-graph-${this.driver}-${Date.now()}-${Math.random().toString(36).slice(2)}`,c=new ye(this.dataSourceOptions(n,Rs(this.port)??Ds[this.driver],i,a,s),l),p=new G;try{await c.initialize(p);const e=await c.raw({query:r,values:d},!0,p),{rows:t,rowCount:o}=(e=>{if(Array.isArray(e))return{rows:e,rowCount:e.length};const t=Es(e);if(!t)return{rows:[],rowCount:0};if(Array.isArray(t.recordsets)){const e=t.recordsets.flat(),o=t.rowsAffected;return{rows:e,rowCount:Array.isArray(o)?o.reduce((e,t)=>e+Number(t||0),0):e.length}}if(Array.isArray(t.rows)){const e=t.rows;return{rows:e,rowCount:Rs(t.rowCount)??e.length}}if(Array.isArray(t.recordset)){const e=t.recordset;return{rows:e,rowCount:e.length}}if(Array.isArray(t.data)){const e=t.data;return{rows:e,rowCount:Rs(t.count)??e.length}}return{rows:[],rowCount:Rs(t.affectedRows)??0}})(e);return{result:t,rows:t,rowCount:o}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`${o} node query failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_DATABASE_QUERY_FAILED",{driver:this.driver})}finally{await c.shutdown().catch(()=>{}),V.unregister(l)}}}k([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.host.label",type:"string"}),Ut({handle:"host",userControlled:!0}),C("design:type",String)],js.prototype,"host",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.port.label",type:"number"}),Ut({handle:"port",userControlled:!0}),C("design:type",Number)],js.prototype,"port",void 0),k([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.database.label",type:"string"}),Ut({handle:"database",userControlled:!0}),C("design:type",String)],js.prototype,"database",void 0),k([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.username.label",type:"string"}),Ut({handle:"username",userControlled:!0}),C("design:type",String)],js.prototype,"username",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.ssl.label",type:"boolean"}),Ut({handle:"ssl",userControlled:!0}),C("design:type",Boolean)],js.prototype,"ssl",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.acceptSelfSigned.label",type:"boolean"}),Ut({handle:"acceptSelfSigned",userControlled:!0}),C("design:type",Boolean)],js.prototype,"acceptSelfSigned",void 0),k([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sql.label",type:"textarea"}),Ut({handle:"sql",userControlled:!0}),C("design:type",String)],js.prototype,"sql",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.parameters.label",type:"array"}),Ut({handle:"parameters",userControlled:!0}),C("design:type",Array)],js.prototype,"parameters",void 0),k([Ut({handle:"value"}),C("design:type",Object)],js.prototype,"value",void 0),k([w(),$t({handle:"result",type:"array"}),C("design:type",Array)],js.prototype,"result",void 0),k([$t({handle:"rows",type:"array"}),C("design:type",Array)],js.prototype,"rows",void 0),k([$t({handle:"rowCount",type:"number"}),C("design:type",Number)],js.prototype,"rowCount",void 0);let Ls=class extends js{constructor(){super(...arguments),this.driver="postgres",this.credentialType="postgres"}};Ls=k([Mt("core.storage.postgres",{kind:"core.storage.postgres",category:"Storage",color:"#336791",icon:"ti-database",width:96,height:96,labels:["storage","database","postgres","sql"],metadata:{title:"graph.node.storage.postgres.name",description:"graph.node.storage.postgres.description"}}),I()],Ls);let Ms=class extends js{constructor(){super(...arguments),this.driver="mysql",this.credentialType="mysql"}};Ms=k([Mt("core.storage.mySql",{kind:"core.storage.mySql",category:"Storage",color:"#00758f",icon:"ti-database",width:96,height:96,labels:["storage","database","mysql","sql"],metadata:{title:"graph.node.storage.my_sql.name",description:"graph.node.storage.my_sql.description"}}),I()],Ms);let Gs=class extends js{constructor(){super(...arguments),this.driver="mssql",this.credentialType="mssql"}};Gs=k([Mt("core.storage.microsoftSql",{kind:"core.storage.microsoftSql",category:"Storage",color:"#cc2927",icon:"ti-database",width:96,height:96,labels:["storage","database","mssql","sqlserver","sql"],metadata:{title:"graph.node.storage.microsoft_sql.name",description:"graph.node.storage.microsoft_sql.description"}}),I()],Gs);const Us=["get","set","delete","incr","keys","llen","lpop","rpop","lpush","rpush","publish","info"];function $s(e){if(null===e)return null;try{return JSON.parse(e)}catch{return e}}function Fs(e){return"string"==typeof e?e:null==e?"":JSON.stringify(e)}let Hs=class extends Wi{constructor(){super(...arguments),this.operation="get",this.tls=!1}async execute(e,t){const o=Us.includes(this.operation)?this.operation:"get",r=Ps(await an(t,e.credentials,"redis",!1,"Redis"),["password","secret","token"],"Redis"),n=As(this.host)??"localhost",i=Rs(this.port)??6379,a=As(this.key),s=As(this.prefix),d=e=>s?`${s}:${e}`:e,l=As(this.pattern),c=As(this.channel),p=this.value??e.inputs.value;if(!("info"===o||a||"keys"===o&&l||"publish"===o&&c))throw new Cr(`Redis node operation '${o}' requires a key`,"GRAPH_REDIS_KEY_REQUIRED",{operation:o});const u=`as-graph-redis-${Date.now()}-${Math.random().toString(36).slice(2)}`,g=new me({host:n,port:i,username:As(this.username),password:r,database:Rs(this.database),tls:!!this.tls||void 0},u);try{await g.initialize();const e=g.client;switch(o){case"get":return{result:$s(await e.get(d(a)))};case"set":{const t=Rs(this.ttlSeconds);return{result:await e.set(d(a),Fs(p),t&&t>0?{EX:Math.floor(t)}:void 0)}}case"delete":{const t=await e.del(d(a));return{result:t,count:t}}case"incr":{const t=await e.incr(d(a));return{result:t,count:t}}case"keys":{const t=await e.keys(d(l??a??"*"));return{result:t,count:t.length}}case"llen":{const t=await e.lLen(d(a));return{result:t,count:t}}case"lpop":return{result:$s(await e.lPop(d(a)))};case"rpop":return{result:$s(await e.rPop(d(a)))};case"lpush":{const t=await e.lPush(d(a),Fs(p));return{result:t,count:t}}case"rpush":{const t=await e.rPush(d(a),Fs(p));return{result:t,count:t}}case"publish":{const t=await e.publish(c??a,Fs(p));return{result:t,count:t}}default:return{result:await e.info(As(this.section))}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Redis node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_REDIS_OPERATION_FAILED",{operation:o})}finally{await g.shutdown().catch(()=>{}),V.unregister(u)}}};k([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Hs.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.host.label",type:"string"}),Ut({handle:"host",userControlled:!0}),C("design:type",String)],Hs.prototype,"host",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.port.label",type:"number"}),Ut({handle:"port",userControlled:!0}),C("design:type",Number)],Hs.prototype,"port",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.username.label",type:"string"}),Ut({handle:"username",userControlled:!0}),C("design:type",String)],Hs.prototype,"username",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.database.label",type:"number"}),Ut({handle:"database",userControlled:!0}),C("design:type",Number)],Hs.prototype,"database",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.tls.label",type:"boolean"}),Ut({handle:"tls",userControlled:!0}),C("design:type",Boolean)],Hs.prototype,"tls",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.prefix.label",type:"string"}),Ut({handle:"prefix",userControlled:!0}),C("design:type",String)],Hs.prototype,"prefix",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.key.label",type:"string"}),Ut({handle:"key",userControlled:!0}),C("design:type",String)],Hs.prototype,"key",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.value.label",type:"textarea"}),Ut({handle:"value",userControlled:!0}),C("design:type",Object)],Hs.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.ttlSeconds.label",type:"number"}),Ut({handle:"ttlSeconds",userControlled:!0}),C("design:type",Number)],Hs.prototype,"ttlSeconds",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.pattern.label",type:"string"}),Ut({handle:"pattern",userControlled:!0}),C("design:type",String)],Hs.prototype,"pattern",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.channel.label",type:"string"}),Ut({handle:"channel",userControlled:!0}),C("design:type",String)],Hs.prototype,"channel",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.redis.fields.section.label",type:"string"}),Ut({handle:"section",userControlled:!0}),C("design:type",String)],Hs.prototype,"section",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],Hs.prototype,"result",void 0),k([$t({handle:"value"}),C("design:type",Object)],Hs.prototype,"valueOutput",void 0),k([$t({handle:"count",type:"number"}),C("design:type",Number)],Hs.prototype,"count",void 0),Hs=k([Mt("core.storage.redis",{kind:"core.storage.redis",category:"Storage",color:"#dc382d",icon:"ti-brand-redis",width:96,height:96,labels:["storage","redis","cache","keyvalue"],metadata:{title:"graph.node.storage.redis.name",description:"graph.node.storage.redis.description"}}),I()],Hs);const Bs=["queue","exchange"];let qs=class extends Wi{constructor(){super(...arguments),this.mode="queue",this.ssl=!1}async execute(e,t){const o=Bs.includes(this.mode)?this.mode:"queue",r=As(this.queue),n=As(this.exchange),i=As(this.routingKey)??"";if("queue"===o&&!r)throw new Cr("RabbitMQ node requires a queue when publishing to a queue","GRAPH_RABBITMQ_QUEUE_REQUIRED");if("exchange"===o&&!n)throw new Cr("RabbitMQ node requires an exchange when publishing to an exchange","GRAPH_RABBITMQ_EXCHANGE_REQUIRED");const a=Ps(await an(t,e.credentials,"rabbitmq",!1,"RabbitMQ"),["password","secret","token"],"RabbitMQ"),s=Ss(this.ssl,!1),d="string"==typeof(l=this.value??e.inputs.value??e.inputs.payload??e.inputs.message)?l:null==l?"":JSON.stringify(l);var l;let c,p;try{let e;if(c=await be({protocol:s?"amqps":"amqp",hostname:As(this.host)??"localhost",port:Rs(this.port)??(s?5671:5672),username:As(this.username)??"guest",password:a,vhost:As(this.vhost)??"/",heartbeat:10}),p=await c.createConfirmChannel(),"exchange"===o){const t=As(this.exchangeType)??"topic";await p.assertExchange(n,t,{durable:!0}),p.publish(n,i,Buffer.from(d,"utf8"),{contentType:"application/json",contentEncoding:"utf8"}),e=n}else await p.assertQueue(r,{durable:!0}),p.sendToQueue(r,Buffer.from(d,"utf8"),{contentType:"application/json",contentEncoding:"utf8"}),e=r;return await p.waitForConfirms(),{result:!0,target:e}}catch(e){if(e instanceof Cr)throw e;throw new Cr("RabbitMQ node publish failed: "+(e instanceof Error?e.message:e+""),"GRAPH_RABBITMQ_PUBLISH_FAILED",{mode:o})}finally{await(p?.close().catch(()=>{})),await(c?.close().catch(()=>{}))}}};k([Ut({handle:"mode",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.mode.label",type:"select"}),C("design:type",String)],qs.prototype,"mode",void 0),k([Ut({handle:"queue",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.queue.label",type:"string"}),C("design:type",String)],qs.prototype,"queue",void 0),k([Ut({handle:"exchange",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.exchange.label",type:"string"}),C("design:type",String)],qs.prototype,"exchange",void 0),k([Ut({handle:"exchangeType",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.exchangeType.label",type:"string"}),C("design:type",String)],qs.prototype,"exchangeType",void 0),k([Ut({handle:"routingKey",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.routingKey.label",type:"string"}),C("design:type",String)],qs.prototype,"routingKey",void 0),k([Ut({handle:"host",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.host.label",type:"string"}),C("design:type",String)],qs.prototype,"host",void 0),k([Ut({handle:"port",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.port.label",type:"number"}),C("design:type",Number)],qs.prototype,"port",void 0),k([Ut({handle:"username",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.username.label",type:"string"}),C("design:type",String)],qs.prototype,"username",void 0),k([Ut({handle:"vhost",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.vhost.label",type:"string"}),C("design:type",String)],qs.prototype,"vhost",void 0),k([Ut({handle:"ssl",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.ssl.label",type:"boolean"}),C("design:type",Boolean)],qs.prototype,"ssl",void 0),k([Ut({handle:"value",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.storage.rabbitmq.fields.value.label",type:"textarea"}),C("design:type",Object)],qs.prototype,"value",void 0),k([w(),$t({handle:"result",type:"boolean"}),C("design:type",Boolean)],qs.prototype,"result",void 0),k([$t({handle:"target"}),C("design:type",String)],qs.prototype,"target",void 0),qs=k([Mt("core.storage.rabbitmq",{kind:"core.storage.rabbitmq",category:"Storage",color:"#ff6600",icon:"ti-inbox",width:96,height:96,labels:["storage","rabbitmq","amqp","queue","publish"],metadata:{title:"graph.node.storage.rabbitmq.name",description:"graph.node.storage.rabbitmq.description"}}),I()],qs);const Ws=["put","get","delete","list","stat","has","url","copy"];class Ks extends Wi{constructor(){super(...arguments),this.operation="get",this.encoding="utf8",this.urlOperation="get"}async execute(e,t){const o=this.constructor.name,r=Ws.includes(this.operation)?this.operation:"get",n=As(this.key);if("list"!==r&&!n)throw new Cr(`${o} node operation '${r}' requires a key`,"GRAPH_BLOB_KEY_REQUIRED",{operation:r});const i=await an(t,e.credentials,this.credentialType,!1,o),a=await this.createService(i);try{switch(r){case"put":{const t=this.content??e.inputs.value,r=Es(this.metadataValues),i=await a.put(n,((e,t,o)=>{if("string"==typeof e)return"base64"===t?Buffer.from(e,"base64"):Buffer.from(e,"utf8");if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(null==e)return Buffer.alloc(0);try{return Buffer.from(JSON.stringify(e),"utf8")}catch{throw new Cr(o+" node cannot encode the blob payload","GRAPH_BLOB_INVALID_PAYLOAD")}})(t,this.encoding,o),{contentType:As(this.contentType),metadata:r?Object.fromEntries(Object.entries(r).map(([e,t])=>[e,t+""])):void 0});return{result:i}}case"get":{const e=await a.get(n),t=await we(e.value),o="base64"===this.encoding?t.toString("base64"):t.toString("utf8");return{result:{key:e.key,uri:e.uri,provider:e.provider,sourceId:e.sourceId,metadata:e.metadata},value:o,contentLength:t.length,contentType:e.metadata.contentType}}case"delete":return await a.delete(n),{result:{key:n,deleted:!0}};case"list":{const e=Rs(this.limit);return{result:await a.list({prefix:As(this.prefix),limit:void 0===e?void 0:Math.max(0,Math.floor(e)),cursor:As(this.cursor)})}}case"stat":return{result:await a.stat(n)};case"has":return{result:await a.has(n)};case"url":{const e=Rs(this.expiresInSeconds);return{result:await a.url(n,{operation:this.urlOperation,expiresInSeconds:void 0===e?void 0:Math.max(0,Math.floor(e)),contentType:As(this.contentType)})}}case"copy":{const e=As(this.targetKey);if(!e)throw new Cr(o+" node copy operation requires a targetKey","GRAPH_BLOB_TARGET_KEY_REQUIRED");return{result:await a.copy(n,e,{contentType:As(this.contentType)})}}default:throw new Cr(`${o} node operation '${r}' is not supported`,"GRAPH_BLOB_OPERATION_NOT_SUPPORTED",{operation:r})}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`${o} node operation '${r}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_BLOB_OPERATION_FAILED",{operation:r})}finally{await a.shutdown().catch(()=>{})}}}k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Ks.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.key.label",type:"string"}),Ut({handle:"key",userControlled:!0}),C("design:type",String)],Ks.prototype,"key",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.targetKey.label",type:"string"}),Ut({handle:"targetKey",userControlled:!0}),C("design:type",String)],Ks.prototype,"targetKey",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.content.label",type:"textarea"}),Ut({handle:"content",userControlled:!0}),C("design:type",Object)],Ks.prototype,"content",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.contentType.label",type:"string"}),Ut({handle:"contentType",userControlled:!0}),C("design:type",String)],Ks.prototype,"contentType",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.encoding.label",type:"select"}),Ut({handle:"encoding",userControlled:!0}),C("design:type",String)],Ks.prototype,"encoding",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.metadataValues.label",type:"object"}),Ut({handle:"metadataValues",userControlled:!0}),C("design:type",Object)],Ks.prototype,"metadataValues",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.prefix.label",type:"string"}),Ut({handle:"prefix",userControlled:!0}),C("design:type",String)],Ks.prototype,"prefix",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.cursor.label",type:"string"}),Ut({handle:"cursor",userControlled:!0}),C("design:type",String)],Ks.prototype,"cursor",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.limit.label",type:"number"}),Ut({handle:"limit",userControlled:!0}),C("design:type",Number)],Ks.prototype,"limit",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.urlOperation.label",type:"select"}),Ut({handle:"urlOperation",userControlled:!0}),C("design:type",String)],Ks.prototype,"urlOperation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.expiresInSeconds.label",type:"number"}),Ut({handle:"expiresInSeconds",userControlled:!0}),C("design:type",Number)],Ks.prototype,"expiresInSeconds",void 0),k([Ut({handle:"value"}),C("design:type",Object)],Ks.prototype,"value",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],Ks.prototype,"result",void 0),k([$t({handle:"value"}),C("design:type",String)],Ks.prototype,"valueOutput",void 0),k([$t({handle:"contentLength",type:"number"}),C("design:type",Number)],Ks.prototype,"contentLength",void 0),k([$t({handle:"contentType"}),C("design:type",String)],Ks.prototype,"contentTypeOutput",void 0);class Vs extends Ks{constructor(){super(...arguments),this.credentialType="s3",this.forcePathStyle=!1}async createService(e){const t=As(this.bucket);if(!t)throw new Cr("S3 node requires a bucket","GRAPH_BLOB_BUCKET_REQUIRED");const o=new ve;return await xe(o,((e,t)=>{const o=e?ks(e,"S3"):void 0;return{provider:"s3",bucket:t.bucket,sourceId:t.sourceId,region:t.region,endpoint:t.endpoint,prefix:t.prefix,forcePathStyle:t.forcePathStyle,credentials:o&&"string"==typeof o.accessKeyId?{accessKeyId:o.accessKeyId,secretAccessKey:(o.secretAccessKey??"")+"",sessionToken:As(o.sessionToken)}:void 0}})(e,{bucket:t,sourceId:As(this.sourceId)??"graph",region:As(this.region),endpoint:As(this.endpoint),prefix:As(this.prefix),forcePathStyle:this.forcePathStyle})),o}}k([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.bucket.label",type:"string"}),Ut({handle:"bucket",userControlled:!0}),C("design:type",String)],Vs.prototype,"bucket",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sourceId.label",type:"string"}),Ut({handle:"sourceId",userControlled:!0}),C("design:type",String)],Vs.prototype,"sourceId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.region.label",type:"string"}),Ut({handle:"region",userControlled:!0}),C("design:type",String)],Vs.prototype,"region",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.endpoint.label",type:"string"}),Ut({handle:"endpoint",userControlled:!0}),C("design:type",String)],Vs.prototype,"endpoint",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.forcePathStyle.label",type:"boolean"}),Ut({handle:"forcePathStyle",userControlled:!0}),C("design:type",Boolean)],Vs.prototype,"forcePathStyle",void 0);let zs=class extends Vs{};zs=k([Mt("core.storage.s3",{kind:"core.storage.s3",category:"Storage",color:"#e25444",icon:"ti-bucket",width:96,height:96,labels:["storage","s3","blob","aws"],metadata:{title:"graph.node.storage.s3.name",description:"graph.node.storage.s3.description"}}),I()],zs);let Qs=class extends Vs{};Qs=k([Mt("core.storage.awsS3",{kind:"core.storage.awsS3",category:"Storage",color:"#ff9900",icon:"ti-brand-aws",width:96,height:96,labels:["storage","s3","blob","aws"],metadata:{title:"graph.node.storage.aws_s3.name",description:"graph.node.storage.aws_s3.description"}}),I()],Qs);let Js=class extends Ks{constructor(){super(...arguments),this.credentialType="gcs"}async createService(e){const t=As(this.bucket);if(!t)throw new Cr("Google Cloud Storage node requires a bucket","GRAPH_BLOB_BUCKET_REQUIRED");const o={provider:"gcs",bucket:t,sourceId:As(this.sourceId)??"graph",projectId:As(this.projectId),apiEndpoint:As(this.apiEndpoint),prefix:As(this.prefix),credentials:e?ks(e,"Google Cloud Storage"):void 0},r=new Ie;return await xe(r,o),r}};function Xs(e){if(!e)return;if("string"!=typeof e)return As(e.connectionString);const t=e.trim();return t.startsWith("{")?As(ks(t,"Azure Storage").connectionString):t}k([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.bucket.label",type:"string"}),Ut({handle:"bucket",userControlled:!0}),C("design:type",String)],Js.prototype,"bucket",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sourceId.label",type:"string"}),Ut({handle:"sourceId",userControlled:!0}),C("design:type",String)],Js.prototype,"sourceId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.projectId.label",type:"string"}),Ut({handle:"projectId",userControlled:!0}),C("design:type",String)],Js.prototype,"projectId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.apiEndpoint.label",type:"string"}),Ut({handle:"apiEndpoint",userControlled:!0}),C("design:type",String)],Js.prototype,"apiEndpoint",void 0),Js=k([Mt("core.storage.googleCloudStorage",{kind:"core.storage.googleCloudStorage",category:"Storage",color:"#4285f4",icon:"ti-brand-google-cloud",width:96,height:96,labels:["storage","gcs","blob","google"],metadata:{title:"graph.node.storage.google_cloud_storage.name",description:"graph.node.storage.google_cloud_storage.description"}}),I()],Js);let Ys=class extends Ks{constructor(){super(...arguments),this.credentialType="azure-blob"}async createService(e){const t=As(this.container);if(!t)throw new Cr("Azure Storage node requires a container","GRAPH_BLOB_CONTAINER_REQUIRED");const o={provider:"azure-blob",container:t,sourceId:As(this.sourceId)??"graph",accountName:As(this.accountName),endpoint:As(this.endpoint),prefix:As(this.prefix),connectionString:Xs(e)},r=new _e;return await xe(r,o),r}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.container.label",type:"string"}),Ut({handle:"container",userControlled:!0}),C("design:type",String)],Ys.prototype,"container",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.sourceId.label",type:"string"}),Ut({handle:"sourceId",userControlled:!0}),C("design:type",String)],Ys.prototype,"sourceId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.accountName.label",type:"string"}),Ut({handle:"accountName",userControlled:!0}),C("design:type",String)],Ys.prototype,"accountName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.storage.common.fields.endpoint.label",type:"string"}),Ut({handle:"endpoint",userControlled:!0}),C("design:type",String)],Ys.prototype,"endpoint",void 0),Ys=k([Mt("core.storage.azureStorage",{kind:"core.storage.azureStorage",category:"Storage",color:"#0078d4",icon:"ti-brand-azure",width:96,height:96,labels:["storage","azure","blob"],metadata:{title:"graph.node.storage.azure_storage.name",description:"graph.node.storage.azure_storage.description"}}),I()],Ys);const Zs=["postMessage","listConversations","getConversation","getUser"];let ed=class extends Wi{constructor(){super(...arguments),this.operation="postMessage"}async execute(e,t){const o=Zs.includes(this.operation)?this.operation:"postMessage";if(!this.operation)throw new Cr("Slack node requires an operation","GRAPH_SLACK_OPERATION_REQUIRED");const r=Ts(await an(t,e.credentials,"slack",!1,"Slack"),"Slack"),n=new Ee;try{switch(await xe(n,{token:r,baseUrl:this.baseUrl}),o){case"postMessage":{const t=this.channel,o=this.text??(e.inputs.value??"")+"";if(!t||!o)throw new Cr("Slack postMessage requires a channel and text","GRAPH_SLACK_MESSAGE_REQUIRED");const r=await n.postMessage({channel:t,text:o,blocks:Os(this.blocks),threadTs:this.threadTs,replyBroadcast:this.replyBroadcast,unfurlLinks:this.unfurlLinks,unfurlMedia:this.unfurlMedia});return{result:r,channel:r.channel,ts:r.ts}}case"listConversations":return{result:await n.listConversations({limit:Rs(this.limit),cursor:this.cursor,types:this.types,excludeArchived:this.excludeArchived})};case"getConversation":{if(!this.channel)throw new Cr("Slack getConversation requires a channel","GRAPH_SLACK_CHANNEL_REQUIRED");const e=await n.getConversation(this.channel);return{result:e,channel:e.id}}default:if(!this.userId)throw new Cr("Slack getUser requires a user ID","GRAPH_SLACK_USER_REQUIRED");return{result:await n.getUser(this.userId)}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Slack node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_SLACK_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],ed.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.channel.label",type:"string"}),Ut({handle:"channel",userControlled:!0}),C("design:type",String)],ed.prototype,"channel",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.text.label",type:"textarea"}),Ut({handle:"text",userControlled:!0}),C("design:type",String)],ed.prototype,"text",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.blocks.label",type:"json"}),Ut({handle:"blocks",userControlled:!0}),C("design:type",Array)],ed.prototype,"blocks",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.threadTs.label",type:"string"}),Ut({handle:"threadTs",userControlled:!0}),C("design:type",String)],ed.prototype,"threadTs",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.limit.label",type:"number"}),Ut({handle:"limit",userControlled:!0}),C("design:type",Number)],ed.prototype,"limit",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.cursor.label",type:"string"}),Ut({handle:"cursor",userControlled:!0}),C("design:type",String)],ed.prototype,"cursor",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.types.label",type:"string"}),Ut({handle:"types",userControlled:!0}),C("design:type",String)],ed.prototype,"types",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.userId.label",type:"string"}),Ut({handle:"userId",userControlled:!0}),C("design:type",String)],ed.prototype,"userId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],ed.prototype,"baseUrl",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.excludeArchived.label",type:"boolean"}),Ut({handle:"excludeArchived",userControlled:!0}),C("design:type",Boolean)],ed.prototype,"excludeArchived",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.replyBroadcast.label",type:"boolean"}),Ut({handle:"replyBroadcast",userControlled:!0}),C("design:type",Boolean)],ed.prototype,"replyBroadcast",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.unfurlLinks.label",type:"boolean"}),Ut({handle:"unfurlLinks",userControlled:!0}),C("design:type",Boolean)],ed.prototype,"unfurlLinks",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.slack.fields.unfurlMedia.label",type:"boolean"}),Ut({handle:"unfurlMedia",userControlled:!0}),C("design:type",Boolean)],ed.prototype,"unfurlMedia",void 0),k([$t({handle:"result"}),C("design:type",Object)],ed.prototype,"result",void 0),k([$t({handle:"channel",type:"string"}),C("design:type",String)],ed.prototype,"resultChannel",void 0),k([$t({handle:"ts",type:"string"}),C("design:type",String)],ed.prototype,"resultTs",void 0),ed=k([Mt("core.comms.slack",{kind:"core.comms.slack",category:"Comms",color:"#4a154b",icon:"ti-brand-slack",width:96,height:96,labels:["comms","slack","messaging","chat"],metadata:{title:"graph.node.comms.slack.name",description:"graph.node.comms.slack.description"}}),I()],ed);const td=["sendMessage","getMe","getUpdates","sendChatAction"];let od=class extends Wi{constructor(){super(...arguments),this.operation="sendMessage"}async execute(e,t){if(!this.operation)throw new Cr("Telegram node requires an operation","GRAPH_TELEGRAM_OPERATION_REQUIRED");const o=td.includes(this.operation)?this.operation:"sendMessage",r=Ts(await an(t,e.credentials,"telegram",!1,"Telegram"),"Telegram"),n=new Ae;try{switch(await xe(n,{token:r,baseUrl:this.baseUrl}),o){case"sendMessage":{const t=this.chatId,o=this.text??(e.inputs.value??"")+"";if(null==t||!o)throw new Cr("Telegram sendMessage requires a chat ID and text","GRAPH_TELEGRAM_MESSAGE_REQUIRED");const r=await n.sendMessage({chatId:t,text:o,parseMode:this.parseMode,disableNotification:this.disableNotification,disablePreview:this.disablePreview,replyToMessageId:Rs(this.replyToMessageId),messageThreadId:Rs(this.messageThreadId)});return{result:r,messageId:Rs(r?.message_id)}}case"getMe":return{result:await n.getMe()};case"getUpdates":return{result:await n.getUpdates({offset:Rs(this.offset),limit:Rs(this.limit),timeoutSeconds:Rs(this.timeoutSeconds)})};default:if(void 0===this.chatId||null===this.chatId)throw new Cr("Telegram sendChatAction requires a chat ID","GRAPH_TELEGRAM_CHAT_REQUIRED");return{result:await n.sendChatAction(this.chatId,this.action??"typing")}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Telegram node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_TELEGRAM_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],od.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.chatId.label",type:"string"}),Ut({handle:"chatId",userControlled:!0}),C("design:type",Object)],od.prototype,"chatId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.text.label",type:"textarea"}),Ut({handle:"text",userControlled:!0}),C("design:type",String)],od.prototype,"text",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.parseMode.label",type:"select"}),Ut({handle:"parseMode",userControlled:!0}),C("design:type",String)],od.prototype,"parseMode",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.disableNotification.label",type:"boolean"}),Ut({handle:"disableNotification",userControlled:!0}),C("design:type",Boolean)],od.prototype,"disableNotification",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.disablePreview.label",type:"boolean"}),Ut({handle:"disablePreview",userControlled:!0}),C("design:type",Boolean)],od.prototype,"disablePreview",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.replyToMessageId.label",type:"number"}),Ut({handle:"replyToMessageId",userControlled:!0}),C("design:type",Number)],od.prototype,"replyToMessageId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.messageThreadId.label",type:"number"}),Ut({handle:"messageThreadId",userControlled:!0}),C("design:type",Number)],od.prototype,"messageThreadId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.offset.label",type:"number"}),Ut({handle:"offset",userControlled:!0}),C("design:type",Number)],od.prototype,"offset",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.limit.label",type:"number"}),Ut({handle:"limit",userControlled:!0}),C("design:type",Number)],od.prototype,"limit",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.timeoutSeconds.label",type:"number"}),Ut({handle:"timeoutSeconds",userControlled:!0}),C("design:type",Number)],od.prototype,"timeoutSeconds",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.action.label",type:"string"}),Ut({handle:"action",userControlled:!0}),C("design:type",String)],od.prototype,"action",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.telegram.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],od.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],od.prototype,"result",void 0),k([$t({handle:"messageId",type:"number"}),C("design:type",Number)],od.prototype,"messageId",void 0),od=k([Mt("core.comms.telegram",{kind:"core.comms.telegram",category:"Comms",color:"#229ed9",icon:"ti-brand-telegram",width:96,height:96,labels:["comms","telegram","messaging","bot"],metadata:{title:"graph.node.comms.telegram.name",description:"graph.node.comms.telegram.description"}}),I()],od);const rd=["sendWebhook","sendChannelMessage","listTeams","listChannels"];let nd=class extends Wi{constructor(){super(...arguments),this.operation="sendWebhook"}async execute(e,t){if(!this.operation)throw new Cr("Microsoft Teams node requires an operation","GRAPH_TEAMS_OPERATION_REQUIRED");const o=rd.includes(this.operation)?this.operation:"sendWebhook",r=await an(t,e.credentials,"teams",!1,"Microsoft Teams"),n=new Se;try{switch(await xe(n,{token:Ns(r,"token","Microsoft Teams"),webhookUrl:Ns(r,"webhookUrl","Microsoft Teams"),baseUrl:this.baseUrl}),o){case"sendWebhook":{const t=this.text??(e.inputs.value??"")+"";if(!t)throw new Cr("Microsoft Teams sendWebhook requires text","GRAPH_TEAMS_TEXT_REQUIRED");return{result:await n.sendWebhook({text:t,title:this.title,markdown:this.markdown})}}case"sendChannelMessage":if(!this.teamId||!this.channelId||!this.content)throw new Cr("Microsoft Teams sendChannelMessage requires teamId, channelId, and content","GRAPH_TEAMS_CHANNEL_MESSAGE_REQUIRED");return{result:await n.sendChannelMessage({teamId:this.teamId,channelId:this.channelId,content:this.content,contentType:this.contentType})};case"listTeams":return{result:await n.listTeams(Rs(this.limit))};default:if(!this.teamId)throw new Cr("Microsoft Teams listChannels requires a teamId","GRAPH_TEAMS_TEAM_REQUIRED");return{result:await n.listChannels(this.teamId)}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Microsoft Teams node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_TEAMS_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],nd.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.text.label",type:"textarea"}),Ut({handle:"text",userControlled:!0}),C("design:type",String)],nd.prototype,"text",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.title.label",type:"string"}),Ut({handle:"title",userControlled:!0}),C("design:type",String)],nd.prototype,"title",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.markdown.label",type:"boolean"}),Ut({handle:"markdown",userControlled:!0}),C("design:type",Boolean)],nd.prototype,"markdown",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.teamId.label",type:"string"}),Ut({handle:"teamId",userControlled:!0}),C("design:type",String)],nd.prototype,"teamId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.channelId.label",type:"string"}),Ut({handle:"channelId",userControlled:!0}),C("design:type",String)],nd.prototype,"channelId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.content.label",type:"textarea"}),Ut({handle:"content",userControlled:!0}),C("design:type",String)],nd.prototype,"content",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.contentType.label",type:"select"}),Ut({handle:"contentType",userControlled:!0}),C("design:type",String)],nd.prototype,"contentType",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.limit.label",type:"number"}),Ut({handle:"limit",userControlled:!0}),C("design:type",Number)],nd.prototype,"limit",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.teams.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],nd.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],nd.prototype,"result",void 0),nd=k([Mt("core.comms.teams",{kind:"core.comms.teams",category:"Comms",color:"#6264a7",icon:"ti-brand-teams",width:96,height:96,labels:["comms","teams","microsoft","messaging"],metadata:{title:"graph.node.comms.teams.name",description:"graph.node.comms.teams.description"}}),I()],nd);const id=["send","list","get","labels"];let ad=class extends Wi{constructor(){super(...arguments),this.operation="send"}async execute(e,t){if(!this.operation)throw new Cr("Gmail node requires an operation","GRAPH_GMAIL_OPERATION_REQUIRED");const o=id.includes(this.operation)?this.operation:"send",r=await an(t,e.credentials,"gmail",!1,"Gmail"),n=new Re;try{switch(await xe(n,{token:Ts(r,"Gmail"),userId:this.userId??Ns(r,"userId","Gmail"),baseUrl:this.baseUrl}),o){case"send":{const t=this.from??Ns(r,"from","Gmail");if(!t||!this.to||!this.subject)throw new Cr("Gmail send requires from, to, and subject","GRAPH_GMAIL_MESSAGE_REQUIRED");const o=await n.send({from:t,to:this.to,cc:this.cc,bcc:this.bcc,subject:this.subject,text:this.text??(e.inputs.value??"")+"",html:this.html,replyTo:this.replyTo});return{result:o,id:o.id}}case"list":return{result:await n.listMessages({query:this.query,maxResults:Rs(this.maxResults),pageToken:this.pageToken,labelIds:Os(this.labelIds)?.map(String)})};case"get":if(!this.messageId)throw new Cr("Gmail get requires a message ID","GRAPH_GMAIL_MESSAGE_ID_REQUIRED");return{result:await n.getMessage(this.messageId,this.format??"full")};default:return{result:await n.listLabels()}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Gmail node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GMAIL_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],ad.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.userId.label",type:"string"}),Ut({handle:"userId",userControlled:!0}),C("design:type",String)],ad.prototype,"userId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.from.label",type:"string"}),Ut({handle:"from",userControlled:!0}),C("design:type",String)],ad.prototype,"from",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.to.label",type:"string"}),Ut({handle:"to",userControlled:!0}),C("design:type",Object)],ad.prototype,"to",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.cc.label",type:"string"}),Ut({handle:"cc",userControlled:!0}),C("design:type",Object)],ad.prototype,"cc",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.bcc.label",type:"string"}),Ut({handle:"bcc",userControlled:!0}),C("design:type",Object)],ad.prototype,"bcc",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.subject.label",type:"string"}),Ut({handle:"subject",userControlled:!0}),C("design:type",String)],ad.prototype,"subject",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.text.label",type:"textarea"}),Ut({handle:"text",userControlled:!0}),C("design:type",String)],ad.prototype,"text",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.html.label",type:"textarea"}),Ut({handle:"html",userControlled:!0}),C("design:type",String)],ad.prototype,"html",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.replyTo.label",type:"string"}),Ut({handle:"replyTo",userControlled:!0}),C("design:type",String)],ad.prototype,"replyTo",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.query.label",type:"string"}),Ut({handle:"query",userControlled:!0}),C("design:type",String)],ad.prototype,"query",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.maxResults.label",type:"number"}),Ut({handle:"maxResults",userControlled:!0}),C("design:type",Number)],ad.prototype,"maxResults",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.pageToken.label",type:"string"}),Ut({handle:"pageToken",userControlled:!0}),C("design:type",String)],ad.prototype,"pageToken",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.labelIds.label",type:"json"}),Ut({handle:"labelIds",userControlled:!0}),C("design:type",Array)],ad.prototype,"labelIds",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.messageId.label",type:"string"}),Ut({handle:"messageId",userControlled:!0}),C("design:type",String)],ad.prototype,"messageId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.format.label",type:"select"}),Ut({handle:"format",userControlled:!0}),C("design:type",String)],ad.prototype,"format",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.gmail.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],ad.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],ad.prototype,"result",void 0),k([$t({handle:"id",type:"string"}),C("design:type",String)],ad.prototype,"id",void 0),ad=k([Mt("core.comms.gmail",{kind:"core.comms.gmail",category:"Comms",color:"#ea4335",icon:"ti-brand-google",width:96,height:96,labels:["comms","gmail","email","google"],metadata:{title:"graph.node.comms.gmail.name",description:"graph.node.comms.gmail.description"}}),I()],ad);const sd=["send","listInbox","listImap"];let dd=class extends Wi{constructor(){super(...arguments),this.operation="send"}async execute(e,t){if(!this.operation)throw new Cr("Email Send node requires an operation","GRAPH_EMAIL_OPERATION_REQUIRED");const o=sd.includes(this.operation)?this.operation:"send",r=await an(t,e.credentials,"email",!1,"Email"),n=Cs(r,"Email"),i=r&&!n?r:void 0,a=new Oe;try{switch(await xe(a,{provider:this.provider??n?.provider,host:this.host??this.asCredentialString(n,"host"),port:Rs(this.port)??Rs(n?.port),secure:this.secure??Ss(n?.secure,!1),username:this.username??this.asCredentialString(n,"username"),password:this.asCredentialString(n,"password"),from:this.from??this.asCredentialString(n,"from"),token:i??this.asCredentialString(n,"token"),graphBaseUrl:this.graphBaseUrl??this.asCredentialString(n,"graphBaseUrl"),baseUrl:this.baseUrl}),o){case"send":{if(!this.to||!this.subject)throw new Cr("Email Send send requires to and subject","GRAPH_EMAIL_MESSAGE_REQUIRED");const t=await a.send({from:this.from??this.asCredentialString(n,"from")??"",to:this.to,cc:this.cc,bcc:this.bcc,subject:this.subject,text:this.text??(e.inputs.value??"")+"",html:this.html,replyTo:this.replyTo});return{result:t,messageId:t.messageId}}case"listInbox":return{result:await a.listInbox({mailbox:this.mailbox,limit:Rs(this.limit),since:this.since,subject:this.subjectFilter})};default:return{result:await a.listImapMessages({mailbox:this.mailbox,limit:Rs(this.limit),since:this.since,subject:this.subjectFilter})}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Email node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_EMAIL_OPERATION_FAILED",{operation:o})}finally{await a.shutdown().catch(()=>{})}}asCredentialString(e,t){const o=e?.[t];return"string"==typeof o&&o.trim().length>0?o.trim():void 0}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],dd.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.provider.label",type:"select"}),Ut({handle:"provider",userControlled:!0}),C("design:type",String)],dd.prototype,"provider",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.host.label",type:"string"}),Ut({handle:"host",userControlled:!0}),C("design:type",String)],dd.prototype,"host",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.port.label",type:"number"}),Ut({handle:"port",userControlled:!0}),C("design:type",Number)],dd.prototype,"port",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.secure.label",type:"boolean"}),Ut({handle:"secure",userControlled:!0}),C("design:type",Boolean)],dd.prototype,"secure",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.username.label",type:"string"}),Ut({handle:"username",userControlled:!0}),C("design:type",String)],dd.prototype,"username",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.from.label",type:"string"}),Ut({handle:"from",userControlled:!0}),C("design:type",String)],dd.prototype,"from",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.to.label",type:"string"}),Ut({handle:"to",userControlled:!0}),C("design:type",Object)],dd.prototype,"to",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.cc.label",type:"string"}),Ut({handle:"cc",userControlled:!0}),C("design:type",Object)],dd.prototype,"cc",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.bcc.label",type:"string"}),Ut({handle:"bcc",userControlled:!0}),C("design:type",Object)],dd.prototype,"bcc",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.subject.label",type:"string"}),Ut({handle:"subject",userControlled:!0}),C("design:type",String)],dd.prototype,"subject",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.text.label",type:"textarea"}),Ut({handle:"text",userControlled:!0}),C("design:type",String)],dd.prototype,"text",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.html.label",type:"textarea"}),Ut({handle:"html",userControlled:!0}),C("design:type",String)],dd.prototype,"html",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.common.fields.replyTo.label",type:"string"}),Ut({handle:"replyTo",userControlled:!0}),C("design:type",String)],dd.prototype,"replyTo",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.mailbox.label",type:"string"}),Ut({handle:"mailbox",userControlled:!0}),C("design:type",String)],dd.prototype,"mailbox",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.limit.label",type:"number"}),Ut({handle:"limit",userControlled:!0}),C("design:type",Number)],dd.prototype,"limit",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.since.label",type:"string"}),Ut({handle:"since",userControlled:!0}),C("design:type",String)],dd.prototype,"since",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.subjectFilter.label",type:"string"}),Ut({handle:"subjectFilter",userControlled:!0}),C("design:type",String)],dd.prototype,"subjectFilter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.graphBaseUrl.label",type:"string"}),Ut({handle:"graphBaseUrl",userControlled:!0}),C("design:type",String)],dd.prototype,"graphBaseUrl",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.email_send.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],dd.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],dd.prototype,"result",void 0),k([$t({handle:"messageId",type:"string"}),C("design:type",String)],dd.prototype,"messageId",void 0),dd=k([Mt("core.comms.emailSend",{kind:"core.comms.emailSend",category:"Comms",color:"#0f766e",icon:"ti-mail",width:96,height:96,labels:["comms","email","smtp","imap"],metadata:{title:"graph.node.comms.email_send.name",description:"graph.node.comms.email_send.description"}}),I()],dd);const ld=["sendMessage","getMessage","listMessages","getChannel","listChannels","createChannel","deleteChannel","addReaction"];function cd(e){if(null==e||""===e)return;if(Array.isArray(e))return e;if("string"==typeof e)try{const t=JSON.parse(e);return Array.isArray(t)?t:[t]}catch{throw new Cr("Discord embeds must be a JSON array","GRAPH_DISCORD_EMBEDS_INVALID")}const t=Es(e);return t?[t]:void 0}let pd=class extends Wi{constructor(){super(...arguments),this.operation="sendMessage"}async execute(e,t){if(!this.operation)throw new Cr("Discord node requires an operation","GRAPH_DISCORD_OPERATION_REQUIRED");const o=ld.includes(this.operation)?this.operation:"sendMessage",r=await an(t,e.credentials,"discord",!1,"Discord"),n=new ke;try{switch(await xe(n,{token:Ts(r,"Discord"),baseUrl:this.baseUrl}),o){case"sendMessage":{if(!this.channelId)throw new Cr("Discord sendMessage requires a channelId","GRAPH_DISCORD_CHANNEL_REQUIRED");const t=this.content??(e.inputs.value??"")+"";if(!t)throw new Cr("Discord sendMessage requires content","GRAPH_DISCORD_CONTENT_REQUIRED");const o=await n.sendMessage({channelId:this.channelId,content:t,tts:this.tts,embeds:cd(this.embeds)}),r=Es(o);return{result:o,channelId:this.channelId,..."string"==typeof r?.id?{messageId:r.id}:{}}}case"getMessage":if(!this.channelId||!this.messageId)throw new Cr("Discord getMessage requires channelId and messageId","GRAPH_DISCORD_MESSAGE_REQUIRED");return{result:await n.getMessage(this.channelId,this.messageId),channelId:this.channelId,messageId:this.messageId};case"listMessages":if(!this.channelId)throw new Cr("Discord listMessages requires a channelId","GRAPH_DISCORD_CHANNEL_REQUIRED");return{result:await n.listMessages({channelId:this.channelId,limit:Rs(this.limit),before:this.before}),channelId:this.channelId};case"getChannel":if(!this.channelId)throw new Cr("Discord getChannel requires a channelId","GRAPH_DISCORD_CHANNEL_REQUIRED");return{result:await n.getChannel(this.channelId),channelId:this.channelId};case"listChannels":if(!this.guildId)throw new Cr("Discord listChannels requires a guildId","GRAPH_DISCORD_GUILD_REQUIRED");return{result:await n.listChannels(this.guildId)};case"createChannel":{if(!this.guildId||!this.name)throw new Cr("Discord createChannel requires guildId and name","GRAPH_DISCORD_CHANNEL_CREATE_REQUIRED");const e=await n.createChannel({guildId:this.guildId,name:this.name,type:Rs(this.channelType),topic:this.topic,parentId:this.parentId}),t=Es(e);return{result:e,..."string"==typeof t?.id?{channelId:t.id}:{}}}case"deleteChannel":if(!this.channelId)throw new Cr("Discord deleteChannel requires a channelId","GRAPH_DISCORD_CHANNEL_REQUIRED");return{result:await n.deleteChannel(this.channelId),channelId:this.channelId};default:if(!this.channelId||!this.messageId||!this.emoji)throw new Cr("Discord addReaction requires channelId, messageId, and emoji","GRAPH_DISCORD_REACTION_REQUIRED");return{result:await n.addReaction({channelId:this.channelId,messageId:this.messageId,emoji:this.emoji}),channelId:this.channelId,messageId:this.messageId}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Discord node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_DISCORD_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],pd.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.channelId.label",type:"string"}),Ut({handle:"channelId",userControlled:!0}),C("design:type",String)],pd.prototype,"channelId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.guildId.label",type:"string"}),Ut({handle:"guildId",userControlled:!0}),C("design:type",String)],pd.prototype,"guildId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.messageId.label",type:"string"}),Ut({handle:"messageId",userControlled:!0}),C("design:type",String)],pd.prototype,"messageId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.content.label",type:"textarea"}),Ut({handle:"content",userControlled:!0}),C("design:type",String)],pd.prototype,"content",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.embeds.label",type:"textarea"}),Ut({handle:"embeds",userControlled:!0}),C("design:type",Object)],pd.prototype,"embeds",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.tts.label",type:"boolean"}),Ut({handle:"tts",userControlled:!0}),C("design:type",Boolean)],pd.prototype,"tts",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.name.label",type:"string"}),Ut({handle:"name",userControlled:!0}),C("design:type",String)],pd.prototype,"name",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.channelType.label",type:"number"}),Ut({handle:"channelType",userControlled:!0}),C("design:type",Number)],pd.prototype,"channelType",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.topic.label",type:"string"}),Ut({handle:"topic",userControlled:!0}),C("design:type",String)],pd.prototype,"topic",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.parentId.label",type:"string"}),Ut({handle:"parentId",userControlled:!0}),C("design:type",String)],pd.prototype,"parentId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.emoji.label",type:"string"}),Ut({handle:"emoji",userControlled:!0}),C("design:type",String)],pd.prototype,"emoji",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.limit.label",type:"number"}),Ut({handle:"limit",userControlled:!0}),C("design:type",Number)],pd.prototype,"limit",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.before.label",type:"string"}),Ut({handle:"before",userControlled:!0}),C("design:type",String)],pd.prototype,"before",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.discord.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],pd.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],pd.prototype,"result",void 0),k([$t({handle:"channelId",type:"string"}),C("design:type",String)],pd.prototype,"resultChannelId",void 0),k([$t({handle:"messageId",type:"string"}),C("design:type",String)],pd.prototype,"resultMessageId",void 0),pd=k([Mt("core.comms.discord",{kind:"core.comms.discord",category:"Comms",color:"#5865f2",icon:"ti-brand-discord",width:96,height:96,labels:["comms","discord","messaging","chat"],metadata:{title:"graph.node.comms.discord.name",description:"graph.node.comms.discord.description"}}),I()],pd);const ud=["sendText","sendTemplate","sendMedia","markAsRead","getMedia"];function gd(e){if(null==e||""===e)return;if(Array.isArray(e))return e;if("string"==typeof e)try{const t=JSON.parse(e);return Array.isArray(t)?t:[t]}catch{throw new Cr("WhatsApp template components must be a JSON array","GRAPH_WHATSAPP_COMPONENTS_INVALID")}const t=Es(e);return t?[t]:void 0}let hd=class extends Wi{constructor(){super(...arguments),this.operation="sendText"}async execute(e,t){if(!this.operation)throw new Cr("WhatsApp node requires an operation","GRAPH_WHATSAPP_OPERATION_REQUIRED");const o=ud.includes(this.operation)?this.operation:"sendText",r=await an(t,e.credentials,"whatsapp",!1,"WhatsApp"),n=new Ce;try{switch(await xe(n,{token:Ts(r,"WhatsApp"),phoneNumberId:this.phoneNumberId??Ns(r,"phoneNumberId","WhatsApp"),baseUrl:this.baseUrl}),o){case"sendText":{const t=this.text??(e.inputs.value??"")+"";if(!this.to||!t)throw new Cr("WhatsApp sendText requires to and text","GRAPH_WHATSAPP_TEXT_REQUIRED");const o=await n.sendText({to:this.to,text:t,previewUrl:this.previewUrl});return{result:o,...this.messageIdOf(o)}}case"sendTemplate":{if(!this.to||!this.templateName||!this.languageCode)throw new Cr("WhatsApp sendTemplate requires to, templateName, and languageCode","GRAPH_WHATSAPP_TEMPLATE_REQUIRED");const e=await n.sendTemplate({to:this.to,templateName:this.templateName,languageCode:this.languageCode,components:gd(this.components)});return{result:e,...this.messageIdOf(e)}}case"sendMedia":{if(!this.to||!this.mediaId&&!this.mediaUrl)throw new Cr("WhatsApp sendMedia requires to and a mediaId or mediaUrl","GRAPH_WHATSAPP_MEDIA_REQUIRED");const e=await n.sendMedia({to:this.to,type:this.mediaType??"image",mediaId:this.mediaId,link:this.mediaUrl,caption:this.caption,filename:this.filename});return{result:e,...this.messageIdOf(e)}}case"markAsRead":if(!this.messageId)throw new Cr("WhatsApp markAsRead requires a messageId","GRAPH_WHATSAPP_MESSAGE_REQUIRED");return{result:await n.markAsRead({messageId:this.messageId}),messageId:this.messageId};default:if(!this.mediaId)throw new Cr("WhatsApp getMedia requires a mediaId","GRAPH_WHATSAPP_MEDIA_REQUIRED");return{result:await n.getMedia(this.mediaId)}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`WhatsApp node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_WHATSAPP_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}messageIdOf(e){const t=Es(e),o=t?.messages;if(Array.isArray(o)){const e=Es(o[0]);if("string"==typeof e?.id)return{messageId:e.id}}return{}}};k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],hd.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.phoneNumberId.label",type:"string"}),Ut({handle:"phoneNumberId",userControlled:!0}),C("design:type",String)],hd.prototype,"phoneNumberId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.to.label",type:"string"}),Ut({handle:"to",userControlled:!0}),C("design:type",String)],hd.prototype,"to",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.text.label",type:"textarea"}),Ut({handle:"text",userControlled:!0}),C("design:type",String)],hd.prototype,"text",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.previewUrl.label",type:"boolean"}),Ut({handle:"previewUrl",userControlled:!0}),C("design:type",Boolean)],hd.prototype,"previewUrl",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.templateName.label",type:"string"}),Ut({handle:"templateName",userControlled:!0}),C("design:type",String)],hd.prototype,"templateName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.languageCode.label",type:"string"}),Ut({handle:"languageCode",userControlled:!0}),C("design:type",String)],hd.prototype,"languageCode",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.components.label",type:"textarea"}),Ut({handle:"components",userControlled:!0}),C("design:type",Object)],hd.prototype,"components",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.mediaType.label",type:"select"}),Ut({handle:"mediaType",userControlled:!0}),C("design:type",String)],hd.prototype,"mediaType",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.mediaId.label",type:"string"}),Ut({handle:"mediaId",userControlled:!0}),C("design:type",String)],hd.prototype,"mediaId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.mediaUrl.label",type:"string"}),Ut({handle:"mediaUrl",userControlled:!0}),C("design:type",String)],hd.prototype,"mediaUrl",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.caption.label",type:"string"}),Ut({handle:"caption",userControlled:!0}),C("design:type",String)],hd.prototype,"caption",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.filename.label",type:"string"}),Ut({handle:"filename",userControlled:!0}),C("design:type",String)],hd.prototype,"filename",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.messageId.label",type:"string"}),Ut({handle:"messageId",userControlled:!0}),C("design:type",String)],hd.prototype,"messageId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.whatsapp.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],hd.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],hd.prototype,"result",void 0),k([$t({handle:"messageId",type:"string"}),C("design:type",String)],hd.prototype,"resultMessageId",void 0),hd=k([Mt("core.comms.whatsApp",{kind:"core.comms.whatsApp",category:"Comms",color:"#25d366",icon:"ti-brand-whatsapp",width:96,height:96,labels:["comms","whatsapp","messaging","meta"],metadata:{title:"graph.node.comms.whatsapp.name",description:"graph.node.comms.whatsapp.description"}}),I()],hd);const fd=["sendMail","listMessages","getMessage","listEvents","createEvent","deleteEvent"];function yd(e){if(null!=e&&""!==e){if(Array.isArray(e))return e.map(e=>(e+"").trim()).filter(e=>e.length>0);if("string"==typeof e){if(e.trim().startsWith("["))try{const t=JSON.parse(e);return Array.isArray(t)?t.map(e=>(e+"").trim()):void 0}catch{throw new Cr("Microsoft Outlook attendees must be a JSON array or a comma-separated list","GRAPH_OUTLOOK_ATTENDEES_INVALID")}return e.split(/[,;]/).map(e=>e.trim()).filter(e=>e.length>0)}}}let md=class extends Wi{constructor(){super(...arguments),this.operation="sendMail"}async execute(e,t){if(!this.operation)throw new Cr("Microsoft Outlook node requires an operation","GRAPH_OUTLOOK_OPERATION_REQUIRED");const o=fd.includes(this.operation)?this.operation:"sendMail",r=await an(t,e.credentials,"microsoft-outlook",!1,"Microsoft Outlook"),n=new Ne;try{switch(await xe(n,{token:Ts(r,"Microsoft Outlook"),baseUrl:this.baseUrl}),o){case"sendMail":{if(!this.to||!this.subject)throw new Cr("Microsoft Outlook sendMail requires to and subject","GRAPH_OUTLOOK_MAIL_REQUIRED");const t=this.body??(e.inputs.value??"")+"";return{result:await n.sendMail({to:this.to,cc:this.cc,bcc:this.bcc,subject:this.subject,body:t,contentType:this.contentType,saveToSentItems:this.saveToSentItems})}}case"listMessages":return{result:await n.listMessages({folderId:this.folderId,top:Rs(this.top),filter:this.filter,search:this.search})};case"getMessage":if(!this.messageId)throw new Cr("Microsoft Outlook getMessage requires a messageId","GRAPH_OUTLOOK_MESSAGE_REQUIRED");return{result:await n.getMessage(this.messageId),messageId:this.messageId};case"listEvents":return{result:await n.listEvents({top:Rs(this.top),filter:this.filter,search:this.search})};case"createEvent":{if(!this.subject||!this.start||!this.end)throw new Cr("Microsoft Outlook createEvent requires subject, start, and end","GRAPH_OUTLOOK_EVENT_REQUIRED");const e=await n.createEvent({subject:this.subject,start:this.start,end:this.end,timeZone:this.timeZone,body:this.body,location:this.location,attendees:yd(this.attendees)}),t=Es(e);return{result:e,..."string"==typeof t?.id?{eventId:t.id}:{}}}default:if(!this.eventId)throw new Cr("Microsoft Outlook deleteEvent requires an eventId","GRAPH_OUTLOOK_EVENT_REQUIRED");return{result:await n.deleteEvent(this.eventId),eventId:this.eventId}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Microsoft Outlook node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_OUTLOOK_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],md.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.to.label",type:"string"}),Ut({handle:"to",userControlled:!0}),C("design:type",String)],md.prototype,"to",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.cc.label",type:"string"}),Ut({handle:"cc",userControlled:!0}),C("design:type",String)],md.prototype,"cc",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.bcc.label",type:"string"}),Ut({handle:"bcc",userControlled:!0}),C("design:type",String)],md.prototype,"bcc",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.subject.label",type:"string"}),Ut({handle:"subject",userControlled:!0}),C("design:type",String)],md.prototype,"subject",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.body.label",type:"textarea"}),Ut({handle:"body",userControlled:!0}),C("design:type",String)],md.prototype,"body",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.contentType.label",type:"select"}),Ut({handle:"contentType",userControlled:!0}),C("design:type",String)],md.prototype,"contentType",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.saveToSentItems.label",type:"boolean"}),Ut({handle:"saveToSentItems",userControlled:!0}),C("design:type",Boolean)],md.prototype,"saveToSentItems",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.folderId.label",type:"string"}),Ut({handle:"folderId",userControlled:!0}),C("design:type",String)],md.prototype,"folderId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.messageId.label",type:"string"}),Ut({handle:"messageId",userControlled:!0}),C("design:type",String)],md.prototype,"messageId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.eventId.label",type:"string"}),Ut({handle:"eventId",userControlled:!0}),C("design:type",String)],md.prototype,"eventId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.start.label",type:"string"}),Ut({handle:"start",userControlled:!0}),C("design:type",String)],md.prototype,"start",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.end.label",type:"string"}),Ut({handle:"end",userControlled:!0}),C("design:type",String)],md.prototype,"end",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.timeZone.label",type:"string"}),Ut({handle:"timeZone",userControlled:!0}),C("design:type",String)],md.prototype,"timeZone",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.location.label",type:"string"}),Ut({handle:"location",userControlled:!0}),C("design:type",String)],md.prototype,"location",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.attendees.label",type:"textarea"}),Ut({handle:"attendees",userControlled:!0}),C("design:type",Object)],md.prototype,"attendees",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.top.label",type:"number"}),Ut({handle:"top",userControlled:!0}),C("design:type",Number)],md.prototype,"top",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.filter.label",type:"string"}),Ut({handle:"filter",userControlled:!0}),C("design:type",String)],md.prototype,"filter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.search.label",type:"string"}),Ut({handle:"search",userControlled:!0}),C("design:type",String)],md.prototype,"search",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.comms.microsoft_outlook.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],md.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],md.prototype,"result",void 0),k([$t({handle:"messageId",type:"string"}),C("design:type",String)],md.prototype,"resultMessageId",void 0),k([$t({handle:"eventId",type:"string"}),C("design:type",String)],md.prototype,"resultEventId",void 0),md=k([Mt("core.comms.microsoftOutlook",{kind:"core.comms.microsoftOutlook",category:"Comms",color:"#0078d4",icon:"ti-brand-office",width:96,height:96,labels:["comms","outlook","microsoft","email","calendar"],metadata:{title:"graph.node.comms.microsoft_outlook.name",description:"graph.node.comms.microsoft_outlook.description"}}),I()],md);const bd=["get","update","append","clear","create"];let wd=class extends Wi{constructor(){super(...arguments),this.operation="get"}async execute(e,t){if(!this.operation)throw new Cr("Google Sheets node requires an operation","GRAPH_GOOGLE_SHEETS_OPERATION_REQUIRED");const o=bd.includes(this.operation)?this.operation:"get",r=await an(t,e.credentials,"google-sheets",!1,"Google Sheets"),n=new Te;try{switch(await xe(n,{token:Ns(r,"token","Google Sheets"),apiKey:Ns(r,"apiKey","Google Sheets"),baseUrl:this.baseUrl}),o){case"get":{const e=await n.getValues(this.requireSpreadsheet(),this.requireRange());return{result:e,values:e.values,spreadsheetId:e.spreadsheetId,range:e.range}}case"update":case"append":{const e=this.requireValues(),t={spreadsheetId:this.requireSpreadsheet(),range:this.requireRange(),values:e,valueInputOption:this.valueInputOption??"USER_ENTERED"},r="update"===o?await n.updateValues(t):await n.appendValues(t);return{result:r,values:r.values,spreadsheetId:r.spreadsheetId,range:r.range}}case"clear":{const e=await n.clearValues(this.requireSpreadsheet(),this.requireRange());return{result:e,spreadsheetId:e.spreadsheetId,range:e.clearedRange}}default:{if(!this.title)throw new Cr("Google Sheets create requires a title","GRAPH_GOOGLE_SHEETS_TITLE_REQUIRED");const e=await n.createSpreadsheet(this.title);return{result:e,spreadsheetId:e.spreadsheetId}}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Google Sheets node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GOOGLE_SHEETS_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}requireSpreadsheet(){if(!this.spreadsheetId)throw new Cr("Google Sheets node requires a spreadsheet ID","GRAPH_GOOGLE_SHEETS_SPREADSHEET_REQUIRED");return this.spreadsheetId}requireRange(){if(!this.range)throw new Cr("Google Sheets node requires a range","GRAPH_GOOGLE_SHEETS_RANGE_REQUIRED");return this.range}requireValues(){if(!Array.isArray(this.values)||!this.values.every(e=>Array.isArray(e)))throw new Cr("Google Sheets node requires values as an array of rows","GRAPH_GOOGLE_SHEETS_VALUES_REQUIRED");return this.values}};k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],wd.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.spreadsheetId.label",type:"string"}),Ut({handle:"spreadsheetId",userControlled:!0}),C("design:type",String)],wd.prototype,"spreadsheetId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.range.label",type:"string"}),Ut({handle:"range",userControlled:!0}),C("design:type",String)],wd.prototype,"range",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.values.label",type:"json"}),Ut({handle:"values",userControlled:!0}),C("design:type",Array)],wd.prototype,"values",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.valueInputOption.label",type:"select"}),Ut({handle:"valueInputOption",userControlled:!0}),C("design:type",String)],wd.prototype,"valueInputOption",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.title.label",type:"string"}),Ut({handle:"title",userControlled:!0}),C("design:type",String)],wd.prototype,"title",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_sheets.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],wd.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],wd.prototype,"result",void 0),k([$t({handle:"values",type:"array"}),C("design:type",Array)],wd.prototype,"outputValues",void 0),k([$t({handle:"spreadsheetId",type:"string"}),C("design:type",String)],wd.prototype,"outputSpreadsheetId",void 0),k([$t({handle:"range",type:"string"}),C("design:type",String)],wd.prototype,"outputRange",void 0),wd=k([Mt("core.io.googleSheets",{kind:"core.io.googleSheets",category:"IO",color:"#0f9d58",icon:"ti-brand-google",width:96,height:96,labels:["io","google","sheets","spreadsheet"],metadata:{title:"graph.node.io.google_sheets.name",description:"graph.node.io.google_sheets.description"}}),I()],wd);const vd=["list","get","create","update","delete"];let xd=class extends Wi{constructor(){super(...arguments),this.operation="list"}async execute(e,t){if(!this.operation)throw new Cr("Airtable node requires an operation","GRAPH_AIRTABLE_OPERATION_REQUIRED");const o=vd.includes(this.operation)?this.operation:"list",r=await an(t,e.credentials,"airtable",!1,"Airtable"),n=new Pe;try{switch(await xe(n,{token:Ns(r,"token","Airtable"),baseId:this.baseId??Ns(r,"baseId","Airtable"),baseUrl:this.baseUrl}),o){case"list":{const e=await n.listRecords({table:this.requireTable(),view:this.view,filterByFormula:this.filterByFormula,maxRecords:Rs(this.maxRecords),pageSize:Rs(this.pageSize),offset:this.offset,fields:Array.isArray(this.fields)?this.fields.map(String):void 0,sort:this.sortField?[{field:this.sortField,direction:this.sortDirection}]:void 0});return{result:e,records:e.records,offset:e.offset}}case"get":{const e=await n.getRecord(this.requireTable(),this.requireRecordId());return{result:e,records:[e]}}case"create":{const e=await n.createRecord({table:this.requireTable(),fields:this.requireRecordFields(),typecast:this.typecast});return{result:e,records:[e]}}case"update":{const e=await n.updateRecord({table:this.requireTable(),recordId:this.requireRecordId(),fields:this.requireRecordFields(),typecast:this.typecast});return{result:e,records:[e]}}default:return{result:await n.deleteRecord(this.requireTable(),this.requireRecordId())}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Airtable node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_AIRTABLE_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}requireTable(){if(!this.table)throw new Cr("Airtable node requires a table","GRAPH_AIRTABLE_TABLE_REQUIRED");return this.table}requireRecordId(){if(!this.recordId)throw new Cr("Airtable node requires a record ID","GRAPH_AIRTABLE_RECORD_REQUIRED");return this.recordId}requireRecordFields(){const e=Es(this.recordFields);if(!e)throw new Cr("Airtable node requires recordFields as an object","GRAPH_AIRTABLE_FIELDS_REQUIRED");return e}};k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],xd.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.baseId.label",type:"string"}),Ut({handle:"baseId",userControlled:!0}),C("design:type",String)],xd.prototype,"baseId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.table.label",type:"string"}),Ut({handle:"table",userControlled:!0}),C("design:type",String)],xd.prototype,"table",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.recordId.label",type:"string"}),Ut({handle:"recordId",userControlled:!0}),C("design:type",String)],xd.prototype,"recordId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.recordFields.label",type:"json"}),Ut({handle:"recordFields",userControlled:!0}),C("design:type",Object)],xd.prototype,"recordFields",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.typecast.label",type:"boolean"}),Ut({handle:"typecast",userControlled:!0}),C("design:type",Boolean)],xd.prototype,"typecast",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.view.label",type:"string"}),Ut({handle:"view",userControlled:!0}),C("design:type",String)],xd.prototype,"view",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.filterByFormula.label",type:"string"}),Ut({handle:"filterByFormula",userControlled:!0}),C("design:type",String)],xd.prototype,"filterByFormula",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.fields.label",type:"json"}),Ut({handle:"fields",userControlled:!0}),C("design:type",Array)],xd.prototype,"fields",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.sortField.label",type:"string"}),Ut({handle:"sortField",userControlled:!0}),C("design:type",String)],xd.prototype,"sortField",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.sortDirection.label",type:"select"}),Ut({handle:"sortDirection",userControlled:!0}),C("design:type",String)],xd.prototype,"sortDirection",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.maxRecords.label",type:"number"}),Ut({handle:"maxRecords",userControlled:!0}),C("design:type",Number)],xd.prototype,"maxRecords",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.pageSize.label",type:"number"}),Ut({handle:"pageSize",userControlled:!0}),C("design:type",Number)],xd.prototype,"pageSize",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.offset.label",type:"string"}),Ut({handle:"offset",userControlled:!0}),C("design:type",String)],xd.prototype,"offset",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.airtable.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],xd.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],xd.prototype,"result",void 0),k([$t({handle:"records",type:"array"}),C("design:type",Array)],xd.prototype,"records",void 0),k([$t({handle:"offset",type:"string"}),C("design:type",String)],xd.prototype,"nextOffset",void 0),xd=k([Mt("core.io.airtable",{kind:"core.io.airtable",category:"IO",color:"#fcb400",icon:"ti-table",width:96,height:96,labels:["io","airtable","database","records"],metadata:{title:"graph.node.io.airtable.name",description:"graph.node.io.airtable.description"}}),I()],xd);const Id=["parse","write"];let _d=class extends Wi{constructor(){super(...arguments),this.spreadsheets=new De,this.operation="parse"}async execute(e){const t=Id.includes(this.operation)?this.operation:"parse";try{if("parse"===t){const t=this.content??e.inputs.value;if("string"!=typeof t)throw new Cr("Spreadsheet File parse requires text content","GRAPH_SPREADSHEET_CONTENT_REQUIRED");const o=this.spreadsheets.parse(t,{format:this.format,delimiter:this.delimiter,header:this.hasHeader});return{result:o,content:t,rows:o.rows,header:o.header}}const o=Array.isArray(this.rows)?this.rows:Array.isArray(e.inputs.value)?e.inputs.value:void 0;if(!o)throw new Cr("Spreadsheet File write requires rows as an array of arrays","GRAPH_SPREADSHEET_ROWS_REQUIRED");const r=this.spreadsheets.serialize(o,{format:this.format,delimiter:this.delimiter,header:Os(this.header)?.map(String)});return{result:r,content:r}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Spreadsheet File node operation '${t}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_SPREADSHEET_OPERATION_FAILED",{operation:t})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],_d.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.format.label",type:"select"}),Ut({handle:"format",userControlled:!0}),C("design:type",String)],_d.prototype,"format",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.delimiter.label",type:"string"}),Ut({handle:"delimiter",userControlled:!0}),C("design:type",String)],_d.prototype,"delimiter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.content.label",type:"textarea"}),Ut({handle:"content",userControlled:!0}),C("design:type",String)],_d.prototype,"content",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.rows.label",type:"json"}),Ut({handle:"rows",userControlled:!0}),C("design:type",Array)],_d.prototype,"rows",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.header.label",type:"json"}),Ut({handle:"header",userControlled:!0}),C("design:type",Array)],_d.prototype,"header",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.spreadsheet_file.fields.hasHeader.label",type:"boolean"}),Ut({handle:"hasHeader",userControlled:!0}),C("design:type",Boolean)],_d.prototype,"hasHeader",void 0),k([$t({handle:"result"}),C("design:type",Object)],_d.prototype,"result",void 0),k([$t({handle:"content",type:"string"}),C("design:type",String)],_d.prototype,"outputContent",void 0),k([$t({handle:"rows",type:"array"}),C("design:type",Array)],_d.prototype,"outputRows",void 0),k([$t({handle:"header",type:"array"}),C("design:type",Array)],_d.prototype,"outputHeader",void 0),_d=k([Mt("core.io.spreadsheetFile",{kind:"core.io.spreadsheetFile",category:"IO",color:"#217346",icon:"ti-file-spreadsheet",width:96,height:96,labels:["io","spreadsheet","csv","tsv","json"],metadata:{title:"graph.node.io.spreadsheet_file.name",description:"graph.node.io.spreadsheet_file.description"}}),I()],_d);const Ed=["query","mutation"];let Ad=class extends Wi{constructor(){super(...arguments),this.operation="query"}async execute(e,t){if(!this.operation)throw new Cr("GraphQL node requires an operation","GRAPH_GRAPHQL_OPERATION_REQUIRED");const o=Ed.includes(this.operation)?this.operation:"query",r=this.query??(e.inputs.value??"")+"";if(!r)throw new Cr("GraphQL node requires a query document","GRAPH_GRAPHQL_QUERY_REQUIRED");const n=await an(t,e.credentials,"graphql",!1,"GraphQL"),i=new je;try{await xe(i,{endpoint:this.endpoint??Ns(n,"endpoint","GraphQL"),token:Ns(n,"token","GraphQL")});const e=await i.request({query:r,variables:Es(this.variables),operationName:this.operationName});return e.errors&&e.errors.length>0?{result:e.data,errors:e.errors}:{result:e.data}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`GraphQL node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GRAPHQL_OPERATION_FAILED",{operation:o})}finally{await i.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Ad.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.endpoint.label",type:"string"}),Ut({handle:"endpoint",userControlled:!0}),C("design:type",String)],Ad.prototype,"endpoint",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.query.label",type:"textarea"}),Ut({handle:"query",userControlled:!0}),C("design:type",String)],Ad.prototype,"query",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.variables.label",type:"json"}),Ut({handle:"variables",userControlled:!0}),C("design:type",Object)],Ad.prototype,"variables",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.graphql.fields.operationName.label",type:"string"}),Ut({handle:"operationName",userControlled:!0}),C("design:type",String)],Ad.prototype,"operationName",void 0),k([$t({handle:"result"}),C("design:type",Object)],Ad.prototype,"result",void 0),k([$t({handle:"errors",type:"array"}),C("design:type",Array)],Ad.prototype,"errors",void 0),Ad=k([Mt("core.io.graphql",{kind:"core.io.graphql",category:"IO",color:"#e10098",icon:"ti-api",width:96,height:96,labels:["io","graphql","api","query"],metadata:{title:"graph.node.io.graphql.name",description:"graph.node.io.graphql.description"}}),I()],Ad);const Sd=["listWorksheets","getRange","updateRange","listTables","addTableRow"];function Rd(e){const t=(e=>{if(null==e||""===e)throw new Cr("Microsoft Excel operation requires values","GRAPH_EXCEL_VALUES_REQUIRED");if(Array.isArray(e))return e;if("string"==typeof e)try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch{throw new Cr("Microsoft Excel values must be a JSON array","GRAPH_EXCEL_VALUES_INVALID")}throw new Cr("Microsoft Excel values must be a JSON array","GRAPH_EXCEL_VALUES_INVALID")})(e);return 0===t.length?[]:Array.isArray(t[0])?t:[t]}let Od=class extends Wi{constructor(){super(...arguments),this.operation="getRange"}async execute(e,t){if(!this.operation)throw new Cr("Microsoft Excel node requires an operation","GRAPH_EXCEL_OPERATION_REQUIRED");const o=Sd.includes(this.operation)?this.operation:"getRange",r=await an(t,e.credentials,"microsoft-excel",!1,"Microsoft Excel"),n=new Le;try{await xe(n,{token:Ts(r,"Microsoft Excel"),baseUrl:this.baseUrl});const e={itemId:this.itemId??"",driveId:this.driveId};switch(o){case"listWorksheets":return{result:await n.listWorksheets(e)};case"getRange":return{result:await n.getRange({...e,worksheet:this.worksheet??"",range:this.range??""})};case"updateRange":return{result:await n.updateRange({...e,worksheet:this.worksheet??"",range:this.range??"",values:Rd(this.values)})};case"listTables":return{result:await n.listTables(e)};default:{const t=Rd(this.values);return{result:await n.addTableRow({...e,tableId:this.tableId??"",values:t[0]??[]})}}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Microsoft Excel node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_EXCEL_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Od.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.itemId.label",type:"string"}),Ut({handle:"itemId",userControlled:!0}),C("design:type",String)],Od.prototype,"itemId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.driveId.label",type:"string"}),Ut({handle:"driveId",userControlled:!0}),C("design:type",String)],Od.prototype,"driveId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.worksheet.label",type:"string"}),Ut({handle:"worksheet",userControlled:!0}),C("design:type",String)],Od.prototype,"worksheet",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.range.label",type:"string"}),Ut({handle:"range",userControlled:!0}),C("design:type",String)],Od.prototype,"range",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.values.label",type:"textarea"}),Ut({handle:"values",userControlled:!0}),C("design:type",Object)],Od.prototype,"values",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.tableId.label",type:"string"}),Ut({handle:"tableId",userControlled:!0}),C("design:type",String)],Od.prototype,"tableId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_excel.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],Od.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],Od.prototype,"result",void 0),Od=k([Mt("core.io.microsoftExcel",{kind:"core.io.microsoftExcel",category:"IO",color:"#217346",icon:"ti-file-spreadsheet",width:96,height:96,labels:["io","microsoft","excel","spreadsheet","onedrive"],metadata:{title:"graph.node.io.microsoft_excel.name",description:"graph.node.io.microsoft_excel.description"}}),I()],Od);const kd=["getPage","listSpaces","createPage","updatePage","deletePage","search"];let Cd=class extends Wi{constructor(){super(...arguments),this.operation="getPage"}async execute(e,t){if(!this.operation)throw new Cr("Confluence node requires an operation","GRAPH_CONFLUENCE_OPERATION_REQUIRED");const o=kd.includes(this.operation)?this.operation:"getPage",r=await an(t,e.credentials,"confluence",!1,"Confluence"),n=new Me;try{switch(await xe(n,{token:Ns(r,"token","Confluence"),username:Ns(r,"username","Confluence"),baseUrl:this.baseUrl??Ns(r,"baseUrl","Confluence")}),o){case"getPage":if(!this.pageId)throw new Cr("Confluence getPage requires a pageId","GRAPH_CONFLUENCE_PAGE_REQUIRED");return{result:await n.getPage(this.pageId)};case"listSpaces":return{result:await n.listSpaces(Rs(this.limit)??25)};case"createPage":if(!this.spaceKey||!this.title)throw new Cr("Confluence createPage requires spaceKey and title","GRAPH_CONFLUENCE_CREATE_REQUIRED");return{result:await n.createPage({spaceKey:this.spaceKey,title:this.title,body:this.body??"",parentId:this.parentId})};case"updatePage":if(!this.pageId||!this.title)throw new Cr("Confluence updatePage requires pageId and title","GRAPH_CONFLUENCE_UPDATE_REQUIRED");return{result:await n.updatePage({pageId:this.pageId,title:this.title,body:this.body??"",version:Rs(this.version)})};case"deletePage":if(!this.pageId)throw new Cr("Confluence deletePage requires a pageId","GRAPH_CONFLUENCE_PAGE_REQUIRED");return{result:await n.deletePage(this.pageId)};default:if(!this.cql)throw new Cr("Confluence search requires a cql query","GRAPH_CONFLUENCE_SEARCH_REQUIRED");return{result:await n.search({cql:this.cql,limit:Rs(this.limit)})}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Confluence node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_CONFLUENCE_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Cd.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.pageId.label",type:"string"}),Ut({handle:"pageId",userControlled:!0}),C("design:type",String)],Cd.prototype,"pageId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.spaceKey.label",type:"string"}),Ut({handle:"spaceKey",userControlled:!0}),C("design:type",String)],Cd.prototype,"spaceKey",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.title.label",type:"string"}),Ut({handle:"title",userControlled:!0}),C("design:type",String)],Cd.prototype,"title",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.body.label",type:"textarea"}),Ut({handle:"body",userControlled:!0}),C("design:type",String)],Cd.prototype,"body",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.parentId.label",type:"string"}),Ut({handle:"parentId",userControlled:!0}),C("design:type",String)],Cd.prototype,"parentId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.version.label",type:"number"}),Ut({handle:"version",userControlled:!0}),C("design:type",Number)],Cd.prototype,"version",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.cql.label",type:"string"}),Ut({handle:"cql",userControlled:!0}),C("design:type",String)],Cd.prototype,"cql",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.limit.label",type:"number"}),Ut({handle:"limit",userControlled:!0}),C("design:type",Number)],Cd.prototype,"limit",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.confluence.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],Cd.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],Cd.prototype,"result",void 0),Cd=k([Mt("core.io.confluence",{kind:"core.io.confluence",category:"IO",color:"#0052cc",icon:"ti-file-text",width:96,height:96,labels:["io","confluence","wiki","atlassian","documentation"],metadata:{title:"graph.node.io.confluence.name",description:"graph.node.io.confluence.description"}}),I()],Cd);const Nd=["createIssue","getIssue","updateIssue","deleteIssue","addComment","getTransitions","transitionIssue","search"];function Td(e,t,o){if(null==e||""===e)return;if("string"==typeof e){try{const t=Es(JSON.parse(e));if(t)return t}catch{}throw new Cr(`Jira ${o} must be a JSON object`,t)}const r=Es(e);if(r)return r;throw new Cr(`Jira ${o} must be a JSON object`,t)}let Pd=class extends Wi{constructor(){super(...arguments),this.operation="createIssue"}async execute(e,t){if(!this.operation)throw new Cr("Jira node requires an operation","GRAPH_JIRA_OPERATION_REQUIRED");const o=Nd.includes(this.operation)?this.operation:"createIssue",r=await an(t,e.credentials,"jira",!1,"Jira"),n=new Ge;try{switch(await xe(n,{token:Ns(r,"token","Jira"),username:Ns(r,"username","Jira"),baseUrl:this.baseUrl??Ns(r,"baseUrl","Jira")}),o){case"createIssue":{if(!this.projectKey||!this.summary)throw new Cr("Jira createIssue requires projectKey and summary","GRAPH_JIRA_CREATE_REQUIRED");const e=await n.createIssue({projectKey:this.projectKey,summary:this.summary,issueType:this.issueType,description:this.description,fields:Td(this.fields,"GRAPH_JIRA_FIELDS_INVALID","fields")}),t=Es(e);return{result:e,..."string"==typeof t?.key?{issueKey:t.key}:{}}}case"getIssue":if(!this.issueKey)throw new Cr("Jira getIssue requires an issueKey","GRAPH_JIRA_ISSUE_REQUIRED");return{result:await n.getIssue(this.issueKey),issueKey:this.issueKey};case"updateIssue":{if(!this.issueKey)throw new Cr("Jira updateIssue requires an issueKey","GRAPH_JIRA_ISSUE_REQUIRED");const e=Td(this.fields,"GRAPH_JIRA_FIELDS_REQUIRED","fields");if(!e)throw new Cr("Jira updateIssue requires fields","GRAPH_JIRA_FIELDS_REQUIRED");return{result:await n.updateIssue({issueKey:this.issueKey,fields:e}),issueKey:this.issueKey}}case"deleteIssue":if(!this.issueKey)throw new Cr("Jira deleteIssue requires an issueKey","GRAPH_JIRA_ISSUE_REQUIRED");return{result:await n.deleteIssue(this.issueKey),issueKey:this.issueKey};case"addComment":if(!this.issueKey||!this.comment)throw new Cr("Jira addComment requires issueKey and comment","GRAPH_JIRA_COMMENT_REQUIRED");return{result:await n.addComment({issueKey:this.issueKey,body:this.comment}),issueKey:this.issueKey};case"getTransitions":if(!this.issueKey)throw new Cr("Jira getTransitions requires an issueKey","GRAPH_JIRA_ISSUE_REQUIRED");return{result:await n.getTransitions(this.issueKey),issueKey:this.issueKey};case"transitionIssue":if(!this.issueKey||!this.transitionId)throw new Cr("Jira transitionIssue requires issueKey and transitionId","GRAPH_JIRA_TRANSITION_REQUIRED");return{result:await n.transitionIssue({issueKey:this.issueKey,transitionId:this.transitionId}),issueKey:this.issueKey};default:if(!this.jql)throw new Cr("Jira search requires a jql query","GRAPH_JIRA_SEARCH_REQUIRED");return{result:await n.search({jql:this.jql,maxResults:Rs(this.maxResults)})}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Jira node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_JIRA_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Pd.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.projectKey.label",type:"string"}),Ut({handle:"projectKey",userControlled:!0}),C("design:type",String)],Pd.prototype,"projectKey",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.issueType.label",type:"string"}),Ut({handle:"issueType",userControlled:!0}),C("design:type",String)],Pd.prototype,"issueType",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.summary.label",type:"string"}),Ut({handle:"summary",userControlled:!0}),C("design:type",String)],Pd.prototype,"summary",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.description.label",type:"textarea"}),Ut({handle:"description",userControlled:!0}),C("design:type",String)],Pd.prototype,"description",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.issueKey.label",type:"string"}),Ut({handle:"issueKey",userControlled:!0}),C("design:type",String)],Pd.prototype,"issueKey",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.fields.label",type:"textarea"}),Ut({handle:"fields",userControlled:!0}),C("design:type",Object)],Pd.prototype,"fields",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.comment.label",type:"textarea"}),Ut({handle:"comment",userControlled:!0}),C("design:type",String)],Pd.prototype,"comment",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.transitionId.label",type:"string"}),Ut({handle:"transitionId",userControlled:!0}),C("design:type",String)],Pd.prototype,"transitionId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.jql.label",type:"string"}),Ut({handle:"jql",userControlled:!0}),C("design:type",String)],Pd.prototype,"jql",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.maxResults.label",type:"number"}),Ut({handle:"maxResults",userControlled:!0}),C("design:type",Number)],Pd.prototype,"maxResults",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.jira.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],Pd.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],Pd.prototype,"result",void 0),k([$t({handle:"issueKey",type:"string"}),C("design:type",String)],Pd.prototype,"resultIssueKey",void 0),Pd=k([Mt("core.io.jira",{kind:"core.io.jira",category:"IO",color:"#0052cc",icon:"ti-brand-jira",width:96,height:96,labels:["io","jira","issues","atlassian","project"],metadata:{title:"graph.node.io.jira.name",description:"graph.node.io.jira.description"}}),I()],Pd);const Dd=["createDocument","getDocument","appendText","replaceAllText","batchUpdate"];function jd(e){if(Array.isArray(e))return e;if("string"==typeof e&&e.trim().length>0)try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch{}throw new Cr("Google Docs requests must be a JSON array","GRAPH_GOOGLE_DOCS_REQUESTS_INVALID")}let Ld=class extends Wi{constructor(){super(...arguments),this.operation="getDocument"}async execute(e,t){if(!this.operation)throw new Cr("Google Docs node requires an operation","GRAPH_GOOGLE_DOCS_OPERATION_REQUIRED");const o=Dd.includes(this.operation)?this.operation:"getDocument",r=await an(t,e.credentials,"google-docs",!1,"Google Docs"),n=new Ue;try{switch(await xe(n,{token:Ns(r,"token","Google Docs"),apiKey:Ns(r,"apiKey","Google Docs"),baseUrl:this.baseUrl}),o){case"createDocument":{if(!this.title)throw new Cr("Google Docs createDocument requires a title","GRAPH_GOOGLE_DOCS_TITLE_REQUIRED");const e=await n.createDocument(this.title),t=Es(e);return{result:e,..."string"==typeof t?.documentId?{documentId:t.documentId}:{}}}case"getDocument":if(!this.documentId)throw new Cr("Google Docs getDocument requires a documentId","GRAPH_GOOGLE_DOCS_DOCUMENT_REQUIRED");return{result:await n.getDocument(this.documentId),documentId:this.documentId};case"appendText":if(!this.documentId||!this.text)throw new Cr("Google Docs appendText requires documentId and text","GRAPH_GOOGLE_DOCS_TEXT_REQUIRED");return{result:await n.appendText(this.documentId,this.text),documentId:this.documentId};case"replaceAllText":if(!this.documentId||!this.findText)throw new Cr("Google Docs replaceAllText requires documentId and findText","GRAPH_GOOGLE_DOCS_REPLACE_REQUIRED");return{result:await n.replaceAllText({documentId:this.documentId,find:this.findText,replace:this.replaceText??"",matchCase:this.matchCase}),documentId:this.documentId};default:if(!this.documentId)throw new Cr("Google Docs batchUpdate requires a documentId","GRAPH_GOOGLE_DOCS_DOCUMENT_REQUIRED");return{result:await n.batchUpdate(this.documentId,jd(this.requests)),documentId:this.documentId}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Google Docs node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GOOGLE_DOCS_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Ld.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.documentId.label",type:"string"}),Ut({handle:"documentId",userControlled:!0}),C("design:type",String)],Ld.prototype,"documentId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.title.label",type:"string"}),Ut({handle:"title",userControlled:!0}),C("design:type",String)],Ld.prototype,"title",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.text.label",type:"textarea"}),Ut({handle:"text",userControlled:!0}),C("design:type",String)],Ld.prototype,"text",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.findText.label",type:"string"}),Ut({handle:"findText",userControlled:!0}),C("design:type",String)],Ld.prototype,"findText",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.replaceText.label",type:"string"}),Ut({handle:"replaceText",userControlled:!0}),C("design:type",String)],Ld.prototype,"replaceText",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.matchCase.label",type:"boolean"}),Ut({handle:"matchCase",userControlled:!0}),C("design:type",Boolean)],Ld.prototype,"matchCase",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.requests.label",type:"textarea"}),Ut({handle:"requests",userControlled:!0}),C("design:type",Object)],Ld.prototype,"requests",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_docs.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],Ld.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],Ld.prototype,"result",void 0),k([$t({handle:"documentId",type:"string"}),C("design:type",String)],Ld.prototype,"resultDocumentId",void 0),Ld=k([Mt("core.io.googleDocs",{kind:"core.io.googleDocs",category:"IO",color:"#4285f4",icon:"ti-brand-google",width:96,height:96,labels:["io","google","docs","document"],metadata:{title:"graph.node.io.google_docs.name",description:"graph.node.io.google_docs.description"}}),I()],Ld);const Md=["listSites","getSite","listLists","listItems","createListItem","listDriveItems"];let Gd=class extends Wi{constructor(){super(...arguments),this.operation="listSites"}async execute(e,t){if(!this.operation)throw new Cr("Microsoft SharePoint node requires an operation","GRAPH_SHAREPOINT_OPERATION_REQUIRED");const o=Md.includes(this.operation)?this.operation:"listSites",r=await an(t,e.credentials,"microsoft-sharepoint",!1,"Microsoft SharePoint"),n=new $e;try{switch(await xe(n,{token:Ts(r,"Microsoft SharePoint"),baseUrl:this.baseUrl}),o){case"listSites":return{result:await n.listSites(this.search??"*")};case"getSite":if(!this.siteId)throw new Cr("Microsoft SharePoint getSite requires a siteId","GRAPH_SHAREPOINT_SITE_REQUIRED");return{result:await n.getSite(this.siteId)};case"listLists":if(!this.siteId)throw new Cr("Microsoft SharePoint listLists requires a siteId","GRAPH_SHAREPOINT_SITE_REQUIRED");return{result:await n.listLists(this.siteId)};case"listItems":if(!this.siteId||!this.listId)throw new Cr("Microsoft SharePoint listItems requires siteId and listId","GRAPH_SHAREPOINT_LIST_REQUIRED");return{result:await n.listItems({siteId:this.siteId,listId:this.listId,top:Rs(this.top),filter:this.filter})};case"createListItem":{if(!this.siteId||!this.listId||!this.fields)throw new Cr("Microsoft SharePoint createListItem requires siteId, listId, and fields","GRAPH_SHAREPOINT_ITEM_REQUIRED");const e=(e=>{if(null==e||""===e)return;if("string"==typeof e){try{const t=Es(JSON.parse(e));if(t)return t}catch{}throw new Cr("Microsoft SharePoint fields must be a JSON object","GRAPH_SHAREPOINT_FIELDS_INVALID")}const t=Es(e);if(t)return t;throw new Cr("Microsoft SharePoint fields must be a JSON object","GRAPH_SHAREPOINT_FIELDS_INVALID")})(this.fields);if(!e)throw new Cr("Microsoft SharePoint createListItem requires fields","GRAPH_SHAREPOINT_ITEM_REQUIRED");return{result:await n.createListItem({siteId:this.siteId,listId:this.listId,fields:e})}}default:if(!this.siteId)throw new Cr("Microsoft SharePoint listDriveItems requires a siteId","GRAPH_SHAREPOINT_SITE_REQUIRED");return{result:await n.listDriveItems({siteId:this.siteId,itemId:this.itemId,top:Rs(this.top)})}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Microsoft SharePoint node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_SHAREPOINT_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Gd.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.siteId.label",type:"string"}),Ut({handle:"siteId",userControlled:!0}),C("design:type",String)],Gd.prototype,"siteId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.listId.label",type:"string"}),Ut({handle:"listId",userControlled:!0}),C("design:type",String)],Gd.prototype,"listId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.itemId.label",type:"string"}),Ut({handle:"itemId",userControlled:!0}),C("design:type",String)],Gd.prototype,"itemId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.search.label",type:"string"}),Ut({handle:"search",userControlled:!0}),C("design:type",String)],Gd.prototype,"search",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.top.label",type:"number"}),Ut({handle:"top",userControlled:!0}),C("design:type",Number)],Gd.prototype,"top",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.filter.label",type:"string"}),Ut({handle:"filter",userControlled:!0}),C("design:type",String)],Gd.prototype,"filter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.fields.label",type:"textarea"}),Ut({handle:"fields",userControlled:!0}),C("design:type",Object)],Gd.prototype,"fields",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.microsoft_sharepoint.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],Gd.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],Gd.prototype,"result",void 0),Gd=k([Mt("core.io.microsoftSharePoint",{kind:"core.io.microsoftSharePoint",category:"IO",color:"#036c70",icon:"ti-brand-office",width:96,height:96,labels:["io","microsoft","sharepoint","files","lists"],metadata:{title:"graph.node.io.microsoft_sharepoint.name",description:"graph.node.io.microsoft_sharepoint.description"}}),I()],Gd);const Ud=["listCalendars","listEvents","createEvent","getEvent","updateEvent","deleteEvent"];function $d(e){if(null!=e&&""!==e){if(Array.isArray(e))return e.map(e=>(e+"").trim()).filter(e=>e.length>0);if("string"==typeof e){if(e.trim().startsWith("["))try{const t=JSON.parse(e);return Array.isArray(t)?t.map(e=>(e+"").trim()):void 0}catch{throw new Cr("Google Calendar attendees must be a JSON array or a comma-separated list","GRAPH_GOOGLE_CALENDAR_ATTENDEES_INVALID")}return e.split(/[,;]/).map(e=>e.trim()).filter(e=>e.length>0)}}}let Fd=class extends Wi{constructor(){super(...arguments),this.operation="listEvents"}async execute(e,t){if(!this.operation)throw new Cr("Google Calendar node requires an operation","GRAPH_GOOGLE_CALENDAR_OPERATION_REQUIRED");const o=Ud.includes(this.operation)?this.operation:"listEvents",r=await an(t,e.credentials,"google-calendar",!1,"Google Calendar"),n=new Fe;try{switch(await xe(n,{token:Ns(r,"token","Google Calendar"),apiKey:Ns(r,"apiKey","Google Calendar"),calendarId:Ns(r,"calendarId","Google Calendar"),baseUrl:this.baseUrl}),o){case"listCalendars":return{result:await n.listCalendars()};case"listEvents":return{result:await n.listEvents({calendarId:this.calendarId,timeMin:this.timeMin,timeMax:this.timeMax,maxResults:Rs(this.maxResults),q:this.q,singleEvents:this.singleEvents})};case"createEvent":{if(!this.summary||!this.start||!this.end)throw new Cr("Google Calendar createEvent requires summary, start, and end","GRAPH_GOOGLE_CALENDAR_EVENT_REQUIRED");const e=await n.createEvent({calendarId:this.calendarId,summary:this.summary,description:this.description,location:this.location,start:this.start,end:this.end,timeZone:this.timeZone,attendees:$d(this.attendees)}),t=Es(e);return{result:e,..."string"==typeof t?.id?{eventId:t.id}:{}}}case"getEvent":if(!this.eventId)throw new Cr("Google Calendar getEvent requires an eventId","GRAPH_GOOGLE_CALENDAR_EVENT_REQUIRED");return{result:await n.getEvent(this.calendarId??"primary",this.eventId),eventId:this.eventId};case"updateEvent":if(!this.eventId)throw new Cr("Google Calendar updateEvent requires an eventId","GRAPH_GOOGLE_CALENDAR_EVENT_REQUIRED");return{result:await n.updateEvent(this.eventId,{calendarId:this.calendarId,summary:this.summary,description:this.description,location:this.location,start:this.start,end:this.end,timeZone:this.timeZone,attendees:$d(this.attendees)}),eventId:this.eventId};default:if(!this.eventId)throw new Cr("Google Calendar deleteEvent requires an eventId","GRAPH_GOOGLE_CALENDAR_EVENT_REQUIRED");return{result:await n.deleteEvent(this.calendarId??"primary",this.eventId),eventId:this.eventId}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Google Calendar node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GOOGLE_CALENDAR_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Fd.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.calendarId.label",type:"string"}),Ut({handle:"calendarId",userControlled:!0}),C("design:type",String)],Fd.prototype,"calendarId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.eventId.label",type:"string"}),Ut({handle:"eventId",userControlled:!0}),C("design:type",String)],Fd.prototype,"eventId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.summary.label",type:"string"}),Ut({handle:"summary",userControlled:!0}),C("design:type",String)],Fd.prototype,"summary",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.description.label",type:"textarea"}),Ut({handle:"description",userControlled:!0}),C("design:type",String)],Fd.prototype,"description",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.location.label",type:"string"}),Ut({handle:"location",userControlled:!0}),C("design:type",String)],Fd.prototype,"location",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.start.label",type:"string"}),Ut({handle:"start",userControlled:!0}),C("design:type",String)],Fd.prototype,"start",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.end.label",type:"string"}),Ut({handle:"end",userControlled:!0}),C("design:type",String)],Fd.prototype,"end",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.timeZone.label",type:"string"}),Ut({handle:"timeZone",userControlled:!0}),C("design:type",String)],Fd.prototype,"timeZone",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.attendees.label",type:"textarea"}),Ut({handle:"attendees",userControlled:!0}),C("design:type",Object)],Fd.prototype,"attendees",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.timeMin.label",type:"string"}),Ut({handle:"timeMin",userControlled:!0}),C("design:type",String)],Fd.prototype,"timeMin",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.timeMax.label",type:"string"}),Ut({handle:"timeMax",userControlled:!0}),C("design:type",String)],Fd.prototype,"timeMax",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.maxResults.label",type:"number"}),Ut({handle:"maxResults",userControlled:!0}),C("design:type",Number)],Fd.prototype,"maxResults",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.q.label",type:"string"}),Ut({handle:"q",userControlled:!0}),C("design:type",String)],Fd.prototype,"q",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.singleEvents.label",type:"boolean"}),Ut({handle:"singleEvents",userControlled:!0}),C("design:type",Boolean)],Fd.prototype,"singleEvents",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.google_calendar.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],Fd.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],Fd.prototype,"result",void 0),k([$t({handle:"eventId",type:"string"}),C("design:type",String)],Fd.prototype,"resultEventId",void 0),Fd=k([Mt("core.io.googleCalendar",{kind:"core.io.googleCalendar",category:"IO",color:"#4285f4",icon:"ti-calendar-event",width:96,height:96,labels:["io","google","calendar","events","scheduling"],metadata:{title:"graph.node.io.google_calendar.name",description:"graph.node.io.google_calendar.description"}}),I()],Fd);const Hd=new Set(["workdocs"]);function Bd(){return["/etc","/proc","/root",oe(de(),".ssh")]}function qd(){const e=process.env.GRAPH_FILE_IO_BASE?.trim(),t=oe(e&&e.length>0?e:process.cwd());try{return le(t)}catch{return t}}function Wd(e,t){const o=re(e,t);return""===o||!o.startsWith("..")&&!ie(o)}function Kd(e,t,o){if(!Wd(e,t))throw new Cr(`File node path '${o}' resolves outside the configured file IO base`,"GRAPH_FILE_PATH_FORBIDDEN",{path:o,base:e});for(const e of Bd())if(Wd(e,t))throw new Cr(`File node path '${o}' targets a forbidden directory`,"GRAPH_FILE_PATH_FORBIDDEN",{path:o});const r=re(e,t).split(ne).filter(Boolean);for(const e of r)if(Hd.has(e.toLowerCase()))throw new Cr(`File node path '${o}' targets a forbidden directory`,"GRAPH_FILE_PATH_FORBIDDEN",{path:o,segment:e})}function Vd(e){if(e.includes("\0"))throw new Cr("File node path contains a NUL byte","GRAPH_FILE_INVALID_PATH",{path:e});const t=qd();(e=>{if(!ie(e))return;const t=oe(e);for(const o of Bd())if(Wd(o,t))throw new Cr(`File node path '${e}' targets a forbidden directory`,"GRAPH_FILE_PATH_FORBIDDEN",{path:e})})(e);const o=e.replace(/^[/\\]+/,""),r=oe(t,o);return Kd(t,r,e),{base:t,candidate:r}}async function zd(e){let t=e;for(;;)try{return await ce(t)}catch{const e=te(t);if(e===t)return;t=e}}const Qd={".csv":"text/csv",".gif":"image/gif",".htm":"text/html",".html":"text/html",".ics":"text/calendar",".jpeg":"image/jpeg",".jpg":"image/jpeg",".json":"application/json",".md":"text/markdown",".ods":"application/vnd.oasis.opendocument.spreadsheet",".pdf":"application/pdf",".png":"image/png",".rtf":"application/rtf",".svg":"image/svg+xml",".txt":"text/plain",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".xml":"application/xml",".zip":"application/zip"};function Jd(e){return Qd[ae(e).toLowerCase()]??"application/octet-stream"}function Xd(e,t,o,r){const n={fileName:t,mimeType:r||Jd(t),byteLength:e.byteLength,data:e.toString("base64")};return void 0!==o&&(n.path=o),n}function Yd(e,t="utf8",o="data"){if("string"==typeof e){if(e.startsWith("data:")){const t=e.indexOf(",");if(t>=0)return Buffer.from(e.slice(t+1),"base64")}return"base64"===t?Buffer.from(e,"base64"):Buffer.from(e,"utf8")}if(_a(e))return Buffer.isBuffer(e)?e:Buffer.from(e instanceof ArrayBuffer?new Uint8Array(e):e);if(pa(e)){const r="auto"===t?"number"==typeof e.byteLength||"string"==typeof e.mimeType?"base64":"utf8":t;for(const t of[o,"data","content","value"])if(t&&void 0!==e[t]&&e[t]!==e)return Yd(e[t],r,o)}throw new Cr("File node requires a binary payload","GRAPH_BINARY_INPUT_REQUIRED",{valueType:typeof e})}async function Zd(e){const{base:t,candidate:o}=Vd(e);let r;try{r=await ce(o)}catch{throw new Cr(`File node path '${e}' does not exist`,"GRAPH_FILE_INVALID_PATH",{path:e})}Kd(t,r,e);const n=await pe(r);return{payload:Xd(n,se(o),e,Jd(o)),bytes:n.byteLength}}function el(e,t,o){const r=e;let n;switch(t.returnValue??"text"){case"attribute":n=t.attribute?r.attr(t.attribute):void 0;break;case"html":n=r.html()??void 0;break;case"value":{const e=r.val();n=void 0===e?void 0:Array.isArray(e)?e.join(","):e;break}default:n=((e,t)=>{const o=e;if(!t.skipSelectors)return o.text()||void 0;const r=t.skipSelectors.split(",").map(e=>e.trim()).filter(e=>e.length>0).map(e=>({selector:e,format:"skip"}));return Be(o.html()??"",{selectors:r})||void 0})(e,t)}if(void 0!==n)return((e,t)=>{if(void 0===e)return e;let o=e;return!1!==t.trimValues&&(o=o.trim()),t.cleanUpText&&(o=o.replace(/^\s+|\s+$/g,"").replace(/(\r\n|\n|\r)/gm,"").replace(/\s+/g," ")),o})(n,o)}function tl(e,t,o={}){const r=He.load(e),n={};for(const e of t){if(!e||"string"!=typeof e.cssSelector)continue;const t=e.key||e.cssSelector,i=r(e.cssSelector);if(e.returnArray){const a=[];i.each((t,n)=>{a.push(el(r(n),e,o))}),n[t]=a}else n[t]=el(i,e,o)}return n}function ol(e){if("string"==typeof e)return[e];if(Array.isArray(e))return e.flatMap(e=>ol(e));if(Buffer.isBuffer(e)||e instanceof Uint8Array)return[Buffer.from(e).toString("utf8")];if(e instanceof ArrayBuffer)return[Buffer.from(new Uint8Array(e)).toString("utf8")];if(pa(e))for(const t of["data","content","html","value"])if(void 0!==e[t]&&e[t]!==e)return ol(e[t]);return[]}function rl(e,t){return e.replace(/\{\{\s*([^}]+?)\s*\}\}/g,(e,o)=>{const r=(o+"").replace(/^\$json\.?/,"").trim(),n=fa(t,r,!0);return null==n?"":"object"==typeof n?JSON.stringify(n):n+""})}function nl(e,t={}){const o=e.map(e=>pa(e)?e:{value:e}),r=Array.from(new Set(o.flatMap(e=>Object.keys(e)))),n=t.customStyling?"":"style='border-spacing:0; font-family:helvetica,arial,sans-serif'",i=t.customStyling?"":"style='margin:0; padding:7px 20px 7px 0px; border-bottom:1px solid #eee; text-align:left; color:#888; font-weight:normal'",a=t.customStyling?"":"style='margin:0; padding:7px 20px 7px 0px; border-bottom:1px solid #eee'";let s=`<table ${n} ${t.tableAttributes??""}>`;t.caption&&(s+=`<caption>${t.caption}</caption>`),s+=`<thead ${i} ${t.headerAttributes??""}>`,s+="<tr>",s+=r.map(e=>`<th>${((e,t)=>t?e.split("_").filter(e=>e).map(e=>e[0].toUpperCase()+e.slice(1)).join(" "):e)(e,t.capitalize)}</th>`).join(""),s+="</tr></thead><tbody>";for(const e of o)s+=`<tr ${t.rowAttributes??""}>`,s+=r.map(o=>{const r=e[o];let n=`<td ${a} ${t.cellAttributes??""}>`;return n+="boolean"==typeof r?`<input type="checkbox" ${r?'checked="checked"':""}/>`:null==r?"":r+"",n+="</td>",n}).join(""),s+="</tr>";return s+="</tbody></table>",s}const il=["csv","html","toJson","toText","toBinary"];function al(e,t){if(null==e)return"";const o="object"==typeof e?JSON.stringify(e):e+"";return o.includes('"')||o.includes("\n")||o.includes("\r")||o.includes(t)?`"${o.replace(/"/g,'""')}"`:o}function sl(e,t){return Buffer.from(`${t?"\ufeff":""}${e}`,"utf8")}let dl=class extends Wi{constructor(){super(...arguments),this.operation="csv",this.binaryPropertyName="data",this.mode="once",this.delimiter=",",this.headerRow=!0,this.addBOM=!1,this.format=!1,this.dataIsBase64=!0,this.customStyling=!1,this.capitalize=!1}execute(e){if(!il.includes(this.operation))throw new Cr(`Convert to File operation '${this.operation}' is not supported`,"GRAPH_CONVERT_TO_FILE_UNSUPPORTED_OPERATION",{operation:this.operation});const t=ua(e.inputs.value).map(e=>pa(e)?e:{value:e});switch(this.operation){case"csv":{const e=((e,t,o)=>{const r=Array.from(new Set(e.flatMap(e=>Object.keys(e)))),n=[];o&&n.push(r.map(e=>al(e,t)).join(t));for(const o of e)n.push(r.map(e=>al(o[e],t)).join(t));return n.join("\n")})(t,this.delimiter||",",!1!==this.headerRow),o=Xd(sl(e,this.addBOM),this.fileName||"file.csv",void 0,"text/csv");return{result:o,content:e,bytes:o.byteLength}}case"html":{const e=`<!DOCTYPE html><html><body>${nl(t,{caption:this.caption,customStyling:!0===this.customStyling,capitalize:!0===this.capitalize})}</body></html>`,o=Xd(sl(e,this.addBOM),this.fileName||"file.html",void 0,"text/html");return{result:o,content:e,bytes:o.byteLength}}case"toText":{const e=this.textPayloads(t);return this.returnPayloads(e)}case"toBinary":{const e=this.binaryPayloads(t);return this.returnPayloads(e)}default:{if("each"===this.mode){const e=t.map(e=>Xd(sl(JSON.stringify(e,null,this.format?2:0),this.addBOM),this.fileName||"file.json",void 0,"application/json"));return this.returnPayloads(e)}const e=JSON.stringify(t,null,this.format?2:0),o=Xd(sl(e,this.addBOM),this.fileName||"file.json",void 0,"application/json");return{result:o,content:e,bytes:o.byteLength}}}}textPayloads(e){return e.map(e=>{const t=this.sourceProperty?fa(e,this.sourceProperty,!0):e.value??e;if(null==t)throw new Cr(`Convert to File node could not find '${this.sourceProperty}' in the input`,"GRAPH_CONVERT_TO_FILE_SOURCE_REQUIRED",{sourceProperty:this.sourceProperty});return Xd(sl("string"==typeof t?t:t+"",this.addBOM),this.fileName||"file.txt",void 0,"text/plain")})}binaryPayloads(e){return e.map(e=>{const t=this.sourceProperty?fa(e,this.sourceProperty,!0):e.data??e.value;if("string"!=typeof t)throw new Cr(`Convert to File node requires a base64 string in '${this.sourceProperty??"data"}'`,"GRAPH_CONVERT_TO_FILE_SOURCE_REQUIRED",{sourceProperty:this.sourceProperty});const o=t.startsWith("data:")?t.slice(t.indexOf(",")+1):t;return!1===this.dataIsBase64?Xd(Buffer.from(o,"utf8"),this.fileName||"file.bin",void 0,this.mimeType||"application/octet-stream"):Xd(Buffer.from(o,"base64"),this.fileName||"file.bin",void 0,this.mimeType||"application/octet-stream")})}returnPayloads(e){return 1===e.length?{result:e[0],bytes:e[0].byteLength}:{result:e,bytes:e.reduce((e,t)=>e+t.byteLength,0)}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],dl.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],dl.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.binaryPropertyName.label",type:"text"}),Ut({handle:"binaryPropertyName",userControlled:!0}),C("design:type",String)],dl.prototype,"binaryPropertyName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.sourceProperty.label",placeholder:"graph.node.io.convert_to_file.fields.sourceProperty.placeholder",type:"text"}),Ut({handle:"sourceProperty",userControlled:!0}),C("design:type",String)],dl.prototype,"sourceProperty",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.mode.label",type:"select"}),Ut({handle:"mode",userControlled:!0}),C("design:type",String)],dl.prototype,"mode",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.fileName.label",placeholder:"graph.node.io.convert_to_file.fields.fileName.placeholder",type:"text"}),Ut({handle:"fileName",userControlled:!0}),C("design:type",String)],dl.prototype,"fileName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.mimeType.label",type:"text"}),Ut({handle:"mimeType",userControlled:!0}),C("design:type",String)],dl.prototype,"mimeType",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.delimiter.label",type:"text"}),Ut({handle:"delimiter",userControlled:!0}),C("design:type",String)],dl.prototype,"delimiter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.headerRow.label",type:"checkbox"}),Ut({handle:"headerRow",userControlled:!0}),C("design:type",Boolean)],dl.prototype,"headerRow",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.sheetName.label",type:"text"}),Ut({handle:"sheetName",userControlled:!0}),C("design:type",String)],dl.prototype,"sheetName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.addBOM.label",type:"checkbox"}),Ut({handle:"addBOM",userControlled:!0}),C("design:type",Boolean)],dl.prototype,"addBOM",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.format.label",type:"checkbox"}),Ut({handle:"format",userControlled:!0}),C("design:type",Boolean)],dl.prototype,"format",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.dataIsBase64.label",type:"checkbox"}),Ut({handle:"dataIsBase64",userControlled:!0}),C("design:type",Boolean)],dl.prototype,"dataIsBase64",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.caption.label",type:"text"}),Ut({handle:"caption",userControlled:!0}),C("design:type",String)],dl.prototype,"caption",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.customStyling.label",type:"checkbox"}),Ut({handle:"customStyling",userControlled:!0}),C("design:type",Boolean)],dl.prototype,"customStyling",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.convert_to_file.fields.capitalize.label",type:"checkbox"}),Ut({handle:"capitalize",userControlled:!0}),C("design:type",Boolean)],dl.prototype,"capitalize",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],dl.prototype,"result",void 0),k([$t({handle:"content"}),C("design:type",String)],dl.prototype,"content",void 0),k([$t({handle:"bytes"}),C("design:type",Number)],dl.prototype,"bytes",void 0),dl=k([Mt("core.io.convertToFile",{kind:"core.io.convertToFile",category:"IO",color:"#0ea5e9",icon:"ti-file-arrow-right",width:96,height:96,labels:["io","file","convert","binary","csv","json"],metadata:{title:"graph.node.io.convert_to_file.name",description:"graph.node.io.convert_to_file.description"}}),I()],dl);let ll=class extends Wi{constructor(){super(...arguments),this.operation="generateHtmlTemplate",this.sourceData="json",this.dataPropertyName="data",this.extractionValues=[],this.trimValues=!0,this.cleanUpText=!1,this.customStyling=!1,this.capitalize=!1}execute(e){const t=e.inputs.value;switch(this.operation){case"extractHtmlContent":{const e=this.dataPropertyName||"data";let o;if(o="binary"===this.sourceData?[Yd(t,"base64",e).toString("utf8")]:pa(t)?ol(fa(t,e,!0)??t):ol(t),0===o.length)throw new Cr("HTML node requires HTML content to extract","GRAPH_HTML_INVALID_INPUT");const r=(this.extractionValues??[]).filter(e=>e&&"string"==typeof e.cssSelector);if(0===r.length)throw new Cr("HTML node requires at least one extraction value","GRAPH_HTML_EXTRACT_VALUES_REQUIRED");return{result:o.map(e=>tl(e,r,{trimValues:!1!==this.trimValues,cleanUpText:!0===this.cleanUpText}))}}case"convertToHtmlTable":{const e=nl(ua(t),{caption:this.caption,tableAttributes:this.tableAttributes,headerAttributes:this.headerAttributes,rowAttributes:this.rowAttributes,cellAttributes:this.cellAttributes,customStyling:!0===this.customStyling,capitalize:!0===this.capitalize});return{result:e,table:e}}default:if(!this.html)throw new Cr("HTML node requires a template to render","GRAPH_HTML_TEMPLATE_REQUIRED");return Array.isArray(t)?{result:t.filter(e=>null!=e).map(e=>rl(this.html,e))}:{result:rl(this.html,t)}}}};k([Ut({handle:"value"}),C("design:type",Object)],ll.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],ll.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.html.label",type:"textarea"}),Ut({handle:"html",userControlled:!0}),C("design:type",String)],ll.prototype,"html",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.sourceData.label",type:"select"}),Ut({handle:"sourceData",userControlled:!0}),C("design:type",String)],ll.prototype,"sourceData",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.dataPropertyName.label",placeholder:"graph.node.io.html.fields.dataPropertyName.placeholder",type:"text"}),Ut({handle:"dataPropertyName",userControlled:!0}),C("design:type",String)],ll.prototype,"dataPropertyName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.extractionValues.label",placeholder:"graph.node.io.html.fields.extractionValues.placeholder",type:"collection"}),Ut({handle:"extractionValues",userControlled:!0,type:"array"}),C("design:type",Array)],ll.prototype,"extractionValues",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.trimValues.label",type:"checkbox"}),Ut({handle:"trimValues",userControlled:!0}),C("design:type",Boolean)],ll.prototype,"trimValues",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.cleanUpText.label",type:"checkbox"}),Ut({handle:"cleanUpText",userControlled:!0}),C("design:type",Boolean)],ll.prototype,"cleanUpText",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.caption.label",type:"text"}),Ut({handle:"caption",userControlled:!0}),C("design:type",String)],ll.prototype,"caption",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.tableAttributes.label",type:"text"}),Ut({handle:"tableAttributes",userControlled:!0}),C("design:type",String)],ll.prototype,"tableAttributes",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.headerAttributes.label",type:"text"}),Ut({handle:"headerAttributes",userControlled:!0}),C("design:type",String)],ll.prototype,"headerAttributes",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.rowAttributes.label",type:"text"}),Ut({handle:"rowAttributes",userControlled:!0}),C("design:type",String)],ll.prototype,"rowAttributes",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.cellAttributes.label",type:"text"}),Ut({handle:"cellAttributes",userControlled:!0}),C("design:type",String)],ll.prototype,"cellAttributes",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.customStyling.label",type:"checkbox"}),Ut({handle:"customStyling",userControlled:!0}),C("design:type",Boolean)],ll.prototype,"customStyling",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html.fields.capitalize.label",type:"checkbox"}),Ut({handle:"capitalize",userControlled:!0}),C("design:type",Boolean)],ll.prototype,"capitalize",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],ll.prototype,"result",void 0),k([$t({handle:"table"}),C("design:type",String)],ll.prototype,"table",void 0),ll=k([Mt("core.io.html",{kind:"core.io.html",category:"IO",color:"#0ea5e9",icon:"ti-brand-html5",width:96,height:96,labels:["io","html","template","table"],metadata:{title:"graph.node.io.html.name",description:"graph.node.io.html.description"}}),I()],ll);let cl=class extends Wi{constructor(){super(...arguments),this.sourceData="json",this.dataPropertyName="data",this.extractionValues=[],this.trimValues=!0,this.cleanUpText=!1}execute(e){const t=e.inputs.value,o=this.dataPropertyName||"data";let r;if(r="binary"===this.sourceData?[Yd(t,"base64",o).toString("utf8")]:pa(t)?ol(fa(t,o,!0)??t):ol(t),0===r.length)throw new Cr("HTML Extract node requires HTML content","GRAPH_HTML_EXTRACT_INVALID_INPUT");const n=(this.extractionValues??[]).filter(e=>e&&"string"==typeof e.cssSelector);if(0===n.length)throw new Cr("HTML Extract node requires at least one extraction value","GRAPH_HTML_EXTRACT_VALUES_REQUIRED");return{result:r.map(e=>tl(e,n,{trimValues:!1!==this.trimValues,cleanUpText:!0===this.cleanUpText}))}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],cl.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html_extract.fields.sourceData.label",type:"select"}),Ut({handle:"sourceData",userControlled:!0}),C("design:type",String)],cl.prototype,"sourceData",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html_extract.fields.dataPropertyName.label",placeholder:"graph.node.io.html_extract.fields.dataPropertyName.placeholder",type:"text"}),Ut({handle:"dataPropertyName",userControlled:!0}),C("design:type",String)],cl.prototype,"dataPropertyName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html_extract.fields.extractionValues.label",placeholder:"graph.node.io.html_extract.fields.extractionValues.placeholder",type:"collection"}),Ut({handle:"extractionValues",userControlled:!0,type:"array"}),C("design:type",Array)],cl.prototype,"extractionValues",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html_extract.fields.trimValues.label",type:"checkbox"}),Ut({handle:"trimValues",userControlled:!0}),C("design:type",Boolean)],cl.prototype,"trimValues",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.html_extract.fields.cleanUpText.label",type:"checkbox"}),Ut({handle:"cleanUpText",userControlled:!0}),C("design:type",Boolean)],cl.prototype,"cleanUpText",void 0),k([w(),$t({handle:"result"}),C("design:type",Array)],cl.prototype,"result",void 0),cl=k([Mt("core.io.htmlExtract",{kind:"core.io.htmlExtract",category:"IO",color:"#0ea5e9",icon:"ti-cut",width:96,height:96,labels:["io","html","extract","css"],metadata:{title:"graph.node.io.html_extract.name",description:"graph.node.io.html_extract.description"}}),I()],cl);let pl=class extends Wi{constructor(){super(...arguments),this.mode="htmlToMarkdown"}execute(e){const t=e.inputs.value,o="markdownToHtml"===this.mode?this.markdown??t:this.html??t;if("string"!=typeof o||0===o.length)throw new Cr(`Markdown node requires ${"markdownToHtml"===this.mode?"markdown":"HTML"} content`,"GRAPH_MARKDOWN_CONTENT_REQUIRED");let r;try{r="markdownToHtml"===this.mode?qe.parse(o):this.turndown().turndown(o)}catch(e){throw new Cr("Markdown node conversion failed: "+(e instanceof Error?e.message:e+""),"GRAPH_MARKDOWN_CONVERSION_FAILED")}if(!this.destinationKey)return{result:r,content:r};const n={};return ya(n,this.destinationKey,r,!0),{result:n,content:r}}turndown(){const e=new We({headingStyle:this.headingStyle??"atx",hr:this.hr??"---",bulletListMarker:this.bulletMarker??"*",codeBlockStyle:"fenced",fence:this.codeBlockFence??"```",emDelimiter:this.emDelimiter??"_",strongDelimiter:this.strongDelimiter??"**",linkStyle:this.linkStyle??"inlined"});for(const t of La(this.ignore,"Ignored Elements"))e.remove(t);return e}};k([Ut({handle:"value"}),C("design:type",Object)],pl.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.mode.label",type:"select"}),Ut({handle:"mode",userControlled:!0}),C("design:type",String)],pl.prototype,"mode",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.markdown.label",type:"textarea"}),Ut({handle:"markdown",userControlled:!0}),C("design:type",String)],pl.prototype,"markdown",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.html.label",type:"textarea"}),Ut({handle:"html",userControlled:!0}),C("design:type",String)],pl.prototype,"html",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.destinationKey.label",placeholder:"graph.node.io.markdown.fields.destinationKey.placeholder",type:"text"}),Ut({handle:"destinationKey",userControlled:!0}),C("design:type",String)],pl.prototype,"destinationKey",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.headingStyle.label",type:"select"}),Ut({handle:"headingStyle",userControlled:!0}),C("design:type",String)],pl.prototype,"headingStyle",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.hr.label",type:"text"}),Ut({handle:"hr",userControlled:!0}),C("design:type",String)],pl.prototype,"hr",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.bulletMarker.label",type:"text"}),Ut({handle:"bulletMarker",userControlled:!0}),C("design:type",String)],pl.prototype,"bulletMarker",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.codeBlockFence.label",type:"text"}),Ut({handle:"codeBlockFence",userControlled:!0}),C("design:type",String)],pl.prototype,"codeBlockFence",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.emDelimiter.label",type:"text"}),Ut({handle:"emDelimiter",userControlled:!0}),C("design:type",String)],pl.prototype,"emDelimiter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.strongDelimiter.label",type:"text"}),Ut({handle:"strongDelimiter",userControlled:!0}),C("design:type",String)],pl.prototype,"strongDelimiter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.linkStyle.label",type:"select"}),Ut({handle:"linkStyle",userControlled:!0}),C("design:type",String)],pl.prototype,"linkStyle",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.markdown.fields.ignore.label",placeholder:"graph.node.io.markdown.fields.ignore.placeholder",type:"text"}),Ut({handle:"ignore",userControlled:!0}),C("design:type",Object)],pl.prototype,"ignore",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],pl.prototype,"result",void 0),k([$t({handle:"content"}),C("design:type",String)],pl.prototype,"content",void 0),pl=k([Mt("core.io.markdown",{kind:"core.io.markdown",category:"IO",color:"#0ea5e9",icon:"ti-markdown",width:96,height:96,labels:["io","markdown","html","convert"],metadata:{title:"graph.node.io.markdown.name",description:"graph.node.io.markdown.description"}}),I()],pl);const ul=10485760,gl=/<!ENTITY/i;let hl=class extends Wi{constructor(){super(...arguments),this.mode="xmlToJson",this.dataPropertyName="data",this.attrkey="$",this.charkey="_",this.explicitArray=!1,this.explicitRoot=!0,this.ignoreAttrs=!1,this.mergeAttrs=!0,this.normalize=!1,this.normalizeTags=!1,this.trim=!1,this.cdata=!1,this.headless=!1,this.rootName="root",this.allowSurrogateChars=!1}async execute(e){const t=e.inputs.value;if("xmlToJson"===this.mode){const e=this.xmlTextOf(t),o=Buffer.byteLength(e,"utf8");if(o>ul)throw new Cr(`XML input of ${o} bytes exceeds the 10485760-byte limit`,"GRAPH_XML_INPUT_TOO_LARGE",{byteLength:o,maxBytes:ul});if(gl.test(e))throw new Cr("XML input entity declarations are not allowed","GRAPH_XML_ENTITY_FORBIDDEN");const r=new Ke({attrkey:this.attrkey||"$",charkey:this.charkey||"_",explicitArray:!0===this.explicitArray,explicitRoot:!1!==this.explicitRoot,ignoreAttrs:!0===this.ignoreAttrs,mergeAttrs:!1!==this.mergeAttrs,normalize:!0===this.normalize,normalizeTags:!0===this.normalizeTags,trim:!0===this.trim});try{const t=await r.parseStringPromise(e);return{result:this.wrap(t)}}catch(e){throw new Cr("XML node could not parse XML: "+(e instanceof Error?e.message:e+""),"GRAPH_XML_PARSE_FAILED")}}const o=t;if(null==o)throw new Cr("XML node requires JSON data to convert","GRAPH_XML_INVALID_INPUT");const r=new Ve({attrkey:this.attrkey||"$",charkey:this.charkey||"_",headless:!0===this.headless,rootName:this.rootName||"root",cdata:!0===this.cdata,allowSurrogateChars:!0===this.allowSurrogateChars});try{return{result:this.wrap(r.buildObject(o))}}catch(e){throw new Cr("XML node could not build XML: "+(e instanceof Error?e.message:e+""),"GRAPH_XML_BUILD_FAILED")}}wrap(e){if(!this.destinationField)return e;const t={};return ya(t,this.destinationField,e,!0),t}xmlTextOf(e){if("string"==typeof e)return e;if(pa(e)){const t=this.dataPropertyName?fa(e,this.dataPropertyName,!0):void 0;if("string"==typeof t)return t}try{return Yd(e,"utf8",this.dataPropertyName||"data").toString("utf8")}catch{throw new Cr("XML node requires XML text to parse","GRAPH_XML_INVALID_INPUT")}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],hl.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.mode.label",type:"select"}),Ut({handle:"mode",userControlled:!0}),C("design:type",String)],hl.prototype,"mode",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.dataPropertyName.label",placeholder:"graph.node.io.xml.fields.dataPropertyName.placeholder",type:"text"}),Ut({handle:"dataPropertyName",userControlled:!0}),C("design:type",String)],hl.prototype,"dataPropertyName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.destinationField.label",placeholder:"graph.node.io.xml.fields.destinationField.placeholder",type:"text"}),Ut({handle:"destinationField",userControlled:!0}),C("design:type",String)],hl.prototype,"destinationField",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.attrkey.label",type:"text"}),Ut({handle:"attrkey",userControlled:!0}),C("design:type",String)],hl.prototype,"attrkey",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.charkey.label",type:"text"}),Ut({handle:"charkey",userControlled:!0}),C("design:type",String)],hl.prototype,"charkey",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.explicitArray.label",type:"checkbox"}),Ut({handle:"explicitArray",userControlled:!0}),C("design:type",Boolean)],hl.prototype,"explicitArray",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.explicitRoot.label",type:"checkbox"}),Ut({handle:"explicitRoot",userControlled:!0}),C("design:type",Boolean)],hl.prototype,"explicitRoot",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.ignoreAttrs.label",type:"checkbox"}),Ut({handle:"ignoreAttrs",userControlled:!0}),C("design:type",Boolean)],hl.prototype,"ignoreAttrs",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.mergeAttrs.label",type:"checkbox"}),Ut({handle:"mergeAttrs",userControlled:!0}),C("design:type",Boolean)],hl.prototype,"mergeAttrs",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.normalize.label",type:"checkbox"}),Ut({handle:"normalize",userControlled:!0}),C("design:type",Boolean)],hl.prototype,"normalize",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.normalizeTags.label",type:"checkbox"}),Ut({handle:"normalizeTags",userControlled:!0}),C("design:type",Boolean)],hl.prototype,"normalizeTags",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.trim.label",type:"checkbox"}),Ut({handle:"trim",userControlled:!0}),C("design:type",Boolean)],hl.prototype,"trim",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.cdata.label",type:"checkbox"}),Ut({handle:"cdata",userControlled:!0}),C("design:type",Boolean)],hl.prototype,"cdata",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.headless.label",type:"checkbox"}),Ut({handle:"headless",userControlled:!0}),C("design:type",Boolean)],hl.prototype,"headless",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.rootName.label",type:"text"}),Ut({handle:"rootName",userControlled:!0}),C("design:type",String)],hl.prototype,"rootName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.xml.fields.allowSurrogateChars.label",type:"checkbox"}),Ut({handle:"allowSurrogateChars",userControlled:!0}),C("design:type",Boolean)],hl.prototype,"allowSurrogateChars",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],hl.prototype,"result",void 0),hl=k([Mt("core.io.xml",{kind:"core.io.xml",category:"IO",color:"#0ea5e9",icon:"ti-code",width:96,height:96,labels:["io","xml","json","convert"],metadata:{title:"graph.node.io.xml.name",description:"graph.node.io.xml.description"}}),I()],hl);let fl=class extends Wi{async execute(){const e=this.filePath||this.path;if(!e)throw new Cr("Read Binary File node requires a file path","GRAPH_READ_BINARY_FILE_PATH_REQUIRED");const{payload:t,bytes:o}=await Zd(e);return{result:t,fileName:t.fileName,mimeType:t.mimeType,bytes:o}}};k([Ut({handle:"value"}),C("design:type",Object)],fl.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.read_binary_file.fields.filePath.label",placeholder:"graph.node.io.read_binary_file.fields.filePath.placeholder",type:"text"}),Ut({handle:"filePath",userControlled:!0}),C("design:type",String)],fl.prototype,"filePath",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.read_binary_file.fields.path.label",placeholder:"graph.node.io.read_binary_file.fields.path.placeholder",type:"text"}),Ut({handle:"path",userControlled:!0}),C("design:type",String)],fl.prototype,"path",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],fl.prototype,"result",void 0),k([$t({handle:"fileName"}),C("design:type",String)],fl.prototype,"fileName",void 0),k([$t({handle:"mimeType"}),C("design:type",String)],fl.prototype,"mimeType",void 0),k([$t({handle:"bytes"}),C("design:type",Number)],fl.prototype,"bytes",void 0),fl=k([Mt("core.io.readBinaryFile",{kind:"core.io.readBinaryFile",category:"IO",color:"#0ea5e9",icon:"ti-file-download",width:96,height:96,labels:["io","file","binary","read"],metadata:{title:"graph.node.io.read_binary_file.name",description:"graph.node.io.read_binary_file.description"}}),I()],fl);let yl=class extends Wi{async execute(){const e=this.fileSelector||this.pattern;if(!e)throw new Cr("Read Binary Files node requires a file selector pattern","GRAPH_READ_BINARY_FILES_SELECTOR_REQUIRED");const t=await(async e=>{const t=qd(),o=e.replace(/^[/\\]+/,""),r=[];for await(const e of fe(o,{cwd:t}))r.push(e);r.sort();const n=[];for(const e of r){const{candidate:o}=Vd(e),r=await zd(o);r&&(Kd(t,r,e),n.push(e))}return n})(e),o=[];let r=0;for(const e of t){const{payload:t,bytes:n}=await Zd(e);o.push(t),r+=n}return{result:o,files:o.length,bytes:r}}};k([Ut({handle:"value"}),C("design:type",Object)],yl.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.read_binary_files.fields.fileSelector.label",placeholder:"graph.node.io.read_binary_files.fields.fileSelector.placeholder",type:"text"}),Ut({handle:"fileSelector",userControlled:!0}),C("design:type",String)],yl.prototype,"fileSelector",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.read_binary_files.fields.pattern.label",placeholder:"graph.node.io.read_binary_files.fields.pattern.placeholder",type:"text"}),Ut({handle:"pattern",userControlled:!0}),C("design:type",String)],yl.prototype,"pattern",void 0),k([w(),$t({handle:"result"}),C("design:type",Array)],yl.prototype,"result",void 0),k([$t({handle:"files"}),C("design:type",Number)],yl.prototype,"files",void 0),k([$t({handle:"bytes"}),C("design:type",Number)],yl.prototype,"bytes",void 0),yl=k([Mt("core.io.readBinaryFiles",{kind:"core.io.readBinaryFiles",category:"IO",color:"#0ea5e9",icon:"ti-files",width:96,height:96,labels:["io","file","binary","glob"],metadata:{title:"graph.node.io.read_binary_files.name",description:"graph.node.io.read_binary_files.description"}}),I()],yl);let ml=class extends Wi{constructor(){super(...arguments),this.dataPropertyName="data",this.encoding="auto",this.append=!1,this.createDirectories=!0}async execute(e){const t=this.fileName||this.path;if(!t)throw new Cr("Write Binary File node requires a file path","GRAPH_WRITE_BINARY_FILE_PATH_REQUIRED");const o=e.inputs.value;if(null==o)throw new Cr("Write Binary File node requires a binary payload","GRAPH_WRITE_BINARY_FILE_CONTENT_REQUIRED");const r=Yd(o,this.encoding??"utf8",this.dataPropertyName||"data"),n=await(async(e,t,o={})=>{const{base:r,candidate:n}=Vd(e),i=await zd(n);i&&Kd(r,i,e),o.createDirectories&&await ue(te(n),{recursive:!0}),Kd(r,await ce(te(n)),e);const a=await zd(n);return a&&Kd(r,a,e),o.append?await ge(n,t):await he(n,t),{path:e,bytes:t.byteLength}})(t,r,{append:!0===this.append,createDirectories:!1!==this.createDirectories});return{result:{fileName:t,path:n.path,bytes:n.bytes},bytes:n.bytes}}};k([w(),Ut({handle:"value"}),C("design:type",Object)],ml.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.write_binary_file.fields.fileName.label",placeholder:"graph.node.io.write_binary_file.fields.fileName.placeholder",type:"text"}),Ut({handle:"fileName",userControlled:!0}),C("design:type",String)],ml.prototype,"fileName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.write_binary_file.fields.path.label",placeholder:"graph.node.io.write_binary_file.fields.path.placeholder",type:"text"}),Ut({handle:"path",userControlled:!0}),C("design:type",String)],ml.prototype,"path",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.write_binary_file.fields.dataPropertyName.label",type:"text"}),Ut({handle:"dataPropertyName",userControlled:!0}),C("design:type",String)],ml.prototype,"dataPropertyName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.write_binary_file.fields.encoding.label",type:"select"}),Ut({handle:"encoding",userControlled:!0}),C("design:type",String)],ml.prototype,"encoding",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.write_binary_file.fields.append.label",type:"checkbox"}),Ut({handle:"append",userControlled:!0}),C("design:type",Boolean)],ml.prototype,"append",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.io.write_binary_file.fields.createDirectories.label",type:"checkbox"}),Ut({handle:"createDirectories",userControlled:!0}),C("design:type",Boolean)],ml.prototype,"createDirectories",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],ml.prototype,"result",void 0),k([$t({handle:"bytes"}),C("design:type",Number)],ml.prototype,"bytes",void 0),ml=k([Mt("core.io.writeBinaryFile",{kind:"core.io.writeBinaryFile",category:"IO",color:"#0ea5e9",icon:"ti-file-upload",width:96,height:96,labels:["io","file","binary","write"],metadata:{title:"graph.node.io.write_binary_file.name",description:"graph.node.io.write_binary_file.description"}}),I()],ml);const bl=["getRepo","listIssues","createIssue","commentIssue","listPullRequests"];let wl=class extends Wi{constructor(){super(...arguments),this.operation="getRepo"}async execute(e,t){if(!this.operation)throw new Cr("GitHub node requires an operation","GRAPH_GITHUB_OPERATION_REQUIRED");const o=bl.includes(this.operation)?this.operation:"getRepo",r=await an(t,e.credentials,"github",!1,"GitHub"),n=new ze;try{switch(await xe(n,{token:Ts(r,"GitHub"),owner:this.owner,repo:this.repo,baseUrl:this.baseUrl}),o){case"getRepo":return{result:await n.getRepository({owner:this.owner,repo:this.repo})};case"listIssues":return{result:await n.listIssues({owner:this.owner,repo:this.repo,state:this.state,limit:Rs(this.limit),page:Rs(this.page),labels:this.labels?.join(",")})};case"createIssue":{if(!this.title)throw new Cr("GitHub createIssue requires a title","GRAPH_GITHUB_TITLE_REQUIRED");const t=await n.createIssue({owner:this.owner,repo:this.repo,title:this.title,body:this.body??(e.inputs.value??"")+"",labels:Os(this.labels)?.map(String),assignees:Os(this.assignees)?.map(String)});return{result:t,number:t.number,url:t.htmlUrl}}case"commentIssue":{const e=Rs(this.number);if(!e||!this.body)throw new Cr("GitHub commentIssue requires an issue number and body","GRAPH_GITHUB_COMMENT_REQUIRED");const t=await n.commentOnIssue({owner:this.owner,repo:this.repo,number:e,body:this.body});return{result:t,number:e,url:t.htmlUrl}}default:return{result:await n.listPullRequests({owner:this.owner,repo:this.repo,state:this.state,limit:Rs(this.limit),page:Rs(this.page)})}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`GitHub node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GITHUB_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],wl.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.owner.label",type:"string"}),Ut({handle:"owner",userControlled:!0}),C("design:type",String)],wl.prototype,"owner",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.repo.label",type:"string"}),Ut({handle:"repo",userControlled:!0}),C("design:type",String)],wl.prototype,"repo",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.number.label",type:"number"}),Ut({handle:"number",userControlled:!0}),C("design:type",Number)],wl.prototype,"number",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.title.label",type:"string"}),Ut({handle:"title",userControlled:!0}),C("design:type",String)],wl.prototype,"title",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.body.label",type:"textarea"}),Ut({handle:"body",userControlled:!0}),C("design:type",String)],wl.prototype,"body",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.labels.label",type:"json"}),Ut({handle:"labels",userControlled:!0}),C("design:type",Array)],wl.prototype,"labels",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.github.fields.assignees.label",type:"json"}),Ut({handle:"assignees",userControlled:!0}),C("design:type",Array)],wl.prototype,"assignees",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.state.label",type:"select"}),Ut({handle:"state",userControlled:!0}),C("design:type",String)],wl.prototype,"state",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.limit.label",type:"number"}),Ut({handle:"limit",userControlled:!0}),C("design:type",Number)],wl.prototype,"limit",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.page.label",type:"number"}),Ut({handle:"page",userControlled:!0}),C("design:type",Number)],wl.prototype,"page",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],wl.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],wl.prototype,"result",void 0),k([$t({handle:"number",type:"number"}),C("design:type",Number)],wl.prototype,"issueNumber",void 0),k([$t({handle:"url",type:"string"}),C("design:type",String)],wl.prototype,"url",void 0),wl=k([Mt("core.devops.github",{kind:"core.devops.github",category:"DevOps",color:"#24292f",icon:"ti-brand-github",width:96,height:96,labels:["devops","github","git","issues"],metadata:{title:"graph.node.devops.github.name",description:"graph.node.devops.github.description"}}),I()],wl);const vl=["getProject","listIssues","createIssue","commentIssue","listMergeRequests"];let xl=class extends Wi{constructor(){super(...arguments),this.operation="getProject"}async execute(e,t){if(!this.operation)throw new Cr("GitLab node requires an operation","GRAPH_GITLAB_OPERATION_REQUIRED");const o=vl.includes(this.operation)?this.operation:"getProject",r=await an(t,e.credentials,"gitlab",!1,"GitLab"),n=new Qe;try{switch(await xe(n,{token:Ts(r,"GitLab"),projectId:this.projectId,baseUrl:this.baseUrl}),o){case"getProject":return{result:await n.getProject(this.projectId)};case"listIssues":return{result:await n.listIssues({projectId:this.projectId,state:this.state,limit:Rs(this.limit),page:Rs(this.page),labels:Os(this.labels)?.map(String).join(","),search:this.search})};case"createIssue":{if(!this.title)throw new Cr("GitLab createIssue requires a title","GRAPH_GITLAB_TITLE_REQUIRED");const t=await n.createIssue({projectId:this.projectId,title:this.title,description:this.body??(e.inputs.value??"")+"",labels:Os(this.labels)?.map(String).join(","),assigneeIds:Os(this.assigneeIds)?.map(Number)});return{result:t,iid:t.iid,url:t.webUrl}}case"commentIssue":{const e=Rs(this.iid);if(!e||!this.body)throw new Cr("GitLab commentIssue requires an issue IID and body","GRAPH_GITLAB_COMMENT_REQUIRED");const t=await n.commentOnIssue({projectId:this.projectId,iid:e,body:this.body});return{result:t,iid:e,url:t.webUrl}}default:return{result:await n.listMergeRequests({projectId:this.projectId,state:this.state,limit:Rs(this.limit),page:Rs(this.page),search:this.search})}}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`GitLab node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_GITLAB_OPERATION_FAILED",{operation:o})}finally{await n.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],xl.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.projectId.label",type:"string"}),Ut({handle:"projectId",userControlled:!0}),C("design:type",String)],xl.prototype,"projectId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.iid.label",type:"number"}),Ut({handle:"iid",userControlled:!0}),C("design:type",Number)],xl.prototype,"iid",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.title.label",type:"string"}),Ut({handle:"title",userControlled:!0}),C("design:type",String)],xl.prototype,"title",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.body.label",type:"textarea"}),Ut({handle:"body",userControlled:!0}),C("design:type",String)],xl.prototype,"body",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.labels.label",type:"json"}),Ut({handle:"labels",userControlled:!0}),C("design:type",Array)],xl.prototype,"labels",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.assigneeIds.label",type:"json"}),Ut({handle:"assigneeIds",userControlled:!0}),C("design:type",Array)],xl.prototype,"assigneeIds",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.state.label",type:"select"}),Ut({handle:"state",userControlled:!0}),C("design:type",String)],xl.prototype,"state",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.gitlab.fields.search.label",type:"string"}),Ut({handle:"search",userControlled:!0}),C("design:type",String)],xl.prototype,"search",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.limit.label",type:"number"}),Ut({handle:"limit",userControlled:!0}),C("design:type",Number)],xl.prototype,"limit",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.page.label",type:"number"}),Ut({handle:"page",userControlled:!0}),C("design:type",Number)],xl.prototype,"page",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.common.fields.baseUrl.label",type:"string"}),Ut({handle:"baseUrl",userControlled:!0}),C("design:type",String)],xl.prototype,"baseUrl",void 0),k([$t({handle:"result"}),C("design:type",Object)],xl.prototype,"result",void 0),k([$t({handle:"iid",type:"number"}),C("design:type",Number)],xl.prototype,"issueIid",void 0),k([$t({handle:"url",type:"string"}),C("design:type",String)],xl.prototype,"url",void 0),xl=k([Mt("core.devops.gitlab",{kind:"core.devops.gitlab",category:"DevOps",color:"#fc6d26",icon:"ti-brand-gitlab",width:96,height:96,labels:["devops","gitlab","git","issues"],metadata:{title:"graph.node.devops.gitlab.name",description:"graph.node.devops.gitlab.description"}}),I()],xl);const Il={MD5:"md5",SHA1:"sha1",SHA256:"sha256",SHA384:"sha384",SHA512:"sha512","SHA3-256":"sha3-256","SHA3-384":"sha3-384","SHA3-512":"sha3-512"},_l=["hash","hmac","encrypt","decrypt","sign","verify","generate"];let El=class extends Wi{constructor(){super(...arguments),this.operation="hash",this.algorithm="SHA256",this.encoding="hex",this.keyType="rsa"}async execute(e,t){const o="Crypto",r=async r=>{const n=Ps(await an(t,e.credentials,"crypto",!0,o),r,o);if(!n)throw new Cr(o+" node credential must contain the required key material","GRAPH_CREDENTIAL_INVALID_FORMAT",{node:o});return n},n=_l.includes(this.operation)?this.operation:"hash",i=Il[this.algorithm]??Il.SHA256,a="base64"===this.encoding?"base64":"hex",s=()=>((e,t)=>{if("string"==typeof e)return e;if(null==e)throw new Cr(t+" node requires a payload","GRAPH_CRYPTO_PAYLOAD_REQUIRED");try{return JSON.stringify(e)}catch{throw new Cr(t+" node cannot serialize the payload","GRAPH_CRYPTO_INVALID_PAYLOAD")}})(this.payload??e.inputs.value,o),d=new Je;await d.boot();const l=d.client;try{switch(n){case"hash":return{result:l.createHash(i).update(s()).digest(a)};case"hmac":{const e=await r(["secret","key","password","token"]);return{result:l.createHmac(i,e).update(s()).digest(a)}}case"encrypt":{const e=await r(["secret","key","password","token"]);return{result:await d.encrypt(s(),e),encodings:["base64"]}}case"decrypt":{const e=await r(["secret","key","password","token"]),t=As(this.encryptedData);if(!t)throw new Cr("Crypto node decrypt requires encryptedData","GRAPH_CRYPTO_ENCRYPTED_DATA_REQUIRED");const o=As(this.salt);if(!o)throw new Cr("Crypto node decrypt requires the encryption salt","GRAPH_CRYPTO_SALT_REQUIRED");return{result:await d.decrypt(t,e,o)}}case"sign":{const e=await r(["privateKey","key","secret","token"]);return{result:l.createSign(i).update(s()).sign(e,a)}}case"verify":{const e=As(this.publicKey)??await r(["publicKey","key","secret","token"]),t=As(this.signature);if(!t)throw new Cr("Crypto node verify requires a signature","GRAPH_CRYPTO_SIGNATURE_REQUIRED");return{result:l.createVerify(i).update(s()).verify(e,t,a)}}case"generate":{const e=this.keyType??"rsa";return"ed25519"===e?{result:l.generateKeyPairSync("ed25519",{publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}})}:"ec"===e?{result:l.generateKeyPairSync("ec",{namedCurve:As(this.namedCurve)??"prime256v1",publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}})}:{result:l.generateKeyPairSync("rsa",{modulusLength:Math.max(2048,Math.floor(this.modulusLength??2048)),publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}})}}default:throw new Cr(`Crypto node operation '${n}' is not supported`,"GRAPH_CRYPTO_OPERATION_NOT_SUPPORTED",{operation:n})}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`Crypto node operation '${n}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_CRYPTO_OPERATION_FAILED",{operation:n})}finally{await d.shutdown().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],El.prototype,"operation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.algorithm.label",type:"select"}),Ut({handle:"algorithm",userControlled:!0}),C("design:type",String)],El.prototype,"algorithm",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.encoding.label",type:"select"}),Ut({handle:"encoding",userControlled:!0}),C("design:type",String)],El.prototype,"encoding",void 0),k([Ut({handle:"value"}),C("design:type",Object)],El.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.payload.label",type:"textarea"}),Ut({handle:"payload",userControlled:!0}),C("design:type",Object)],El.prototype,"payload",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.encryptedData.label",type:"textarea"}),Ut({handle:"encryptedData",userControlled:!0}),C("design:type",String)],El.prototype,"encryptedData",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.salt.label",type:"string"}),Ut({handle:"salt",userControlled:!0}),C("design:type",String)],El.prototype,"salt",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.publicKey.label",type:"textarea"}),Ut({handle:"publicKey",userControlled:!0}),C("design:type",String)],El.prototype,"publicKey",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.signature.label",type:"textarea"}),Ut({handle:"signature",userControlled:!0}),C("design:type",String)],El.prototype,"signature",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.keyType.label",type:"select"}),Ut({handle:"keyType",userControlled:!0}),C("design:type",String)],El.prototype,"keyType",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.modulusLength.label",type:"number"}),Ut({handle:"modulusLength",userControlled:!0}),C("design:type",Number)],El.prototype,"modulusLength",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.crypto.fields.namedCurve.label",type:"string"}),Ut({handle:"namedCurve",userControlled:!0}),C("design:type",String)],El.prototype,"namedCurve",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],El.prototype,"result",void 0),k([$t({handle:"encodings",type:"array"}),C("design:type",Array)],El.prototype,"encodings",void 0),El=k([Mt("core.devops.crypto",{kind:"core.devops.crypto",category:"DevOps",color:"#7c3aed",icon:"ti-lock",width:96,height:96,labels:["devops","crypto","hash","encrypt","sign"],metadata:{title:"graph.node.devops.crypto.name",description:"graph.node.devops.crypto.description"}}),I()],El);const Al=["sign","verify","decode"];let Sl=class extends Wi{constructor(){super(...arguments),this.operation="decode"}async execute(e,t){const o=Al.includes(this.operation)?this.operation:"decode",r=As(this.token)??As(e.inputs.value);if("sign"!==o&&!r)throw new Cr(`JWT node operation '${o}' requires a token`,"GRAPH_JWT_TOKEN_REQUIRED",{operation:o});try{if("sign"===o){const o=await an(t,e.credentials,"jwt",!0,"JWT"),r=(e=>{if("string"==typeof e&&e.trim().startsWith("{"))try{return Es(JSON.parse(e))??{}}catch{throw new Cr("JWT node claims must be a JSON object","GRAPH_JWT_INVALID_CLAIMS")}const t=Es(e);if(!t)throw new Cr("JWT node sign operation requires claims","GRAPH_JWT_CLAIMS_REQUIRED");return t})(this.claims??e.inputs.value),n={secret:o,expiry:As(this.expiry)??"1h"},i=await Xe(r,n);return{result:i,token:i}}if("verify"===o){const o=await an(t,e.credentials,"jwt",!1,"JWT"),n=As(this.verifyUrl);if(!o&&!n)throw new Cr("JWT node verify requires a secret credential or verifyUrl","GRAPH_JWT_VERIFICATION_NOT_CONFIGURED");const i=await Ye(r,{secret:"string"==typeof o?o:As(o?.secret),verifyUrl:n,clockToleranceSeconds:Rs(this.clockToleranceSeconds)});return{result:i,payload:i}}const n=Ze(r);return{result:n??null,payload:n??null}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`JWT node operation '${o}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_JWT_OPERATION_FAILED",{operation:o})}}};function Rl(e,t="utf8"){const o=Buffer.isBuffer(e)?e:Buffer.from(e??"",t);return o.length>vr?{value:o.subarray(0,vr).toString(t),truncated:!0}:{value:o.toString(t),truncated:!1}}k([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Sl.prototype,"operation",void 0),k([Ut({handle:"value"}),C("design:type",Object)],Sl.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.token.label",type:"textarea"}),Ut({handle:"token",userControlled:!0}),C("design:type",String)],Sl.prototype,"token",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.claims.label",type:"object"}),Ut({handle:"claims",userControlled:!0}),C("design:type",Object)],Sl.prototype,"claims",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.expiry.label",type:"string"}),Ut({handle:"expiry",userControlled:!0}),C("design:type",String)],Sl.prototype,"expiry",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.verifyUrl.label",type:"string"}),Ut({handle:"verifyUrl",userControlled:!0}),C("design:type",String)],Sl.prototype,"verifyUrl",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.jwt.fields.clockToleranceSeconds.label",type:"number"}),Ut({handle:"clockToleranceSeconds",userControlled:!0}),C("design:type",Number)],Sl.prototype,"clockToleranceSeconds",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],Sl.prototype,"result",void 0),k([$t({handle:"token"}),C("design:type",String)],Sl.prototype,"tokenOutput",void 0),k([$t({handle:"payload"}),C("design:type",Object)],Sl.prototype,"payload",void 0),Sl=k([Mt("core.devops.jwt",{kind:"core.devops.jwt",category:"DevOps",color:"#0f766e",icon:"ti-key",width:96,height:96,labels:["devops","jwt","token","auth"],metadata:{title:"graph.node.devops.jwt.name",description:"graph.node.devops.jwt.description"}}),I()],Sl);let Ol=class extends Wi{constructor(){super(...arguments),this.failOnError=!1}async execute(e,t){const o=As(this.command);if(!o)throw new Cr("Execute Command node requires a command","GRAPH_EXECUTE_COMMAND_REQUIRED");const r=Math.min(6e4,Math.max(1,Math.floor(Rs(this.timeoutMs)??3e4))),n=await new Promise(e=>{et(o,{timeout:r,maxBuffer:vr,cwd:As(this.cwd),shell:As(this.shell),signal:t.abortSignal,windowsHide:!0},(t,o,r)=>{const n=Rl(o),i=Rl(r),a=t?.code;e({stdout:n.value,stderr:i.value,exitCode:"number"==typeof a?a:t?null:0,error:t??void 0,truncated:n.truncated||i.truncated})})});if(n.error&&this.failOnError)throw new Cr("Execute Command node command failed: "+n.error.message,"GRAPH_EXECUTE_COMMAND_FAILED",{exitCode:n.exitCode});return{result:{stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode,truncated:n.truncated},stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode}}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.command.label",type:"textarea"}),Ut({handle:"command",userControlled:!0}),C("design:type",String)],Ol.prototype,"command",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.cwd.label",type:"string"}),Ut({handle:"cwd",userControlled:!0}),C("design:type",String)],Ol.prototype,"cwd",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.shell.label",type:"string"}),Ut({handle:"shell",userControlled:!0}),C("design:type",String)],Ol.prototype,"shell",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.timeoutMs.label",type:"number"}),Ut({handle:"timeoutMs",userControlled:!0}),C("design:type",Number)],Ol.prototype,"timeoutMs",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.execute_command.fields.failOnError.label",type:"boolean"}),Ut({handle:"failOnError",userControlled:!0}),C("design:type",Boolean)],Ol.prototype,"failOnError",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],Ol.prototype,"result",void 0),k([$t({handle:"stdout"}),C("design:type",String)],Ol.prototype,"stdout",void 0),k([$t({handle:"stderr"}),C("design:type",String)],Ol.prototype,"stderr",void 0),k([$t({handle:"exitCode",type:"number"}),C("design:type",Object)],Ol.prototype,"exitCode",void 0),Ol=k([Mt("core.devops.executeCommand",{kind:"core.devops.executeCommand",category:"DevOps",color:"#334155",icon:"ti-terminal-2",width:96,height:96,labels:["devops","shell","command","process"],metadata:{title:"graph.node.devops.execute_command.name",description:"graph.node.devops.execute_command.description"}}),I()],Ol);const kl=["list","download","delete"];function Cl(e){if(!e)return{};if("string"!=typeof e)return{password:As(e.password),privateKey:As(e.privateKey),passphrase:As(e.passphrase)};if(!e.trim().startsWith("{"))return{password:e};const t=ks(e,"FTP");return{password:As(t.password),privateKey:As(t.privateKey),passphrase:As(t.passphrase)}}let Nl=class extends Wi{constructor(){super(...arguments),this.operation="list",this.encoding="utf8"}async execute(e,t){const o=As(this.host),r=As(this.username);if(!o||!r)throw new Cr("FTP node requires host and username","GRAPH_FTP_CONNECTION_REQUIRED");const n=kl.includes(this.operation)?this.operation:"list",i=As(this.path);if("list"!==n&&!i)throw new Cr(`FTP node operation '${n}' requires a path`,"GRAPH_FTP_PATH_REQUIRED",{operation:n});const a=await an(t,e.credentials,"sftp",!1,"FTP"),s={provider:"ssh2",sourceId:As(this.sourceId)??"graph",host:o,port:Rs(this.port)??22,username:r,remotePath:As(this.remotePath),...Cl(a)},d=new tt;try{if(await d.initialize(s),"list"===n)return{result:await d.list(i)};if("delete"===n)return await d.delete(i),{result:{path:i,deleted:!0}};const e=await d.fetch(i);return{result:{path:e.path,name:e.name,size:e.size},content:"base64"===this.encoding?e.content.toString("base64"):e.content.toString("utf8"),size:e.size}}catch(e){if(e instanceof Cr)throw e;throw new Cr(`FTP node operation '${n}' failed: ${e instanceof Error?e.message:e+""}`,"GRAPH_FTP_OPERATION_FAILED",{operation:n})}finally{await d.close().catch(()=>{})}}};k([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.operation.label",type:"select"}),Ut({handle:"operation",userControlled:!0}),C("design:type",String)],Nl.prototype,"operation",void 0),k([w(),i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.host.label",type:"string"}),Ut({handle:"host",userControlled:!0}),C("design:type",String)],Nl.prototype,"host",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.port.label",type:"number"}),Ut({handle:"port",userControlled:!0}),C("design:type",Number)],Nl.prototype,"port",void 0),k([w(),i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.username.label",type:"string"}),Ut({handle:"username",userControlled:!0}),C("design:type",String)],Nl.prototype,"username",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.sourceId.label",type:"string"}),Ut({handle:"sourceId",userControlled:!0}),C("design:type",String)],Nl.prototype,"sourceId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.remotePath.label",type:"string"}),Ut({handle:"remotePath",userControlled:!0}),C("design:type",String)],Nl.prototype,"remotePath",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.path.label",type:"string"}),Ut({handle:"path",userControlled:!0}),C("design:type",String)],Nl.prototype,"path",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.devops.ftp.fields.encoding.label",type:"select"}),Ut({handle:"encoding",userControlled:!0}),C("design:type",String)],Nl.prototype,"encoding",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],Nl.prototype,"result",void 0),k([$t({handle:"content"}),C("design:type",String)],Nl.prototype,"content",void 0),k([$t({handle:"size",type:"number"}),C("design:type",Number)],Nl.prototype,"size",void 0),Nl=k([Mt("core.devops.ftp",{kind:"core.devops.ftp",category:"DevOps",color:"#0ea5e9",icon:"ti-folder-symlink",width:96,height:96,labels:["devops","ftp","sftp","files"],metadata:{title:"graph.node.devops.ftp.name",description:"graph.node.devops.ftp.description"}}),I()],Nl);let Tl=class extends Wi{constructor(){super(...arguments),this.mode="once",this.inputPort="value"}async execute(e,t){const o=t.engine;if(!o)throw new Cr("Execute Sub-workflow node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");const r=await this.documentOf(o,t),n=this.inputPort||"value",i=e.inputs.value??e.inputs.input;if("perItem"===this.mode){const e=[];let a,s;for(const d of ua(i)){const i=await o.execute(r,{[n]:d},{parentRunId:t.runId,path:[...t.path,"subworkflow"],auth:t.auth,metadata:{...t.metadata,item:d}},t);e.push(i.outputs.result??i.outputs),a=i.outputs,s=i.runId}return{result:e,outputs:a,childRunId:s}}const a=await o.execute(r,{[n]:i},{parentRunId:t.runId,path:[...t.path,"subworkflow"],auth:t.auth,metadata:t.metadata},t);return{result:a.outputs.result??a.outputs,outputs:a.outputs,childRunId:a.runId}}async documentOf(e,t){if(pa(o=this.workflow)&&"string"==typeof o.id&&Array.isArray(o.nodes)&&Array.isArray(o.edges))return this.workflow;var o;const r=this.workflowId;if(!r)throw new Cr("Execute Sub-workflow node requires a workflow id or an inline workflow document","GRAPH_SUB_WORKFLOW_REQUIRED");try{return await e.getWorkflow(r,t)}catch(e){throw new Cr(`Execute Sub-workflow node could not resolve workflow '${r}': ${e instanceof Error?e.message:e+""}`,"GRAPH_SUB_WORKFLOW_NOT_FOUND",{workflowId:r})}}};k([Ut({handle:"value"}),C("design:type",Object)],Tl.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.workflowId.label",placeholder:"graph.node.flow_control.execute_sub_workflow.fields.workflowId.placeholder",type:"text"}),Ut({handle:"workflowId",userControlled:!0}),C("design:type",String)],Tl.prototype,"workflowId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.workflow.label",type:"json"}),Ut({handle:"workflow",userControlled:!0,type:"object"}),C("design:type",Object)],Tl.prototype,"workflow",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.mode.label",type:"select"}),Ut({handle:"mode",userControlled:!0}),C("design:type",String)],Tl.prototype,"mode",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.flow_control.execute_sub_workflow.fields.inputPort.label",placeholder:"graph.node.flow_control.execute_sub_workflow.fields.inputPort.placeholder",type:"text"}),Ut({handle:"inputPort",userControlled:!0}),C("design:type",String)],Tl.prototype,"inputPort",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],Tl.prototype,"result",void 0),k([$t({handle:"outputs"}),C("design:type",Object)],Tl.prototype,"outputs",void 0),k([$t({handle:"childRunId"}),C("design:type",String)],Tl.prototype,"childRunId",void 0),Tl=k([Mt("core.flow.executeSubWorkflow",{kind:"core.flow.executeSubWorkflow",category:"Flow Control",color:"#f59e0b",icon:"ti-subtask",width:96,height:96,labels:["flow","workflow","subworkflow"],metadata:{title:"graph.node.flow_control.execute_sub_workflow.name",description:"graph.node.flow_control.execute_sub_workflow.description"}}),I()],Tl);let Pl=class extends Wi{execute(e){const t=e.inputs.payload;return{result:void 0!==t?t:e.inputs.value??e.inputs}}};k([Ut({handle:"payload"}),C("design:type",Object)],Pl.prototype,"payload",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.trigger.execute_workflow.fields.schema.label",placeholder:"graph.node.trigger.execute_workflow.fields.schema.placeholder",type:"json"}),Ut({handle:"schema",userControlled:!0,type:"object"}),C("design:type",Object)],Pl.prototype,"schema",void 0),k([w(),$t({handle:"result"}),C("design:type",Object)],Pl.prototype,"result",void 0),Pl=k([Mt("core.trigger.executeWorkflow",{kind:"core.trigger.executeWorkflow",category:"Trigger",color:"#3b82f6",icon:"ti-player-play",width:96,height:96,labels:["trigger","workflow","subworkflow"],metadata:{title:"graph.node.trigger.execute_workflow.name",description:"graph.node.trigger.execute_workflow.description",trigger:{type:"executeWorkflow"}}}),I()],Pl);let Dl=class extends Wi{execute(e){return{message:e.inputs.message??null,sessionId:e.inputs.sessionId??null,userId:e.inputs.userId??null}}};k([w(),$t({handle:"message"}),C("design:type",String)],Dl.prototype,"message",void 0),k([w(),$t({handle:"sessionId"}),C("design:type",String)],Dl.prototype,"sessionId",void 0),k([w(),$t({handle:"userId"}),C("design:type",String)],Dl.prototype,"userId",void 0),Dl=k([Mt("core.trigger.chat",{kind:"core.trigger.chat",category:"Trigger",color:"#3b82f6",icon:"ti-message-circle",width:96,height:96,labels:["trigger","chat","entrypoint"],metadata:{title:"graph.node.trigger.chat.name",description:"graph.node.trigger.chat.description",trigger:{type:"chat"}}}),I()],Dl);let jl=class extends Wi{execute(e){return{payload:e.inputs.payload??null}}};k([w(),$t({handle:"payload"}),C("design:type",Object)],jl.prototype,"payload",void 0),jl=k([Mt("core.trigger.event",{kind:"core.trigger.event",category:"Trigger",color:"#3b82f6",icon:"ti-broadcast",width:96,height:96,labels:["trigger","event","bus"],metadata:{title:"graph.node.trigger.event.name",description:"graph.node.trigger.event.description",trigger:{type:"event",topic:"default"}}}),I()],jl);let Ll=class extends Wi{execute(e){return{payload:e.inputs.payload??null}}};k([w(),Ut({handle:"schema"}),i("ngx-decaf-model-builder",{label:"graph.node.trigger.form.fields.schema.label",placeholder:"graph.node.trigger.form.fields.schema.placeholder"}),C("design:type",Object)],Ll.prototype,"schema",void 0),k([w(),$t({handle:"payload"}),C("design:type",Object)],Ll.prototype,"payload",void 0),Ll=k([Mt("core.trigger.form",{kind:"core.trigger.form",category:"Trigger",color:"#3b82f6",icon:"ti-forms",width:96,height:96,labels:["trigger","form","public"],metadata:{title:"graph.node.trigger.form.name",description:"graph.node.trigger.form.description",trigger:{type:"form",fields:[]}}}),I()],Ll);let Ml=class extends Wi{execute(e){return{payload:e.inputs.payload??null}}};k([w(),$t({handle:"payload"}),C("design:type",Object)],Ml.prototype,"payload",void 0),Ml=k([Mt("core.trigger.manual",{kind:"core.trigger.manual",category:"Trigger",color:"#3b82f6",icon:"ti-hand-click",width:96,height:96,labels:["trigger","manual","entrypoint"],metadata:{title:"graph.node.trigger.manual.name",description:"graph.node.trigger.manual.description",trigger:{type:"manual",inputSchema:{}}}}),I()],Ml);let Gl=class extends Wi{execute(e){return{payload:e.inputs.payload??null}}};k([w(),Ut({handle:"cron"}),i("app-cron-selector-field",{label:"graph.node.trigger.schedule.fields.cron.label",placeholder:"graph.node.trigger.schedule.fields.cron.placeholder"}),C("design:type",String)],Gl.prototype,"cron",void 0),k([w(),$t({handle:"payload"}),C("design:type",Object)],Gl.prototype,"payload",void 0),Gl=k([Mt("core.trigger.schedule",{kind:"core.trigger.schedule",category:"Trigger",color:"#3b82f6",icon:"ti-calendar-time",width:96,height:96,labels:["trigger","schedule","cron"],metadata:{title:"graph.node.trigger.schedule.name",description:"graph.node.trigger.schedule.description",trigger:{type:"schedule",schedule:"0 * * * *",timezone:"UTC"}}}),I()],Gl);let Ul=class extends Wi{execute(e){return{payload:e.inputs.payload??null}}};k([w(),Ut({handle:"schema"}),i("ngx-decaf-model-builder",{label:"graph.node.trigger.webhook.fields.schema.label",placeholder:"graph.node.trigger.webhook.fields.schema.placeholder"}),C("design:type",Object)],Ul.prototype,"schema",void 0),k([w(),$t({handle:"payload"}),C("design:type",Object)],Ul.prototype,"payload",void 0),Ul=k([Mt("core.trigger.webhook",{kind:"core.trigger.webhook",category:"Trigger",color:"#3b82f6",icon:"ti-webhook",width:96,height:96,labels:["trigger","webhook","http"],metadata:{title:"graph.node.trigger.webhook.name",description:"graph.node.trigger.webhook.description",trigger:{type:"webhook",path:"/webhook",method:"POST",auth:"none",responseMode:"onReceived"}}}),I()],Ul);let $l=class extends Wi{execute(e){const t=this.payload??e.inputs.payload??e.inputs.value??e.inputs,o=Es(t)??{value:t},r=Es(o.execution)??Es(e.inputs.execution),n=Es(o.workflow)??Es(e.inputs.workflow),i=Es(r?.error)??Es(o.error)??Es(e.inputs.error);return{payload:o,...r?{execution:r}:{},...n?{workflow:n}:{},...i?{error:i}:{}}}};k([Ut({handle:"payload",type:"object"}),C("design:type",Object)],$l.prototype,"payload",void 0),k([w(),$t({handle:"payload",type:"object"}),C("design:type",Object)],$l.prototype,"payloadOut",void 0),k([$t({handle:"execution",type:"object"}),C("design:type",Object)],$l.prototype,"execution",void 0),k([$t({handle:"workflow",type:"object"}),C("design:type",Object)],$l.prototype,"workflow",void 0),k([$t({handle:"error",type:"object"}),C("design:type",Object)],$l.prototype,"error",void 0),$l=k([Mt("core.trigger.error",{kind:"core.trigger.error",category:"Trigger",color:"#3b82f6",icon:"ti-alert-triangle",width:96,height:96,labels:["trigger","error","failure","workflow"],metadata:{title:"graph.node.trigger.error.name",description:"graph.node.trigger.error.description",trigger:{type:"error"}}}),I()],$l);const Fl={activate:"Workflow activated",update:"Workflow updated"};function Hl(e){if("string"!=typeof e)return;const t=e.trim().toLowerCase();return"activate"===t||"workflow activated"===t?"activate":"update"===t||"workflow updated"===t?"update":void 0}let Bl=class extends Wi{constructor(){super(...arguments),this.events=["activate"]}execute(e){const t=Es(this.payload??e.inputs.payload),o=this.event??e.inputs.event??t?.event??t?.workflow_event,r=(e=>{const t=(Array.isArray(e)?e:"string"==typeof e?e.split(","):[]).map(e=>Hl(e)).filter(e=>void 0!==e);return t.length?t:["activate"]})(this.events),n=void 0===o?r[0]:Hl(o);if(!n)throw new Cr(`Workflow trigger received an unsupported event '${o+""}'`,"GRAPH_WORKFLOW_TRIGGER_EVENT_INVALID",{event:o});if(!r.includes(n))throw new Cr(`Workflow trigger is not configured for the '${n}' event`,"GRAPH_WORKFLOW_TRIGGER_EVENT_NOT_CONFIGURED",{event:n,events:r});const i=this.timestamp??e.inputs.timestamp??("string"==typeof t?.timestamp?t.timestamp:void 0)??(new Date).toISOString(),a=this.workflowId??e.inputs.workflowId??("string"==typeof t?.workflow_id?t.workflow_id:void 0);return{payload:t??{event:Fl[n],timestamp:i,...a?{workflow_id:a}:{}},event:n,timestamp:i,...a?{workflowId:a}:{}}}};function ql(e){const t=Rs(e);return t&&t>0?Math.floor(t):3e4}function Wl(e,t){if(!t)return e;try{return JSON.parse(e)}catch{return e}}function Kl(e,t,o){return o instanceof Cr?o:new Cr(`${e} trigger failed: ${o instanceof Error?o.message:o+""}`,t,{cause:o instanceof Error?o.name:typeof o})}function Vl(e){if(e)try{Promise.resolve(e()).catch(()=>{})}catch{}}async function zl(e,t,o,r,n){let i,a;const s=e.abortSignal;let d;try{return await new Promise((e,l)=>{let c=!1;const p=e=>{c||(c=!0,e())};if(a=setTimeout(()=>p(()=>l(new Cr(n,r,{timeoutMs:t}))),t),s){if(d=()=>p(()=>l(new Cr("The trigger wait was aborted because the run was cancelled or timed out","GRAPH_TRIGGER_ABORTED"))),s.aborted)return void d();s.addEventListener("abort",d,{once:!0})}Promise.resolve(o(t=>p(()=>e(t)),e=>p(()=>l(e)))).then(e=>{i=e,c&&Vl(e)}).catch(e=>p(()=>l(e)))})}finally{a&&clearTimeout(a),d&&s&&s.removeEventListener("abort",d),Vl(i)}}function Ql(e){const t=e?.timestamp,o={contentType:e?.contentType,contentEncoding:e?.contentEncoding,correlationId:e?.correlationId,replyTo:e?.replyTo,messageId:e?.messageId,type:e?.type,appId:e?.appId,timestamp:t instanceof Date?t.toISOString():void 0===t?void 0:t+""};for(const[e,t]of Object.entries(o))void 0===t&&delete o[e];return o}k([w(),Ut({handle:"events",userControlled:!0,type:"array"}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.workflow.fields.events.label",type:"select"}),C("design:type",Array)],Bl.prototype,"events",void 0),k([Ut({handle:"event"}),C("design:type",Object)],Bl.prototype,"event",void 0),k([Ut({handle:"payload",type:"object"}),C("design:type",Object)],Bl.prototype,"payload",void 0),k([Ut({handle:"timestamp"}),C("design:type",Object)],Bl.prototype,"timestamp",void 0),k([Ut({handle:"workflowId"}),C("design:type",Object)],Bl.prototype,"workflowId",void 0),k([w(),$t({handle:"payload",type:"object"}),C("design:type",Object)],Bl.prototype,"payloadOut",void 0),k([$t({handle:"event"}),C("design:type",String)],Bl.prototype,"eventOut",void 0),k([$t({handle:"timestamp"}),C("design:type",String)],Bl.prototype,"timestampOut",void 0),k([$t({handle:"workflowId"}),C("design:type",String)],Bl.prototype,"workflowIdOut",void 0),Bl=k([Mt("core.trigger.workflow",{kind:"core.trigger.workflow",category:"Trigger",color:"#3b82f6",icon:"ti-git-branch",width:96,height:96,labels:["trigger","workflow","lifecycle","activate","update"],metadata:{title:"graph.node.trigger.workflow.name",description:"graph.node.trigger.workflow.description",trigger:{type:"workflow",events:["activate"]}}}),I()],Bl);let Jl=class extends Wi{constructor(){super(...arguments),this.ssl=!1,this.jsonParseBody=!1}async execute(e,t){const o=As(this.queue);if(!o)throw new Cr("RabbitMQ trigger requires a queue","GRAPH_RABBITMQ_TRIGGER_QUEUE_REQUIRED");const r=As(this.exchange),n=As(this.routingKey)??"",i=Ps(await an(t,e.credentials,"rabbitmq",!1,"RabbitMQ trigger"),["password","secret","token"],"RabbitMQ trigger"),a=Ss(this.ssl,!1),s=ql(this.timeoutMs);let d,l;try{d=await be({protocol:a?"amqps":"amqp",hostname:As(this.host)??"localhost",port:Rs(this.port)??(a?5671:5672),username:As(this.username)??"guest",password:i,vhost:As(this.vhost)??"/",heartbeat:10}),l=await d.createChannel(),await l.assertQueue(o,{durable:!0}),r&&(await l.assertExchange(r,As(this.exchangeType)??"topic",{durable:!0}),await l.bindQueue(o,r,n)),await l.prefetch(1);const e=await zl(t,s,async e=>{const r=await l.consume(o,t=>{if(!t)return;const o=t.content.toString("utf8");try{l.ack(t)}catch{}e({message:o,properties:Ql(t.properties)})},{noAck:!1});return await t.log("RabbitMQ trigger subscribed",{queue:o}),async()=>{await l.cancel(r.consumerTag).catch(()=>{})}},"GRAPH_TRIGGER_TIMEOUT",`RabbitMQ trigger received no message within ${s}ms`);return{payload:Wl(e.message,!0===this.jsonParseBody),message:e.message,queue:o,properties:e.properties}}catch(e){throw Kl("RabbitMQ","GRAPH_RABBITMQ_TRIGGER_FAILED",e)}finally{await(l?.close().catch(()=>{})),await(d?.close().catch(()=>{}))}}};k([w(),Ut({handle:"queue"}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.queue.label",placeholder:"queue-name",type:"string"}),C("design:type",String)],Jl.prototype,"queue",void 0),k([Ut({handle:"exchange",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.exchange.label",type:"string"}),C("design:type",String)],Jl.prototype,"exchange",void 0),k([Ut({handle:"exchangeType",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.exchangeType.label",type:"string"}),C("design:type",String)],Jl.prototype,"exchangeType",void 0),k([Ut({handle:"routingKey",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.routingKey.label",type:"string"}),C("design:type",String)],Jl.prototype,"routingKey",void 0),k([Ut({handle:"host",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.host.label",type:"string"}),C("design:type",String)],Jl.prototype,"host",void 0),k([Ut({handle:"port",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.port.label",type:"number"}),C("design:type",Number)],Jl.prototype,"port",void 0),k([Ut({handle:"username",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.username.label",type:"string"}),C("design:type",String)],Jl.prototype,"username",void 0),k([Ut({handle:"vhost",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.vhost.label",type:"string"}),C("design:type",String)],Jl.prototype,"vhost",void 0),k([Ut({handle:"ssl",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.ssl.label",type:"boolean"}),C("design:type",Boolean)],Jl.prototype,"ssl",void 0),k([Ut({handle:"jsonParseBody",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.jsonParseBody.label",type:"boolean"}),C("design:type",Boolean)],Jl.prototype,"jsonParseBody",void 0),k([Ut({handle:"timeoutMs",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.rabbitmq.fields.timeoutMs.label",type:"number"}),C("design:type",Number)],Jl.prototype,"timeoutMs",void 0),k([w(),$t({handle:"payload"}),C("design:type",Object)],Jl.prototype,"payload",void 0),k([$t({handle:"message"}),C("design:type",String)],Jl.prototype,"message",void 0),k([$t({handle:"queue"}),C("design:type",String)],Jl.prototype,"queueOutput",void 0),k([$t({handle:"properties",type:"object"}),C("design:type",Object)],Jl.prototype,"properties",void 0),Jl=k([Mt("core.trigger.rabbitmq",{kind:"core.trigger.rabbitmq",category:"Trigger",color:"#3b82f6",icon:"ti-inbox",width:96,height:96,labels:["trigger","rabbitmq","amqp","queue"],metadata:{title:"graph.node.trigger.rabbitmq.name",description:"graph.node.trigger.rabbitmq.description",trigger:{type:"rabbitmq",queue:"",jsonParseBody:!1}}}),I()],Jl);let Xl=class extends Wi{constructor(){super(...arguments),this.tls=!1,this.jsonParseBody=!1}async execute(e,t){const o=As(this.channels);if(!o)throw new Cr("Redis trigger requires at least one channel","GRAPH_REDIS_TRIGGER_CHANNELS_REQUIRED");const r=As(this.prefix),n=o.split(",").map(e=>e.trim()).filter(e=>e.length>0).map(e=>r?`${r}:${e}`:e);if(!n.length)throw new Cr("Redis trigger requires at least one channel","GRAPH_REDIS_TRIGGER_CHANNELS_REQUIRED");const i=Ps(await an(t,e.credentials,"redis",!1,"Redis trigger"),["password","secret","token"],"Redis trigger"),a=ql(this.timeoutMs),s=`as-graph-redis-trigger-${Date.now()}-${Math.random().toString(36).slice(2)}`,d=new me({host:As(this.host)??"localhost",port:Rs(this.port)??6379,username:As(this.username),password:i,database:Rs(this.database),tls:!!this.tls||void 0},s);try{await d.initialize();const e=d.client,o=await zl(t,a,async o=>{for(const t of n)await e.pSubscribe(t,(e,t)=>o({channel:t,message:e}));return await t.log("Redis trigger subscribed",{channels:n}),async()=>{await e.pUnsubscribe().catch(()=>{})}},"GRAPH_TRIGGER_TIMEOUT",`Redis trigger received no message within ${a}ms`);return{payload:Wl(o.message,!0===this.jsonParseBody),message:o.message,channel:o.channel}}catch(e){throw Kl("Redis","GRAPH_REDIS_TRIGGER_FAILED",e)}finally{await d.shutdown().catch(()=>{}),V.unregister(s)}}};k([w(),Ut({handle:"channels"}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.channels.label",placeholder:"graph.node.trigger.redis.fields.channels.placeholder",type:"string"}),C("design:type",String)],Xl.prototype,"channels",void 0),k([Ut({handle:"host",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.host.label",type:"string"}),C("design:type",String)],Xl.prototype,"host",void 0),k([Ut({handle:"port",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.port.label",type:"number"}),C("design:type",Number)],Xl.prototype,"port",void 0),k([Ut({handle:"username",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.username.label",type:"string"}),C("design:type",String)],Xl.prototype,"username",void 0),k([Ut({handle:"database",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.database.label",type:"number"}),C("design:type",Number)],Xl.prototype,"database",void 0),k([Ut({handle:"tls",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.tls.label",type:"boolean"}),C("design:type",Boolean)],Xl.prototype,"tls",void 0),k([Ut({handle:"prefix",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.prefix.label",type:"string"}),C("design:type",String)],Xl.prototype,"prefix",void 0),k([Ut({handle:"jsonParseBody",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.jsonParseBody.label",type:"boolean"}),C("design:type",Boolean)],Xl.prototype,"jsonParseBody",void 0),k([Ut({handle:"timeoutMs",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.redis.fields.timeoutMs.label",type:"number"}),C("design:type",Number)],Xl.prototype,"timeoutMs",void 0),k([w(),$t({handle:"payload"}),C("design:type",Object)],Xl.prototype,"payload",void 0),k([$t({handle:"message"}),C("design:type",String)],Xl.prototype,"message",void 0),k([$t({handle:"channel"}),C("design:type",String)],Xl.prototype,"channel",void 0),Xl=k([Mt("core.trigger.redis",{kind:"core.trigger.redis",category:"Trigger",color:"#3b82f6",icon:"ti-brand-redis",width:96,height:96,labels:["trigger","redis","pubsub","channel"],metadata:{title:"graph.node.trigger.redis.name",description:"graph.node.trigger.redis.description",trigger:{type:"redis",channels:"",jsonParseBody:!1}}}),I()],Xl);let Yl=class extends Wi{constructor(){super(...arguments),this.jsonParseBody=!0}async execute(e,t){const o=As(this.url);if(!o)throw new Cr("SSE trigger requires a URL","GRAPH_SSE_TRIGGER_URL_REQUIRED");let r;try{r=new URL(o)}catch{throw new Cr("SSE trigger URL is not a valid URL","GRAPH_SSE_TRIGGER_URL_INVALID")}const n=Ps(await an(t,e.credentials,"token",!1,"SSE trigger"),["token","secret","apiKey"],"SSE trigger"),{url:i,authorization:a}=(e=>{if(!e.username&&!e.password)return{url:e};const t=`${decodeURIComponent(e.username)}:${decodeURIComponent(e.password)}`,o=new URL(e.toString());return o.username="",o.password="",{url:o,authorization:"Basic "+Buffer.from(t,"utf8").toString("base64")}})(r),s=n?"Bearer "+n:a,d=ql(this.timeoutMs);let l;try{const e=await zl(t,d,(e,o)=>(l=new ot(i,{fetch:(e,t)=>fetch(e,{...t,headers:s?{...t.headers,Authorization:s}:t.headers})}),l.onopen=()=>{t.log("SSE trigger connected",{url:i.toString()}).catch(()=>{})},l.onmessage=t=>e({data:t.data,event:t.type||"message",id:t.lastEventId??""}),l.onerror=e=>{const t=void 0===e.code?"":` (HTTP ${e.code})`;o(new Cr(`SSE trigger connection failed${t}: ${e.message??"unknown error"}`,"GRAPH_SSE_TRIGGER_FAILED"))},()=>l?.close()),"GRAPH_TRIGGER_TIMEOUT",`SSE trigger received no event within ${d}ms`);return{payload:Wl(e.data,!1!==this.jsonParseBody),message:e.data,event:e.event,id:e.id}}catch(e){throw Kl("SSE","GRAPH_SSE_TRIGGER_FAILED",e)}finally{l?.close()}}};k([w(),Ut({handle:"url"}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.sse.fields.url.label",placeholder:"graph.node.trigger.sse.fields.url.placeholder",type:"string"}),C("design:type",String)],Yl.prototype,"url",void 0),k([Ut({handle:"jsonParseBody",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.sse.fields.jsonParseBody.label",type:"boolean"}),C("design:type",Boolean)],Yl.prototype,"jsonParseBody",void 0),k([Ut({handle:"timeoutMs",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.sse.fields.timeoutMs.label",type:"number"}),C("design:type",Number)],Yl.prototype,"timeoutMs",void 0),k([w(),$t({handle:"payload"}),C("design:type",Object)],Yl.prototype,"payload",void 0),k([$t({handle:"message"}),C("design:type",String)],Yl.prototype,"message",void 0),k([$t({handle:"event"}),C("design:type",String)],Yl.prototype,"event",void 0),k([$t({handle:"id"}),C("design:type",String)],Yl.prototype,"id",void 0),Yl=k([Mt("core.trigger.sse",{kind:"core.trigger.sse",category:"Trigger",color:"#3b82f6",icon:"ti-rss",width:96,height:96,labels:["trigger","sse","events","stream"],metadata:{title:"graph.node.trigger.sse.name",description:"graph.node.trigger.sse.description",trigger:{type:"sse",url:""}}}),I()],Yl);const Zl=/^[A-Za-z_][A-Za-z0-9_]*$/;let ec=class extends Wi{constructor(){super(...arguments),this.ssl=!1,this.acceptSelfSigned=!1,this.jsonParseBody=!1}async execute(e,t){const o=As(this.channel);if(!o)throw new Cr("Postgres trigger requires a channel","GRAPH_POSTGRES_TRIGGER_CHANNEL_REQUIRED");if(!Zl.test(o))throw new Cr(`Postgres trigger channel '${o}' is not a valid identifier`,"GRAPH_POSTGRES_TRIGGER_CHANNEL_INVALID",{channel:o});const r=As(this.database),n=As(this.username);if(!r||!n)throw new Cr("Postgres trigger requires a database and username","GRAPH_POSTGRES_TRIGGER_CONNECTION_REQUIRED");const i=Ps(await an(t,e.credentials,"postgres",!1,"Postgres trigger"),["password","secret","token"],"Postgres trigger"),a=Ss(this.ssl,!1),s=Ss(this.acceptSelfSigned,!1),d=ql(this.timeoutMs),l=new rt({host:As(this.host)??"localhost",port:Rs(this.port)??5432,database:r,user:n,password:i,ssl:!!a&&{rejectUnauthorized:!s}});try{await l.connect();const e=await zl(t,d,async e=>(l.on("notification",t=>{t.channel===o&&e({channel:t.channel,message:t.payload??""})}),await l.query(`LISTEN "${o}"`),await t.log("Postgres trigger listening",{channel:o}),async()=>{await l.query(`UNLISTEN "${o}"`).catch(()=>{})}),"GRAPH_TRIGGER_TIMEOUT",`Postgres trigger received no notification within ${d}ms`);return{payload:Wl(e.message,!0===this.jsonParseBody),message:e.message,channel:e.channel}}catch(e){throw Kl("Postgres","GRAPH_POSTGRES_TRIGGER_FAILED",e)}finally{await l.end().catch(()=>{})}}};k([Ut({handle:"host",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.host.label",type:"string"}),C("design:type",String)],ec.prototype,"host",void 0),k([Ut({handle:"port",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.port.label",type:"number"}),C("design:type",Number)],ec.prototype,"port",void 0),k([w(),Ut({handle:"database",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.database.label",type:"string"}),C("design:type",String)],ec.prototype,"database",void 0),k([w(),Ut({handle:"username",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.username.label",type:"string"}),C("design:type",String)],ec.prototype,"username",void 0),k([w(),Ut({handle:"channel"}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.channel.label",placeholder:"graph.node.trigger.postgres.fields.channel.placeholder",type:"string"}),C("design:type",String)],ec.prototype,"channel",void 0),k([Ut({handle:"ssl",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.ssl.label",type:"boolean"}),C("design:type",Boolean)],ec.prototype,"ssl",void 0),k([Ut({handle:"acceptSelfSigned",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.acceptSelfSigned.label",type:"boolean"}),C("design:type",Boolean)],ec.prototype,"acceptSelfSigned",void 0),k([Ut({handle:"jsonParseBody",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.jsonParseBody.label",type:"boolean"}),C("design:type",Boolean)],ec.prototype,"jsonParseBody",void 0),k([Ut({handle:"timeoutMs",userControlled:!0}),i("ngx-decaf-crud-field",{label:"graph.node.trigger.postgres.fields.timeoutMs.label",type:"number"}),C("design:type",Number)],ec.prototype,"timeoutMs",void 0),k([w(),$t({handle:"payload"}),C("design:type",Object)],ec.prototype,"payload",void 0),k([$t({handle:"message"}),C("design:type",String)],ec.prototype,"message",void 0),k([$t({handle:"channel"}),C("design:type",String)],ec.prototype,"channelOutput",void 0),ec=k([Mt("core.trigger.postgres",{kind:"core.trigger.postgres",category:"Trigger",color:"#3b82f6",icon:"ti-database",width:96,height:96,labels:["trigger","postgres","sql","listen","notify"],metadata:{title:"graph.node.trigger.postgres.name",description:"graph.node.trigger.postgres.description",trigger:{type:"postgres",channel:"",jsonParseBody:!1}}}),I()],ec);const tc={memory:"memory",scorers:"scorers",embedding:"embedding",hooks:"hooks",sandbox:"sandbox",tools:"tools",skill:"skill",inputProcessors:"inputProcessors",outputProcessors:"outputProcessors"},oc=["memory","scorers","embedding","hooks","sandbox","tools","skill","inputProcessors","outputProcessors"];let rc=class extends Wi{execute(e){throw new Cr("Node kind 'core.agent' requires the mastra engine, which the local backend does not provide",dr,{kind:"core.agent",backend:"local"})}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.prompt.label",placeholder:"graph.node.agent.agent.fields.prompt.placeholder",type:"textarea"}),Ut({handle:"prompt"}),C("design:type",String)],rc.prototype,"prompt",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.name.label",placeholder:"graph.node.agent.agent.fields.name.placeholder",type:"text"}),Ut({handle:"name",userControlled:!0}),C("design:type",String)],rc.prototype,"name",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.description.label",type:"textarea"}),Ut({handle:"description",userControlled:!0}),C("design:type",String)],rc.prototype,"description",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.instructions.label",placeholder:"graph.node.agent.agent.fields.instructions.placeholder",type:"textarea"}),Ut({handle:"instructions",userControlled:!0}),C("design:type",String)],rc.prototype,"instructions",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.skillsFormat.label",type:"select"}),Ut({handle:"skillsFormat",userControlled:!0}),C("design:type",String)],rc.prototype,"skillsFormat",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.maxRetries.label",type:"number"}),Ut({handle:"maxRetries",userControlled:!0}),C("design:type",Number)],rc.prototype,"maxRetries",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.modelAdapter.label",type:"object"}),Ut({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],rc.prototype,"modelAdapter",void 0),k([i("ngx-decaf-model-builder",{label:"graph.node.agent.agent.fields.structuredOutput.label"}),Ut({handle:"structuredOutput",userControlled:!0,type:"object"}),C("design:type",Object)],rc.prototype,"structuredOutput",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.agent.fields.agentOptions.label",type:"object"}),Ut({handle:"agentOptions",userControlled:!0,type:"object"}),C("design:type",Object)],rc.prototype,"agentOptions",void 0),k([w(),$t({handle:"response"}),C("design:type",String)],rc.prototype,"response",void 0),k([w(),$t({handle:"actions"}),C("design:type",Array)],rc.prototype,"actions",void 0),k([Ft({category:"memory",handle:"memory",zone:{side:"bottom",align:"start",order:0}}),C("design:type",Object)],rc.prototype,"memory",void 0),k([Ft({category:"scorers",handle:"scorers",zone:{side:"top",align:"end",order:0}}),C("design:type",Object)],rc.prototype,"scorers",void 0),k([Ft({category:"embedding",handle:"embedding",zone:{side:"bottom",align:"end",order:0}}),C("design:type",Object)],rc.prototype,"embedding",void 0),k([Ft({category:"hooks",handle:"hooks",zone:{side:"top",align:"center",order:0}}),C("design:type",Object)],rc.prototype,"hooks",void 0),k([Ft({category:"sandbox",handle:"sandbox",zone:{side:"top",align:"center",order:1}}),C("design:type",Object)],rc.prototype,"sandbox",void 0),k([Ft({category:"tools",handle:"tools",zone:{side:"bottom",align:"center",order:0}}),C("design:type",Object)],rc.prototype,"tools",void 0),k([Ft({category:"skill",handle:"skill",zone:{side:"bottom",align:"center",order:1}}),C("design:type",Object)],rc.prototype,"skill",void 0),k([Ft({category:"inputProcessors",handle:"inputProcessors",zone:{side:"top",align:"center",order:2}}),C("design:type",Object)],rc.prototype,"inputProcessors",void 0),k([Ft({category:"outputProcessors",handle:"outputProcessors",zone:{side:"bottom",align:"center",order:2}}),C("design:type",Object)],rc.prototype,"outputProcessors",void 0),k([Ft({category:"model",handle:"model",zone:{side:"bottom",align:"start",order:1}}),C("design:type",Object)],rc.prototype,"model",void 0),k([Ft({category:"workspace",handle:"workspace",zone:{side:"bottom",align:"start",order:2}}),C("design:type",Object)],rc.prototype,"workspace",void 0),rc=k([Mt("core.agent",{kind:"core.agent",category:"Agent",width:168,height:132,labels:["agent","ai","orchestrator"],metadata:{title:"graph.node.agent.agent.name",description:"graph.node.agent.agent.description",shape:"rectangle"}}),I()],rc);const nc=[rc];let ic=class extends Wi{execute(e){return{resource:{type:"mastra.tool",toolId:this.toolId,description:this.description,input:e.inputs}}}};k([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool.fields.toolId.label",placeholder:"graph.node.agent.tool.fields.toolId.placeholder",type:"text"}),Ut({handle:"toolId",userControlled:!0}),C("design:type",String)],ic.prototype,"toolId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool.fields.description.label",type:"textarea"}),Ut({handle:"description",userControlled:!0}),C("design:type",String)],ic.prototype,"description",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],ic.prototype,"resource",void 0),k([Ft({category:"tools",handle:"tool"}),C("design:type",Object)],ic.prototype,"tool",void 0),ic=k([Mt("core.agent.tool",{kind:"core.agent.tool",category:"Agent",width:128,height:112,labels:["agent","ai","tool"],metadata:{title:"graph.node.agent.tool.name",description:"graph.node.agent.tool.description",shape:"rectangle"}}),I()],ic);const ac=[ic];let sc=class extends Wi{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.tools??[],r="string"==typeof t?t:o.length?o[0]:void 0;return{selected:r,resource:r?{type:"mastra.tool",toolId:r}:null}}};k([Ut({handle:"decision"}),C("design:type",Object)],sc.prototype,"decision",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool_selector.fields.tools.label",type:"text"}),Ut({handle:"tools",userControlled:!0}),C("design:type",Array)],sc.prototype,"tools",void 0),k([$t({handle:"selected"}),C("design:type",Object)],sc.prototype,"selectedOut",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],sc.prototype,"resource",void 0),k([Ft({category:"tools",handle:"tool"}),C("design:type",Object)],sc.prototype,"tool",void 0),sc=k([Mt("core.agent.toolSelector",{kind:"core.agent.toolSelector",category:"Agent",width:128,height:112,labels:["agent","ai","tool","selector"],metadata:{title:"graph.node.agent.tool_selector.name",description:"graph.node.agent.tool_selector.description",shape:"rectangle"}}),I()],sc);const dc=[sc];let lc=class extends Wi{execute(e){const t=e.inputs??{};return{toolName:t.toolName??this.toolName,input:t.input,output:t.output,error:t.error,value:t.value??t}}};k([i("ngx-decaf-crud-field",{label:"graph.node.agent.hook.fields.phase.label",type:"select"}),Ut({handle:"phase",userControlled:!0}),C("design:type",String)],lc.prototype,"phase",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.hook.fields.toolName.label",type:"text"}),Ut({handle:"toolName",userControlled:!0}),C("design:type",String)],lc.prototype,"toolName",void 0),k([w(),Ut({handle:"value"}),C("design:type",Object)],lc.prototype,"value",void 0),k([w(),$t({handle:"toolName"}),C("design:type",Object)],lc.prototype,"toolNameOut",void 0),k([$t({handle:"input"}),C("design:type",Object)],lc.prototype,"inputOut",void 0),k([$t({handle:"output"}),C("design:type",Object)],lc.prototype,"outputOut",void 0),k([$t({handle:"error"}),C("design:type",Object)],lc.prototype,"errorOut",void 0),k([$t({handle:"value"}),C("design:type",Object)],lc.prototype,"valueOut",void 0),k([Ft({category:"hooks",handle:"hook"}),C("design:type",Object)],lc.prototype,"hook",void 0),lc=k([Mt("core.agent.hook",{kind:"core.agent.hook",category:"Agent",width:128,height:112,labels:["agent","ai","hook"],metadata:{title:"graph.node.agent.hook.name",description:"graph.node.agent.hook.description",shape:"rectangle"}}),I()],lc);const cc=[lc];let pc=class extends Wi{execute(e){const t=e.inputs.value;return{proceed:!1,denied:!0,reason:this.reason,value:this.replacement??t}}};k([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool_deny.fields.replacement.label",type:"textarea"}),Ut({handle:"replacement",userControlled:!0}),C("design:type",Object)],pc.prototype,"replacement",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.tool_deny.fields.reason.label",type:"text"}),Ut({handle:"reason",userControlled:!0}),C("design:type",String)],pc.prototype,"reason",void 0),k([Ut({handle:"value"}),C("design:type",Object)],pc.prototype,"value",void 0),k([$t({handle:"proceed"}),C("design:type",Boolean)],pc.prototype,"proceedOut",void 0),k([$t({handle:"value"}),C("design:type",Object)],pc.prototype,"valueOut",void 0),k([$t({handle:"denied"}),C("design:type",Boolean)],pc.prototype,"deniedOut",void 0),k([$t({handle:"reason"}),C("design:type",Object)],pc.prototype,"reasonOut",void 0),pc=k([Mt("core.agent.toolDeny",{kind:"core.agent.toolDeny",category:"Agent",width:112,height:96,labels:["agent","ai","hook","deny"],metadata:{title:"graph.node.agent.tool_deny.name",description:"graph.node.agent.tool_deny.description",shape:"rectangle"}}),I()],pc);const uc=[pc];let gc=class extends Wi{execute(e){const t=e.inputs??{};return{fromAgentId:t.fromAgentId,toAgentId:t.toAgentId??this.subAgentId,input:t.input,output:t.output,error:t.error,value:t.value??t}}};k([i("ngx-decaf-crud-field",{label:"graph.node.agent.delegation_hook.fields.phase.label",type:"select"}),Ut({handle:"phase",userControlled:!0}),C("design:type",String)],gc.prototype,"phase",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.delegation_hook.fields.subAgentId.label",type:"text"}),Ut({handle:"subAgentId",userControlled:!0}),C("design:type",String)],gc.prototype,"subAgentId",void 0),k([w(),Ut({handle:"value"}),C("design:type",Object)],gc.prototype,"value",void 0),k([$t({handle:"fromAgentId"}),C("design:type",Object)],gc.prototype,"fromAgentIdOut",void 0),k([$t({handle:"toAgentId"}),C("design:type",Object)],gc.prototype,"toAgentIdOut",void 0),k([$t({handle:"input"}),C("design:type",Object)],gc.prototype,"inputOut",void 0),k([$t({handle:"output"}),C("design:type",Object)],gc.prototype,"outputOut",void 0),k([$t({handle:"error"}),C("design:type",Object)],gc.prototype,"errorOut",void 0),k([$t({handle:"value"}),C("design:type",Object)],gc.prototype,"valueOut",void 0),k([Ft({category:"hooks",handle:"hook"}),C("design:type",Object)],gc.prototype,"hook",void 0),gc=k([Mt("core.agent.delegationHook",{kind:"core.agent.delegationHook",category:"Agent",width:128,height:112,labels:["agent","ai","hook","delegation"],metadata:{title:"graph.node.agent.delegation_hook.name",description:"graph.node.agent.delegation_hook.description",shape:"rectangle"}}),I()],gc);const hc=[gc];let fc=class extends Wi{execute(e){return{resource:{type:"mastra.skill",name:this.name,description:this.description,input:e.inputs}}}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.skill.fields.name.label",type:"text"}),Ut({handle:"name",userControlled:!0}),C("design:type",String)],fc.prototype,"name",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.skill.fields.description.label",type:"textarea"}),Ut({handle:"description",userControlled:!0}),C("design:type",String)],fc.prototype,"description",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.skill.fields.instructions.label",type:"textarea"}),Ut({handle:"instructions",userControlled:!0}),C("design:type",String)],fc.prototype,"instructions",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],fc.prototype,"resource",void 0),k([Ft({category:"skill",handle:"skill"}),C("design:type",Object)],fc.prototype,"skill",void 0),fc=k([Mt("core.agent.skill",{kind:"core.agent.skill",category:"Agent",width:128,height:112,labels:["agent","ai","skill"],metadata:{title:"graph.node.agent.skill.name",description:"graph.node.agent.skill.description",shape:"rectangle"}}),I()],fc);const yc=[fc];let mc=class extends Wi{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.skills??[],r="string"==typeof t?t:o.length?o[0]:void 0;return{selected:r,resource:r?{type:"mastra.skill",name:r}:null}}};k([Ut({handle:"decision"}),C("design:type",Object)],mc.prototype,"decision",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.skill_selector.fields.skills.label",type:"text"}),Ut({handle:"skills",userControlled:!0}),C("design:type",Array)],mc.prototype,"skills",void 0),k([$t({handle:"selected"}),C("design:type",Object)],mc.prototype,"selectedOut",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],mc.prototype,"resource",void 0),k([Ft({category:"skill",handle:"skill"}),C("design:type",Object)],mc.prototype,"skill",void 0),mc=k([Mt("core.agent.skillSelector",{kind:"core.agent.skillSelector",category:"Agent",width:128,height:112,labels:["agent","ai","skill","selector"],metadata:{title:"graph.node.agent.skill_selector.name",description:"graph.node.agent.skill_selector.description",shape:"rectangle"}}),I()],mc);const bc=[mc];function wc(e){const t=Zi.graph.execution?.maxCodeTimeoutMs;return ta(e,"number"==typeof t&&Number.isFinite(t)&&t>0?t:hr)}let vc=class extends Wi{execute(e){return{resource:{type:"mastra.sandbox",workingDirectory:this.workingDirectory,isolation:this.isolation,timeoutMs:wc(this.timeoutMs),input:e.inputs}}}};k([i("ngx-decaf-crud-field",{label:"graph.node.agent.sandbox.fields.workingDirectory.label",type:"text"}),Ut({handle:"workingDirectory",userControlled:!0}),C("design:type",String)],vc.prototype,"workingDirectory",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.sandbox.fields.isolation.label",type:"select"}),Ut({handle:"isolation",userControlled:!0}),C("design:type",String)],vc.prototype,"isolation",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.sandbox.fields.timeoutMs.label",type:"number"}),Ut({handle:"timeoutMs",userControlled:!0}),C("design:type",Number)],vc.prototype,"timeoutMs",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],vc.prototype,"resource",void 0),k([Ft({category:"sandbox",handle:"sandbox"}),C("design:type",Object)],vc.prototype,"sandbox",void 0),vc=k([Mt("core.agent.sandbox",{kind:"core.agent.sandbox",category:"Agent",width:128,height:112,labels:["agent","ai","sandbox","filesystem"],metadata:{title:"graph.node.agent.sandbox.name",description:"graph.node.agent.sandbox.description",shape:"rectangle"}}),I()],vc);const xc=[vc];let Ic=class extends Wi{execute(e){return{resource:{type:"mastra.scorer",id:this.scorerId,description:this.description,scorerType:this.scorerType,input:e.inputs}}}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.scorer.fields.scorerId.label",type:"text"}),Ut({handle:"scorerId",userControlled:!0}),C("design:type",String)],Ic.prototype,"scorerId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.scorer.fields.description.label",type:"textarea"}),Ut({handle:"description",userControlled:!0}),C("design:type",String)],Ic.prototype,"description",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.scorer.fields.scorerType.label",type:"select"}),Ut({handle:"scorerType",userControlled:!0}),C("design:type",String)],Ic.prototype,"scorerType",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Ic.prototype,"resource",void 0),k([Ft({category:"scorers",handle:"scorer"}),C("design:type",Object)],Ic.prototype,"scorer",void 0),Ic=k([Mt("core.agent.scorer",{kind:"core.agent.scorer",category:"Agent",width:128,height:112,labels:["agent","ai","scorer","eval"],metadata:{title:"graph.node.agent.scorer.name",description:"graph.node.agent.scorer.description",shape:"rectangle"}}),I()],Ic);const _c=[Ic];let Ec=class extends Wi{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.scorers??[],r="string"==typeof t?t:o.length?o[0]:void 0;return{selected:r,resource:r?{type:"mastra.scorer",id:r}:null}}};k([Ut({handle:"decision"}),C("design:type",Object)],Ec.prototype,"decision",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.scorer_selector.fields.scorers.label",type:"text"}),Ut({handle:"scorers",userControlled:!0}),C("design:type",Array)],Ec.prototype,"scorers",void 0),k([$t({handle:"selected"}),C("design:type",Object)],Ec.prototype,"selectedOut",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Ec.prototype,"resource",void 0),k([Ft({category:"scorers",handle:"scorer"}),C("design:type",Object)],Ec.prototype,"scorer",void 0),Ec=k([Mt("core.agent.scorerSelector",{kind:"core.agent.scorerSelector",category:"Agent",width:128,height:112,labels:["agent","ai","scorer","selector"],metadata:{title:"graph.node.agent.scorer_selector.name",description:"graph.node.agent.scorer_selector.description",shape:"rectangle"}}),I()],Ec);const Ac=[Ec];o.accumulate({mastra:{engine:{enabled:!0,terminalTimeoutMs:3e5},provider:{endpoint:"",model:""},credentials:{apiKeyEnv:"MASTRA_PROVIDER_API_KEY"},observability:{enabled:!0,serviceName:"as-graph-mastra",environment:"",langfuse:{endpoint:"https://cloud.langfuse.com",publicKeyEnv:"LANGFUSE_PUBLIC_KEY",secretKeyEnv:"LANGFUSE_SECRET_KEY"}},persistence:{replaysAdapter:"fs",cacheAdapter:"ram",pinsAdapter:"fs",fsRoot:"var/as-graph-mastra"}}});const Sc=[...Pn,"connectionString","dsn","pwd","passphrase","authToken"];function Rc(e,t,o,r=0){if(8>=r&&null!==e)if(Array.isArray(e))for(const n of e)Rc(n,t,o,r+1);else if("object"==typeof e)for(const[n,i]of Object.entries(e)){const e=[...t,n];if(Sc.includes(n))throw new Cr(`The '${o.provider}' ${o.surface} connection options carry plaintext credential material in '${e.join(".")}'; configs may only reference credentials by name through 'credentialRef', resolved by the host from the git-ignored .env.secret (gate C, SAA-911 F4)`,"GRAPH_MASTRA_PLAIN_CREDENTIAL_REFUSED",{provider:o.provider,id:o.id,key:n,path:e.join(".")});Rc(i,e,o,r+1)}}function Oc(e,t){Rc(e,[],t)}const kc=["memory","libsql","pg","mongodb","upstash","cloud","d1","dynamodb","convex","astra","redis"];function Cc(e){const t={type:"mastra.memory",provider:e.provider,id:e.id??e.provider};return void 0!==e.threadId&&(t.threadId=e.threadId),void 0!==e.resourceId&&(t.resourceId=e.resourceId),void 0!==e.lastMessages&&(t.lastMessages=e.lastMessages),void 0!==e.semanticRecall&&(t.semanticRecall=e.semanticRecall),void 0!==e.workingMemoryTemplate&&(t.workingMemory={enabled:!0,template:e.workingMemoryTemplate}),void 0!==e.generateTitle&&(t.generateTitle=e.generateTitle),void 0!==e.credentialRef&&(t.credentialRef=e.credentialRef),t}let Nc=class extends Wi{execute(e){return{resource:Cc(this.configOf(e))}}configOf(e){const t=this.provider??"memory";if(!kc.includes(t))throw new Cr(`Memory provider node '${e.nodeId}' declares unknown provider '${t+""}'`,"GRAPH_MASTRA_MEMORY_PROVIDER_UNKNOWN",{nodeId:e.nodeId,provider:t+""});const o=e.inputs.workingMemoryTemplate,r={provider:t};void 0!==this.memoryId&&(r.id=this.memoryId),void 0!==this.threadId&&(r.threadId=this.threadId),void 0!==this.resourceId&&(r.resourceId=this.resourceId),void 0!==this.lastMessages&&(r.lastMessages=this.lastMessages),void 0!==this.semanticRecall&&(r.semanticRecall=this.semanticRecall),void 0!==this.generateTitle&&(r.generateTitle=this.generateTitle),void 0!==this.memoryOptions&&(r.memoryOptions=this.memoryOptions),void 0!==this.connection&&(r.connection=this.connection),void 0!==this.credentialKey&&(r.credentialKey=this.credentialKey),void 0!==this.credentialRef&&(r.credentialRef=this.credentialRef);const n="string"==typeof o&&o.trim().length>0?o:this.workingMemoryTemplate;return"string"==typeof n&&n.trim().length>0&&(r.workingMemoryTemplate=n),r}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.provider.label",type:"select"}),Ut({handle:"provider",userControlled:!0}),C("design:type",String)],Nc.prototype,"provider",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.memoryId.label",type:"text"}),Ut({handle:"memoryId",userControlled:!0}),C("design:type",String)],Nc.prototype,"memoryId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.threadId.label",placeholder:"graph.node.agent.memory.fields.threadId.placeholder",type:"text"}),Ut({handle:"threadId",userControlled:!0}),C("design:type",String)],Nc.prototype,"threadId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.resourceId.label",type:"text"}),Ut({handle:"resourceId",userControlled:!0}),C("design:type",String)],Nc.prototype,"resourceId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.lastMessages.label",type:"number"}),Ut({handle:"lastMessages",userControlled:!0}),C("design:type",Number)],Nc.prototype,"lastMessages",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.semanticRecall.label",type:"select"}),Ut({handle:"semanticRecall",userControlled:!0}),C("design:type",Boolean)],Nc.prototype,"semanticRecall",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.workingMemoryTemplate.label",placeholder:"graph.node.agent.memory.fields.workingMemoryTemplate.placeholder",type:"textarea"}),Ut({handle:"workingMemoryTemplate",userControlled:!0}),C("design:type",String)],Nc.prototype,"workingMemoryTemplate",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.generateTitle.label",type:"select"}),Ut({handle:"generateTitle",userControlled:!0}),C("design:type",Boolean)],Nc.prototype,"generateTitle",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.memoryOptions.label",type:"object"}),Ut({handle:"memoryOptions",userControlled:!0,type:"object"}),C("design:type",Object)],Nc.prototype,"memoryOptions",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.connection.label",type:"object"}),Ut({handle:"connection",userControlled:!0,type:"object"}),C("design:type",Object)],Nc.prototype,"connection",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.credentialRef.label",type:"text"}),Ut({handle:"credentialKey",userControlled:!0}),C("design:type",String)],Nc.prototype,"credentialKey",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory.fields.credentialRef.label",type:"object"}),Ut({handle:"credentialRef",userControlled:!0,type:"object"}),C("design:type",Object)],Nc.prototype,"credentialRef",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Nc.prototype,"resource",void 0),k([Ft({category:"memory",handle:"memory"}),C("design:type",Object)],Nc.prototype,"memory",void 0),Nc=k([Mt("core.agent.memory",{kind:"core.agent.memory",category:"Agent",width:140,height:120,labels:["agent","ai","memory"],metadata:{title:"graph.node.agent.memory.name",description:"graph.node.agent.memory.description",shape:"rectangle"}}),I()],Nc);let Tc=class extends Wi{execute(e){const t=e.inputs.decision??e.inputs.value,o=this.memories??[],r="string"==typeof t?t:o.length?o[0]:void 0;return{selected:r,resource:r?{type:"mastra.memory",id:r}:null}}};k([Ut({handle:"decision"}),C("design:type",Object)],Tc.prototype,"decision",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.memory_selector.fields.memories.label",type:"text"}),Ut({handle:"memories",userControlled:!0}),C("design:type",Array)],Tc.prototype,"memories",void 0),k([$t({handle:"selected"}),C("design:type",Object)],Tc.prototype,"selectedOut",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Tc.prototype,"resource",void 0),k([Ft({category:"memory",handle:"memory"}),C("design:type",Object)],Tc.prototype,"memory",void 0),Tc=k([Mt("core.agent.memorySelector",{kind:"core.agent.memorySelector",category:"Agent",width:128,height:112,labels:["agent","ai","memory","selector"],metadata:{title:"graph.node.agent.memory_selector.name",description:"graph.node.agent.memory_selector.description",shape:"rectangle"}}),I()],Tc);const Pc=[Tc];let Dc=class extends Wi{execute(e){const t=this.modelAdapter??{};return{resource:{type:"mastra.embedding",provider:t.provider,modelId:t.modelId,dimension:this.dimension,batchSize:this.batchSize,input:e.inputs}}}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.modelAdapter.label",type:"object"}),Ut({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Dc.prototype,"modelAdapter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.dimension.label",type:"number"}),Ut({handle:"dimension",userControlled:!0}),C("design:type",Number)],Dc.prototype,"dimension",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.batchSize.label",type:"number"}),Ut({handle:"batchSize",userControlled:!0}),C("design:type",Number)],Dc.prototype,"batchSize",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Dc.prototype,"resource",void 0),k([Ft({category:"embedding",handle:"embedding"}),C("design:type",Object)],Dc.prototype,"embedding",void 0),Dc=k([Mt("core.agent.embedding",{kind:"core.agent.embedding",category:"Agent",width:128,height:112,labels:["agent","ai","embedding","vector"],metadata:{title:"graph.node.agent.embedding.name",description:"graph.node.agent.embedding.description",shape:"rectangle"}}),I()],Dc);const jc=[Dc];let Lc=class extends Wi{execute(e){const t=this.provider??"memory",o={type:"mastra.vectorStore",provider:t,id:this.storeId??this.indexName??t};void 0!==this.indexName&&(o.indexName=this.indexName),void 0!==this.dimension&&(o.dimension=this.dimension),void 0!==this.metric&&(o.metric=this.metric),void 0!==this.embedding&&(Oc(this.embedding,{provider:t,id:this.storeId??this.indexName??t,surface:"vector store embedding"}),o.embedding=this.embedding),void 0!==this.credentialRef&&(o.credentialRef=this.credentialRef);const r=e.inputs.ids;return{resource:o,inserted:Array.isArray(r)?r:[],documents:e.inputs.documents??[]}}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.provider.label",type:"select"}),Ut({handle:"provider",userControlled:!0}),C("design:type",String)],Lc.prototype,"provider",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.storeId.label",type:"text"}),Ut({handle:"storeId",userControlled:!0}),C("design:type",String)],Lc.prototype,"storeId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.indexName.label",type:"text"}),Ut({handle:"indexName",userControlled:!0}),C("design:type",String)],Lc.prototype,"indexName",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.dimension.label",type:"number"}),Ut({handle:"dimension",userControlled:!0}),C("design:type",Number)],Lc.prototype,"dimension",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.metric.label",type:"select"}),Ut({handle:"metric",userControlled:!0}),C("design:type",String)],Lc.prototype,"metric",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.embedding.fields.modelAdapter.label",type:"object"}),Ut({handle:"embedding",userControlled:!0,type:"object"}),C("design:type",Object)],Lc.prototype,"embedding",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.connection.label",type:"object"}),Ut({handle:"connection",userControlled:!0,type:"object"}),C("design:type",Object)],Lc.prototype,"connection",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.credentialRef.label",type:"text"}),Ut({handle:"credentialKey",userControlled:!0}),C("design:type",String)],Lc.prototype,"credentialKey",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.vector_store.fields.credentialRef.label",type:"object"}),Ut({handle:"credentialRef",userControlled:!0,type:"object"}),C("design:type",Object)],Lc.prototype,"credentialRef",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Lc.prototype,"resource",void 0),k([$t({handle:"inserted"}),C("design:type",Object)],Lc.prototype,"insertedOut",void 0),k([$t({handle:"documents"}),C("design:type",Object)],Lc.prototype,"documentsOut",void 0),Lc=k([Mt("core.agent.vectorStore",{kind:"core.agent.vectorStore",category:"Agent",width:140,height:120,labels:["agent","ai","vector-store","rag"],metadata:{title:"graph.node.agent.vector_store.name",description:"graph.node.agent.vector_store.description",shape:"rectangle"}}),I()],Lc);const Mc=[Lc];let Gc=class extends Wi{execute(e){const t=e.inputs.documents;return{documents:Array.isArray(t)?t:[],resource:{type:"mastra.retriever",topK:this.topK,indexName:this.indexName,store:e.inputs.store,input:e.inputs}}}};k([w(),Ut({handle:"store"}),C("design:type",Object)],Gc.prototype,"store",void 0),k([w(),Ut({handle:"query"}),C("design:type",Object)],Gc.prototype,"query",void 0),k([Ut({handle:"queryVector"}),C("design:type",Object)],Gc.prototype,"queryVector",void 0),k([Ut({handle:"filter",type:"object"}),C("design:type",Object)],Gc.prototype,"filter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.retriever.fields.topK.label",type:"number"}),Ut({handle:"topK",userControlled:!0}),C("design:type",Number)],Gc.prototype,"topK",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.retriever.fields.indexName.label",type:"text"}),Ut({handle:"indexName",userControlled:!0}),C("design:type",String)],Gc.prototype,"indexName",void 0),k([w(),$t({handle:"documents"}),C("design:type",Object)],Gc.prototype,"documents",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Gc.prototype,"resource",void 0),Gc=k([Mt("core.agent.retriever",{kind:"core.agent.retriever",category:"Agent",width:128,height:112,labels:["agent","ai","retriever","rag"],metadata:{title:"graph.node.agent.retriever.name",description:"graph.node.agent.retriever.description",shape:"rectangle"}}),I()],Gc);const Uc=[Gc],$c=1e3,Fc=200;function Hc(e,t,o){if("number"!=typeof e||!Number.isFinite(e))return t;const r=Math.floor(e);return o>r?t:r}function Bc(e,t,o){if(e.length<=t)return e.length?[e]:[];const r=Math.max(1,t-o),n=[];for(let o=0;o<e.length;o+=r){const r=Math.min(o+t,e.length);if(n.push(e.slice(o,r)),r>=e.length)break}return n}function qc(e,t={}){if("string"!=typeof e||0===e.length)return[];const o=t.strategy??"recursive",r=Hc(t.chunkSize,1e3,1),n=Hc(t.chunkOverlap,200,0),i=Math.min(n,Math.max(0,r-1));if("character"===o)return Bc(e,r,i);if("token"===o){const t=e.split(/\s+/).filter(e=>e.length>0);if(0===t.length)return[];const o=Math.max(1,r-i),n=[];for(let e=0;e<t.length&&(n.push(t.slice(e,e+r).join(" ")),e+r<t.length);e+=o);return n}const a="markdown"===o?"\n#":t.separator??"\n\n",s=e.split(a),d=[];return s.forEach(e=>{const t=e.trim();t&&(t.length>r?d.push(...Bc(t,r,i)):d.push(t))}),d.length?d:Bc(e,r,i)}function Wc(e){const t=e.documents,o=[];if("string"==typeof e.text&&o.push(e.text),Array.isArray(t))for(const e of t)"string"==typeof e?o.push(e):e&&"object"==typeof e&&"string"==typeof e.text&&o.push(e.text);return o}let Kc=class extends Wi{execute(e){const t=Wc(e.inputs),o={strategy:this.strategy,chunkSize:this.chunkSize,chunkOverlap:this.chunkOverlap,separator:this.separator},r=t.flatMap(e=>qc(e,o));return{chunks:r,count:r.length}}};k([i("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.strategy.label",type:"select"}),Ut({handle:"strategy",userControlled:!0}),C("design:type",String)],Kc.prototype,"strategy",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.chunkSize.label",type:"number"}),Ut({handle:"chunkSize",userControlled:!0}),C("design:type",Number)],Kc.prototype,"chunkSize",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.chunkOverlap.label",type:"number"}),Ut({handle:"chunkOverlap",userControlled:!0}),C("design:type",Number)],Kc.prototype,"chunkOverlap",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.chunking.fields.separator.label",type:"text"}),Ut({handle:"separator",userControlled:!0}),C("design:type",String)],Kc.prototype,"separator",void 0),k([w(),$t({handle:"chunks"}),C("design:type",Object)],Kc.prototype,"chunks",void 0),k([$t({handle:"count"}),C("design:type",Object)],Kc.prototype,"countOut",void 0),Kc=k([Mt("core.agent.chunking",{kind:"core.agent.chunking",category:"Agent",width:128,height:112,labels:["agent","ai","chunking","rag"],metadata:{title:"graph.node.agent.chunking.name",description:"graph.node.agent.chunking.description",shape:"rectangle"}}),I()],Kc);const Vc=[Kc];let zc=class extends Wi{execute(e){const t=e.inputs.documents,o=Array.isArray(t)?t:[],r="number"==typeof this.topN&&this.topN>0?this.topN:void 0,n=this.modelAdapter??{};return{documents:void 0!==r?o.slice(0,r):o,resource:{type:"mastra.rerank",provider:n.provider,modelId:n.modelId,topN:r}}}};k([w(),Ut({handle:"documents"}),C("design:type",Object)],zc.prototype,"documents",void 0),k([Ut({handle:"query"}),C("design:type",Object)],zc.prototype,"query",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.rerank.fields.modelAdapter.label",type:"object"}),Ut({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],zc.prototype,"modelAdapter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.rerank.fields.topN.label",type:"number"}),Ut({handle:"topN",userControlled:!0}),C("design:type",Number)],zc.prototype,"topN",void 0),k([w(),$t({handle:"documents"}),C("design:type",Object)],zc.prototype,"documentsOut",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],zc.prototype,"resource",void 0),zc=k([Mt("core.agent.rerank",{kind:"core.agent.rerank",category:"Agent",width:128,height:112,labels:["agent","ai","rerank","rag"],metadata:{title:"graph.node.agent.rerank.name",description:"graph.node.agent.rerank.description",shape:"rectangle"}}),I()],zc);const Qc=[zc];let Jc=class extends Wi{execute(e){const t=this.modelAdapter??{},o=e.inputs.context??e.inputs.documents,r=Array.isArray(o)?o:[];return{text:"string"==typeof e.inputs.text?e.inputs.text:"",sourceDocuments:this.returnSourceDocuments?r:[],resource:{type:"mastra.chain.qa",provider:t.provider,modelId:t.modelId,returnSourceDocuments:this.returnSourceDocuments??!1}}}};k([w(),Ut({handle:"query"}),C("design:type",Object)],Jc.prototype,"query",void 0),k([Ut({handle:"context"}),C("design:type",Object)],Jc.prototype,"context",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.qa.fields.modelAdapter.label",type:"object"}),Ut({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Jc.prototype,"modelAdapter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.qa.fields.promptTemplate.label",type:"textarea"}),Ut({handle:"promptTemplate",userControlled:!0}),C("design:type",String)],Jc.prototype,"promptTemplate",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.qa.fields.returnSourceDocuments.label",type:"boolean"}),Ut({handle:"returnSourceDocuments",userControlled:!0}),C("design:type",Boolean)],Jc.prototype,"returnSourceDocuments",void 0),k([w(),$t({handle:"text"}),C("design:type",Object)],Jc.prototype,"text",void 0),k([$t({handle:"sourceDocuments"}),C("design:type",Object)],Jc.prototype,"sourceDocumentsOut",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Jc.prototype,"resource",void 0),Jc=k([Mt("core.agent.chain.qa",{kind:"core.agent.chain.qa",category:"Agent",width:128,height:112,labels:["agent","ai","chain","qa"],metadata:{title:"graph.node.agent.chain.qa.name",description:"graph.node.agent.chain.qa.description",shape:"rectangle"}}),I()],Jc);const Xc=[Jc];let Yc=class extends Wi{execute(e){const t=this.modelAdapter??{};return{text:"string"==typeof e.inputs.text?e.inputs.text:"",resource:{type:"mastra.chain.basic",provider:t.provider,modelId:t.modelId,promptTemplate:this.promptTemplate}}}};k([w(),Ut({handle:"input"}),C("design:type",Object)],Yc.prototype,"input",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.basic.fields.modelAdapter.label",type:"object"}),Ut({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],Yc.prototype,"modelAdapter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.basic.fields.promptTemplate.label",type:"textarea"}),Ut({handle:"promptTemplate",userControlled:!0}),C("design:type",String)],Yc.prototype,"promptTemplate",void 0),k([w(),$t({handle:"text"}),C("design:type",Object)],Yc.prototype,"text",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Yc.prototype,"resource",void 0),Yc=k([Mt("core.agent.chain.basic",{kind:"core.agent.chain.basic",category:"Agent",width:128,height:112,labels:["agent","ai","chain","llm"],metadata:{title:"graph.node.agent.chain.basic.name",description:"graph.node.agent.chain.basic.description",shape:"rectangle"}}),I()],Yc);const Zc=[Yc];let ep=class extends Wi{execute(e){const t=this.modelAdapter??{},o=e.inputs.documents;return{text:"string"==typeof e.inputs.text?e.inputs.text:"",resource:{type:"mastra.chain.summarization",provider:t.provider,modelId:t.modelId,strategy:this.strategy??"stuff",documentCount:Array.isArray(o)?o.length:0}}}};k([w(),Ut({handle:"documents"}),C("design:type",Object)],ep.prototype,"documents",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.summarization.fields.modelAdapter.label",type:"object"}),Ut({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],ep.prototype,"modelAdapter",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.summarization.fields.strategy.label",type:"select"}),Ut({handle:"strategy",userControlled:!0}),C("design:type",String)],ep.prototype,"strategy",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.chain.summarization.fields.instructions.label",type:"textarea"}),Ut({handle:"instructions",userControlled:!0}),C("design:type",String)],ep.prototype,"instructions",void 0),k([w(),$t({handle:"text"}),C("design:type",Object)],ep.prototype,"text",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],ep.prototype,"resource",void 0),ep=k([Mt("core.agent.chain.summarization",{kind:"core.agent.chain.summarization",category:"Agent",width:128,height:112,labels:["agent","ai","chain","summarization"],metadata:{title:"graph.node.agent.chain.summarization.name",description:"graph.node.agent.chain.summarization.description",shape:"rectangle"}}),I()],ep);const tp=[ep];function op(e){if("string"!=typeof e||0===e.trim().length)return null;try{return JSON.parse(e)}catch{return null}}let rp=class extends Wi{execute(e){return{object:op(e.inputs.text??e.inputs.input),resource:{type:"mastra.structuredOutputParser",strict:this.strict??!1,hasSchema:void 0!==this.structuredOutput}}}};k([w(),Ut({handle:"text"}),C("design:type",Object)],rp.prototype,"text",void 0),k([i("ngx-decaf-model-builder",{label:"graph.node.agent.structured_output_parser.fields.structuredOutput.label"}),Ut({handle:"structuredOutput",userControlled:!0,type:"object"}),C("design:type",Object)],rp.prototype,"structuredOutput",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.structured_output_parser.fields.strict.label",type:"boolean"}),Ut({handle:"strict",userControlled:!0}),C("design:type",Boolean)],rp.prototype,"strict",void 0),k([w(),$t({handle:"object"}),C("design:type",Object)],rp.prototype,"object",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],rp.prototype,"resource",void 0),rp=k([Mt("core.agent.structuredOutputParser",{kind:"core.agent.structuredOutputParser",category:"Agent",width:128,height:112,labels:["agent","ai","parser","structured-output"],metadata:{title:"graph.node.agent.structured_output_parser.name",description:"graph.node.agent.structured_output_parser.description",shape:"rectangle"}}),I()],rp);const np=[rp];let ip=class extends Wi{execute(e){const t=this.modelAdapter??{};return{data:e.inputs.data??null,resource:{type:"mastra.informationExtractor",provider:t.provider,modelId:t.modelId,instructions:this.instructions,hasSchema:void 0!==this.structuredOutput}}}};k([w(),Ut({handle:"text"}),C("design:type",Object)],ip.prototype,"text",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.information_extractor.fields.modelAdapter.label",type:"object"}),Ut({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],ip.prototype,"modelAdapter",void 0),k([i("ngx-decaf-model-builder",{label:"graph.node.agent.information_extractor.fields.structuredOutput.label"}),Ut({handle:"structuredOutput",userControlled:!0,type:"object"}),C("design:type",Object)],ip.prototype,"structuredOutput",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.information_extractor.fields.instructions.label",type:"textarea"}),Ut({handle:"instructions",userControlled:!0}),C("design:type",String)],ip.prototype,"instructions",void 0),k([w(),$t({handle:"data"}),C("design:type",Object)],ip.prototype,"data",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],ip.prototype,"resource",void 0),ip=k([Mt("core.agent.informationExtractor",{kind:"core.agent.informationExtractor",category:"Agent",width:128,height:112,labels:["agent","ai","extractor","structured-output"],metadata:{title:"graph.node.agent.information_extractor.name",description:"graph.node.agent.information_extractor.description",shape:"rectangle"}}),I()],ip);const ap=[ip];let sp=class extends Wi{execute(e){return{output:e.inputs.input??null,resource:{type:"mastra.langchainCode",language:this.language??"javascript",mode:this.mode??"runOnce",hasCode:"string"==typeof this.code&&this.code.length>0}}}};k([w(),Ut({handle:"input"}),C("design:type",Object)],sp.prototype,"input",void 0),k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.langchain_code.fields.code.label",type:"textarea"}),Ut({handle:"code",userControlled:!0}),C("design:type",String)],sp.prototype,"code",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.langchain_code.fields.language.label",type:"select"}),Ut({handle:"language",userControlled:!0}),C("design:type",String)],sp.prototype,"language",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.langchain_code.fields.mode.label",type:"select"}),Ut({handle:"mode",userControlled:!0}),C("design:type",String)],sp.prototype,"mode",void 0),k([$t({handle:"output"}),C("design:type",Object)],sp.prototype,"outputOut",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],sp.prototype,"resource",void 0),sp=k([Mt("core.agent.langchainCode",{kind:"core.agent.langchainCode",category:"Agent",width:128,height:112,labels:["agent","ai","code","glue"],metadata:{title:"graph.node.agent.langchain_code.name",description:"graph.node.agent.langchain_code.description",shape:"rectangle"}}),I()],sp);const dp=[sp],lp=["unicodeNormalizer","languageDetector","piiDetector","promptInjectionDetector","systemPromptScrubber","tokenCostControl","modelSelection"],cp=["tokenLimiter","toolCallFilter","regexFilter","responseCache","batchParts","providerHistoryCompat","cyberRefusalHandler","prefillErrorHandler","streamErrorRetry","unsupportedFileHandler"],pp=["moderation","piiDetector","promptInjectionDetector","regexFilter"];let up=class extends Wi{execute(e){return{resource:{type:"mastra.inputProcessor",processorType:this.processorType,options:this.options,input:e.inputs}}}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.input_processor.fields.processorType.label",type:"select"}),Ut({handle:"processorType",userControlled:!0}),C("design:type",Object)],up.prototype,"processorType",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.input_processor.fields.options.label",type:"object"}),Ut({handle:"options",userControlled:!0,type:"object"}),C("design:type",Object)],up.prototype,"options",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.input_processor.fields.modelAdapter.label",type:"object"}),Ut({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],up.prototype,"modelAdapter",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],up.prototype,"resource",void 0),k([Ft({category:"inputProcessors",handle:"processors"}),C("design:type",Object)],up.prototype,"processors",void 0),up=k([Mt("core.agent.inputProcessor",{kind:"core.agent.inputProcessor",category:"Agent",width:128,height:112,labels:["agent","ai","processor","input"],metadata:{title:"graph.node.agent.input_processor.name",description:"graph.node.agent.input_processor.description",shape:"rectangle"}}),I()],up);const gp=[up];let hp=class extends Wi{execute(e){return{resource:{type:"mastra.outputProcessor",processorType:this.processorType,options:this.options,input:e.inputs}}}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.output_processor.fields.processorType.label",type:"select"}),Ut({handle:"processorType",userControlled:!0}),C("design:type",Object)],hp.prototype,"processorType",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.output_processor.fields.options.label",type:"object"}),Ut({handle:"options",userControlled:!0,type:"object"}),C("design:type",Object)],hp.prototype,"options",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],hp.prototype,"resource",void 0),k([Ft({category:"outputProcessors",handle:"processors"}),C("design:type",Object)],hp.prototype,"processors",void 0),hp=k([Mt("core.agent.outputProcessor",{kind:"core.agent.outputProcessor",category:"Agent",width:128,height:112,labels:["agent","ai","processor","output"],metadata:{title:"graph.node.agent.output_processor.name",description:"graph.node.agent.output_processor.description",shape:"rectangle"}}),I()],hp);const fp=[hp];let yp=class extends Wi{execute(e){return{resource:{type:"mastra.guardrail",guardrailType:this.guardrailType,strategy:this.strategy,options:this.options,input:e.inputs}}}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.guardrailType.label",type:"select"}),Ut({handle:"guardrailType",userControlled:!0}),C("design:type",Object)],yp.prototype,"guardrailType",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.strategy.label",type:"select"}),Ut({handle:"strategy",userControlled:!0}),C("design:type",String)],yp.prototype,"strategy",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.options.label",type:"object"}),Ut({handle:"options",userControlled:!0,type:"object"}),C("design:type",Object)],yp.prototype,"options",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.guardrail.fields.modelAdapter.label",type:"object"}),Ut({handle:"modelAdapter",userControlled:!0,type:"object"}),C("design:type",Object)],yp.prototype,"modelAdapter",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],yp.prototype,"resource",void 0),k([Ft({category:"outputProcessors",handle:"guardrail"}),C("design:type",Object)],yp.prototype,"guardrail",void 0),yp=k([Mt("core.agent.guardrail",{kind:"core.agent.guardrail",category:"Agent",width:128,height:112,labels:["agent","ai","guardrail","safety"],metadata:{title:"graph.node.agent.guardrail.name",description:"graph.node.agent.guardrail.description",shape:"rectangle"}}),I()],yp);const mp=[yp];let bp=class extends Wi{execute(e){throw new Cr("Node kind 'core.agent.hitl' requires the mastra engine, which the local backend does not provide",dr,{kind:"core.agent.hitl",backend:"local"})}};k([w(),Ut({handle:"value"}),C("design:type",Object)],bp.prototype,"value",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.hitl.fields.message.label",placeholder:"graph.node.agent.hitl.fields.message.placeholder",type:"textarea"}),Ut({handle:"message",userControlled:!0}),C("design:type",String)],bp.prototype,"message",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.hitl.fields.prompt.label",type:"textarea"}),Ut({handle:"prompt",userControlled:!0}),C("design:type",String)],bp.prototype,"prompt",void 0),k([w(),Ut({handle:"resumeSchema"}),i("ngx-decaf-model-builder",{label:"graph.node.agent.hitl.fields.resumeSchema.label",placeholder:"graph.node.agent.hitl.fields.resumeSchema.placeholder"}),C("design:type",Object)],bp.prototype,"resumeSchema",void 0),k([$t({handle:"approved"}),C("design:type",Object)],bp.prototype,"approvedOut",void 0),k([$t({handle:"rejected"}),C("design:type",Object)],bp.prototype,"rejectedOut",void 0),bp=k([Mt("core.agent.hitl",{kind:"core.agent.hitl",category:"Agent",width:128,height:112,labels:["agent","ai","hitl","suspend"],metadata:{title:"graph.node.agent.hitl.name",description:"graph.node.agent.hitl.description",shape:"rectangle"}}),I()],bp);const wp=[bp];let vp=class extends Wi{execute(e){throw new Cr("Node kind 'core.agent.trigger.mcp' requires the mastra engine, which the local backend does not provide",dr,{kind:"core.agent.trigger.mcp",backend:"local"})}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.serverId.label",placeholder:"graph.node.agent.mcp_trigger.fields.serverId.placeholder",type:"text"}),Ut({handle:"serverId",userControlled:!0}),C("design:type",String)],vp.prototype,"serverId",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.title.label",type:"text"}),Ut({handle:"title",userControlled:!0}),C("design:type",String)],vp.prototype,"title",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.instructions.label",type:"textarea"}),Ut({handle:"instructions",userControlled:!0}),C("design:type",String)],vp.prototype,"instructions",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.transport.label",type:"select"}),Ut({handle:"transport",userControlled:!0}),C("design:type",String)],vp.prototype,"transport",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.authMode.label",type:"select"}),Ut({handle:"authMode",userControlled:!0}),C("design:type",String)],vp.prototype,"authMode",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.authCredentialRef.label",type:"object"}),Ut({handle:"authCredentialRef",userControlled:!0,type:"object"}),C("design:type",Object)],vp.prototype,"authCredentialRef",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.pendingCap.label",type:"number"}),Ut({handle:"pendingCap",userControlled:!0}),C("design:type",Number)],vp.prototype,"pendingCap",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.mcp_trigger.fields.pendingTimeoutMs.label",type:"number"}),Ut({handle:"pendingTimeoutMs",userControlled:!0}),C("design:type",Number)],vp.prototype,"pendingTimeoutMs",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],vp.prototype,"resource",void 0),vp=k([Mt("core.agent.trigger.mcp",{kind:"core.agent.trigger.mcp",category:"Agent",width:128,height:112,labels:["agent","ai","trigger","mcp","server"],metadata:{title:"graph.node.agent.mcp_trigger.name",description:"graph.node.agent.mcp_trigger.description",shape:"rectangle"}}),I()],vp);const xp=[vp];let Ip=class extends Wi{execute(e){throw new Cr("Node kind 'core.agent.trigger.slack' requires the mastra engine, which the local backend does not provide",dr,{kind:"core.agent.trigger.slack",backend:"local"})}};k([w(),$t({handle:"message"}),C("design:type",Object)],Ip.prototype,"message",void 0),k([w(),$t({handle:"sessionId"}),C("design:type",Object)],Ip.prototype,"sessionId",void 0),k([w(),$t({handle:"userId"}),C("design:type",Object)],Ip.prototype,"userId",void 0),k([w(),$t({handle:"threadId"}),C("design:type",Object)],Ip.prototype,"threadId",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Ip.prototype,"resource",void 0),Ip=k([Mt("core.agent.trigger.slack",{kind:"core.agent.trigger.slack",category:"Agent",icon:"ti-brand-slack",width:96,height:96,labels:["agent","ai","trigger","channel","slack"],metadata:{title:"graph.node.agent.slack_trigger.name",description:"graph.node.agent.slack_trigger.description"}}),I()],Ip);const _p=[Ip];let Ep=class extends Wi{execute(e){throw new Cr("Node kind 'core.agent.trigger.discord' requires the mastra engine, which the local backend does not provide",dr,{kind:"core.agent.trigger.discord",backend:"local"})}};k([w(),$t({handle:"message"}),C("design:type",Object)],Ep.prototype,"message",void 0),k([w(),$t({handle:"sessionId"}),C("design:type",Object)],Ep.prototype,"sessionId",void 0),k([w(),$t({handle:"userId"}),C("design:type",Object)],Ep.prototype,"userId",void 0),k([w(),$t({handle:"threadId"}),C("design:type",Object)],Ep.prototype,"threadId",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Ep.prototype,"resource",void 0),Ep=k([Mt("core.agent.trigger.discord",{kind:"core.agent.trigger.discord",category:"Agent",icon:"ti-brand-discord",width:96,height:96,labels:["agent","ai","trigger","channel","discord"],metadata:{title:"graph.node.agent.discord_trigger.name",description:"graph.node.agent.discord_trigger.description"}}),I()],Ep);const Ap=[Ep];let Sp=class extends Wi{execute(e){throw new Cr("Node kind 'core.agent.trigger.telegram' requires the mastra engine, which the local backend does not provide",dr,{kind:"core.agent.trigger.telegram",backend:"local"})}};k([w(),$t({handle:"message"}),C("design:type",Object)],Sp.prototype,"message",void 0),k([w(),$t({handle:"sessionId"}),C("design:type",Object)],Sp.prototype,"sessionId",void 0),k([w(),$t({handle:"userId"}),C("design:type",Object)],Sp.prototype,"userId",void 0),k([w(),$t({handle:"threadId"}),C("design:type",Object)],Sp.prototype,"threadId",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Sp.prototype,"resource",void 0),Sp=k([Mt("core.agent.trigger.telegram",{kind:"core.agent.trigger.telegram",category:"Agent",icon:"ti-brand-telegram",width:96,height:96,labels:["agent","ai","trigger","channel","telegram"],metadata:{title:"graph.node.agent.telegram_trigger.name",description:"graph.node.agent.telegram_trigger.description"}}),I()],Sp);const Rp=[Sp];let Op=class extends Wi{execute(e){throw new Cr("Node kind 'core.agent.trigger.teams' requires the mastra engine, which the local backend does not provide",dr,{kind:"core.agent.trigger.teams",backend:"local"})}};k([w(),$t({handle:"message"}),C("design:type",Object)],Op.prototype,"message",void 0),k([w(),$t({handle:"sessionId"}),C("design:type",Object)],Op.prototype,"sessionId",void 0),k([w(),$t({handle:"userId"}),C("design:type",Object)],Op.prototype,"userId",void 0),k([w(),$t({handle:"threadId"}),C("design:type",Object)],Op.prototype,"threadId",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Op.prototype,"resource",void 0),Op=k([Mt("core.agent.trigger.teams",{kind:"core.agent.trigger.teams",category:"Agent",icon:"ti-brand-teams",width:96,height:96,labels:["agent","ai","trigger","channel","teams"],metadata:{title:"graph.node.agent.teams_trigger.name",description:"graph.node.agent.teams_trigger.description"}}),I()],Op);const kp=[Op];let Cp=class extends Wi{execute(e){throw new Cr("Node kind 'core.agent.response.slack' requires the mastra engine, which the local backend does not provide",dr,{kind:"core.agent.response.slack",backend:"local"})}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.slack_response.fields.response.label",type:"textarea"}),Ut({handle:"response"}),C("design:type",Object)],Cp.prototype,"response",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.slack_response.fields.threadId.label",type:"text"}),Ut({handle:"threadId",userControlled:!0}),C("design:type",String)],Cp.prototype,"threadId",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Cp.prototype,"resource",void 0),Cp=k([Mt("core.agent.response.slack",{kind:"core.agent.response.slack",category:"Agent",icon:"ti-brand-slack",width:96,height:96,labels:["agent","ai","response","channel","slack"],metadata:{title:"graph.node.agent.slack_response.name",description:"graph.node.agent.slack_response.description"}}),I()],Cp);const Np=[Cp];let Tp=class extends Wi{execute(e){throw new Cr("Node kind 'core.agent.response.discord' requires the mastra engine, which the local backend does not provide",dr,{kind:"core.agent.response.discord",backend:"local"})}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.discord_response.fields.response.label",type:"textarea"}),Ut({handle:"response"}),C("design:type",Object)],Tp.prototype,"response",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.discord_response.fields.threadId.label",type:"text"}),Ut({handle:"threadId",userControlled:!0}),C("design:type",String)],Tp.prototype,"threadId",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Tp.prototype,"resource",void 0),Tp=k([Mt("core.agent.response.discord",{kind:"core.agent.response.discord",category:"Agent",icon:"ti-brand-discord",width:96,height:96,labels:["agent","ai","response","channel","discord"],metadata:{title:"graph.node.agent.discord_response.name",description:"graph.node.agent.discord_response.description"}}),I()],Tp);const Pp=[Tp];let Dp=class extends Wi{execute(e){throw new Cr("Node kind 'core.agent.response.telegram' requires the mastra engine, which the local backend does not provide",dr,{kind:"core.agent.response.telegram",backend:"local"})}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.telegram_response.fields.response.label",type:"textarea"}),Ut({handle:"response"}),C("design:type",Object)],Dp.prototype,"response",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.telegram_response.fields.threadId.label",type:"text"}),Ut({handle:"threadId",userControlled:!0}),C("design:type",String)],Dp.prototype,"threadId",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Dp.prototype,"resource",void 0),Dp=k([Mt("core.agent.response.telegram",{kind:"core.agent.response.telegram",category:"Agent",icon:"ti-brand-telegram",width:96,height:96,labels:["agent","ai","response","channel","telegram"],metadata:{title:"graph.node.agent.telegram_response.name",description:"graph.node.agent.telegram_response.description"}}),I()],Dp);const jp=[Dp];let Lp=class extends Wi{execute(e){throw new Cr("Node kind 'core.agent.response.teams' requires the mastra engine, which the local backend does not provide",dr,{kind:"core.agent.response.teams",backend:"local"})}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.agent.teams_response.fields.response.label",type:"textarea"}),Ut({handle:"response"}),C("design:type",Object)],Lp.prototype,"response",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.teams_response.fields.threadId.label",type:"text"}),Ut({handle:"threadId",userControlled:!0}),C("design:type",String)],Lp.prototype,"threadId",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Lp.prototype,"resource",void 0),Lp=k([Mt("core.agent.response.teams",{kind:"core.agent.response.teams",category:"Agent",icon:"ti-brand-teams",width:96,height:96,labels:["agent","ai","response","channel","teams"],metadata:{title:"graph.node.agent.teams_response.name",description:"graph.node.agent.teams_response.description"}}),I()],Lp);const Mp=[Lp];let Gp=class extends Wi{execute(e){throw new Cr("Node kind 'core.agent.voice' requires the mastra engine, which the local backend does not provide",dr,{kind:"core.agent.voice",backend:"local"})}};k([i("ngx-decaf-crud-field",{label:"graph.node.agent.voice.fields.speaker.label",type:"text"}),Ut({handle:"speaker",userControlled:!0}),C("design:type",String)],Gp.prototype,"speaker",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.voice.fields.speechModel.label",type:"object"}),Ut({handle:"speechModel",userControlled:!0,type:"object"}),C("design:type",Object)],Gp.prototype,"speechModel",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.agent.voice.fields.listeningModel.label",type:"object"}),Ut({handle:"listeningModel",userControlled:!0,type:"object"}),C("design:type",Object)],Gp.prototype,"listeningModel",void 0),k([w(),$t({handle:"resource"}),C("design:type",Object)],Gp.prototype,"resource",void 0),Gp=k([Mt("core.agent.voice",{kind:"core.agent.voice",category:"Agent",icon:"ti-volume-2",shape:"rounded",width:96,height:96,labels:["agent","ai","voice","speech"],metadata:{title:"graph.node.agent.voice.name",description:"graph.node.agent.voice.description"}}),I()],Gp);const Up=[Gp];function $p(e,t,o,r){const n=t??o;if(null==e)return Math.min(o,n);const i=Number(e);if(!Number.isFinite(i)||0>=i)throw new Tr(r+" loop maxIterations must be a positive finite number");return Math.min(Math.floor(i),n)}function Fp(e,t,o){const r=t.node.loop,n=t.metadata?.loop;if(!r?.body&&!n?.body)throw new Tr(o+" node is missing loop configuration (instance.loop.body)");const i=t=>{const o=e[t]??r?.[t]??n?.[t],i=Number(o);return void 0!==o&&Number.isFinite(i)?i:void 0},a=t=>{const o=e[t]??n?.[t];return"string"==typeof o?o:void 0};return{body:r?.body??n?.body,maxIterations:i("maxIterations"),timeoutMs:i("timeoutMs"),concurrency:i("concurrency"),condition:e.condition??n?.condition,inputPort:a("inputPort"),outputPort:a("outputPort"),itemPort:a("itemPort"),resultPort:a("resultPort"),statePort:a("statePort"),slice:i("slice")}}let Hp=class extends Wi{async execute(e,t){const o=Fp(this,t,"foreach"),r=e.inputs,n=r.items,i=$p(o.maxIterations,t.limits?.maxForeachIterations,1e3,"foreach");if(!Array.isArray(n))throw new Tr("foreach input 'items' must be an array");const a=t.engine;if(!a)throw new Cr("foreach node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");const s=Number(r.slice??o.slice??1),d=Number.isFinite(s)&&s>0?Math.floor(s):1,l=d>1?Math.ceil(n.length/d):n.length;if(l>i)throw new Pr(`foreach exceeded max iterations (${l} > ${i})`);const c=o.itemPort??"item",p=o.resultPort??"result",u=o.statePort??"state",g=o.body,h=[];let f=r.state,y=!1;await t.emit({type:yt.LOOP_STARTED});for(let e=0;l>e;e++){await t.emit({type:yt.LOOP_ITERATION_STARTED,iteration:e});const o=d>1?n.slice(e*d,e*d+d):n[e],r={[c]:o,index:e};d>1&&(r.slice=o),void 0!==f&&(r[u]=f);try{const n=await a.execute(g,r,{parentRunId:t.runId,path:[...t.path,"iteration:"+e],metadata:{item:o,index:e,slice:d},auth:t.auth},t);h.push(n.outputs[p]),void 0!==n.outputs[u]&&(f=n.outputs[u])}catch(o){if(o instanceof Gr){const r=o.details?.value;void 0!==r&&h.push(r),y=!0,await t.emit({type:yt.LOOP_ITERATION_COMPLETED,iteration:e,metadata:{broken:!0}});break}throw o}await t.emit({type:yt.LOOP_ITERATION_COMPLETED,iteration:e})}await t.emit({type:yt.LOOP_COMPLETED,metadata:{broken:y}});const m={results:h,completed:h,iterations:h.length,broken:y};return void 0!==f&&(m[u]=f),m}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.items.label",placeholder:"graph.node.loop.foreach.fields.items.placeholder",type:"textarea"}),Ut({handle:"items"}),C("design:type",Array)],Hp.prototype,"items",void 0),k([w(),i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.slice.label",placeholder:"graph.node.loop.foreach.fields.slice.placeholder",type:"number"}),Ut({handle:"slice"}),C("design:type",Number)],Hp.prototype,"slice",void 0),k([w(),$t({handle:"item"}),C("design:type",Object)],Hp.prototype,"item",void 0),k([w(),Ft({handle:"loop",connectionRules:{allowSelf:!0,maxConnections:1}}),C("design:type",Object)],Hp.prototype,"loop",void 0),k([w(),$t({handle:"completed"}),C("design:type",Array)],Hp.prototype,"completed",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.maxIterations.label",type:"number"}),Ut({handle:"maxIterations",userControlled:!0}),C("design:type",Number)],Hp.prototype,"maxIterations",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.condition.label",type:"code"}),Ut({handle:"condition",userControlled:!0}),C("design:type",Object)],Hp.prototype,"condition",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.itemPort.label",type:"text"}),Ut({handle:"itemPort",userControlled:!0}),C("design:type",String)],Hp.prototype,"itemPort",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.resultPort.label",type:"text"}),Ut({handle:"resultPort",userControlled:!0}),C("design:type",String)],Hp.prototype,"resultPort",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.foreach.fields.statePort.label",type:"text"}),Ut({handle:"statePort",userControlled:!0}),C("design:type",String)],Hp.prototype,"statePort",void 0),Hp=k([Mt("graph-foreach-loop-node",{kind:"core.loop.foreach",category:"Loop",color:"#eab308",icon:"ti-repeat",width:120,height:140,labels:["loop","iteration","foreach"],metadata:{title:"graph.node.loop.foreach.name",description:"graph.node.loop.foreach.description",loop:{maxIterations:100,itemPort:"item",resultPort:"result",slice:1}}}),I()],Hp);class Bp{constructor(){this.expressionEvaluator=new fn}evaluate(e,t){if(this.isConditionExpression(e))return this.expressionEvaluator.evaluate(e,t);const o=this.resolveValue(e.left,t),r=e.right;switch(e.type){case Or.TRUTHY:return!!o;case Or.FALSY:return!o;case Or.EQUALS:return o===r;case Or.NOT_EQUALS:return o!==r;case Or.GREATER_THAN:return Number(o)>Number(r);case Or.GREATER_THAN_OR_EQUAL:return Number(o)>=Number(r);case Or.LESS_THAN:return Number(r)>Number(o);case Or.LESS_THAN_OR_EQUAL:return Number(r)>=Number(o);case Or.EXISTS:return null!=o;case Or.CUSTOM:throw new Cr("Custom condition evaluators are not supported in v1","GRAPH_CUSTOM_CONDITION_UNSUPPORTED");default:throw new Cr(`Unknown condition type '${e.type}'`,"GRAPH_UNKNOWN_CONDITION_TYPE",{condition:e})}}async evaluateAsync(e,t,o,r){return yn(e)?bn(e,r,o):this.evaluate(e,t)}resolveValue(e,t){if(!e)return t;const o=e.split(".");let r=t;for(const e of o){if(null==r)return;r=r[e]}return r}isConditionExpression(e){return"string"==typeof e.op}}let qp=class extends Wi{async execute(e,t){const o=Fp(this,t,"until"),r=e.inputs,n=$p(o.maxIterations,t.limits?.maxLoopIterations,100,"until"),i=o.condition;if(!i)throw new Tr("until node is missing a condition");const a=o.statePort??"state",s=o.inputPort??a,d=o.outputPort??a,l=o.body,c=t.engine;if(!c)throw new Cr("until node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let p=r.state,u=0;await t.emit({type:yt.LOOP_STARTED});let g=!1;do{if(u>=n)throw await t.emit({type:yt.LOOP_LIMIT_REACHED,iteration:u}),new Pr(`until loop exceeded max iterations (${n})`);await t.emit({type:yt.LOOP_ITERATION_STARTED,iteration:u}),p=(await c.execute(l,{[s]:p,iteration:u},{parentRunId:t.runId,path:[...t.path,"iteration:"+u],auth:t.auth},t)).outputs[d],await t.emit({type:yt.LOOP_ITERATION_COMPLETED,iteration:u});const e=await(new Bp).evaluateAsync(i,p,t,{...r,state:p});await t.emit({type:yt.LOOP_CONDITION_EVALUATED,iteration:u,payload:{result:e}}),u++,g=e}while(!g);return await t.emit({type:yt.LOOP_COMPLETED}),{state:p,iterations:u}}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.state.label",placeholder:"graph.node.loop.until.fields.state.placeholder",type:"textarea"}),Ut({handle:"state"}),C("design:type",Object)],qp.prototype,"state",void 0),k([w(),$t({handle:"state"}),C("design:type",Object)],qp.prototype,"stateOut",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.maxIterations.label",type:"number"}),Ut({handle:"maxIterations",userControlled:!0}),C("design:type",Number)],qp.prototype,"maxIterations",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.condition.label",type:"code"}),Ut({handle:"condition",userControlled:!0}),C("design:type",Object)],qp.prototype,"condition",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.statePort.label",type:"text"}),Ut({handle:"statePort",userControlled:!0}),C("design:type",String)],qp.prototype,"statePort",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.inputPort.label",type:"text"}),Ut({handle:"inputPort",userControlled:!0}),C("design:type",String)],qp.prototype,"inputPort",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.until.fields.outputPort.label",type:"text"}),Ut({handle:"outputPort",userControlled:!0}),C("design:type",String)],qp.prototype,"outputPort",void 0),qp=k([Mt("graph-until-loop-node",{kind:"core.loop.until",category:"Loop",color:"#eab308",icon:"ti-player-stop",width:96,height:96,labels:["loop","conditional","until"],metadata:{title:"graph.node.loop.until.name",description:"graph.node.loop.until.description",loop:{maxIterations:50,statePort:"state",condition:{type:"greaterThanOrEqual",left:"iteration",right:2}}}}),I()],qp);let Wp=class extends Wi{async execute(e,t){const o=Fp(this,t,"while"),r=e.inputs,n=$p(o.maxIterations,t.limits?.maxLoopIterations,100,"while"),i=o.condition;if(!i)throw new Tr("while node is missing a condition");const a=o.statePort??"state",s=o.inputPort??a,d=o.outputPort??a,l=o.body,c=t.engine;if(!c)throw new Cr("while node requires engine access","GRAPH_ENGINE_NOT_AVAILABLE");let p=r.state,u=0;for(await t.emit({type:yt.LOOP_STARTED});await(new Bp).evaluateAsync(i,p,t,{...r,state:p});){if(u>=n)throw await t.emit({type:yt.LOOP_LIMIT_REACHED,iteration:u}),new Pr(`while loop exceeded max iterations (${n})`);await t.emit({type:yt.LOOP_CONDITION_EVALUATED,iteration:u,payload:{result:!0}}),await t.emit({type:yt.LOOP_ITERATION_STARTED,iteration:u}),p=(await c.execute(l,{[s]:p,iteration:u},{parentRunId:t.runId,path:[...t.path,"iteration:"+u],auth:t.auth},t)).outputs[d],await t.emit({type:yt.LOOP_ITERATION_COMPLETED,iteration:u}),u++}return await t.emit({type:yt.LOOP_COMPLETED}),{state:p,iterations:u}}};k([w(),i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.state.label",placeholder:"graph.node.loop.while.fields.state.placeholder",type:"textarea"}),Ut({handle:"state"}),C("design:type",Object)],Wp.prototype,"state",void 0),k([w(),$t({handle:"state"}),C("design:type",Object)],Wp.prototype,"stateOut",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.maxIterations.label",type:"number"}),Ut({handle:"maxIterations",userControlled:!0}),C("design:type",Number)],Wp.prototype,"maxIterations",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.condition.label",type:"code"}),Ut({handle:"condition",userControlled:!0}),C("design:type",Object)],Wp.prototype,"condition",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.statePort.label",type:"text"}),Ut({handle:"statePort",userControlled:!0}),C("design:type",String)],Wp.prototype,"statePort",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.inputPort.label",type:"text"}),Ut({handle:"inputPort",userControlled:!0}),C("design:type",String)],Wp.prototype,"inputPort",void 0),k([i("ngx-decaf-crud-field",{label:"graph.node.loop.while.fields.outputPort.label",type:"text"}),Ut({handle:"outputPort",userControlled:!0}),C("design:type",String)],Wp.prototype,"outputPort",void 0),Wp=k([Mt("graph-while-loop-node",{kind:"core.loop.while",category:"Loop",color:"#eab308",icon:"ti-arrows-loop",width:96,height:96,labels:["loop","conditional","while"],metadata:{title:"graph.node.loop.while.name",description:"graph.node.loop.while.description",loop:{maxIterations:50,statePort:"state",condition:{type:"lessThan",left:"iteration",right:3}}}}),I()],Wp);let Kp=class extends Wi{execute(e){const t=e.inputs;return{value:t?.value??null}}};k([$t({handle:"value",connectionRules:{allowMultiple:!0}}),C("design:type",Object)],Kp.prototype,"value",void 0),Kp=k([Mt("graph-input-value-node",{kind:"value",category:"Boundary",color:"#0f766e",icon:"ti-circle-plus",labels:["workflow","input","value"],metadata:{title:"graph.node.boundary.input.name",description:"graph.node.boundary.input.description"}}),I()],Kp);let Vp=class extends Wi{execute(e){return{}}};function zp(e,t,o,r={}){return{id:e,label:t,direction:o,...r}}function Qp(e){const t=e,o=Rt(t),r=o?.metadata?.title;return Xo(t,r?{name:r}:{})}function Jp(e,t){const o=e,r=Rt(o),n=r?.metadata?.title;return Xo(o,{...n?{name:n}:{},icon:{type:"catalogue",name:t}})}function Xp(e,t,o){const r={type:"credential",id:"credentialRef",label:o,required:!1,credentialType:t};return{...e,parameters:[...e.parameters,r],credentials:[...(e.credentials??[]).filter(e=>e.type!==t),{type:t,required:!1}]}}k([w(),Ut({handle:"value"}),C("design:type",Object)],Vp.prototype,"value",void 0),Vp=k([Mt("graph-output-value-node",{kind:"result",category:"Boundary",color:"#0f766e",icon:"ti-circle-minus",width:96,height:96,labels:["workflow","output","value"],metadata:{title:"graph.node.boundary.output.name",description:"graph.node.boundary.output.description"}}),I()],Vp);const Yp={kind:"core.loop.foreach",capabilities:["loop"],display:{name:"graph.node.loop.foreach.name",description:"graph.node.loop.foreach.description",category:"Loop",color:"#eab308",icon:{type:"catalogue",name:"ti-repeat"},width:120,height:140,labels:["loop","iteration","foreach"]},inputs:[zp("items","graph.node.loop.foreach.ports.input.items.label","input",{required:!0,schema:{type:"array",items:{type:"any"}}}),zp("slice","graph.node.loop.foreach.ports.input.slice.label","input",{schema:{type:"number",integer:!0,min:1}}),zp("state","graph.node.loop.foreach.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[zp("results","graph.node.loop.foreach.ports.output.results.label","output",{schema:{type:"array",items:{type:"any"}}}),zp("completed","graph.node.loop.foreach.ports.output.completed.label","output",{schema:{type:"array",items:{type:"any"}}}),zp("iterations","graph.node.loop.foreach.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}}),zp("broken","graph.node.loop.foreach.ports.output.broken.label","output",{schema:{type:"boolean"}}),zp("state","graph.node.loop.foreach.ports.output.state.label","output",{schema:{type:"any"}})],parameters:[{type:"number",id:"maxIterations",label:"graph.node.loop.foreach.fields.maxIterations.label",integer:!0,min:1},{type:"object",id:"condition",label:"graph.node.loop.foreach.fields.condition.label"},{type:"string",id:"itemPort",label:"graph.node.loop.foreach.fields.itemPort.label"},{type:"string",id:"resultPort",label:"graph.node.loop.foreach.fields.resultPort.label"},{type:"string",id:"statePort",label:"graph.node.loop.foreach.fields.statePort.label"},{type:"number",id:"slice",label:"graph.node.loop.foreach.fields.slice.label",integer:!0,min:1}]},Zp={kind:"core.loop.while",capabilities:["loop"],display:{name:"graph.node.loop.while.name",description:"graph.node.loop.while.description",category:"Loop",color:"#eab308",icon:{type:"catalogue",name:"ti-arrows-loop"},width:120,height:140,labels:["loop","conditional","while"]},inputs:[zp("state","graph.node.loop.while.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[zp("state","graph.node.loop.while.ports.output.state.label","output",{schema:{type:"any"}}),zp("iterations","graph.node.loop.while.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}})],parameters:[{type:"number",id:"maxIterations",label:"graph.node.loop.while.fields.maxIterations.label",integer:!0,min:1},{type:"object",id:"condition",label:"graph.node.loop.while.fields.condition.label",required:!0},{type:"string",id:"statePort",label:"graph.node.loop.while.fields.statePort.label"},{type:"string",id:"inputPort",label:"graph.node.loop.while.fields.inputPort.label"},{type:"string",id:"outputPort",label:"graph.node.loop.while.fields.outputPort.label"}]},eu={kind:"core.loop.until",capabilities:["loop"],display:{name:"graph.node.loop.until.name",description:"graph.node.loop.until.description",category:"Loop",color:"#eab308",icon:{type:"catalogue",name:"ti-player-stop"},width:120,height:140,labels:["loop","conditional","until"]},inputs:[zp("state","graph.node.loop.until.ports.input.state.label","input",{schema:{type:"any"}})],outputs:[zp("state","graph.node.loop.until.ports.output.state.label","output",{schema:{type:"any"}}),zp("iterations","graph.node.loop.until.ports.output.iterations.label","output",{schema:{type:"number",integer:!0,min:0}})],parameters:[{type:"number",id:"maxIterations",label:"graph.node.loop.until.fields.maxIterations.label",integer:!0,min:1},{type:"object",id:"condition",label:"graph.node.loop.until.fields.condition.label",required:!0},{type:"string",id:"statePort",label:"graph.node.loop.until.fields.statePort.label"},{type:"string",id:"inputPort",label:"graph.node.loop.until.fields.inputPort.label"},{type:"string",id:"outputPort",label:"graph.node.loop.until.fields.outputPort.label"}]},tu=[Qp(Kp),Qp(Vp),Qp(Ea),Qp(Aa),Qp(Ra),Qp(Oa),Qp(Ca),Qp(Ta),Qp(Pa),Qp(Da),Qp(ja),Qp(rs),Qp(ns),Qp(ds),Qp(ls),Qp(cs),Qp(us),Qp(hs),Qp(ys),Qp(Is),Xp(Qp(Ls),"postgres","graph.node.storage.common.fields.credentialRef.label"),Xp(Qp(Ms),"mysql","graph.node.storage.common.fields.credentialRef.label"),Xp(Qp(Gs),"mssql","graph.node.storage.common.fields.credentialRef.label"),Xp(Qp(Hs),"redis","graph.node.storage.common.fields.credentialRef.label"),Xp(Qp(qs),"rabbitmq","graph.node.storage.common.fields.credentialRef.label"),Xp(Qp(zs),"s3","graph.node.storage.common.fields.credentialRef.label"),Xp(Qp(Qs),"s3","graph.node.storage.common.fields.credentialRef.label"),Xp(Qp(Js),"gcs","graph.node.storage.common.fields.credentialRef.label"),Xp(Qp(Ys),"azure-blob","graph.node.storage.common.fields.credentialRef.label"),Xp(Qp(El),"crypto","graph.node.devops.common.fields.credentialRef.label"),Xp(Qp(Sl),"jwt","graph.node.devops.common.fields.credentialRef.label"),(()=>{const e=Qp(Ol);return{...e,metadata:{...e.metadata??{},danger:!0,requiresOptIn:!0,dangerReason:"Executes arbitrary shell commands with the host process privileges; expose only behind an explicit operator opt-in."}}})(),Xp(Qp(Nl),"sftp","graph.node.devops.common.fields.credentialRef.label"),Xp(Qp(wl),"github","graph.node.devops.common.fields.credentialRef.label"),Xp(Qp(xl),"gitlab","graph.node.devops.common.fields.credentialRef.label"),Xp(Qp(ed),"slack","graph.node.comms.common.fields.credentialRef.label"),Xp(Qp(od),"telegram","graph.node.comms.common.fields.credentialRef.label"),Xp(Qp(nd),"teams","graph.node.comms.common.fields.credentialRef.label"),Xp(Qp(ad),"gmail","graph.node.comms.common.fields.credentialRef.label"),Xp(Qp(dd),"email","graph.node.comms.common.fields.credentialRef.label"),Xp(Qp(pd),"discord","graph.node.comms.common.fields.credentialRef.label"),Xp(Qp(hd),"whatsapp","graph.node.comms.common.fields.credentialRef.label"),Xp(Qp(md),"microsoft-outlook","graph.node.comms.common.fields.credentialRef.label"),Xp(Qp(wd),"google-sheets","graph.node.io.common.fields.credentialRef.label"),Xp(Qp(xd),"airtable","graph.node.io.common.fields.credentialRef.label"),Xp(Qp(Ad),"graphql","graph.node.io.common.fields.credentialRef.label"),Xp(Qp(Od),"microsoft-excel","graph.node.io.common.fields.credentialRef.label"),Xp(Qp(Cd),"confluence","graph.node.io.common.fields.credentialRef.label"),Xp(Qp(Pd),"jira","graph.node.io.common.fields.credentialRef.label"),Xp(Qp(Ld),"google-docs","graph.node.io.common.fields.credentialRef.label"),Xp(Qp(Gd),"microsoft-sharepoint","graph.node.io.common.fields.credentialRef.label"),Xp(Qp(Fd),"google-calendar","graph.node.io.common.fields.credentialRef.label"),Qp(_d),Qp(dl),Qp(ll),Qp(cl),Qp(pl),Qp(hl),Qp(fl),Qp(yl),Qp(ml),Qp(_s),Qp(Tl),Qp(Pl),Qp($l),Qp(Bl),Xp(Qp(Jl),"rabbitmq","graph.node.storage.common.fields.credentialRef.label"),Xp(Qp(Xl),"redis","graph.node.storage.common.fields.credentialRef.label"),Xp(Qp(Yl),"token","graph.node.storage.common.fields.credentialRef.label"),Xp(Qp(ec),"postgres","graph.node.storage.common.fields.credentialRef.label"),Qp(Ml),Qp(Ul),Qp(Gl),Qp(jl),Qp(Ll),Qp(Dl),(ou=Qp(Ji),{...ou,dynamicPorts:[{type:"togglePort",parameter:"else",equals:!0,port:{id:"else",label:"graph.node.flow_control.if.ports.output.else.label",direction:"output",schema:{type:"any"}}}]}),(e=>({...e,outputs:[],parameters:[...e.parameters,{type:"collection",id:"cases",label:"graph.node.flow_control.switch.fields.cases.label",required:!0,itemIdPath:"outputPort",itemLabelPath:"label"},{type:"boolean",id:"hasDefault",label:"graph.node.flow_control.switch.fields.hasDefault.label",defaultValue:!1},{type:"object",id:"switch",label:"graph.node.flow_control.switch.fields.switch.label",required:!1}],dynamicPorts:[{type:"repeatFromParameter",parameter:"cases",itemIdPath:"outputPort",itemLabelPath:"label",direction:"output",portIdTemplate:"${id}",defaultPort:{id:"case",label:"graph.node.flow_control.switch.ports.output.case.label",direction:"output",schema:{type:"any"}}},{type:"togglePort",parameter:"hasDefault",equals:!0,port:{id:"default",label:"graph.node.flow_control.switch.ports.output.default.label",direction:"output",schema:{type:"any"}}}]}))(Qp(Xi)),Qp(da),Qp(aa),Qp(zi),Qp(Qi),Qp(ia),Qp(sa),Qp(la),Qp(Ki),Qp(rc),Qp(ic),Qp(sc),Qp(lc),Qp(pc),Qp(gc),Qp(fc),Qp(mc),Qp(vc),Qp(Ic),Qp(Ec),Qp(Nc),Qp(Tc),Qp(Dc),Qp(Lc),Qp(Gc),Qp(Kc),Qp(zc),Qp(Jc),Qp(Yc),Qp(ep),Qp(rp),Qp(ip),Qp(sp),Qp(up),Qp(hp),Qp(yp),Qp(bp),Qp(vp),Jp(Ip,"ti-brand-slack"),Jp(Ep,"ti-brand-discord"),Jp(Sp,"ti-brand-telegram"),Jp(Op,"ti-brand-teams"),Jp(Cp,"ti-brand-slack"),Jp(Tp,"ti-brand-discord"),Jp(Dp,"ti-brand-telegram"),Jp(Lp,"ti-brand-teams"),Jp(Gp,"ti-volume-2"),Yp,Zp,eu];var ou;const ru=Object.fromEntries(tu.map(e=>[e.kind,e])),nu=[Ml,Ul,Gl,jl,Ll,Dl],iu=[Ji,Xi,aa,zi,Qi,sa,Ki],au=[ia,da,la],su=[Hp,Wp,qp],du=[Kp,Vp],lu=[ic,sc,lc,pc,gc,fc,mc,vc,Ic,Ec],cu=[Nc,Tc],pu=[Dc,Lc,Gc,Kc,zc,Jc,Yc,ep,rp,ip,sp],uu=[up,hp,yp],gu=[bp,vp],hu=[Ip,Ep,Sp,Op,Cp,Tp,Dp,Lp,Gp],fu=[Pa,Ca,Ra,ja,Ea,Aa,Oa,Da,Ta,rs,ns,ds,ls,cs],yu=[hs,_s,us,ys,Is,dl,ll,cl,pl,hl,fl,yl,ml],mu={value:Kp,result:Vp,"core.trigger.manual":Ml,"core.trigger.webhook":Ul,"core.trigger.schedule":Gl,"core.trigger.event":jl,"core.trigger.form":Ll,"core.trigger.chat":Dl,"core.flow.if":Ji,"core.flow.switch":Xi,"core.utility.map":da,"core.flow.delay":aa,"core.flow.errorBoundary":zi,"core.flow.humanApproval":Qi,"core.utility.code":ia,"core.flow.log":sa,"core.utility.log":la,"core.flow.break":Ki,"core.agent":rc,"core.agent.tool":ic,"core.agent.toolSelector":sc,"core.agent.hook":lc,"core.agent.toolDeny":pc,"core.agent.delegationHook":gc,"core.agent.skill":fc,"core.agent.skillSelector":mc,"core.agent.sandbox":vc,"core.agent.scorer":Ic,"core.agent.scorerSelector":Ec,"core.agent.memory":Nc,"core.agent.memorySelector":Tc,"core.agent.embedding":Dc,"core.agent.vectorStore":Lc,"core.agent.retriever":Gc,"core.agent.chunking":Kc,"core.agent.rerank":zc,"core.agent.chain.qa":Jc,"core.agent.chain.basic":Yc,"core.agent.chain.summarization":ep,"core.agent.structuredOutputParser":rp,"core.agent.informationExtractor":ip,"core.agent.langchainCode":sp,"core.agent.inputProcessor":up,"core.agent.outputProcessor":hp,"core.agent.guardrail":yp,"core.agent.hitl":bp,"core.agent.trigger.mcp":vp,"core.agent.trigger.slack":Ip,"core.agent.trigger.discord":Ep,"core.agent.trigger.telegram":Sp,"core.agent.trigger.teams":Op,"core.agent.response.slack":Cp,"core.agent.response.discord":Tp,"core.agent.response.telegram":Dp,"core.agent.response.teams":Lp,"core.agent.voice":Gp,"core.data.set":Pa,"core.data.merge":Ca,"core.data.filter":Ra,"core.data.splitOut":ja,"core.data.aggregate":rs,"core.data.itemLists":ns,"core.data.compareDatasets":ds,"core.data.summarize":ls,"core.data.removeDuplicates":cs,"core.data.dateTime":Ea,"core.data.dataTable":Aa,"core.data.limit":Oa,"core.data.sort":Da,"core.data.renameKeys":Ta,"core.io.httpRequest":hs,"core.io.respondToWebhook":_s,"core.io.extractFromFile":us,"core.io.readPDF":ys,"core.io.readWriteFile":Is,"core.storage.postgres":Ls,"core.storage.mySql":Ms,"core.storage.microsoftSql":Gs,"core.storage.redis":Hs,"core.storage.rabbitmq":qs,"core.storage.s3":zs,"core.storage.awsS3":Qs,"core.storage.googleCloudStorage":Js,"core.storage.azureStorage":Ys,"core.devops.crypto":El,"core.devops.jwt":Sl,"core.devops.executeCommand":Ol,"core.devops.ftp":Nl,"core.devops.github":wl,"core.devops.gitlab":xl,"core.comms.slack":ed,"core.comms.telegram":od,"core.comms.teams":nd,"core.comms.gmail":ad,"core.comms.emailSend":dd,"core.comms.discord":pd,"core.comms.whatsApp":hd,"core.comms.microsoftOutlook":md,"core.io.googleSheets":wd,"core.io.airtable":xd,"core.io.spreadsheetFile":_d,"core.io.graphql":Ad,"core.io.microsoftExcel":Od,"core.io.confluence":Cd,"core.io.jira":Pd,"core.io.googleDocs":Ld,"core.io.microsoftSharePoint":Gd,"core.io.googleCalendar":Fd,"core.io.convertToFile":dl,"core.io.html":ll,"core.io.htmlExtract":cl,"core.io.markdown":pl,"core.io.xml":hl,"core.io.readBinaryFile":fl,"core.io.readBinaryFiles":yl,"core.io.writeBinaryFile":ml,"core.flow.executeSubWorkflow":Tl,"core.trigger.executeWorkflow":Pl,"core.trigger.error":$l,"core.trigger.workflow":Bl,"core.trigger.rabbitmq":Jl,"core.trigger.redis":Xl,"core.trigger.sse":Yl,"core.trigger.postgres":ec,"core.loop.foreach":Hp,"core.loop.while":Wp,"core.loop.until":qp};function bu(e){return{execute:(t,o)=>e.instantiate({...qi(o.node),...t.parameters,...o.node.state??{}}).execute(t,o)}}function wu(){const e=[];for(const[t,o]of Object.entries(ru)){const r=mu[t];r&&e.push(Hi({manifest:o,executor:bu(r)}))}return e}function vu(e,...t){for(const o of wu())e.register(o,{},...t);return e}class xu{resolve(e){const t=this.createValidator(e);return{name:e.name,required:e.required,validate:t}}resolveAll(e){const t={};for(const o of e)t[o.name]=this.resolve(o);return t}createValidator(e){switch((e.type??e.designType??"").toLowerCase()){case"string":return e=>"string"==typeof e;case"number":return e=>"number"==typeof e;case"boolean":return e=>"boolean"==typeof e;case"date":return e=>e instanceof Date||"string"==typeof e&&!isNaN(Date.parse(e));case"array":return e=>Array.isArray(e);case"bigint":return e=>"bigint"==typeof e;default:return()=>!0}}}class Iu{constructor(e){this.resolver=e}validateWorkflowInputs(e,t){this.validatePorts(e.inputs,t,"workflow input")}validateWorkflowOutputs(e,t){this.validatePorts(e.outputs,t,"workflow output")}validateNodeInputs(e,t){const o=(e.ports??[]).filter(e=>"input"===e.direction);this.validatePorts(o,t,`node '${e.name}' input`)}validateNodeOutputs(e,t){const o=(e.ports??[]).filter(e=>"output"===e.direction);this.validatePorts(o,t,`node '${e.name}' output`)}validatePorts(e,t,o){if(e)for(const r of e){const e=Object.prototype.hasOwnProperty.call(t,r.name);if(r.required&&!e)throw new Tr(`Missing required ${o} port '${r.name}'`);if(e&&!this.resolver.resolve(r).validate(t[r.name]))throw new Tr(`Invalid value for ${o} port '${r.name}'`)}}}const _u=["node","definition","executor","execute","ports","component"];function Eu(e,t,o,r){return{code:e,path:t,message:o,...void 0!==r?.nodeId?{nodeId:r.nodeId}:{},...void 0!==r?.edgeId?{edgeId:r.edgeId}:{},...r?.details?{details:r.details}:{}}}function Au(e,t){const o=[];for(const r of Object.keys(e))_u.includes(r)&&o.push(Eu("document.forbidden-field",`${t}.${r}`,`Field '${r}' is not accepted in a canonical workflow document: node, definition, executor, execute, ports and component fields are rejected at the boundary`,{details:{field:r}}));return o}function Su(e,t){t.push(...Au(e,"$")),e.inputs.forEach((e,o)=>t.push(...Au(e,`inputs[${o}]`))),e.outputs.forEach((e,o)=>t.push(...Au(e,`outputs[${o}]`)));for(const o of e.nodes)t.push(...Au(o,`nodes[${o.id}]`)),o.loop&&(t.push(...Au(o.loop,`nodes[${o.id}].loop`)),Su(o.loop.body,t));for(const o of e.edges)t.push(...Au(o,`edges[${o.id}]`))}function Ru(e,t){const o=[];e.nodes.length>t.maxNodes&&o.push(Eu("document.limit.nodes","$.nodes",`Document declares ${e.nodes.length} nodes; at most ${t.maxNodes} are allowed`,{details:{count:e.nodes.length,limit:t.maxNodes}})),e.edges.length>t.maxEdges&&o.push(Eu("document.limit.edges","$.edges",`Document declares ${e.edges.length} edges; at most ${t.maxEdges} are allowed`,{details:{count:e.edges.length,limit:t.maxEdges}}));const r=Ou(e);r>t.maxNestingDepth&&o.push(Eu("document.limit.depth","$.nodes",`Document nests loop bodies ${r} levels deep; at most ${t.maxNestingDepth} levels are allowed`,{details:{depth:r,limit:t.maxNestingDepth}}));const n=Buffer.byteLength(JSON.stringify(e),"utf8");return n>t.maxDocumentBytes&&o.push(Eu("document.limit.size","$",`Document serializes to ${n} bytes; at most ${t.maxDocumentBytes} bytes are allowed`,{details:{bytes:n,limit:t.maxDocumentBytes}})),o}function Ou(e,t=0){let o=t;for(const r of e.nodes)r.loop?.body&&(o=Math.max(o,Ou(r.loop.body,t+1)));return o}async function ku(e,t,...o){const r=[];for(const n of e.nodes)t.has(n.kind,...o)||r.push(Eu("node.unknown-kind",`nodes[${n.id}].kind`,`Node '${n.id}' references kind '${n.kind}' which is not registered in the backend catalogue`,{nodeId:n.id,details:{kind:n.kind}})),n.loop?.body&&r.push(...await ku(n.loop.body,t,...o));return r}async function Cu(e,t={},...o){const r={...Yi,...t.limits},n=[];if(!_o(e))return n.push(Eu("document.shape","$","Payload is not a canonical GraphWorkflowDocument: id and name must be strings and inputs, outputs, nodes and edges must be arrays")),{valid:!1,issues:n};if(!Vt(e))return n.push(Eu("document.json-unsafe","$","Document contains JSON-unsafe values: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys (__proto__/prototype/constructor) are rejected")),{valid:!1,issues:n};Su(e,n),n.push(...(e=>{const t=[],o=new Set;for(const r of[...e.inputs,...e.outputs])o.has(r.id)?t.push(Eu("document.duplicate-port-id",`ports[${r.id}]`,`Workflow port '${r.id}' is declared more than once; workflow port ids must be unique`)):o.add(r.id);const r=new Set;for(const o of e.nodes)r.has(o.id)?t.push(Eu("document.duplicate-node-id",`nodes[${o.id}]`,`Node '${o.id}' is declared more than once; node ids must be unique`,{nodeId:o.id})):r.add(o.id);const n=new Set;for(const o of e.edges)n.has(o.id)?t.push(Eu("document.duplicate-edge-id",`edges[${o.id}]`,`Edge '${o.id}' is declared more than once; edge ids must be unique`,{edgeId:o.id})):n.add(o.id);return t})(e)),n.push(...Ru(e,r)),Xn(e,n);try{go(e)}catch(e){const t=e instanceof S?e.message:e+"";n.push(Eu("document.structure","$",t))}return t.catalogue&&n.push(...await ku(e,t.catalogue,...o)),{valid:0===n.length,issues:n}}class Nu{constructor(e,t){this.iteration=e,this.metadata=t}}function Tu(e,t,o={}){const r=e?.owner??null;return!r||r===t||(null==t||""===t)&&!0===o.allowAnonymousAccess}function Pu(e,t){return(e?.owner??null)===(t??null)}function Du(e,t,o){if(!Pu(e,t))throw new M(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function ju(e,t,o){if(!Tu(e,t,o))throw new M(`${o.resourceKind} '${o.resourceId}' is owned by another user`)}function Lu(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>Lu(e)).join(",")}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${Lu(t[e])}`).join(",")}}`}function Mu(e){return ee("sha256").update(Lu(e)).digest("hex")}class Gu{constructor(e={}){this.events=new Map,this.listeners=new Map,this.limits={...mt,...e}}async append(e){let t=this.events.get(e.runId);t||(t=[],this.events.set(e.runId,t)),t.push(e),this.enforceRetention(t);for(const t of this.listeners.get(e.runId)??[])try{t(e)}catch{}}async listAfter(e,t){const o=this.events.get(e);return o?o.filter(e=>e.sequence>t):[]}subscribe(e,t){let o=this.listeners.get(e);return o||(o=new Set,this.listeners.set(e,o)),o.add(t),()=>{o.delete(t),0===o.size&&this.listeners.delete(e)}}release(e){this.events.delete(e),this.listeners.delete(e)}enforceRetention(e){const t=this.limits.maxEventsPerRun;for(;e.length>t;){const t=e.findIndex(e=>!wt(e.type));if(-1===t)break;e.splice(t,1)}}}function Uu(e){return new er({runId:e.runId,workflowId:e.workflowId,...e.ownerUser?{owner:e.ownerUser}:{},status:e.status,...e.documentFingerprint?{documentFingerprint:e.documentFingerprint}:{},...void 0!==e.result?{result:$u(e.result)}:{},...e.error?{error:$u(e.error)}:{},createdAt:new Date(e.createdAt),...e.startedAt?{startedAt:new Date(e.startedAt)}:{},...e.finishedAt?{finishedAt:new Date(e.finishedAt)}:{}})}function $u(e){if(null!=e)return JSON.parse(JSON.stringify(e))}class Fu{constructor(){this.runs=new Map}async saveRun(e){this.runs.set(e.runId,{...e})}async readRun(e){const t=this.runs.get(e);return t?{...t}:null}async listRuns(e){return[...this.runs.values()].filter(t=>t.workflowId===e).map(e=>Uu(e))}release(e){this.runs.delete(e)}}class Hu{constructor(e,t={}){this.sequences=new Map,this.chains=new Map,this.store=e,this.limits={...mt,...t}}async publish(e){const t=e.runId,o=(this.sequences.get(t)??0)+1;this.sequences.set(t,o);const r={...e,payload:this.limitPayload(e.payload),sequence:o,timestamp:(new Date).toISOString()},n=(this.chains.get(t)??Promise.resolve()).then(()=>this.store.append(r));return this.chains.set(t,n.catch(()=>{})),await n,r}lastSequence(e){return this.sequences.get(e)??0}release(e){this.sequences.delete(e),this.chains.delete(e)}limitPayload(e){if(void 0===e)return;let t;try{t=JSON.stringify(e)}catch{return{nonSerializable:!0}}return t.length>this.limits.maxEventPayloadBytes?{truncated:!0,reason:"event payload exceeds the configured byte limit",bytes:t.length}:e}}class Bu{constructor(e,t,o,r={},n={}){this.controllers=new Map,this.completions=new Map,this.timeouts=new Map,this.engine=e,this.runStore=t,this.publisher=o,this.hooks=r,this.limits={...mt,...n}}begin(e){const t=this.controllers.get(e);if(t)return t;const o=new AbortController;return this.controllers.set(e,o),o}abort(e,t){const o=this.controllers.get(e);return!!o&&(o.signal.aborted||o.abort(t),!0)}isAborted(e){return!0===this.controllers.get(e)?.signal.aborted}abortReason(e){const t=this.controllers.get(e)?.signal;if(t?.aborted)return"timeout"===t.reason?"timeout":"user"}waitFor(e){return this.completions.get(e)}schedule(e,t,o,...r){const n=this.completions.get(e.runId);if(n)return n;const i=this.runExecution({...e},t,o,...r).catch(async t=>{const o=qu(t);try{await this.emitTerminal({...e},yt.WORKFLOW_FAILED,o)}catch{}return await this.finalize({...e},"failed",void 0,o,...r)});return this.completions.set(e.runId,i),i}release(e){this.controllers.delete(e),this.completions.delete(e);const t=this.timeouts.get(e);t&&(clearTimeout(t),this.timeouts.delete(e)),this.publisher.release(e)}armTimeout(e){const t=setTimeout(()=>{this.timeouts.delete(e),this.abort(e,"timeout")},this.limits.executionTimeoutMs);this.timeouts.set(e,t)}async runExecution(e,t,o,...r){const n=e.runId;let i,a,s=!1;const d=this.engine.observe({refresh:async t=>{t.runId===n&&(t.error&&(i=t.error),wt((await this.publisher.publish(this.envelopeOf(e,t))).type)?s=!0:t.type===yt.WORKFLOW_STARTED&&"validating"===e.status&&(e.status="running",await this.persist(e,...r)))}});this.armTimeout(n);try{if(this.isAborted(n)){const t={name:"GraphRunCancelledError",message:`Graph run '${n}' was cancelled before execution started`,code:"GRAPH_RUN_CANCELLED"};return i=t,await this.emitTerminal(e,yt.WORKFLOW_CANCELLED,t),s=!0,await this.finalize(e,"cancelled",void 0,t,...r)}let d,l;e.status="validating",e.startedAt=(new Date).toISOString(),await this.persist(e,...r);try{({document:d,fingerprint:l}=await t(...r)),e.documentFingerprint=l,await this.persist(e,...r)}catch(t){const o=qu(t);return i=o,s||(await this.emitTerminal(e,yt.WORKFLOW_FAILED,o),s=!0),await this.finalize(e,"failed",void 0,o,...r)}if(this.isAborted(n)){const t={name:"GraphRunCancelledError",message:`Graph run '${n}' was cancelled before execution started`,code:"GRAPH_RUN_CANCELLED"};return i=t,s||(await this.emitTerminal(e,yt.WORKFLOW_CANCELLED,t),s=!0),await this.finalize(e,"cancelled",void 0,t,...r)}try{a=await this.engine.execute(d,o,{runId:n,abortSignal:this.controllers.get(n)?.signal,metadata:{documentFingerprint:l}},...r)}catch(e){i=qu(e)}const c=this.abortReason(n);let p,u;return"timeout"===c?(p="failed",u=i??{name:"GraphRunTimeoutError",message:`Graph run '${n}' exceeded the configured execution timeout of ${this.limits.executionTimeoutMs}ms`,code:"GRAPH_RUN_TIMEOUT"}):"user"===c?(p="cancelled",u=i):a?.status===gt.SUCCEEDED?p="succeeded":a?.status===gt.CANCELLED?(p="cancelled",u=i):(p="failed",u=i??qu(new Cr(a?`Graph run '${n}' failed`:`Graph run '${n}' failed without a result`,"GRAPH_RUN_FAILED",{runId:n}))),s||await this.emitTerminal(e,"succeeded"===p?yt.WORKFLOW_COMPLETED:"cancelled"===p?yt.WORKFLOW_CANCELLED:yt.WORKFLOW_FAILED,u),await this.finalize(e,p,a,u,...r)}finally{d();const e=this.timeouts.get(n);e&&(clearTimeout(e),this.timeouts.delete(n))}}async emitTerminal(e,t,o){await this.publisher.publish({runId:e.runId,workflowId:e.workflowId,type:t,error:o})}async finalize(e,t,o,r,...n){e.status=t,o&&(e.result=o),r&&(e.error=r),e.startedAt||(e.startedAt=(new Date).toISOString()),e.finishedAt=(new Date).toISOString(),await this.persist(e,...n);try{await(this.hooks.onRunCompleted?.(e,o))}catch{}return e}async persist(e,...t){await this.runStore.saveRun({...e},...t)}envelopeOf(e,t){return{runId:e.runId,workflowId:t.workflowId??e.workflowId,type:t.type,nodeId:t.nodeId,edgeId:t.edgeId,payload:void 0===t.payload?void 0:Kt(t.payload)?t.payload:{nonSerializable:!0},error:t.error,parentRunId:t.parentRunId,path:t.path}}}function qu(e){return e instanceof Error?{name:e.name,message:e.message,stack:e.stack,code:e.graphCode??("number"==typeof e.code?e.code+"":e.code)}:{name:"UnknownError",message:e+""}}class Wu{constructor(e,t,o,r={}){this.activeByCaller=new Map,this.callerKeysByRun=new Map,this.releaseTimers=new Map,this.engine=e,this.runStore=t,this.eventStore=o,this.publisher=new Hu(o,r.limits),this.executor=new Bu(e,t,this.publisher,{onRunCompleted:r.onRunCompleted},r.limits),this.options={...r,limits:{...mt,...r.limits}}}get limits(){return this.options.limits}async createRun(e,t,o,...r){this.validateCreateRequest(e);const n=e.workflowId??e.workflow?.id??"";if(!n)throw new S("Graph run request must carry a workflow document with an id or a saved workflowId");if(e.workflowId&&!this.options.documentResolver)throw new S("Graph run requests by workflowId require a document resolver");const i=o??t??"anonymous",a=this.activeByCaller.get(i)??new Set;if(a.size>=this.options.limits.maxConcurrentRuns)throw new S(`Graph run rejected: the configured limit of ${this.options.limits.maxConcurrentRuns} concurrent runs per caller is exhausted`);const s=this.generateRunId(),d={runId:s,workflowId:n,ownerUser:t,status:"queued",createdAt:(new Date).toISOString()};this.executor.begin(s),await this.runStore.saveRun({...d},...r);const l=this.documentProviderFor(e,t);return a.add(s),this.activeByCaller.set(i,a),this.callerKeysByRun.set(s,i),this.executor.schedule(d,l,e.inputs??{},...r).catch(()=>{}).finally(()=>this.finishActiveRun(s)),d}async getRun(e,t,...o){const r=await this.runStore.readRun(e,...o);if(!r)throw new O(`No graph run found for runId '${e}'`);return this.assertOwnership(r,t),r}async listRunsByWorkflow(e,t,...o){return(await this.runStore.listRuns(e,...o)).filter(e=>Tu({owner:e.owner},t,{allowAnonymousAccess:!0===this.options.allowAnonymousAccess})).sort((e,t)=>{const o=e.updatedAt instanceof Date?e.updatedAt.getTime():NaN,r=t.updatedAt instanceof Date?t.updatedAt.getTime():NaN;return(Number.isFinite(r)?r:0)-(Number.isFinite(o)?o:0)})}async cancelRun(e,t,...o){const r=await this.runStore.readRun(e,...o);if(!r)throw new O(`No graph run found for runId '${e}'`);return this.assertWriteOwnership(r,t),"succeeded"===(n=r.status)||"failed"===n||"cancelled"===n||(this.executor.abort(e,"user"),r.status="cancelled",r.finishedAt=(new Date).toISOString(),await this.runStore.saveRun({...r},...o)),r;var n}async resumeRun(e,t,o,...r){const n=await this.runStore.readRun(e,...r);if(!n)throw new O(`No graph run found for runId '${e}'`);this.assertWriteOwnership(n,o);const i=this.engine.backend,a=i.resume;if("function"!=typeof a)throw new Cr(`Graph execution backend '${i.constructor?.name??"GraphExecutionBackend"}' does not support resume`,"GRAPH_RESUME_UNSUPPORTED_BACKEND",{runId:e});let s;try{s=await a.call(i,e,t,...r)}catch(e){throw(d=e)instanceof Cr?new Cr(d.message,d.graphCode):d}var d;const l={...s,runId:e,caller:o};return await this.publisher.publish({runId:e,workflowId:n.workflowId,type:yt.WORKFLOW_RESUMED,payload:l}),l}async listEvents(e,t,o,...r){return await this.getRun(e,o,...r),this.eventStore.listAfter(e,t)}async subscribeEvents(e,t,o,...r){return await this.getRun(e,t,...r),this.eventStore.subscribe(e,o)}subscribeRunEvents(e,t){return this.eventStore.subscribe(e.runId,t)}async waitForRun(e,t,...o){const r=this.executor.waitFor(e);return r&&await r,this.getRun(e,t,...o)}async executeAndWait(e,t,o,...r){const n=await this.createRun(e,t,o,...r);return this.waitForRun(n.runId,t,...r)}release(e){this.finishActiveRun(e);const t=this.releaseTimers.get(e);t&&(clearTimeout(t),this.releaseTimers.delete(e)),this.executor.release(e),this.eventStore.release?.(e)}finishActiveRun(e){const t=this.callerKeysByRun.get(e);if(void 0!==t){this.callerKeysByRun.delete(e);const o=this.activeByCaller.get(t);o&&(o.delete(e),0===o.size&&this.activeByCaller.delete(t))}if(this.releaseTimers.has(e))return;const o=setTimeout(()=>{this.releaseTimers.delete(e),this.release(e)},this.options.limits.eventReplayWindowMs);o.unref?.(),this.releaseTimers.set(e,o)}validateCreateRequest(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new S("Graph run request must be an object carrying either a workflow document or a workflowId plus inputs");const t=void 0!==e.workflow,o=void 0!==e.workflowId;if(t&&o)throw new S("Graph run request is ambiguous: supply either an unsaved workflow document or a saved workflowId, not both");if(!t&&!o)throw new S("Graph run request must supply either an unsaved workflow document or a saved workflowId");if(t&&!_o(e.workflow))throw new S("Graph run request carries a payload that is not a canonical GraphWorkflowDocument");if(void 0!==e.inputs&&!Vt(e.inputs))throw new S("Graph run inputs must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys (__proto__/prototype/constructor) are rejected");const r=(e=>{try{return JSON.stringify(e)?.length??0}catch{return Number.MAX_SAFE_INTEGER}})(e);if(r>this.options.limits.maxRequestBytes)throw new S(`Graph run request of ${r} bytes exceeds the configured limit of ${this.options.limits.maxRequestBytes} bytes`)}documentProviderFor(e,t){if(e.workflow){const t=e.workflow;return async()=>({document:t,fingerprint:Mu(t)})}const o=e.workflowId;return async(...e)=>{const r=this.options.documentResolver;if(!r)throw new S("Graph run requests by workflowId require a document resolver");const n=await r.resolve(o,t,...e);return{document:n,fingerprint:Mu(n)}}}assertOwnership(e,t){ju({owner:e.ownerUser},t,{allowAnonymousAccess:!0===this.options.allowAnonymousAccess,resourceKind:"Graph run",resourceId:e.runId})}assertWriteOwnership(e,t){Du({owner:e.ownerUser},t,{resourceKind:"Graph run",resourceId:e.runId})}generateRunId(){const e=globalThis.crypto;if(!e||"function"!=typeof e.randomUUID)throw new Lr("Cannot generate a graph run id: crypto.randomUUID is unavailable in this runtime",{runtime:typeof globalThis.crypto});return e.randomUUID()}}function Ku(e){if(!e)return;let t;try{t=e.cache?.user}catch{t=void 0}if(null==t)try{t=e.get("user")}catch{t=void 0}return"string"==typeof t&&t.length>0?t:void 0}function Vu(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&_o(e.document)&&!_o(e)}function zu(e){return JSON.parse(JSON.stringify(e))}function Qu(e){if(null==e)return 0;let t;try{t=e.getTime()}catch{return 0}return Number.isFinite(t)?t:0}let Ju=class extends z{constructor(e){super(tr),this.catalogue=e}get limits(){return{...Yi,...Zi.graph.workflows.limits??{}}}get allowAnonymousAccess(){return!0===Zi.graph.workflows.allowAnonymousAccess}async saveDocument(e,t,...o){const{ctx:r,ctxArgs:n}=(await this.logCtx(o,"saveDocument",!0)).for(this.saveDocument);if(!_o(t))throw new S("Payload is not a canonical GraphWorkflowDocument: id and name must be strings and inputs, outputs, nodes and edges must be arrays");if(t.id!==e)throw new S(`Document id '${t.id}' does not match the workflow id '${e}' from the request path`);const i=await this.validateDocument(t,r);if(!i.valid)throw new $r(i.issues);const a=Ku(r),s=await this.readExistingForWrite(e,n);s&&this.assertWriteOwnership(e,s,a);const d=new Date;if(s)return s.name=t.name,s.document=zu(t),s.updatedAt=d,this.update(s,...n);const l=new tr({workflowId:e,name:t.name,document:zu(t),...a?{owner:a}:{},updatedAt:d});return this.create(l,...n)}async seedDocument(e,t,...o){const{log:r,ctxArgs:n}=(await this.logCtx(o,"seedDocument",!0)).for(this.seedDocument);try{return await this.saveDocument(e,t,...n)}catch(t){if(t instanceof M)return r.warn(`Skipping boot seed of graph workflow '${e}': an existing row is owned by another user`),null;throw t}}async getDocument(e,...t){const{ctx:o,ctxArgs:r}=(await this.logCtx(t,"getDocument",!0)).for(this.getDocument);let n;try{n=await this.read(e,...r)}catch{n=null}if(!n)throw new O(`No graph workflow found for workflowId '${e}'`);if(this.assertOwnership(e,n,Ku(o)),n.document)return zu(n.document);throw new O(`Graph workflow '${e}' has no canonical document; legacy definition/state snapshots are no longer supported (DECAF-50 \xa74.26 R2-2)`)}async listWorkflows(...e){const{ctx:t,ctxArgs:o}=(await this.logCtx(e,"listWorkflows",!0)).for(this.listWorkflows),r=await this.listBy("workflowId",W.ASC,...o),n=Ku(t);return r.filter(e=>Tu(e,n,{allowAnonymousAccess:this.allowAnonymousAccess})).sort((e,t)=>Qu(t.updatedAt)-Qu(e.updatedAt))}async assertAccess(e,...t){const{ctx:o,ctxArgs:r}=(await this.logCtx(t,"assertAccess",!0)).for(this.assertAccess);let n;try{n=await this.read(e,...r)}catch{n=null}if(!n)throw new O(`No graph workflow found for workflowId '${e}'`);return this.assertOwnership(e,n,Ku(o)),n}async validateDocument(e,...t){const{ctx:o}=(await this.logCtx(t,"validateDocument",!0)).for(this.validateDocument);return await Cu(e,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o)}async saveSnapshot(e,t,...o){const{ctx:r,ctxArgs:n}=(await this.logCtx(o,"saveSnapshot",!0)).for(this.saveSnapshot);if(!Vt(t))throw new S("Workflow snapshot payload must be JSON-safe: functions, class instances, undefined, NaN/Infinity, symbol keys and unsafe prototype keys (__proto__/prototype/constructor) are rejected");if(!Vu(t))throw new S("Workflow snapshots must wrap a canonical GraphWorkflowDocument ({ document, editor?, metadata? }): legacy definition/state snapshots are no longer accepted; save canonical documents via PUT /graph/workflows/{workflowId}");const i=Ku(r),a=await this.readExistingForWrite(e,n);a&&this.assertWriteOwnership(e,a,i);const s=new Date;if(a)return a.snapshot=t,await this.applyCanonicalWrapper(a,t,r),a.updatedAt=s,this.update(a,...n);const d=new tr({workflowId:e,snapshot:t,...i?{owner:i}:{},updatedAt:s});return await this.applyCanonicalWrapper(d,t,r),this.create(d,...n)}async loadSnapshot(e,...t){const{ctx:o,ctxArgs:r}=(await this.logCtx(t,"loadSnapshot",!0)).for(this.loadSnapshot);try{const t=await this.read(e,...r);return this.assertOwnership(e,t,Ku(o)),t}catch{return null}}async readExistingForWrite(e,t){try{return await this.read(e,...t)}catch(e){if(e instanceof O)return null;throw e}}assertOwnership(e,t,o){ju(t??null,o??null,{allowAnonymousAccess:this.allowAnonymousAccess,resourceKind:"Graph workflow",resourceId:e})}assertWriteOwnership(e,t,o){Du(t??null,o??null,{resourceKind:"Graph workflow",resourceId:e})}async applyCanonicalWrapper(e,t,o){if(!Vu(t))return;if(t.document.id!==e.workflowId)throw new S(`Document id '${t.document.id}' does not match the workflow id '${e.workflowId}' from the request path`);const r=await Cu(t.document,{limits:this.limits,...this.catalogue?{catalogue:this.catalogue}:{}},o);if(!r.valid)throw new $r(r.issues);e.document=zu(t.document),e.name=t.document.name}};Ju=k([H(tr),C("design:paramtypes",[Function])],Ju);let Xu=class extends z{constructor(){super(er)}async saveRun(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"saveRun",!0)).for(this.saveRun),r=Uu(e);let n;try{n=await super.read(e.runId,...o)}catch{n=null}if(n)return n.workflowId=r.workflowId,n.owner=r.owner,n.status=r.status,n.documentFingerprint=r.documentFingerprint,n.result=r.result,n.error=r.error,n.startedAt=r.startedAt,n.finishedAt=r.finishedAt,void await this.update(n,...o);await this.create(r,...o)}async readRun(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"readRun",!0)).for(this.readRun);try{return(e=>{const t=e.result;return{runId:e.runId,workflowId:e.workflowId,ownerUser:e.owner??null,status:(o=e.status,"string"==typeof o&&["queued","validating","running","succeeded","failed","cancelled"].includes(o)?e.status:"failed"),createdAt:e.createdAt.toISOString(),...e.startedAt?{startedAt:e.startedAt.toISOString()}:{},...e.finishedAt?{finishedAt:e.finishedAt.toISOString()}:{},...t?{result:t}:{},...e.error?{error:e.error}:{},...e.documentFingerprint?{documentFingerprint:e.documentFingerprint}:{}};var o})(await super.read(e,...o))}catch{return null}}async listRuns(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"listRuns",!0)).for(this.listRuns);return await this.findBy("workflowId",e,...o)}};Xu=k([H(er),C("design:paramtypes",[])],Xu);let Yu=class extends z{constructor(){super(or)}async upsertManifest(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"upsertManifest",!0)).for(this.upsertManifest),r=(e=>new or({kind:e.kind,name:e.display?.name,category:e.display?.category,group:e.display?.group,description:e.display?.description,manifest:Co(ko(e))}))(e);let n;try{n=await this.read(r.kind,...o)}catch{n=void 0}return n?(n.name=r.name,n.category=r.category,n.group=r.group,n.description=r.description,n.manifest=r.manifest,await this.update(n,...o)):await this.create(r,...o)}async syncFromCatalogue(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"syncFromCatalogue",!0)).for(this.syncFromCatalogue),r=e.listManifests(void 0,...o),n=[];for(const e of r)n.push(await this.upsertManifest(e,...o));return n}async listNodes(...e){const{ctxArgs:t}=(await this.logCtx(e,"listNodes",!0)).for(this.listNodes);return await this.listBy("kind",W.ASC,...t)}async listManifests(...e){return(await this.listNodes(...e)).map(e=>(e=>{if(!e.manifest)throw new S(`Graph node row '${e.kind}' has no manifest to convert`);return Co(ko(e.manifest))})(e))}async getNode(e,...t){const{ctxArgs:o}=(await this.logCtx(t,"getNode",!0)).for(this.getNode);try{return await this.read(e,...o)}catch{throw new O(`Graph node kind '${e}' is not registered`)}}};Yu=k([H(or),C("design:paramtypes",[])],Yu);class Zu{map(e){const t={};for(const[o,r]of Object.entries(e.nodeResults))t[o]={status:r.status,startedAt:r.startedAt?.toISOString(),finishedAt:r.finishedAt?.toISOString(),error:r.error,outputs:r.outputs,fromCache:r.fromCache,pinned:r.pinned};const o={};for(const t of e.events)t.edgeId&&"edge.valueRouted"===t.type&&(o[t.edgeId]={status:gt.SUCCEEDED,lastValue:t.payload?.value,updatedAt:t.timestamp.toISOString()});const r=[...e.events];return{runId:e.runId,status:e.status,nodes:t,edges:o,outputs:e.outputs,events:r}}}export{Yc as AgentBasicChainNode,Kc as AgentChunkingNode,gc as AgentDelegationHookNode,Dc as AgentEmbeddingNode,yp as AgentGuardrailNode,bp as AgentHitlNode,lc as AgentHookNode,ip as AgentInformationExtractorNode,up as AgentInputProcessorNode,sp as AgentLangChainCodeNode,Nc as AgentMemoryNode,Tc as AgentMemorySelectorNode,rc as AgentNode,hp as AgentOutputProcessorNode,Jc as AgentQaChainNode,zc as AgentRerankNode,Gc as AgentRetrieverNode,vc as AgentSandboxNode,Ic as AgentScorerNode,Ec as AgentScorerSelectorNode,fc as AgentSkillNode,mc as AgentSkillSelectorNode,rp as AgentStructuredOutputParserNode,ep as AgentSummarizationChainNode,pc as AgentToolDenyNode,ic as AgentToolNode,sc as AgentToolSelectorNode,Lc as AgentVectorStoreNode,Gp as AgentVoiceNode,rs as AggregateNode,xd as AirtableNode,Qs as AwsS3StorageNode,Ys as AzureStorageNode,Ki as BreakFlowNode,Dl as ChatTriggerNode,na as CodeInputSchema,ia as CodeNode,ds as CompareDatasetsNode,fn as ConditionExpressionEvaluator,Cd as ConfluenceNode,dl as ConvertToFileNode,El as CryptoNode,Yi as DEFAULT_GRAPH_WORKFLOW_DOCUMENT_LIMITS,ni as DEFAULT_GRAPH_WORKFLOW_VALIDATION_LIMITS,Bn as DEFAULT_PINNING_METADATA,Fc as DEFAULT_RAG_CHUNK_OVERLAP,$c as DEFAULT_RAG_CHUNK_SIZE,Aa as DataTableNode,Ea as DateTimeNode,aa as DelayFlowNode,Tp as DiscordChannelResponseNode,Ep as DiscordChannelTriggerNode,pd as DiscordNode,dd as EmailSendNode,zi as ErrorBoundaryFlowNode,$l as ErrorTriggerNode,jl as EventTriggerNode,Ol as ExecuteCommandNode,Tl as ExecuteSubWorkflowNode,Pl as ExecuteWorkflowTriggerNode,us as ExtractFromFileNode,Ra as FilterNode,Ll as FormTriggerNode,Nl as FtpNode,Zc as GRAPH_AGENT_BASIC_CHAIN_NODES,Vc as GRAPH_AGENT_CHUNKING_NODES,hc as GRAPH_AGENT_DELEGATION_HOOK_NODES,Pp as GRAPH_AGENT_DISCORD_RESPONSE_NODES,Ap as GRAPH_AGENT_DISCORD_TRIGGER_NODES,jc as GRAPH_AGENT_EMBEDDING_NODES,lu as GRAPH_AGENT_FAMILY_NODES,mp as GRAPH_AGENT_GUARDRAIL_NODES,wp as GRAPH_AGENT_HITL_NODES,cc as GRAPH_AGENT_HOOK_NODES,ap as GRAPH_AGENT_INFORMATION_EXTRACTOR_NODES,gp as GRAPH_AGENT_INPUT_PROCESSOR_NODES,dp as GRAPH_AGENT_LANGCHAIN_CODE_NODES,gu as GRAPH_AGENT_M5_NODES,hu as GRAPH_AGENT_M6_NODES,xp as GRAPH_AGENT_MCP_TRIGGER_NODES,cu as GRAPH_AGENT_MEMORY_NODES,Pc as GRAPH_AGENT_MEMORY_SELECTOR_NODES,nc as GRAPH_AGENT_NODES,fp as GRAPH_AGENT_OUTPUT_PROCESSOR_NODES,uu as GRAPH_AGENT_PROCESSOR_NODES,Xc as GRAPH_AGENT_QA_CHAIN_NODES,pu as GRAPH_AGENT_RAG_NODES,Qc as GRAPH_AGENT_RERANK_NODES,Uc as GRAPH_AGENT_RETRIEVER_NODES,xc as GRAPH_AGENT_SANDBOX_NODES,_c as GRAPH_AGENT_SCORER_NODES,Ac as GRAPH_AGENT_SCORER_SELECTOR_NODES,yc as GRAPH_AGENT_SKILL_NODES,bc as GRAPH_AGENT_SKILL_SELECTOR_NODES,Np as GRAPH_AGENT_SLACK_RESPONSE_NODES,_p as GRAPH_AGENT_SLACK_TRIGGER_NODES,np as GRAPH_AGENT_STRUCTURED_OUTPUT_PARSER_NODES,tp as GRAPH_AGENT_SUMMARIZATION_CHAIN_NODES,Mp as GRAPH_AGENT_TEAMS_RESPONSE_NODES,kp as GRAPH_AGENT_TEAMS_TRIGGER_NODES,jp as GRAPH_AGENT_TELEGRAM_RESPONSE_NODES,Rp as GRAPH_AGENT_TELEGRAM_TRIGGER_NODES,uc as GRAPH_AGENT_TOOL_DENY_NODES,ac as GRAPH_AGENT_TOOL_NODES,dc as GRAPH_AGENT_TOOL_SELECTOR_NODES,Mc as GRAPH_AGENT_VECTOR_STORE_NODES,Up as GRAPH_AGENT_VOICE_NODES,du as GRAPH_BOUNDARY_NODES,mu as GRAPH_BUILT_IN_NODE_CLASSES_BY_KIND,tu as GRAPH_BUILT_IN_NODE_MANIFESTS,ru as GRAPH_BUILT_IN_NODE_MANIFESTS_BY_KIND,ra as GRAPH_CODE_DEFAULT_LANGUAGE,ea as GRAPH_CODE_DEFAULT_TIMEOUT_MS,oa as GRAPH_CODE_LANGUAGES,hr as GRAPH_CODE_MAX_TIMEOUT_MS,fu as GRAPH_DATA_NODES,Ar as GRAPH_DATA_TABLE_MAX_LIST_ROWS,_r as GRAPH_DATA_TABLE_MAX_ROWS,Er as GRAPH_DATA_TABLE_MAX_ROW_BYTES,lr as GRAPH_DEFAULT_CONCURRENCY,pr as GRAPH_DEFAULT_MAX_FOREACH_ITERATIONS,cr as GRAPH_DEFAULT_MAX_LOOP_ITERATIONS,ii as GRAPH_DOCUMENT_FORBIDDEN_FIELD_KEYS,wr as GRAPH_EXECUTE_COMMAND_DEFAULT_TIMEOUT_MS,vr as GRAPH_EXECUTE_COMMAND_MAX_OUTPUT_BYTES,br as GRAPH_EXECUTE_COMMAND_MAX_TIMEOUT_MS,iu as GRAPH_FLOW_CONTROL_NODES,mr as GRAPH_HTTP_MAX_REDIRECTS,yr as GRAPH_HTTP_MAX_RESPONSE_BYTES,fr as GRAPH_HTTP_MAX_TIMEOUT_MS,yu as GRAPH_IO_NODES,sr as GRAPH_LOCAL_EXECUTION_BACKEND,dr as GRAPH_LOCAL_UNSUPPORTED_NODE_KIND,kr as GRAPH_LOOP_KIND,su as GRAPH_LOOP_NODES,Ir as GRAPH_MAX_CHILD_RUNS,gr as GRAPH_MAX_FOREACH_ITERATIONS,ur as GRAPH_MAX_LOOP_ITERATIONS,xr as GRAPH_MAX_SUB_WORKFLOW_DEPTH,Sr as GRAPH_PINNING_METADATA_KEY,Pn as GRAPH_PLAIN_SECRET_KEYS,nu as GRAPH_TRIGGER_NODES,au as GRAPH_UTILITY_NODES,ar as GRAPH_WORKFLOW_BOUNDARY,_u as GRAPH_WORKFLOW_FORBIDDEN_FIELD_KEYS,wl as GithubNode,xl as GitlabNode,ad as GmailNode,Fd as GoogleCalendarNode,Js as GoogleCloudStorageNode,Ld as GoogleDocsNode,wd as GoogleSheetsNode,rn as GraphAuthValidator,Gr as GraphBreakSignal,Bp as GraphConditionEvaluator,Or as GraphConditionType,Zn as GraphConnectionPolicyValidator,oi as GraphConnectionValidationError,ri as GraphCredentialAuthorizationError,ei as GraphCredentialReferenceValidator,Nr as GraphCycleError,pi as GraphDataTableModel,bi as GraphDataTableRepository,ti as GraphDocumentValidationError,Yn as GraphEdgeInstanceValidator,un as GraphEngineEventSink,Zi as GraphEnvironment,hn as GraphExecutionBackendRegistry,ln as GraphExecutionContext,_i as GraphExecutionEngine,Cr as GraphExecutionError,Fr as GraphExecutionEventEmitter,Hr as GraphExecutionEventFactory,cn as GraphExecutionFrame,li as GraphExecutionPlanner,Zu as GraphExecutionSnapshotMapper,Hp as GraphForeachLoopNode,Tr as GraphInputError,Kp as GraphInputValueNode,Nu as GraphLoopExecutionContext,Pr as GraphLoopLimitError,Wi as GraphNode,Ui as GraphNodeCatalogue,nn as GraphNodeCredentialResolver,$i as GraphNodeExecutorRegistry,Fi as GraphNodeExecutorResolver,Jn as GraphNodeInstanceValidator,ji as GraphNodeManifestResolver,Oi as GraphNodeMethodNotFoundError,ki as GraphNodeMethodRegistry,Yu as GraphNodeModelService,Ri as GraphNodeNotFoundError,Si as GraphNodeRegistrationError,Vp as GraphOutputValueNode,Dn as GraphParameterValidator,Kn as GraphPinningDependencyResolver,Dr as GraphPinningError,Wn as GraphPinningPolicy,Hn as GraphPinningService,Rr as GraphPinningStrategy,jr as GraphPortError,xu as GraphPortSchemaResolver,Ur as GraphRunCancelledError,Hu as GraphRunEventPublisher,Bu as GraphRunExecutor,Xu as GraphRunModelService,Wu as GraphRunService,Lr as GraphStoreError,Fn as GraphTopology,Mr as GraphTopologyError,qp as GraphUntilLoopNode,jn as GraphValueModel,Un as GraphValueRepository,Iu as GraphValueValidator,ci as GraphWebhookResponseRegistry,Wp as GraphWhileLoopNode,$r as GraphWorkflowDocumentRejectedError,di as GraphWorkflowDocumentValidator,Ju as GraphWorkflowService,Ad as GraphqlNode,cl as HtmlExtractNode,ll as HtmlNode,hs as HttpRequestNode,Qi as HumanApprovalFlowNode,Ji as IfFlowNode,Gu as InMemoryGraphRunEventStore,Fu as InMemoryGraphRunStore,Ai as IsolatedVmCodeSandboxEvaluator,ns as ItemListsNode,Pd as JiraNode,Sl as JwtNode,Oa as LimitNode,Vn as LocalGraphExecutionBackend,sa as LogFlowNode,tc as MASTRA_AGENT_ZONE,oc as MASTRA_AGENT_ZONES,pp as MASTRA_GUARDRAIL_TYPES,lp as MASTRA_INPUT_PROCESSOR_TYPES,cp as MASTRA_OUTPUT_PROCESSOR_TYPES,Ml as ManualTriggerNode,da as MapNode,pl as MarkdownNode,vp as McpServerTriggerNode,Ca as MergeNode,Od as MicrosoftExcelNode,md as MicrosoftOutlookNode,Gd as MicrosoftSharePointNode,Gs as MicrosoftSqlNode,Ms as MySqlNode,Ls as PostgresNode,ec as PostgresTriggerNode,qs as RabbitMqNode,Jl as RabbitMqTriggerNode,fl as ReadBinaryFileNode,yl as ReadBinaryFilesNode,ys as ReadPDFNode,Is as ReadWriteFileNode,Hs as RedisNode,Xl as RedisTriggerNode,cs as RemoveDuplicatesNode,Ta as RenameKeysNode,_s as RespondToWebhookNode,Vs as S3Node,zs as S3StorageNode,Gl as ScheduleTriggerNode,Pa as SetNode,Cp as SlackChannelResponseNode,Ip as SlackChannelTriggerNode,ed as SlackNode,Da as SortNode,ja as SplitOutNode,_d as SpreadsheetFileNode,Yl as SseTriggerNode,ls as SummarizeNode,Xi as SwitchFlowNode,Lp as TeamsChannelResponseNode,Op as TeamsChannelTriggerNode,nd as TeamsNode,Dp as TelegramChannelResponseNode,Sp as TelegramChannelTriggerNode,od as TelegramNode,la as UtilityLogNode,Ul as WebhookTriggerNode,hd as WhatsAppNode,Bl as WorkflowTriggerNode,ml as WriteBinaryFileNode,hl as XmlNode,ju as assertGraphResourceOwnership,Du as assertGraphResourceWriteOwnership,pn as buildGraphExecutionResult,wu as builtInGraphNodeRegistrations,Tu as canAccessGraphResource,Pu as canAccessGraphResourcePayload,kn as checkGraphValueAgainstSchema,qc as chunkText,ta as clampGraphCodeTimeoutMs,wc as clampSandboxTimeoutMs,Xn as collectLooseNodeIssues,qr as composeGraphNamespace,wi as createGraphDataTableRepository,$n as createGraphValueRepository,Bi as declaredGraphNodeMethods,Br as decomposeGraphNamespace,tn as decomposeGraphNamespaces,Hi as defineGraphNode,Rn as detectGraphCodeModeBlockingSurfaces,En as detectGraphCodeModeSurfaces,bn as evaluateCodeCondition,vn as evaluateCondition,wn as evaluateConditionSync,Wc as extractChunkTexts,Qr as findMalformedGraphNamespaces,zr as findUngrantedGraphNamespaces,Zr as graphAuthDataFromRecord,en as graphAuthDataOf,An as graphDocumentHasCodeMode,Vr as graphNamespaceCovers,Kr as graphNamespacePartsOf,qi as graphNodeConfig,Jr as graphRolesFromNamespaces,Mu as graphRunDocumentFingerprint,Ku as graphWorkflowOwnerOf,yn as isCodeCondition,mn as isConditionExpression,Sn as isGraphCodeModeBlockingSurface,Nn as isGraphCredentialReferenceLike,Wr as isGraphNamespaceCacheEntryValid,ai as isGraphResolvedWorkflow,qn as isPinnable,on as mergeGraphAuthData,vu as registerBuiltInGraphNodes,gn as resolveGraphBackendCapabilities,Pi as resolveGraphDynamicPorts,Di as resolveGraphNodeManifest,an as resolveNodeCredential,Ln as serializeGraphValueKey,Ii as stripFacadeOwnedBackendConfig,Cu as validateGraphWorkflowDocumentAtBoundary};
2
2
  //# sourceMappingURL=as-graph.js.map