flujo-ai 3.40.0 → 3.41.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.
- package/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +400 -384
- package/.next/app-path-routes-manifest.json +53 -53
- package/.next/build-manifest.json +5 -5
- package/.next/prerender-manifest.json +33 -33
- package/.next/react-loadable-manifest.json +9 -9
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +3 -3
- package/.next/server/app/api/approvals/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/approvals/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/backup/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/browse/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/bugs/enhance/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/cwd/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/encryption/secure/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/env/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/[id]/convert-process-to-subflow/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/[id]/versions/[versionId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/[id]/versions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/assist/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/compile/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/generate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/generator/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/improve/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/prompt-renderer/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/quick-chat/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/repair/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/flow/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/capability/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/pull/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/local-models/suggest/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/app-sandbox/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/flujo/authoring/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/flujo/automation/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/flujo/flows/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/flujo/resources/read/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/flujo/resources/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/flujo/servers/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/flujo/state/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/flujo/tools/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/oauth-capability/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/prompts/get/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/prompts/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/resources/read/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/resources/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/tools/[toolName]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/[name]/tools/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/servers/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/test-connection/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp/test-connection/stream/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp-registry/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/mcp-registry/spotlight/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/provider/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/model/test/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/callback/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/initiate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/reset/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/build/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/derive-secrets/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/install/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/install/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/installed/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/resolve/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/scan-targets/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/search/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/packages/uninstall/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/run/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/[id]/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/preview-schedule/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/reconcile/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/planned-executions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/auth/resend/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/auth/reset/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/auth/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/feedback/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/oauth/callback/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/oauth/initiate/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/packages/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/publish/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/registry/settings/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/restore/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/runs/active/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/setup/ai-cli/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/statistics/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/storage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/telemetry/daily-active/route.js +1 -1
- package/.next/server/app/api/telemetry/daily-active/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/waves/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/webhooks/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/automation/triggers/page.js +1 -1
- package/.next/server/app/automation/triggers/page.js.nft.json +1 -1
- package/.next/server/app/automation/triggers/page_client-reference-manifest.js +1 -1
- package/.next/server/app/automation/triggers.html +1 -1
- package/.next/server/app/automation/triggers.rsc +4 -4
- package/.next/server/app/automation/waves/page_client-reference-manifest.js +1 -1
- package/.next/server/app/automation/waves.html +1 -1
- package/.next/server/app/automation/waves.rsc +4 -4
- package/.next/server/app/chat/page.js +2 -2
- package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/chat.html +1 -1
- package/.next/server/app/chat.rsc +4 -4
- package/.next/server/app/docs/page.js +3 -3
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +4 -4
- package/.next/server/app/executions/page.js +1 -1
- package/.next/server/app/executions/page.js.nft.json +1 -1
- package/.next/server/app/executions/page_client-reference-manifest.js +1 -1
- package/.next/server/app/executions.html +1 -1
- package/.next/server/app/executions.rsc +4 -4
- package/.next/server/app/flows/page.js +5 -3
- package/.next/server/app/flows/page.js.nft.json +1 -1
- package/.next/server/app/flows/page_client-reference-manifest.js +1 -1
- package/.next/server/app/flows.html +1 -1
- package/.next/server/app/flows.rsc +4 -4
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +4 -4
- package/.next/server/app/mcp/page.js +73 -44
- package/.next/server/app/mcp/page.js.nft.json +1 -1
- package/.next/server/app/mcp/page_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp-flows/route.js +1 -1
- package/.next/server/app/mcp-flows/route_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp-proxy/[server]/route.js +1 -1
- package/.next/server/app/mcp-proxy/[server]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/mcp.html +1 -1
- package/.next/server/app/mcp.rsc +4 -4
- package/.next/server/app/models/page.js +7 -7
- package/.next/server/app/models/page_client-reference-manifest.js +1 -1
- package/.next/server/app/packages/page.js +1 -1
- package/.next/server/app/packages/page_client-reference-manifest.js +1 -1
- package/.next/server/app/packages.html +1 -1
- package/.next/server/app/packages.rsc +4 -4
- package/.next/server/app/page.js +2 -2
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page.js +2 -2
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings.html +1 -1
- package/.next/server/app/settings.rsc +4 -4
- package/.next/server/app/statistics/page.js +2 -2
- package/.next/server/app/statistics/page_client-reference-manifest.js +1 -1
- package/.next/server/app/statistics.html +1 -1
- package/.next/server/app/statistics.rsc +4 -4
- package/.next/server/app/v1/chat/completions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/breakpoints/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/continue/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/debug/step/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/edit-state/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/inject/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/resources/[resourceId]/content/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/resources/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/respond/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/revert/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/[conversationId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/conversations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/chat/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/v1/models/route_client-reference-manifest.js +1 -1
- package/.next/server/app/waves/page_client-reference-manifest.js +1 -1
- package/.next/server/app/waves.html +1 -1
- package/.next/server/app/waves.rsc +4 -4
- package/.next/server/app-paths-manifest.json +53 -53
- package/.next/server/chunks/1227.js +1 -1
- package/.next/server/chunks/1403.js +2 -2
- package/.next/server/chunks/1539.js +1 -1
- package/.next/server/chunks/2069.js +1 -1
- package/.next/server/chunks/2372.js +1 -1
- package/.next/server/chunks/2828.js +2 -2
- package/.next/server/chunks/3422.js +1 -0
- package/.next/server/chunks/3945.js +3 -3
- package/.next/server/chunks/519.js +2 -2
- package/.next/server/chunks/5444.js +2 -2
- package/.next/server/chunks/5750.js +1 -1
- package/.next/server/chunks/5918.js +10 -10
- package/.next/server/chunks/6226.js +2 -2
- package/.next/server/chunks/9088.js +2 -2
- package/.next/server/chunks/9490.js +5 -0
- package/.next/server/chunks/9543.js +3 -3
- package/.next/server/chunks/9624.js +8 -8
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-manifest.json +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{1161-19176c3e7c655121.js → 1161-563a8028f59f00de.js} +1 -1
- package/.next/static/chunks/1521-9ad145dcb8e3abfc.js +1 -0
- package/.next/static/chunks/1576.06797b29a19fa26c.js +1 -0
- package/.next/static/chunks/{4386-e9621d3c94969a68.js → 2005-f9d38c39f10c321f.js} +1 -1
- package/.next/static/chunks/2493-da85c47ef972c066.js +1 -0
- package/.next/static/chunks/361.c88d43436e974006.js +1 -0
- package/.next/static/chunks/3731-c18f48522b159d7f.js +1 -0
- package/.next/static/chunks/3781.5086bce03aa281f7.js +1 -0
- package/.next/static/chunks/3969-15a32253b112652c.js +1 -0
- package/.next/static/chunks/4167.2ce97ca450815df1.js +1 -0
- package/.next/static/chunks/4814-52b7254ab573a455.js +1 -0
- package/.next/static/chunks/4965.d401547984d71b7a.js +1 -0
- package/.next/static/chunks/5148-9174ba300221fd1b.js +1 -0
- package/.next/static/chunks/5417-fb7d3760cc288ab1.js +1 -0
- package/.next/static/chunks/5967-34735763d1b03ccc.js +1 -0
- package/.next/static/chunks/7260-743e4b0cc4211dcb.js +1 -0
- package/.next/static/chunks/7711-7323dabe7dc02311.js +1 -0
- package/.next/static/chunks/8124-f99060fe1dfc119e.js +1 -0
- package/.next/static/chunks/8135-7fe07a34a8c49967.js +1 -0
- package/.next/static/chunks/8529.6187e01de8e9a692.js +1 -0
- package/.next/static/chunks/9136-e9ee57cc581ddd50.js +1 -0
- package/.next/static/chunks/9140.9180b569c4b26168.js +1 -0
- package/.next/static/chunks/9195-6a18a5867bb76c64.js +1 -0
- package/.next/static/chunks/app/automation/triggers/{page-594a6294c58344bf.js → page-34b9a8a2e6f28c2f.js} +1 -1
- package/.next/static/chunks/app/automation/waves/{page-ce2fef4996cad8e6.js → page-fd4929ea308183b2.js} +1 -1
- package/.next/static/chunks/app/chat/page-fb8a33db7628ecd0.js +1 -0
- package/.next/static/chunks/app/docs/page-3e21583b1cd5d7ca.js +1 -0
- package/.next/static/chunks/app/executions/{page-fcc848de86714386.js → page-56ecca56c17c05d7.js} +1 -1
- package/.next/static/chunks/app/flows/page-8c1a656197b15894.js +1 -0
- package/.next/static/chunks/app/layout-6e2756704ddc9f39.js +1 -0
- package/.next/static/chunks/app/mcp/page-4c4390354fdd94c8.js +1 -0
- package/.next/static/chunks/app/models/error-ea477f0ad52f4dcb.js +1 -0
- package/.next/static/chunks/app/models/page-e237ac64a0f62c3d.js +1 -0
- package/.next/static/chunks/app/packages/page-8680e4bea6b7ea45.js +1 -0
- package/.next/static/chunks/app/page-6dca06b6b7667181.js +1 -0
- package/.next/static/chunks/app/settings/page-a5f7fedcbf9e3a7f.js +1 -0
- package/.next/static/chunks/app/statistics/page-f9f9627d1c1ff963.js +1 -0
- package/.next/static/chunks/app/waves/{page-5b53af3eb9409414.js → page-7529febc48eb473d.js} +1 -1
- package/.next/static/chunks/{webpack-9fbd3587b9ef4dca.js → webpack-f3df493faa0bd612.js} +1 -1
- package/.next/static/css/{400b1b927c3ffaf6.css → 9f9b7f1374ac2d01.css} +1 -1
- package/.next/trace +11 -11
- package/README.md +1 -1
- package/mcp-servers/bash/package.json +1 -1
- package/mcp-servers/browser/package.json +1 -1
- package/mcp-servers/filesystem/package.json +1 -1
- package/mcp-servers/flujo/package.json +1 -1
- package/package.json +5 -5
- package/.next/server/chunks/7508.js +0 -5
- package/.next/server/chunks/8598.js +0 -1
- package/.next/static/chunks/1521-1c98c9a56726e053.js +0 -1
- package/.next/static/chunks/1576.bc6ae6c9e6d939d8.js +0 -1
- package/.next/static/chunks/2005.300528b5119c2d38.js +0 -1
- package/.next/static/chunks/2499-92cd97ce4993999f.js +0 -1
- package/.next/static/chunks/361.51d642c530c84295.js +0 -1
- package/.next/static/chunks/3731-64070760ae44448f.js +0 -1
- package/.next/static/chunks/4814-31eb5f3b10c651c1.js +0 -1
- package/.next/static/chunks/4965.39e24b54c3c6ca58.js +0 -1
- package/.next/static/chunks/5967-59fde8c214c9ca9f.js +0 -1
- package/.next/static/chunks/6417.70056fe81ca21682.js +0 -1
- package/.next/static/chunks/7711-4b017720ec49c96d.js +0 -1
- package/.next/static/chunks/8124-94140ee1dd8ed87c.js +0 -1
- package/.next/static/chunks/8135-5b975b9014f8920b.js +0 -1
- package/.next/static/chunks/8529.b5a43e728bb5bb8a.js +0 -1
- package/.next/static/chunks/9001-4c27a608feddb878.js +0 -1
- package/.next/static/chunks/9136-9c415453ec02519c.js +0 -1
- package/.next/static/chunks/9140.6502327a2c098d33.js +0 -1
- package/.next/static/chunks/9195-3c9c4300e7505d9e.js +0 -1
- package/.next/static/chunks/9524-b9d2c7e4426edd07.js +0 -1
- package/.next/static/chunks/app/chat/page-203cb7bf21638ada.js +0 -1
- package/.next/static/chunks/app/docs/page-c466a58caf5e3336.js +0 -1
- package/.next/static/chunks/app/flows/page-172c759ca81ba02f.js +0 -1
- package/.next/static/chunks/app/layout-a6ca531683a518a7.js +0 -1
- package/.next/static/chunks/app/mcp/page-0a96e6b30e45b1e6.js +0 -1
- package/.next/static/chunks/app/models/error-1964203c5c6e7d0e.js +0 -1
- package/.next/static/chunks/app/models/page-ad1cbea6d3324966.js +0 -1
- package/.next/static/chunks/app/packages/page-dda48425be9fc137.js +0 -1
- package/.next/static/chunks/app/page-04189aa1b1318c2d.js +0 -1
- package/.next/static/chunks/app/settings/page-906c229c87011ead.js +0 -1
- package/.next/static/chunks/app/statistics/page-9b13a95549f438c0.js +0 -1
- /package/.next/static/{b1aMk0634gkkiunttd1SQ → utOrEUSzguWncIosxgCeR}/_buildManifest.js +0 -0
- /package/.next/static/{b1aMk0634gkkiunttd1SQ → utOrEUSzguWncIosxgCeR}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3080],{3986:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79s7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58s9.14-3.47 12.65 0L21 3zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8z"}),"Update")},4097:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"m18.04 7.99-.63-1.4-1.4-.63c-.39-.18-.39-.73 0-.91l1.4-.63.63-1.4c.18-.39.73-.39.91 0l.63 1.4 1.4.63c.39.18.39.73 0 .91l-1.4.63-.63 1.4c-.17.39-.73.39-.91 0m3.24 4.73-.32-.72c-.18-.39-.73-.39-.91 0l-.32.72-.73.32c-.39.18-.39.73 0 .91l.72.32.32.73c.18.39.73.39.91 0l.32-.72.73-.32c.39-.18.39-.73 0-.91zm-5.04 1.65 1.23.93c.4.3.51.86.26 1.3l-1.62 2.8c-.25.44-.79.62-1.25.42l-1.43-.6c-.2.13-.42.26-.64.37l-.19 1.54c-.06.5-.49.88-.99.88H8.38c-.5 0-.93-.38-.99-.88l-.19-1.54c-.22-.11-.43-.23-.64-.37l-1.43.6c-.46.2-1 .02-1.25-.42l-1.62-2.8c-.25-.44-.14-.99.26-1.3l1.23-.93V14c0-.12 0-.25.01-.37l-1.23-.93c-.4-.3-.51-.86-.26-1.3l1.62-2.8c.25-.44.79-.62 1.25-.42l1.43.6c.2-.13.42-.26.64-.37l.19-1.54c.05-.49.48-.87.98-.87h3.23c.5 0 .93.38.99.88l.19 1.54c.22.11.43.23.64.37l1.43-.6c.46-.2 1-.02 1.25.42l1.62 2.8c.25.44.14.99-.26 1.3l-1.23.93c.01.12.01.24.01.37s0 .24-.01.36M13 14c0-1.66-1.34-3-3-3s-3 1.34-3 3 1.34 3 3 3 3-1.34 3-3"}),"SettingsSuggestRounded")},7107:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"m9.78 11.16-1.42 1.42c-.68-.69-1.34-1.58-1.79-2.94l1.94-.49c.32.89.77 1.5 1.27 2.01M11 6 7 2 3 6h3.02c.02.81.08 1.54.19 2.17l1.94-.49C8.08 7.2 8.03 6.63 8.02 6zm10 0-4-4-4 4h2.99c-.1 3.68-1.28 4.75-2.54 5.88-.5.44-1.01.92-1.45 1.55-.34-.49-.73-.88-1.13-1.24L9.46 13.6c.93.85 1.54 1.54 1.54 3.4v5h2v-5c0-2.02.71-2.66 1.79-3.63 1.38-1.24 3.08-2.78 3.2-7.37z"}),"AltRoute")},10076:(e,t,n)=>{Promise.resolve().then(n.bind(n,38378))},14418:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M9.29 16.29 5.7 12.7a.996.996 0 0 1 0-1.41c.39-.39 1.02-.39 1.41 0L10 14.17l6.88-6.88c.39-.39 1.02-.39 1.41 0s.39 1.02 0 1.41l-7.59 7.59c-.38.39-1.02.39-1.41 0"}),"CheckCircleRounded")},22590:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M19.3 16.9c.4-.7.7-1.5.7-2.4 0-2.5-2-4.5-4.5-4.5S11 12 11 14.5s2 4.5 4.5 4.5c.9 0 1.7-.3 2.4-.7l3.2 3.2 1.4-1.4zm-3.8.1c-1.4 0-2.5-1.1-2.5-2.5s1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5-1.1 2.5-2.5 2.5M12 20v2C6.48 22 2 17.52 2 12S6.48 2 12 2c4.84 0 8.87 3.44 9.8 8h-2.07c-.64-2.46-2.4-4.47-4.73-5.41V5c0 1.1-.9 2-2 2h-2v2c0 .55-.45 1-1 1H8v2h2v3H9l-4.79-4.79C4.08 10.79 4 11.38 4 12c0 4.41 3.59 8 8 8"}),"TravelExplore")},24610:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)([(0,o.jsx)("path",{d:"M13 8.57c-.79 0-1.43.64-1.43 1.43s.64 1.43 1.43 1.43 1.43-.64 1.43-1.43-.64-1.43-1.43-1.43"},"0"),(0,o.jsx)("path",{d:"M13 3C9.25 3 6.2 5.94 6.02 9.64L4.1 12.2c-.25.33-.01.8.4.8H6v3c0 1.1.9 2 2 2h1v3h7v-4.68c2.36-1.12 4-3.53 4-6.32 0-3.87-3.13-7-7-7m3 7c0 .13-.01.26-.02.39l.83.66c.08.06.1.16.05.25l-.8 1.39c-.05.09-.16.12-.24.09l-.99-.4c-.21.16-.43.29-.67.39L14 13.83c-.01.1-.1.17-.2.17h-1.6c-.1 0-.18-.07-.2-.17l-.15-1.06c-.25-.1-.47-.23-.68-.39l-.99.4c-.09.03-.2 0-.25-.09l-.8-1.39c-.05-.08-.03-.19.05-.25l.84-.66c-.01-.13-.02-.26-.02-.39s.02-.27.04-.39l-.85-.66c-.08-.06-.1-.16-.05-.26l.8-1.38c.05-.09.15-.12.24-.09l1 .4c.2-.15.43-.29.67-.39L12 6.17c.02-.1.1-.17.2-.17h1.6c.1 0 .18.07.2.17l.15 1.06c.24.1.46.23.67.39l1-.4c.09-.03.2 0 .24.09l.8 1.38c.05.09.03.2-.05.26l-.85.66c.03.12.04.25.04.39"},"1")],"Psychology")},25541:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"}),"RestartAlt")},25766:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M3 18c0 .55.45 1 1 1h5v-2H4c-.55 0-1 .45-1 1M3 6c0 .55.45 1 1 1h9V5H4c-.55 0-1 .45-1 1m10 14v-1h7c.55 0 1-.45 1-1s-.45-1-1-1h-7v-1c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1M7 10v1H4c-.55 0-1 .45-1 1s.45 1 1 1h3v1c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1s-1 .45-1 1m14 2c0-.55-.45-1-1-1h-9v2h9c.55 0 1-.45 1-1m-5-3c.55 0 1-.45 1-1V7h3c.55 0 1-.45 1-1s-.45-1-1-1h-3V4c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1"}),"TuneRounded")},26842:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M9 16.17 5.53 12.7a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L20.29 7.71c.39-.39.39-1.02 0-1.41a.996.996 0 0 0-1.41 0z"}),"CheckRounded")},30351:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M18 19H6c-.55 0-1-.45-1-1V6c0-.55.45-1 1-1h5c.55 0 1-.45 1-1s-.45-1-1-1H5c-1.11 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-6c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55-.45 1-1 1M14 4c0 .55.45 1 1 1h2.59l-9.13 9.13c-.39.39-.39 1.02 0 1.41s1.02.39 1.41 0L19 6.41V9c0 .55.45 1 1 1s1-.45 1-1V4c0-.55-.45-1-1-1h-5c-.55 0-1 .45-1 1"}),"OpenInNewRounded")},38378:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>rG});var r=n(95155),o=n(12115),l=n(20063),a=n(33567),s=n(94049),i=n(25635),d=n(91871),c=n(5421),u=n(41983),p=n(78470),h=n(50430),m=n(22003),f=n(2778),g=n(52363),x=n(65036),v=n(50001),b=n(9562),w=n(75912),y=n(15485);let j=(0,y.A)((0,r.jsx)("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"}),"ArrowBack");var A=n(86946);let C=(0,y.A)((0,r.jsx)("path",{d:"m19 9 1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25zm-7.5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12zM19 15l-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25z"}),"AutoAwesome");var S=n(38343),k=n(25766),T=n(48116),I=n(2300),M=n(28548),N=n(4474),F=n(99944),P=n(9957),R=n(21067),E=n(36314),z=n(86973),W=n(73288),L=n(22539),D=n(74879),H=n(90057),B=n(17897),O=n(43076),V=n(93764),U=n(57563);function G(e){var t;return null==(t=e.data)?void 0:t.edgeType}function K(e){return"mcp"===G(e)}function $(e){return"resource"===G(e)}var _=n(18466),X=n(61033);function Y(e){return{id:e.id,label:e.data.label,type:e.type||e.data.type}}var q=n(38700);n(18037);var J=n(8532),Z=n(56422),Q=n(56350),ee=n(77842),et=n(55930),en=n(59323),er=n(20195),eo=n(11096),el=n(52393),ea=n(96429),es=n(98008),ei=n(41603);let ed=(0,W.h)("components/flow/FlowBuilder/NodePalette.tsx"),ec="NodePalette",eu=(0,T.Ay)(I.A)(e=>{let{theme:t}=e;return{padding:t.spacing(1.4),width:"218px",height:"100%",minHeight:0,flexShrink:0,display:"flex",flexDirection:"column",gap:t.spacing(1.2),overflowY:"auto",border:"1px solid ".concat(t.palette.divider),borderRadius:16,backgroundColor:"dark"===t.palette.mode?"rgba(17, 22, 41, 0.86)":"rgba(255, 255, 255, 0.9)",boxShadow:"dark"===t.palette.mode?"0 16px 45px rgba(0,0,0,.22)":"0 16px 45px rgba(49,45,99,.09)",backdropFilter:"blur(18px)",[t.breakpoints.down("md")]:{width:"176px",padding:t.spacing(1)},[t.breakpoints.down("md")]:{width:"100%",height:"68px",padding:t.spacing(.65),gap:t.spacing(.6),alignItems:"flex-start",overflowX:"auto",overflowY:"hidden"}}}),ep=(0,T.Ay)(I.A,{shouldForwardProp:e=>"nodeType"!==e})(e=>{let{theme:t,nodeType:n}=e;return{padding:t.spacing(1.25),width:"100%",minWidth:0,borderRadius:"12px",backgroundColor:(0,J.X4)(t.palette.background.paper,.72),border:"1px solid ".concat(t.palette.divider),borderLeft:"3px solid ".concat("process"===n?t.palette.primary.main:"finish"===n?t.palette.success.main:"subflow"===n?t.palette.warning.main:"resource"===n?ei.nH:"signal"===n?ei.vp:"trigger"===n?ei.$Q:t.palette.info.main),boxShadow:"none",transition:"transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease",cursor:"grab","&:hover":{transform:"translateY(-2px)",borderColor:(0,J.X4)("process"===n?t.palette.primary.main:"finish"===n?t.palette.success.main:"subflow"===n?t.palette.warning.main:"resource"===n?ei.nH:"signal"===n?ei.vp:"trigger"===n?ei.$Q:t.palette.info.main,.55),boxShadow:"0 0 0 1px ".concat("process"===n?t.palette.primary.main:"finish"===n?t.palette.success.main:"subflow"===n?t.palette.warning.main:"resource"===n?ei.nH:"signal"===n?ei.vp:"trigger"===n?ei.$Q:t.palette.info.main,", 0 14px 30px rgba(0,0,0,0.12)")},"&:active":{cursor:"grabbing"},[t.breakpoints.down("md")]:{width:64,minWidth:64,minHeight:54,padding:t.spacing(.55),flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderLeftWidth:2}}}),eh=(0,T.Ay)(s.default,{shouldForwardProp:e=>"nodeType"!==e})(e=>{let{theme:t,nodeType:n}=e;return{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid ".concat("process"===n?t.palette.primary.light:"finish"===n?t.palette.success.light:"subflow"===n?t.palette.warning.light:"resource"===n?"#4DB6AC":"signal"===n?"#B39DDB":"trigger"===n?ei.C2:t.palette.info.light),marginBottom:t.spacing(1),paddingBottom:t.spacing(.5),[t.breakpoints.down("md")]:{width:"100%",marginBottom:0,paddingBottom:0,borderBottom:0,justifyContent:"center"}}}),em=(0,T.Ay)(s.default)(e=>{let{theme:t}=e;return{display:"flex",alignItems:"center",gap:"8px",[t.breakpoints.down("md")]:{flexDirection:"column",justifyContent:"center",gap:2}}}),ef=[{type:"process",label:"Ask AI",shortLabel:"AI step",description:"Write, summarize, analyze, or make a decision"},{type:"finish",label:"Send the answer",shortLabel:"Finish",description:"Return the finished result to the person"},{type:"mcp",label:"Use a connected app",shortLabel:"Tool",description:"Let the agent use an app or service"},{type:"subflow",label:"Ask another agent",shortLabel:"Agent",description:"Hand part of the job to another agent"},{type:"resource",label:"Use saved information",shortLabel:"Information",description:"Read or create a reusable result"},{type:"signal",label:"Notify an automation",shortLabel:"Notify",description:"Let another automation know this step finished"},{type:"trigger",label:"Start automatically",shortLabel:"Start",description:"Run on a schedule or when something happens"}],eg=e=>{let{authoringMode:t="guided",onAddNode:n}=e;ed.debug("".concat(ec,": Entering component"));let[l,a]=(0,o.useState)(""),d=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=()=>{var e,t;null==(e=d.current)||e.focus(),null==(t=d.current)||t.select()};return document.addEventListener("openFlowQuickAdd",e),()=>document.removeEventListener("openFlowQuickAdd",e)},[]);let c=(0,o.useCallback)(e=>{ed.debug("".concat(ec,".addNodeFromPalette: Adding ").concat(e," node")),null==n||n(e),ed.info("".concat(ec,".addNodeFromPalette: Requested ").concat(e," node"))},[n]),u=(0,o.useMemo)(()=>{let e=l.trim().toLowerCase();return ef.filter(e=>"advanced"===t||"process"===e.type).filter(t=>!e||"".concat(t.label," ").concat(t.description," ").concat(t.shortLabel).toLowerCase().includes(e))},[t,l]);return ed.debug("".concat(ec,": Rendering component")),(0,r.jsxs)(eu,{elevation:2,children:[(0,r.jsxs)(s.default,{sx:{display:{xs:"none",md:"flex"},alignItems:"baseline",justifyContent:"space-between"},children:[(0,r.jsx)(i.A,{className:"node-palette-title",variant:"subtitle1",fontWeight:800,children:"Add an action"}),(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",children:"A"})]}),(0,r.jsx)(b.A,{inputRef:d,value:l,onChange:e=>a(e.target.value),size:"small",placeholder:"Search actions",inputProps:{"aria-label":"Search actions to add"},sx:{display:{xs:"none",md:"flex"}},InputProps:{startAdornment:(0,r.jsx)(Z.A,{position:"start",children:(0,r.jsx)(es.A,{fontSize:"small"})})}}),(0,r.jsxs)(s.default,{display:"flex",flexDirection:{xs:"row",md:"column"},gap:{xs:.75,md:1},width:{xs:"max-content",md:"100%"},children:[u.map(e=>(0,r.jsxs)(ep,{nodeType:e.type,elevation:1,draggable:!0,role:"button",tabIndex:0,"aria-label":"".concat(e.label,": ").concat(e.description),title:"".concat(e.label," — ").concat(e.description),onDragStart:t=>((e,t)=>{var n;ed.debug("".concat(ec,".onDragStart: Entering method with nodeType=").concat(t)),e.dataTransfer.setData("application/reactflow",t),e.dataTransfer.effectAllowed="move";let r=document.createElement("div"),o=ef.find(e=>e.type===t);r.textContent=null!=(n=null==o?void 0:o.label)?n:"Agent step",Object.assign(r.style,{padding:"10px",background:"white",border:"1px solid #ccc",borderRadius:"8px"}),document.body.appendChild(r),ed.debug("".concat(ec,".onDragStart: Created drag preview element"));try{e.dataTransfer.setDragImage(r,75,25),ed.debug("".concat(ec,".onDragStart: Set drag image with offset (75, 25)"))}catch(e){ed.error("".concat(ec,".onDragStart: Error setting drag image:"),e)}setTimeout(()=>{document.body.removeChild(r),ed.debug("".concat(ec,".onDragStart: Removed drag preview element"))},0),ed.debug("".concat(ec,".onDragStart: Drag operation initialized"))})(t,e.type),onDragEnd:t=>{var n;return n=e.type,void ed.debug("".concat(ec,".onDragEnd: Drag operation ended for nodeType=").concat(n))},onClick:()=>c(e.type),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),c(e.type))},children:[(0,r.jsx)(eh,{nodeType:e.type,children:(0,r.jsxs)(em,{children:[(e=>{switch(e){case"process":return(0,r.jsx)(ea.default,{color:"primary"});case"finish":return(0,r.jsx)(ee.A,{color:"success"});case"mcp":return(0,r.jsx)(el.A,{color:"info"});case"subflow":return(0,r.jsx)(et.A,{color:"warning"});case"resource":return(0,r.jsx)(en.A,{sx:{color:ei.nH}});case"signal":return(0,r.jsx)(er.A,{sx:{color:ei.vp}});case"trigger":return(0,r.jsx)(eo.A,{sx:{color:ei.$Q}});default:return(0,r.jsx)(Q.A,{color:"primary"})}})(e.type),(0,r.jsx)(i.A,{variant:"caption",fontWeight:"bold",sx:{display:{xs:"block",md:"none"},fontSize:"0.62rem",lineHeight:1},children:e.shortLabel}),(0,r.jsx)(i.A,{variant:"subtitle2",fontWeight:"bold",sx:{display:{xs:"none",md:"block"}},children:e.label})]})}),(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",sx:{display:{xs:"none",md:"block"}},children:e.description})]},e.type)),0===u.length&&(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",sx:{px:.5,py:1},children:"No matching nodes"})]})]})};var ex=n(3004),ev=n(8279),eb=n(41602),ew=n(49501),ey=n(17681),ej=n(73707),eA=n(23820);let eC=(0,y.A)((0,r.jsx)("path",{fillRule:"evenodd",d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2M10 17H5v-2h5zm0-4H5v-2h5zm0-4H5V7h5zm4.82 6L12 12.16l1.41-1.41 1.41 1.42L17.99 9l1.42 1.42z"}),"FactCheck");var eS=n(60691),ek=n(76808),eT=n(36741),eI=n(19875);let eM=/\$\{var:([^}]+)\}/g,eN=/^[A-Za-z_][\w-]*$/;function eF(e){return"string"==typeof e&&eN.test(e)}let eP=/\$\{kv:([^}]+)\}/g,eR=["global","flow","folder"];function eE(e){let t=(null!=e?e:"").trim(),n=t.indexOf("/");if(n>0){let e=t.slice(0,n);if(eR.includes(e))return{scope:e,key:t.slice(n+1).trim()}}return{scope:"folder",key:t}}function ez(e,t){let n=(null!=t?t:"").trim();return n?"folder"===e?n:"".concat(e,"/").concat(n):""}let eW=/^[A-Za-z_][\w-]*$/;function eL(e){return"string"==typeof e&&eW.test(e)}function eD(e){var t,n,r;return null!=(r=null!=(n=null==(t=e.data)?void 0:t.type)?n:e.type)?r:"unknown"}function eH(e){var t;return(null==(t=e.data)?void 0:t.label)||e.id}function eB(e){var t;return(null==(t=e.data)?void 0:t.edgeType)==="mcp"}function eO(e){var t;return(null==(t=e.data)?void 0:t.edgeType)==="resource"}function eV(e){return eB(e)||eO(e)}function eU(e,t,n){let r=new Map(t.map(e=>[e.id,e])),o=new Set;for(let t of n){var l,a;if(!eB(t))continue;let n=null;if(t.source===e?n=t.target:t.target===e&&(n=t.source),!n)continue;let s=r.get(n);if(!s||"mcp"!==eD(s))continue;let i=null==(a=s.data)||null==(l=a.properties)?void 0:l.boundServer;"string"==typeof i&&i&&o.add(i)}return o}function eG(e,t,n){let r=new Map(t.map(e=>[e.id,e])),o=[],l=new Set;for(let t of n){var a;if(eV(t))continue;let n=null;t.source===e?n=t.target:t.target===e&&(null==(a=t.data)?void 0:a.bidirectional)&&(n=t.source),!n||l.has(n)||(l.add(n),o.push(n))}let s=o.map(e=>r.get(e)).filter(e=>!!e).map(e=>{var t;return{id:e.id,label:null==(t=e.data)?void 0:t.label,type:eD(e)}});return new Set((0,_.E9)(s).values())}function eK(e){let t=e.replace(/\S*\$\{[^}]*\}\S*/g," ");return/(?:^|[\s("'`])file:\/\/(?:\/|[^/\s]+\/)[^\s<>"'`]+/i.test(t)||/(?:^|[\s("'`])(?:[A-Za-z]:[\\/][^\s<>"'`]*|\\\\[^\\\s<>"'`]+\\[^\\\s<>"'`]+(?:\\[^\s<>"'`]*)?)/.test(t)||/(?:^|[\s("'`])\/(?!\/)[^\s<>"'`]+/.test(t)}function e$(e){if("string"!=typeof e)return!1;let t=e.trim();if(!t)return!1;if(/^\$\{global:[^{}]+\}$/.test(t))return!0;if(t.includes("${"))return!1;if(/^file:/i.test(t))try{let e=new URL(t);return"file:"===e.protocol&&(!!e.hostname||!!e.pathname)}catch(e){return!1}return!t.includes("\0")}function e_(e){var t,n,r,o,l,a,s,i,d,c,u,p,h,m,f,g,x,v,b,w,y,j,A,C,S,k;let T=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},I=[],M=Array.isArray(null==e?void 0:e.nodes)?e.nodes:[],N=Array.isArray(null==e?void 0:e.edges)?e.edges:[],F=(e,t,n,r)=>I.push({severity:e,code:t,message:n,nodeId:null==r?void 0:r.id,nodeLabel:r?eH(r):void 0}),P=new Map((null!=(t=T.models)?t:[]).map(e=>[e.id,e])),R=new Map((null!=(n=T.servers)?n:[]).map(e=>[e.name,e])),E=!!T.models,z=!!T.servers,W=M.filter(e=>"start"===eD(e)),L=M.filter(e=>"finish"===eD(e)),D=M.filter(e=>"process"===eD(e)),H=M.filter(e=>"mcp"===eD(e));if(0===W.length)F("error","no-start-node","The flow has no Start node, so it has no entry point.");else if(W.length>1)for(let e of W.slice(1))F("error","multiple-start-nodes","The flow has more than one Start node; only one is allowed.",e);for(let e of(0===L.length&&F("warning","no-finish-node","The flow has no Finish node; it will run but never reaches a defined end."),D)){let t=null!=(o=null==(r=e.data)?void 0:r.properties)?o:{},n=t.boundModel;if(n){if(E&&!P.has(n)){let n="string"==typeof t.modelName&&t.modelName?' (was "'.concat(t.modelName,'")'):"";F("error","process-model-missing",'Process node "'.concat(eH(e),'" is bound to a model that no longer exists').concat(n,"."),e)}}else F("error","process-missing-model",'Process node "'.concat(eH(e),'" has no model bound.'),e)}for(let e of H){let t=(null!=(a=null==(l=e.data)?void 0:l.properties)?a:{}).boundServer;if(t){if(z&&!R.has(t))F("warning","mcp-server-missing",'MCP node "'.concat(eH(e),'" is bound to server "').concat(t,"\", which isn't in your current MCP server list. It may be offline (e.g. not connected), renamed, or removed — if it was renamed or removed, rebind this node."),e);else if(z){let n=R.get(t);if(n.status&&"connected"!==n.status){let r="disabled"===n.status?"disabled":"not connected (".concat(n.status,")");F("warning","mcp-server-disconnected",'MCP node "'.concat(eH(e),'" is bound to server "').concat(t,'", which is currently ').concat(r,". It will provide tools again once it reconnects."),e)}}}else F("warning","mcp-missing-server",'MCP node "'.concat(eH(e),'" is not bound to a server.'),e);N.some(t=>eB(t)&&(t.source===e.id||t.target===e.id))||F("warning","mcp-node-unconnected",'MCP node "'.concat(eH(e),'" is not connected to any Process node.'),e)}if(T.fileAccessMcp){let e=T.fileAccessMcp,t=Object.entries(e).filter(e=>{let[,t]=e;return t.configured&&!t.disabled&&"usable"===t.usability}).map(e=>{let[t]=e;return t}),n=Object.values(e).some(e=>e.configured&&!e.disabled&&"unknown"===e.usability);for(let r of D)if((function(e){var t,n;let r=null!=(n=null==(t=e.data)?void 0:t.properties)?n:{},o=[];return"string"==typeof r.promptTemplate&&r.promptTemplate&&o.push(r.promptTemplate),"isolated"===r.inputMode&&"string"==typeof r.isolatedPrompt&&r.isolatedPrompt&&o.push(r.isolatedPrompt),o})(r).some(eK)){if(0===t.length){n||F("warning","process-filepath-mcp-unavailable",'Process node "'.concat(eH(r),'" contains a literal filepath, but no configured file-access MCP server is currently available. Enable or reconnect one so this flow can access the path.'),r);continue}!n&&t.every(t=>!function(e,t,n){return!![...Array.isArray(t.roots)?t.roots:[],...n.filter(t=>{var n,r;return(null==(r=t.data)||null==(n=r.properties)?void 0:n.boundServer)===e}).flatMap(e=>{var t,n;let r=null==(n=e.data)||null==(t=n.properties)?void 0:t.roots;return Array.isArray(r)?r:[]})].some(e$)||e$(t.rootPath)}(t,e[t],H))&&F("warning","process-filepath-mcp-roots-missing",'Process node "'.concat(eH(r),'" contains a literal filepath, but the available file-access MCP servers have no effective roots configured. Add roots globally or on the corresponding MCP node in this flow.'),r)}}for(let e of M.filter(e=>"resource"===eD(e))){let t=null!=(i=null==(s=e.data)?void 0:s.properties)?i:{},n="run"===t.scope?"run":"mcp",r="string"==typeof t.boundServer?t.boundServer:"",o="string"==typeof t.uri?t.uri:"",l="string"==typeof t.runName?t.runName.trim():"";"mcp"!==n||r&&o||F("warning","resource-missing-binding",'Resource node "'.concat(eH(e),'" has no ').concat(r?"resource URI":"server"," bound; connected steps will receive nothing."),e),"run"!==n||l||F("warning","resource-missing-binding",'Resource node "'.concat(eH(e),'" is a run artifact with no name; give it a name so steps can produce/consume it.'),e),"run"===n&&l&&!eF(l)&&F("warning","resource-run-name",'Resource node "'.concat(eH(e),'" is named "').concat(l,'", which is not a valid artifact name (letters, digits, _ and - only, not starting with a digit); it will be awkward to reference with ${res:...}.'),e),"mcp"===n&&r&&z&&!R.has(r)&&F("warning","resource-server-missing",'Resource node "'.concat(eH(e),'" is bound to server "').concat(r,"\", which isn't in your current MCP server list."),e);let a=N.filter(t=>eO(t)&&(t.source===e.id||t.target===e.id));0===a.length&&F("warning","resource-node-unconnected",'Resource node "'.concat(eH(e),'" is not connected to any Process node.'),e);let d=a.filter(t=>t.target===e.id);"mcp"===n&&d.length>0&&F("error","resource-produce-static",'Resource node "'.concat(eH(e),'" is a static MCP resource, but a step writes INTO it. Only run artifacts (scope "run") can be produced by a step — flip the edge or make this a run artifact.'),e),"run"===n&&d.length>1&&F("warning","resource-multiple-producers",'Resource node "'.concat(eH(e),'" is produced by ').concat(d.length," steps; the last writer wins. Consider one producer per artifact."),e),"run"===n&&0===d.length&&a.length>0&&F("warning","resource-consumed-never-produced",'Resource node "'.concat(eH(e),'" is consumed but no step in this flow produces it; it resolves to nothing unless an earlier run captured it.'),e)}for(let e of M.filter(e=>"signal"===eD(e))){let t=null!=(c=null==(d=e.data)?void 0:d.properties)?c:{};("string"==typeof t.topic?t.topic.trim():"")||F("warning","signal-missing-topic",'Signal node "'.concat(eH(e),'" has no topic; it emits nothing. Give it a topic that a flow-event trigger can listen for.'),e)}if(W.length>0){let e=function(e){let t=new Map,n=(e,n)=>{t.has(e)||t.set(e,[]),t.get(e).push(n)};for(let t of e){var r;!eV(t)&&(n(t.source,t.target),(null==(r=t.data)?void 0:r.bidirectional)&&n(t.target,t.source))}return t}(N);for(let t of W)(null==(u=e.get(t.id))?void 0:u.length)||F("error","start-no-outgoing","The Start node is not connected to anything; the flow cannot run.",t);let t=function(e,t){let n=new Set(e),r=[...e];for(;r.length;){var o;let e=r.shift();for(let l of null!=(o=t.get(e))?o:[])n.has(l)||(n.add(l),r.push(l))}return n}(W.map(e=>e.id),e);for(let e of[...D,...L])t.has(e.id)||F("warning","unreachable-node","".concat("finish"===eD(e)?"Finish":"Process",' node "').concat(eH(e),'" is not reachable from the Start node.'),e)}for(let e of M.filter(e=>"subflow"===eD(e))){let t=N.filter(t=>{var n;return!eV(t)&&(t.source===e.id||t.target===e.id&&!!(null==(n=t.data)?void 0:n.bidirectional))});t.length>1&&F("error","subflow-multiple-outgoing",'Subflow node "'.concat(eH(e),'" has ').concat(t.length," outgoing connections; a subflow can only have one (either A > B > C or a bidirectional A <> B)."),e);let n=null!=(h=null==(p=e.data)?void 0:p.properties)?h:{},r="string"==typeof n.subflowId&&n.subflowId?n.subflowId:void 0,o=Array.isArray(n.parallelSubflowIds)?n.parallelSubflowIds.filter(e=>"string"==typeof e&&!!e):[];r&&o.length>0&&F("error","subflow-both-targets",'Subflow node "'.concat(eH(e),'" sets both a single "subflowId" and "parallelSubflowIds"; use one or the other.'),e);let l=!0===n.mapOverList;l&&o.length>0&&F("error","subflow-map-and-parallel",'Subflow node "'.concat(eH(e),'" combines "mapOverList" with "parallelSubflowIds"; map-over-list runs a single child once per item and cannot be combined with parallel fan-out.'),e),l&&!r&&0===o.length&&F("error","subflow-map-no-child",'Subflow node "'.concat(eH(e),'" has "mapOverList" but no child flow ("subflowId"); select a flow to run once per item.'),e);let a=Array.isArray(n.spawnBriefs)?n.spawnBriefs.filter(e=>"string"==typeof e&&""!==e.trim()):[];a.length>0&&!r&&F("error","subflow-spawn-no-child",'Subflow node "'.concat(eH(e),'" has spawn briefs but no sub-agent flow ("subflowId"); select the flow to spawn once per brief.'),e),a.length>0&&o.length>0&&F("error","subflow-spawn-and-parallel",'Subflow node "'.concat(eH(e),'" combines "spawnBriefs" with "parallelSubflowIds"; spawn briefs run one sub-agent per brief and cannot be combined with a multi-flow fan-out list.'),e),a.length>0&&l&&F("error","subflow-spawn-and-map",'Subflow node "'.concat(eH(e),'" combines "spawnBriefs" with "mapOverList"; use one lane source or the other.'),e);let s="string"==typeof n.parallelSubflowIdsVar?n.parallelSubflowIdsVar.trim():"";if(s&&(eF(s)||F("warning","subflow-parallel-var-name",'Subflow node "'.concat(eH(e),'" reads dynamic fan-out targets from "').concat(s,'", which is not a valid variable name (letters, digits, _ and - only, not starting with a digit); it will be awkward to capture with ${var:...}.'),e),l&&F("error","subflow-map-and-parallel-var",'Subflow node "'.concat(eH(e),'" combines "mapOverList" with dynamic fan-out ("parallelSubflowIdsVar"); map-over-list runs a single child once per item and cannot be combined with fan-out.'),e),M.some(e=>{var t,n;let r=null==(n=e.data)||null==(t=n.properties)?void 0:t.captureVariable;return"string"==typeof r&&r.trim()===s})||F("warning","subflow-parallel-var-uncaptured",'Subflow node "'.concat(eH(e),'" reads dynamic fan-out targets from variable "').concat(s,'", but no node captures it (captureVariable). It may be seeded by the caller; otherwise it resolves to no targets and the node falls back to its static parallel list.'),e)),!0===n.allowCallerFanout&&l&&F("error","subflow-map-and-caller-fanout",'Subflow node "'.concat(eH(e),'" combines "mapOverList" with agentic fan-out ("allowCallerFanout"); map-over-list runs a single child once per item and cannot be combined with fan-out.'),e),o.length>0||a.length>0){let t=n.concurrencyLimit;"number"==typeof t&&t<1&&F("warning","subflow-concurrency-limit",'Subflow node "'.concat(eH(e),'" has a concurrencyLimit of ').concat(t,"; it must be at least 1 (the runtime default will be used)."),e)}}{let e=new Map(M.map(e=>[e.id,e])),t=new Set;for(let n of N){if(eV(n))continue;let r=null==(m=n.data)?void 0:m.condition;if(!r||"object"!=typeof r)continue;let o=e.get(n.source),l=o?eD(o):"unknown";if("process"!==l){F("error","edge-condition-non-process","An edge leaving ".concat("unknown"===l?"an unknown":"the ".concat(l),' node "').concat(o?eH(o):n.source,'" has a routing condition, but only process nodes can route on a condition.'),null!=o?o:void 0);continue}t.add(n.source),(0,eI.C)(r.kind)?"always"===r.kind||("string"!=typeof r.value||0===r.value.length?F("warning","edge-condition-value",'Process node "'.concat(eH(o),'" has an outgoing edge condition with no "value"; it will never match.'),o):"regex"!==r.kind||(0,eI.wM)(r.value)||F("warning","edge-condition-regex",'Process node "'.concat(eH(o),'" has an outgoing edge with a regex condition that does not compile; it will never match.'),o)):F("warning","edge-condition-kind",'Process node "'.concat(eH(o),'" has an outgoing edge whose condition kind "').concat(String(r.kind),'" is unknown; it will never match.'),o)}for(let n of t){let t=e.get(n);t&&(N.some(e=>{var t,r;return!eV(e)&&(e.source===n?!(null==(r=e.data)?void 0:r.condition)||"always"===e.data.condition.kind&&!e.data.condition.negate:e.target===n&&null!=(t=e.data)&&!!t.bidirectional)})||F("warning","edge-condition-no-fallback",'Process node "'.concat(eH(t),'" has conditioned outgoing edges but no bare fallback edge; if no condition matches, the flow ends here.'),t))}}{let e=new Set;for(let t of M){let n=null==(g=t.data)||null==(f=g.properties)?void 0:f.captureVariable;if("string"==typeof n&&n.trim()){let r=n.trim();e.add(r),eF(r)||F("warning","capture-var-name","".concat("subflow"===eD(t)?"Subflow":"Process",' node "').concat(eH(t),'" captures into "').concat(r,'", which is not a valid variable name (letters, digits, _ and - only, not starting with a digit); it will be awkward to reference with ${var:...}.'),t)}}let t=["promptTemplate","isolatedPrompt"],n=new Set;for(let r of M){let o=null!=(v=null==(x=r.data)?void 0:x.properties)?v:{};for(let l of t){let t=o[l];if("string"==typeof t&&t)for(let o of function(e){let t;if("string"!=typeof e||0===e.length)return[];let n=new Set;for(eM.lastIndex=0;null!==(t=eM.exec(e));){let e=t[1].trim();e&&n.add(e)}return[...n]}(t)){if(e.has(o))continue;let t="".concat(r.id,":").concat(o);n.has(t)||(n.add(t),F("warning","var-ref-uncaptured","".concat(eH(r)," references ${var:").concat(o,'} but no step in this flow captures "').concat(o,'" (via captureVariable). It resolves to empty unless supplied as a run input — check for a typo or a step ordered after this one.'),r))}}}}{for(let e of M){let t=null==(w=e.data)||null==(b=w.properties)?void 0:b.captureKv;if("string"==typeof t&&t.trim()){let{key:n}=eE(t.trim());eL(n)||F("warning","capture-kv-name","".concat("subflow"===eD(e)?"Subflow":"Process",' node "').concat(eH(e),'" captures into kv "').concat(t.trim(),'", whose key is not a valid name (letters, digits, _ and - only, not starting with a digit); it will be awkward to reference with ${kv:...}.'),e)}}let e=["promptTemplate","isolatedPrompt"],t=new Set;for(let n of M){let r=null!=(j=null==(y=n.data)?void 0:y.properties)?j:{};for(let o of e){let e=r[o];if("string"==typeof e&&e)for(let r of function(e){let t;if("string"!=typeof e||0===e.length)return[];let n=new Set;for(eP.lastIndex=0;null!==(t=eP.exec(e));){let e=t[1].trim();e&&n.add(e)}return[...n]}(e)){let{key:e}=eE(r);if(eL(e))continue;let o="".concat(n.id,":").concat(r);t.has(o)||(t.add(o),F("warning","kv-ref-name","".concat(eH(n)," references ${kv:").concat(r,"}, whose key is not a valid name (letters, digits, _ and - only, not starting with a digit); it resolves to empty."),n))}}}}for(let e of D){let t=null==(C=e.data)||null==(A=C.properties)?void 0:A.promptTemplate;if("string"!=typeof t||!t)continue;let n=eU(e.id,M,N),r=null,o=new Set,l=new Set;for(let a of(0,X.A$)(t)){if("handoff"===a.server){let t="handoff:".concat(a.name);if(l.has(t))continue;l.add(t),o.add(a.name),r||(r=eG(e.id,M,N)),r.has(a.name)||F("warning","handoff-pill-obsolete",'Process node "'.concat(eH(e),'" references handoff tool "').concat(a.name,'", which no longer exists (the target node was removed, or renamed so the tool name changed). Update or remove the pill.'),e);continue}let t="".concat(a.kind,":").concat(a.server,":").concat(a.name);!l.has(t)&&(l.add(t),n.has(a.server)?"tool"===a.kind&&T.serverTools&&T.serverTools[a.server]&&!T.serverTools[a.server].includes(a.name)&&F("warning","tool-unavailable",'Process node "'.concat(eH(e),'" references tool "').concat(a.name,'" which server "').concat(a.server,'" does not currently expose.'),e):F("error","tool-pill-disconnected",'Process node "'.concat(eH(e),'" references ').concat(a.kind,' "').concat(a.name,'" from server "').concat(a.server,'", but it is not connected to that server (the MCP node was removed or the server was renamed).'),e))}if(o.size>0)for(let t of null!=r?r:eG(e.id,M,N))o.has(t)||F("warning","handoff-target-unreferenced",'Process node "'.concat(eH(e),'" can hand off to "').concat(t,'" but its prompt never references ${tool:handoff__').concat(t,"}, so the model may never route there."),e)}if(T.serverTools)for(let e of D){let t=eU(e.id,M,N),n=new Set;for(let r of t){let t=T.serverTools[r];if(Array.isArray(t)&&0===t.length&&F("warning","mcp-server-no-tools",'Process node "'.concat(eH(e),'" is connected to MCP server "').concat(r,'", which currently exposes 0 tools. The connection has no effect until the server provides tools.'),e),Array.isArray(t))for(let o of Array.isArray(null==(k=e.data)||null==(S=k.properties)?void 0:S.enabledTools)?e.data.properties.enabledTools:[]){let l="enabledTool:".concat(r,":").concat(o);!n.has(l)&&(t.includes(o)||(n.add(l),F("warning","tool-unavailable",'Process node "'.concat(eH(e),'" has enabledTool "').concat(o,'" which server "').concat(r,'" does not currently expose.'),e)))}}}let B=I.filter(e=>"error"===e.severity).length,O=I.length-B;return{issues:I,errorCount:B,warningCount:O,isRunnable:0===B}}let eX=(0,W.h)("components/flow/FlowBuilder/FlowValidationButton"),eY=e=>{var t,n;let{nodes:l,edges:a}=e,[c,u]=(0,o.useState)(!1),[p,h]=(0,o.useState)(null),[m,f]=(0,o.useState)(!1),[g,x]=(0,o.useState)(null),[v,b]=(0,o.useState)(null),w=(0,o.useRef)(null),y=(0,o.useRef)(null),j=(0,o.useId)(),A=(0,o.useId)(),C=(0,o.useId)();(0,o.useEffect)(()=>{if(!c)return;let e=window.requestAnimationFrame(()=>{var e;null==(e=y.current)||e.focus()});return()=>window.cancelAnimationFrame(e)},[c]);let S=(0,o.useCallback)(()=>{u(!1),window.requestAnimationFrame(()=>{var e;null==(e=w.current)||e.focus()})},[]),k=(0,o.useCallback)(()=>{var e;let t=null==(e=y.current)?void 0:e.contains(document.activeElement);u(!1),t&&window.requestAnimationFrame(()=>{var e;null==(e=w.current)||e.focus()})},[]),T=(0,o.useCallback)(async()=>{f(!0),b(null);try{var e,t,n,r,o,s;let i=null!=(e=await O.N.tryLoadModels())?e:void 0,d=await B.S.loadServerConfigs(),c=Array.isArray(d)?d:void 0,u=null==c?void 0:c.map(e=>({name:e.name,status:e.disabled?"disabled":void 0})),p={},h=new Map,m=null!=(t=null==c?void 0:c.filter(e=>!!e.hostPathAccess))?t:[],f=new Set(m.map(e=>e.name));if(c){let e=new Map(c.map(e=>[e.name,!!e.disabled])),t=new Set;for(let e of l){let l=null!=(s=null==e||null==(n=e.data)?void 0:n.type)?s:null==e?void 0:e.type,a=null==e||null==(o=e.data)||null==(r=o.properties)?void 0:r.boundServer;"mcp"===l&&"string"==typeof a&&a&&t.add(a)}for(let{name:e,disabled:n}of m)n||t.add(e);await Promise.all([...t].map(async t=>{if(!e.get(t))try{let e=await B.S.listServerTools(t);!e.error&&Array.isArray(e.tools)?(p[t]=e.tools.map(e=>null==e?void 0:e.name).filter(e=>"string"==typeof e),h.set(t,"usable")):f.has(t)&&h.set(t,"unknown")}catch(e){f.has(t)&&h.set(t,"unknown"),eX.debug('Could not gather MCP tool list for "'.concat(t,'" during the flow check'),e)}}))}let g=c?Object.fromEntries(m.map(e=>[e.name,function(e,t,n){var r;let o=t.find(t=>t.name===e);if(!o)return{configured:!1,disabled:!1,usability:"unavailable"};let l=!!o.disabled;return{configured:!0,disabled:l,usability:l?"unavailable":null!=(r=n.get(e))?r:"unknown",roots:o.roots,rootPath:o.rootPath}}(e.name,c,h)])):void 0,v=e_({nodes:l,edges:a},{models:i,servers:u,serverTools:p,fileAccessMcp:g});x(v.issues)}catch(e){eX.warn("Flow validation failed to run",e),x(null),b("The flow check could not finish. Your graph was not marked healthy—try again.")}finally{f(!1)}},[l,a]),F=(0,o.useCallback)(e=>{h(e.currentTarget),u(!0),x(null),b(null),T()},[T]),P=(0,o.useCallback)(e=>{e&&(S(),document.dispatchEvent(new CustomEvent("selectNode",{detail:{nodeId:e}})))},[S]),E=null!=(t=null==g?void 0:g.filter(e=>"error"===e.severity).length)?t:0,z=(null!=(n=null==g?void 0:g.length)?n:0)-E;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(d.A,{ref:w,id:j,variant:"outlined",color:"primary",onClick:F,startIcon:(0,r.jsx)(eC,{}),"aria-haspopup":"dialog","aria-expanded":c,"aria-controls":A,sx:{textTransform:"none"},children:["Check Flow",g&&g.length>0&&(0,r.jsx)(M.A,{size:"small",color:E>0?"error":"warning",label:g.length,sx:{ml:1,height:20}})]}),(0,r.jsx)(ex.A,{open:c,anchorEl:p,placement:"bottom-end",sx:{zIndex:e=>e.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,10]}}],children:(0,r.jsx)(ev.x,{onClickAway:k,children:(0,r.jsxs)(I.A,{ref:y,id:A,role:"dialog","aria-modal":"false","aria-labelledby":C,"aria-busy":m,tabIndex:-1,onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),S())},elevation:18,sx:{width:"min(92vw, 440px)",maxHeight:"min(68dvh, 560px)",overflow:"hidden",border:1,borderColor:"divider",borderRadius:3},children:[(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1.5},children:[(0,r.jsx)(i.A,{id:C,variant:"subtitle1",fontWeight:800,children:"Flow Check"}),g&&(0,r.jsxs)(s.default,{sx:{display:"flex",gap:.75,ml:.5},children:[E>0&&(0,r.jsx)(M.A,{size:"small",color:"error",label:"".concat(E," error").concat(1===E?"":"s")}),z>0&&(0,r.jsx)(M.A,{size:"small",color:"warning",label:"".concat(z," warning").concat(1===z?"":"s")})]})]}),(0,r.jsx)(R.A,{}),(0,r.jsx)(s.default,{sx:{maxHeight:"min(52dvh, 420px)",overflowY:"auto",p:1},children:m?(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:2,py:3,justifyContent:"center"},children:[(0,r.jsx)(N.default,{size:22}),(0,r.jsx)(i.A,{color:"text.secondary",children:"Checking flow…"})]}):v?(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,py:2,px:1},children:[(0,r.jsx)(eS.A,{color:"error"}),(0,r.jsxs)(s.default,{children:[(0,r.jsx)(i.A,{fontWeight:700,children:"Check unavailable"}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",children:v})]})]}):g&&0===g.length?(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1.5,py:3,px:1,justifyContent:"center"},children:[(0,r.jsx)(eT.A,{color:"success"}),(0,r.jsx)(i.A,{children:"No problems found — this flow looks runnable."})]}):(0,r.jsx)(eb.A,{dense:!0,disablePadding:!0,children:(null!=g?g:[]).map((e,t)=>{var n;let o=!!e.nodeId,l=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ew.A,{sx:{minWidth:36},children:"error"===e.severity?(0,r.jsx)(eS.A,{color:"error",fontSize:"small"}):(0,r.jsx)(ek.A,{color:"warning",fontSize:"small"})}),(0,r.jsx)(ey.A,{primary:e.message,secondary:o?"Node: ".concat(null!=(n=e.nodeLabel)?n:e.nodeId," — reveal in inspector"):void 0})]});return o?(0,r.jsx)(ej.A,{onClick:()=>P(e.nodeId),alignItems:"flex-start",children:l},t):(0,r.jsx)(eA.Ay,{alignItems:"flex-start",children:l},t)})})}),(0,r.jsx)(R.A,{}),(0,r.jsxs)(s.default,{sx:{display:"flex",justifyContent:"flex-end",gap:1,p:1},children:[(0,r.jsx)(d.A,{onClick:T,disabled:m,children:"Re-check"}),(0,r.jsx)(d.A,{onClick:S,variant:"contained",children:"Done"})]})]})})})]})};var eq=n(80777),eJ=n(57813),eZ=n(26466),eQ=n(83478),e0=n(30351),e1=n(4097),e2=n(60700);let e5=(0,T.Ay)(I.A)(e=>{let{theme:t}=e;return{width:320,minWidth:320,height:"100%",minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",border:"1px solid ".concat(t.palette.divider),borderRadius:16,backgroundColor:"dark"===t.palette.mode?"rgba(17, 22, 41, 0.9)":"rgba(255, 255, 255, 0.92)",boxShadow:"dark"===t.palette.mode?"0 18px 55px rgba(0,0,0,.24)":"0 18px 55px rgba(49,45,99,.1)",backdropFilter:"blur(20px) saturate(140%)",[t.breakpoints.down("lg")]:{width:286,minWidth:286},[t.breakpoints.down("md")]:{width:"100%",minWidth:0,height:"auto",maxHeight:"none"}}}),e4=e=>{var t,n,l,a;let{selectedNode:c,onClearSelection:h,onCommitNode:m,onOpenAdvanced:f,flowName:g,flowNameError:x,onFlowNameChange:v,flowDescription:w,onFlowDescriptionChange:y,authoringMode:j,onAuthoringModeChange:A,permissionRuleCount:C,onOpenPermissionRules:S,beginnerMode:T=!1,onSuggestTools:I,onCheckPlausibility:N}=e,[E,z]=(0,o.useState)(c?"node":"flow"),[W,L]=(0,o.useState)(null!=(n=null==c?void 0:c.data.label)?n:""),[D,H]=(0,o.useState)(null!=(l=null==c?void 0:c.data.description)?l:""),[B,O]=(0,o.useState)(String(null!=(a=null==c||null==(t=c.data.properties)?void 0:t.promptTemplate)?a:""));(0,o.useEffect)(()=>{c?z("node"):z("flow")},[null==c?void 0:c.id]),(0,o.useEffect)(()=>{var e,t,n,r;L(null!=(t=null==c?void 0:c.data.label)?t:""),H(null!=(n=null==c?void 0:c.data.description)?n:""),O(String(null!=(r=null==c||null==(e=c.data.properties)?void 0:e.promptTemplate)?r:""))},[null==c?void 0:c.id,null==c?void 0:c.data]);let V=(0,o.useMemo)(()=>{var e;if(!c)return[];let t=null!=(e=c.data.properties)?e:{},n=[];return"string"==typeof t.modelId&&t.modelId?n.push({label:T?"AI":"Model",value:t.modelId}):"string"==typeof t.model&&t.model&&n.push({label:T?"AI":"Model",value:t.model}),"string"==typeof t.boundServer&&t.boundServer&&n.push({label:T?"App":"Server",value:t.boundServer}),"string"==typeof t.subflowId&&t.subflowId&&n.push({label:T?"Agent":"Flow",value:t.subflowId}),"string"==typeof t.signalName&&t.signalName&&n.push({label:T?"Notification":"Signal",value:t.signalName}),n},[c,T]),U=()=>{var e;if(!c)return null;let t={...null!=(e=c.data.properties)?e:{}};("process"===c.data.type||"start"===c.data.type)&&(t.promptTemplate=B);let n={...c.data,label:W.trim()||c.data.label,description:D.trim()||void 0,properties:t};return JSON.stringify(n)!==JSON.stringify(c.data)&&m(c.id,n),{...c,data:n}};return(0,r.jsxs)(e5,{elevation:0,"aria-label":T&&c?"Step settings":T?"Agent settings":"Flow inspector",children:[(0,r.jsxs)(s.default,{sx:{px:1.5,pt:1.25},children:[(0,r.jsxs)(eq.A,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1,children:[(0,r.jsxs)(s.default,{sx:{minWidth:0},children:[(0,r.jsx)(i.A,{variant:"overline",color:"text.secondary",sx:{letterSpacing:".12em"},children:T?c?"Edit this step":"Agent settings":"Inspector"}),(0,r.jsx)(i.A,{variant:"subtitle1",fontWeight:800,noWrap:!0,children:c?c.data.label:g})]}),c&&(0,r.jsx)(p.A,{title:T?"Close step settings":"Clear node selection",children:(0,r.jsx)(u.A,{size:"small","aria-label":T?"Close step settings":"Close node inspector",onClick:h,children:(0,r.jsx)(eQ.A,{fontSize:"small"})})})]}),!T&&(0,r.jsxs)(eJ.A,{value:E,onChange:(e,t)=>z(t),variant:"fullWidth",sx:{mt:.5,minHeight:38,"& .MuiTab-root":{minHeight:38}},children:[(0,r.jsx)(eZ.A,{value:"node",label:"Node",disabled:!c}),(0,r.jsx)(eZ.A,{value:"flow",label:"Flow"})]})]}),(0,r.jsx)(R.A,{}),(0,r.jsx)(s.default,{sx:{p:1.5,overflowY:"auto",flex:1},children:"node"===E&&c?(0,r.jsxs)(eq.A,{spacing:1.5,children:[(0,r.jsxs)(eq.A,{direction:"row",alignItems:"center",gap:1,children:[(0,r.jsx)(M.A,{size:"small",label:((e,t)=>{let n=String(e.data.type||e.type||"node");if(t){var r;return null!=(r=({start:"When it starts",process:"AI step",finish:"Final answer",mcp:"Connected app",subflow:"Another agent",resource:"Saved information",signal:"Notification",trigger:"Automatic start"})[n])?r:"Step"}return"mcp"===n?"MCP":"".concat(n.charAt(0).toUpperCase()).concat(n.slice(1))})(c,T),color:"finish"===c.data.type?"success":"primary",variant:"outlined"}),!T&&(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",noWrap:!0,children:c.id})]}),(0,r.jsx)(b.A,{label:T?"Step name":"Node name",size:"small",fullWidth:!0,value:W,onChange:e=>L(e.target.value),onBlur:U,onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()}}),(0,r.jsx)(b.A,{label:T?"Short note (optional)":"What this step does",size:"small",fullWidth:!0,multiline:!0,minRows:2,maxRows:4,value:D,onChange:e=>H(e.target.value),onBlur:U,placeholder:T?"A reminder about why this step is here":"Optional note for future you"}),("process"===c.data.type||"start"===c.data.type)&&(0,r.jsx)(b.A,{label:T?"start"===c.data.type?"Helpful background":"What should the AI do?":"start"===c.data.type?"Starting context":"Task prompt",size:"small",fullWidth:!0,multiline:!0,minRows:5,maxRows:12,value:B,onChange:e=>O(e.target.value),onBlur:U,onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),U())},placeholder:"start"===c.data.type?T?"Anything the agent should always know":"Optional context injected when the flow starts":T?"Explain the job in everyday language":"Describe the result this step should produce",helperText:T?"Your change is applied when you leave this field.":"Changes apply when you leave the field. Ctrl/⌘ + Enter applies immediately."}),!T&&V.length>0&&(0,r.jsx)(s.default,{sx:e=>({p:1.25,borderRadius:2.5,border:"1px solid ".concat(e.palette.divider),bgcolor:(0,J.X4)(e.palette.primary.main,.05)}),children:V.map(e=>(0,r.jsxs)(eq.A,{direction:"row",justifyContent:"space-between",gap:1,mb:.5,children:[(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",children:e.label}),(0,r.jsx)(i.A,{variant:"caption",fontWeight:700,noWrap:!0,children:e.value})]},e.label))}),(0,r.jsx)(d.A,{variant:T?"outlined":"contained",startIcon:(0,r.jsx)(k.A,{}),endIcon:(0,r.jsx)(e0.A,{}),onClick:()=>{let e=U();e&&f(e)},children:T?"More options":"Full settings"}),"process"===c.data.type&&I&&(0,r.jsx)(d.A,{variant:"contained",startIcon:(0,r.jsx)(e2.A,{}),onClick:()=>{let e=U();e&&I(e)},children:"Suggest connected tools"}),(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",children:T?"Most people only need the fields above. More options contains AI and connected-app controls.":"Single-click any node to inspect it. Double-click opens full settings immediately."})]}):(0,r.jsxs)(eq.A,{spacing:1.5,children:[(0,r.jsxs)(eq.A,{direction:"row",gap:1,alignItems:"center",children:[(0,r.jsx)(e1.A,{color:"primary",fontSize:"small"}),(0,r.jsxs)(s.default,{children:[(0,r.jsx)(i.A,{variant:"subtitle2",fontWeight:800,children:T?"About your agent":"Flow details"}),(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",children:T?"Give it a clear name and say what it is for.":"Name, describe, and tune the whole workflow."})]})]}),(0,r.jsx)(b.A,{size:"small",label:T?"Agent name":"Flow Name",value:g,onChange:e=>v(e.target.value),error:!!x,helperText:null!=x?x:T?"Use a short name you will recognize.":"Renames save directly—Duplicate is a separate command.",fullWidth:!0}),N&&(0,r.jsx)(d.A,{variant:"outlined",startIcon:(0,r.jsx)(e2.A,{}),onClick:N,children:"Check whole agent"}),(0,r.jsx)(b.A,{size:"small",label:T?"What should it help with?":"Description",value:w,onChange:e=>y(e.target.value),multiline:!0,minRows:3,maxRows:7,fullWidth:!0,placeholder:T?"Example: Turns long notes into a short, friendly summary":"What this flow accomplishes"}),!T&&(0,r.jsxs)(s.default,{sx:e=>({p:1.25,borderRadius:2.5,border:"1px solid ".concat(e.palette.divider),bgcolor:(0,J.X4)(e.palette.primary.main,.04)}),children:[(0,r.jsx)(F.A,{control:(0,r.jsx)(P.A,{size:"small",checked:"advanced"===j,onChange:e=>A(e.target.checked?"advanced":"guided")}),label:"advanced"===j?"Advanced":"Guided"}),(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",display:"block",children:"advanced"===j?"Runtime, routing, resources, signals, and scheduling are visible.":"The common authoring controls stay focused and calm."})]}),"advanced"===j&&(0,r.jsxs)(d.A,{variant:"outlined",onClick:S,startIcon:(0,r.jsx)(e1.A,{}),children:["Permission rules",C?" (".concat(C,")"):""]}),!T&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(R.A,{}),(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",children:"Shortcuts: A or / adds a step \xb7 Ctrl/⌘ S saves \xb7 Ctrl/⌘ Z undoes."})]})]})})]})};var e3=n(52641),e9=n(95436),e6=n(55606),e8=n(95070);let e7=(0,y.A)((0,r.jsx)("path",{d:"M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1"}),"AddRounded"),te=(0,y.A)((0,r.jsx)("path",{d:"M11 5v11.17l-4.88-4.88c-.39-.39-1.03-.39-1.42 0s-.39 1.02 0 1.41l6.59 6.59c.39.39 1.02.39 1.41 0l6.59-6.59c.39-.39.39-1.02 0-1.41a.996.996 0 0 0-1.41 0L13 16.17V5c0-.55-.45-1-1-1s-1 .45-1 1"}),"ArrowDownwardRounded");var tt=n(26842);let tn=(0,y.A)((0,r.jsx)("path",{d:"M8 6.82v10.36c0 .79.87 1.27 1.54.84l8.14-5.18c.62-.39.62-1.29 0-1.69L9.54 5.98C8.87 5.55 8 6.03 8 6.82"}),"PlayArrowRounded"),tr={process:"AI works on the task",subflow:"Ask another agent",signal:"Notify another automation"},to=new Set(["Process Node","Subflow Node","Signal Node"]),tl=e=>{let{children:t,complete:n=!1}=e;return(0,r.jsx)(s.default,{"aria-hidden":"true",sx:{display:"grid",width:34,height:34,flexShrink:0,placeItems:"center",borderRadius:"50%",color:n?"success.contrastText":"primary.contrastText",bgcolor:n?"success.main":"primary.main",fontWeight:850,boxShadow:e=>"0 8px 24px ".concat((0,J.X4)(n?e.palette.success.main:e.palette.primary.main,.28))},children:n?(0,r.jsx)(tt.A,{fontSize:"small"}):t})},ta=e=>{let{nodes:t,orderedStepIds:n=[],selectedNodeId:l,flowName:a,flowNameError:c,onFlowNameChange:u,onSelectNode:p,onAddTask:h,onTry:f,isSaving:g=!1,hasAdvancedFeatures:x=!1,readyToTry:v=!0,needsAIConnection:w=!1,onSwitchAdvanced:y,models:j=[],aiAssistance:A="manual",selectedModelId:C,onChooseAssistance:S,onModelChange:T,onCheckPlausibility:N}=e,[F,P]=(0,o.useState)(""),R=(0,o.useMemo)(()=>{let e=new Map(n.map((e,t)=>[e,t]));return t.filter(e=>["process","subflow","signal"].includes(e.data.type)).sort((t,n)=>{var r,o,l,a,s,i;return(null!=(l=e.get(t.id))?l:Number.MAX_SAFE_INTEGER)-(null!=(a=e.get(n.id))?a:Number.MAX_SAFE_INTEGER)||(null!=(s=null==(r=t.position)?void 0:r.y)?s:0)-(null!=(i=null==(o=n.position)?void 0:o.y)?i:0)})},[t,n]),E=!!a.trim()&&!/^(?:NewFlow\d*|Untitled (?:assistant|agent)(?: \d+)?)$/i.test(a.trim())&&!c,W=!!F.trim()&&!x&&"unasked"!==A&&("assisted"!==A||!!C),L=E&&R.length>0&&v&&!g,D=()=>{let e=F.trim();e&&(h(e),P(""))};return(0,r.jsx)(s.default,{"aria-label":"Guided agent builder",sx:{flex:1,minHeight:0,overflowY:"auto",px:{xs:.5,sm:1.5,lg:3},py:{xs:1,sm:1.5,lg:2.5}},children:(0,r.jsxs)(s.default,{sx:{width:"100%",maxWidth:780,mx:"auto"},children:[(0,r.jsxs)(eq.A,{spacing:.8,sx:{mb:2.5},children:[(0,r.jsx)(M.A,{icon:(0,r.jsx)(e2.A,{}),label:"Simple setup",color:"primary",variant:"outlined",sx:{alignSelf:"flex-start"}}),(0,r.jsx)(i.A,{variant:"h4",children:"Build it like a simple recipe."}),(0,r.jsx)(i.A,{color:"text.secondary",children:"No diagrams or technical setup needed. Tell FLUJO what you want, one step at a time."})]}),(0,r.jsxs)(eq.A,{spacing:1.5,children:[j.length>0&&S&&(0,r.jsx)(I.A,{elevation:0,sx:{p:{xs:2,sm:2.5},border:1,borderColor:"unasked"===A?"primary.main":"divider",borderRadius:4},children:(0,r.jsxs)(eq.A,{spacing:1.5,children:[(0,r.jsxs)(s.default,{children:[(0,r.jsx)(i.A,{variant:"h6",children:"May one of your connected AIs help build this?"}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",children:"If you say yes, choose the AI that should suggest connected tools and check the finished workflow."})]}),"unasked"===A?(0,r.jsxs)(eq.A,{direction:{xs:"column",sm:"row"},spacing:1,children:[(0,r.jsx)(d.A,{variant:"contained",startIcon:(0,r.jsx)(e2.A,{}),onClick:()=>S("assisted"),children:"Yes, help me"}),(0,r.jsx)(d.A,{variant:"outlined",onClick:()=>S("manual"),children:"No, I’ll build it myself"})]}):(0,r.jsxs)(eq.A,{direction:{xs:"column",sm:"row"},spacing:1.5,alignItems:{sm:"center"},children:[(0,r.jsx)(M.A,{color:"assisted"===A?"primary":"default",label:"assisted"===A?"AI help is on":"Manual setup"}),"assisted"===A&&T&&(0,r.jsxs)(e3.A,{size:"small",sx:{minWidth:260},children:[(0,r.jsx)(e9.A,{id:"guided-helper-model-label",children:"AI helper"}),(0,r.jsx)(e6.A,{labelId:"guided-helper-model-label",label:"AI helper",value:null!=C?C:"",onChange:e=>T(String(e.target.value)),children:j.map(e=>(0,r.jsx)(z.A,{value:e.id,children:e.displayName||e.name},e.id))})]}),(0,r.jsx)(d.A,{size:"small",onClick:()=>S("assisted"===A?"manual":"assisted"),children:"assisted"===A?"Turn off":"Turn on AI help"})]})]})}),(0,r.jsx)(I.A,{elevation:0,sx:{p:{xs:2,sm:2.5},border:1,borderColor:E?"success.main":"divider",borderRadius:4,bgcolor:"background.paper"},children:(0,r.jsxs)(eq.A,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[(0,r.jsx)(tl,{complete:E,children:"1"}),(0,r.jsxs)(s.default,{sx:{flex:1,minWidth:0},children:[(0,r.jsx)(i.A,{variant:"h6",children:"Give your agent a name"}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"Pick something you will recognize later, like “Trip planner” or “Weekly report helper.”"}),(0,r.jsx)(b.A,{fullWidth:!0,size:"small",label:"Agent name",value:a,error:!!c,helperText:null!=c?c:E?"Looks good.":"Use a short, memorable name.",onChange:e=>u(e.target.value),onFocus:e=>{/^(?:NewFlow\d*|Untitled (?:assistant|agent)(?: \d+)?)$/i.test(e.currentTarget.value)&&e.currentTarget.select()}})]})]})}),(0,r.jsx)(I.A,{elevation:0,sx:{p:{xs:2,sm:2.5},border:1,borderColor:R.length>0?"success.main":"divider",borderRadius:4,bgcolor:"background.paper"},children:(0,r.jsxs)(eq.A,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[(0,r.jsx)(tl,{complete:R.length>0,children:"2"}),(0,r.jsxs)(s.default,{sx:{flex:1,minWidth:0},children:[(0,r.jsx)(i.A,{variant:"h6",children:R.length?"Add another step":"What is the goal of this workflow?"}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",children:R.length?"Write it the same way you would explain the next job to a helpful person.":"This goal becomes the first AI step’s prompt, exactly as if you added that step yourself."}),x&&(0,r.jsx)(m.A,{severity:"info",action:(0,r.jsx)(d.A,{color:"inherit",size:"small",onClick:y,children:"Open expert view"}),sx:{mt:1.5},children:"This agent uses branches or expert settings. You can review it here and make structural changes in Expert view."}),(0,r.jsxs)(eq.A,{spacing:1,sx:{mt:2},children:[(0,r.jsxs)(s.default,{sx:{px:1.5,py:1,borderRadius:3,color:"text.secondary",bgcolor:e=>(0,J.X4)(e.palette.primary.main,.055),border:1,borderColor:"divider"},children:[(0,r.jsx)(i.A,{variant:"caption",fontWeight:800,color:"primary.main",children:"WHEN"}),(0,r.jsx)(i.A,{variant:"body2",fontWeight:700,children:"Someone asks this agent for help"})]}),R.map((e,t)=>(0,r.jsxs)(o.Fragment,{children:[(0,r.jsx)(te,{"aria-hidden":"true",sx:{alignSelf:"center",color:"text.disabled",fontSize:20}}),(0,r.jsx)(e8.A,{onClick:()=>p(e.id),sx:{display:"block",width:"100%",borderRadius:3,textAlign:"left"},children:(0,r.jsx)(I.A,{elevation:0,sx:{width:"100%",p:1.5,border:1,borderColor:l===e.id?"primary.main":"divider",borderRadius:3,bgcolor:l===e.id?e=>(0,J.X4)(e.palette.primary.main,.1):"background.default",boxShadow:l===e.id?e=>"0 0 0 3px ".concat((0,J.X4)(e.palette.primary.main,.12)):"none"},children:(0,r.jsxs)(eq.A,{direction:"row",spacing:1.25,alignItems:"flex-start",children:[(0,r.jsx)(s.default,{sx:{display:"grid",width:30,height:30,flexShrink:0,placeItems:"center",borderRadius:2,color:"primary.contrastText",bgcolor:"primary.main",fontWeight:850},children:t+1}),(0,r.jsxs)(s.default,{sx:{minWidth:0,flex:1},children:[(0,r.jsx)(i.A,{variant:"overline",color:"primary.main",children:(e=>"subflow"===e?"Another agent":"signal"===e?"Notification":"AI step")(e.data.type)}),(0,r.jsx)(i.A,{variant:"subtitle1",fontWeight:800,children:(e=>{var t,n;let r=null==(t=e.data.label)?void 0:t.trim();return!r||to.has(r)?null!=(n=tr[e.data.type])?n:"Agent step":r})(e)}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mt:.35,display:"-webkit-box",overflow:"hidden",WebkitBoxOrient:"vertical",WebkitLineClamp:2},children:(e=>{var t,n,r;let o=String(null!=(r=null==(t=e.data.properties)?void 0:t.promptTemplate)?r:"").trim();return o||((null==(n=e.data.description)?void 0:n.trim())?e.data.description.trim():"subflow"===e.data.type?"Hand this part of the job to another saved agent.":"signal"===e.data.type?"Let another automation know that this point was reached.":"Click this step to describe the result you want.")})(e)})]}),(0,r.jsx)(k.A,{color:"action",fontSize:"small"})]})})})]},e.id)),(0,r.jsx)(te,{"aria-hidden":"true",sx:{alignSelf:"center",color:"text.disabled",fontSize:20}}),(0,r.jsxs)(s.default,{sx:{px:1.5,py:1,borderRadius:3,color:"text.secondary",bgcolor:e=>(0,J.X4)(e.palette.success.main,.055),border:1,borderColor:"divider"},children:[(0,r.jsx)(i.A,{variant:"caption",fontWeight:800,color:"success.main",children:"THEN"}),(0,r.jsx)(i.A,{variant:"body2",fontWeight:700,children:"Send the finished answer back"})]})]}),(0,r.jsxs)(eq.A,{direction:{xs:"column",sm:"row"},spacing:1,alignItems:"stretch",sx:{mt:2},children:[(0,r.jsx)(b.A,{fullWidth:!0,multiline:!0,minRows:2,maxRows:5,label:R.length?"Add another thing it should do":"Workflow goal",placeholder:"Example: Read my notes, find the important points, and explain them simply.",value:F,disabled:x,onChange:e=>P(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&W&&(e.preventDefault(),D())}}),(0,r.jsx)(d.A,{variant:"contained",startIcon:(0,r.jsx)(e7,{}),disabled:!W,onClick:D,sx:{minWidth:{sm:150}},children:R.length?"Add this step":"Create goal step"})]})]})]})}),(0,r.jsx)(I.A,{elevation:0,sx:{p:{xs:2,sm:2.5},border:1,borderColor:L?"primary.main":"divider",borderRadius:4,bgcolor:e=>(0,J.X4)(e.palette.primary.main,L?.075:.025)},children:(0,r.jsxs)(eq.A,{direction:{xs:"column",sm:"row"},spacing:1.5,alignItems:{sm:"center"},children:[(0,r.jsx)(tl,{children:"3"}),(0,r.jsxs)(s.default,{sx:{flex:1},children:[(0,r.jsx)(i.A,{variant:"h6",children:"Try it with a real question"}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",children:"FLUJO will save your changes, then open a normal chat so you can see how it feels."}),w&&R.some(e=>"process"===e.data.type)&&(0,r.jsx)(m.A,{severity:"warning",sx:{mt:1},children:"This step still needs an AI. Select the step, choose More options, and connect the AI you want to use."})]}),f&&(0,r.jsxs)(eq.A,{spacing:1,children:[N&&"assisted"===A&&(0,r.jsx)(d.A,{variant:"outlined",startIcon:(0,r.jsx)(e2.A,{}),disabled:0===R.length,onClick:N,children:"Check setup with AI"}),(0,r.jsx)(d.A,{size:"large",variant:"contained",startIcon:(0,r.jsx)(tn,{}),disabled:!L,onClick:f,children:g?"Saving…":"Try my agent"})]})]})})]})]})})};var ts=n(22822);let ti=(0,y.A)((0,r.jsx)("path",{d:"M12.09 2.91C10.08.9 7.07.49 4.65 1.67L8.28 5.3c.39.39.39 1.02 0 1.41L6.69 8.3c-.39.4-1.02.4-1.41 0L1.65 4.67C.48 7.1.89 10.09 2.9 12.1c1.86 1.86 4.58 2.35 6.89 1.48l7.96 7.96c1.03 1.03 2.69 1.03 3.71 0 1.03-1.03 1.03-2.69 0-3.71L13.54 9.9c.92-2.34.44-5.1-1.45-6.99"}),"BuildRounded"),td=(0,y.A)((0,r.jsx)("path",{fillRule:"evenodd",d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2M9 17H6c-.55 0-1-.45-1-1s.45-1 1-1h3c.55 0 1 .45 1 1s-.45 1-1 1m0-4H6c-.55 0-1-.45-1-1s.45-1 1-1h3c.55 0 1 .45 1 1s-.45 1-1 1m0-4H6c-.55 0-1-.45-1-1s.45-1 1-1h3c.55 0 1 .45 1 1s-.45 1-1 1m9.7 2.12-3.17 3.17c-.39.39-1.03.39-1.42 0l-1.41-1.42a.996.996 0 0 1 0-1.41c.39-.39 1.02-.39 1.41 0l.71.71 2.47-2.47c.39-.39 1.02-.39 1.41 0l.01.01c.38.39.38 1.03-.01 1.41"}),"FactCheckRounded");function tc(e){let{open:t,flow:n,relatedFlows:l=[],nodeId:a,modelId:c,models:u=[],onApply:p,onApplyRelatedFlows:h,onClose:v}=e,[b,y]=(0,o.useState)("suggesting"),[j,A]=(0,o.useState)(null),[C,S]=(0,o.useState)(new Set),[k,T]=(0,o.useState)(null),[P,R]=(0,o.useState)(n),[E,W]=(0,o.useState)(null!=c?c:""),[L,D]=(0,o.useState)(null),B=async e=>{y("checking"),D(null);try{let t=await H.g.checkPlausibility({flow:e,relatedFlows:l,modelId:E||c||void 0,intendedContext:"chat"});T(t),y("plausibility")}catch(e){D(e instanceof Error?e.message:"Could not check this flow."),y("plausibility")}};(0,o.useEffect)(()=>{if(!t)return;let e=!0;return(R(n),A(null),T(null),S(new Set),W(null!=c?c:""),D(null),a)?c?(y("suggesting"),H.g.suggestToolsForStep({flow:n,nodeId:a,modelId:c,goal:n.description}).then(t=>{e&&(A(t),S(new Set(t.suggestions.map(e=>"".concat(e.server,"\0").concat(e.tool)))),0===t.suggestions.length?B(n):y("tools"))}).catch(t=>{e&&(D(t instanceof Error?t.message:"Could not suggest tools."),y("tools"))}),()=>{e=!1}):(y("tools"),()=>{e=!1}):(B(n),()=>{e=!1})},[t,a,c]);let O=(0,o.useMemo)(()=>{var e;return null!=(e=null==j?void 0:j.suggestions.filter(e=>C.has("".concat(e.server,"\0").concat(e.tool))))?e:[]},[C,j]),V=(0,o.useMemo)(()=>{if(!k)return 0;let e=new Set([n.id,...l.map(e=>e.id)]);return k.patches.filter(t=>e.has(t.flowId)).length},[n.id,k,l]),U=async()=>{if(a&&E){y("suggesting"),D(null);try{let e=await H.g.suggestToolsForStep({flow:P,nodeId:a,modelId:E,goal:P.description});A(e),S(new Set(e.suggestions.map(e=>"".concat(e.server,"\0").concat(e.tool)))),0===e.suggestions.length?await B(P):y("tools")}catch(e){D(e instanceof Error?e.message:"Could not suggest tools."),y("tools")}}},G=async()=>{if(a&&j){y("suggesting"),D(null);try{let e=await H.g.applyToolsToStep({flow:P,nodeId:a,selections:O,proposedPrompt:j.proposedPrompt});R(e),p(e),await B(e)}catch(e){D(e instanceof Error?e.message:"Could not connect the approved tools."),y("tools")}}},K="suggesting"===b||"checking"===b;return(0,r.jsxs)(f.A,{open:t,onClose:K?void 0:v,fullWidth:!0,maxWidth:"md",children:[(0,r.jsxs)(g.A,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(e2.A,{color:"primary"}),"plausibility"===b||"checking"===b?"Plausibility review":"Connected tool suggestions"]}),(0,r.jsxs)(x.A,{dividers:!0,children:[K&&(0,r.jsxs)(eq.A,{alignItems:"center",spacing:1.5,sx:{py:5},children:[(0,r.jsx)(N.default,{}),(0,r.jsx)(i.A,{color:"text.secondary",children:"suggesting"===b?"Finding useful connected tools…":"Checking the complete flow and how it is called…"})]}),L&&!K&&(0,r.jsx)(m.A,{severity:"error",sx:{mb:2},children:L}),"tools"===b&&!j&&(0,r.jsx)(eq.A,{spacing:2,children:0===u.length?(0,r.jsx)(m.A,{severity:"warning",children:"Connect an AI model before asking for tool suggestions."}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(m.A,{severity:"info",children:"Choose which connected AI should review this step. FLUJO will not pick one silently."}),(0,r.jsxs)(e3.A,{fullWidth:!0,size:"small",children:[(0,r.jsx)(e9.A,{id:"assistance-model-label",children:"AI helper"}),(0,r.jsx)(e6.A,{labelId:"assistance-model-label",label:"AI helper",value:E,onChange:e=>W(String(e.target.value)),children:u.map(e=>(0,r.jsx)(z.A,{value:e.id,children:e.displayName||e.name},e.id))})]})]})}),"tools"===b&&j&&(0,r.jsxs)(eq.A,{spacing:1.5,children:[(0,r.jsx)(m.A,{severity:"info",children:"Nothing changes until you approve. FLUJO will connect only the checked tools and add their pills to this step's prompt."}),0===j.suggestions.length?(0,r.jsx)(m.A,{severity:"success",children:"No connected MCP tool is needed for this step."}):j.suggestions.map(e=>{let t="".concat(e.server,"\0").concat(e.tool);return(0,r.jsx)(I.A,{variant:"outlined",sx:{p:1.25},children:(0,r.jsx)(F.A,{control:(0,r.jsx)(ts.A,{checked:C.has(t),onChange:e=>{S(n=>{let r=new Set(n);return e.target.checked?r.add(t):r.delete(t),r})}}),label:(0,r.jsxs)(s.default,{children:[(0,r.jsxs)(eq.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,r.jsx)(M.A,{size:"small",label:e.server}),(0,r.jsx)(i.A,{fontWeight:800,children:e.tool})]}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:e.reason})]})})},t)}),(0,r.jsxs)(s.default,{children:[(0,r.jsx)(i.A,{variant:"subtitle2",children:"Prompt preview"}),(0,r.jsx)(I.A,{variant:"outlined",sx:{p:1.25,mt:.5,whiteSpace:"pre-wrap",maxHeight:220,overflow:"auto"},children:(0,r.jsx)(i.A,{variant:"body2",component:"pre",sx:{m:0,fontFamily:"inherit",whiteSpace:"pre-wrap"},children:j.proposedPrompt})})]})]}),"plausibility"===b&&k&&(0,r.jsxs)(eq.A,{spacing:1.5,children:[(0,r.jsx)(eq.A,{direction:"row",gap:1,flexWrap:"wrap",children:k.contexts.map(e=>{var t;return(0,r.jsx)(M.A,{label:e.label},"".concat(e.kind,"-").concat(null!=(t=e.sourceId)?t:""))})}),0===k.issues.length?(0,r.jsx)(m.A,{severity:"success",children:"The flow is plausible in its current invocation context."}):k.issues.map((e,t)=>{var o,l;let a=k.repairedFlows.find(t=>t.id===e.flowId);return(0,r.jsxs)(m.A,{severity:e.severity,children:[a&&a.id!==n.id?"".concat(a.name,": "):"",e.message]},"".concat(e.code,"-").concat(null!=(o=e.flowId)?o:"","-").concat(null!=(l=e.nodeId)?l:"","-").concat(t))}),V>0&&(0,r.jsxs)(m.A,{severity:"info",children:[V," recommended input/output repair",1===V?"":"s"," can be applied to this draft."]}),k.patches.length>V&&(0,r.jsxs)(m.A,{severity:"warning",children:[k.patches.length-V," repair",k.patches.length-V==1?"":"s"," belong to saved helper flows. Open those helpers separately to apply them."]})]})]}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:v,disabled:K,children:"Close"}),"tools"===b&&!j&&u.length>0&&(0,r.jsx)(d.A,{variant:"contained",disabled:!E,onClick:()=>void U(),children:"Suggest connected tools"}),"tools"===b&&j&&0===j.suggestions.length&&(0,r.jsx)(d.A,{startIcon:(0,r.jsx)(td,{}),onClick:()=>void B(P),children:"Check whole flow"}),"tools"===b&&j&&j.suggestions.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.A,{onClick:()=>void B(P),children:"Skip tools"}),(0,r.jsxs)(d.A,{variant:"contained",startIcon:(0,r.jsx)(ti,{}),disabled:0===O.length,onClick:()=>void G(),children:["Connect ",O.length," and fix prompt"]})]}),"plausibility"===b&&k&&V>0?(0,r.jsx)(d.A,{variant:"contained",startIcon:(0,r.jsx)(td,{}),onClick:()=>{p(k.repairedFlow);let e=new Map(k.repairedFlows.map(e=>[e.id,e]));null==h||h(l.map(t=>{var n;return null!=(n=e.get(t.id))?n:t})),v()},children:"Apply recommended settings"}):null]})]})}var tu=n(77073),tp=n(90880);function th(e){let{currentLabel:t,nameIsCustom:n,defaultLabel:r,previousAutoLabel:o,nextAutoLabel:l}=e;return!0===n?t&&t.length>0?t:l:!t||0===t.length||t===r||void 0!==o&&o.length>0&&t===o?l:t}let tm=(0,W.h)("components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/hooks/useModelManagement.ts");var tf=n(9898);let tg=(0,W.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/hooks/useServerConnection");function tx(e,t){let n=e.replace(/\s+/g," ").trim();if(n.length<=t)return n;let r=n.slice(0,t),o=r.lastIndexOf(" ");return"".concat((o>.6*t?r.slice(0,o):r).trimEnd(),"…")}let tv=(0,W.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/hooks/useHandoffTools"),tb=e=>{let{nodeData:t,setNodeData:n}=e;return t?(0,r.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",height:"100%",pr:2},children:[(0,r.jsx)(i.A,{variant:"h6",gutterBottom:!0,children:"Node Configuration"}),(0,r.jsx)(b.A,{fullWidth:!0,label:"Node Label",value:t.label||"",onChange:e=>n(t=>({...t,label:e.target.value,properties:{...null==t?void 0:t.properties,nameIsCustom:!0}})),margin:"normal"}),(0,r.jsx)(b.A,{fullWidth:!0,label:"Description",value:t.description||"",onChange:e=>n({...t,description:e.target.value}),margin:"normal",multiline:!0,rows:2,helperText:"This description will be displayed on the node"})]}):null};var tw=n(18369),ty=n(12857),tj=n(99162),tA=n(61267),tC=n(68503);let tS=e=>{let{isLoadingModels:t,loadError:n,models:o,selectedModelId:l,handleModelSelect:a,isModelBound:c,handleUnbindModel:u}=e,p=(0,tC.E)("models",o),h=e=>({key:e.id,content:(e=>(0,r.jsx)(tA.A,{model:e,selectable:!0,selected:l===e.id,onSelect:a}))(e)}),m=p.items.map(h),f=p.groups?p.groups.map(e=>({...e,items:e.items.map(h)})):null;return(0,r.jsxs)(s.default,{sx:{mt:4},children:[(0,r.jsx)(i.A,{variant:"subtitle1",gutterBottom:!0,children:"Bind to Model"}),(0,r.jsx)(s.default,{role:"radiogroup","aria-label":"Bind to model",children:(0,r.jsx)(tj.A,{isLoading:t,error:n,loadingMessage:"Loading models...",emptyMessage:"No models available. Add some in the Model Manager.",searchable:!0,searchPlaceholder:"Search models…",searchTerm:p.searchTerm,onSearchChange:p.setSearchTerm,columns:{xs:12,sm:6},items:m,groups:f,collapsedKeys:p.collapsedKeys,onToggleGroup:p.toggleGroup})}),!t&&!n&&o.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tw.A,{children:l?"This node will use the selected model for processing.":"Select a model to bind this node to."}),c&&(0,r.jsx)(s.default,{sx:{mt:2,display:"flex",justifyContent:"flex-end"},children:(0,r.jsx)(d.A,{startIcon:(0,r.jsx)(ty.A,{}),onClick:u,color:"primary",variant:"outlined",size:"small",children:"Unbind Model"})})]})]})};var tk=n(66177),tT=n(29767),tI=n(84578),tM=n(76530),tN=n(25541),tF=n(51611),tP=n(89218),tR=n(63186),tE=n(62962),tz=n(96362),tW=n(95906);let tL=(0,W.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/ServerTools"),tD=e=>{var t,n,l;let{isLoadingServers:a,connectedMcpNodes:c,availableServers:h,onConnectMcpServer:m,serverToolsMap:f,serverStatuses:g,isLoadingTools:x,handleSelectToolServer:v,handleInsertToolBinding:w,selectedToolServerNodeId:y,selectedNodeId:j,isLoadingSelectedServerTools:C,promptBuilderRef:S,handleRetryServer:k,handleRestartServer:T}=e,M=null!=(l=null!=y?y:null==(t=c[0])?void 0:t.nodeId)?l:null,[F,P]=(0,o.useState)({}),[R,E]=(0,o.useState)(!1),z=(null!=h?h:[]).filter(e=>!c.some(t=>t.serverName===e.name)),W=!!m&&z.length>0,L=(0,tC.E)("mcp",z),D=e=>({key:e.name,content:(e=>(0,r.jsx)(tW.A,{name:e.name,status:e.status||"disconnected",path:e.rootPath||"",enabled:!e.disabled,transport:e.transport||"stdio",pickerMode:!0,onClick:()=>{var t;return t=e.name,void(E(!1),null==m||m(t))}}))(e)}),H=L.items.map(D),B=L.groups?L.groups.map(e=>({...e,items:e.items.map(D)})):null,O=(0,r.jsx)(tz.A,{open:R,onClose:()=>E(!1),title:"Connect an MCP server",description:"Pick a server to add to this flow and wire to this Process node.",emptyMessage:"No more servers to connect.",searchable:!0,searchPlaceholder:"Search servers…",searchTerm:L.searchTerm,onSearchChange:L.setSearchTerm,columns:{xs:12,sm:6},items:H,groups:B,collapsedKeys:L.collapsedKeys,onToggleGroup:L.toggleGroup}),[V,U]=(0,o.useState)(""),[G,K]=(0,o.useState)({}),$=(e,t,n)=>{if(e!==M){tL.debug("Node tab not selected, selecting node first",{selectedNodeId:e,serverName:t,toolName:n}),Y(e);return}t&&n?(tL.debug("Inserting tool binding",{serverName:t,toolName:n}),w(t,n)):tL.warn("Cannot insert tool binding, server or tool name is undefined",{serverName:t,toolName:n})},_=e=>{try{let t=c.find(t=>t.nodeId===e);if(!t)return tL.warn("Could not find connected MCP node with ID ".concat(e)),[];let n=t.enabledTools||[];return tL.debug("Enabled tools for node ".concat(e,": ").concat(JSON.stringify(n))),Array.isArray(n)?n:[]}catch(t){return tL.error("Error getting enabled tools for node ".concat(e,":"),t),[]}},X=(e,t,n)=>{try{if(!n||!Array.isArray(n))return tL.warn("Tools array is not available or not an array for server ".concat(t)),[];let r=_(e),o=n;if(r.length>0?o=n.filter(e=>e&&e.name&&r.includes(e.name)):(tL.debug("No tools explicitly enabled for node ".concat(e,", showing none.")),o=[]),V.trim()){let e=V.toLowerCase().trim();o=o.filter(t=>t.name&&t.name.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e)||t.inputSchema&&JSON.stringify(t.inputSchema).toLowerCase().includes(e))}return o}catch(r){return tL.error("Error filtering tools for node ".concat(e," (server ").concat(t,"):"),r),n||[]}},Y=e=>{v(e)},q=async(e,t)=>{t.stopPropagation(),tL.debug("Retry button clicked for server: ".concat(e)),P(t=>({...t,[e]:!0}));try{k&&await k(e)}finally{setTimeout(()=>{P(t=>({...t,[e]:!1}))},500)}},J=async(e,t)=>{t.stopPropagation(),tL.debug("Restart button clicked for server: ".concat(e)),P(t=>({...t,[e]:!0}));try{T&&await T(e)}finally{setTimeout(()=>{P(t=>({...t,[e]:!1}))},500)}};(0,o.useEffect)(()=>{c.length>0&&!y&&v(c[0].nodeId)},[c,y,v]);let Q=c.find(e=>e.nodeId===M),ee=null==Q?void 0:Q.serverName;return(0,r.jsxs)(s.default,{sx:{mt:4,display:"flex",flexDirection:"column",height:"100%"},children:[(0,r.jsx)(i.A,{variant:"subtitle1",gutterBottom:!0,children:"Connected MCP Servers and Tools"}),a?(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(N.default,{size:20}),(0,r.jsx)(i.A,{color:"text.secondary",children:"Loading connected MCP nodes..."})]}):0===c.length?(0,r.jsxs)(s.default,{sx:{p:2,border:"1px dashed rgba(0, 0, 0, 0.12)",borderRadius:1},children:[(0,r.jsx)(i.A,{color:"text.secondary",align:"center",children:"No MCP nodes connected to this Process node."}),(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",align:"center",display:"block",sx:{mt:1},children:W?"Pick a server below — the MCP node is added to the flow and wired up for you.":"Connect MCP nodes to this Process node using the side handles to access their tools."}),W&&(0,r.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",mt:2},children:(0,r.jsx)(d.A,{variant:"contained",size:"small",startIcon:(0,r.jsx)(A.A,{}),onClick:()=>E(!0),children:"Connect MCP Server"})}),O]}):(0,r.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",flexGrow:1,height:"calc(100% - 40px)"},children:[(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",mb:2,borderBottom:1,borderColor:"divider"},children:[(0,r.jsx)(eJ.A,{value:M||(null==(n=c[0])?void 0:n.nodeId)||"",onChange:(e,t)=>Y(t),variant:"scrollable",scrollButtons:"auto",sx:{flexGrow:1},children:c.map(e=>{if(!e||!e.nodeId||!e.serverName)return tL.warn("Skipping invalid MCP node in tabs:",e),null;let t=e.serverName,n=e.nodeId,o=e.status;F[t],x[t];let l=f[t]||[],a=_(n);return X(n,t,l).length,(0,r.jsx)(eZ.A,{value:n,label:(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(i.A,{variant:"body2",sx:{color:"connected"===o?"success.main":"error"===o?"error.main":"text.secondary"},children:t}),a.length>0&&(0,r.jsx)(tk.A,{badgeContent:a.length,color:"primary",sx:{ml:1}})]}),sx:{textTransform:"none",minHeight:"48px",opacity:"connected"!==o?.7:1}},n)})}),W&&(0,r.jsx)(p.A,{title:"Connect another MCP server",children:(0,r.jsx)(u.A,{size:"small",onClick:()=>E(!0),sx:{ml:1},children:(0,r.jsx)(A.A,{fontSize:"small"})})}),O]}),Q&&ee&&(0,r.jsxs)(s.default,{sx:{display:"flex",justifyContent:"flex-end",mb:2},children:[(0,r.jsx)(p.A,{title:"Retry connection for ".concat(ee),children:(0,r.jsx)("span",{children:(0,r.jsx)(u.A,{size:"small",onClick:e=>q(ee,e),disabled:F[ee]||x[ee],children:F[ee]?(0,r.jsx)(N.default,{size:16}):(0,r.jsx)(tM.A,{fontSize:"small"})})})}),"connected"===Q.status&&T&&(0,r.jsx)(p.A,{title:"Restart server ".concat(ee),children:(0,r.jsx)("span",{children:(0,r.jsx)(u.A,{size:"small",onClick:e=>J(ee,e),disabled:F[ee],sx:{ml:1},children:(0,r.jsx)(tN.A,{fontSize:"small"})})})})]}),(0,r.jsx)(b.A,{placeholder:"Search enabled tools...",variant:"outlined",size:"small",fullWidth:!0,value:V,onChange:e=>U(e.target.value),sx:{mb:2},InputProps:{startAdornment:(0,r.jsx)(Z.A,{position:"start",children:(0,r.jsx)(tF.A,{fontSize:"small"})})}}),(0,r.jsx)(I.A,{variant:"outlined",sx:{flexGrow:1,overflow:"auto",p:0,height:"calc(100% - 140px)"},children:Q&&ee&&(()=>{let e=Q.nodeId,t=Q.serverName;if("connected"!==Q.status)return(0,r.jsx)(s.default,{sx:{p:2,textAlign:"center"},children:(0,r.jsxs)(i.A,{color:"text.secondary",children:["Server '",t,"' is not connected. Connect to view tools."]})},e);if(x[t])return(0,r.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:2},children:(0,r.jsx)(N.default,{size:24})},e);let n=f[t]||[],o=X(e,t,n);if(0===o.length){let t=_(e).length;return(0,r.jsx)(s.default,{sx:{p:2,textAlign:"center"},children:(0,r.jsx)(i.A,{color:"text.secondary",children:V.trim()?'No enabled tools match "'.concat(V,'" for this node.'):0===t?"No tools are enabled for this node instance. Enable tools in the MCP Node properties.":"No tools available or enabled for this node instance."})},e)}return(0,r.jsx)(eb.A,{disablePadding:!0,children:o.map(n=>{let o,l=(o=n.name,"".concat(e,"::").concat(o)),a=!!G[l],d=n.description||"No description available",c=(e=>{var t;let n=Object.keys(null!=(t=null==e?void 0:e.properties)?t:{}).length;if(0===n)return"No parameters";let r=Array.isArray(null==e?void 0:e.required)?e.required.length:0;return"".concat(n," parameter").concat(1===n?"":"s").concat(r>0?" \xb7 ".concat(r," required"):"")})(n.inputSchema);return(0,r.jsx)(tT.A,{variant:"outlined",role:"button",tabIndex:0,"aria-label":"Add ".concat(n.name," from ").concat(t," to prompt"),onClick:()=>$(e,t,n.name),onKeyDown:r=>{r.target===r.currentTarget&&("Enter"===r.key||" "===r.key)&&(r.preventDefault(),$(e,t,n.name))},sx:{mb:1,mx:1,mt:1,cursor:"pointer","&:hover":{boxShadow:1,bgcolor:"action.hover"},"&:focus-visible":{outline:"2px solid",outlineColor:"primary.main",outlineOffset:1}},children:(0,r.jsxs)(tI.A,{sx:{p:1.25,"&:last-child":{pb:1.25}},children:[(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"flex-start",gap:1},children:[(0,r.jsxs)(s.default,{sx:{flexGrow:1,minWidth:0},children:[(0,r.jsxs)(i.A,{variant:"subtitle2",component:"div",sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(tP.A,{fontSize:"small",sx:{mr:1,color:"primary.main",flexShrink:0}}),(0,r.jsx)(s.default,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.name})]}),(0,r.jsx)(p.A,{title:d,describeChild:!0,placement:"top-start",children:(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",tabIndex:0,sx:{mt:.5,display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,overflow:"hidden"},children:d})}),(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:.5},children:c})]}),(0,r.jsx)(p.A,{title:"".concat(a?"Collapse":"Expand"," ").concat(n.name," details"),children:(0,r.jsx)(u.A,{size:"small","aria-label":"".concat(a?"Collapse":"Expand"," ").concat(n.name," details"),"aria-expanded":a,"aria-controls":"".concat(l,"-details"),onClick:e=>((e,t)=>{t.stopPropagation(),K(t=>({...t,[e]:!t[e]}))})(l,e),children:a?(0,r.jsx)(tE.A,{}):(0,r.jsx)(tR.A,{})})})]}),a&&(0,r.jsxs)(s.default,{id:"".concat(l,"-details"),sx:{mt:1,pt:1,borderTop:1,borderColor:"divider"},onClick:e=>e.stopPropagation(),children:[(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-wrap"},children:d}),n.inputSchema&&(e=>e&&e.properties?(0,r.jsxs)(s.default,{sx:{mt:1},children:[(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",sx:{fontWeight:"medium"},children:"Parameters:"}),(0,r.jsx)(s.default,{sx:{pl:1,mt:.5},children:Object.entries(e.properties).map(t=>{var n;let[o,l]=t;return(0,r.jsxs)(s.default,{sx:{mb:.5},children:[(0,r.jsxs)(i.A,{variant:"caption",component:"span",sx:{fontWeight:"medium"},children:[o,(null==(n=e.required)?void 0:n.includes(o))&&(0,r.jsx)(i.A,{variant:"caption",component:"span",color:"error.main",children:" *"}),": "]}),(0,r.jsx)(i.A,{variant:"caption",component:"span",color:"text.secondary",children:l.description||l.type||"No description"})]},o)})})]}):null)(n.inputSchema)]})]})},n.name)})},e)})()})]})]})},tH=(0,W.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/ServerResources"),tB=e=>{let{primary:t,secondary:n,chip:o,onClick:l}=e;return(0,r.jsx)(tT.A,{variant:"outlined",onClick:l,sx:{mb:1,mx:1,mt:1,cursor:"pointer","&:hover":{boxShadow:1,bgcolor:"action.hover"}},children:(0,r.jsx)(tI.A,{sx:{p:2,"&:last-child":{pb:2}},children:(0,r.jsxs)(s.default,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[(0,r.jsxs)(s.default,{sx:{width:"100%"},children:[(0,r.jsxs)(i.A,{variant:"subtitle2",component:"div",sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(en.A,{fontSize:"small",sx:{mr:1,color:"primary.main"}}),t]}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mt:.5,wordBreak:"break-all"},children:n})]}),o&&(0,r.jsx)(M.A,{size:"small",label:o,sx:{ml:1,flexShrink:0}})]})})})},tO=e=>{var t;let{connectedMcpNodes:n,handleInsertResourceBinding:l,promptBuilderRef:a}=e,[d,c]=(0,o.useState)(null),[u,p]=(0,o.useState)([]),[h,f]=(0,o.useState)([]),[g,x]=(0,o.useState)(!1),[v,w]=(0,o.useState)(),[y,j]=(0,o.useState)(""),A=n.find(e=>e.nodeId===d),C=null==A?void 0:A.serverName;(0,o.useEffect)(()=>{n.length>0&&!d&&c(n[0].nodeId)},[n,d]);let S=(0,o.useCallback)(async e=>{x(!0),w(void 0);try{let t=await B.S.listServerResources(e);p(t.resources||[]),f(t.resourceTemplates||[]),w(t.error)}catch(t){tH.warn("Failed to load resources for ".concat(e),t),w(t instanceof Error?t.message:"Failed to load resources")}finally{x(!1)}},[]);(0,o.useEffect)(()=>{C?S(C):(p([]),f([]))},[C,S]);let k=e=>e.toLowerCase().includes(y.toLowerCase().trim()),T=y.trim()?u.filter(e=>k(e.name||"")||k(e.uri)||k(e.description||"")):u,M=y.trim()?h.filter(e=>k(e.name||"")||k(e.uriTemplate)||k(e.description||"")):h,F=e=>{C&&e&&l(C,e)};return(0,r.jsxs)(s.default,{sx:{mt:4,display:"flex",flexDirection:"column",height:"100%"},children:[(0,r.jsx)(i.A,{variant:"subtitle1",gutterBottom:!0,children:"Give this step access to…"}),(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",sx:{mb:1},children:"Pick a resource to insert. Its contents are read and placed into the prompt each time the step runs."}),0===n.length?(0,r.jsxs)(s.default,{sx:{p:2,border:"1px dashed rgba(0, 0, 0, 0.12)",borderRadius:1},children:[(0,r.jsx)(i.A,{color:"text.secondary",align:"center",children:"No MCP nodes connected to this Process node."}),(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",align:"center",display:"block",sx:{mt:1},children:"Connect MCP nodes using the side handles to access their resources."})]}):(0,r.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",flexGrow:1,height:"calc(100% - 40px)"},children:[(0,r.jsx)(eJ.A,{value:d||(null==(t=n[0])?void 0:t.nodeId)||"",onChange:(e,t)=>c(t),variant:"scrollable",scrollButtons:"auto",sx:{mb:2,borderBottom:1,borderColor:"divider"},children:n.map(e=>(0,r.jsx)(eZ.A,{value:e.nodeId,label:(0,r.jsx)(i.A,{variant:"body2",sx:{color:"connected"===e.status?"success.main":"error"===e.status?"error.main":"text.secondary"},children:e.serverName}),sx:{textTransform:"none",minHeight:48,opacity:"connected"!==e.status?.7:1}},e.nodeId))}),(0,r.jsx)(b.A,{placeholder:"Search resources…",variant:"outlined",size:"small",fullWidth:!0,value:y,onChange:e=>j(e.target.value),sx:{mb:2},InputProps:{startAdornment:(0,r.jsx)(Z.A,{position:"start",children:(0,r.jsx)(tF.A,{fontSize:"small"})})}}),v&&(0,r.jsx)(m.A,{severity:"warning",sx:{mb:2},children:v}),(0,r.jsx)(I.A,{variant:"outlined",sx:{flexGrow:1,overflow:"auto",p:0,height:"calc(100% - 140px)"},children:A&&"connected"!==A.status?(0,r.jsx)(s.default,{sx:{p:2,textAlign:"center"},children:(0,r.jsxs)(i.A,{color:"text.secondary",children:["Server '",C,"' is not connected. Connect to view resources."]})}):g?(0,r.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:2},children:(0,r.jsx)(N.default,{size:24})}):0===T.length&&0===M.length?(0,r.jsx)(s.default,{sx:{p:2,textAlign:"center"},children:(0,r.jsx)(i.A,{color:"text.secondary",children:y.trim()?'No resources match "'.concat(y,'".'):"This server does not publish any resources."})}):(0,r.jsxs)(eb.A,{disablePadding:!0,children:[T.map(e=>(0,r.jsx)(tB,{primary:e.name||e.uri,secondary:e.description||e.uri,chip:e.mimeType,tooltip:"Add ".concat(e.name||e.uri," to prompt"),onClick:()=>F(e.uri)},e.uri)),M.map(e=>(0,r.jsx)(tB,{primary:e.name||e.uriTemplate,secondary:e.description||e.uriTemplate,chip:"template",tooltip:"Add template ".concat(e.uriTemplate," to prompt (fill in variables, e.g. with ${global:VAR})"),onClick:()=>F(e.uriTemplate)},e.uriTemplate))]})})]})]})},tV=(0,y.A)((0,r.jsx)("path",{d:"M19 12v7H5v-7H3v7c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-7zm-6 .67 2.59-2.58L17 11.5l-5 5-5-5 1.41-1.41L11 12.67V3h2z"}),"SaveAlt"),tU=e=>{let{wiredResources:t,promptBuilderRef:n}=e;return 0===t.length?null:(0,r.jsxs)(s.default,{sx:{mb:3},children:[(0,r.jsx)(i.A,{variant:"subtitle1",gutterBottom:!0,children:"Wired resource nodes"}),(0,r.jsxs)(i.A,{variant:"caption",color:"text.secondary",sx:{mb:1,display:"block"},children:["Resource nodes connected to this step on the canvas. A ",(0,r.jsx)("strong",{children:"produce"})," node is written by the step's ",(0,r.jsx)("code",{children:"write_resource"})," tool; a ",(0,r.jsx)("strong",{children:"consume"})," node's contents are injected into the prompt when the step runs."]}),(0,r.jsx)(eb.A,{disablePadding:!0,children:t.map(e=>(0,r.jsx)(tT.A,{variant:"outlined",sx:{mb:1,mt:1},children:(0,r.jsx)(tI.A,{sx:{p:2,"&:last-child":{pb:2}},children:(0,r.jsxs)(s.default,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[(0,r.jsxs)(s.default,{sx:{width:"100%"},children:[(0,r.jsxs)(i.A,{variant:"subtitle2",component:"div",sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(en.A,{fontSize:"small",sx:{mr:1,color:"primary.main"}}),e.label]}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mt:.5,wordBreak:"break-all"},children:"run"===e.scope?"Temporary Data".concat(e.runName?' "'.concat(e.runName,'"'):" (no name set)"):"MCP resource".concat(e.uri?" ".concat(e.uri):"").concat(e.boundServer?" on ".concat(e.boundServer):"")})]}),(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",flexShrink:0,ml:1,gap:.5},children:["run"===e.scope&&e.runName&&(0,r.jsx)(p.A,{title:"Insert ${res:".concat(e.runName,"} into the prompt"),children:(0,r.jsx)(M.A,{size:"small",icon:(0,r.jsx)(tV,{}),label:"${res:".concat(e.runName,"}"),onClick:()=>(e=>{e&&n.current&&n.current.insertText("${res:".concat(e,"}"))})(e.runName),clickable:!0,sx:{maxWidth:220}})}),(0,r.jsx)(M.A,{size:"small",color:"produce"===e.role?"secondary":"default",label:e.role})]})]})})},"".concat(e.role,"-").concat(e.id)))})]})},tG=(0,W.h)("frontend/components/flow/FlowBuilder/Modals/ProcessNodePropertiesModal/ServerTools/AgentTools"),tK=e=>{let{handoffTools:t,isLoadingHandoffTools:n,handleInsertToolBinding:l,promptBuilderRef:a}=e,[d,c]=(0,o.useState)(""),u=t.filter(e=>{if(!d.trim())return!0;let t=d.toLowerCase().trim();return e.name&&e.name.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)});return(0,r.jsxs)(s.default,{sx:{mt:4,display:"flex",flexDirection:"column",height:"100%"},children:[(0,r.jsx)(i.A,{variant:"subtitle1",gutterBottom:!0,children:"Agent Handoff Tools"}),n?(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(N.default,{size:20}),(0,r.jsx)(i.A,{color:"text.secondary",children:"Loading handoff tools..."})]}):0===t.length?(0,r.jsxs)(s.default,{sx:{p:2,border:"1px dashed rgba(0, 0, 0, 0.12)",borderRadius:1},children:[(0,r.jsx)(i.A,{color:"text.secondary",align:"center",children:"No handoff tools available for this node."}),(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",align:"center",display:"block",sx:{mt:1},children:"Connect this Process node to other nodes to enable handoff tools."})]}):(0,r.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",flexGrow:1,height:"calc(100% - 40px)"},children:[(0,r.jsx)(b.A,{placeholder:"Search handoff tools...",variant:"outlined",size:"small",fullWidth:!0,value:d,onChange:e=>c(e.target.value),sx:{mb:2},InputProps:{startAdornment:(0,r.jsx)(Z.A,{position:"start",children:(0,r.jsx)(tF.A,{fontSize:"small"})})}}),(0,r.jsx)(I.A,{variant:"outlined",sx:{flexGrow:1,overflow:"auto",p:0,height:"calc(100% - 56px)"},children:0===u.length?(0,r.jsx)(s.default,{sx:{p:2,textAlign:"center"},children:(0,r.jsx)(i.A,{color:"text.secondary",children:d.trim()?'No handoff tools match "'.concat(d,'".'):"No handoff tools available."})}):(0,r.jsx)(eb.A,{disablePadding:!0,children:u.map(e=>(0,r.jsxs)(tT.A,{variant:"outlined",onClick:()=>{e.name?(tG.debug("Inserting handoff tool binding",{toolType:"handoff",toolName:e.name}),l("handoff",e.name)):tG.warn("Cannot insert handoff tool binding, tool name is undefined",{toolName:e.name})},sx:{mb:1,mx:1,mt:1,cursor:"pointer",position:"relative",bgcolor:"rgba(0, 0, 0, 0.04)","&:hover":{boxShadow:1,bgcolor:"rgba(0, 0, 0, 0.08)"}},children:[(0,r.jsx)(tI.A,{sx:{p:2,"&:last-child":{pb:2}},children:(0,r.jsx)(s.default,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:(0,r.jsxs)(s.default,{sx:{width:"100%"},children:[(0,r.jsxs)(i.A,{variant:"subtitle2",component:"div",sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(tP.A,{fontSize:"small",sx:{mr:1,color:"text.secondary"}}),e.name]}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:e.description||"No description available"}),e.inputSchema&&(e=>e&&e.properties&&0!==Object.keys(e.properties).length?(0,r.jsxs)(s.default,{sx:{mt:1},children:[(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",sx:{fontWeight:"medium"},children:"Parameters:"}),(0,r.jsx)(s.default,{sx:{pl:1,mt:.5},children:Object.entries(e.properties).map(t=>{var n;let[o,l]=t;return(0,r.jsxs)(s.default,{sx:{mb:.5},children:[(0,r.jsxs)(i.A,{variant:"caption",component:"span",sx:{fontWeight:"medium"},children:[o,(null==(n=e.required)?void 0:n.includes(o))&&(0,r.jsx)(i.A,{variant:"caption",component:"span",color:"error.main",children:" *"}),": "]}),(0,r.jsx)(i.A,{variant:"caption",component:"span",color:"text.secondary",children:l.description||l.type||"No description"}),l.enum&&(0,r.jsx)(s.default,{sx:{pl:2,mt:.5},children:(0,r.jsxs)(i.A,{variant:"caption",color:"text.secondary",children:["Options: ",l.enum.join(", ")]})})]},o)})})]}):(0,r.jsx)(s.default,{sx:{mt:1},children:(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",sx:{fontStyle:"italic"},children:"No parameters required."})}))(e.inputSchema)]})})}),(0,r.jsx)(p.A,{title:"Add ".concat(e.name," handoff tool to prompt"),children:(0,r.jsx)(s.default,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0}})})]},e.name))})})]})]})};var t$=n(95480);let t_=(0,W.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/ProcessNodePropertiesModal/PromptTemplateEditor"),tX=(0,o.forwardRef)((e,t)=>{let{promptTemplate:n,handlePromptChange:l,excludeModelPrompt:a,excludeStartNodePrompt:c,excludeSystemPrompt:u,nodeData:p,flowId:h,suggestions:f}=e,[g,x]=(0,o.useState)(""),[v,b]=(0,o.useState)(!1),[w,y]=(0,o.useState)(null),j=(0,o.useRef)(null);(0,o.useImperativeHandle)(t,()=>({insertText:e=>{j.current&&j.current.insertText(e)},getMode:()=>j.current?j.current.getMode():"raw"}));let A=async()=>{if(t_.debug("fetchRenderedPrompt called with:",{flowId:h,nodeId:null==p?void 0:p.id}),!h||!p||!p.id)return void y("Flow ID or Node ID is missing");b(!0),y(null);try{var e;let t=await fetch("/api/flow/prompt-renderer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:h,nodeId:p.id,options:{renderMode:"rendered",includeConversationHistory:!1,excludeModelPrompt:a,excludeStartNodePrompt:c,excludeSystemPrompt:u}})}),n=await t.json();if(!t.ok)throw Error(n.error||"Failed to render prompt");t_.debug("Rendered prompt received",{promptLength:null==(e=n.prompt)?void 0:e.length}),x(n.prompt+"\n\n [Messages sent by User]")}catch(e){t_.error("Error fetching rendered prompt",e),y(e instanceof Error?e.message:"An unknown error occurred")}finally{b(!1)}};return(0,o.useEffect)(()=>{j.current&&"preview"===j.current.getMode()&&A()},[n,a,c,u,h,null==p?void 0:p.id]),(0,r.jsx)(s.default,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:(0,r.jsx)(t$.A,{ref:j,value:n,onChange:l,label:"",height:"100%",onModeChange:e=>{"preview"===e&&A()},customPreviewRenderer:()=>v?(0,r.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,r.jsx)(N.default,{size:40})}):w?(0,r.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",p:2},children:[(0,r.jsx)(m.A,{severity:"error",sx:{mb:2},action:(0,r.jsx)(d.A,{color:"inherit",size:"small",onClick:A,children:"Retry"}),children:w}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mb:2,textAlign:"center"},children:h?"Check that the flow and node IDs are valid and try again.":"This flow hasn't been saved yet. Save the flow first to enable complete preview."})]}):(0,r.jsxs)(s.default,{sx:{p:2},children:[(0,r.jsx)(i.A,{variant:"subtitle1",gutterBottom:!0,sx:{fontWeight:"medium"},children:"Complete Rendered Prompt"}),(0,r.jsx)(I.A,{elevation:0,sx:{p:2,overflow:"auto",bgcolor:"rgba(0, 0, 0, 0.02)",border:"1px solid rgba(0, 0, 0, 0.1)",borderRadius:1},children:(0,r.jsx)(s.default,{component:"pre",sx:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"monospace",fontSize:"0.875rem",m:0},children:g||"No rendered prompt available. Please check your flow configuration."})})]}),suggestions:f})})});tX.displayName="PromptTemplateEditor";let tY=(0,y.A)((0,r.jsx)("path",{d:"M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9m-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8z"}),"History"),tq=(0,y.A)((0,r.jsx)("path",{d:"M4 9h16v2H4zm0 4h10v2H4z"}),"ShortText"),tJ=(0,y.A)((0,r.jsx)("path",{d:"M3 10h11v2H3zm0-2h11V6H3zm0 8h7v-2H3zm15.01-3.13.71-.71c.39-.39 1.02-.39 1.41 0l.71.71c.39.39.39 1.02 0 1.41l-.71.71zm-.71.71-5.3 5.3V21h2.12l5.3-5.3z"}),"EditNote");var tZ=n(54178);let tQ=(0,y.A)((0,r.jsx)("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2m0 14H6l-2 2V4h16z"}),"ChatBubbleOutline"),t0=e=>{let{selected:t,icon:n,title:o,description:l,onClick:a}=e;return(0,r.jsxs)(s.default,{role:"radio","aria-checked":t,tabIndex:0,onClick:a,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),a())},sx:{flex:1,minWidth:180,position:"relative",p:2,borderRadius:2,border:2,borderColor:t?"primary.main":"divider",bgcolor:t?"action.selected":"background.paper",cursor:"pointer",transition:"border-color 120ms, background-color 120ms","&:hover":{borderColor:t?"primary.main":"text.disabled"},outline:"none","&:focus-visible":{boxShadow:e=>"0 0 0 3px ".concat(e.palette.primary.light)}},children:[t&&(0,r.jsx)(eT.A,{color:"primary",fontSize:"small",sx:{position:"absolute",top:8,right:8}}),(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5,color:t?"primary.main":"text.secondary"},children:[n,(0,r.jsx)(i.A,{variant:"subtitle1",sx:{fontWeight:600,color:"text.primary"},children:o})]}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",children:l})]})},t1=e=>{let{excludeModelPrompt:t,setExcludeModelPrompt:n,excludeStartNodePrompt:o,setExcludeStartNodePrompt:l,excludeSystemPrompt:a,setExcludeSystemPrompt:d,inputMode:c,setInputMode:u,isolatedPrompt:p,setIsolatedPrompt:h,allowCallerPrompt:m,setAllowCallerPrompt:f,outputMode:g,setOutputMode:x,isModelBound:v,models:w,nodeData:y}=e;return(0,r.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column"},children:[(0,r.jsxs)(s.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",mb:2},children:[(0,r.jsx)(F.A,{control:(0,r.jsx)(P.A,{checked:t,onChange:e=>n(e.target.checked),color:"primary",size:"small"}),label:"Exclude Model Prompt"}),(0,r.jsx)(F.A,{control:(0,r.jsx)(P.A,{checked:o,onChange:e=>l(e.target.checked),color:"primary",size:"small"}),label:"Exclude Start Node Prompt"}),(0,r.jsx)(F.A,{control:(0,r.jsx)(P.A,{checked:a,onChange:e=>d(e.target.checked),color:"primary",size:"small"}),label:"Exclude System Prompt"})]}),(0,r.jsxs)(s.default,{sx:{mb:2,p:2,bgcolor:"rgba(0, 0, 0, 0.03)",borderRadius:1,fontSize:"0.85rem"},children:[(0,r.jsx)(i.A,{variant:"caption",sx:{display:"block",mb:1,fontWeight:"bold"},children:"Prompt Rendering Order:"}),(0,r.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[!o&&(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsx)(i.A,{variant:"caption",sx:{color:"primary.main",fontWeight:"medium"},children:"1. Start Node Prompt"}),(0,r.jsx)(i.A,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:"(from the Start node in this flow)"})]}),!t&&v&&(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsxs)(i.A,{variant:"caption",sx:{color:"secondary.main",fontWeight:"medium"},children:[o?"1.":"2."," Model Prompt"]}),(0,r.jsxs)(i.A,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:["(from the selected model: ",(()=>{var e,t;let n=null==(e=y.properties)?void 0:e.boundModel;if(!n)return"None";let r=w.find(e=>e.id===n);return r?r.displayName||r.name:(null==(t=y.properties)?void 0:t.modelName)||"None"})(),")"]})]}),(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsxs)(i.A,{variant:"caption",sx:{fontWeight:"medium"},children:[o||t||!v?o&&(t||!v)?"1.":"2.":"3."," This Node's Prompt"]}),(0,r.jsx)(i.A,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:"(defined in the Task tab)"})]}),(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsxs)(i.A,{variant:"caption",sx:{fontWeight:"medium"},children:[o||t||!v?o&&(t||!v)?"2.":"3.":"4."," ","isolated"===c?"Isolated prompt":"latest-message"===c?"Latest message only":"Conversation History"]}),(0,r.jsx)(i.A,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:"isolated"===c?"(the prompt below, as the user message)":"latest-message"===c?"(the last user message + the last agent response)":"(coming from ChatCompletion endpoint)"})]})]})]}),(0,r.jsxs)(s.default,{sx:{mb:2},children:[(0,r.jsx)(i.A,{variant:"subtitle2",sx:{mb:1},children:"What does the model receive?"}),(0,r.jsxs)(s.default,{role:"radiogroup","aria-label":"Model input",sx:{display:"flex",gap:1.5,flexWrap:"wrap"},children:[(0,r.jsx)(t0,{selected:"full-history"===c,onClick:()=>u("full-history"),icon:(0,r.jsx)(tY,{fontSize:"small"}),title:"Full conversation",description:"The model sees this node's prompt plus the whole conversation so far. The default."}),(0,r.jsx)(t0,{selected:"latest-message"===c,onClick:()=>u("latest-message"),icon:(0,r.jsx)(tq,{fontSize:"small"}),title:"Latest message only",description:"The model sees this node's prompt plus the most recent exchange — the last user message and the last agent response — plus this turn's own in-flight tool calls and results."}),(0,r.jsx)(t0,{selected:"isolated"===c,onClick:()=>u("isolated"),icon:(0,r.jsx)(tJ,{fontSize:"small"}),title:"Isolated",description:"The conversation is ignored. The model sees this node's prompt plus the prompt below, sent as the user message."})]}),"isolated"===c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F.A,{sx:{mt:1,display:"block"},control:(0,r.jsx)(ts.A,{checked:m,onChange:e=>f(e.target.checked)}),label:"Let the caller pass a prompt"}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{ml:4,mt:-.5},children:"When on, a step that hands off to this node can attach an instruction through its handoff tool, overriding the prompt below. The prompt below is then used only as a default when the caller sends none."}),(0,r.jsx)(b.A,{fullWidth:!0,label:m?"Default prompt (used if the caller sends none)":"Isolated prompt",value:p,onChange:e=>h(e.target.value),margin:"normal",multiline:!0,rows:2,helperText:m?"The default user message. A routing model may override it via the handoff tool. The prior conversation is not shown to the model (it is still kept in the transcript for later nodes).":"Sent to the model as the user message. The prior conversation is not shown to the model (it is still kept in the transcript for later nodes)."})]})]}),(0,r.jsxs)(s.default,{sx:{mb:1},children:[(0,r.jsx)(i.A,{variant:"subtitle2",sx:{mb:1},children:"What do later steps see of this step's work?"}),(0,r.jsxs)(s.default,{role:"radiogroup","aria-label":"Model output",sx:{display:"flex",gap:1.5,flexWrap:"wrap"},children:[(0,r.jsx)(t0,{selected:"full-conversation"===g,onClick:()=>x("full-conversation"),icon:(0,r.jsx)(tZ.A,{fontSize:"small"}),title:"Full conversation",description:"Later steps see everything this step did — tool calls, tool results, and intermediate turns. The default."}),(0,r.jsx)(t0,{selected:"latest-message"===g,onClick:()=>x("latest-message"),icon:(0,r.jsx)(tQ,{fontSize:"small"}),title:"Latest message only",description:"Later steps see only this step's final response. Its tool calls and results are hidden from later models to save context tokens (they stay visible in the chat and log)."})]})]})]})},t2=e=>{let{nodeData:t,handlePropertyChange:n,properties:o}=e;return(0,r.jsx)(r.Fragment,{children:o.length>0&&(0,r.jsxs)(s.default,{sx:{mt:3},children:[(0,r.jsx)(i.A,{variant:"subtitle1",gutterBottom:!0,children:"Node Properties"}),o.map(e=>(e=>{var o,l,a;if(!t)return null;let s=null!=(l=null==(o=t.properties)?void 0:o[e.key])?l:"";switch(e.type){case"text":return(0,r.jsx)(b.A,{fullWidth:!0,label:e.label,multiline:e.multiline,rows:e.multiline?4:1,value:s,onChange:t=>n(e.key,t.target.value),margin:"normal",helperText:e.helperText},e.key);case"number":return(0,r.jsx)(b.A,{fullWidth:!0,type:"number",label:e.label,value:s,inputProps:{min:e.min,max:e.max,step:e.step},onChange:t=>{let r=t.target.value;n(e.key,""===r?void 0:Number(r))},margin:"normal",helperText:e.helperText},e.key);case"select":return(0,r.jsxs)(e3.A,{fullWidth:!0,margin:"normal",children:[(0,r.jsx)(e9.A,{children:e.label}),(0,r.jsx)(e6.A,{value:s||"",label:e.label,onChange:t=>n(e.key,t.target.value),children:null==(a=e.options)?void 0:a.map(e=>(0,r.jsx)(z.A,{value:e,children:e},e))})]},e.key);case"boolean":return(0,r.jsx)(F.A,{control:(0,r.jsx)(P.A,{checked:s||!1,onChange:t=>n(e.key,t.target.checked)}),label:e.label,sx:{my:1}},e.key);default:return null}})(e))]})})},t5=e=>{let{value:t,onChange:n,onInsertRef:o}=e,l=t.captureVariable.trim(),a=t.captureKvKey.trim(),c=t.captureResource.trim(),u=""===l||eF(l),p=""===a||eL(a);return(0,r.jsxs)(s.default,{children:[(0,r.jsx)(i.A,{variant:"subtitle2",sx:{mb:.5},children:"Data-flow capture"}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Optionally save this step's output so a later step can reuse it. Leave a field empty to not capture it."}),(0,r.jsxs)(eq.A,{direction:"row",spacing:1,alignItems:"flex-start",sx:{mb:2},children:[(0,r.jsx)(b.A,{fullWidth:!0,size:"small",label:"Capture as run variable",value:t.captureVariable,onChange:e=>n({captureVariable:e.target.value}),error:!u,helperText:u?"Saves this step’s output into a run-scoped variable, injected later with ${var:NAME}.":"Use letters, digits, _ or - and start with a letter or _."}),o&&(0,r.jsxs)(d.A,{variant:"outlined",size:"small",sx:{mt:.5,whiteSpace:"nowrap",textTransform:"none"},disabled:!l||!u,onClick:()=>o("${var:".concat(l,"}")),children:["Insert $","{var:NAME}"]})]}),(0,r.jsxs)(eq.A,{direction:"row",spacing:1,alignItems:"flex-start",sx:{mb:2},children:[(0,r.jsx)(b.A,{fullWidth:!0,size:"small",label:"Capture as run resource",value:t.captureResource,onChange:e=>n({captureResource:e.target.value}),helperText:"Saves this step’s output as a named run resource, referenced later with ${res:NAME}."}),o&&(0,r.jsxs)(d.A,{variant:"outlined",size:"small",sx:{mt:.5,whiteSpace:"nowrap",textTransform:"none"},disabled:!c,onClick:()=>o("${res:".concat(c,"}")),children:["Insert $","{res:NAME}"]})]}),(0,r.jsxs)(eq.A,{direction:"row",spacing:1,alignItems:"flex-start",children:[(0,r.jsx)(b.A,{select:!0,size:"small",label:"Scope",sx:{width:130,flexShrink:0},value:t.captureKvScope,onChange:e=>n({captureKvScope:e.target.value}),children:eR.map(e=>(0,r.jsx)(z.A,{value:e,children:e},e))}),(0,r.jsx)(b.A,{fullWidth:!0,size:"small",label:"Capture as persistent key (kv)",value:t.captureKvKey,onChange:e=>n({captureKvKey:e.target.value}),error:!p,helperText:p?"Persists across runs. Reference later with ${kv:NAME} (scope lives on this capture, not the reference).":"Use letters, digits, _ or - and start with a letter or _."}),o&&(0,r.jsxs)(d.A,{variant:"outlined",size:"small",sx:{mt:.5,whiteSpace:"nowrap",textTransform:"none"},disabled:!a||!p,onClick:()=>o("${kv:".concat(a,"}")),children:["Insert $","{kv:NAME}"]})]})]})},t4=(0,W.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/ProcessNodePropertiesModal"),t3=[{key:"basic",label:"Basic"},{key:"model",label:"Model"},{key:"io",label:"Input/Output"},{key:"task",label:"Task"},{key:"advanced",label:"Advanced"}],t9=e=>{var t;let{open:n,node:l,onClose:a,onSave:c,flowEdges:p=[],flowNodes:h=[],flowId:m,onConnectMcpServer:v,authoringMode:b="advanced",mode:y="edit"}=e;t4.debug("ProcessNodePropertiesModal rendered with:",{node:l,flowId:m});let{nodeData:j,setNodeData:A,handlePropertyChange:C}=(e=>{let[t,n]=(0,o.useState)(null);(0,o.useEffect)(()=>{e&&n({id:e.id,...e.data,properties:{...e.data.properties}})},[e]);let r=(0,o.useCallback)((e,t)=>{n(n=>n?{...n,properties:{...n.properties,[e]:t}}:null)},[]);return{nodeData:t,setNodeData:n,handlePropertyChange:r}})(l),[S,k]=(0,o.useState)(""),[T,I]=(0,o.useState)(!1),[M,N]=(0,o.useState)(!1),[E,z]=(0,o.useState)(!1),[W,L]=(0,o.useState)(!1),[D,H]=(0,o.useState)("full-history"),[V,U]=(0,o.useState)(""),[G,K]=(0,o.useState)(!0),[$,Y]=(0,o.useState)("full-conversation"),[q,J]=(0,o.useState)(!1),[Z,Q]=(0,o.useState)(""),[ee,et]=(0,o.useState)(""),[en,er]=(0,o.useState)("folder"),[eo,el]=(0,o.useState)(""),[ea,es]=(0,o.useState)("server"),[ei,ed]=(0,o.useState)("basic"),ec="advanced"===b?t3:t3.filter(e=>["basic","model","task"].includes(e.key)),eu=(0,o.useRef)(null),ep=(0,o.useRef)(null),eh=(0,o.useRef)(null),em=(0,o.useRef)(null),ef=(0,o.useRef)(null),eg=(0,o.useRef)(null),ex={basic:ep,model:eh,io:em,task:ef,advanced:eg},ev=(0,o.useRef)(!1);(0,o.useEffect)(()=>{"guided"===b&&("io"===ei||"advanced"===ei)&&ed("basic"),"guided"===b&&"server"!==ea&&es("server")},[ei,ea,b]);let{models:eb,isLoadingModels:ew,loadError:ey,handleModelSelect:ej,handleUnbindModel:eA}=((e,t,n,r,l)=>{var a,s;tm.debug("useModelManagement: Entering hook");let[i,d]=(0,o.useState)([]),[c,u]=(0,o.useState)(!1),[p,h]=(0,o.useState)(null);(0,o.useEffect)(()=>{tm.debug("useModelManagement useEffect: Checking if modal is open",{open:e}),e&&m()},[e]),(0,o.useEffect)(()=>{var e,r;if(0===i.length)return;let o=null==t||null==(e=t.properties)?void 0:e.boundModel;if(!o)return;let l=i.find(e=>e.id===o);l&&l.name&&(null==t||null==(r=t.properties)?void 0:r.modelName)!==l.name&&n(e=>{var t;return e&&(null==(t=e.properties)?void 0:t.modelName)!==l.name?{...e,properties:{...e.properties,modelName:l.name}}:e})},[i,null==t||null==(a=t.properties)?void 0:a.boundModel,null==t||null==(s=t.properties)?void 0:s.modelName,n]);let m=async()=>{tm.debug("loadModels: Entering method"),u(!0),h(null);try{let e=await O.N.loadModels();d(e)}catch(e){tm.warn("loadModels: Failed to load models:",e),h("Failed to load models")}u(!1)},f=(0,o.useCallback)(e=>{tm.debug("handleModelSelect: Entering method",{modelId:e});let t=i.find(t=>t.id===e);t&&(n(n=>{var r;if(!n)return null;let o=i.find(e=>{var t;return e.id===(null==(t=n.properties)?void 0:t.boundModel)}),l=th({currentLabel:n.label,nameIsCustom:null==(r=n.properties)?void 0:r.nameIsCustom,defaultLabel:"Process Node",previousAutoLabel:o?o.displayName||o.name:void 0,nextAutoLabel:t.displayName||t.name});return{...n,label:l,properties:{...n.properties,boundModel:e,modelName:t.name}}}),l(!0))},[i,n,r,l]);return{models:i,isLoadingModels:c,loadError:p,handleModelSelect:f,handleUnbindModel:(0,o.useCallback)(()=>{tm.debug("handleUnbindModel: Entering method"),n(e=>{if(!e)return null;let{boundModel:t,modelName:n,...r}=e.properties;return{...e,properties:{...r,promptTemplate:r.promptTemplate||""}}}),l(!1)},[n,l])}})(n,j,A,k,I),{connectedMcpNodes:eC,allServers:eS,isLoadingServers:ek,selectedToolServerNodeId:eT,serverToolsMap:eI,serverStatuses:eM,isLoadingTools:eN,handleSelectToolServer:eF,isLoadingSelectedServerTools:eP,handleRetryServer:eR,handleRestartServer:eW}=((e,t,n,r)=>{let l=(0,tf.v)(),a=l.servers||[],s=l.isLoading||!1,[i,d]=(0,o.useState)({}),[c,u]=(0,o.useState)({}),[p,h]=(0,o.useState)({}),[m,f]=(0,o.useState)(null),[g,x]=(0,o.useState)(!1),v=(0,o.useMemo)(()=>t?((e,t)=>[...new Set(t.filter(t=>{var n,r;return t.source===e&&(null==(n=t.data)?void 0:n.edgeType)==="mcp"||t.target===e&&(null==(r=t.data)?void 0:r.edgeType)==="mcp"}).map(t=>t.source===e?t.target:t.source))])(t.id,n):[],[t,n]),b=(0,o.useMemo)(()=>{if(!t||0===v.length)return[];if(!r||!Array.isArray(r))return tg.warn("flowNodes is not available or not an array when filtering connected servers"),[];try{let e=[],t=new Set;return v.forEach(n=>{if(t.has(n))return;let o=r.find(e=>e&&e.id===n);if(!o||!o.data||!o.data.properties)return void tg.warn("Could not find valid MCP node data for ID ".concat(n));let l=o.data.properties.boundServer;if(!l)return void tg.warn("MCP node ".concat(n," is not bound to any server."));let s=a.find(e=>e.name===l),i=(null==s?void 0:s.status)||"unknown",d=o.data.properties.enabledTools||[],c=o.data.properties.enabledResources;e.push({nodeId:n,serverName:l,status:i,enabledTools:Array.isArray(d)?d:[],enabledResources:c}),t.add(n)}),tg.debug("Generated connectedMcpNodes:",JSON.stringify(e)),e}catch(e){return tg.error("Error preparing connected MCP nodes:",e),[]}},[t,v,a,r]);(0,o.useEffect)(()=>{if(b&&b.length>0){let e={};b.forEach(t=>{let n=a.find(e=>e.name===t.serverName);e[t.serverName]=(null==n?void 0:n.status)||t.status||"unknown"}),d(e)}},[b,a]),(0,o.useEffect)(()=>{if(e&&b.length>0){let e=Array.from(new Set(b.map(e=>e.serverName)));(async()=>{let t={},n={...c},r=e.filter(e=>{let t=a.find(t=>t.name===e);return(null==t?void 0:t.status)==="connected"&&!c[e]&&!p[e]});0!==r.length&&(r.forEach(e=>{t[e]=!0}),h(e=>({...e,...t})),await Promise.all(r.map(async e=>{try{tg.debug("Loading tools for server: ".concat(e));let t=await B.S.listServerTools(e);if(t.error)tg.warn("Error loading tools for ".concat(e,":"),t.error),n[e]=[];else{let r=t.tools||[];tg.debug("Loaded ".concat(r.length," tools for ").concat(e)),n[e]=r}}catch(t){tg.warn("Failed to load tools for server ".concat(e,":"),t),n[e]=[]}finally{h(t=>({...t,[e]:!1}))}})),u(n))})()}},[e,b,a]);let w=(0,o.useRef)(c);(0,o.useEffect)(()=>{w.current=c},[c]);let y=(0,o.useCallback)(e=>{tg.debug("Selected MCP Node ID: ".concat(e)),f(e);let t=b.find(t=>t.nodeId===e),n=null==t?void 0:t.serverName;!n||w.current[n]||p[n]?x(p[n||""]||!1):(tg.debug("Tools not loaded for server ".concat(n,", loading now.")),x(!0),h(e=>({...e,[n]:!0})),B.S.listServerTools(n).then(e=>{let t=e.tools||[];e.error?tg.warn("Error loading tools for ".concat(n,":"),e.error):tg.debug("Loaded ".concat(t.length," tools for ").concat(n)),u(e=>({...e,[n]:t}))}).catch(e=>{tg.warn("Failed to load tools for server ".concat(n,":"),e),u(e=>({...e,[n]:[]}))}).finally(()=>{x(!1),h(e=>({...e,[n]:!1}))}))},[b,p]),j=(0,o.useRef)(l);return(0,o.useEffect)(()=>{j.current=l},[l]),{connectedMcpNodes:b,allServers:a,isLoadingServers:s,selectedToolServerNodeId:m,serverToolsMap:c,serverStatuses:i,isLoadingTools:p,handleSelectToolServer:y,isLoadingSelectedServerTools:g,handleRetryServer:(0,o.useCallback)(async e=>{tg.debug("Retrying server: ".concat(e)),h(t=>({...t,[e]:!0}));try{await j.current.retryServer(e);let t=await B.S.listServerTools(e);if(t.error)return tg.warn("Error loading tools for ".concat(e," after retry:"),t.error),!1;{let n=t.tools||[];return tg.debug("Loaded ".concat(n.length," tools for ").concat(e," after retry")),u(t=>({...t,[e]:n})),!0}}catch(t){return tg.warn("Failed to retry or load tools for server ".concat(e,":"),t),!1}finally{h(t=>({...t,[e]:!1}))}},[]),handleRestartServer:(0,o.useCallback)(async e=>{tg.debug("Restarting server: ".concat(e)),h(t=>({...t,[e]:!0}));try{await B.S.restartServer(e),await new Promise(e=>setTimeout(e,1e3));let t=await B.S.listServerTools(e);if(t.error)return tg.warn("Error loading tools for ".concat(e," after restart:"),t.error),!1;{let n=t.tools||[];return tg.debug("Loaded ".concat(n.length," tools for ").concat(e," after restart")),u(t=>({...t,[e]:n})),!0}}catch(t){return tg.warn("Failed to restart or load tools for server ".concat(e,":"),t),!1}finally{h(t=>({...t,[e]:!1}))}},[])}})(n,l,p,h),[eL,eD]=(0,o.useState)([]);(0,o.useEffect)(()=>{let e=!1,t=[...new Set(eC.filter(e=>"connected"===e.status).map(e=>e.serverName))];return n&&0!==t.length?(Promise.all(t.map(async e=>{try{var t,n;let r=await B.S.listServerResources(e),o=eC.filter(t=>t.serverName===e),l=e=>o.some(t=>{let n=t.enabledResources;return void 0===n||"all"===n||n.includes(e)});return[...(null!=(t=r.resources)?t:[]).filter(e=>l(e.uri)).map(t=>(0,tp.Ub)({kind:"resource",server:e,name:t.uri},t.name||t.uri,t.description||"".concat(e," \xb7 ").concat(t.uri))),...(null!=(n=r.resourceTemplates)?n:[]).filter(e=>l(e.uriTemplate)).map(t=>(0,tp.Ub)({kind:"resource",server:e,name:t.uriTemplate},t.name||t.uriTemplate,t.description||"".concat(e," \xb7 ").concat(t.uriTemplate)))]}catch(t){return t4.warn("Failed to load @ resource suggestions for ".concat(e),t),[]}})).then(t=>{e||eD(t.flat())}),()=>{e=!0}):(eD([]),()=>{e=!0})},[n,eC]);let eH=o.useMemo(()=>[...eC.flatMap(e=>{var t,n;let r=new Set(null!=(t=e.enabledTools)?t:[]);return(null!=(n=eI[e.serverName])?n:[]).filter(e=>(null==e?void 0:e.name)&&r.has(e.name)).map(t=>(0,tp.Ub)({kind:"tool",server:e.serverName,name:t.name},t.name,t.description||e.serverName))}),...eL],[eC,eL,eI]),eB=o.useMemo(()=>{if(!l)return[];let e=[];for(let o of p){var t,n,r;let a,s;if((null==(t=o.data)?void 0:t.edgeType)!=="resource"||(o.target===l.id?(a=o.source,s="consume"):o.source===l.id&&(a=o.target,s="produce"),!a||!s))continue;let i=h.find(e=>e.id===a);if(!i||"resource"!==i.type)continue;let d=null!=(r=null==(n=i.data)?void 0:n.properties)?r:{};e.push({id:a,role:s,label:d.name||d.runName||d.uri||a,scope:d.scope,runName:d.runName,uri:d.uri,boundServer:d.boundServer})}return e},[l,p,h]),eO=((e,t,n,r)=>{let[l,a]=(0,o.useState)([]),[s,i]=(0,o.useState)(!1),d=(0,o.useMemo)(()=>t?function(e,t){let n=[];for(let l of t){var r,o;!("string"==typeof(null==(r=l.data)?void 0:r.edgeType)&&(l.data.edgeType.includes("mcp")||"resource"===l.data.edgeType))&&(l.source===e?n.push(l.target):l.target===e&&(null==(o=l.data)?void 0:o.bidirectional)&&n.push(l.source))}return[...new Set(n)]}(t.id,n):[],[t,n]);return(0,o.useEffect)(()=>{if(e&&t){i(!0);try{let e=d.map(e=>r.find(t=>t.id===e)).filter(e=>!!e),t=(0,_.E9)(e.map(e=>({id:e.id,label:e.data.label,type:e.type||e.data.type}))),n=e.map(e=>({name:t.get(e.id)||"handoff_to_".concat(e.id),description:function(e){if(e.userDescription&&e.userDescription.trim())return tx(e.userDescription,1500);let t="Hand off execution to ".concat(e.label," (").concat(e.type,")."),n=[];!function e(t,n,r){let o=" ".repeat(n);if(t.userDescription&&t.userDescription.trim())return void r.push("".concat(o).concat(tx(t.userDescription,200)));if("subflow"===t.type){var l,a;if(t.subflowMissing)return void r.push("".concat(o,"Runs a subflow (referenced flow not found)."));if(t.subflowDetailsUnavailable){let e=t.subflowName?' "'.concat(t.subflowName,'"'):"";r.push("".concat(o,"Runs a subflow").concat(e," (contents summarised when the flow runs)."));return}if(r.push("".concat(o,'Runs the subflow "').concat(null!=(l=t.subflowName)?l:"unknown",'", which contains:')),t.depthCapReached)return void r.push("".concat(o," (nested subflows omitted — recursion depth limit reached)"));let s=null!=(a=t.children)?a:[];if(0===s.length)return void r.push("".concat(o," (no process or subflow steps)"));for(let t of s.slice(0,10))r.push("".concat(o," - ").concat(t.label,":")),e(t,n+2,r);return void(s.length>10&&r.push("".concat(o," - …and ").concat(s.length-10," more step(s)")))}if(t.modelName&&r.push("".concat(o,"Model: ").concat(t.modelName)),t.promptSummary&&r.push("".concat(o,"Role: ").concat(tx(t.promptSummary,200))),t.servers&&t.servers.length>0)for(let e of t.servers)if(e.connected&&e.tools&&e.tools.length>0){let t=e.tools.slice(0,10),n=e.tools.length-t.length,l=n>0?", +".concat(n," more"):"";r.push("".concat(o,"Tools (").concat(e.name,"): ").concat(t.join(", ")).concat(l))}else r.push("".concat(o,"Tools (").concat(e.name,"): server not connected"))}(e,0,n);let r=n.join("\n").trim(),o=r?"".concat(t,"\n").concat(r):t;if(o.length<=1500)return o;let l=1500-t.length-2;return l<=0?t:"".concat(t,"\n").concat(tx(r,l))}(function(e){let t=e.type||e.data.type||"unknown",n=e.data.label||"Unknown Node",r=e.data.description,o=e.data.properties||{},l={label:n,type:t,userDescription:r};if(r&&r.trim())return l;if("subflow"===t)return l.subflowDetailsUnavailable=!0,l;"string"==typeof o.boundModel&&o.boundModel&&(l.modelName=o.boundModel),"string"==typeof o.promptTemplate&&o.promptTemplate.trim()&&(l.promptSummary=o.promptTemplate);let a=Array.isArray(o.mcpNodes)?o.mcpNodes:[],s=[],i=new Set;for(let e of a){var d,c;let t=null==e||null==(d=e.properties)?void 0:d.boundServer;if(!t||i.has(t))continue;i.add(t);let n=Array.isArray(null==e||null==(c=e.properties)?void 0:c.enabledTools)?e.properties.enabledTools:[];s.push({name:t,connected:!0,tools:n})}return s.length>0&&(l.servers=s),l}(e)),inputSchema:{type:"object",properties:{},required:[]}}));a(n),tv.debug("Generated handoff tools",{toolsCount:n.length})}catch(e){tv.error("Error generating handoff tools",e),a([])}finally{i(!1)}}else a([])},[e,t,d,n,r]),{handoffTools:l,isLoadingHandoffTools:s}})(n,l,p,h),eV=(null==eO?void 0:eO.handoffTools)||[],eU=(null==eO?void 0:eO.isLoadingHandoffTools)||!1;(0,o.useEffect)(()=>{n&&l&&t4.debug("Handoff tools:",{count:eV.length,tools:eV.map(e=>e.name)})},[n,l,eV]),(0,o.useEffect)(()=>{var e,t,r,o,a,s,i,d,c,u,p,h,m,f;if(!n)return;if(l){k((null==(t=l.data.properties)?void 0:t.promptTemplate)||""),(null==(r=l.data.properties)?void 0:r.boundModel)?I(!0):I(!1),N((null==(o=l.data.properties)?void 0:o.excludeModelPrompt)||!1),z((null==(a=l.data.properties)?void 0:a.excludeStartNodePrompt)||!1),L((null==(s=l.data.properties)?void 0:s.excludeSystemPrompt)||!1),H((null==(i=l.data.properties)?void 0:i.inputMode)||"full-history"),U((null==(d=l.data.properties)?void 0:d.isolatedPrompt)||""),K((null==(c=l.data.properties)?void 0:c.allowCallerPrompt)!==!1),Y((null==(u=l.data.properties)?void 0:u.outputMode)||"full-conversation"),J((null==(p=l.data.properties)?void 0:p.enableTodoTool)||!1),Q((null==(h=l.data.properties)?void 0:h.captureVariable)||""),et((null==(m=l.data.properties)?void 0:m.captureResource)||"");let e=eE((null==(f=l.data.properties)?void 0:f.captureKv)||"");er(e.scope),el(e.key||"")}let g="create"===y?"basic":function(e,t){return"guided"===e&&"string"==typeof t&&t.trim().length>0?"task":"basic"}(b,null==l||null==(e=l.data.properties)?void 0:e.promptTemplate);ed(g),es("server"),ev.current=!0;let x=window.requestAnimationFrame(()=>{let e=ex[g].current;if(e&&"function"==typeof e.scrollIntoView)e.scrollIntoView({behavior:"auto",block:"start"});else if(eu.current){var t;eu.current.scrollTop=null!=(t=null==e?void 0:e.offsetTop)?t:0}ev.current=!1});return()=>{window.cancelAnimationFrame(x),ev.current=!1}},[l,n,y,b]),(0,o.useEffect)(()=>{if(!n)return;let e=eu.current;if(!e)return;let t=new IntersectionObserver(e=>{var t,n;if(ev.current)return;let r=null==(n=e.filter(e=>e.isIntersecting).sort((e,t)=>t.intersectionRatio-e.intersectionRatio)[0])||null==(t=n.target)?void 0:t.dataset.section;r&&ed(r)},{root:e,threshold:[.15,.4,.75],rootMargin:"0px 0px -45% 0px"});return Object.values(ex).forEach(e=>{e.current&&t.observe(e.current)}),()=>t.disconnect()},[n,l]);let eG=(0,o.useRef)(null),eK=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"server";if(t4.debug("handleInsertToolBinding called with:",JSON.stringify({serverName:e,toolName:t})),!e||!t)return void t4.warn("Invalid parameters for handleInsertToolBinding:",{serverName:e,toolName:t});let r=(eI[e]||[]).find(e=>e.name===t);null==r||r.description;let o="handoff"===n?(0,X.X8)("tool","handoff",t):(0,X.X8)("tool",e,t),l=(!(S.length>0)||S.endsWith(" ")||S.endsWith("\n")?"":" ")+o;eG.current?(t4.debug("Inserting text into PromptBuilder:",JSON.stringify({textToInsert:l})),eG.current.insertText(l),t4.debug("Tool binding inserted successfully")):t4.warn("promptBuilderRef.current is null, cannot insert text")};if(!l||!j)return null;let e$=(null==(t=j.properties)?void 0:t.boundModel)||"",e_={minHeight:"100%",scrollSnapAlign:"start",scrollSnapStop:"always",display:"flex",flexDirection:"column",pb:4},eX=(0,r.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:["advanced"===b&&(0,r.jsx)(s.default,{sx:{borderBottom:1,borderColor:"divider",flexShrink:0},children:(0,r.jsxs)(eJ.A,{value:ea,onChange:(e,t)=>es(t),variant:"scrollable",scrollButtons:"auto","aria-label":"Task tools",children:[(0,r.jsx)(eZ.A,{id:"process-task-tab-server","aria-controls":"process-task-panel-server",label:"MCP",value:"server"}),(0,r.jsx)(eZ.A,{id:"process-task-tab-agent","aria-controls":"process-task-panel-agent",label:"Connected Nodes",value:"agent"}),(0,r.jsx)(eZ.A,{id:"process-task-tab-resources","aria-controls":"process-task-panel-resources",label:"Resources",value:"resources"})]})}),(0,r.jsxs)(s.default,{id:"process-task-panel-".concat(ea),role:"tabpanel","aria-labelledby":"process-task-tab-".concat(ea),"data-testid":"process-task-tools-scroll",sx:{flexGrow:1,minHeight:0,overflow:"auto",pr:.5},children:["server"===ea&&(0,r.jsx)(tD,{isLoadingServers:ek,connectedMcpNodes:eC,availableServers:eS,onConnectMcpServer:v,serverStatuses:eM,serverToolsMap:eI,isLoadingTools:eN,handleInsertToolBinding:eK,selectedToolServerNodeId:eT,selectedNodeId:(null==l?void 0:l.id)||null,handleSelectToolServer:eF,isLoadingSelectedServerTools:eP,promptBuilderRef:eG,handleRetryServer:eR,handleRestartServer:eW}),"advanced"===b&&"resources"===ea&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tU,{wiredResources:eB,promptBuilderRef:eG}),(0,r.jsx)(tO,{connectedMcpNodes:eC,handleInsertResourceBinding:(e,t)=>{if(!e||!t)return void t4.warn("Invalid parameters for handleInsertResourceBinding:",{serverName:e,uri:t});let n=(0,X.X8)("resource",e,t),r=S.length>0&&!S.endsWith(" ")&&!S.endsWith("\n");eG.current?eG.current.insertText((r?" ":"")+n):t4.warn("promptBuilderRef.current is null, cannot insert resource binding")},promptBuilderRef:eG})]}),"advanced"===b&&"agent"===ea&&(0,r.jsx)(tK,{handoffTools:eV,isLoadingHandoffTools:eU,handleInsertToolBinding:(e,t)=>eK(e,t,"handoff"),promptBuilderRef:eG})]})]});return(0,r.jsxs)(f.A,{open:n,onClose:a,slotProps:{transition:{onEntered:()=>{var e;"task"===ei&&(ev.current=!0,null==(e=ef.current)||e.scrollIntoView({block:"start"}),window.setTimeout(()=>{ev.current=!1},0))}}},maxWidth:"xl",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"secondary.main",width:"95vw",height:"90vh",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,r.jsx)(g.A,{component:"div",children:(0,r.jsxs)(s.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,r.jsxs)(i.A,{variant:"h6",children:[j.label||"Process Node"," Properties"]}),(0,r.jsx)(u.A,{edge:"end",color:"inherit",onClick:a,"aria-label":"close",children:(0,r.jsx)(tu.A,{})})]})}),(0,r.jsx)(R.A,{}),(0,r.jsxs)(x.A,{sx:{display:"flex",flexDirection:"column",p:0,overflow:"hidden",height:"calc(90vh - 130px)"},children:[(0,r.jsx)(s.default,{sx:{borderBottom:1,borderColor:"divider",px:2,flexShrink:0},children:(0,r.jsx)(eJ.A,{value:ei,onChange:(e,t)=>(e=>{ed(e),ev.current=!0;let t=ex[e].current;if(t&&"function"==typeof t.scrollIntoView)t.scrollIntoView({behavior:"smooth",block:"start"});else if(eu.current){var n;eu.current.scrollTop=null!=(n=null==t?void 0:t.offsetTop)?n:0}window.setTimeout(()=>{ev.current=!1},700)})(t),variant:"scrollable",scrollButtons:"auto",children:ec.map(e=>(0,r.jsx)(eZ.A,{label:e.label,value:e.key},e.key))})}),(0,r.jsxs)(s.default,{ref:eu,sx:{flexGrow:1,overflow:"auto",p:3,scrollSnapType:"y mandatory",scrollPaddingTop:"24px"},children:[(0,r.jsxs)(s.default,{ref:ep,"data-section":"basic",sx:e_,children:[(0,r.jsx)(i.A,{variant:"h6",sx:{mb:2},children:"Basic"}),(0,r.jsx)(tb,{nodeData:j,setNodeData:A})]}),(0,r.jsxs)(s.default,{ref:eh,"data-section":"model",sx:e_,children:[(0,r.jsx)(i.A,{variant:"h6",sx:{mb:2},children:"Model"}),(0,r.jsx)(tS,{isLoadingModels:ew,loadError:ey,models:eb,selectedModelId:e$,handleModelSelect:ej,isModelBound:T,handleUnbindModel:eA})]}),"advanced"===b&&(0,r.jsxs)(s.default,{ref:em,"data-section":"io",sx:e_,children:[(0,r.jsx)(i.A,{variant:"h6",sx:{mb:2},children:"Input / Output"}),(0,r.jsx)(t1,{excludeModelPrompt:M,setExcludeModelPrompt:N,excludeStartNodePrompt:E,setExcludeStartNodePrompt:z,excludeSystemPrompt:W,setExcludeSystemPrompt:L,inputMode:D,setInputMode:H,isolatedPrompt:V,setIsolatedPrompt:U,allowCallerPrompt:G,setAllowCallerPrompt:K,outputMode:$,setOutputMode:Y,isModelBound:T,models:eb,nodeData:j}),(0,r.jsx)(F.A,{sx:{mt:1},control:(0,r.jsx)(P.A,{checked:q,onChange:e=>J(e.target.checked)}),label:"Enable todo tool (run-scoped task list)"})]}),(0,r.jsxs)(s.default,{ref:ef,"data-section":"task",sx:e_,children:[(0,r.jsx)(i.A,{variant:"h6",sx:{mb:2},children:"Task"}),(0,r.jsxs)(s.default,{sx:{display:"flex",gap:2,flexGrow:1,minHeight:480},children:[(0,r.jsx)(s.default,{sx:{flex:"0 0 340px",minWidth:0,display:"flex",flexDirection:"column",minHeight:0},children:eX}),(0,r.jsx)(s.default,{sx:{flex:"1 1 auto",minWidth:0,display:"flex",flexDirection:"column",minHeight:0},children:(0,r.jsx)(tX,{ref:eG,promptTemplate:S,handlePromptChange:e=>{k(e),A(t=>t?{...t,properties:{...t.properties,promptTemplate:e}}:null)},excludeModelPrompt:M,excludeStartNodePrompt:E,excludeSystemPrompt:W,nodeData:j,flowId:m,suggestions:eH})})]})]}),"advanced"===b&&(0,r.jsxs)(s.default,{ref:eg,"data-section":"advanced",sx:e_,children:[(0,r.jsx)(i.A,{variant:"h6",sx:{mb:2},children:"Advanced"}),(0,r.jsx)(s.default,{sx:{mb:3},children:(0,r.jsx)(t2,{nodeData:j,handlePropertyChange:C,properties:[{key:"maxTurns",label:"Max Turns (override)",type:"number",min:1,helperText:"Optional. Overrides the bound model's Max Turns for this node. Leave empty to inherit the model setting (default 50)."},{key:"maxTokens",label:"Max Output Tokens (override)",type:"number",min:1,helperText:"Optional. Overrides the bound model's Max Output Tokens for this node. Leave empty to inherit the model setting (adapter default). Not enforced for the Claude subscription adapter."}]})}),(0,r.jsx)(s.default,{children:(0,r.jsx)(t5,{value:{captureVariable:Z,captureResource:ee,captureKvScope:en,captureKvKey:eo},onChange:e=>{void 0!==e.captureVariable&&Q(e.captureVariable),void 0!==e.captureResource&&et(e.captureResource),void 0!==e.captureKvScope&&er(e.captureKvScope),void 0!==e.captureKvKey&&el(e.captureKvKey)},onInsertRef:e=>{let t=S.length>0&&!S.endsWith(" ")&&!S.endsWith("\n");eG.current?eG.current.insertText((t?" ":"")+e):t4.warn("promptBuilderRef.current is null, cannot insert capture reference")}})})]})]})]}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:a,children:"Cancel"}),(0,r.jsx)(d.A,{onClick:()=>{if(l&&j){let e={...j.properties,promptTemplate:S};if("advanced"===b){Object.assign(e,{excludeModelPrompt:M,excludeStartNodePrompt:E,excludeSystemPrompt:W,inputMode:D,isolatedPrompt:V,allowCallerPrompt:G,outputMode:$}),q?e.enableTodoTool=!0:delete e.enableTodoTool;let t=Z.trim();t?e.captureVariable=t:delete e.captureVariable;let n=ee.trim();n?e.captureResource=n:delete e.captureResource;let r=ez(en,eo);r?e.captureKv=r:delete e.captureKv}c(l.id,{...j,properties:e}),a()}},variant:"contained",color:"primary",children:"Save Changes"})]})]})};var t6=n(71651),t8=n(94035);let t7=(0,W.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/MCPNodePropertiesModal"),ne=e=>{var t,n,l,a,c,h,m,v;let{open:y,node:j,onClose:A,onSave:C,authoringMode:S="advanced"}=e,[k,T]=(0,o.useState)(null),{servers:I,isLoading:M,loadError:E,retryServer:z}=(0,tf.v)(),[W,L]=(0,o.useState)({}),D=(0,tC.E)("mcp",I),[H,B]=(0,o.useState)(!1),O=async()=>{B(!0);try{await Promise.all(I.map(e=>z(e.name)))}finally{setTimeout(()=>B(!1),500)}},{tools:V,isLoading:U,error:G,loadTools:K}=(0,t8.O)((null==k||null==(t=k.properties)?void 0:t.boundServer)||"");(0,o.useEffect)(()=>{j&&T({...j.data,properties:{...j.data.properties}})},[j,y]);let $=(null==k||null==(n=k.properties)?void 0:n.boundServer)||"";(0,o.useEffect)(()=>{V&&V.length>0&&(e=>{k&&0===(k.properties.enabledTools||[]).length&&e.length>0&&(t7.debug("Enabling all tools by default"),T(t=>t?{...t,properties:{...t.properties,enabledTools:e.map(e=>e.name)}}:null))})(V)},[V]);let _=(e,t)=>{T(n=>n?{...n,properties:{...n.properties,[e]:t}}:null)},X=async(e,t)=>{t&&t.stopPropagation(),t7.debug("Retrying server: ".concat(e)),L(t=>({...t,[e]:!0}));try{return await z(e),e===$&&K(!0),!0}catch(t){return t7.warn("Failed to retry server ".concat(e,": ").concat(t)),!1}finally{setTimeout(()=>{L(t=>({...t,[e]:!1}))},500)}};if(!j||!k)return null;let Y=(null==(l=k.properties)?void 0:l.boundServer)||"",q=(null==(a=k.properties)?void 0:a.enabledTools)||[],J=e=>({key:e.name,content:(e=>(0,r.jsx)(tW.A,{name:e.name,status:e.status||"disconnected",path:e.path||e.rootPath||"",enabled:!e.disabled,transport:e.transport||"stdio",pickerMode:!0,selected:Y===e.name,onClick:()=>(e=>{t7.debug("Server selected: ".concat(e)),t7.debug("Server selected: ".concat(e)),T(t=>{var n,r;if(!t)return null;let o=th({currentLabel:t.label,nameIsCustom:null==(n=t.properties)?void 0:n.nameIsCustom,defaultLabel:"MCP Node",previousAutoLabel:(null==(r=t.properties)?void 0:r.boundServer)||void 0,nextAutoLabel:e});return{...t,label:o,properties:{...t.properties,boundServer:e}}})})(e.name)}))(e)}),Z=D.items.map(J),Q=D.groups?D.groups.map(e=>({...e,items:e.items.map(J)})):null,ee=null==(c=k.properties)?void 0:c.toolTimeout,et=-1===ee;return(0,r.jsxs)(f.A,{open:y,onClose:A,maxWidth:"guided"===S?"xl":"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"info.main",width:"guided"===S?"95vw":void 0,height:"guided"===S?"90vh":"80vh",maxWidth:"guided"===S?"95vw":void 0,maxHeight:"guided"===S?"90vh":"80vh"}},children:[(0,r.jsx)(g.A,{component:"div",children:(0,r.jsxs)(s.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,r.jsxs)(i.A,{variant:"h6",children:[k.label||"MCP Node"," Properties"]}),(0,r.jsx)(u.A,{edge:"end",color:"inherit",onClick:A,"aria-label":"close",children:(0,r.jsx)(tu.A,{})})]})}),(0,r.jsx)(R.A,{}),(0,r.jsxs)(x.A,{sx:{display:"flex",flexDirection:"column",p:3,overflow:"auto"},children:[(0,r.jsx)(b.A,{fullWidth:!0,label:"Node Label",value:k.label||"",onChange:e=>{T(t=>t?{...t,label:e.target.value,properties:{...t.properties,nameIsCustom:!0}}:null)},margin:"normal",helperText:"The display name for this node on the canvas",sx:{mb:2}}),(0,r.jsxs)(s.default,{sx:{mb:4},children:[(0,r.jsx)(i.A,{variant:"subtitle1",gutterBottom:!0,children:"Bind to MCP Server"}),(0,r.jsx)(s.default,{sx:{display:"flex",justifyContent:"flex-end",mb:1},children:(0,r.jsx)(p.A,{title:"Retry all server connections",children:(0,r.jsx)("span",{children:(0,r.jsx)(u.A,{size:"small",onClick:O,disabled:H||M,children:H?(0,r.jsx)(N.default,{size:16}):(0,r.jsx)(tM.A,{fontSize:"small"})})})})}),(0,r.jsx)(tj.A,{isLoading:M,error:E,emptyMessage:"No MCP servers available. Add some in the MCP Manager.",loadingMessage:"Loading MCP servers…",searchable:!0,searchPlaceholder:"Search servers…",searchTerm:D.searchTerm,onSearchChange:D.setSearchTerm,columns:{xs:12,sm:6},items:Z,groups:Q,collapsedKeys:D.collapsedKeys,onToggleGroup:D.toggleGroup}),(0,r.jsx)(tw.A,{children:Y?'This node will use the "'.concat(Y,'" MCP server for processing.'):"Select an MCP server to bind this node to."})]}),(0,r.jsx)(b.A,{fullWidth:!0,label:"Description",value:k.description||"",onChange:e=>T({...k,description:e.target.value}),margin:"normal",multiline:!0,rows:2,helperText:"This description will be displayed on the node"}),Y&&(0,r.jsxs)(s.default,{sx:{mt:4},children:[(0,r.jsx)(i.A,{variant:"subtitle1",gutterBottom:!0,children:"Tool Call Timeout"}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mb:1},children:"How long a single tool call on this server may run before it is aborted. Tools that report progress keep the timeout alive while they work."}),(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:2},children:[(0,r.jsx)(b.A,{label:"Timeout (seconds)",type:"number",size:"small",sx:{width:200},value:et?"":null!=ee?ee:"",placeholder:String(300),disabled:et,inputProps:{min:1},onChange:e=>{let t=e.target.value;if(""===t)return void _("toolTimeout",void 0);let n=parseInt(t,10);!isNaN(n)&&n>0&&_("toolTimeout",n)},helperText:et?"No timeout — tool calls run until they finish.":"Empty = default (".concat(300," seconds / 5 minutes).")}),(0,r.jsx)(F.A,{control:(0,r.jsx)(P.A,{checked:et,onChange:e=>_("toolTimeout",e.target.checked?-1:void 0)}),label:"No timeout (infinite)"})]})]}),Y&&(0,r.jsxs)(s.default,{sx:{mt:4},children:[(0,r.jsx)(i.A,{variant:"subtitle1",gutterBottom:!0,children:"Allowed Tools"}),(null==(h=I.find(e=>e.name===Y))?void 0:h.status)!=="connected"&&(0,r.jsxs)(s.default,{sx:{mb:2,p:2,bgcolor:"error.light",borderRadius:1},children:[(0,r.jsx)(i.A,{color:"error.dark",children:"Server is disconnected. Tools cannot be fetched. Please retry the connection."}),(0,r.jsx)(d.A,{variant:"outlined",size:"small",color:"primary",startIcon:W[Y]?(0,r.jsx)(N.default,{size:16}):(0,r.jsx)(tM.A,{}),onClick:()=>X(Y),disabled:W[Y],sx:{mt:1},children:"Retry Connection"})]}),U?(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(N.default,{size:20}),(0,r.jsx)(i.A,{color:"text.secondary",children:"Loading tools..."})]}):G?(0,r.jsx)(i.A,{color:"error",children:G}):V&&0!==V.length?(0,r.jsxs)(s.default,{sx:{mt:2},children:[(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Select which tools this node will have access to. This helps limit the tools available to connected process nodes."}),(0,r.jsx)(eb.A,{children:V.map(e=>(0,r.jsxs)(eA.Ay,{sx:{py:0},children:[(0,r.jsx)(ew.A,{sx:{minWidth:42},children:(0,r.jsx)(P.A,{edge:"start",checked:q.includes(e.name),onChange:()=>(e=>{t7.debug("Tool toggled: ".concat(e)),T(t=>{let n;if(!t)return null;let r=t.properties.enabledTools||[];return n=r.includes(e)?r.filter(t=>t!==e):[...r,e],{...t,properties:{...t.properties,enabledTools:n}}})})(e.name)})}),(0,r.jsx)(ey.A,{primary:e.name,secondary:e.description,primaryTypographyProps:{fontWeight:"medium"}})]},e.name))})]}):(0,r.jsx)(i.A,{color:"text.secondary",children:(null==(m=I.find(e=>e.name===Y))?void 0:m.status)==="connected"?"No tools available for this MCP server.":"Connect to the server to view available tools."})]}),Y&&(0,r.jsxs)(s.default,{sx:{mt:4},children:[(0,r.jsx)(t6.A,{roots:(null==(v=k.properties)?void 0:v.roots)||[],onChange:e=>_("roots",e)}),(0,r.jsxs)(i.A,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:1},children:["These folders apply to this node only and are ",(0,r.jsx)("strong",{children:"added to"}),' the workspace folders configured on the "',Y,'" server itself. When neither is set, the server sees its own root dir as its workspace folder.']})]})]}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:A,children:"Cancel"}),(0,r.jsx)(d.A,{onClick:()=>{j&&k&&(C(j.id,k),A())},variant:"contained",color:"primary",children:"Save Changes"})]})]})},nt=e=>{let{open:t,node:n,onClose:l,onSave:a}=e,[c,p]=(0,o.useState)(null),[h,m]=(0,o.useState)("");return((0,o.useEffect)(()=>{if(n){var e;p({...n.data,properties:{...n.data.properties}}),m((null==(e=n.data.properties)?void 0:e.promptTemplate)||"")}},[n,t]),n&&c)?(0,r.jsxs)(f.A,{open:t,onClose:l,maxWidth:"xl",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"primary.main",width:"95vw",height:"90vh",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,r.jsx)(g.A,{component:"div",children:(0,r.jsxs)(s.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,r.jsxs)(i.A,{variant:"h6",children:[c.label||"Start Node"," Properties"]}),(0,r.jsx)(u.A,{edge:"end",color:"inherit",onClick:l,"aria-label":"close",children:(0,r.jsx)(tu.A,{})})]})}),(0,r.jsx)(R.A,{}),(0,r.jsx)(x.A,{sx:{display:"flex",flexDirection:"column",p:3,overflow:"auto",height:"calc(90vh - 130px)"},children:(0,r.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,r.jsx)(i.A,{variant:"h6",gutterBottom:!0,children:"Prompt Template"}),(0,r.jsx)(s.default,{sx:{flexGrow:1,display:"flex",flexDirection:"column",height:"calc(100% - 40px)"},children:(0,r.jsx)(t$.A,{value:h,onChange:e=>{m(e),p(t=>t?{...t,properties:{...t.properties,promptTemplate:e}}:null)},label:"",height:"100%"})})]})}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:l,children:"Cancel"}),(0,r.jsx)(d.A,{onClick:()=>{if(n&&c){let e={...c,properties:{...c.properties,promptTemplate:h}};a(n.id,e),l()}},variant:"contained",color:"primary",children:"Save Changes"})]})]}):null},nn=e=>{let{open:t,node:n,onClose:l,onSave:a}=e,[c,p]=(0,o.useState)(null);return((0,o.useEffect)(()=>{n&&p({...n.data,properties:{...n.data.properties}})},[n,t]),n&&c)?(0,r.jsxs)(f.A,{open:t,onClose:l,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"success.main",width:"600px",height:"400px",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,r.jsx)(g.A,{component:"div",children:(0,r.jsxs)(s.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,r.jsxs)(i.A,{variant:"h6",children:[c.label||"Finish Node"," Properties"]}),(0,r.jsx)(u.A,{edge:"end",color:"inherit",onClick:l,"aria-label":"close",children:(0,r.jsx)(tu.A,{})})]})}),(0,r.jsx)(R.A,{}),(0,r.jsx)(x.A,{sx:{display:"flex",flexDirection:"column",p:3,overflow:"auto"},children:(0,r.jsx)(s.default,{sx:{display:"flex",flexDirection:"column",height:"100%",justifyContent:"center",alignItems:"center",py:4},children:(0,r.jsxs)(I.A,{elevation:0,sx:{p:4,textAlign:"center",backgroundColor:"rgba(76, 175, 80, 0.08)",borderRadius:2,width:"100%"},children:[(0,r.jsx)(i.A,{variant:"h6",color:"success.main",gutterBottom:!0,children:"Finish Node"}),(0,r.jsx)(i.A,{variant:"body1",color:"text.secondary",children:"This is the end point of your flow. No additional configuration is needed."}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mt:2,fontStyle:"italic"},children:"Future versions will support output formatting options."})]})})}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:l,children:"Cancel"}),(0,r.jsx)(d.A,{onClick:()=>{n&&c&&(a(n.id,c),l())},variant:"contained",color:"primary",children:"Save"})]})]}):null},nr={contains:"Contains",regex:"Regex",equals:"Equals",always:"Always (any reply)"},no={"last-assistant":"Last agent reply (this step's output)","last-message":"Last message (any role)"},nl=e=>{let{open:t,edge:n,onClose:l,onSave:a}=e,[c,p]=(0,o.useState)(!1),[h,m]=(0,o.useState)("contains"),[v,y]=(0,o.useState)(""),[j,A]=(0,o.useState)("last-assistant"),[C,S]=(0,o.useState)(!1),[k,T]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{var e,t;let r=null==n||null==(e=n.data)?void 0:e.condition;r?(p(!0),m(r.kind),y("string"==typeof r.value?r.value:""),A(null!=(t=r.target)?t:"last-assistant"),S(!!r.ignoreCase),T(!!r.negate)):(p(!1),m("contains"),y(""),A("last-assistant"),S(!1),T(!1))},[n,t]),!n)return null;let I="always"!==h,M=c&&"regex"===h&&v.length>0&&!(0,eI.wM)(v),N=c&&I&&0===v.length;return(0,r.jsxs)(f.A,{open:t,onClose:l,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"primary.main",width:"520px",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,r.jsx)(g.A,{component:"div",children:(0,r.jsxs)(s.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,r.jsx)(i.A,{variant:"h6",children:"Edge Properties"}),(0,r.jsx)(u.A,{edge:"end",color:"inherit",onClick:l,"aria-label":"close",children:(0,r.jsx)(tu.A,{})})]})}),(0,r.jsx)(R.A,{}),(0,r.jsxs)(x.A,{sx:{display:"flex",flexDirection:"column",gap:2,p:3},children:[(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",children:"A conditional edge is taken only when its predicate matches the selected message at runtime. The flow takes the first matching outgoing edge; a plain (condition-less) edge is the default/fallback."}),(0,r.jsx)(F.A,{control:(0,r.jsx)(P.A,{checked:c,onChange:e=>p(e.target.checked)}),label:"Conditional edge"}),c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(e3.A,{fullWidth:!0,size:"small",children:[(0,r.jsx)(e9.A,{id:"edge-condition-kind-label",children:"Kind"}),(0,r.jsx)(e6.A,{labelId:"edge-condition-kind-label",label:"Kind",value:h,onChange:e=>m(e.target.value),children:eI.w4.map(e=>(0,r.jsx)(z.A,{value:e,children:nr[e]},e))})]}),I&&(0,r.jsx)(b.A,{fullWidth:!0,size:"small",label:"regex"===h?"Pattern (JS regex source)":"Value",value:v,onChange:e=>y(e.target.value),error:M||N,helperText:M?"Invalid regular expression — will never match at runtime.":N?"A value is required for this kind (an empty value never matches).":" "}),(0,r.jsxs)(e3.A,{fullWidth:!0,size:"small",children:[(0,r.jsx)(e9.A,{id:"edge-condition-target-label",children:"Test against"}),(0,r.jsx)(e6.A,{labelId:"edge-condition-target-label",label:"Test against",value:j,onChange:e=>A(e.target.value),children:eI.L2.map(e=>(0,r.jsx)(z.A,{value:e,children:no[e]},e))})]}),(0,r.jsxs)(s.default,{display:"flex",gap:2,flexWrap:"wrap",children:[I&&(0,r.jsx)(F.A,{control:(0,r.jsx)(ts.A,{checked:C,onChange:e=>S(e.target.checked)}),label:"Ignore case"}),(0,r.jsx)(F.A,{control:(0,r.jsx)(ts.A,{checked:k,onChange:e=>T(e.target.checked)}),label:"Negate (match when NOT true)"})]}),(0,r.jsx)(tw.A,{children:"Predicates never throw at runtime: a broken regex simply never matches."})]})]}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:l,children:"Cancel"}),(0,r.jsx)(d.A,{onClick:()=>{if(!c){a(n.id,void 0),l();return}let e={kind:h};I&&(e.value=v,C&&(e.ignoreCase=!0)),"last-assistant"!==j&&(e.target=j),k&&(e.negate=!0),a(n.id,e),l()},variant:"contained",color:"primary",disabled:M,children:"Save"})]})]})};var na=n(56900),ns=n(92241);let ni=(0,W.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/SubflowNodePropertiesModal"),nd=e=>{var t,n,l,a,c,p,h,v,y,j,A,C,S,k,T,I,M,N,E;let{open:W,node:L,onClose:D,onSave:B,flowId:O,authoringMode:V="advanced"}=e,[U,G]=(0,o.useState)(null),[K,$]=(0,o.useState)([]),[_,X]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),[J,Z]=(0,o.useState)(""),[Q,ee]=(0,o.useState)(""),[et,en]=(0,o.useState)(""),[er,eo]=(0,o.useState)("folder"),[el,ea]=(0,o.useState)("");(0,o.useEffect)(()=>{if(L){let e=L.data.properties||{};G({...L.data,properties:{...e}}),Z(Array.isArray(e.spawnBriefs)?e.spawnBriefs.filter(e=>"string"==typeof e).join("\n"):""),ee(e.captureVariable||""),en(e.captureResource||"");let t=eE(e.captureKv||"");eo(t.scope),ea(t.key||"")}},[L,W]),(0,o.useEffect)(()=>{if(!W)return;let e=!1;return X(!0),H.g.loadFlows().then(t=>{e||$(t||[])}).catch(t=>{ni.warn("Failed to load flows for subflow picker",t),e||$([])}).finally(()=>{e||X(!1)}),()=>{e=!0}},[W]);let es=(e,t)=>{G(n=>n?{...n,properties:{...n.properties,[e]:t}}:null)},ei=e=>{G(t=>{if(!t)return null;let n={...t.properties};return delete n[e],{...t,properties:n}})},ed=K.filter(e=>e.id!==O),ec=(0,tC.E)("flows",ed);if(!L||!U)return null;let eu=(null==(t=U.properties)?void 0:t.subflowId)||"",ep=!!eu&&!K.some(e=>e.id===eu),eh=ep?"":(null==(n=K.find(e=>e.id===eu))?void 0:n.name)||"",em=Array.isArray(null==(l=U.properties)?void 0:l.parallelSubflowIds)?U.properties.parallelSubflowIds.filter(e=>"string"==typeof e&&""!==e):[],ef=em.map(e=>{var t;return(null==(t=K.find(t=>t.id===e))?void 0:t.name)||e}),eg="string"==typeof(null==(a=U.properties)?void 0:a.parallelSubflowIdsVar)?U.properties.parallelSubflowIdsVar.trim():"",ex=(null==(c=U.properties)?void 0:c.mapOverList)===!0,ev=!!(null==(p=U.properties)?void 0:p.allowCallerFanout),eb=J.split("\n").some(e=>""!==e.trim()),ew=ev||eb||em.length>0||!!eg||ex,ey=em.length>0,ej=ev||eb,eA=!ey&&!eg&&!ej,eC=!ex&&!ey,eS=(null==(h=U.properties)?void 0:h.promptTemplate)||"",ek=(null==(v=U.properties)?void 0:v.inputMode)||(eS.trim()?"isolated":"full-history");return(0,r.jsxs)(f.A,{open:W,onClose:D,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"warning.main",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,r.jsx)(g.A,{component:"div",children:(0,r.jsxs)(s.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,r.jsxs)(i.A,{variant:"h6",children:[U.label||"Subflow Node"," Properties"]}),(0,r.jsx)(u.A,{edge:"end",color:"inherit",onClick:D,"aria-label":"close",children:(0,r.jsx)(tu.A,{})})]})}),(0,r.jsx)(R.A,{}),(0,r.jsxs)(x.A,{sx:{p:3},children:[(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"This step runs another flow inside this one — like calling a helper. When it finishes, its answer becomes part of this conversation and the flow continues to the next node."}),(0,r.jsx)(b.A,{fullWidth:!0,label:"Node Label",value:U.label||"",onChange:e=>G({...U,label:e.target.value}),margin:"normal"}),(0,r.jsxs)(s.default,{sx:{mt:2},children:[(0,r.jsx)(i.A,{variant:"subtitle2",sx:{mb:1},children:"Flow to run"}),(0,r.jsx)(d.A,{variant:"outlined",startIcon:(0,r.jsx)(na.A,{}),onClick:()=>q(!0),sx:{textTransform:"none",maxWidth:"100%"},children:(0,r.jsx)(s.default,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:eh||(em.length>0?"Parallel fan-out: ".concat(em.length," flows"):eg?"Fan-out targets from ${var:".concat(eg,"}"):"Choose a flow…")})})]}),ep&&(0,r.jsx)(m.A,{severity:"warning",sx:{mt:1},children:"The previously selected flow no longer exists. Please choose another."}),em.length>0&&(0,r.jsx)(m.A,{severity:"info",sx:{mt:1},children:"This node runs ".concat(em.length," flows in parallel and merges their results: ").concat(ef.join(", "),". (Configured via the flow API.)")}),(0,r.jsx)(tz.A,{open:Y,onClose:()=>q(!1),title:"Choose a flow to run",description:"This subflow node will run the selected flow as a helper.",isLoading:_,skeleton:(0,r.jsx)(ns.o,{}),emptyMessage:"No other flows available. Create another flow first.",searchable:!0,searchPlaceholder:"Search flows…",searchTerm:ec.searchTerm,onSearchChange:ec.setSearchTerm,items:ec.items.map(e=>({key:e.id,content:(0,r.jsx)(ns.A,{flow:e,selected:e.id===eu,onSelect:e=>{es("subflowId",e),q(!1)},pickerMode:!0})})),groups:ec.groups?ec.groups.map(e=>({...e,items:e.items.map(e=>({key:e.id,content:(0,r.jsx)(ns.A,{flow:e,selected:e.id===eu,onSelect:e=>{es("subflowId",e),q(!1)},pickerMode:!0})}))})):null,collapsedKeys:ec.collapsedKeys,onToggleGroup:ec.toggleGroup}),"guided"===V&&(0,r.jsx)(b.A,{fullWidth:!0,label:"What should this helper do?",value:U.description||"",onChange:e=>G({...U,description:e.target.value}),margin:"normal",multiline:!0,minRows:2,helperText:"This instruction is used when another step hands work to the helper flow."}),"advanced"===V&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.A,{variant:"subtitle2",sx:{mt:3,mb:1},children:"What does the subflow receive?"}),(0,r.jsxs)(s.default,{role:"radiogroup","aria-label":"Subflow input",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,r.jsx)(t0,{selected:"full-history"===ek,onClick:()=>es("inputMode","full-history"),icon:(0,r.jsx)(tY,{}),title:"Full conversation",description:"The subflow sees the whole conversation so far, minus tool plumbing (system messages, tool calls and tool results are always stripped). Best for a helper that should continue with all the context."}),(0,r.jsx)(t0,{selected:"latest-message"===ek,onClick:()=>es("inputMode","latest-message"),icon:(0,r.jsx)(tq,{}),title:"Latest message only",description:"The subflow sees the conversation from the most recent user message onward (not just one message), with tool plumbing stripped. Best for an orchestrator that hands off one task at a time, so old tasks don't leak in."}),(0,r.jsx)(t0,{selected:"isolated"===ek,onClick:()=>es("inputMode","isolated"),icon:(0,r.jsx)(tJ,{}),title:"Isolated",description:"The conversation is ignored. The subflow receives only the prompt you write below, as its first message."})]}),"isolated"===ek&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F.A,{sx:{mt:1,display:"block"},control:(0,r.jsx)(ts.A,{checked:(null==(y=U.properties)?void 0:y.allowCallerPrompt)!==!1,onChange:e=>es("allowCallerPrompt",e.target.checked)}),label:"Let the caller pass a prompt"}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mb:1,ml:4,mt:-.5},children:"When on, a step that routes to this subflow can attach an instruction through its handoff tool, overriding the prompt below. The prompt below is then used only as a default when the caller sends none."}),(0,r.jsx)(b.A,{fullWidth:!0,label:(null==(j=U.properties)?void 0:j.allowCallerPrompt)!==!1?"Default prompt (used if the caller sends none)":"Isolated prompt",value:eS,onChange:e=>es("promptTemplate",e.target.value),margin:"normal",multiline:!0,rows:3,helperText:(null==(A=U.properties)?void 0:A.allowCallerPrompt)!==!1?"The default first message for the subflow. A routing model may override it via the handoff tool. The parent conversation is not passed.":"Sent to the subflow as its single user message. The parent conversation is not passed."})]}),(0,r.jsx)(i.A,{variant:"subtitle2",sx:{mt:3,mb:1},children:"Dynamic fan-out"}),(0,r.jsx)(b.A,{fullWidth:!0,label:"Parallel flows from run variable",value:eg,disabled:!eC,onChange:e=>{let t=e.target.value.trim();t?es("parallelSubflowIdsVar",t):ei("parallelSubflowIdsVar")},margin:"normal",helperText:eC?"Enter a run-variable NAME only (no ${…}); it resolves at runtime to the list of flow ids to run in parallel.":ex?"Disabled while “map over list” is on — a node can’t do both.":"Disabled while a static parallel list is configured via the flow API."}),(0,r.jsx)(F.A,{sx:{display:"block",mt:1},control:(0,r.jsx)(ts.A,{checked:ex,disabled:!eA&&!ex,onChange:e=>{e.target.checked?es("mapOverList",!0):G(e=>{if(!e)return null;let{mapOverList:t,itemSplit:n,sequential:r,...o}=e.properties;return{...e,properties:o}})}}),label:"Run the selected flow once per input item (map over list)"}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mb:1,ml:4,mt:-.5},children:eA||ex?"When on, the node parses its input into a list and runs the single selected flow once per item, merging the results.":"Disabled: map-over-list needs a single selected flow and can’t combine with parallel or spawning modes."}),ex&&(0,r.jsxs)(s.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center",ml:4,mt:1},children:[(0,r.jsxs)(b.A,{label:"Split input as",select:!0,size:"small",sx:{width:240},value:(null==(C=U.properties)?void 0:C.itemSplit)==="lines"?"lines":"json-array",onChange:e=>{"lines"===e.target.value?es("itemSplit","lines"):ei("itemSplit")},helperText:"How the input is parsed into items",children:[(0,r.jsx)(z.A,{value:"json-array",children:"JSON array (default)"}),(0,r.jsx)(z.A,{value:"lines",children:"Lines"})]}),(0,r.jsx)(F.A,{control:(0,r.jsx)(ts.A,{checked:(null==(S=U.properties)?void 0:S.sequential)===!0,onChange:e=>{e.target.checked?es("sequential",!0):ei("sequential")}}),label:"Run items one at a time (ignores max copies)"})]}),(0,r.jsx)(i.A,{variant:"subtitle2",sx:{mt:3,mb:1},children:"Parallel workers (spawning)"}),(0,r.jsx)(F.A,{sx:{display:"block"},control:(0,r.jsx)(ts.A,{checked:ev,onChange:e=>es("allowCallerFanout",e.target.checked)}),label:"Let the caller spawn parallel copies of this sub-agent"}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{mb:1,ml:4,mt:-.5},children:"When on, the step that hands off here may call this node's handoff tool several times in one reply — each call runs one parallel copy of the selected flow with its own task brief. The copies run concurrently; their results are merged in order and the flow continues once all of them finish."}),(0,r.jsx)(b.A,{fullWidth:!0,label:"Always spawn these briefs (one per line, optional)",value:J,onChange:e=>Z(e.target.value),margin:"normal",multiline:!0,minRows:2,helperText:"When set, every visit runs one parallel copy of the selected flow per line — no caller needed. Caller-passed tasks (above) override this list for that visit. Supports ${var:NAME}, ${res:NAME} and ${kv:NAME}."}),ew&&(0,r.jsxs)(s.default,{sx:{display:"flex",gap:2,flexWrap:"wrap",mt:1},children:[(0,r.jsx)(b.A,{label:"Max copies at once",type:"number",size:"small",sx:{width:160},value:"number"==typeof(null==(k=U.properties)?void 0:k.concurrencyLimit)?U.properties.concurrencyLimit:"",onChange:e=>{let t=e.target.value;if(""===t)G(e=>{if(!e)return null;let{concurrencyLimit:t,...n}=e.properties;return{...e,properties:n}});else{let e=Math.max(1,Math.floor(Number(t)));Number.isNaN(e)||es("concurrencyLimit",e)}},helperText:"Default 4"}),(0,r.jsxs)(b.A,{label:"Error handling",select:!0,size:"small",sx:{width:220},value:(null==(T=U.properties)?void 0:T.errorStrategy)==="fail-fast"?"fail-fast":"collect-all",onChange:e=>es("errorStrategy",e.target.value),helperText:"What happens if a copy fails",children:[(0,r.jsx)(z.A,{value:"collect-all",children:"Collect all (note failures, continue)"}),(0,r.jsx)(z.A,{value:"fail-fast",children:"Fail fast (first failure stops the node)"})]}),(0,r.jsx)(b.A,{label:"Separator between merged results",size:"small",sx:{width:260},multiline:!0,maxRows:2,value:"string"==typeof(null==(I=U.properties)?void 0:I.joinSeparator)?U.properties.joinSeparator:"",onChange:e=>{let t=e.target.value;""===t?G(e=>{if(!e)return null;let{joinSeparator:t,...n}=e.properties;return{...e,properties:n}}):es("joinSeparator",t)},helperText:"Empty = blank line"})]}),(0,r.jsx)(i.A,{variant:"subtitle2",sx:{mt:3,mb:1},children:"What do you see in the chat while the subflow runs?"}),(0,r.jsxs)(s.default,{role:"radiogroup","aria-label":"Subflow output",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,r.jsx)(t0,{selected:"final-only"!==((null==(M=U.properties)?void 0:M.outputMode)||"steps"),onClick:()=>es("outputMode","steps"),icon:(0,r.jsx)(tZ.A,{}),title:"Full",description:"You see all of the subflow's messages in the chat, indented under this step — like watching it work."}),(0,r.jsx)(t0,{selected:(null==(N=U.properties)?void 0:N.outputMode)==="final-only",onClick:()=>es("outputMode","final-only"),icon:(0,r.jsx)(tQ,{}),title:"Condensed",description:"You only see the subflow's final answer as a single message. Its inner steps stay hidden."})]}),(0,r.jsx)(i.A,{variant:"subtitle2",sx:{mt:3,mb:1},children:"Debugging"}),(0,r.jsx)(F.A,{sx:{display:"block"},control:(0,r.jsx)(P.A,{checked:(null==(E=U.properties)?void 0:E.saveConversation)!==!1,onChange:e=>es("saveConversation",e.target.checked)}),label:"Save this subflow's conversation to the sidebar (useful for debugging)"}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",sx:{ml:4,mt:-.5},children:'When on, each run of this subflow is persisted as its own conversation in the chat sidebar, linked to the parent run — like a planned execution\'s "Save full conversations". Parallel copies each get their own conversation, titled by their brief.'}),(0,r.jsx)(R.A,{sx:{my:3}}),(0,r.jsx)(t5,{value:{captureVariable:Q,captureResource:et,captureKvScope:er,captureKvKey:el},onChange:e=>{void 0!==e.captureVariable&&ee(e.captureVariable),void 0!==e.captureResource&&en(e.captureResource),void 0!==e.captureKvScope&&eo(e.captureKvScope),void 0!==e.captureKvKey&&ea(e.captureKvKey)}})]})]}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:D,children:"Cancel"}),(0,r.jsx)(d.A,{onClick:()=>{if(L&&U){if("guided"===V){B(L.id,U),D();return}let e=J.split("\n").map(e=>e.trim()).filter(e=>""!==e),t={...U.properties};e.length>0?t.spawnBriefs=e:delete t.spawnBriefs;let n=Q.trim();n?t.captureVariable=n:delete t.captureVariable;let r=et.trim();r?t.captureResource=r:delete t.captureResource;let o=ez(er,el);o?t.captureKv=o:delete t.captureKv,B(L.id,{...U,properties:t}),D()}},variant:"contained",color:"primary",children:"Save"})]})]})};var nc=n(43861),nu=n(75656),np=n(98286),nh=n(32683);let nm=(0,W.h)("frontend/components/Flow/FlowManager/FlowBuilder/Modals/ResourceNodePropertiesModal"),nf=e=>{var t,n,l,a,c;let{open:u,node:p,onClose:m,onSave:v,flowNodes:y}=e,[j,A]=(0,o.useState)(null),{servers:C,isLoading:S}=(0,tf.v)(),[k,T]=(0,o.useState)([]),[I,M]=(0,o.useState)(!1),[P,R]=(0,o.useState)(null),[E,W]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(p){A({...p.data,properties:{scope:"run",...p.data.properties}});let e=!!p.data.label&&"Resource Node"!==p.data.label.trim(),t=!!p.data.description&&p.data.description.trim().length>0;W(e||t)}},[p,u]);let L=(null==j||null==(t=j.properties)?void 0:t.scope)==="mcp"?"mcp":"run",D=(null==j||null==(n=j.properties)?void 0:n.boundServer)||"",H=(null==j||null==(l=j.properties)?void 0:l.uri)||"",O=(null==j||null==(a=j.properties)?void 0:a.runName)||"",V=(0,o.useMemo)(()=>{let e=(null!=y?y:[]).filter(e=>e.id!==(null==p?void 0:p.id)).map(e=>{try{var t,n;return JSON.stringify(null!=(n=null==(t=e.data)?void 0:t.properties)?n:{})}catch(e){return""}});return(0,tp.jX)(e)},[y,null==p?void 0:p.id]),U=(0,o.useCallback)((e,t)=>{A(n=>n?{...n,properties:{...n.properties,[e]:t}}:n)},[]);(0,o.useEffect)(()=>{if(!u||"mcp"!==L||!D){T([]),R(null);return}let e=!1;return M(!0),R(null),B.S.listServerResources(D).then(t=>{if(!e)if(t.error)R(t.error),T([]);else{var n,r;T([...(null!=(n=t.resources)?n:[]).map(e=>({uri:e.uri,name:e.name,description:e.description,mimeType:e.mimeType})),...(null!=(r=t.resourceTemplates)?r:[]).map(e=>({uri:e.uriTemplate,name:e.name?"".concat(e.name," (template)"):"(template)",description:e.description}))])}}).catch(t=>{e||(nm.warn("Failed to browse resources of ".concat(D),t),R(t instanceof Error?t.message:String(t)))}).finally(()=>{e||M(!1)}),()=>{e=!0}},[u,L,D]);let G="run"===L&&!!O.trim()&&!eF(O.trim());return j?(0,r.jsxs)(f.A,{open:u,onClose:m,maxWidth:"sm",fullWidth:!0,children:[(0,r.jsx)(g.A,{children:"Resource Node Properties"}),(0,r.jsx)(x.A,{children:(0,r.jsxs)(s.default,{display:"flex",flexDirection:"column",gap:2,mt:1,children:[(0,r.jsxs)(e3.A,{children:[(0,r.jsxs)(nc.A,{row:!0,value:L,onChange:e=>U("scope","mcp"===e.target.value?"mcp":"run"),children:[(0,r.jsx)(F.A,{value:"run",control:(0,r.jsx)(nu.A,{}),label:"Temporary Data"}),(0,r.jsx)(F.A,{value:"mcp",control:(0,r.jsx)(nu.A,{}),label:"MCP resource"})]}),(0,r.jsx)(tw.A,{children:"mcp"===L?"A static resource published by an MCP server. Steps connected FROM this node receive its contents.":"A named piece of run data: a step writing INTO this node saves its output here; steps reading FROM it receive the latest value (also available as ${res:NAME})."})]}),"mcp"===L?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(e3.A,{fullWidth:!0,children:[(0,r.jsx)(e9.A,{id:"resource-server-label",children:"Server"}),(0,r.jsxs)(e6.A,{labelId:"resource-server-label",label:"Server",value:D,onChange:e=>{U("boundServer",e.target.value)},children:[S&&(0,r.jsx)(z.A,{value:"",disabled:!0,children:"Loading servers…"}),C.map(e=>(0,r.jsx)(z.A,{value:e.name,children:e.name},e.name))]})]}),(0,r.jsx)(b.A,{label:"Resource URI",value:H,onChange:e=>U("uri",e.target.value),fullWidth:!0,placeholder:"e.g. file:///data/report.md",helperText:"Pick from the list below or paste a URI / filled-in template."}),I&&(0,r.jsxs)(s.default,{display:"flex",alignItems:"center",gap:1,children:[(0,r.jsx)(N.default,{size:18}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",children:"Loading resources…"})]}),P&&(0,r.jsxs)(i.A,{variant:"body2",color:"warning.main",children:["Could not list resources: ",P]}),!I&&!P&&D&&0===k.length&&(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",children:"This server publishes no resources (you can still paste a URI above)."}),k.length>0&&(0,r.jsx)(eb.A,{dense:!0,sx:{maxHeight:240,overflow:"auto",border:1,borderColor:"divider",borderRadius:1},children:k.map(e=>(0,r.jsxs)(ej.A,{selected:e.uri===H,onClick:()=>U("uri",e.uri),children:[(0,r.jsx)(ew.A,{sx:{minWidth:34},children:(0,r.jsx)(en.A,{fontSize:"small",sx:{color:"#009688"}})}),(0,r.jsx)(ey.A,{primary:e.name||e.uri,secondary:e.name?e.uri:e.description,secondaryTypographyProps:{sx:{wordBreak:"break-all"}}})]},e.uri))})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(np.A,{freeSolo:!0,options:V,inputValue:O,onInputChange:(e,t)=>U("runName",t),renderInput:e=>(0,r.jsx)(b.A,{...e,label:"Temporary Data name",fullWidth:!0,error:G,helperText:G?"Letters, digits, _ and - only; must not start with a digit.":V.length>0?"Steps reference it as ${res:NAME}. Suggestions are names already used in this flow.":"Steps reference it as ${res:NAME}; a producing edge saves the step output under this name."})}),O.trim()&&!G&&(0,r.jsxs)(i.A,{variant:"caption",color:"text.secondary",children:['URI at run time: flujo://run/<conversation>/… (named "',O.trim(),'")']})]}),(0,r.jsx)(nh.A,{component:"button",type:"button",underline:"hover",onClick:()=>W(e=>!e),sx:{alignSelf:"flex-start"},children:E?"Hide advanced":"Advanced — name & description"}),(0,r.jsx)(h.A,{in:E,unmountOnExit:!0,children:(0,r.jsxs)(s.default,{display:"flex",flexDirection:"column",gap:2,children:[(0,r.jsx)(b.A,{label:"Label",value:j.label,onChange:e=>A({...j,label:e.target.value}),fullWidth:!0,helperText:"Optional. The node's name on the canvas; defaults to the Temporary Data name."}),(0,r.jsx)(b.A,{label:"Description",value:null!=(c=j.description)?c:"",onChange:e=>A({...j,description:e.target.value}),fullWidth:!0,multiline:!0,minRows:2})]})})]})}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:m,children:"Cancel"}),(0,r.jsx)(d.A,{onClick:()=>{var e;if(!p||!j)return;let t={...j.properties};"run"===L?(delete t.boundServer,delete t.uri,delete t.mimeType,t.scope="run",t.runName=O.trim()):(delete t.runName,t.scope="mcp");let n=(null!=(e=j.label)?e:"").trim()||("run"===L?O.trim()||"Temporary Data":"MCP resource");v(p.id,{...j,label:n,properties:t})},variant:"contained",children:"Save"})]})]}):null},ng=e=>{var t,n,l,a;let{open:i,node:c,onClose:u,onSave:p}=e,[v,y]=(0,o.useState)(null),[j,A]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(c){var e;y({...c.data,properties:{...c.data.properties}}),A(!!(null==(e=c.data.properties)?void 0:e.payloadTemplate))}},[c,i]);let C=(e,t)=>{y(n=>n?{...n,properties:{...n.properties,[e]:t}}:n)};if(!v)return null;let S=null!=(l=null==(t=v.properties)?void 0:t.topic)?l:"",k=null!=(a=null==(n=v.properties)?void 0:n.payloadTemplate)?a:"";return(0,r.jsxs)(f.A,{open:i,onClose:u,maxWidth:"sm",fullWidth:!0,children:[(0,r.jsx)(g.A,{children:"Signal Node"}),(0,r.jsx)(x.A,{children:(0,r.jsxs)(s.default,{display:"flex",flexDirection:"column",gap:2,mt:1,children:[(0,r.jsx)(b.A,{label:"Signal Name (topic)",value:S,onChange:e=>C("topic",e.target.value),fullWidth:!0,required:!0,autoFocus:!0,error:!S.trim(),placeholder:"e.g. review-blocked",helperText:S.trim()?"A free-form shared name (no registry). A planned execution reacts to it via a flow-event trigger with this signal name. This is also the node’s display name.":"A signal name is required — a flow-event trigger listens for this exact name."}),(0,r.jsx)(m.A,{severity:"info",children:"When execution reaches this node it emits the signal and continues immediately (fire-and-forget). To emit conditionally, put a conditioned edge into this node. Runaway signal chains are bounded by the trigger’s max chain depth."}),(0,r.jsx)(nh.A,{component:"button",type:"button",underline:"hover",onClick:()=>A(e=>!e),sx:{alignSelf:"flex-start"},children:j?"Hide advanced":"Advanced — optional payload"}),(0,r.jsx)(h.A,{in:j,unmountOnExit:!0,children:(0,r.jsx)(b.A,{label:"Payload template (optional)",value:k,onChange:e=>C("payloadTemplate",e.target.value),fullWidth:!0,multiline:!0,minRows:3,placeholder:"e.g. Review found blockers: ${var:reviewSummary}",helperText:"Optional. Emitted as the signal payload and handed to the triggered flow. ${var:NAME} is resolved from run variables at emit time."})})]})}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:u,children:"Cancel"}),(0,r.jsx)(d.A,{onClick:()=>{if(!c||!v)return;let e={...v.properties},t="string"==typeof e.topic?e.topic.trim():"";e.topic=t;let n=t||"Signal";p(c.id,{...v,label:n,properties:e})},variant:"contained",children:"Save"})]})]})};var nx=n(26922),nv=n(40520),nb=n(79299),nw=n(22590),ny=n(53657),nj=n(7107),nA=n(93632),nC=n(23143),nS=n(84765),nk=n(43673),nT=n(21997),nI=n(80811),nM=n(14368),nN=n(23833);let nF=(0,W.h)("frontend/components/FlowBuilder/Modals/TriggerNodePropertiesModal"),nP={type:"schedule",cron:"0 9 * * *"},nR={type:"file-watch",path:"",events:["add","change"]},nE={type:"mcp-poll",serverName:"",toolName:"",args:{},cron:"*/5 * * * *",evaluate:{mode:"on-change"}},nz={type:"url-watch",url:"",cron:"*/15 * * * *"},nW={type:"flow-event",source:{flowId:""},on:["completed"]},nL=e=>{let{open:t,node:n,flowId:l,onClose:a,onSave:c}=e,[p,h]=(0,o.useState)("Flow Trigger"),[v,y]=(0,o.useState)(!0),[j,A]=(0,o.useState)(nP),[C,S]=(0,o.useState)("skip"),[k,T]=(0,o.useState)(""),[I,M]=(0,o.useState)(!1),[E,W]=(0,o.useState)(null),[L,D]=(0,o.useState)([]),[B,O]=(0,o.useState)(()=>crypto.randomUUID()),[V,U]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(!t||!n)return;W(null);let e=n.data.properties||{};h("string"==typeof e.name?e.name:"Flow Trigger"),y(!1!==e.enabled),A(e.trigger||nP),S(e.overlapStrategy||"skip"),T("string"==typeof e.prompt?e.prompt:""),"string"==typeof e.executionId&&e.executionId?(O(e.executionId),U(!0)):(O(crypto.randomUUID()),U(!1))},[t,n]),(0,o.useEffect)(()=>{if(!t)return;let e=!1;return H.g.loadFlows().then(t=>{e||D(t||[])}).catch(()=>{e||D([])}),()=>{e=!0}},[t]);let G=(0,o.useCallback)(async()=>{if(!n)return;M(!0),W(null);let e={name:p.trim()||"Flow Trigger",flowId:l,prompt:k,overlapStrategy:C,trigger:j,enabled:v};try{let t;if(!(t=V?await nA.P.update(B,e):await nA.P.create({...e,id:B})).success){W(t.error||"Failed to save trigger configuration"),M(!1);return}U(!0);let r=p.trim()||"Trigger";c(n.id,{...n.data,label:r,type:"trigger",properties:{executionId:B,name:p,enabled:v,trigger:j,overlapStrategy:C,prompt:k}})}catch(e){W(e instanceof Error?e.message:"Failed to save trigger configuration"),M(!1);return}M(!1),nF.info("TriggerNodePropertiesModal: Saved trigger node for executionId=".concat(B))},[n,B,p,v,j,C,k,l,V,c]);return n?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(f.A,{open:t,onClose:a,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderTop:5,borderColor:"#E91E63",maxWidth:"95vw",maxHeight:"90vh"}},children:[(0,r.jsx)(g.A,{component:"div",children:(0,r.jsxs)(s.default,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[(0,r.jsx)(i.A,{variant:"h6",children:"Trigger Node"}),(0,r.jsx)(u.A,{edge:"end",color:"inherit",onClick:a,"aria-label":"close",children:(0,r.jsx)(tu.A,{})})]})}),(0,r.jsx)(R.A,{}),(0,r.jsxs)(x.A,{sx:{p:3},children:[(0,r.jsxs)(m.A,{severity:"info",sx:{mb:2},children:["This node links a planned execution trigger to this flow. When the trigger fires, the flow will run headlessly. Configure the trigger below.",!V&&(0,r.jsx)(r.Fragment,{children:" The trigger will be created when you first save."})]}),(0,r.jsx)(b.A,{fullWidth:!0,label:"Trigger name",value:p,onChange:e=>h(e.target.value),margin:"normal",placeholder:"e.g. Daily digest trigger"}),(0,r.jsx)(F.A,{control:(0,r.jsx)(P.A,{checked:v,onChange:e=>y(e.target.checked),color:"primary"}),label:"Enabled",sx:{mt:1,mb:1}}),(0,r.jsx)(i.A,{variant:"subtitle1",sx:{mt:2,mb:1,fontWeight:600},children:"When should it run?"}),(0,r.jsxs)(s.default,{role:"radiogroup","aria-label":"Trigger type",sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[(0,r.jsx)(nC.A,{selected:"schedule"===j.type,onClick:()=>{"schedule"!==j.type&&A(nP)},icon:(0,r.jsx)(nx.A,{}),title:"On a schedule",description:"Run at fixed times — every few minutes, daily, on weekdays, or a custom rhythm."}),(0,r.jsx)(nC.A,{selected:"webhook"===j.type,onClick:()=>{"webhook"!==j.type&&A({type:"webhook",token:crypto.randomUUID()})},icon:(0,r.jsx)(nv.A,{}),title:"When called (webhook)",description:"Other apps run this flow by calling a URL."}),(0,r.jsx)(nC.A,{selected:"file-watch"===j.type,onClick:()=>{"file-watch"!==j.type&&A(nR)},icon:(0,r.jsx)(nb.A,{}),title:"When files change",description:"Watch a folder on this computer and run when files appear, change, or disappear."}),(0,r.jsx)(nC.A,{selected:"mcp-poll"===j.type,onClick:()=>{"mcp-poll"!==j.type&&A(nE)},icon:(0,r.jsx)(nw.A,{}),title:"Watch a tool",description:"Check one of your MCP tools regularly — run when its result changes."}),(0,r.jsx)(nC.A,{selected:"url-watch"===j.type,onClick:()=>{"url-watch"!==j.type&&A(nz)},icon:(0,r.jsx)(ny.A,{}),title:"When a website changes",description:"Check a URL regularly and run when its content is different from the last check."}),(0,r.jsx)(nC.A,{selected:"flow-event"===j.type,onClick:()=>{"flow-event"!==j.type&&A(nW)},icon:(0,r.jsx)(nj.A,{}),title:"When another flow finishes",description:"React to another flow completing or erroring."})]}),"schedule"===j.type&&(0,r.jsx)(nS.A,{cron:j.cron,timezone:j.timezone,onChange:e=>{let{cron:t,timezone:n}=e;return A({...j,cron:t,timezone:n})},catchUp:!0===j.catchUp,onCatchUpChange:e=>A({...j,catchUp:e})}),"webhook"===j.type&&(0,r.jsx)(nk.A,{config:j,onChange:A,executionId:B,saved:V}),"file-watch"===j.type&&(0,r.jsx)(nT.A,{config:j,onChange:A}),"mcp-poll"===j.type&&(0,r.jsx)(nI.A,{config:j,onChange:A}),"url-watch"===j.type&&(0,r.jsx)(nM.A,{config:j,onChange:A}),"flow-event"===j.type&&(0,r.jsx)(nN.A,{config:j,onChange:A,flows:L,currentExecutionId:B}),(0,r.jsxs)(e3.A,{fullWidth:!0,margin:"normal",children:[(0,r.jsx)(e9.A,{id:"overlap-strategy-label",children:"If it's already running…"}),(0,r.jsxs)(e6.A,{labelId:"overlap-strategy-label",label:"If it's already running…",value:C,onChange:e=>S(e.target.value),children:[(0,r.jsx)(z.A,{value:"skip",children:"Skip the new run (default)"}),(0,r.jsx)(z.A,{value:"queue",children:"Queue it — run after the current one finishes"}),(0,r.jsx)(z.A,{value:"parallel",children:"Run in parallel — allow concurrent runs"}),(0,r.jsx)(z.A,{value:"error",children:"Reject the new run with an error"})]})]}),(0,r.jsx)(b.A,{fullWidth:!0,label:"Initial prompt (optional)",value:k,onChange:e=>T(e.target.value),margin:"normal",multiline:!0,minRows:2,placeholder:"Optional prompt override for the triggered run",helperText:"Leave blank to use the flow's default prompt. When set, this overrides the Start node prompt template for runs fired by this trigger."}),E&&(0,r.jsx)(m.A,{severity:"error",sx:{mt:2},children:E})]}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:a,disabled:I,children:"Cancel"}),(0,r.jsx)(d.A,{onClick:G,variant:"contained",disabled:I,startIcon:I?(0,r.jsx)(N.default,{size:16}):void 0,sx:{backgroundColor:"#E91E63","&:hover":{backgroundColor:"#C2185B"}},children:I?"Saving…":"Save"})]})]})}):null};var nD=n(50291),nH=n(76122);let nB=e=>{let{flow:t}=e,n=(0,a.A)(),l=(0,o.useMemo)(()=>(t.edges||[]).filter(e=>e.source&&e.target&&e.sourceHandle&&e.targetHandle),[t.edges]),s=(0,o.useMemo)(()=>({type:"custom",animated:!1,style:{stroke:n.palette.text.secondary,strokeWidth:2},markerEnd:{type:nH.TG.ArrowClosed,width:20,height:20,color:n.palette.text.secondary}}),[n.palette.text.secondary]);return(0,r.jsx)(L.Gc,{nodes:t.nodes||[],edges:l,nodeTypes:q.c_,edgeTypes:q.nd,defaultEdgeOptions:s,connectionLineType:nH.Do.SmoothStep,fitView:!0,minZoom:.1,maxZoom:2,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,deleteKeyCode:null,proOptions:{hideAttribution:!0},children:(0,r.jsx)(L.VS,{})})},nO=e=>(0,r.jsx)(L.Ln,{children:(0,r.jsx)(nB,{...e})}),nV=(0,W.h)("components/flow/FlowBuilder/Modals/FlowVersionHistoryDialog"),nU=e=>{let{open:t,flowId:n,onClose:l,onRestore:a}=e,[c,u]=(0,o.useState)(!1),[p,h]=(0,o.useState)([]),[m,v]=(0,o.useState)(null),[b,y]=(0,o.useState)(!1),[j,A]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!t||!n)return;let e=!1;return u(!0),h([]),v(null),A(null),H.g.listFlowVersions(n).then(t=>{e||h(t)}).finally(()=>{e||u(!1)}),()=>{e=!0}},[t,n]);let C=(0,o.useCallback)(e=>{n&&(v(e),y(!0),A(null),H.g.getFlowVersion(n,e).then(t=>{t?A(t.flow):nV.warn("Version ".concat(e," could not be loaded (pruned?)"))}).finally(()=>y(!1)))},[n]),S=(0,o.useCallback)(()=>{j&&a(j)},[j,a]);return(0,r.jsxs)(f.A,{open:t,onClose:l,maxWidth:"lg",fullWidth:!0,children:[(0,r.jsx)(g.A,{children:"Version History"}),(0,r.jsx)(x.A,{dividers:!0,sx:{p:0},children:(0,r.jsxs)(s.default,{sx:{display:"flex",height:"65vh"},children:[(0,r.jsx)(s.default,{sx:{width:300,borderRight:1,borderColor:"divider",overflowY:"auto"},children:c?(0,r.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",p:4},children:(0,r.jsx)(N.default,{size:28})}):0===p.length?(0,r.jsx)(s.default,{sx:{p:3},children:(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",children:"No saved versions yet. A version is archived automatically each time you save a change to this flow."})}):(0,r.jsx)(eb.A,{disablePadding:!0,children:p.map((e,t)=>(0,r.jsxs)(o.Fragment,{children:[(0,r.jsx)(ej.A,{selected:e.versionId===m,onClick:()=>C(e.versionId),children:(0,r.jsx)(ey.A,{primary:(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(i.A,{variant:"body2",children:function(e){try{return new Date(e).toLocaleString()}catch(t){return String(e)}}(e.savedAt)}),0===t&&(0,r.jsx)(M.A,{label:"most recent",size:"small"})]}),secondary:"".concat(e.nodeCount," node").concat(1===e.nodeCount?"":"s"," \xb7 ").concat(e.edgeCount," edge").concat(1===e.edgeCount?"":"s")})}),(0,r.jsx)(R.A,{component:"li"})]},e.versionId))})}),(0,r.jsx)(s.default,{sx:{flex:1,position:"relative",minWidth:0},children:b?(0,r.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,r.jsx)(N.default,{size:32})}):j?(0,r.jsx)(nO,{flow:j}):(0,r.jsx)(s.default,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",p:4},children:(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",align:"center",children:0===p.length?"Versions appear here after you save changes.":"Select a version on the left to preview it."})})})]})}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:l,children:"Close"}),(0,r.jsx)(d.A,{variant:"contained",color:"primary",startIcon:(0,r.jsx)(nD.A,{}),onClick:S,disabled:!j,children:"Restore this version"})]})]})},nG=e=>{var t;return(null==(t=e.data)?void 0:t.bidirectional)===!0},nK=e=>!(0,U.BY)(e),n$=e=>{var t,n,r;return String(null!=(r=null!=(n=null==e?void 0:e.type)?n:null==e||null==(t=e.data)?void 0:t.type)?r:"")},n_=e=>{var t,n,r;return String(null!=(r=null!=(n=null==e||null==(t=e.data)?void 0:t.label)?n:null==e?void 0:e.id)?r:"Unknown node")};function nX(e,t,n,r,o,l){if(l){var a;return{...l,id:e,source:t,target:n,sourceHandle:r,targetHandle:o,data:{...null!=(a=l.data)?a:{},edgeType:"standard",bidirectional:!1},markerStart:void 0}}return{id:e,source:t,target:n,sourceHandle:r,targetHandle:o,type:"custom",animated:!0,data:{edgeType:"standard"}}}function nY(e){let{open:t,processNodeId:n,parentFlow:l,existingFlowNames:a,onClose:c,onAccept:u}=e,[p,h]=(0,o.useState)(""),[y,j]=(0,o.useState)(null),[A,C]=(0,o.useState)(!1),[S,k]=(0,o.useState)(null);(0,o.useEffect)(()=>{var e;if(!t)return;let r=l.nodes.find(e=>e.id===n);h("".concat(String((null==r||null==(e=r.data)?void 0:e.label)||"Process").replace(/[^\w-]+/g,"_"),"_subflow")),j(null),C(!1),k(null)},[t,n,l.nodes]);let T=()=>{n&&(k(null),j(function(e){var t,n;let{parentFlow:r,processNodeId:o,subflowName:l,existingFlowNames:a=[],createId:s=D.A}=e,i=[],d=[],c=null!=(t=r.nodes)?t:[],u=null!=(n=r.edges)?n:[],p=new Map(c.map(e=>[e.id,e])),h=p.get(o),m=l.trim();h&&"process"===n$(h)||i.push({code:"target-not-process",message:"The selected node no longer exists or is not a Process node.",nodeId:o}),m?/^[\w-]+$/.test(m)?a.some(e=>e.toLowerCase()===m.toLowerCase())&&i.push({code:"duplicate-name",message:'A flow named "'.concat(m,'" already exists.')}):i.push({code:"invalid-name",message:"The subflow name may contain only letters, numbers, underscores, and dashes."}):i.push({code:"name-required",message:"Enter a name for the new subflow."});let f=new Set;h&&f.add(h.id);let g=h?[h.id]:[];for(;g.length>0;){let e=g.shift();for(let t of u){if(!nK(t))continue;let n=[];for(let r of(t.source===e&&n.push(t.target),nG(t)&&t.target===e&&n.push(t.source),n)){if(f.has(r))continue;let e=p.get(r);if(!e){i.push({code:"missing-edge-node",message:'Edge "'.concat(t.id,'" points to a missing node. Repair the flow before converting.'),edgeId:t.id});continue}let n=n$(e);"signal"===n?(f.add(r),g.push(r)):("mcp"===n||"resource"===n)&&i.push({code:"attachment-on-control-edge",message:"".concat(n_(e)," is connected as control flow. Reconnect it with its ").concat(n.toUpperCase()," attachment handles before converting."),nodeId:r,edgeId:t.id})}}}let x=!0;for(;x;)for(let e of(x=!1,u)){if(!(0,U.BY)(e))continue;let t=f.has(e.source);if(t===f.has(e.target))continue;let n=t?e.target:e.source,r=n$(p.get(n));"mcp"===r||"resource"===r?(f.add(n),x=!0):i.push({code:"unsupported-attachment",message:'Attachment edge "'.concat(e.id,'" does not connect to an MCP or Resource node.'),edgeId:e.id,nodeId:n})}let v=u.filter(e=>f.has(e.source)&&f.has(e.target)),b=[],w=[],y=new Set;for(let e of u){let t=f.has(e.source);if(t===f.has(e.target))continue;if((0,U.BY)(e)){i.push({code:"shared-attachment",message:'Attachment "'.concat(e.id,'" is also used outside the converted region. Duplicate or disconnect that attachment first.'),edgeId:e.id});continue}let n=t?e.source:e.target,r=t?e.target:e.source,o={edge:e,edgeId:e.id,insideNodeId:n,outsideNodeId:r,outsideLabel:n_(p.get(r))};y.add(r),t?w.push(o):b.push(o),nG(e)&&((t?b:w).push(o),i.push({code:"bidirectional-boundary",message:'Boundary edge "'.concat(e.id,'" is bidirectional. Make it one-way before converting; internal bidirectional edges are preserved.'),edgeId:e.id}))}let j=[...new Map(w.map(e=>[e.edgeId,e])).values()];j.length>1&&i.push({code:"multiple-outputs",message:"This region has ".concat(j.length," distinct parent exits. A Subflow supports one outgoing control path; join the branches before converting.")});let A=c.filter(e=>f.has(e.id)),C={includedNodes:A.map(e=>({id:e.id,label:n_(e),type:n$(e)})),attachmentCount:A.filter(e=>"mcp"===n$(e)||"resource"===n$(e)).length,signalCount:A.filter(e=>"signal"===n$(e)).length,internalEdgeCount:v.length,inputCount:new Set(b.map(e=>e.edgeId)).size,outputCount:j.length,excludedBoundaryNodes:[...y].map(e=>{let t=p.get(e);return{id:e,label:n_(t),type:n$(t)}}),rewires:["".concat(new Set(b.map(e=>e.edgeId)).size," parent input edge(s) will target the new Subflow node."),1===j.length?"The parent output to ".concat(j[0].outsideLabel," will leave the new Subflow node."):"The new Subflow node will have no parent output.","The child Start node will provide an isolated input to the converted Process."],warnings:d};0===j.length&&d.push("No parent follow-up exists; the extracted fan-out will finish inside the child flow.");let S=b.map(e=>{let{edge:t,...n}=e;return n}),k=w.map(e=>{let{edge:t,...n}=e;return n}),T={valid:0===i.length,errors:i,selectedNodeIds:[...f],selectedEdgeIds:v.map(e=>e.id),boundaryInputs:S,boundaryOutputs:k,preview:C};if(i.length>0||!h)return T;let I=s(),M=s(),N=s(),F=()=>"conversion-".concat(s()),P=A.filter(e=>{let t=n$(e);return"process"===t||"signal"===t}),R=Math.min(...A.map(e=>e.position.y),h.position.y),E=Math.max(...A.map(e=>e.position.y),h.position.y),z={id:M,type:"start",position:{x:h.position.x,y:R-180},data:{label:"Start Node",type:"start",properties:{promptTemplate:""}}},W={id:N,type:"finish",position:{x:h.position.x,y:E+180},data:{label:"Finish Node",type:"finish",properties:{}}},L=[...v.map(e=>({...e,data:e.data?{...e.data}:e.data})),nX(F(),M,h.id,"start-bottom","process-top")];if(1===j.length){let e=j[0];L.push(nX(F(),e.insideNodeId,N,"signal"===n$(p.get(e.insideNodeId))?"signal-bottom":"process-bottom","finish-top",e.edge))}else{let e=P.filter(e=>!u.some(t=>!!nK(t)&&(!!(t.source===e.id&&f.has(t.target))||nG(t)&&t.target===e.id&&f.has(t.source)))),t=e.length>0?e:[h];for(let e of(t.length>1&&d.push("".concat(t.length," internal branches will converge on the child Finish node.")),t))L.push(nX(F(),e.id,N,"signal"===n$(e)?"signal-bottom":"process-bottom","finish-top"))}let H={id:I,name:m,description:"Converted from ".concat(n_(h)," in ").concat(r.name),nodes:[z,...A,W],edges:L},B={...h,type:"subflow",selected:!1,data:{label:m,type:"subflow",description:"Runs the ".concat(m," subflow"),properties:{subflowId:I,inputMode:"isolated",outputMode:"final-only",allowCallerPrompt:!0}}},O=c.filter(e=>!f.has(e.id));O.push(B);let V=u.flatMap(e=>{let t=f.has(e.source),n=f.has(e.target);return t&&n?[]:t||n?(0,U.BY)(e)?[]:[{...e,source:t?B.id:e.source,target:n?B.id:e.target,sourceHandle:t?"subflow-bottom":e.sourceHandle,targetHandle:n?"subflow-top":e.targetHandle,data:e.data?{...e.data}:e.data}]:[e]}),G={...r,nodes:O,edges:V};return{...T,valid:!0,childFlow:H,parentFlow:G}}({parentFlow:l,processNodeId:n,subflowName:p,existingFlowNames:a})))},I=async()=>{if((null==y?void 0:y.valid)&&y.childFlow&&y.parentFlow){C(!0),k(null);try{await u(y),c()}catch(e){k(e instanceof Error?e.message:"The conversion could not be saved.")}finally{C(!1)}}};return(0,r.jsxs)(f.A,{open:t,onClose:A?void 0:c,fullWidth:!0,maxWidth:"md",children:[(0,r.jsx)(g.A,{children:y?"Preview Process conversion":"Convert Process to subflow"}),(0,r.jsx)(x.A,{children:y?(0,r.jsxs)(eq.A,{spacing:2,children:[y.errors.length>0&&(0,r.jsxs)(m.A,{severity:"error",children:[(0,r.jsx)(i.A,{fontWeight:600,children:"This graph cannot be converted yet."}),(0,r.jsx)(eb.A,{dense:!0,disablePadding:!0,children:y.errors.map((e,t)=>(0,r.jsx)(eA.Ay,{disableGutters:!0,children:(0,r.jsx)(ey.A,{primary:e.message})},"".concat(e.code,"-").concat(t)))})]}),S&&(0,r.jsx)(m.A,{severity:"error",children:S}),y.preview.warnings.map((e,t)=>(0,r.jsx)(m.A,{severity:"warning",children:e},"".concat(e,"-").concat(t))),(0,r.jsxs)(s.default,{children:[(0,r.jsxs)(i.A,{variant:"subtitle1",fontWeight:600,children:["Included in “",p.trim(),"”"]}),(0,r.jsx)(eq.A,{direction:"row",gap:1,flexWrap:"wrap",sx:{mt:1},children:y.preview.includedNodes.map(e=>(0,r.jsx)(M.A,{label:"".concat(e.label," \xb7 ").concat(e.type),size:"small"},e.id))}),(0,r.jsxs)(i.A,{variant:"body2",color:"text.secondary",sx:{mt:1},children:[y.preview.attachmentCount," attachment(s), ",y.preview.signalCount," signal(s), and ",y.preview.internalEdgeCount," internal edge(s)."]})]}),(0,r.jsx)(R.A,{}),(0,r.jsxs)(s.default,{children:[(0,r.jsx)(i.A,{variant:"subtitle1",fontWeight:600,children:"Boundary and rewiring"}),(0,r.jsx)(eb.A,{dense:!0,children:y.preview.rewires.map(e=>(0,r.jsx)(eA.Ay,{disableGutters:!0,children:(0,r.jsx)(ey.A,{primary:e})},e))}),y.preview.excludedBoundaryNodes.length>0&&(0,r.jsxs)(i.A,{variant:"body2",color:"text.secondary",children:["Kept in parent: ",y.preview.excludedBoundaryNodes.map(e=>"".concat(e.label," (").concat(e.type,")")).join(", ")]})]}),(0,r.jsx)(m.A,{severity:"info",children:"Accepting saves the child and parent together. If either save fails, the server compensates so the parent is restored and no child is left behind."})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v.A,{sx:{mb:2},children:"Name the child flow. The next step builds a non-persisted preview; closing or rejecting it changes nothing."}),(0,r.jsx)(b.A,{autoFocus:!0,fullWidth:!0,label:"Subflow name",value:p,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key&&T()}})]})}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:c,disabled:A,children:y?"Reject":"Cancel"}),y?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.A,{onClick:()=>{j(null),k(null)},disabled:A,children:"Back"}),(0,r.jsx)(d.A,{variant:"contained",onClick:I,disabled:!y.valid||A,children:A?"Converting…":"Accept conversion"})]}):(0,r.jsx)(d.A,{variant:"contained",onClick:T,children:"Preview"})]})]})}let nq=(0,y.A)((0,r.jsx)("path",{d:"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3m3-10H5V5h10z"}),"Save"),nJ=(0,y.A)((0,r.jsx)("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"}),"Undo"),nZ=(0,y.A)((0,r.jsx)("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"}),"Redo"),nQ=(0,y.A)((0,r.jsx)("path",{d:"M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"MoreHoriz");var n0=n(51314),n1=n(40171);let n2=(0,y.A)((0,r.jsx)("path",{d:"m20 12-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8z"}),"ArrowDownward");var n5=n(90363);let n4=(0,W.h)("frontend/components/Flow/FlowManager/ImproveFlowDialog"),n3=e=>{let{open:t,onClose:n,currentFlow:l,onImproved:a,initialDescription:i}=e,[c,u]=(0,o.useState)(""),[p,h]=(0,o.useState)([]),[y,j]=(0,o.useState)(""),[A,C]=(0,o.useState)(!1),[S,k]=(0,o.useState)(!1),[T,I]=(0,o.useState)(null);(0,o.useEffect)(()=>{t&&u(null!=i?i:"")},[t,i]),(0,o.useEffect)(()=>{if(!t)return;let e=!1;return O.N.loadModels().then(t=>{e||(h(t),j(e=>{var n,r;return t.some(t=>t.id===e)?e:null!=(r=null==(n=t[0])?void 0:n.id)?r:""}))}).catch(t=>{n4.warn("Failed to load models for the improve dialog",t),e||I("Could not load your models. Configure a model first.")}),()=>{e=!0}},[t]);let M=(0,o.useCallback)(()=>{S||(I(null),n())},[S,n]),P=(0,o.useCallback)(async()=>{I(null),k(!0);try{let e={...l,nodes:[...l.nodes],edges:[...l.edges]},t=await H.g.improveFlow(e,c.trim(),y,{allowInstall:A});if(!t.success)return void I(t.error);n4.info("Flow improved",{flowId:t.flow.id,attempts:t.attempts,errors:t.validation.errorCount,warnings:t.validation.warningCount,installedServers:t.installedServers.length}),u(""),a({flow:t.flow,errorCount:t.validation.errorCount,warningCount:t.validation.warningCount,attempts:t.attempts,installedServers:t.installedServers})}finally{k(!1)}},[l,c,y,A,a]),R=!S&&c.trim().length>0&&!!y;return(0,r.jsxs)(f.A,{open:t,onClose:M,maxWidth:"sm",fullWidth:!0,children:[(0,r.jsx)(g.A,{children:"Improve this flow with AI"}),(0,r.jsxs)(x.A,{children:[(0,r.jsxs)(v.A,{sx:{mb:2},children:["Describe the changes you want — add or remove a step, rewrite a prompt, wire up a tool, rename a node. The model revises the ",(0,r.jsx)("strong",{children:"current"})," flow and the result opens on the canvas as an unsaved change you can review, undo, and save."]}),T&&(0,r.jsx)(m.A,{severity:"error",sx:{mb:2},onClose:()=>I(null),children:T}),(0,r.jsx)(b.A,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:4,label:"What should change?",placeholder:"e.g. Add a step after the research that emails the summary, and make the research step use the full conversation",value:c,onChange:e=>u(e.target.value),disabled:S,sx:{mb:2}}),(0,r.jsxs)(e3.A,{fullWidth:!0,disabled:S||0===p.length,children:[(0,r.jsx)(e9.A,{id:"improve-flow-model-label",children:"Generator model"}),(0,r.jsx)(e6.A,{labelId:"improve-flow-model-label",label:"Generator model",value:y,onChange:e=>j(e.target.value),children:p.map(e=>{var t;return(0,r.jsx)(z.A,{value:e.id,children:(null==(t=e.displayName)?void 0:t.trim())||e.name},e.id)})})]}),(0,r.jsx)(F.A,{sx:{mt:2},control:(0,r.jsx)(ts.A,{checked:A,onChange:e=>C(e.target.checked),disabled:S}),label:"Let the improver install MCP servers it needs (self-improve)"}),A&&(0,r.jsxs)(m.A,{severity:"warning",sx:{mt:1},children:["The improver may ",(0,r.jsx)("strong",{children:"download, install, and run third-party MCP servers"})," from the public registry on this machine — without asking again. It prefers servers that need no API keys, but anything it installs executes real code with your user's permissions. Installed servers stay configured afterwards (remove them on the MCP page)."]}),S&&(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1.5,mt:2},children:[(0,r.jsx)(N.default,{size:20}),(0,r.jsx)(v.A,{children:A?"Improving… the model may search the marketplace and install servers (this can take a few minutes).":"Improving… the model revises the flow and FLUJO checks it (this can take up to a minute)."})]})]}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:M,disabled:S,children:"Cancel"}),(0,r.jsx)(d.A,{onClick:P,variant:"contained",color:"primary",startIcon:(0,r.jsx)(n5.A,{}),disabled:!R,children:"Improve"})]})]})};var n9=n(77890);let n6=e=>({source:"".concat(e,"-bottom"),target:"".concat(e,"-top")});function n8(e){var t,n,r;return null!=(r=null!=(n=null==(t=e.data)?void 0:t.type)?n:e.type)?r:"unknown"}let n7=(0,y.A)((0,r.jsx)("path",{d:"M13 2H4c-1.1 0-2 .9-2 2v9c0 .55.45 1 1 1s1-.45 1-1V4h9c.55 0 1-.45 1-1s-.45-1-1-1m4 4H8c-1.1 0-2 .9-2 2v9c0 .55.45 1 1 1s1-.45 1-1V8h9c.55 0 1-.45 1-1s-.45-1-1-1m3 4h-8c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2"}),"AutoAwesomeMotionRounded");var re=n(14418);let rt=(0,y.A)((0,r.jsx)("path",{d:"M24 15c0-2.64-2.05-4.78-4.65-4.96C18.67 6.59 15.64 4 12 4c-1.33 0-2.57.36-3.65.97l1.49 1.49C10.51 6.17 11.23 6 12 6c3.04 0 5.5 2.46 5.5 5.5v.5H19c1.66 0 3 1.34 3 3 0 .99-.48 1.85-1.21 2.4l1.41 1.41c1.09-.92 1.8-2.27 1.8-3.81M3.71 4.56c-.39.39-.39 1.02 0 1.41l2.06 2.06h-.42c-3.28.35-5.76 3.34-5.29 6.79C.46 17.84 3.19 20 6.22 20h11.51l1.29 1.29c.39.39 1.02.39 1.41 0s.39-1.02 0-1.41L5.12 4.56a.996.996 0 0 0-1.41 0M6 18c-2.21 0-4-1.79-4-4s1.79-4 4-4h1.73l8 8z"}),"CloudOffRounded");var rn=n(97104);let rr=new Set(["maxTurns","excludeModelPrompt","excludeStartNodePrompt","excludeSystemPrompt","allowedTools","isolatedPrompt","allowCallerPrompt","enableTodoTool","captureVariable","captureResource","captureKv","resourceNodes"]),ro=new Set(["parallelSubflowIds","parallelSubflowIdsVar","mapOverList","itemSplit","sequential","allowCallerFanout","spawnBriefs","concurrencyLimit","joinSeparator","errorStrategy","allowCallerPrompt","saveConversation","captureVariable","captureResource","captureKv"]);function rl(e){var t,n,r,o,l;if(void 0!==e.permissionRules)return!0;for(let l of null!=(t=e.nodes)?t:[]){if(!["start","process","finish","subflow","mcp"].includes(null!=(r=l.type)?r:""))return!0;let e=null!=(o=null==(n=l.data)?void 0:n.properties)?o:{},t=Object.keys(e);if("process"===l.type&&t.some(e=>rr.has(e))||"subflow"===l.type&&t.some(e=>ro.has(e))||"process"===l.type&&(void 0!==e.inputMode&&"full-history"!==e.inputMode||void 0!==e.outputMode&&"latest-message"!==e.outputMode)||"subflow"===l.type&&(void 0!==e.inputMode&&"full-history"!==e.inputMode||void 0!==e.outputMode&&"final-only"!==e.outputMode))return!0}return(null!=(l=e.edges)?l:[]).some(e=>{let t=e.data;return!!(null==t?void 0:t.condition)||(null==t?void 0:t.bidirectional)===!0||(null==t?void 0:t.edgeType)==="resource"})}let ra=(0,W.h)("components/flow/FlowBuilder/index.tsx"),rs=(0,T.Ay)(s.default)(e=>{let{theme:t}=e;return{display:"flex",height:"100%",minHeight:0,gap:"12px",padding:"12px",overflow:"hidden",backgroundColor:"transparent",[t.breakpoints.down("md")]:{flexDirection:"column",gap:"8px",padding:"8px",height:"auto",overflow:"visible"}}}),ri=(0,T.Ay)(I.A)(e=>{let{theme:t}=e;return{padding:t.spacing(1.1),display:"flex",flexWrap:"wrap",gap:t.spacing(1),border:"1px solid ".concat(t.palette.divider),borderRadius:14,alignItems:"center",marginBottom:t.spacing(1),backgroundColor:"dark"===t.palette.mode?"rgba(17, 22, 41, 0.86)":"rgba(255, 255, 255, 0.9)",boxShadow:"dark"===t.palette.mode?"0 16px 45px rgba(0,0,0,.25)":"0 16px 45px rgba(49,45,99,.1)",backdropFilter:"blur(20px) saturate(140%)"}}),rd=(0,T.Ay)(s.default)(e=>{let{theme:t}=e;return{flex:1,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden",minWidth:0,minHeight:0,[t.breakpoints.down("md")]:{flex:"0 0 640px",height:640,overflow:"hidden"},[t.breakpoints.down("sm")]:{flexBasis:"auto",height:"auto",minHeight:0,overflow:"visible"}}}),rc=new Set(["start","process","finish","subflow","signal"]),ru=(e,t)=>{var n,r;let o=e.filter(e=>rc.has(e.data.type)),l=new Set(o.map(e=>e.id)),a=t.filter(e=>{var t;return l.has(e.source)&&l.has(e.target)&&(null==(t=e.data)?void 0:t.edgeType)!=="resource"}),s=new Map,i=new Map;a.forEach(e=>{var t,n;s.set(e.source,[...null!=(t=s.get(e.source))?t:[],e]),i.set(e.target,[...null!=(n=i.get(e.target))?n:[],e])});let d=o.filter(e=>"start"===e.data.type),c=o.filter(e=>"finish"===e.data.type),u=1!==d.length||c.length>1;o.forEach(e=>{var t,n,r,o;let l=null!=(r=null==(t=i.get(e.id))?void 0:t.length)?r:0,a=null!=(o=null==(n=s.get(e.id))?void 0:n.length)?o:0;"start"===e.data.type?u||(u=0!==l||a>1):"finish"===e.data.type?u||(u=1!==l||0!==a):u||(u=1!==l||a>1)});let p=[],h=new Set,m=null==(n=d[0])?void 0:n.id;for(;m&&!h.has(m);){h.add(m),p.push(m);let e=null!=(r=s.get(m))?r:[];if(1!==e.length)break;m=e[0].target}return u||(u=0===o.length||h.size!==o.length),{unsafe:u,orderedNodeIds:p}},rp=o.forwardRef((e,t)=>{var n,l;let{initialFlow:a,onSave:c,onDelete:y,onConversionCommitted:j,allFlows:C,relatedDraftFlows:S=[],onRelatedDraftFlowsChange:k,isDraft:T=!1,onTry:I}=e;ra.debug("FlowBuilder rendered with initialFlow:",a);let[W,G]=(0,o.useState)((null==a?void 0:a.nodes)||[]),[J,Z]=(0,o.useState)(((null==a?void 0:a.edges)||[]).filter(e=>e.source&&e.target&&e.sourceHandle&&e.targetHandle)),[Q,ee]=(0,o.useState)((null==a?void 0:a.name)||"Untitled agent"),[et,en]=(0,o.useState)(null),[er,eo]=(0,o.useState)((null==a?void 0:a.description)||""),el=!!a&&(rl({nodes:a.nodes||[],edges:a.edges||[],permissionRules:a.permissionRules})||ru(a.nodes||[],a.edges||[]).unsafe),[ea,es]=(0,rn.Xk)("flujo-ui:flow-builder:mode","guided"),[ei,ed]=(0,o.useState)(()=>el?"advanced":ea),ec=(0,o.useCallback)(e=>{ed(e),es(e)},[es]),eu=(0,o.useRef)(0),ep=(0,o.useCallback)(e=>({...e,id:"permission-rule-".concat(++eu.current)}),[]),[eh,em]=(0,o.useState)(()=>((null==a?void 0:a.permissionRules)||[]).map(ep)),[ef,ex]=(0,o.useState)((null==a?void 0:a.permissionRules)!==void 0),[ev,eb]=(0,o.useState)(!1),[ew,ey]=(0,o.useState)(null),ej=rl({nodes:W,edges:J,permissionRules:null==a?void 0:a.permissionRules}),eA=ru(W,J),eC=ej||eA.unsafe,[eS,ek]=(0,o.useState)(!1),[eT,eI]=(0,o.useState)("none"),[eM,eN]=(0,o.useState)(""),[eF,eP]=(0,o.useState)(null),[eR,eE]=(0,o.useState)(!1),[ez,eW]=(0,o.useState)(!1),[eL,eD]=(0,o.useState)(!1),[eH,eB]=(0,o.useState)(!1),[eO,eV]=(0,o.useState)(!1),[eU,eG]=(0,o.useState)(!1),[eK,e$]=(0,o.useState)(!1),[e_,eX]=(0,o.useState)(!1),[eq,eJ]=(0,o.useState)(null),[eZ,eQ]=(0,o.useState)(null),[e0,e1]=(0,o.useState)("edit"),[e2,e5]=(0,o.useState)(null),[e3,e9]=(0,o.useState)(null),[e6,e8]=(0,o.useState)(!1),[e7,te]=(0,o.useState)(null),[tt,tr]=(0,o.useState)(null),[to,tl]=(0,o.useState)(""),[ts,ti]=(0,o.useState)(!1),[td,tu]=(0,o.useState)([]),[tp,th]=(0,o.useState)(-1),[tm,tf]=(0,o.useState)(!1),[tg,tx]=(0,o.useState)(!1),[tv,tb]=(0,o.useState)(T?"unsaved":"saved"),[tw,ty]=(0,o.useState)([]),[tj,tA]=(0,o.useState)(null),[tC,tS]=(0,o.useState)(()=>{var e;return T&&!(null!=(e=null==a?void 0:a.nodes)?e:[]).some(e=>"process"===e.data.type)?"unasked":"manual"}),[tk,tT]=(0,o.useState)(!1),[tI,tM]=(0,o.useState)(null),tN=(0,o.useRef)(null!=(n=null==a?void 0:a.id)?n:(0,D.A)()),tF=(0,o.useRef)(0),tP=(0,o.useRef)(null),tR=(0,o.useRef)(W.some(e=>"trigger"===e.type));tR.current=W.some(e=>"trigger"===e.type);let tE=(0,o.useRef)(null),tz=(0,o.useRef)(!1),tW=(0,o.useRef)(!0);(0,o.useEffect)(()=>{let e=!0;return O.N.loadModels().then(t=>{e&&(ty(t),0===t.length&&tS(e=>"unasked"===e?"manual":e))}).catch(t=>{ra.warn("Could not load connected AIs for Guided mode",t),e&&(ty([]),tS(e=>"unasked"===e?"manual":e))}),()=>{e=!1}},[]);let tL=(0,o.useCallback)(e=>e.filter(e=>e.source&&e.target&&e.sourceHandle&&e.targetHandle).map(e=>{var t;return(null==(t=e.data)?void 0:t.edgeType)==="resource"&&"resourceEdge"!==e.type?{...e,type:"resourceEdge"}:e}),[]);(0,o.useEffect)(()=>{if(tW.current=!0,tF.current=0,tx(!1),tb(T?"unsaved":"saved"),a){let e=a.nodes||[],t=T?e.map(e=>({...e,selected:!1})):e;G(t);let n=tL(a.edges||[]);n.length!==a.edges.length&&console.warn("Filtered out ".concat(a.edges.length-n.length," invalid edges")),Z(n),ee(a.name),eo(a.description||""),em((a.permissionRules||[]).map(ep)),ex(void 0!==a.permissionRules),ey(null),(rl({nodes:e,edges:n,permissionRules:a.permissionRules})||ru(e,n).unsafe)&&ec("advanced"),tu([{nodes:t,edges:n}]),th(0)}else{let e=H.g.createStartNode();G([e]),Z([]),ee("Untitled agent"),eo(""),em([]),ex(!1),ey(null),tu([{nodes:[e],edges:[]}]),th(0)}},[null==a?void 0:a.id,ep,ec]);let tD=e=>JSON.stringify(e,(e,t)=>"selected"===e||"dragging"===e||"measured"===e||"width"===e||"height"===e||"positionAbsolute"===e||"resizing"===e?void 0:t);(0,o.useEffect)(()=>{if(tm)return void tf(!1);if(tW.current){tW.current=!1;return}if(tz.current)return;let e={nodes:[...W],edges:[...J]},t=td.slice(0,tp+1);(tp<0||tD(e)!==tD(t[tp]))&&(tu([...t,e]),th(tp+1),tx(!0),tF.current+=1,tb("unsaved"))},[W,J]),(0,o.useEffect)(()=>{let e=e=>{if(tg)return e.preventDefault(),e.returnValue="",""};return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}},[tg]);let tH=e=>e.trim()?RegExp("^[\\p{L}\\p{N}_ -]+$","u").test(e.trim())?(!a||a&&a.name!==e)&&C.some(t=>t.id!==((null==a?void 0:a.id)||"")&&t.name.trim().toLowerCase()===e.trim().toLowerCase())?"An agent with this name already exists":null:"Use letters, numbers, spaces, underscores, or dashes":"Agent name cannot be empty",tB=(0,o.useCallback)(()=>{tx(!0),tF.current+=1,tb("unsaved")},[]),tO=(e,t)=>{em(n=>n.map(n=>n.id===e?{...n,...t}:n)),ex(!0),ey(null),tB()},tV=(e,t)=>{let n=e+t;n<0||n>=eh.length||(em(t=>{let r=[...t];return[r[e],r[n]]=[r[n],r[e]],r}),ex(!0),tB())},tU=(0,o.useCallback)(()=>ef?eh.map(e=>{let{id:t,...n}=e;return n}):void 0,[eh,ef]),tG=(0,o.useCallback)(()=>!eh.find(e=>!e.action.trim()||!e.resource.trim())||(ey("Each permission rule needs both an action and a resource. Use * to match any value."),eb(!0),!1),[eh]),tK=(0,o.useCallback)(()=>{if(tP.current)return tP.current;let e=(async()=>{ra.debug('handleSave: Attempting to save flow "'.concat(Q,'"'));let e=tH(Q);if(e)return ra.warn("handleSave: Invalid flow name - ".concat(e)),en(e),"invalid-name";if(!tG())return"invalid-name";let t=[...W];0===t.length&&(ra.debug("handleSave: No nodes found, adding a default Start node"),G(t=[H.g.createStartNode()]));let n={id:(null==a?void 0:a.id)||(0,D.A)(),name:Q.trim(),description:er,nodes:t,edges:J,folder:null==a?void 0:a.folder,favorite:null==a?void 0:a.favorite,permissionRules:tU()};ra.info('handleSave: Saving flow "'.concat(Q,'" with ').concat(t.length," nodes and ").concat(J.length," edges"));let r=tF.current;tb("saving");try{let e=await c(n);if(!1===e)return tb("error"),"failed";return tF.current===r?(tx(!1),tb("saved")):(tx(!0),tb("unsaved")),"saved"}catch(e){return ra.error("handleSave: Persistence failed",e),tb("error"),tx(!0),"failed"}})();return tP.current=e,e.finally(()=>{tP.current===e&&(tP.current=null)}),e},[Q,er,W,J,a,c,tU,tG]),t$=(0,o.useCallback)(async()=>{I&&((T||tg||"saved"!==tv)&&"saved"!==await tK()||I())},[I,T,tg,tv,tK]);o.useImperativeHandle(t,()=>({requestNavigation:e=>{tg?(tE.current=e,eI("unsaved"),ek(!0)):e()}}),[tg]);let t_=(0,o.useCallback)(()=>{a?(ra.info('handleDelete: Deleting flow "'.concat(a.name,'" (ID: ').concat(a.id,")")),y(a.id)):ra.warn("handleDelete: Attempted to delete flow but no initialFlow is available")},[a,y]),tX=(0,o.useCallback)(e=>{ra.info("Applying AI-improved flow to the canvas",{flowId:e.flow.id,attempts:e.attempts,errors:e.errorCount,warnings:e.warningCount}),e8(!1),G(e.flow.nodes||[]),Z(tL(e.flow.edges||[])),ee(e.flow.name),eo(e.flow.description||""),void 0!==e.flow.permissionRules&&(em(e.flow.permissionRules.map(ep)),ex(!0)),en(tH(e.flow.name)),tx(!0);let t=e.installedServers.filter(e=>!e.alreadyExisted),n=t.length>0?" Installed MCP server(s): ".concat(t.map(e=>e.name).join(", "),"."):"";e.errorCount>0?te({severity:"warning",message:"Flow revised with ".concat(e.errorCount," error(s) and ").concat(e.warningCount," warning(s) — use the Check button, fix, then Save.").concat(n)}):e.warningCount>0?te({severity:"info",message:"Flow revised with ".concat(e.warningCount," warning(s) — review the changes, then Save to keep them.").concat(n)}):te({severity:"success",message:"Flow revised — review the changes (Undo reverts them), then Save to keep them.".concat(n)})},[tL]),tY=(0,o.useCallback)(e=>{var t,n,r,o;ra.info("Restoring an archived flow version to the canvas",{flowId:e.id,nodes:null!=(r=null==(t=e.nodes)?void 0:t.length)?r:0,edges:null!=(o=null==(n=e.edges)?void 0:n.length)?o:0}),ti(!1),G(e.nodes||[]),Z(tL(e.edges||[])),ee(e.name),eo(e.description||""),em((e.permissionRules||[]).map(ep)),ex(void 0!==e.permissionRules),en(tH(e.name)),tx(!0),te({severity:"info",message:"Restored an earlier version to the canvas — review it (Undo reverts), then Save to keep it."})},[tL]),tq=(0,o.useCallback)(()=>{tr(null);let{flow:e,changes:t}=function(e){var t,n,r,o,l,a,s,i;let d=(null!=(t=null==e?void 0:e.nodes)?t:[]).map(e=>{var t;return{...e,position:{...null!=(t=e.position)?t:{x:0,y:0}},data:{...e.data}}}),c=[...null!=(n=null==e?void 0:e.edges)?n:[]],u={...e,nodes:d,edges:c},p=[],h=function(e,t){let n=e.filter(e=>"mcp"!==e.type&&"resource"!==e.type&&"string"==typeof e.id),r=new Map(n.map(e=>[e.id,e])),o=new Map,l=new Map,a=new Set;for(let e of n)o.set(e.id,0),l.set(e.id,0);let s=(e,t)=>{var n,r;a.add("".concat(e,"->").concat(t)),l.set(e,(null!=(n=l.get(e))?n:0)+1),o.set(t,(null!=(r=o.get(t))?r:0)+1)};for(let e of t)r.has(e.from)&&r.has(e.to)&&e.from!==e.to&&(s(e.from,e.to),e.bidirectional&&s(e.to,e.from));let i=[];for(let e of[...n].sort((e,t)=>e.y-t.y||e.x-t.x)){let t=i[i.length-1];t&&70>=Math.abs(e.y-t[0].y)?t.push(e):i.push([e])}let d=new Map;i.forEach((e,t)=>e.forEach(e=>d.set(e.id,t)));let c=new Map;for(let e=1;e<i.length;e++){let t=i[e],n=t.filter(e=>"subflow"===e.type);if(n.length>=2&&n.length===t.length){let t=i[e-1];if(1===t.length&&"process"===t[0].type)for(let e of n)c.set(e.id,t[0].id)}}let u=[],p=(e,t)=>{var n;if(e===t||a.has("".concat(e,"->").concat(t)))return!1;let o=r.get(e),s=r.get(t);return!!o&&!!s&&null===(0,U.vC)(o.type,n6(o.type).source,s.type,n6(s.type).target)&&("subflow"!==o.type||!((null!=(n=l.get(e))?n:0)>=1))},h=(e,t,n,r)=>{u.push({from:e,to:t,bidirectional:n,reason:r}),s(e,t),n&&s(t,e)},m=e=>{var t;let n=null!=(t=d.get(e.id))?t:0;for(let t=n-1;t>=0;t--){let n=i[t].filter(t=>t.id!==e.id&&"finish"!==t.type&&!c.has(t.id));if(0!==n.length){if(1===n.length)return n[0];return n.reduce((t,n)=>Math.abs(n.x-e.x)<Math.abs(t.x-e.x)?n:t)}}return null};for(let e of i)for(let t of e){var f;if("start"===t.type||(null!=(f=o.get(t.id))?f:0)>0)continue;let e=c.get(t.id);if(e){p(e,t.id)&&h(e,t.id,!0,"auto-bidirectional-subflow");continue}let n=m(t);n&&p(n.id,t.id)&&h(n.id,t.id,!1,"auto-connected")}let g=n.filter(e=>"start"===e.type),x=()=>n.filter(e=>{var t;return"start"!==e.type&&"finish"!==e.type&&!c.has(e.id)&&(null!=(t=o.get(e.id))?t:0)===0}),v=null;if(0===g.length){let e=x();if(e.length>0)v={targets:e.map(e=>e.id)};else{let e=n.filter(e=>"finish"!==e.type).sort((e,t)=>e.y-t.y)[0];e&&(v={targets:[e.id]})}}else{let e=g[0];for(let t of x())p(e.id,t.id)&&h(e.id,t.id,!1,"auto-connected")}let b=n.filter(e=>"finish"===e.type),w=()=>n.filter(e=>{var t;return"start"!==e.type&&"finish"!==e.type&&!c.has(e.id)&&(null!=(t=l.get(e.id))?t:0)===0}),y=null;if(0===b.length){let e=w();e.length>0&&(y={sources:e.map(e=>e.id)})}else{let e=b[0];for(let t of w())p(t.id,e.id)&&h(t.id,e.id,!1,"auto-connected")}return{addEdges:u,addStart:v,addFinish:y}}(d.filter(e=>"mcp"!==n8(e)&&"resource"!==n8(e)).map(e=>{var t,n,r,o;return{id:e.id,type:n8(e),x:null!=(r=null==(t=e.position)?void 0:t.x)?r:0,y:null!=(o=null==(n=e.position)?void 0:n.y)?o:0}}),c.filter(e=>!function(e){var t;let n=null==(t=e.data)?void 0:t.edgeType;return"mcp"===n||"resource"===n}(e)).map(e=>{var t;return{from:e.source,to:e.target,bidirectional:(null==(t=e.data)?void 0:t.bidirectional)===!0}})),m=new Map(d.map(e=>[e.id,e])),f=(e,t,n)=>{let r=m.get(e),o=m.get(t);r&&o&&c.push((0,n9.pX)(r,o,n))};for(let e of h.addEdges)f(e.from,e.to,e.bidirectional),p.push({code:e.reason,message:function(e){switch(e){case"auto-connected":return"Connected a disconnected step into the flow.";case"auto-bidirectional-subflow":return"Wired a parallel subflow with a two-way handoff to its orchestrator.";case"auto-added-start":return"Added a Start node.";case"auto-added-finish":return"Added a Finish node."}}(e.reason),nodeId:e.to});if(h.addStart){let e=h.addStart.targets.map(e=>m.get(e)).filter(Boolean).reduce((e,t)=>!e||t.position.y<e.position.y?t:e,null),t=(s={x:null!=(r=null==e?void 0:e.position.x)?r:250,y:(null!=(o=null==e?void 0:e.position.y)?o:150)-150},{id:(0,D.A)(),type:"start",position:s,data:{label:"Start Node",type:"start",properties:{promptTemplate:""}}});for(let e of(d.unshift(t),m.set(t.id,t),h.addStart.targets))f(t.id,e,!1);p.push({code:"auto-added-start",message:"Added a Start node connected to ".concat(h.addStart.targets.length," entry step(s)."),nodeId:t.id})}if(h.addFinish){let e=h.addFinish.sources.map(e=>m.get(e)).filter(Boolean).reduce((e,t)=>!e||t.position.y>e.position.y?t:e,null),t=(i={x:null!=(l=null==e?void 0:e.position.x)?l:250,y:(null!=(a=null==e?void 0:e.position.y)?a:0)+150},{id:(0,D.A)(),type:"finish",position:i,data:{label:"Finish Node",type:"finish",properties:{}}});for(let e of(d.push(t),m.set(t.id,t),h.addFinish.sources))f(e,t.id,!1);p.push({code:"auto-added-finish",message:"Added a Finish node connected from ".concat(h.addFinish.sources.length," final step(s)."),nodeId:t.id})}return{flow:u,changes:p}}({id:(null==a?void 0:a.id)||"",name:Q,description:er,nodes:W,edges:J,folder:null==a?void 0:a.folder,favorite:null==a?void 0:a.favorite,permissionRules:tU()});if(0===t.length)return void te({severity:"info",message:"Nothing to repair — the flow is already wired up."});ra.info("Applying static auto-repair to the canvas (".concat(t.length," change(s))")),G(e.nodes||[]),Z(tL(e.edges||[])),tx(!0);let n=t.filter(e=>"auto-added-start"===e.code||"auto-added-finish"===e.code).length,r=t.length-n,o=[];t.some(e=>"auto-added-start"===e.code)&&o.push("added a Start node"),t.some(e=>"auto-added-finish"===e.code)&&o.push("added a Finish node"),r>0&&o.push("connected ".concat(r," step(s)")),te({severity:"success",message:"Repaired the flow — ".concat(o.join(", "),". Review the changes (Undo reverts them), then Save to keep them.")})},[a,Q,er,W,J,tL,tU]),tJ=(0,o.useCallback)(()=>{tr(null),tl("Repair this flow's wiring so it is runnable, without changing any node's prompt, model, or servers: add a Start node if one is missing (connected to the first step), add a Finish node if one is missing (connected from the last step), and connect any disconnected process/subflow nodes. Read node placement as intent: nodes stacked top-to-bottom are sequential steps, and nodes on the same horizontal line are parallel branches under a shared parent above them."),e8(!0)},[]),tZ=(0,o.useCallback)(async(e,t)=>{ra.debug('handleCopyFlow: Copying flow "'.concat(e.name,'" to "').concat(t,'"'));let n={id:(0,D.A)(),name:t,description:e.description,nodes:e.nodes,edges:e.edges,folder:e.folder,favorite:e.favorite,permissionRules:e.permissionRules};return ra.info('handleCopyFlow: Created copy of flow "'.concat(e.name,'" with new name "').concat(t,'" (').concat(e.nodes.length," nodes, ").concat(e.edges.length," edges)")),await c(n)!==!1},[c]),tQ=()=>{let e=tE.current;tE.current=null,e&&e()},t0=()=>{tE.current=null,ek(!1),eI("none"),eN(""),eP(null)},t1=async()=>{let e=tH(eM);if(e)return void eP(e);if("duplicate"===eT){if(a&&!await tZ(a,eM))return}else if("rename"===eT){let e={id:(null==a?void 0:a.id)||(0,D.A)(),name:eM,description:er,nodes:W,edges:J,folder:null==a?void 0:a.folder,favorite:null==a?void 0:a.favorite,permissionRules:tU()};if(await c(e)===!1)return void tb("error");tx(!1),tb("saved"),tQ()}t0()},t2=async()=>{let e=await tK();"saved"===e?(tQ(),t0()):"invalid-name"===e&&t0()},t5=tp>0,t4=tp<td.length-1,t3=(0,o.useCallback)(()=>{if(t5){ra.debug("handleUndo: Performing undo operation, moving from history index ".concat(tp," to ").concat(tp-1)),tf(!0);let e=tp-1,t=td[e];G(t.nodes),Z(t.edges),th(e),tB(),ra.info("handleUndo: Restored flow state to previous version (".concat(t.nodes.length," nodes, ").concat(t.edges.length," edges)"))}},[td,tp,t5,tB]),t6=(0,o.useCallback)(()=>{if(t4){ra.debug("handleRedo: Performing redo operation, moving from history index ".concat(tp," to ").concat(tp+1)),tf(!0);let e=tp+1,t=td[e];G(t.nodes),Z(t.edges),th(e),tB(),ra.info("handleRedo: Restored flow state to next version (".concat(t.nodes.length," nodes, ").concat(t.edges.length," edges)"))}},[td,tp,t4,tB]);(0,o.useEffect)(()=>{let e=e=>{let t=e.target,n=(null==t?void 0:t.tagName)==="INPUT"||(null==t?void 0:t.tagName)==="TEXTAREA"||(null==t?void 0:t.isContentEditable),r=e.ctrlKey||e.metaKey,o=e.key.toLowerCase();if(r&&"s"===o){e.preventDefault(),tK();return}if(!n&&r&&"z"===o){e.preventDefault(),e.shiftKey?t6():t3();return}if(!n&&r&&"y"===o){e.preventDefault(),t6();return}n||(!r||"k"!==o)&&(r||"a"!==o&&"/"!==e.key)||(e.preventDefault(),document.dispatchEvent(new CustomEvent("openFlowQuickAdd")))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[tK,t3,t6]);let t8=(0,o.useCallback)(async e=>{if(!a||!e3||!e.parentFlow||!e.childFlow)throw Error("Save the parent flow before converting a Process node.");let t=await H.g.convertProcessToSubflow(e.parentFlow,e.childFlow,e3,a.updatedAt);if(!t.success)throw Error(t.error);let n={nodes:t.parentFlow.nodes,edges:t.parentFlow.edges},r=[...td.slice(0,tp+1),n];tf(!0),tu(r),th(r.length-1),G(t.parentFlow.nodes),Z(t.parentFlow.edges),tx(!1),tb("saved"),e9(null),null==j||j(t.parentFlow,t.childFlow)},[a,e3,td,tp,j]),t7=(0,o.useCallback)(e=>{for(let t of e)"position"===t.type&&(tz.current=!0===t.dragging);G(t=>(0,L._0)(e,t))},[]),nr=(0,o.useCallback)((e,t)=>{Z(n=>n.map(n=>{var r;if(n.id!==e)return n;let o={...null!=(r=n.data)?r:{}};return t?o.condition=t:delete o.condition,{...n,data:o}})),ra.info("handleSaveEdgeCondition: ".concat(t?"set":"cleared"," condition on edge ").concat(e))},[]),no=(0,o.useCallback)(e=>{ra.debug("onEdgesChange: Processing ".concat(e.length," edge changes")),e.forEach(e=>{"remove"===e.type?ra.info("onEdgesChange: Edge ".concat(e.id," removed")):"select"===e.type&&ra.debug("onEdgesChange: Edge ".concat(e.id," selection changed to ").concat(e.selected))}),Z(t=>(0,L.zW)(e,t))},[]),na=(0,o.useRef)(null),[ns,ni]=(0,o.useState)(null),nc=(0,o.useCallback)(e=>{eJ(e),setTimeout(()=>eJ(t=>t===e?null:t),5e3)},[]),nu=(0,o.useCallback)((e,t,n)=>{if("trigger"===e&&tR.current)return nc("A Trigger node already exists in this flow. Only one Trigger node is allowed per flow."),null;"trigger"===e&&(tR.current=!0);let r=null!=n?n:H.g.createNode(e,t);return G(e=>[...e.map(e=>({...e,selected:!1})),{...r,selected:!0}]),r},[nc]),np=(0,o.useCallback)(e=>{var t,n;let r=null!=(n=W.find(e=>e.selected))?n:1===W.length&&"start"===W[0].data.type?W[0]:void 0,o=null==(t=na.current)?void 0:t.getBoundingClientRect(),l=o&&ns?ns.screenToFlowPosition({x:o.left+o.width/2,y:o.top+o.height/2}):{x:250,y:180},a=r&&!["mcp","resource","trigger"].includes(e)?{x:r.position.x,y:r.position.y+180}:l;for(let e=0;e<12&&W.some(e=>90>Math.abs(e.position.x-a.x)&&70>Math.abs(e.position.y-a.y));e+=1)a={x:a.x+36,y:a.y+36};let s=!!r&&["process","finish","subflow","signal"].includes(e),i=H.g.createNode(e,a);if(r&&s){let t={start:"start-bottom",process:"process-bottom",subflow:"subflow-bottom",signal:"signal-bottom"}[r.type];if(!t)return nc("".concat(r.data.label||"The selected node"," cannot lead to another step. Select a Start, Process, Subflow, or Signal node first.")),null;let n={source:r.id,sourceHandle:t,target:i.id,targetHandle:(0,U.CW)(e,t)},o=[...W,i];if(!(0,V.JL)(n,o,J))return nc("That step cannot be appended here. Choose another source node or adjust its existing connection."),null;let l=nu(e,a,i);if(!l)return null;let s=(0,V.wn)(n,o);return Z(e=>[...e,s]),l}return nu(e,a,i)},[W,J,ns,nu,nc]),nh=(0,o.useCallback)(e=>{var t,n;if(eC)return void nc("This agent uses custom wiring. Open Expert mode before changing its sequence.");let r=W.find(e=>"start"===e.data.type),o=W.find(e=>"finish"===e.data.type),l=null!=(t=[...eA.orderedNodeIds.map(e=>W.find(t=>t.id===e)).filter(e=>!!e)].reverse().find(e=>["start","process","subflow","signal"].includes(e.data.type)))?t:r;if(!l)return void nc("This agent is missing its starting point. Open Expert mode to repair it.");let a={start:"start-bottom",process:"process-bottom",subflow:"subflow-bottom",signal:"signal-bottom"}[l.data.type];if(!a)return void nc("Add this step from Expert mode so its custom connection stays safe.");let s=H.g.createNode("process",{x:l.position.x,y:l.position.y+180});s.data={...s.data,label:"AI task",properties:{...null!=(n=s.data.properties)?n:{},promptTemplate:e,inputMode:"full-history",outputMode:"latest-message",..."assisted"===tC&&tj?{boundModel:tj}:{}}};let i=null!=o?o:H.g.createNode("finish",{x:l.position.x,y:l.position.y+360}),d=[...W.filter(e=>e.id!==i.id).map(e=>({...e,selected:!1})),{...s,selected:!0},{...i,position:{x:l.position.x,y:l.position.y+360},selected:!1}],c=J.filter(e=>!(o&&e.source===l.id&&e.target===o.id)),u={source:l.id,sourceHandle:a,target:s.id,targetHandle:(0,U.CW)("process",a)},p={source:s.id,sourceHandle:"process-bottom",target:i.id,targetHandle:(0,U.CW)("finish","process-bottom")};G(d),Z([...c,(0,V.wn)(u,d),(0,V.wn)(p,d)]),W.some(e=>"process"===e.data.type)||er.trim()||eo(e),"assisted"===tC&&tj?(tM(s.id),tT(!0)):tj||nc("Step added. Connect an AI model before trying this agent.")},[W,J,tC,tj,eA.orderedNodeIds,eC,nc,er]),nm=null!=(l=W.find(e=>e.selected))?l:null,nx=W.some(e=>["process","subflow"].includes(e.data.type)),nv=W.filter(e=>"process"===e.data.type).every(e=>{var t;return"string"==typeof(null==(t=e.data.properties)?void 0:t.boundModel)&&!!e.data.properties.boundModel}),nb=!!Q.trim()&&!/^(?:NewFlow\d*|Untitled (?:assistant|agent)(?: \d+)?)$/i.test(Q.trim())&&!et,nw=nx&&nv&&nb&&!eC&&"saving"!==tv,ny=(0,o.useCallback)(e=>{G(t=>t.map(t=>({...t,selected:t.id===e})))},[]),nj=(0,o.useMemo)(()=>{var e;return{...null!=a?a:{id:tN.current,name:Q,nodes:[],edges:[]},id:null!=(e=null==a?void 0:a.id)?e:tN.current,name:Q,...er.trim()?{description:er}:{},nodes:W,edges:J,permissionRules:ef?eh.map(e=>{let{id:t,...n}=e;return n}):void 0}},[J,er,Q,a,W,eh,ef]),nA=(0,o.useMemo)(()=>{var e,t,n;if(tI){let e=W.find(e=>e.id===tI),t=null==e||null==(n=e.data.properties)?void 0:n.boundModel;if("string"==typeof t&&t)return t}if(tj)return tj;let r=null==(t=W.find(e=>{var t;return"process"===e.data.type&&"string"==typeof(null==(t=e.data.properties)?void 0:t.boundModel)&&!!e.data.properties.boundModel}))||null==(e=t.data.properties)?void 0:e.boundModel;return"string"==typeof r?r:null},[tI,tj,W]),nC=(0,o.useCallback)(e=>{G(e.nodes),Z(e.edges),void 0!==e.description&&eo(e.description),tB()},[tB]),nS=(0,o.useCallback)(()=>{let e=W.filter(e=>e.selected).map(e=>({type:"select",id:e.id,selected:!1}));e.length>0&&t7(e)},[W,t7]),nk=(0,o.useCallback)(()=>{ra.debug("handleAutoAlign: auto-arranging flow nodes"),G(e=>(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{direction:r="TB",rankSep:o=120,nodeSep:l=80,mcpOffsetX:a=350,mcpStackY:s=120}=n,i=e.filter(e=>"mcp"===e.type),d=e.filter(e=>"resource"===e.type),c=e.filter(e=>"mcp"!==e.type&&"resource"!==e.type);if(c.length<=1)return e;let u=new Set(c.map(e=>e.id)),p=new Map;for(let e of(c.forEach(e=>p.set(e.id,new Set)),t))!(K(e)||$(e))&&e.source!==e.target&&u.has(e.source)&&u.has(e.target)&&p.get(e.source).add(e.target);let h=new Map;c.forEach(e=>h.set(e.id,0));let m=c.length;for(let e=0;e<m;e++){let e=!1;for(let[t,n]of p){let r=h.get(t)+1;for(let t of n)h.get(t)<r&&(h.set(t,r),e=!0)}if(!e)break}let f=new Map;for(let e of c){let t=h.get(e.id),n=f.get(t);n?n.push(e):f.set(t,[e])}let g=[...f.keys()].sort((e,t)=>e-t),x=new Map,v=0;for(let e of g){let t=f.get(e),n=0,a=0;for(let e of t){let{width:t,height:o}=function(e){var t,n,r,o;let l=e.measured;return{width:null!=(n=null!=(t=null==l?void 0:l.width)?t:e.width)?n:240,height:null!=(o=null!=(r=null==l?void 0:l.height)?r:e.height)?o:80}}(e);"TB"===r?(x.set(e.id,{x:n,y:v}),n+=t+l,a=Math.max(a,o)):(x.set(e.id,{x:v,y:n}),n+=o+l,a=Math.max(a,t))}v+=a+o}let b=(e,n,r)=>{let o=new Set(e.map(e=>e.id)),l=new Map;for(let e of t){let t,r;if(!n(e))continue;let a=o.has(e.source),s=o.has(e.target);a&&!s?(t=e.source,r=e.target):s&&!a&&(t=e.target,r=e.source),t&&r&&x.has(r)&&!l.has(t)&&l.set(t,r)}let a=new Map;for(let t of e){var i;let e=l.get(t.id);if(!e)continue;let n=x.get(e),o=null!=(i=a.get(e))?i:0;a.set(e,o+1),x.set(t.id,{x:n.x+r,y:n.y+o*s})}};return b(i,K,a),b(d,$,-a),e.map(e=>{let t=x.get(e.id);return t?{...e,position:t}:e})})(e,J)),requestAnimationFrame(()=>null==ns?void 0:ns.fitView({padding:.2}))},[J,ns]),nT=(0,o.useCallback)((e,t)=>{ra.debug("handleNodeUpdate: Updating node ".concat(e," properties")),G(n=>{let r=n.map(n=>n.id===e?(ra.info("handleNodeUpdate: Node ".concat(e," properties updated")),{...n,data:t}):n);return function(e,t,n){let r=new Map(e.map(e=>[e.id,e])),o=new Map(t.map(e=>[e.id,e])),l=!1;for(let[e,t]of o){let n=r.get(e);if(n&&n.data.label!==t.data.label){l=!0;break}}return l?t.map(e=>{var t;let l=null==(t=e.data.properties)?void 0:t.promptTemplate;if("string"!=typeof l||!l)return e;let a=function(e,t){let n=[];for(let l of t){var r,o;!("string"==typeof(null==(r=l.data)?void 0:r.edgeType)&&(l.data.edgeType.includes("mcp")||"resource"===l.data.edgeType))&&(l.source===e?n.push(l.target):l.target===e&&(null==(o=l.data)?void 0:o.bidirectional)&&n.push(l.source))}return[...new Set(n)]}(e.id,n);if(0===a.length)return e;let s=[],i=[];for(let e of a){let t=o.get(e);if(!t)continue;let n=r.get(e)||t;s.push(Y(n)),i.push(Y(t))}if(0===i.length)return e;let d=(0,_.E9)(s),c=(0,_.E9)(i),u=new Map;for(let e of a){let t=d.get(e),n=c.get(e);t&&n&&t!==n&&u.set(t,n)}if(0===u.size)return e;let p=function(e,t){if(!e||0===t.size)return e;let n=(0,X.A$)(e);if(0===n.length)return e;let r="",o=0,l=!1;for(let a of n){r+=e.slice(o,a.index);let n="tool"===a.kind&&"handoff"===a.server?t.get(a.name):void 0;n?(r+=(0,X.X8)("tool","handoff",n),l=!0):r+=a.fullMatch,o=a.index+a.fullMatch.length}return r+=e.slice(o),l?r:e}(l,u);return p===l?e:{...e,data:{...e.data,properties:{...e.data.properties,promptTemplate:p}}}}):t}(n,r,J)})},[J]),nI=(0,o.useCallback)((e,t)=>{nT(e,t),eE(!1),e1("edit"),eW(!1),eD(!1),eB(!1),eV(!1),eG(!1),e$(!1),eX(!1),eQ(null),ra.debug("handleNodeUpdate: Closed property modals")},[nT]),nM=(0,o.useCallback)(async(e,t)=>{var n;let r=W.find(t=>t.id===e);if(!r)return void ra.warn("handleConnectMcpServer: process node ".concat(e," not found"));let o=[];try{let e=await B.S.listServerTools(t);!e.error&&Array.isArray(e.tools)&&(o=e.tools.map(e=>e.name))}catch(e){ra.warn("handleConnectMcpServer: could not load tools for ".concat(t),e)}let l=J.filter(t=>{var n;return(null==(n=t.data)?void 0:n.edgeType)==="mcp"&&(t.source===e||t.target===e)}).length,a=H.g.createNode("mcp",{x:r.position.x+350,y:r.position.y+120*l});a.data.label=t,a.data.properties={...null!=(n=a.data.properties)?n:{},boundServer:t,enabledTools:o};let s=(0,V.wn)({source:e,sourceHandle:"process-right-mcp",target:a.id,targetHandle:"mcp-left"},[...W,a]);G(e=>[...e,a]),Z(e=>[...e,s]),ra.info('Connected MCP server "'.concat(t,'" to process node ').concat(e))},[W,J]),nN=(0,o.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"edit";ra.debug("Opening properties for node:",e),eQ(e),"process"===e.data.type&&e1(t),"mcp"===e.data.type?eW(!0):"start"===e.data.type?eD(!0):"finish"===e.data.type?eB(!0):"subflow"===e.data.type?eV(!0):"resource"===e.data.type?eG(!0):"signal"===e.data.type?e$(!0):"trigger"===e.data.type?eX(!0):eE(!0)},[]),nF=(0,o.useCallback)(e=>{ra.debug("onDrop: Node dropped on canvas"),e.preventDefault();let t=e.dataTransfer.getData("application/reactflow");if(ra.debug("onDrop: Node type from data transfer: ".concat(t)),!t||!ns)return void ra.debug("onDrop: Missing required data - type: ".concat(!!t,", reactFlowInstance: ").concat(!!ns));let n=ns.screenToFlowPosition({x:e.clientX,y:e.clientY});ra.debug("onDrop: Calculated position: (".concat(n.x,", ").concat(n.y,")"));let r=nu(t,n);r&&(ra.info("onDrop: Created new ".concat(t," node with ID: ").concat(r.id)),ra.debug("onDrop: Selected new node ".concat(r.id," in the inspector")))},[ns,nu]),nP=(0,o.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect="move"},[]),nR=(0,o.useCallback)(e=>{ra.debug("onInit: ReactFlow instance initialized"),ni(e)},[]);return(0,r.jsxs)(rs,{children:["advanced"===ei&&(0,r.jsx)(eg,{authoringMode:ei,onAddNode:np}),(0,r.jsx)(L.Ln,{children:(0,r.jsxs)(rd,{children:[(0,r.jsxs)(ri,{elevation:1,children:[(0,r.jsxs)(s.default,{sx:{minWidth:0,flex:"1 1 180px"},children:[(0,r.jsx)(i.A,{variant:"subtitle2",fontWeight:850,noWrap:!0,children:Q}),(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",children:"guided"===ei?"".concat(W.filter(e=>["process","subflow","signal"].includes(e.data.type)).length," agent step").concat(1===W.filter(e=>["process","subflow","signal"].includes(e.data.type)).length?"":"s"):"".concat(W.length," nodes \xb7 ").concat(J.length," connections")})]}),(0,r.jsx)(M.A,{size:"small",variant:"outlined",color:"error"===tv?"error":"saved"===tv?"success":"default",icon:"saving"===tv?(0,r.jsx)(N.default,{size:14}):"error"===tv?(0,r.jsx)(rt,{}):"saved"===tv?(0,r.jsx)(re.A,{}):void 0,label:"saving"===tv?"Saving…":"error"===tv?"Save failed":"unsaved"===tv?T&&!tg?"Draft":"Unsaved":"Saved","aria-label":"Save status: ".concat("error"===tv?"failed":tg?"unsaved":tv)}),(0,r.jsx)(F.A,{sx:{m:0,whiteSpace:"nowrap"},control:(0,r.jsx)(P.A,{size:"small",checked:"advanced"===ei,onChange:e=>ec(e.target.checked?"advanced":"guided"),inputProps:{"aria-label":"Expert view"}}),label:"advanced"===ei?"Expert":"Easy"}),"advanced"===ei&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.A,{variant:"outlined",size:"small",startIcon:(0,r.jsx)(A.A,{}),onClick:()=>np("process"),"aria-label":"Add node",title:"Append a Process node after the selected node",children:"Add node"}),(0,r.jsx)(eY,{nodes:W,edges:J}),(0,r.jsx)(p.A,{title:"Auto-align nodes",children:(0,r.jsx)("span",{children:(0,r.jsx)(u.A,{"aria-label":"Auto-Align",onClick:nk,disabled:W.length<=1,color:"primary",size:"small",children:(0,r.jsx)(n7,{})})})}),(0,r.jsx)(R.A,{orientation:"vertical",flexItem:!0}),(0,r.jsx)(p.A,{title:"Undo \xb7 Ctrl/⌘ Z",children:(0,r.jsx)("span",{children:(0,r.jsx)(u.A,{"aria-label":"Undo",onClick:t3,disabled:!t5,color:"primary",size:"small",children:(0,r.jsx)(nJ,{})})})}),(0,r.jsx)(p.A,{title:"Redo \xb7 Ctrl/⌘ Shift Z",children:(0,r.jsx)("span",{children:(0,r.jsx)(u.A,{"aria-label":"Redo",onClick:t6,disabled:!t4,color:"primary",size:"small",children:(0,r.jsx)(nZ,{})})})})]}),(0,r.jsx)(d.A,{variant:"guided"===ei?"outlined":"contained",color:"primary",onClick:()=>void tK(),startIcon:"saving"===tv?(0,r.jsx)(N.default,{size:16,color:"inherit"}):(0,r.jsx)(nq,{}),disabled:!!et||"saving"===tv,"aria-label":"Save Flow",children:"Save"}),"guided"===ei&&I&&(0,r.jsx)(d.A,{variant:"contained",color:"primary",onClick:()=>void t$(),startIcon:(0,r.jsx)(tn,{}),disabled:!nw,children:"Try it"}),("advanced"===ei||a&&!T)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p.A,{title:"More commands",children:(0,r.jsx)(u.A,{id:"more-actions-button","data-tour":"improve-flow","aria-label":"More actions","aria-controls":tt?"more-actions-menu":void 0,"aria-haspopup":"menu","aria-expanded":tt?"true":void 0,onClick:e=>tr(e.currentTarget),color:"primary",size:"small",children:(0,r.jsx)(nQ,{})})}),(0,r.jsxs)(E.A,{id:"more-actions-menu",anchorEl:tt,open:!!tt,onClose:()=>tr(null),MenuListProps:{"aria-labelledby":"more-actions-button"},children:["advanced"===ei&&(0,r.jsx)(z.A,{disabled:W.length<=1,onClick:()=>{tr(null),nk()},children:"Auto-Align"}),"advanced"===ei&&(0,r.jsx)(z.A,{disabled:0===W.length,onClick:tq,children:"Repair automatically (no model)"}),"advanced"===ei&&(0,r.jsx)(z.A,{disabled:0===W.length,onClick:tJ,children:"Repair with AI…"}),a&&!T&&(0,r.jsx)(R.A,{}),a&&!T&&"advanced"===ei&&(0,r.jsx)(z.A,{onClick:()=>{tr(null),tl(""),e8(!0)},children:"AI-Improve"}),a&&!T&&(0,r.jsx)(z.A,{onClick:()=>{tr(null),ti(!0)},children:"guided"===ei?"Previous versions":"History"}),a&&!T&&(0,r.jsx)(z.A,{onClick:()=>{tr(null),eI("duplicate"),eN("".concat(a.name," copy")),ek(!0)},children:"guided"===ei?"Duplicate agent":"Duplicate Flow"}),a&&!T&&(0,r.jsx)(z.A,{sx:{color:"error.main"},onClick:()=>{tr(null),t_()},children:"guided"===ei?"Delete agent":"Delete Flow"})]})]})]}),(0,r.jsx)(h.A,{in:!!eq,unmountOnExit:!0,children:eq&&(0,r.jsx)(m.A,{severity:"warning",onClose:()=>eJ(null),sx:{mb:1},children:eq})}),(0,r.jsx)(h.A,{in:!!e7,unmountOnExit:!0,children:e7&&(0,r.jsx)(m.A,{severity:e7.severity,onClose:()=>te(null),sx:{mb:1},children:e7.message})}),"guided"===ei?(0,r.jsx)(ta,{nodes:W,orderedStepIds:eA.orderedNodeIds,selectedNodeId:null==nm?void 0:nm.id,flowName:Q,flowNameError:et,onFlowNameChange:e=>{ee(e),en(tH(e)),tB()},onSelectNode:ny,onAddTask:nh,onTry:I?()=>{t$()}:void 0,isSaving:"saving"===tv,hasAdvancedFeatures:eC,readyToTry:nw,needsAIConnection:!nv,onSwitchAdvanced:()=>ec("advanced"),models:tw,aiAssistance:tC,selectedModelId:tj,onChooseAssistance:e=>{tS(e),"manual"===e&&tA(null)},onModelChange:tA,onCheckPlausibility:()=>{tM(null),tT(!0)}}):(0,r.jsx)(s.default,{sx:{flex:1,width:"100%",minWidth:0,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:(0,r.jsx)(q.Ay,{ref:na,nodes:W,edges:J,onNodesChange:t7,onEdgesChange:no,onDrop:nF,onDragOver:nP,onInit:nR,reactFlowWrapper:na,onEditNode:nN,onCreateNode:nu,onConvertProcessToSubflow:a?e=>e9(e.id):void 0,onEditEdge:e=>e5(e)})})]})}),("advanced"===ei||nm)&&(0,r.jsx)(e4,{selectedNode:nm,onClearSelection:nS,onCommitNode:nT,onOpenAdvanced:nN,flowName:Q,flowNameError:et,onFlowNameChange:e=>{ee(e),en(tH(e)),tB()},flowDescription:er,onFlowDescriptionChange:e=>{eo(e),tB()},authoringMode:ei,beginnerMode:"guided"===ei,onAuthoringModeChange:ec,permissionRuleCount:eh.length,onOpenPermissionRules:()=>eb(!0),onSuggestTools:e=>{tM(e.id),tT(!0)},onCheckPlausibility:()=>{tM(null),tT(!0)}}),(0,r.jsx)(t9,{open:eR,node:eZ,onClose:()=>{eE(!1),e1("edit")},onSave:nI,mode:e0,flowEdges:J,flowNodes:W,flowId:null==a?void 0:a.id,onConnectMcpServer:e=>{eZ&&nM(eZ.id,e)},authoringMode:ei}),(0,r.jsx)(tc,{open:tk,flow:nj,relatedFlows:S,nodeId:tI,modelId:nA,models:tw,onApply:nC,onApplyRelatedFlows:k,onClose:()=>tT(!1)}),(0,r.jsx)(ne,{open:ez,node:eZ,onClose:()=>eW(!1),onSave:nI,authoringMode:ei}),(0,r.jsx)(nt,{open:eL,node:eZ,onClose:()=>eD(!1),onSave:nI}),(0,r.jsx)(nn,{open:eH,node:eZ,onClose:()=>eB(!1),onSave:nI}),(0,r.jsx)(nd,{open:eO,node:eZ,onClose:()=>eV(!1),onSave:nI,flowId:null==a?void 0:a.id,authoringMode:ei}),(0,r.jsx)(nf,{open:eU,node:eZ,onClose:()=>eG(!1),onSave:nI,flowNodes:W}),(0,r.jsx)(ng,{open:eK,node:eZ,onClose:()=>e$(!1),onSave:nI}),(0,r.jsx)(nL,{open:e_,node:eZ,flowId:(null==a?void 0:a.id)||"",onClose:()=>{eX(!1),eQ(null)},onSave:nI}),(0,r.jsx)(nl,{open:!!e2,edge:e2,onClose:()=>e5(null),onSave:nr}),(0,r.jsx)(nY,{open:!!e3,processNodeId:e3,parentFlow:{id:(null==a?void 0:a.id)||"",name:Q,description:er,folder:null==a?void 0:a.folder,favorite:null==a?void 0:a.favorite,permissionRules:tU(),createdAt:null==a?void 0:a.createdAt,updatedAt:null==a?void 0:a.updatedAt,nodes:W,edges:J},existingFlowNames:C.map(e=>e.name),onClose:()=>e9(null),onAccept:t8}),(0,r.jsx)(nU,{open:ts,flowId:null==a?void 0:a.id,onClose:()=>ti(!1),onRestore:tY}),(0,r.jsx)(n3,{open:e6,onClose:()=>e8(!1),currentFlow:{id:(null==a?void 0:a.id)||"",name:Q,description:er,permissionRules:tU(),nodes:W,edges:J},onImproved:tX,initialDescription:to}),(0,r.jsxs)(f.A,{open:ev,onClose:()=>eb(!1),fullWidth:!0,maxWidth:"md","aria-labelledby":"permission-rules-dialog-title",children:[(0,r.jsx)(g.A,{id:"permission-rules-dialog-title",children:"Flow permission rules"}),(0,r.jsxs)(x.A,{children:[(0,r.jsx)(v.A,{sx:{mb:2},children:"Rules are evaluated in order; the last matching rule wins. Use * to match any action or resource."}),ew&&(0,r.jsx)(m.A,{severity:"error",sx:{mb:2},children:ew}),0===eh.length?(0,r.jsx)(i.A,{color:"text.secondary",sx:{mb:2},children:"No flow-level rules. Add one to allow, deny, or ask for matching tool calls."}):eh.map((e,t)=>(0,r.jsxs)(s.default,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[(0,r.jsxs)(i.A,{"aria-label":"Rule ".concat(t+1),sx:{minWidth:24},children:[t+1,"."]}),(0,r.jsx)(b.A,{label:"Action",size:"small",value:e.action,onChange:t=>tO(e.id,{action:t.target.value}),inputProps:{"aria-label":"Rule ".concat(t+1," action")},sx:{flex:1}}),(0,r.jsx)(b.A,{label:"Resource",size:"small",value:e.resource,onChange:t=>tO(e.id,{resource:t.target.value}),inputProps:{"aria-label":"Rule ".concat(t+1," resource")},sx:{flex:1}}),(0,r.jsxs)(b.A,{select:!0,label:"Effect",size:"small",value:e.effect,onChange:t=>tO(e.id,{effect:t.target.value}),inputProps:{"aria-label":"Rule ".concat(t+1," effect")},sx:{minWidth:100},children:[(0,r.jsx)(z.A,{value:"allow",children:"Allow"}),(0,r.jsx)(z.A,{value:"deny",children:"Deny"}),(0,r.jsx)(z.A,{value:"ask",children:"Ask"})]}),(0,r.jsx)(p.A,{title:"Move rule up",children:(0,r.jsx)("span",{children:(0,r.jsx)(u.A,{"aria-label":"Move rule ".concat(t+1," up"),onClick:()=>tV(t,-1),disabled:0===t,children:(0,r.jsx)(n1.A,{})})})}),(0,r.jsx)(p.A,{title:"Move rule down",children:(0,r.jsx)("span",{children:(0,r.jsx)(u.A,{"aria-label":"Move rule ".concat(t+1," down"),onClick:()=>tV(t,1),disabled:t===eh.length-1,children:(0,r.jsx)(n2,{})})})}),(0,r.jsx)(p.A,{title:"Delete rule",children:(0,r.jsx)(u.A,{"aria-label":"Delete rule ".concat(t+1),onClick:()=>{var t;return t=e.id,void(em(e=>e.filter(e=>e.id!==t)),ex(!0),ey(null),tB())},children:(0,r.jsx)(n0.A,{})})})]},e.id)),(0,r.jsx)(d.A,{startIcon:(0,r.jsx)(A.A,{}),onClick:()=>{em(e=>[...e,ep({action:"",resource:"",effect:"ask"})]),ex(!0),ey(null),tB()},children:"Add rule"})]}),(0,r.jsx)(w.A,{children:(0,r.jsx)(d.A,{onClick:()=>eb(!1),children:"Done"})})]}),(0,r.jsxs)(f.A,{open:eS,onClose:t0,children:[(0,r.jsx)(g.A,{children:"duplicate"===eT?"guided"===ei?"Copy agent":"Copy Flow":"rename"===eT?"guided"===ei?"Rename agent":"Rename Flow":"Unsaved changes"}),(0,r.jsx)(x.A,{children:"unsaved"===eT?(0,r.jsx)(v.A,{children:"You have unsaved changes in this agent. What would you like to do?"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v.A,{children:"duplicate"===eT?"Give the copy a name:":"You are changing this agent’s name. Would you like to rename it or create a copy?"}),(0,r.jsx)(b.A,{autoFocus:!0,margin:"dense",label:"guided"===ei?"Agent name":"Flow Name",type:"text",fullWidth:!0,value:eM,onChange:e=>{let t=e.target.value;eN(t),eP(tH(t))},error:!!eF,helperText:eF,sx:{mt:2}})]})}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:t0,children:"Cancel"}),"unsaved"===eT&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.A,{onClick:()=>{tx(!1),tQ(),t0()},color:"error",children:"Discard Changes"}),(0,r.jsx)(d.A,{onClick:t2,variant:"contained",color:"primary",children:"Save Changes"})]}),"rename"===eT&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.A,{onClick:()=>{let e=tH(eM);if(e)return void eP(e);a&&tZ(a,eM),t0()},children:"Copy"}),(0,r.jsx)(d.A,{onClick:t1,variant:"contained",color:"primary",disabled:!!eF,children:"Rename"})]}),"duplicate"===eT&&(0,r.jsx)(d.A,{onClick:t1,variant:"contained",color:"primary",disabled:!!eF,children:"Copy"})]})]})]})});rp.displayName="FlowBuilder";var rh=n(10915),rm=n(76750),rf=n(49479),rg=n(9164);let rx=(0,W.h)("frontend/components/Flow/FlowManager/GenerateFlowDialog");function rv(e,t){return{id:(0,D.A)(),role:e,content:t,timestamp:Date.now()}}function rb(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}}function rw(e,t){let n=Math.max(0,e.flows.length-1),r=n?" It includes ".concat(n," helper agent").concat(1===n?"":"s","."):"",o=e.errorCount+e.warningCount,l=o?" I found ".concat(o," thing").concat(1===o?"":"s"," worth reviewing before you try it."):" It is ready for you to review and try.";return"".concat(t?"I updated your agent":"Your agent is ready",": ").concat(e.flow.name,".").concat(r).concat(l)}let ry=e=>{var t;let{open:n,onClose:l,onGenerated:a}=e,{settings:c,settingsHydrated:h}=(0,rg.useStorage)(),v=h&&(null==c||null==(t=c.experimental)?void 0:t.enabled)===!0&&!0===c.experimental.flowBasedGenerator,[b,y]=(0,o.useState)([]),[j,A]=(0,o.useState)(""),[S,k]=(0,o.useState)(null),[T,I]=(0,o.useState)([]),[N,P]=(0,o.useState)(null),[R,E]=(0,o.useState)(!1),[W,L]=(0,o.useState)(!1),[B,V]=(0,o.useState)(!1),[U,G]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!n)return;let e=!1;return O.N.loadModels().then(t=>{e||(y(t),A(e=>{var n,r;return t.some(t=>t.id===e)?e:null!=(r=null==(n=t[0])?void 0:n.id)?r:""}))}).catch(t=>{rx.warn("Failed to load generator models",t),e||G("Could not load your models. Configure a model first.")}),()=>{e=!0}},[n]),(0,o.useEffect)(()=>{n&&(k(null),I([]),P(null),E(!1),G(null))},[v,n]);let K=(0,o.useMemo)(()=>T.filter(e=>("user"===e.role||"assistant"===e.role)&&"string"==typeof e.content&&e.content.trim()).map((e,t)=>({id:"string"==typeof e.id?e.id:"flow-generator-".concat(t),role:e.role,content:e.content,timestamp:"number"==typeof e.timestamp?e.timestamp:Date.now()+t,processNodeId:e.processNodeId})),[T]),$=(0,o.useCallback)(async()=>{if(S)return S;let e=(0,D.A)(),{flow:t}=await rf.O.synthesizeFlowGenerator({conversationId:e,modelId:j,allowInstall:R}),n=Date.now();return await rf.O.createConversation({id:e,title:"Experimental Flow generation",flowId:t.id,flowSnapshot:t,createdAt:n,updatedAt:n}),k(e),e},[R,S,j]),_=(0,o.useCallback)(async e=>{let t=e.trim();if(!t||W||!j)return;let n=[...T,rv("user",t)];I(n),G(null),L(!0);try{if(v){var r,o,l,a;let e=await $(),t=await rf.O.completeFlowGeneratorTurn({conversationId:e,messages:n}),s=Array.isArray(null==t?void 0:t.messages)?t.messages:n;I(s);let i=function(e){let t=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(n>6)return null;let r=rb(e);if(!r||"object"!=typeof r)return null;if(r.flow&&Array.isArray(r.flows)&&"string"==typeof r.rootFlowId)return r;if(Array.isArray(r.content))for(let e=r.content.length-1;e>=0;e--){let o=t(r.content[e],n+1);if(o)return o}for(let e of["text","data","result"])if(e in r){let o=t(r[e],n+1);if(o)return o}return null};for(let r=e.length-1;r>=0;r--){var n;let o=t(null==(n=e[r])?void 0:n.content);if(o)return o}return null}(s);if(!i)return void G("The experimental Generation Flow finished without calling draft_generated_flow. You can revise the editable “Experimental Flow Generator” system Flow or try another model.");let d={flow:i.flow,flows:i.flows,rootFlowId:i.rootFlowId,errorCount:null!=(l=null==(r=i.validation)?void 0:r.errorCount)?l:0,warningCount:null!=(a=null==(o=i.validation)?void 0:o.warningCount)?a:0,attempts:s.filter(e=>"user"===e.role).length,installedServers:function(e){let t=new Map,n=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(r>6)return;let o=rb(e);if(o&&"object"==typeof o){if(!0===o.installed&&"string"==typeof o.serverName&&Array.isArray(o.tools)){var l,a,s;t.set(o.serverName,{name:o.serverName,tools:o.tools.map(e=>{var t;return"string"==typeof e?e:e&&"object"==typeof e?String(null!=(t=e.name)?t:""):""}).filter(Boolean),alreadyExisted:!0===o.alreadyExisted,..."string"==typeof(null==(l=o.plan)?void 0:l.command)?{command:o.plan.command}:{},...Array.isArray(null==(a=o.plan)?void 0:a.args)?{args:o.plan.args.map(String)}:{},..."string"==typeof(null==(s=o.plan)?void 0:s.verificationStatus)?{verificationStatus:o.plan.verificationStatus}:{}})}for(let e of Object.values(o))n(e,r+1)}};for(let t of e)n(t.content);return[...t.values()]}(s)};P(d),rx.info("Experimental Generation Flow returned a draft",{flowId:d.rootFlowId,flowCount:d.flows.length,errors:d.errorCount,warnings:d.warningCount});return}if(!N){let e=await H.g.generateFlow(t,j,{allowInstall:R,allowSubflows:!0,maxDepth:2});if(!e.success)return void G(e.error);let r={flow:e.flow,flows:e.flows.map(e=>e.flow),rootFlowId:e.rootFlowId,errorCount:e.validation.errorCount,warningCount:e.validation.warningCount,attempts:e.attempts,installedServers:e.installedServers};rx.info("Draft flow generated",{flowId:r.rootFlowId,flowCount:r.flows.length,attempts:r.attempts,errors:r.errorCount,warnings:r.warningCount,installedServers:r.installedServers.length}),P(r),I([...n,rv("assistant",rw(r,!1))]);return}let e=N.flows.filter(e=>e.id!==N.rootFlowId),s=await H.g.improveFlow(N.flow,t,j,{allowInstall:R,relatedFlows:e});if(!s.success)return void G(s.error);let i={flow:s.flow,flows:s.flows.map(e=>e.flow),rootFlowId:s.rootFlowId,errorCount:s.validation.errorCount,warningCount:s.validation.warningCount,attempts:N.attempts+s.attempts,installedServers:[...N.installedServers,...s.installedServers]};rx.info("Draft flow improved",{flowId:i.rootFlowId,flowCount:i.flows.length,attempts:i.attempts,errors:i.errorCount,warnings:i.warningCount,installedServers:i.installedServers.length}),P(i),I([...n,rv("assistant",rw(i,!0))])}catch(e){G(e instanceof Error?e.message:String(e))}finally{L(!1)}},[R,N,v,W,j,$,T]),X=(0,o.useCallback)(()=>{N&&a(N)},[N,a]),Y=(0,o.useCallback)(async()=>{if(!W&&!B){V(!0),G(null);try{await rf.O.restoreFlowGenerator(),k(null),I([]),P(null)}catch(e){G(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[B,W]),q=(0,o.useCallback)(()=>{W||B||(k(null),I([]),P(null),E(!1),G(null),l())},[B,W,l]);return(0,r.jsxs)(f.A,{open:n,onClose:q,maxWidth:"md",fullWidth:!0,children:[(0,r.jsxs)(g.A,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(C,{color:"primary"}),(0,r.jsxs)(s.default,{sx:{flex:1},children:["Create an agent",v&&(0,r.jsx)(M.A,{label:"Experimental \xb7 Flow-based",size:"small",color:"warning",variant:"outlined",sx:{ml:1}}),(0,r.jsx)(i.A,{variant:"body2",color:"text.secondary",children:v?"The editable multi-stage Generation Flow handles drafting and revisions.":"Describe what you need in your own words. You can refine it together before saving."})]}),v&&(0,r.jsx)(p.A,{title:"Restore the bundled experimental Generation Flow",children:(0,r.jsx)("span",{children:(0,r.jsx)(u.A,{"aria-label":"Restore experimental Generation Flow",onClick:()=>{Y()},disabled:W||B,children:(0,r.jsx)(tN.A,{})})})})]}),(0,r.jsxs)(x.A,{dividers:!0,sx:{p:0},children:[(0,r.jsxs)(s.default,{sx:{p:2,borderBottom:1,borderColor:"divider"},children:[U&&(0,r.jsx)(m.A,{severity:"error",sx:{mb:1.5},onClose:()=>G(null),children:U}),v&&(0,r.jsx)(m.A,{severity:"warning",sx:{mb:1.5},children:"Experimental mode runs entirely through the editable System Flow. It does not fall back to the production generator if that Flow fails to submit a draft."}),(0,r.jsxs)(s.default,{component:"details",sx:{mt:U||v?1.5:0,border:1,borderColor:"divider",borderRadius:2.5,"&[open]":{p:1.5},"&[open] > summary":{mb:1.5}},children:[(0,r.jsx)(s.default,{component:"summary",sx:{px:1.5,py:1.1,cursor:"pointer",color:"text.secondary",fontSize:"0.86rem",fontWeight:700},children:"Advanced options"}),(0,r.jsxs)(e3.A,{size:"small",fullWidth:!0,disabled:W||v&&!!S,children:[(0,r.jsx)(e9.A,{id:"flow-generator-model-label",children:"AI used to build it"}),(0,r.jsx)(e6.A,{labelId:"flow-generator-model-label",label:"AI used to build it",value:j,onChange:e=>A(e.target.value),children:b.map(e=>{var t;return(0,r.jsx)(z.A,{value:e.id,children:(null==(t=e.displayName)?void 0:t.trim())||e.name},e.id)})})]}),(0,r.jsx)(F.A,{sx:{mt:1},control:(0,r.jsx)(ts.A,{checked:R,onChange:e=>E(e.target.checked),disabled:W||v&&!!S}),label:"Allow adding new connected tools"}),(0,r.jsxs)(i.A,{variant:"caption",color:"text.secondary",display:"block",children:["Leave this off unless the agent truly needs an app or service that is not connected yet.",v&&" Expert generation may also create helper flows up to ".concat(2," levels deep.")]}),R&&(0,r.jsx)(m.A,{severity:"warning",sx:{mt:1},children:"FLUJO may download and run third-party connectors on this device. They remain installed after the agent is created."})]})]}),(0,r.jsx)(s.default,{sx:{minHeight:360,maxHeight:"55vh",overflowY:"auto",p:2},children:0===K.length?(0,r.jsxs)(s.default,{sx:{py:8,textAlign:"center",color:"text.secondary"},children:[(0,r.jsx)(i.A,{variant:"h6",children:"What should your agent help with?"}),(0,r.jsx)(i.A,{variant:"body2",children:"Try: “Turn my rough notes into a warm, clear email” or “Research a topic and give me the important points.”"})]}):(0,r.jsx)(rm.A,{messages:K,conversationId:"new-flow-generator",onToggleDisabled:()=>void 0,onSplitConversation:()=>void 0})}),N&&(0,r.jsx)(m.A,{severity:N.errorCount?"warning":"success",sx:{mx:2,mb:1},children:N.errorCount?"The draft is ready, but ".concat(N.errorCount," thing").concat(1===N.errorCount?"":"s"," still need attention."):"Your draft is ready. You can ask for changes or continue to the simple builder."}),(0,r.jsxs)(s.default,{sx:{p:1.5,borderTop:1,borderColor:"divider"},children:[(0,r.jsx)(rh.A,{onSendMessage:e=>{_(e)},disabled:W||!j,placeholder:"Describe the helper you want…"}),W&&(0,r.jsx)(i.A,{variant:"caption",color:"text.secondary",children:N?"Applying your changes and checking the agent…":v?"Running the Flow Architect and Generation Compiler…":"Building your agent and checking that it is ready…"})]})]}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:q,disabled:W||B,children:"Close"}),(0,r.jsx)(d.A,{variant:"contained",onClick:X,disabled:!N||W,startIcon:(0,r.jsx)(C,{}),children:"Continue to simple builder"})]})]})};var rj=n(79508),rA=n(60530),rC=n(15712),rS=n(33077),rk=n(64419);let rT=(0,y.A)((0,r.jsx)("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}),"FilterList"),rI=(0,y.A)((0,r.jsx)("path",{d:"M3 14h4v-4H3zm0 5h4v-4H3zM3 9h4V5H3zm5 5h13v-4H8zm0 5h13v-4H8zM8 5v4h13V5z"}),"ViewList"),rM=(0,y.A)((0,r.jsx)("path",{d:"M14.67 5v6.5H9.33V5zm1 6.5H21V5h-5.33zm-1 7.5v-6.5H9.33V19zm1-6.5V19H21v-6.5zm-7.34 0H3V19h5.33zm0-1V5H3v6.5z"}),"ViewModule");var rN=n(28466),rF=n(3986),rP=n(94885),rR=n(15686),rE=n(91665),rz=n(22573),rW=n(38459),rL=n(88377),rD=n(64598),rH=n(23201);let rB=(0,W.h)("components/Flow/FlowDashboard/FlowDashboard");function rO(e,t){return e+Math.round(255*t).toString(16).padStart(2,"0")}let rV=e=>{let{flows:t,selectedFlow:n,onSelectFlow:l,onDeleteFlow:c,onCopyFlow:p,onEditFlow:h,onOpenInChat:m,onCreateFlow:f,onSetFolder:g,onToggleFavorite:x,isLoading:v=!1}=e,[w,y]=(0,o.useState)(""),[j,C]=(0,rn.Xk)("flujo-ui:flows:sort","name-asc"),[S,k]=(0,rn.Xk)("flujo-ui:flows:view","grid"),[T,M]=(0,o.useState)(null),[N,F]=(0,rn.Xk)("flujo-ui:flows:group",rW.FM),[P,W]=(0,o.useState)(null),[L,D]=(0,rn.Xk)("flujo-ui:flows:collapsed",[]),H=(0,o.useMemo)(()=>new Set(L),[L]),[B,O]=(0,o.useState)({});(0,o.useEffect)(()=>{let e=!1;return(async()=>{let t={};try{let e=await fetch("/api/model");if(e.ok){let n=await e.json();Array.isArray(n)&&(t.models=n)}}catch(e){rB.warn("Could not load models for flow badges",e)}try{let e=await fetch("/api/mcp/servers");if(e.ok){let n=await e.json();Array.isArray(n)&&(t.servers=n.map(e=>({name:e.name,status:e.disabled?"disabled":void 0})))}}catch(e){rB.warn("Could not load servers for flow badges",e)}e||O(t)})(),()=>{e=!0}},[]);let V=(0,o.useMemo)(()=>{let e={};for(let n of t)try{e[n.id]=e_(n,B)}catch(e){rB.warn("Failed to validate flow for badge",{flowId:n.id,error:e})}return e},[t,B]),U=(0,a.A)(),G=(0,rC.A)(U.breakpoints.down("sm")),K=(0,rC.A)(U.breakpoints.down("md")),$=()=>{M(null)},_=e=>{C(e),$()},X=e=>{F(e),W(null)},Y=(0,o.useMemo)(()=>{rB.debug("Filtering and sorting flows",{searchTerm:w,sortOption:j});let e=t;if(""!==w.trim()){let n=w.toLowerCase();e=t.filter(e=>e.name.toLowerCase().includes(n))}return(0,rL.NP)(e,j)},[t,w,j]),{ref:q,showBackToTop:J,scrollToTop:Q}=(0,rD.R)("flujo-ui:scroll:flows",{deps:[v,Y.length]}),ee=(0,o.useMemo)(()=>(0,rW.yF)(t,e=>e.folder),[t]),et=(0,o.useMemo)(()=>"folder"===N?(0,rW.Je)(Y,e=>e.folder):"sort"===N?(0,rW.Az)(Y,e=>(0,rL.ts)(e,j)):[],[N,Y,j]),en=e=>(0,r.jsx)(rS.Ay,{container:!0,spacing:2.5,children:e.map(e=>(0,r.jsx)(rS.Ay,{item:!0,xs:12,sm:"compact"===S?12:6,md:"compact"===S?12:3==("compact"===S||G?1:K?2:3)?4:6,children:(0,r.jsx)(ns.A,{flow:e,selected:n===e.id,onSelect:l,onDelete:c,onCopy:p,onEdit:h,onOpenInChat:m,onSetFolder:g,onToggleFavorite:x,folders:ee,validation:V[e.id]})},e.id))});return(0,r.jsxs)(s.default,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,r.jsx)(I.A,{elevation:1,sx:{mb:2,p:1},children:(0,r.jsxs)(s.default,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:1,alignItems:{xs:"stretch",sm:"center"},justifyContent:"space-between"},children:[(0,r.jsx)(b.A,{placeholder:"Search agents...",variant:"outlined",size:"small",fullWidth:!0,value:w,onChange:e=>{y(e.target.value)},InputProps:{startAdornment:(0,r.jsx)(Z.A,{position:"start",children:(0,r.jsx)(tF.A,{fontSize:"small"})})},sx:{maxWidth:{sm:300}}}),(0,r.jsxs)(s.default,{sx:{display:"flex",gap:1,alignItems:"center"},children:[(0,r.jsxs)(s.default,{sx:{display:"flex",backgroundColor:U.palette.background.default,borderRadius:1,border:"1px solid ".concat(U.palette.divider),overflow:"hidden"},children:[(0,r.jsx)(u.A,{"aria-label":"Show agent cards",size:"small",onClick:()=>k("grid"),color:"grid"===S?"primary":"default",sx:{borderRadius:0,backgroundColor:"grid"===S?rO(U.palette.primary.main,.1):"transparent"},children:(0,r.jsx)(rM,{fontSize:"small"})}),(0,r.jsx)(u.A,{"aria-label":"Show compact agent list",size:"small",onClick:()=>k("compact"),color:"compact"===S?"primary":"default",sx:{borderRadius:0,backgroundColor:"compact"===S?rO(U.palette.primary.main,.1):"transparent"},children:(0,r.jsx)(rI,{fontSize:"small"})})]}),(0,r.jsx)(u.A,{size:"small",onClick:e=>W(e.currentTarget),color:"none"!==N?"primary":"default",sx:{border:"1px solid ".concat(U.palette.divider),backgroundColor:U.palette.background.default},title:"Group cards","aria-label":"Group agents",children:(0,r.jsx)(rP.A,{fontSize:"small"})}),(0,r.jsx)(u.A,{"aria-label":"Sort agents",size:"small",onClick:e=>{M(e.currentTarget)},sx:{border:"1px solid ".concat(U.palette.divider),backgroundColor:U.palette.background.default},children:(0,r.jsx)(rk.A,{fontSize:"small"})})]})]})}),(0,r.jsxs)(s.default,{sx:{display:"flex",justifyContent:"space-between",mb:2,px:1},children:[(0,r.jsxs)(i.A,{variant:"body2",color:"textSecondary",children:[Y.length," of ",t.length," agents",w&&' matching "'.concat(w,'"')]}),(0,r.jsxs)(i.A,{variant:"body2",color:"textSecondary",children:["Showing: ","name-asc"===j?"Name (A-Z)":"name-desc"===j?"Name (Z-A)":"newest"===j?"Newest first":"oldest"===j?"Oldest first":"most-nodes"===j?"Most steps":"Fewest steps"]})]}),(0,r.jsx)(s.default,{ref:q,sx:{flex:1,overflow:"auto",px:1,pb:2},children:v?(0,r.jsx)(rS.Ay,{container:!0,spacing:2.5,children:Array(6).fill(0).map((e,t)=>(0,r.jsx)(rS.Ay,{item:!0,xs:12,sm:"compact"===S?12:6,md:"compact"===S?12:4,children:(0,r.jsx)(ns.o,{})},"skeleton-".concat(t)))}):Y.length>0?"none"===N?en(Y):et.map(e=>(0,r.jsx)(rz.A,{label:e.label,count:e.items.length,expanded:!H.has(e.key),onToggle:()=>(e=>{D(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])})(e.key),showFolderIcon:"folder"===N,children:en(e.items)},e.key)):(0,r.jsxs)(s.default,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",p:4,backgroundColor:U.palette.background.paper,borderRadius:1,border:"1px dashed ".concat(U.palette.divider),height:"100%",minHeight:200},children:[(0,r.jsx)(i.A,{variant:"h6",gutterBottom:!0,color:"textSecondary",children:w?"No matching agents":"No agents yet"}),w?(0,r.jsxs)(i.A,{variant:"body2",color:"textSecondary",align:"center",children:["No agents match that search.",(0,r.jsxs)(s.default,{component:"span",display:"block",mt:1,children:["Try a different search term or ",(0,r.jsx)(d.A,{size:"small",onClick:()=>y(""),children:"clear the search"})]})]}):(0,r.jsxs)(i.A,{variant:"body2",color:"textSecondary",align:"center",children:["Create a helper for something you do often. You can explain the job in everyday language.",f&&(0,r.jsx)(s.default,{component:"span",display:"block",mt:2,children:(0,r.jsx)(d.A,{variant:"contained",color:"primary",startIcon:(0,r.jsx)(A.A,{}),onClick:f,children:"Create My First Agent"})})]})]})}),(0,r.jsxs)(E.A,{anchorEl:P,open:!!P,onClose:()=>W(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[(0,r.jsxs)(z.A,{selected:"none"===N,onClick:()=>X("none"),children:[(0,r.jsx)(ew.A,{children:(0,r.jsx)(rR.A,{fontSize:"small"})}),(0,r.jsx)(ey.A,{primary:"No grouping"})]}),(0,r.jsxs)(z.A,{selected:"folder"===N,onClick:()=>X("folder"),children:[(0,r.jsx)(ew.A,{children:(0,r.jsx)(rE.A,{fontSize:"small"})}),(0,r.jsx)(ey.A,{primary:"By folder"})]}),(0,r.jsxs)(z.A,{selected:"sort"===N,onClick:()=>X("sort"),children:[(0,r.jsx)(ew.A,{children:(0,r.jsx)(rP.A,{fontSize:"small"})}),(0,r.jsx)(ey.A,{primary:"By sort setting"})]})]}),(0,r.jsxs)(E.A,{anchorEl:T,open:!!T,onClose:$,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[(0,r.jsxs)(z.A,{onClick:()=>_("name-asc"),children:[(0,r.jsx)(ew.A,{children:(0,r.jsx)(rN.A,{fontSize:"small"})}),(0,r.jsx)(ey.A,{primary:"Name (A-Z)"})]}),(0,r.jsxs)(z.A,{onClick:()=>_("name-desc"),children:[(0,r.jsx)(ew.A,{children:(0,r.jsx)(rN.A,{fontSize:"small",sx:{transform:"scaleX(-1)"}})}),(0,r.jsx)(ey.A,{primary:"Name (Z-A)"})]}),(0,r.jsx)(R.A,{}),(0,r.jsxs)(z.A,{onClick:()=>_("newest"),children:[(0,r.jsx)(ew.A,{children:(0,r.jsx)(rF.A,{fontSize:"small"})}),(0,r.jsx)(ey.A,{primary:"Newest first"})]}),(0,r.jsxs)(z.A,{onClick:()=>_("oldest"),children:[(0,r.jsx)(ew.A,{children:(0,r.jsx)(rF.A,{fontSize:"small",sx:{transform:"scaleX(-1)"}})}),(0,r.jsx)(ey.A,{primary:"Oldest first"})]}),(0,r.jsx)(R.A,{}),(0,r.jsxs)(z.A,{onClick:()=>_("most-nodes"),children:[(0,r.jsx)(ew.A,{children:(0,r.jsx)(rT,{fontSize:"small"})}),(0,r.jsx)(ey.A,{primary:"Most nodes"})]}),(0,r.jsxs)(z.A,{onClick:()=>_("least-nodes"),children:[(0,r.jsx)(ew.A,{children:(0,r.jsx)(rT,{fontSize:"small",sx:{transform:"scaleY(-1)"}})}),(0,r.jsx)(ey.A,{primary:"Least nodes"})]})]}),(0,r.jsx)(rH.A,{show:J,onClick:Q})]})},rU=(0,W.h)("app/flows/page"),rG=()=>{var e;rU.debug("Rendering FlowsPage"),(0,a.A)();let t=(0,l.useRouter)(),[n,y]=(0,o.useState)([]),[T,I]=(0,o.useState)(null),[M,N]=(0,o.useState)(!0),[F,P]=(0,o.useState)(!1),R=(0,o.useRef)(null),[E,z]=(0,o.useState)(null),[W,L]=(0,o.useState)([]),[B,O]=(0,o.useState)(!1),V=(0,o.useRef)(!1),[U,G]=(0,o.useState)(!1),[K,$]=(0,o.useState)(null),[_,X]=(0,o.useState)(""),[Y,q]=(0,o.useState)(null),[J,Z]=(0,o.useState)({open:!1,message:"",severity:"info"});(0,o.useEffect)(()=>{rU.info("Loading flows"),(async()=>{N(!0);try{let e=await H.g.loadFlows();rU.debug("Flows loaded successfully",{count:e.length}),y(e),T&&(e.some(e=>e.id===T)||(null==E?void 0:E.id)===T||(rU.warn("Previously selected flow no longer exists",{flowId:T}),I(null),P(!1),er("The previously selected flow is no longer available","warning")))}catch(e){rU.error("Error loading flows",e),er("Failed to load agents","error")}finally{N(!1)}})()},[T,E]);let Q=(0,o.useCallback)(e=>{rU.debug("Flow selected",{flowId:e}),I(e),P(!0)},[]),ee=(0,o.useCallback)(e=>{rU.debug("Opening flow in chat",{flowId:e}),t.push("/chat?flow=".concat(encodeURIComponent(e)))},[t]),et=(0,o.useCallback)(()=>{T&&t.push("/chat?flow=".concat(encodeURIComponent(T)))},[T,t]),en=(0,o.useRef)(!1);(0,o.useEffect)(()=>{if(en.current||M)return;let e=new URLSearchParams(window.location.search).get("flow");if(!e){en.current=!0;return}n.some(t=>t.id===e)&&(en.current=!0,Q(e))},[M,n,Q]),(0,o.useEffect)(()=>{if(!(F&&T))return;let e=e=>{R.current?R.current.requestNavigation(e):e()};return(0,rA.QO)(e),()=>(0,rA.bH)(e)},[F,T]);let er=(0,o.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";rU.debug("Showing snackbar",{message:e,severity:t}),Z({open:!0,message:e,severity:t})},[]),eo=(0,o.useCallback)(()=>{rU.debug("Returning to dashboard");let e=()=>{if(P(!1),E&&E.id===T){let e=W.length>0;z(null),L([]),I(null),er(e?"Generated draft (and its subflows) discarded":"Generated draft discarded","info")}};R.current?R.current.requestNavigation(e):e()},[E,W,T,er]),el=(0,o.useCallback)(()=>{Z(e=>({...e,open:!1}))},[]);(0,o.useEffect)(()=>{if(!J.open||"error"===J.severity)return;let e=setTimeout(()=>{Z(e=>({...e,open:!1}))},6e3);return()=>clearTimeout(e)},[J.open,J.message,J.severity]);let ea=(0,o.useCallback)(e=>(rU.debug("Validating flow name",{name:e}),e.trim())?RegExp("^[\\p{L}\\p{N}_ -]+$","u").test(e.trim())?n.some(t=>t.name.trim().toLowerCase()===e.trim().toLowerCase())?(rU.debug("Flow name validation failed: duplicate name"),"An agent with this name already exists"):(rU.debug("Flow name validation passed"),null):(rU.debug("Flow name validation failed: invalid characters"),"Use letters, numbers, spaces, underscores, or dashes"):(rU.debug("Flow name validation failed: empty name"),"Agent name cannot be empty"),[n]),es=async e=>{rU.info("Saving flow",{flowId:e.id,flowName:e.name});try{if((null==E?void 0:E.id)===e.id&&W.length>0){for(let e of(rU.info("Persisting generated subflow descendants before the root",{count:W.length}),W)){let t=n.some(t=>t.id===e.id)?await H.g.updateFlow(e):await H.g.addFlow(e);if(!t.success)return rU.error("Failed to save a generated subflow",{error:t.error,childId:e.id}),er(t.error||"Failed to save a generated subflow","error"),!1}y(e=>{let t=new Set(e.map(e=>e.id)),n=W.filter(e=>!t.has(e.id));return n.length?[...e,...n]:e}),L([])}let t=n.some(t=>t.id===e.id)?await H.g.updateFlow(e):await H.g.addFlow(e);if(!t.success)return rU.error("Failed to save flow",{error:t.error}),er(t.error||"Failed to save flow","error"),!1;return rU.debug("Flow saved successfully"),y(t=>{let n=t.findIndex(t=>t.id===e.id);if(!(n>=0))return rU.debug("Adding new flow to state"),[...t,e];{rU.debug("Updating existing flow in state");let r=[...t];return r[n]=e,r}}),(null==E?void 0:E.id)===e.id&&z(null),I(e.id),er("Agent saved","success"),!0}catch(e){return rU.error("Error saving flow",e),er("Failed to save flow","error"),!1}},ei=(0,o.useCallback)((e,t)=>{y(n=>[...n.filter(n=>n.id!==e.id&&n.id!==t.id),e,t]),I(e.id),er('Created subflow "'.concat(t.name,'"'),"success")},[er]),ed=async e=>{rU.info("Deleting flow",{flowId:e});try{await H.g.deleteFlow(e),rU.debug("Flow deleted successfully"),y(t=>t.filter(t=>t.id!==e)),T===e&&(rU.debug("Clearing selected flow as it was deleted"),I(null),P(!1)),er("Flow deleted","success")}catch(e){rU.error("Error deleting flow",e),er("Failed to delete flow","error")}},ec=(0,o.useCallback)(async(e,t)=>{rU.info("Setting flow folder",{flowId:e,folder:t});let r=n.find(t=>t.id===e);if(!r)return void rU.warn("Flow to move not found",{flowId:e});let o={...r,folder:t&&t.trim()?t.trim():void 0};try{let t=await H.g.updateFlow(o);if(!t.success)return void er(t.error||"Failed to move flow to folder","error");y(t=>t.map(t=>t.id===e?o:t)),er(o.folder?'Moved to "'.concat(o.folder,'"'):"Removed from folder","success")}catch(e){rU.error("Error setting flow folder",e),er("Failed to move flow to folder","error")}},[n,er]),eu=(0,o.useCallback)(async e=>{rU.info("Toggling flow favorite",{flowId:e});let t=n.find(t=>t.id===e);if(!t)return void rU.warn("Flow to favorite not found",{flowId:e});let r=!t.favorite,o={...t,favorite:r||void 0};try{let t=await H.g.updateFlow(o);if(!t.success)return void er(t.error||"Failed to update favorite","error");y(t=>t.map(t=>t.id===e?o:t)),er(r?"Added to favorites":"Removed from favorites","success")}catch(e){rU.error("Error toggling flow favorite",e),er("Failed to update favorite","error")}},[n,er]),ep=e=>{rU.info("Copying flow",{flowId:e});let t=n.find(t=>t.id===e);t?(rU.debug("Found flow to copy",{flowName:t.name}),$(t),X("".concat(t.name," copy")),G(!0)):(rU.warn("Flow to copy not found",{flowId:e}),er("Agent not found","error"))},eh=()=>{rU.debug("Closing copy flow dialog"),G(!1),$(null),X(""),q(null)},em=async()=>{if(rU.info("Confirming flow copy"),!K){rU.warn("No flow to copy"),er("No agent selected to copy","error");return}let e=ea(_);if(e){rU.debug("Flow name validation failed",{error:e}),q(e);return}let t=(0,D.A)();rU.debug("Creating new flow from copy",{newId:t,newName:_});let n={id:t,name:_,description:K.description,nodes:K.nodes,edges:K.edges,folder:K.folder,favorite:K.favorite};await es(n)&&(eh(),rU.debug("Selecting newly copied flow"),I(n.id),P(!0),er('Created a copy named "'.concat(_,'"'),"success"))},ef=(0,o.useCallback)(e=>{var t,n,r;rU.info("Opening generated draft flow",{flowId:e.flow.id,attempts:e.attempts,errors:e.errorCount,warnings:e.warningCount}),O(!1);let o=(null!=(n=e.flows)?n:[]).filter(t=>t.id!==e.rootFlowId);z(e.flow),L(o),I(e.flow.id),P(!0);let l=null!=(r=null==(t=e.installedServers)?void 0:t.filter(e=>!e.alreadyExisted))?r:[],a=l.length>0?" Connected ".concat(l.map(e=>e.name).join(", "),"."):"",s=o.length>0?" It also includes ".concat(o.length," helper agent").concat(1===o.length?"":"s","."):"";e.errorCount>0?er("Your draft is ready, but ".concat(e.errorCount," thing").concat(1===e.errorCount?"":"s"," need attention before it can run. Review it here; Expert view has the detailed fixes.").concat(s).concat(a),"warning"):e.warningCount>0?er("Your agent draft is ready. Review the suggestions, then try it.".concat(s).concat(a),"info"):er("Your agent draft is ready. Review it, then choose Try it.".concat(s).concat(a),"success")},[er]),eg=(0,o.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"guided";rU.info("Creating new flow");let t="Untitled agent",r=t,o=2;for(;n.some(e=>e.name===r);)r="".concat(t," ").concat(o),o++;let l=H.g.createNewFlow(r);(0,rn.vi)("flujo-ui:flow-builder:mode",e),z(l),L([]),I(l.id),P(!0),er("advanced"===e?"Your new agent is ready in Expert view. Add and connect the nodes you need.":"Your new agent is ready. Give it a name, add a task, then try it.","info")},[n,er]);return(0,o.useEffect)(()=>{if(!V.current&&!M){if("assistant"!==new URLSearchParams(window.location.search).get("create")){V.current=!0;return}V.current=!0,eg("guided"),t.replace("/flows")}},[eg,M,t]),(0,r.jsxs)(s.default,{sx:{height:{xs:"auto",md:"calc(100dvh - var(--app-bar-height))"},minHeight:"calc(100dvh - var(--app-bar-height))",display:"flex",flexDirection:"column",overflow:{xs:"visible",md:"hidden"}},children:[(0,r.jsx)(rj.default,{eyebrow:F?"My agents":"Create",icon:S.A,compact:F,title:F&&T?(null==E?void 0:E.id)===T?"".concat(E.name," \xb7 Draft"):(null==(e=n.find(e=>e.id===T))?void 0:e.name)||"Agent":"My agents",description:F?"Choose what it should do, in order. You can always change it later.":"Create helpful AI agents, keep them organized, and try them whenever you need them.",leading:F&&T?(0,r.jsx)(u.A,{color:"primary",onClick:eo,"aria-label":"Back to my agents",sx:{border:1,borderColor:"divider"},children:(0,r.jsx)(j,{})}):void 0,actions:F?void 0:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p.A,{title:"Describe what you need in everyday language",describeChild:!0,children:(0,r.jsx)(d.A,{variant:"contained",color:"primary",startIcon:(0,r.jsx)(C,{}),onClick:()=>O(!0),"data-tour":"generate-flow",children:"Create with AI"})}),(0,r.jsx)(p.A,{title:"Create an agent step by step in easy mode",describeChild:!0,children:(0,r.jsx)(d.A,{variant:"outlined",color:"primary",startIcon:(0,r.jsx)(A.A,{}),onClick:()=>eg("guided"),"data-tour":"new-flow",children:"Start simple"})}),(0,r.jsx)(p.A,{title:"Build directly with the full node editor",describeChild:!0,children:(0,r.jsx)(d.A,{variant:"outlined",color:"primary",startIcon:(0,r.jsx)(k.A,{}),onClick:()=>eg("advanced"),"data-tour":"new-expert-flow",children:"Start expert"})})]})}),(0,r.jsx)(h.A,{in:J.open,unmountOnExit:!0,children:(0,r.jsx)(m.A,{severity:J.severity,onClose:el,sx:{borderRadius:0},children:J.message})}),(0,r.jsx)(s.default,{sx:{flex:1,minHeight:0,overflow:{xs:"visible",md:"hidden"}},children:(()=>{if(F&&T){var e;let t=null!=(e=n.find(e=>e.id===T))?e:(null==E?void 0:E.id)===T?E:void 0;return t?(0,r.jsx)(c.A,{in:!0,timeout:300,children:(0,r.jsx)(s.default,{sx:{height:{xs:"auto",md:"100%"}},children:(0,r.jsx)(rp,{ref:R,initialFlow:t,onSave:es,onDelete:ed,onConversionCommitted:ei,allFlows:[...n.filter(e=>!W.some(t=>t.id===e.id)),...W],relatedDraftFlows:W,onRelatedDraftFlowsChange:L,isDraft:(null==E?void 0:E.id)===t.id,onTry:et},T)})}):(0,r.jsxs)(s.default,{sx:{p:4,textAlign:"center"},children:[(0,r.jsx)(i.A,{variant:"h6",color:"error",children:"Agent not found"}),(0,r.jsx)(d.A,{variant:"contained",onClick:eo,sx:{mt:2},children:"Back to My Agents"})]})}return(0,r.jsx)(c.A,{in:!0,timeout:300,children:(0,r.jsx)(s.default,{sx:{height:{xs:"auto",md:"100%"}},children:(0,r.jsx)(rV,{flows:n,selectedFlow:T,onSelectFlow:Q,onDeleteFlow:ed,onCopyFlow:ep,onCreateFlow:()=>eg("guided"),onSetFolder:ec,onToggleFavorite:eu,onOpenInChat:ee,isLoading:M})})})})()}),(0,r.jsxs)(f.A,{open:U,onClose:eh,children:[(0,r.jsx)(g.A,{children:"Copy agent"}),(0,r.jsxs)(x.A,{children:[(0,r.jsx)(v.A,{children:"Give the copy a name:"}),(0,r.jsx)(b.A,{autoFocus:!0,margin:"dense",label:"Agent name",type:"text",fullWidth:!0,value:_,onChange:e=>{let t=e.target.value;rU.debug("Flow name changed",{name:t}),X(t),q(ea(t))},error:!!Y,helperText:Y})]}),(0,r.jsxs)(w.A,{children:[(0,r.jsx)(d.A,{onClick:eh,children:"Cancel"}),(0,r.jsx)(d.A,{onClick:em,variant:"contained",color:"primary",disabled:!!Y,children:"Copy"})]})]}),(0,r.jsx)(ry,{open:B,onClose:()=>O(!1),onGenerated:ef})]})}},40520:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M10 15h5.88c.27-.31.67-.5 1.12-.5.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5c-.44 0-.84-.19-1.12-.5H11.9c-.46 2.28-2.48 4-4.9 4-2.76 0-5-2.24-5-5 0-2.42 1.72-4.44 4-4.9v2.07c-1.16.41-2 1.53-2 2.83 0 1.65 1.35 3 3 3s3-1.35 3-3zm2.5-11c1.65 0 3 1.35 3 3h2c0-2.76-2.24-5-5-5s-5 2.24-5 5c0 1.43.6 2.71 1.55 3.62l-2.35 3.9c-.68.14-1.2.75-1.2 1.48 0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5c0-.16-.02-.31-.07-.45l3.38-5.63C10.49 9.61 9.5 8.42 9.5 7c0-1.65 1.35-3 3-3m4.5 9c-.64 0-1.23.2-1.72.54l-3.05-5.07C11.53 8.35 11 7.74 11 7c0-.83.67-1.5 1.5-1.5S14 6.17 14 7c0 .15-.02.29-.06.43l2.19 3.65c.28-.05.57-.08.87-.08 2.76 0 5 2.24 5 5s-2.24 5-5 5c-1.85 0-3.47-1.01-4.33-2.5h2.67c.48.32 1.05.5 1.66.5 1.65 0 3-1.35 3-3s-1.35-3-3-3"}),"Webhook")},41356:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M18 23H4c-1.1 0-2-.9-2-2V7h2v14h14zM15 1H8c-1.1 0-1.99.9-1.99 2L6 17c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V7zm1.5 14h-6v-2h6zm0-6h-2v2h-2V9h-2V7h2V5h2v2h2z"}),"Difference")},51314:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM8 9h8v10H8zm7.5-5-1-1h-5l-1 1H5v2h14V4z"}),"DeleteOutline")},60530:(e,t,n)=>{"use strict";n.d(t,{L_:()=>a,QO:()=>o,bH:()=>l});let r=null;function o(e){r=e}function l(e){r===e&&(r=null)}function a(e){return!!r&&(r(e),!0)}},61267:(e,t,n)=>{"use strict";n.d(t,{A:()=>B});var r=n(95155),o=n(12115),l=n(33567),a=n(78470),s=n(41983),i=n(8532),d=n(84578),c=n(94049),u=n(25635),p=n(28548),h=n(29767),m=n(53062),f=n(1702),g=n(14915),x=n(4484),v=n(89623),b=n(11665),w=n(91665),y=n(62291),j=n(47529),A=n(88107),C=n(43076),S=n(73288),k=n(2778),T=n(52363),I=n(65036),M=n(4474),N=n(22003),F=n(21067),P=n(75912),R=n(91871),E=n(36741),z=n(48563);let W=e=>{var t,n,o,l,a,s,i,d,h;let{title:m,attempt:f}=e;return(0,r.jsxs)(c.default,{sx:{mb:2},children:[(0,r.jsxs)(c.default,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[f.ok?(0,r.jsx)(E.A,{color:"success",fontSize:"small"}):(0,r.jsx)(z.A,{color:"error",fontSize:"small"}),(0,r.jsx)(u.A,{variant:"subtitle2",children:m}),"number"==typeof f.status&&(0,r.jsx)(p.A,{size:"small",label:"HTTP ".concat(f.status)}),(0,r.jsx)(p.A,{size:"small",variant:"outlined",label:"".concat(f.durationMs," ms")})]}),f.ok?(0,r.jsxs)(u.A,{variant:"body2",color:"text.secondary",sx:{pl:3},children:["Response: ",f.content?'"'.concat(f.content,'"'):"(empty)"]}):(0,r.jsxs)(c.default,{sx:{pl:3},children:[(0,r.jsx)(u.A,{variant:"body2",color:"error.main",children:null==(t=f.error)?void 0:t.message}),((null==(n=f.error)?void 0:n.code)||(null==(o=f.error)?void 0:o.type))&&(0,r.jsxs)(u.A,{variant:"caption",color:"text.secondary",display:"block",children:[(null==(l=f.error)?void 0:l.type)?"type: ".concat(f.error.type):"",(null==(a=f.error)?void 0:a.type)&&(null==(s=f.error)?void 0:s.code)?" \xb7 ":"",(null==(i=f.error)?void 0:i.code)?"code: ".concat(f.error.code):""]}),(null==(d=f.error)?void 0:d.retryAfter)&&(0,r.jsxs)(u.A,{variant:"caption",color:"text.secondary",display:"block",children:["retry-after: ",f.error.retryAfter,"s"]}),(null==(h=f.error)?void 0:h.body)!==void 0&&(0,r.jsx)(c.default,{component:"pre",sx:{mt:.5,p:1,bgcolor:"action.hover",borderRadius:1,fontSize:"0.7rem",overflowX:"auto",maxHeight:160},children:JSON.stringify(f.error.body,null,2)})]})]})},L=e=>{let{open:t,modelLabel:n,loading:o,result:l,error:a,onClose:s,onRetry:i}=e,d=(null==l?void 0:l.provider)==="codex"?"Codex SDK (used by flows)":"OpenAI SDK (used by flows)";return(0,r.jsxs)(k.A,{open:t,onClose:s,maxWidth:"sm",fullWidth:!0,children:[(0,r.jsxs)(T.A,{children:["Test model: ",n]}),(0,r.jsx)(I.A,{dividers:!0,children:o?(0,r.jsxs)(c.default,{sx:{display:"flex",alignItems:"center",gap:2,py:3},children:[(0,r.jsx)(M.default,{size:24}),(0,r.jsx)(u.A,{variant:"body2",children:"Sending a direct test request (SDK + axios)…"})]}):a?(0,r.jsx)(N.A,{severity:"error",children:a}):l?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.A,{severity:l.ok?"success":"warning",sx:{mb:2},children:l.diagnosis}),(0,r.jsxs)(u.A,{variant:"caption",color:"text.secondary",display:"block",sx:{mb:2},children:["model: ",l.model,l.baseUrl?" \xb7 ".concat(l.baseUrl):"",l.provider?" \xb7 ".concat(l.provider):""]}),(0,r.jsx)(F.A,{sx:{mb:2}}),(0,r.jsx)(W,{title:d,attempt:l.sdk}),(0,r.jsx)(W,{title:"axios (independent cross-check)",attempt:l.axios})]}):null}),(0,r.jsxs)(P.A,{children:[(0,r.jsx)(R.A,{onClick:i,disabled:o,children:"Run again"}),(0,r.jsx)(R.A,{onClick:s,variant:"contained",children:"Close"})]})]})};var D=n(81956);let H=(0,S.h)("frontend/components/models/list/ModelCard"),B=e=>{let{model:t,onEdit:n,onDelete:S,folder:k,folders:T=[],onSetFolder:I,selectable:M=!1,selected:N=!1,onSelect:F,onToggleFavorite:P}=e,R=(0,l.A)(),[E,z]=(0,o.useState)(!1),[W,B]=(0,o.useState)(!1),[O,V]=(0,o.useState)(null),[U,G]=(0,o.useState)(null),[K,$]=(0,o.useState)(null),_=async()=>{B(!0),G(null),V(null);try{let e=await (0,C.X)().testModel({modelId:t.id});V(e)}catch(e){H.error("Model test failed",{modelId:t.id,error:e}),G(e instanceof Error?e.message:"Failed to run test")}finally{B(!1)}},X=P?(0,r.jsx)(a.A,{title:t.favorite?"Remove from favorites":"Add to favorites",arrow:!0,placement:"top",children:(0,r.jsx)(s.A,{size:"small","aria-label":t.favorite?"remove from favorites":"add to favorites",onClick:e=>{e.stopPropagation(),null==P||P(t.id)},sx:{position:"absolute",top:4,left:4,zIndex:2,color:t.favorite?R.palette.warning.main:R.palette.text.secondary,backgroundColor:(0,i.X4)(R.palette.background.paper,.6),"&:hover":{backgroundColor:(0,i.X4)(R.palette.background.paper,.9)}},children:t.favorite?(0,r.jsx)(y.A,{fontSize:"small"}):(0,r.jsx)(j.A,{fontSize:"small"})})}):null,Y=(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(d.A,{sx:{flexGrow:1,p:2.25},children:[(0,r.jsxs)(c.default,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:1,mb:1.2},children:[(0,r.jsx)(u.A,{variant:"h6",sx:{pr:1},children:t.displayName||t.name}),(0,r.jsx)(p.A,{label:(0,A.T_)(t.provider,t.adapter).label,size:"small",sx:{flexShrink:0,color:"primary.light",bgcolor:(0,i.X4)(R.palette.primary.main,.09),border:"1px solid ".concat((0,i.X4)(R.palette.primary.main,.16))}})]}),(0,r.jsx)(u.A,{variant:"body2",color:"text.secondary",sx:{mb:2,minHeight:42},style:{display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},children:t.description}),(0,r.jsxs)(c.default,{sx:{mb:1,p:1.25,border:1,borderColor:"divider",borderRadius:2.5,bgcolor:(0,i.X4)(R.palette.background.default,.44)},children:[t.displayName&&(0,r.jsxs)(u.A,{variant:"body2",color:"text.secondary",noWrap:!0,children:[(0,r.jsx)(c.default,{component:"span",sx:{color:"text.primary",fontWeight:650},children:"Model"})," \xb7 ",t.name]}),"number"==typeof t.contextWindow&&(0,r.jsxs)(u.A,{variant:"body2",color:"text.secondary",children:[(0,r.jsx)(c.default,{component:"span",sx:{color:"text.primary",fontWeight:650},children:"Context"})," \xb7 ",t.contextWindow.toLocaleString()," tokens"]})]}),t.baseUrl&&(0,r.jsx)(a.A,{title:t.baseUrl,arrow:!0,placement:"top",children:(0,r.jsxs)(u.A,{variant:"body2",color:"text.secondary",noWrap:!0,children:["Base URL: ",t.baseUrl]})}),k&&(0,r.jsx)(p.A,{icon:(0,r.jsx)(w.A,{}),label:k,size:"small",variant:"outlined",sx:{mt:1,maxWidth:"100%"}})]})});return M?(0,r.jsxs)(h.A,{elevation:0,role:"radio","aria-checked":N,sx:{height:"100%",display:"flex",flexDirection:"column",position:"relative",border:e=>"1px solid ".concat(N?e.palette.primary.main:e.palette.divider),boxShadow:N?"0 0 0 3px ".concat((0,i.X4)(R.palette.primary.main,.13)):void 0,transition:"transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease","&:hover":{borderColor:(0,i.X4)(R.palette.primary.main,.42),transform:"translateY(-3px)"}},children:[X,(0,r.jsx)(m.A,{onClick:()=>null==F?void 0:F(t.id),sx:{height:"100%",display:"flex",flexDirection:"column",alignItems:"stretch"},children:Y})]}):(0,r.jsxs)(h.A,{elevation:0,sx:{height:"100%",display:"flex",flexDirection:"column",position:"relative",transition:"transform 200ms ease, border-color 200ms ease, box-shadow 200ms ease","&:hover":{borderColor:(0,i.X4)(R.palette.primary.main,.38),boxShadow:"0 22px 60px ".concat((0,i.X4)(R.palette.primary.main,.12)),transform:"translateY(-4px)"}},children:[X,Y,(0,r.jsxs)(f.A,{disableSpacing:!0,sx:{px:1.5,pb:1.4,borderTop:1,borderColor:"divider"},children:[(0,r.jsx)(a.A,{title:"Test model (direct SDK call, no flow)",arrow:!0,children:(0,r.jsx)(s.A,{"aria-label":"test",onClick:()=>{z(!0),_()},children:(0,r.jsx)(v.A,{})})}),(0,r.jsx)(s.A,{"aria-label":"edit",onClick:n,children:(0,r.jsx)(g.A,{})}),(0,r.jsx)(s.A,{"aria-label":"delete",onClick:S,children:(0,r.jsx)(x.A,{})}),I&&(0,r.jsx)(a.A,{title:"Move to folder…",arrow:!0,children:(0,r.jsx)(s.A,{"aria-label":"move to folder",onClick:e=>$(e.currentTarget),sx:{ml:"auto"},children:(0,r.jsx)(b.A,{})})})]}),I&&(0,r.jsx)(D.A,{anchorEl:K,open:!!K,currentFolder:k,folders:T,onClose:()=>$(null),onAssign:I}),(0,r.jsx)(L,{open:E,modelLabel:t.displayName||t.name,loading:W,result:O,error:U,onClose:()=>z(!1),onRetry:_})]})}},83478:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M18.3 5.71a.996.996 0 0 0-1.41 0L12 10.59 7.11 5.7a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41L10.59 12 5.7 16.89c-.39.39-.39 1.02 0 1.41s1.02.39 1.41 0L12 13.41l4.89 4.89c.39.39 1.02.39 1.41 0s.39-1.02 0-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4"}),"CloseRounded")},89218:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6z"}),"Code")},89623:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M19.8 18.4 14 10.67V6.5l1.35-1.69c.26-.33.03-.81-.39-.81H9.04c-.42 0-.65.48-.39.81L10 6.5v4.17L4.2 18.4c-.49.66-.02 1.6.8 1.6h14c.82 0 1.29-.94.8-1.6"}),"Science")},90363:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M7.5 5.6 10 7 8.6 4.5 10 2 7.5 3.4 5 2l1.4 2.5L5 7zm12 9.8L17 14l1.4 2.5L17 19l2.5-1.4L22 19l-1.4-2.5L22 14zM22 2l-2.5 1.4L17 2l1.4 2.5L17 7l2.5-1.4L22 7l-1.4-2.5zm-7.63 5.29a.996.996 0 0 0-1.41 0L1.29 18.96c-.39.39-.39 1.02 0 1.41l2.34 2.34c.39.39 1.02.39 1.41 0L16.7 11.05c.39-.39.39-1.02 0-1.41zm-1.03 5.49-2.12-2.12 2.44-2.44 2.12 2.12z"}),"AutoFixHigh")},95480:(e,t,n)=>{"use strict";n.d(t,{A:()=>S});var r=n(95155),o=n(12115),l=n(94049),a=n(25635),s=n(14913),i=n(57883),d=n(2300),c=n(89218),u=n(42063),p=n(17897),h=n(9164),m=n(73288),f=n(90880),g=n(11433);n(32098);let x=(0,m.h)("frontend/components/shared/PromptBuilder"),v=e=>{let{server:t,name:n}=e,l="handoff"===t,[a,s]=(0,o.useState)(null),[i,d]=(0,o.useState)(!0);return((0,o.useEffect)(()=>{let e=!1;return(async()=>{try{var r;d(!0);let o=null==(r=(await p.S.listServerTools(t)).tools)?void 0:r.find(e=>e.name===n);e||s(o||null)}catch(e){x.error("Failed to fetch tool info for ".concat(t,":").concat(n),e)}finally{e||d(!1)}})(),()=>{e=!0}},[t,n]),i)?(0,r.jsx)("span",{className:"tool-reference-preview loading ".concat(l?"handoff":""),children:"tool:".concat(t,"__").concat(n)}):a?(0,r.jsxs)("span",{className:"tool-reference-preview ".concat(l?"handoff":""),children:["[The user is referencing a ",l?"handoff":"tool"," `tool:",t,"__",n,"` (",a.description||"No description",")]"]}):(0,r.jsx)("span",{className:"tool-reference-preview not-found ".concat(l?"handoff":""),children:"tool:".concat(t,"__").concat(n," (Tool not found)")})},b=e=>{let{server:t,name:n}=e,[l,a]=(0,o.useState)(null),[s,i]=(0,o.useState)(!0);return((0,o.useEffect)(()=>{let e=!1;return(async()=>{try{i(!0);let r=await p.S.listServerResources(t),o=[...r.resources||[],...r.resourceTemplates||[]].find(e=>e.uri===n||e.uriTemplate===n);e||a((null==o?void 0:o.description)||(null==o?void 0:o.name)||null)}catch(e){x.error("Failed to fetch resource info for ".concat(t,":").concat(n),e)}finally{e||i(!1)}})(),()=>{e=!0}},[t,n]),s)?(0,r.jsx)("span",{className:"tool-reference-preview loading resource",children:"resource:".concat(t,"__").concat(n)}):(0,r.jsxs)("span",{className:"tool-reference-preview resource",children:["[The contents of resource `",n,"` from `",t,"`",l?" (".concat(l,")"):""," will be inserted here]"]})},w=e=>{let{name:t}=e;return(0,r.jsxs)("span",{className:"tool-reference-preview runres",children:["[The contents of the Temporary Data `",t,"` will be inserted here at run time]"]})},y=e=>{let{name:t}=e;return(0,r.jsxs)("span",{className:"tool-reference-preview global",children:["[Global variable ",(0,r.jsx)("code",{children:"${global:".concat(t,"}")})," will be inserted at run time]"]})},j=e=>{let{binding:t}=e;return"global"===t.kind?(0,r.jsx)(y,{name:t.name}):"runres"===t.kind?(0,r.jsx)(w,{name:t.name}):"resource"===t.kind?(0,r.jsx)(b,{server:t.server,name:t.name}):(0,r.jsx)(v,{server:t.server,name:t.name})},A=e=>{let{value:t}=e,n=[],o=0;for(let e of(0,f.sE)(t))e.index>o&&n.push({type:"text",value:t.slice(o,e.index)}),n.push({type:"binding",binding:e,key:e.index}),o=e.index+e.fullMatch.length;o<t.length&&n.push({type:"text",value:t.slice(o)});let l=[],a=[],s=()=>{l.push((0,r.jsx)("p",{children:a},"p-".concat(l.length))),a=[]};for(let e of n)if("text"===e.type){let t=e.value.split("\n");for(let e=0;e<t.length;e++)a.push(t[e]),e<t.length-1&&s()}else a.push((0,r.jsx)(j,{binding:e.binding},"binding-".concat(e.key)));return(a.length>0||0===l.length)&&s(),(0,r.jsx)("div",{className:"preview-content",children:l})},C=(0,o.forwardRef)((e,t)=>{let{value:n,onChange:p,label:m="Prompt Builder",height:x=300,onModeChange:v,customPreviewRenderer:b,suggestions:w=[]}=e,{globalEnvVars:y}=(0,h.useStorage)(),j=(0,o.useMemo)(()=>Object.entries(y).filter(e=>{var t;let[,n]=e;return!(null==(t=n.metadata)?void 0:t.isSecret)}).map(e=>{let[t]=e;return t}).sort((e,t)=>e.localeCompare(t)),[y]),C=(0,o.useMemo)(()=>[...w,...j.map(e=>(0,f.Ub)({kind:"global",server:"",name:e},e))],[j,w]),S=(0,o.useRef)(null),[k,T]=(0,o.useState)("raw");return(0,o.useImperativeHandle)(t,()=>({insertText:e=>{var t;return null==(t=S.current)?void 0:t.insertText(e)},getMode:()=>k}),[k]),(0,r.jsxs)(l.default,{sx:{width:"100%",height:"100%",display:"flex",flexDirection:"column"},children:[m&&(0,r.jsx)(a.A,{variant:"subtitle1",gutterBottom:!0,sx:{fontWeight:"medium",mb:1},children:m}),(0,r.jsx)(l.default,{sx:{mb:1},children:(0,r.jsxs)(s.A,{value:k,exclusive:!0,onChange:(e,t)=>{t&&(T(t),null==v||v(t))},size:"small",children:[(0,r.jsxs)(i.A,{value:"raw",children:[(0,r.jsx)(c.A,{fontSize:"small",sx:{mr:.5}}),"Raw"]}),(0,r.jsxs)(i.A,{value:"preview",children:[(0,r.jsx)(u.A,{fontSize:"small",sx:{mr:.5}}),"Preview"]})]})}),(0,r.jsx)(d.A,{elevation:0,sx:{border:"1px solid rgba(0, 0, 0, 0.12)",borderRadius:1,overflow:"visible",flexGrow:1,display:"flex",flexDirection:"column"},children:"raw"===k?(0,r.jsx)(l.default,{className:"slate-editor-container",sx:{height:"number"==typeof x?x:"100%",overflow:"visible",p:2},children:(0,r.jsx)(g.Ay,{ref:S,value:n,onChange:p,suggestions:C,placeholder:"Write your prompt here...",bare:!0,minRows:4,containerSx:{height:"100%"},ariaLabel:m||"Prompt editor"})}):b?(0,r.jsx)(l.default,{className:"custom-preview-container",sx:{height:"number"==typeof x?x:"100%",overflow:"auto"},children:b()}):(0,r.jsx)(l.default,{className:"preview-container",sx:{height:"number"==typeof x?x:"100%",overflow:"auto",p:2},children:(0,r.jsx)(A,{value:n})})})]})});C.displayName="PromptBuilder";let S=C},96429:(e,t,n)=>{"use strict";n.d(t,{default:()=>l});var r=n(15485),o=n(95155);let l=(0,r.A)((0,o.jsx)("path",{d:"M14 9h-4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1m-1 4h-2v-2h2zm8-3c0-.55-.45-1-1-1h-1V7c0-1.1-.9-2-2-2h-2V4c0-.55-.45-1-1-1s-1 .45-1 1v1h-2V4c0-.55-.45-1-1-1s-1 .45-1 1v1H7c-1.1 0-2 .9-2 2v2H4c-.55 0-1 .45-1 1s.45 1 1 1h1v2H4c-.55 0-1 .45-1 1s.45 1 1 1h1v2c0 1.1.9 2 2 2h2v1c0 .55.45 1 1 1s1-.45 1-1v-1h2v1c0 .55.45 1 1 1s1-.45 1-1v-1h2c1.1 0 2-.9 2-2v-2h1c.55 0 1-.45 1-1s-.45-1-1-1h-1v-2h1c.55 0 1-.45 1-1m-5 7H8c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1h8c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1"}),"MemoryRounded")}},e=>{e.O(0,[1137,3862,7926,4754,7758,3392,2678,981,1983,1871,5954,9562,3816,3272,155,4123,8598,9611,3303,5418,1675,4386,6547,4122,8620,8326,2141,4483,4755,1161,4814,1521,9524,8124,3731,5967,2499,8441,1255,7358],()=>e(e.s=10076)),_N_E=e.O()}]);
|