@powerhousedao/workflow 6.2.3-dev.95 → 6.2.3-dev.97
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/dist/browser/{BlockSelector-DFzzAWXh.js → BlockSelector-CEdYUqjx.js} +38 -37
- package/dist/browser/BlockSelector-CEdYUqjx.js.map +1 -0
- package/dist/browser/{connection-form-O02M1hkC.js → connection-form-Biksq2jW.js} +4 -4
- package/dist/browser/{connection-form-O02M1hkC.js.map → connection-form-Biksq2jW.js.map} +1 -1
- package/dist/browser/{connection-PaKXHYz9.js → connection-ilYFCRUK.js} +2 -2
- package/dist/browser/{connection-PaKXHYz9.js.map → connection-ilYFCRUK.js.map} +1 -1
- package/dist/browser/{data-tree-DKS0EQys.js → data-tree-Cq-s6bJp.js} +2 -2
- package/dist/browser/{data-tree-DKS0EQys.js.map → data-tree-Cq-s6bJp.js.map} +1 -1
- package/dist/browser/document-models/connection/index.js +1 -1
- package/dist/browser/document-models/workflow/index.js +1 -1
- package/dist/browser/{editor-gCkAwv09.js → editor-CIqKi7XK.js} +6 -6
- package/dist/browser/{editor-gCkAwv09.js.map → editor-CIqKi7XK.js.map} +1 -1
- package/dist/browser/{editor-BPF_SXdt.js → editor-DYjoPfta.js} +8 -8
- package/dist/browser/{editor-BPF_SXdt.js.map → editor-DYjoPfta.js.map} +1 -1
- package/dist/browser/{editor-xBTKbbNO.js → editor-GeRXGdie.js} +6 -6
- package/dist/browser/{editor-xBTKbbNO.js.map → editor-GeRXGdie.js.map} +1 -1
- package/dist/browser/editors/connection-editor/module.js +1 -1
- package/dist/browser/editors/runtime/index.js +1 -1
- package/dist/browser/editors/workflow-editor/module.js +1 -1
- package/dist/browser/editors/workflow-studio/module.js +1 -1
- package/dist/browser/index.js +127 -87
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/{runtime-queries-C5bqAgQy.js → runtime-queries-FmEzElOY.js} +39 -20
- package/dist/browser/runtime-queries-FmEzElOY.js.map +1 -0
- package/dist/browser/{trigger-text-BfIu-QcC.js → trigger-text-DH6HIeoa.js} +4 -4
- package/dist/browser/{trigger-text-BfIu-QcC.js.map → trigger-text-DH6HIeoa.js.map} +1 -1
- package/dist/browser/{workflow-BFdnSGRD.js → workflow-2gR2JXUS.js} +2 -2
- package/dist/browser/{workflow-BFdnSGRD.js.map → workflow-2gR2JXUS.js.map} +1 -1
- package/dist/node/pieces/ai/descriptor.json +1 -1
- package/dist/node/pieces/ai/index.mjs +16 -16
- package/dist/node/pieces/ai/package.json +1 -1
- package/dist/node/pieces/reactor/descriptor.json +1 -1
- package/dist/node/pieces/reactor/index.mjs +7 -7
- package/dist/node/pieces/reactor/package.json +1 -1
- package/dist/powerhouse.manifest.json +2 -2
- package/dist/types/ai/runtime.d.ts +13 -0
- package/dist/types/ai/runtime.d.ts.map +1 -0
- package/dist/types/ai/tools.d.ts +6 -2
- package/dist/types/ai/tools.d.ts.map +1 -1
- package/dist/types/ai/workflow-tools.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-api.d.ts +13 -12
- package/dist/types/editors/workflow-editor/runtime-api.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-client.d.ts +8 -2
- package/dist/types/editors/workflow-editor/runtime-client.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-context.d.ts +1 -1
- package/dist/types/editors/workflow-editor/runtime-context.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/use-workflow-runtime.d.ts +13 -0
- package/dist/types/editors/workflow-editor/use-workflow-runtime.d.ts.map +1 -0
- package/dist/types/editors/workflow-editor/use-workflow-runtime.test.d.ts +2 -0
- package/dist/types/editors/workflow-editor/use-workflow-runtime.test.d.ts.map +1 -0
- package/dist/types/pieces/reactor/lib/documents.d.ts +1 -0
- package/dist/types/pieces/reactor/lib/documents.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/input-props.d.ts.map +1 -1
- package/dist/types/scripts/ui-stack.d.ts.map +1 -1
- package/dist/types/test/switchboards.d.ts +20 -0
- package/dist/types/test/switchboards.d.ts.map +1 -0
- package/package.json +11 -11
- package/dist/browser/BlockSelector-DFzzAWXh.js.map +0 -1
- package/dist/browser/runtime-queries-C5bqAgQy.js.map +0 -1
- package/dist/types/ai/runtime-url.d.ts +0 -2
- package/dist/types/ai/runtime-url.d.ts.map +0 -1
- package/dist/types/ai/runtime-url.test.d.ts +0 -2
- package/dist/types/ai/runtime-url.test.d.ts.map +0 -1
- package/dist/types/editors/workflow-editor/use-runtime-url.d.ts +0 -2
- package/dist/types/editors/workflow-editor/use-runtime-url.d.ts.map +0 -1
- package/dist/types/test/drive-window.d.ts +0 -6
- package/dist/types/test/drive-window.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockSelector-CEdYUqjx.js","names":["Tabs","CALLABLE_FLOW_TRIGGER","CALLABLE_FLOW_TRIGGER"],"sources":["../../editors/shared/DocumentErrorBoundary.tsx","../../editors/shared/icons.tsx","../../editors/shared/controls.tsx","../../editors/shared/url-param.ts","../../editors/workflow-editor/runtime-persist.ts","../../editors/workflow-editor/ui/piece-source.ts","../../editors/workflow-editor/use-workflow-runtime.ts","../../editors/workflow-editor/runtime-context.tsx","../../editors/workflow-editor/ui/validation.ts","../../editors/workflow-editor/ui/design-time.tsx","../../editors/workflow-studio/components/run-format.ts","../../editors/workflow-editor/ui/block-meta.ts","../../editors/workflow-editor/ui/version-badge.tsx","../../editors/workflow-editor/ui/picker-placement.ts","../../editors/workflow-editor/ui/PickerPopover.tsx","../../editors/workflow-editor/ui/picker-recent.ts","../../editors/workflow-editor/ui/VirtualList.tsx","../../editors/workflow-editor/ui/BlockSelector.tsx"],"sourcesContent":["// Keeps a broken document from taking down the studio: a drive node can point\n// at a document the reactor no longer serves (deleted, or with unreadable\n// history), and the document hooks throw for it. Everything that renders such a\n// document goes inside a boundary so the failure stays in that one pane.\nimport { Component, Fragment, type ErrorInfo, type ReactNode } from \"react\";\n\n/** Best-effort message for anything thrown, without stringifying an object. */\nexport function errorMessage(error: unknown): string {\n if (error instanceof Error) return error.message;\n if (typeof error === \"string\") return error;\n return \"Unknown error\";\n}\n\n/** Inline \"could not load\" panel, also used for hook-level (non-thrown) failures. */\nexport function DocumentLoadError(props: {\n title?: string;\n label?: string | null;\n documentId?: string | null;\n error: unknown;\n onRetry?: () => void;\n onDismiss?: () => void;\n}) {\n return (\n <div className=\"m-3 rounded border border-solid border-wf-fail/40 bg-wf-fail/10 p-3\">\n <p className=\"text-sm font-medium text-wf-fail\">\n {props.title ?? \"This document could not be loaded\"}\n </p>\n {props.label ? (\n <p className=\"mt-0.5 text-xs text-wf-fail\">{props.label}</p>\n ) : null}\n {props.documentId ? (\n <p className=\"mt-0.5 font-mono text-[11px] text-wf-fail\">\n {props.documentId}\n </p>\n ) : null}\n <p className=\"mt-1 text-xs text-muted-foreground\">\n {errorMessage(props.error)}\n </p>\n <div className=\"mt-2 flex gap-2\">\n {props.onRetry ? (\n <button\n type=\"button\"\n className=\"rounded border border-solid border-wf-fail/40 px-2 py-0.5 text-xs font-medium text-wf-fail\"\n onClick={props.onRetry}\n >\n Retry\n </button>\n ) : null}\n {props.onDismiss ? (\n <button\n type=\"button\"\n className=\"rounded border border-solid border-foreground/15 px-2 py-0.5 text-xs text-muted-foreground\"\n onClick={props.onDismiss}\n >\n Dismiss\n </button>\n ) : null}\n </div>\n </div>\n );\n}\n\ntype Props = {\n /** Human-readable name of the node being rendered, when known. */\n label?: string | null;\n /** Document id, shown so a broken node can be identified in the drive. */\n documentId?: string | null;\n /** Called when the user dismisses the error (e.g. to close the pane). */\n onDismiss?: () => void;\n children: ReactNode;\n};\n\ntype State = { error: unknown; attempt: number };\n\nexport class DocumentErrorBoundary extends Component<Props, State> {\n override state: State = { error: undefined, attempt: 0 };\n\n static getDerivedStateFromError(error: unknown): Partial<State> {\n return { error };\n }\n\n override componentDidCatch(error: unknown, info: ErrorInfo) {\n console.error(\n `Failed to render document ${this.props.documentId ?? \"(unknown id)\"}:`,\n error,\n info.componentStack,\n );\n }\n\n private retry = () => {\n this.setState((state) => ({\n error: undefined,\n attempt: state.attempt + 1,\n }));\n };\n\n private dismiss = () => {\n this.setState({ error: undefined });\n this.props.onDismiss?.();\n };\n\n override render() {\n if (this.state.error !== undefined) {\n return (\n <DocumentLoadError\n label={this.props.label}\n documentId={this.props.documentId}\n error={this.state.error}\n onRetry={this.retry}\n onDismiss={this.props.onDismiss ? this.dismiss : undefined}\n />\n );\n }\n // Remounting on retry drops the failed subtree's state and refetches.\n return <Fragment key={this.state.attempt}>{this.props.children}</Fragment>;\n }\n}\n","// Stroke icons on a 24px grid; they inherit colour from the text.\nconst ICON_PATHS = {\n pencil: \"M4 20h4L19 9l-4-4L4 16v4zM14 6l4 4\",\n trash: \"M5 7h14M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3\",\n plus: \"M12 5v14M5 12h14\",\n minus: \"M5 12h14\",\n list: \"M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01\",\n play: \"M7 5v14l12-7z\",\n stop: \"M7 7h10v10H7z\",\n chevron: \"M9 6l6 6-6 6\",\n chevronDown: \"M6 9l6 6 6-6\",\n retry: \"M4 12a8 8 0 1 0 2.3-5.7M4 4v4h4\",\n back: \"M15 6l-6 6 6 6\",\n close: \"M6 6l12 12M18 6L6 18\",\n check: \"M5 12l5 5 9-10\",\n search: \"M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM20 20l-4-4\",\n braces:\n \"M8 4c-2 0-3 1-3 3v2c0 1.5-1 3-2 3 1 0 2 1.5 2 3v2c0 2 1 3 3 3M16 4c2 0 3 1 3 3v2c0 1.5 1 3 2 3-1 0-2 1.5-2 3v2c0 2-1 3-3 3\",\n link: \"M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1\",\n arrowRight: \"M5 12h14M13 6l6 6-6 6\",\n alert:\n \"M12 8v5M12 16.5v.01M10.3 4l-7.6 13.2A2 2 0 0 0 4.4 20h15.2a2 2 0 0 0 1.7-2.8L13.7 4a2 2 0 0 0-3.4 0z\",\n copy: \"M9 9h10v10H9zM5 15V5h10\",\n sliders: \"M4 7h10M18 7h2M4 17h4M12 17h8M14 5v4M8 15v4\",\n eye: \"M2.5 12s3.5-6.5 9.5-6.5 9.5 6.5 9.5 6.5-3.5 6.5-9.5 6.5S2.5 12 2.5 12zM12 14.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5z\",\n eyeOff:\n \"M3 3l18 18M10.6 5.6A10 10 0 0 1 12 5.5c6 0 9.5 6.5 9.5 6.5a17 17 0 0 1-3 3.7M6.6 6.6C4 8.3 2.5 12 2.5 12s3.5 6.5 9.5 6.5a9.6 9.6 0 0 0 4.4-1M9.9 9.9a3 3 0 0 0 4.2 4.2\",\n undo: \"M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3\",\n redo: \"M15 14l5-5-5-5M20 9H10a6 6 0 0 0 0 12h3\",\n clock: \"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 7v5l3 2\",\n bolt: \"M13 3L5 13h6l-1 8 8-10h-6l1-8z\",\n branch:\n \"M6 4v10M6 14a3 3 0 1 0 0 6 3 3 0 0 0 0-6zM18 4a3 3 0 1 0 0 6 3 3 0 0 0 0-6zM18 10c0 4-6 3-11 6\",\n route: \"M12 21v-7M12 14L5 5M12 14l7-9M12 14V3\",\n loop: \"M17 2l3 3-3 3M4 11V9a4 4 0 0 1 4-4h12M7 22l-3-3 3-3M20 13v2a4 4 0 0 1-4 4H4\",\n lock: \"M6 11h12v9H6zM8.5 11V8a3.5 3.5 0 0 1 7 0v3M12 15v2\",\n more: \"M5 11a1 1 0 1 0 0 2 1 1 0 0 0 0-2zM12 11a1 1 0 1 0 0 2 1 1 0 0 0 0-2zM19 11a1 1 0 1 0 0 2 1 1 0 0 0 0-2z\",\n archive: \"M4 5h16v4H4zM6 9v10h12V9M10 13h4\",\n subflow: \"M4 4h8v6H4zM12 14h8v6h-8zM8 10v7h4\",\n reply: \"M10 7l-5 5 5 5M5 12h9a5 5 0 0 1 5 5v2\",\n};\n\nexport type IconName = keyof typeof ICON_PATHS;\n\n// A piece names icons by string; only the ones this set draws are shown.\nexport function isIconName(name: unknown): name is IconName {\n return typeof name === \"string\" && name in ICON_PATHS;\n}\n\nexport function Icon(props: {\n name: IconName;\n className?: string;\n // Pixel size; otherwise 16px, overridable through className.\n size?: number;\n}) {\n return (\n <svg\n aria-hidden\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={1.75}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n width={props.size}\n height={props.size}\n className={`shrink-0 ${props.size ? \"\" : \"h-4 w-4\"} ${props.className ?? \"\"}`}\n >\n <path d={ICON_PATHS[props.name]} />\n </svg>\n );\n}\n","// Form and action primitives for the workflow editors, drawn from Connect's\n// theme tokens so they work in both themes.\nimport {\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type KeyboardEvent,\n type ReactNode,\n type Ref,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Icon, type IconName } from \"./icons.js\";\n\nconst FOCUS_RING =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40\";\n\n// ─── buttons ────────────────────────────────────────────────────────────────\n\nconst BUTTON_SIZE = {\n sm: \"h-7 gap-1 rounded-md px-2 text-xs\",\n md: \"h-8 gap-1.5 rounded-md px-3 text-[13px]\",\n};\n\nconst BUTTON_VARIANT = {\n primary: \"bg-primary text-primary-foreground hover:opacity-90\",\n secondary:\n \"border border-solid border-foreground/15 bg-card text-foreground hover:bg-accent\",\n ghost: \"text-muted-foreground hover:bg-accent hover:text-foreground\",\n danger: \"text-wf-fail hover:bg-wf-fail/10\",\n // Dark text on the lighter dark-theme red, as primary does.\n destructive: \"bg-wf-fail text-background hover:opacity-90\",\n};\n\nexport function Button(\n props: ButtonHTMLAttributes<HTMLButtonElement> & {\n ref?: Ref<HTMLButtonElement>;\n variant?: keyof typeof BUTTON_VARIANT;\n size?: keyof typeof BUTTON_SIZE;\n },\n) {\n const { variant = \"secondary\", size = \"md\", className = \"\", ...rest } = props;\n return (\n <button\n type=\"button\"\n className={`inline-flex shrink-0 items-center font-medium transition-colors disabled:pointer-events-none disabled:opacity-50 ${FOCUS_RING} ${BUTTON_SIZE[size]} ${BUTTON_VARIANT[variant]} ${className}`}\n {...rest}\n />\n );\n}\n\nexport function IconButton(\n props: ButtonHTMLAttributes<HTMLButtonElement> & {\n icon: IconName;\n label: string;\n active?: boolean;\n },\n) {\n const { icon, label, active, className = \"\", ...rest } = props;\n return (\n <button\n type=\"button\"\n title={label}\n aria-label={label}\n className={`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors disabled:pointer-events-none disabled:opacity-50 ${FOCUS_RING} ${\n active\n ? \"bg-wf-run/10 text-wf-run\"\n : \"text-muted-foreground hover:bg-accent hover:text-foreground\"\n } ${className}`}\n {...rest}\n >\n <Icon name={icon} className=\"h-3.5 w-3.5\" />\n </button>\n );\n}\n\n// ─── fields ─────────────────────────────────────────────────────────────────\n\nexport const inputClass =\n \"w-full rounded-md border border-solid border-foreground/15 bg-card px-2.5 text-[13px] text-foreground placeholder:text-muted-foreground/70 transition-colors hover:border-foreground/25 focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/25 disabled:cursor-not-allowed disabled:opacity-60\";\n\nexport const textInputClass = `${inputClass} h-9`;\nexport const textAreaClass = `${inputClass} min-h-20 py-2 leading-relaxed`;\nexport const invalidClass = \"border-wf-warn/70 hover:border-wf-warn\";\n\n/** Label row above a control: name, optional marker, and a trailing action. */\nexport function FieldLabel(props: {\n htmlFor?: string;\n label: ReactNode;\n optional?: boolean;\n needsValue?: boolean;\n action?: ReactNode;\n}) {\n // A <label> only when pointed at a control; callers that wrap the control\n // in their own <label> get a span, so labels never nest.\n const LabelTag = props.htmlFor ? \"label\" : \"span\";\n return (\n <div className=\"mb-1.5 flex min-h-6 items-center justify-between gap-2\">\n <LabelTag\n htmlFor={props.htmlFor}\n className=\"flex min-w-0 items-baseline gap-1.5 text-[13px] font-medium text-foreground\"\n >\n <span className=\"truncate\">{props.label}</span>\n {props.optional ? (\n <span className=\"shrink-0 text-xs font-normal text-muted-foreground\">\n Optional\n </span>\n ) : null}\n {props.needsValue ? (\n <span className=\"shrink-0 text-xs font-normal text-wf-warn\">\n Needs a value\n </span>\n ) : null}\n </LabelTag>\n {props.action ? (\n <span className=\"flex shrink-0 items-center gap-0.5\">\n {props.action}\n </span>\n ) : null}\n </div>\n );\n}\n\nconst LONG_HINT = 140;\n\n/** Help text under a control; long piece descriptions fold to two lines. */\nexport function Hint(props: { children?: ReactNode; text?: string }) {\n const [open, setOpen] = useState(false);\n const text = props.text;\n if (text !== undefined) {\n if (!text.trim()) return null;\n const long = text.length > LONG_HINT;\n return (\n <p className=\"mt-1.5 text-xs leading-relaxed text-muted-foreground\">\n <span className={long && !open ? \"line-clamp-2\" : undefined}>\n {text}\n </span>\n {long ? (\n <button\n type=\"button\"\n className=\"mt-0.5 block font-medium text-foreground/70 hover:text-foreground\"\n onClick={() => setOpen((value) => !value)}\n >\n {open ? \"Show less\" : \"Show more\"}\n </button>\n ) : null}\n </p>\n );\n }\n return (\n <p className=\"mt-1.5 text-xs leading-relaxed text-muted-foreground\">\n {props.children}\n </p>\n );\n}\n\nexport function FieldError(props: { children?: ReactNode }) {\n if (!props.children) return null;\n return <p className=\"mt-1.5 text-xs text-wf-fail\">{props.children}</p>;\n}\n\nexport function Switch(props: {\n checked: boolean;\n onChange: (checked: boolean) => void;\n label: ReactNode;\n description?: string;\n disabled?: boolean;\n}) {\n const id = useId();\n return (\n <div className=\"flex items-start justify-between gap-4\">\n <label htmlFor={id} className=\"min-w-0\">\n <span className=\"block text-[13px] font-medium text-foreground\">\n {props.label}\n </span>\n {props.description ? <Hint text={props.description} /> : null}\n </label>\n <button\n id={id}\n type=\"button\"\n role=\"switch\"\n aria-checked={props.checked}\n disabled={props.disabled}\n className={`relative mt-0.5 inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors disabled:opacity-50 ${FOCUS_RING} ${\n props.checked ? \"bg-primary\" : \"bg-foreground/20\"\n }`}\n onClick={() => props.onChange(!props.checked)}\n >\n <span\n className={`inline-block h-4 w-4 rounded-full bg-card shadow-sm transition-transform ${\n props.checked ? \"translate-x-[18px]\" : \"translate-x-0.5\"\n }`}\n />\n </button>\n </div>\n );\n}\n\n// A bare switch for toolbars; the label is for assistive tech and the title.\nexport function Toggle(props: {\n checked: boolean;\n onChange: (checked: boolean) => void;\n label: string;\n disabled?: boolean;\n}) {\n return (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={props.checked}\n aria-label={props.label}\n disabled={props.disabled}\n className={`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${FOCUS_RING} ${\n props.checked ? \"bg-wf-ok\" : \"bg-foreground/20\"\n }`}\n onClick={(event) => {\n event.stopPropagation();\n props.onChange(!props.checked);\n }}\n >\n <span\n className={`inline-block h-4 w-4 rounded-full bg-card shadow-sm transition-transform ${\n props.checked ? \"translate-x-[18px]\" : \"translate-x-0.5\"\n }`}\n />\n </button>\n );\n}\n\n// Shows `content` on hover or focus; it stays open while the pointer is on it,\n// so it can hold a link. Disabled controls inside still trigger it.\nexport function Tooltip(props: {\n content: ReactNode;\n children: ReactNode;\n // Off renders the children alone.\n enabled?: boolean;\n align?: \"start\" | \"end\";\n // Left of the control, for rows inside a clipping container.\n side?: \"below\" | \"left\";\n}) {\n if (props.enabled === false) return <>{props.children}</>;\n const place =\n props.side === \"left\"\n ? \"right-full top-1/2 -translate-y-1/2 pr-1.5\"\n : `top-full pt-1.5 ${props.align === \"start\" ? \"left-0\" : \"right-0\"}`;\n return (\n <span className=\"group/tip relative inline-flex\">\n {props.children}\n <span\n className={`invisible absolute z-50 opacity-0 transition-opacity group-focus-within/tip:visible group-focus-within/tip:opacity-100 group-hover/tip:visible group-hover/tip:opacity-100 ${place}`}\n >\n <span\n role=\"tooltip\"\n className=\"block w-max max-w-64 rounded-md border border-solid border-foreground/10 bg-card px-2.5 py-1.5 text-xs text-foreground shadow-lg\"\n >\n {props.content}\n </span>\n </span>\n </span>\n );\n}\n\n// ─── tabs ───────────────────────────────────────────────────────────────────\n\nexport function Tabs<T extends string>(props: {\n value: T;\n onChange: (value: T) => void;\n tabs: { value: T; label: string; badge?: ReactNode }[];\n}) {\n return (\n <div role=\"tablist\" className=\"flex gap-4\">\n {props.tabs.map((tab) => {\n const selected = tab.value === props.value;\n return (\n <button\n key={tab.value}\n type=\"button\"\n role=\"tab\"\n aria-selected={selected}\n className={`-mb-px flex items-center gap-1.5 border-b-2 border-solid pb-2 text-[13px] font-medium transition-colors ${FOCUS_RING} ${\n selected\n ? \"border-foreground text-foreground\"\n : \"border-transparent text-muted-foreground hover:text-foreground\"\n }`}\n onClick={() => props.onChange(tab.value)}\n >\n {tab.label}\n {tab.badge}\n </button>\n );\n })}\n </div>\n );\n}\n\n// ─── segmented ──────────────────────────────────────────────────────────────\n\n/** Two or three short, mutually exclusive choices shown side by side. */\nexport function Segmented(props: {\n value: string;\n options: { value: string; label: string }[];\n onChange: (value: string) => void;\n invalid?: boolean;\n}) {\n return (\n <div\n role=\"radiogroup\"\n className={`flex h-9 w-full items-center gap-0.5 rounded-md bg-muted p-0.5 ${\n props.invalid ? \"ring-1 ring-wf-warn/60\" : \"\"\n }`}\n >\n {props.options.map((option) => {\n const selected = option.value === props.value;\n return (\n <button\n key={option.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n className={`h-8 min-w-0 flex-1 truncate rounded px-2 text-[13px] transition-colors ${FOCUS_RING} ${\n selected\n ? \"bg-card font-medium text-foreground shadow-sm\"\n : \"text-muted-foreground hover:text-foreground\"\n }`}\n onClick={() => props.onChange(option.value)}\n >\n {option.label}\n </button>\n );\n })}\n </div>\n );\n}\n\n// ─── select ─────────────────────────────────────────────────────────────────\n\nexport interface SelectOption {\n value: string;\n label: string;\n description?: string;\n icon?: ReactNode;\n disabled?: boolean;\n}\n\n// Past this many options the list gets a search box.\nconst SEARCH_THRESHOLD = 7;\n\ninterface SelectProps {\n options: SelectOption[];\n placeholder?: string;\n loading?: boolean;\n disabled?: boolean;\n invalid?: boolean;\n id?: string;\n // Names the control when no <label> points at it.\n ariaLabel?: string;\n // Reloads options from their source; shown in the list header.\n onRefresh?: () => void;\n emptyText?: string;\n // Always show the search box, not only once the list is long.\n searchable?: boolean;\n // Search happens at the source: every keystroke is reported, and the list\n // shown is the options given, unfiltered.\n onQueryChange?: (query: string) => void;\n // Extra actions at the foot of the list; each closes it when chosen.\n actions?: SelectAction[];\n // Shown for a value the options don't list yet, instead of the raw value.\n valueLabel?: ReactNode;\n}\n\nexport interface SelectAction {\n label: string;\n icon?: IconName;\n onSelect: () => void;\n}\n\ntype SingleSelectProps = SelectProps & {\n multiple?: false;\n value: string;\n onChange: (value: string) => void;\n clearable?: boolean;\n};\n\ntype MultiSelectProps = SelectProps & {\n multiple: true;\n value: string[];\n onChange: (value: string[]) => void;\n};\n\n// A listbox in a popover, portalled to the body so a scrolling side panel\n// never clips it; searchable once the list is long.\nexport function Select(props: SingleSelectProps | MultiSelectProps) {\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState(\"\");\n const [active, setActive] = useState(0);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const popoverRef = useRef<HTMLDivElement>(null);\n const searchRef = useRef<HTMLInputElement>(null);\n const listId = useId();\n const [position, setPosition] = useState<{\n left: number;\n width: number;\n top?: number;\n bottom?: number;\n maxHeight: number;\n // Inside a modal dialog, which blocks pointer events outside itself.\n container: HTMLElement;\n } | null>(null);\n\n const selected = props.multiple\n ? props.value\n : props.value\n ? [props.value]\n : [];\n const selectedSet = new Set(selected);\n const searchable =\n props.searchable ||\n Boolean(props.onQueryChange) ||\n props.options.length > SEARCH_THRESHOLD;\n const needle = query.trim().toLowerCase();\n const serverSide = Boolean(props.onQueryChange);\n const visible = useMemo(\n () =>\n needle && !serverSide\n ? props.options.filter((option) =>\n `${option.label} ${option.description ?? \"\"}`\n .toLowerCase()\n .includes(needle),\n )\n : props.options,\n [needle, props.options, serverSide],\n );\n\n const onQueryChange = props.onQueryChange;\n // Closing also ends a source search, so the next opening starts unfiltered.\n const dismiss = () => {\n setOpen(false);\n setQuery(\"\");\n onQueryChange?.(\"\");\n };\n\n const close = () => {\n dismiss();\n triggerRef.current?.focus();\n };\n\n const place = () => {\n const rect = triggerRef.current?.getBoundingClientRect();\n if (!rect) return;\n const below = window.innerHeight - rect.bottom - 8;\n const above = rect.top - 8;\n const flip = below < 240 && above > below;\n setPosition({\n left: rect.left,\n width: rect.width,\n top: flip ? undefined : rect.bottom + 4,\n bottom: flip ? window.innerHeight - rect.top + 4 : undefined,\n maxHeight: Math.min(320, flip ? above : below),\n container:\n triggerRef.current?.closest<HTMLElement>('[role=\"dialog\"]') ??\n document.body,\n });\n };\n\n const openList = () => {\n const index = props.options.findIndex((option) =>\n selectedSet.has(option.value),\n );\n setActive(Math.max(0, index));\n setOpen(true);\n };\n\n useLayoutEffect(() => {\n if (!open) return;\n place();\n // Placed once per opening; scroll and resize re-place it below.\n }, [open]);\n\n // The popover mounts once placed; a long list then takes focus in its search\n // box, a short one leaves focus on the trigger, which handles the keys.\n const placed = position !== null;\n useEffect(() => {\n if (open && placed && searchable) searchRef.current?.focus();\n }, [open, placed, searchable]);\n\n useEffect(() => {\n if (!open) return;\n const onPointer = (event: MouseEvent) => {\n const target = event.target as globalThis.Node;\n if (\n !popoverRef.current?.contains(target) &&\n !triggerRef.current?.contains(target)\n ) {\n setOpen(false);\n setQuery(\"\");\n onQueryChange?.(\"\");\n }\n };\n window.addEventListener(\"mousedown\", onPointer);\n window.addEventListener(\"resize\", place);\n window.addEventListener(\"scroll\", place, true);\n return () => {\n window.removeEventListener(\"mousedown\", onPointer);\n window.removeEventListener(\"resize\", place);\n window.removeEventListener(\"scroll\", place, true);\n };\n }, [open, searchable, onQueryChange]);\n\n useEffect(() => {\n popoverRef.current\n ?.querySelector(`[data-index=\"${active}\"]`)\n ?.scrollIntoView({ block: \"nearest\" });\n }, [active]);\n\n const choose = (option: SelectOption) => {\n if (option.disabled) return;\n if (props.multiple) {\n props.onChange(\n selectedSet.has(option.value)\n ? props.value.filter((value) => value !== option.value)\n : [...props.value, option.value],\n );\n return;\n }\n props.onChange(option.value);\n close();\n };\n\n const onListKey = (event: KeyboardEvent) => {\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n setActive((index) => Math.min(visible.length - 1, index + 1));\n } else if (event.key === \"ArrowUp\") {\n event.preventDefault();\n setActive((index) => Math.max(0, index - 1));\n } else if (event.key === \"Enter\") {\n event.preventDefault();\n const option = visible[active] as SelectOption | undefined;\n if (option) choose(option);\n } else if (event.key === \"Escape\") {\n event.preventDefault();\n close();\n } else if (event.key === \"Tab\") {\n // Let focus move on as usual.\n dismiss();\n }\n };\n\n const labels = props.options\n .filter((option) => selectedSet.has(option.value))\n .map((option) => option.label);\n // A saved value the current options don't list still shows as itself.\n const unknown = selected.filter(\n (value) => !props.options.some((option) => option.value === value),\n );\n const shown = [...labels, ...unknown];\n const selectedIcon = props.multiple\n ? undefined\n : props.options.find((option) => option.value === props.value)?.icon;\n\n return (\n <>\n <button\n ref={triggerRef}\n id={props.id}\n aria-label={props.ariaLabel}\n type=\"button\"\n role=\"combobox\"\n aria-expanded={open}\n aria-controls={open ? listId : undefined}\n aria-activedescendant={\n open && visible.length > 0 ? `${listId}-${active}` : undefined\n }\n aria-haspopup=\"listbox\"\n disabled={props.disabled}\n className={`${textInputClass} flex items-center gap-2 text-left ${\n props.invalid ? invalidClass : \"\"\n } ${open ? \"border-ring ring-2 ring-ring/25\" : \"\"}`}\n onClick={() => (open ? close() : openList())}\n onKeyDown={(event) => {\n if (open) {\n onListKey(event);\n return;\n }\n if (\n event.key === \"ArrowDown\" ||\n event.key === \"Enter\" ||\n event.key === \" \"\n ) {\n event.preventDefault();\n openList();\n }\n }}\n >\n {selectedIcon}\n <span\n className={`min-w-0 flex-1 truncate ${shown.length ? \"\" : \"text-muted-foreground/70\"}`}\n >\n {labels.length === 0 &&\n unknown.length > 0 &&\n props.valueLabel !== undefined\n ? props.valueLabel\n : shown.length > 0\n ? shown.join(\", \")\n : props.loading\n ? \"Loading…\"\n : (props.placeholder ?? \"Choose…\")}\n </span>\n {props.multiple && shown.length > 1 ? (\n <span className=\"shrink-0 rounded bg-muted px-1.5 text-[11px] tabular-nums text-muted-foreground\">\n {shown.length}\n </span>\n ) : null}\n <Icon\n name=\"chevronDown\"\n className={`h-3.5 w-3.5 text-muted-foreground transition-transform ${open ? \"rotate-180\" : \"\"}`}\n />\n </button>\n {open && position\n ? createPortal(\n <div\n ref={popoverRef}\n tabIndex={-1}\n className=\"workflow-select-popover fixed flex flex-col overflow-hidden rounded-lg border border-solid border-foreground/10 bg-popover text-popover-foreground shadow-lg outline-none\"\n style={{\n left: position.left,\n width: Math.max(position.width, 220),\n top: position.top,\n bottom: position.bottom,\n maxHeight: position.maxHeight,\n }}\n onKeyDown={onListKey}\n >\n {searchable || props.onRefresh ? (\n <div className=\"flex items-center gap-1 border-b border-solid border-foreground/10 px-2\">\n {searchable ? (\n <>\n <Icon\n name=\"search\"\n className=\"h-3.5 w-3.5 text-muted-foreground\"\n />\n <input\n ref={searchRef}\n className=\"h-9 min-w-0 flex-1 bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground/70 focus:outline-none\"\n placeholder=\"Search\"\n value={query}\n onChange={(event) => {\n setQuery(event.target.value);\n setActive(0);\n props.onQueryChange?.(event.target.value);\n }}\n />\n </>\n ) : (\n <span className=\"h-9 flex-1\" />\n )}\n {props.onRefresh ? (\n <IconButton\n icon=\"retry\"\n label=\"Reload options\"\n disabled={props.loading}\n onClick={props.onRefresh}\n />\n ) : null}\n </div>\n ) : null}\n <div\n id={listId}\n role=\"listbox\"\n aria-multiselectable={props.multiple || undefined}\n className=\"min-h-0 flex-1 overflow-y-auto p-1\"\n >\n {props.loading && props.options.length === 0 ? (\n <p className=\"px-2 py-2 text-[13px] text-muted-foreground\">\n Loading options…\n </p>\n ) : visible.length === 0 ? (\n <p className=\"px-2 py-2 text-[13px] text-muted-foreground\">\n {needle\n ? \"Nothing matches.\"\n : (props.emptyText ?? \"No options.\")}\n </p>\n ) : (\n visible.map((option, index) => {\n const isSelected = selectedSet.has(option.value);\n return (\n <div\n key={option.value}\n id={`${listId}-${index}`}\n role=\"option\"\n aria-selected={isSelected}\n aria-disabled={option.disabled || undefined}\n data-index={index}\n className={`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-[13px] ${\n index === active ? \"bg-accent\" : \"\"\n } ${option.disabled ? \"cursor-not-allowed opacity-50\" : \"\"}`}\n onMouseEnter={() => setActive(index)}\n onMouseDown={(event) => {\n event.preventDefault();\n choose(option);\n }}\n >\n {props.multiple ? (\n <span\n className={`flex h-4 w-4 shrink-0 items-center justify-center rounded border border-solid ${\n isSelected\n ? \"border-primary bg-primary text-primary-foreground\"\n : \"border-foreground/25\"\n }`}\n >\n {isSelected ? (\n <Icon name=\"check\" className=\"h-3 w-3\" />\n ) : null}\n </span>\n ) : null}\n {option.icon}\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate\">{option.label}</span>\n {option.description ? (\n <span className=\"block truncate text-xs text-muted-foreground\">\n {option.description}\n </span>\n ) : null}\n </span>\n {!props.multiple && isSelected ? (\n <Icon\n name=\"check\"\n className=\"h-3.5 w-3.5 text-foreground\"\n />\n ) : null}\n </div>\n );\n })\n )}\n </div>\n {props.actions?.length ? (\n <div className=\"border-t border-solid border-foreground/10 p-1\">\n {props.actions.map((action) => (\n <button\n key={action.label}\n type=\"button\"\n className=\"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-muted-foreground hover:bg-accent hover:text-foreground\"\n onMouseDown={(event) => {\n event.preventDefault();\n dismiss();\n action.onSelect();\n }}\n >\n {action.icon ? (\n <Icon name={action.icon} className=\"h-3.5 w-3.5\" />\n ) : null}\n {action.label}\n </button>\n ))}\n </div>\n ) : null}\n {!props.multiple && props.clearable && props.value ? (\n <div className=\"border-t border-solid border-foreground/10 p-1\">\n {\n <button\n type=\"button\"\n className=\"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-muted-foreground hover:bg-accent hover:text-foreground\"\n onMouseDown={(event) => {\n event.preventDefault();\n props.onChange(\"\");\n close();\n }}\n >\n <Icon name=\"close\" className=\"h-3.5 w-3.5\" />\n Clear selection\n </button>\n }\n </div>\n ) : null}\n </div>,\n position.container,\n )\n : null}\n </>\n );\n}\n","// Editor view state kept in the URL's query params through the host navigation,\n// so it survives a refresh and is dropped when the document is left.\nimport type { PHSearchUpdate } from \"@powerhousedao/reactor-browser\";\nimport {\n useSearchParams,\n useSetSearchParams,\n} from \"@powerhousedao/reactor-browser\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\n/** The studio's sidebar selection. */\nexport const ITEM_PARAM = \"item\";\n\nexport type SetParam<T extends string> = (\n value: T,\n options?: { replace?: boolean; also?: PHSearchUpdate },\n) => void;\n\n/** A query param read as one of `allowed`, else `fallback`; the fallback is\n * kept out of the URL. `also` updates other params in the same entry. */\nexport function useSearchParam<T extends string>(\n key: string,\n fallback: T,\n allowed?: readonly T[],\n): [T, SetParam<T>] {\n const params = useSearchParams();\n const setParams = useSetSearchParams();\n const raw = params[key] as string | undefined;\n const value =\n raw !== undefined && (!allowed || allowed.includes(raw as T))\n ? (raw as T)\n : fallback;\n\n const set = useCallback<SetParam<T>>(\n (next, options) => {\n if (next === value && !options?.also) return;\n setParams(\n { ...options?.also, [key]: next === fallback ? undefined : next },\n { replace: options?.replace },\n );\n },\n [key, fallback, value, setParams],\n );\n return [value, set];\n}\n\n/** A text param with a local draft, so typing never waits on a navigation;\n * the draft follows other URL changes, e.g. back and forward. */\nexport function useSearchParamDraft(\n key: string,\n): [string, (value: string) => void] {\n const [param, setParam] = useSearchParam<string>(key, \"\");\n const [draft, setDraft] = useState(param);\n // Values written from the draft, in order; their arrival in the URL is no\n // change, and drops those written before it that the URL skipped.\n const written = useRef<string[]>([]);\n\n useEffect(() => {\n const index = written.current.indexOf(param);\n written.current = index === -1 ? [] : written.current.slice(index + 1);\n if (index === -1) setDraft(param);\n }, [param]);\n\n const set = useCallback(\n (value: string) => {\n setDraft(value);\n if (value === param) return;\n written.current.push(value);\n setParam(value, { replace: true });\n },\n [param, setParam],\n );\n return [draft, set];\n}\n","// Browser cache for runtime data that is the same for every caller: the piece\n// catalog and piece block forms. Nothing caller-scoped is ever written.\nimport type { Query, QueryClient, QueryKey } from \"@tanstack/react-query\";\nimport { CORE_PIECE_NAME } from \"@powerhousedao/pieces-framework/workflow\";\nimport { queryKind } from \"./ui/query-keys.js\";\n\n// Bump when the cached shapes, or how forms are derived, change.\nexport const RUNTIME_CACHE_VERSION = 2;\nexport const RUNTIME_CACHE_MAX_AGE_MS = 7 * 24 * 60 * 60_000;\n\nexport interface PersistedQuery {\n id: string;\n url: string;\n queryKey: QueryKey;\n data: unknown;\n updatedAt: number;\n version: number;\n}\n\nexport interface RuntimeCacheStore {\n load: (url: string) => Promise<PersistedQuery[]>;\n save: (entry: PersistedQuery) => Promise<void>;\n remove: (id: string) => Promise<void>;\n}\n\nexport function shouldPersistQuery(queryKey: QueryKey): boolean {\n if (typeof queryKey[0] !== \"string\") return false;\n const kind = queryKind(queryKey);\n if (kind === \"catalog\") return queryKey.length === 2;\n if (kind === \"form\") {\n const block = queryKey[2];\n // Core forms change with each reactor build; never pin a copy.\n return Array.isArray(block) && block[0] !== CORE_PIECE_NAME;\n }\n return false;\n}\n\n// Hydrates `url`'s entries, then writes every persistable fetch back.\nexport function persistRuntimeQueries(\n queryClient: QueryClient,\n url: string,\n store: RuntimeCacheStore | null,\n now: () => number = Date.now,\n): { ready: Promise<void>; dispose: () => void } {\n if (!store) return { ready: Promise.resolve(), dispose: () => undefined };\n const ready = hydrate(queryClient, url, store, now());\n const unsubscribe = queryClient.getQueryCache().subscribe((event) => {\n if (event.type !== \"updated\" || event.action.type !== \"success\") return;\n // Manual writes are hydration or optimistic updates, not fetches.\n if (event.action.manual) return;\n const query = event.query as Query<unknown, Error, unknown, QueryKey>;\n const { queryKey, state } = query;\n if (!shouldPersistQuery(queryKey) || state.data === undefined) return;\n store\n .save({\n id: JSON.stringify(queryKey),\n url: queryKey[0] as string,\n queryKey,\n data: state.data,\n updatedAt: state.dataUpdatedAt,\n version: RUNTIME_CACHE_VERSION,\n })\n .catch(() => undefined);\n });\n return { ready, dispose: unsubscribe };\n}\n\nasync function hydrate(\n queryClient: QueryClient,\n url: string,\n store: RuntimeCacheStore,\n at: number,\n): Promise<void> {\n let entries: PersistedQuery[];\n try {\n entries = await store.load(url);\n } catch {\n return;\n }\n for (const entry of entries) {\n const expired =\n entry.version !== RUNTIME_CACHE_VERSION ||\n at - entry.updatedAt > RUNTIME_CACHE_MAX_AGE_MS ||\n !shouldPersistQuery(entry.queryKey);\n if (expired) {\n store.remove(entry.id).catch(() => undefined);\n continue;\n }\n const current = queryClient.getQueryState(entry.queryKey);\n // A fetch that landed first is newer than anything on disk.\n if (current && current.dataUpdatedAt >= entry.updatedAt) continue;\n queryClient.setQueryData(entry.queryKey, entry.data, {\n updatedAt: entry.updatedAt,\n });\n }\n}\n\nconst DB_NAME = \"ph-workflow-runtime-cache\";\nconst STORE = \"queries\";\n\nfunction request<T>(req: IDBRequest<T>): Promise<T> {\n return new Promise((resolve, reject) => {\n req.onsuccess = () => resolve(req.result);\n req.onerror = () =>\n reject(req.error ?? new Error(\"IndexedDB request failed\"));\n });\n}\n\n// Null when the browser has no IndexedDB; every call rejects when it throws.\nexport function openIdbCacheStore(): RuntimeCacheStore | null {\n const idb = (globalThis as { indexedDB?: IDBFactory }).indexedDB;\n if (!idb) return null;\n let db: Promise<IDBDatabase> | undefined;\n const open = () => {\n db ??= new Promise<IDBDatabase>((resolve, reject) => {\n const req = idb.open(DB_NAME, 1);\n req.onupgradeneeded = () => {\n const store = req.result.createObjectStore(STORE, { keyPath: \"id\" });\n store.createIndex(\"url\", \"url\");\n };\n req.onsuccess = () => resolve(req.result);\n req.onerror = () =>\n reject(req.error ?? new Error(\"IndexedDB unavailable\"));\n req.onblocked = () => reject(new Error(\"IndexedDB blocked\"));\n });\n db.catch(() => (db = undefined));\n return db;\n };\n const withStore = async <T>(\n mode: IDBTransactionMode,\n run: (store: IDBObjectStore) => IDBRequest<T>,\n ): Promise<T> => {\n const database = await open();\n return request(run(database.transaction(STORE, mode).objectStore(STORE)));\n };\n return {\n load: (url) =>\n withStore(\"readonly\", (store) =>\n store.index(\"url\").getAll(url),\n ) as Promise<PersistedQuery[]>,\n save: (entry) =>\n withStore(\"readwrite\", (store) => store.put(entry)).then(() => undefined),\n remove: (id) =>\n withStore(\"readwrite\", (store) => store.delete(id)).then(() => undefined),\n };\n}\n","// Catalog source for the block selector's piece browser. Provided by the\n// editor shell's RuntimeProvider through context, to keep ui/ decoupled.\nimport { checkTriggerStrategy } from \"@powerhousedao/pieces-framework/workflow\";\nimport { createContext, useContext } from \"react\";\n\nexport interface PieceSummaryUi {\n name: string;\n displayName: string;\n description: string;\n logoUrl: string;\n actionCount: number;\n triggerCount: number;\n // Activepieces category ids; empty for uncategorised pieces.\n categories: string[];\n // Absent from older runtimes, which list Activepieces pieces only.\n source?: PieceSourceKind;\n // Why none of the piece's blocks can run on this reactor.\n unsupported?: string | null;\n // Retired by its publisher: still listed, marked as such.\n deprecated?: boolean;\n // The installed version; pins the blocks picked from it.\n version?: string;\n // A local package shadowing a published piece: the version published.\n publishedVersion?: string;\n}\n\nexport interface BlockSearchHitUi {\n pieceName: string;\n pieceVersion: string;\n // The action or trigger name.\n name: string;\n pieceDisplayName: string;\n logoUrl: string;\n displayName: string;\n description: string;\n kind: \"action\" | \"trigger\";\n strategy: string | null;\n unsupported?: string | null;\n}\n\n// Where a piece is listed from: a reactor package, the Powerhouse registry,\n// or the Activepieces cloud catalog.\nexport type PieceSourceKind = \"local\" | \"registry\" | \"activepieces\";\n\nexport interface PieceSearchMatchUi {\n pieceName: string;\n pieceVersion: string;\n displayName: string;\n description: string;\n logoUrl: string;\n categories: string[];\n source: PieceSourceKind;\n deprecated?: boolean | null;\n unsupported?: string | null;\n // Every query token matched the piece's own name.\n namedPiece: boolean;\n // Matching blocks, best first.\n blocks: BlockSearchHitUi[];\n}\n\nexport interface PieceSearchResultUi {\n status: \"ready\" | \"indexing\" | \"error\";\n pieces: PieceSearchMatchUi[];\n error: string | null;\n}\n\nexport interface PieceSearchFilterUi {\n kind: \"action\" | \"trigger\";\n // Any of; all when absent.\n sources?: readonly PieceSourceKind[];\n // Category ids, any of; all when absent.\n categories?: readonly string[];\n}\n\n// One action of a piece, at the version its listing answered with.\nexport interface PieceActionUi {\n pieceName: string;\n pieceVersion: string;\n name: string;\n displayName: string;\n description: string;\n unsupported?: string | null;\n}\n\nexport interface PieceTriggerUi {\n pieceName: string;\n pieceVersion: string;\n name: string;\n displayName: string;\n description: string;\n // Read through checkTriggerStrategy.\n strategy: string;\n unsupported?: string | null;\n}\n\n// Why a listed block cannot be picked, or undefined when it can: the\n// runtime's own reason first, then a trigger strategy it cannot serve.\nexport function blockUnavailable(entry: {\n unsupported?: string | null;\n kind?: \"action\" | \"trigger\";\n strategy?: string | null;\n}): string | undefined {\n if (entry.unsupported) return entry.unsupported;\n if (entry.kind !== \"trigger\") return undefined;\n const strategy = checkTriggerStrategy(entry.strategy);\n return \"issue\" in strategy ? strategy.issue : undefined;\n}\n\nexport interface PieceCatalogSource {\n loadCatalog: () => Promise<PieceSummaryUi[]>;\n // Refetches past any cached answer; loadCatalog is used when absent.\n reloadCatalog?: () => Promise<PieceSummaryUi[]>;\n loadActions: (packageName: string) => Promise<PieceActionUi[]>;\n loadTriggers: (packageName: string) => Promise<PieceTriggerUi[]>;\n // Catalog-wide search grouped by piece; optional for offline sources.\n searchPieces?: (\n query: string,\n filter: PieceSearchFilterUi,\n ) => Promise<PieceSearchResultUi>;\n}\n\nconst PieceSourceContext = createContext<PieceCatalogSource | undefined>(\n undefined,\n);\n\nexport const PieceSourceProvider = PieceSourceContext.Provider;\n\nexport function usePieceSource(): PieceCatalogSource | undefined {\n return useContext(PieceSourceContext);\n}\n","// Which switchboard's workflow runtime an editor talks to: the one serving the\n// selected drive, else the only one that runs workflows. Resolved from the\n// host's switchboard directory; there is no default URL to fall back on.\nimport {\n resolveSwitchboard,\n useSelectedDriveSafe,\n useSwitchboards,\n type SwitchboardEntry,\n} from \"@powerhousedao/reactor-browser\";\nimport { useEffect, useState } from \"react\";\nimport { workflowRuntimeUrl } from \"./runtime-client.js\";\n\nexport type WorkflowRuntimeState =\n | { status: \"resolving\" }\n | { status: \"ready\"; url: string; switchboard: SwitchboardEntry }\n | { status: \"unavailable\"; error: Error };\n\nexport function useWorkflowRuntime(): WorkflowRuntimeState {\n const switchboards = useSwitchboards();\n const [drive] = useSelectedDriveSafe();\n const driveId = drive?.header.id;\n const [state, setState] = useState<WorkflowRuntimeState>({\n status: \"resolving\",\n });\n\n useEffect(() => {\n const controller = new AbortController();\n resolveSwitchboard(switchboards, {\n documentId: driveId,\n need: \"workflows\",\n signal: controller.signal,\n }).then(\n (switchboard) => {\n if (controller.signal.aborted) return;\n setState({\n status: \"ready\",\n url: workflowRuntimeUrl(switchboard),\n switchboard,\n });\n },\n (error: unknown) => {\n if (controller.signal.aborted) return;\n setState({\n status: \"unavailable\",\n error: error instanceof Error ? error : new Error(String(error)),\n });\n },\n );\n return () => controller.abort();\n }, [switchboards, driveId]);\n\n return state;\n}\n","// One runtime client and query cache per editor instance. Hooks pass the\n// client explicitly, leaving the host's QueryClientProvider alone.\nimport {\n useInfiniteQuery,\n useQuery,\n type QueryClient,\n} from \"@tanstack/react-query\";\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n} from \"react\";\nimport {\n createRuntimeClient,\n type OAuthAttempt,\n type RunsScope,\n type RuntimeClient,\n type SecretStat,\n type WaitingRunsScope,\n} from \"./runtime-client.js\";\nimport {\n openIdbCacheStore,\n persistRuntimeQueries,\n type RuntimeCacheStore,\n} from \"./runtime-persist.js\";\nimport {\n catalogQuery,\n createRuntimeQueryClient,\n pieceActionsQuery,\n pieceTriggersQuery,\n runPagesQuery,\n runQuery,\n runsQuery,\n secretStatQuery,\n waitingRunsQuery,\n} from \"./runtime-queries.js\";\nimport {\n PieceSourceProvider,\n type PieceCatalogSource,\n} from \"./ui/piece-source.js\";\nimport { runtimeKeys } from \"./ui/query-keys.js\";\nimport { useWorkflowRuntime } from \"./use-workflow-runtime.js\";\n\nexport interface RuntimeContextValue {\n client: RuntimeClient;\n queryClient: QueryClient;\n}\n\nconst RuntimeContext = createContext<RuntimeContextValue | null>(null);\n\n// A repeated query while the picker is open answers at once.\nconst SEARCH_STALE_MS = 5 * 60_000;\n\n// The block selector's catalog seam, answered from this editor's cache.\nfunction runtimePieceSource(\n client: RuntimeClient,\n queryClient: QueryClient,\n): PieceCatalogSource {\n return {\n loadCatalog: () => queryClient.fetchQuery(catalogQuery(client)),\n reloadCatalog: () =>\n queryClient.fetchQuery({ ...catalogQuery(client), staleTime: 0 }),\n loadActions: (packageName) =>\n queryClient.fetchQuery(pieceActionsQuery(client, packageName)),\n loadTriggers: (packageName) =>\n queryClient.fetchQuery(pieceTriggersQuery(client, packageName)),\n searchPieces: async (query, filter) => {\n const key = runtimeKeys.searchPieces(client.url, query, filter);\n const result = await queryClient.fetchQuery({\n queryKey: key,\n queryFn: () => client.searchPieces(query, filter),\n staleTime: SEARCH_STALE_MS,\n });\n // Only a finished index is worth keeping; the caller polls the rest.\n if (result.status !== \"ready\")\n queryClient.removeQueries({ queryKey: key });\n return result;\n },\n };\n}\n\nexport function RuntimeProvider(props: {\n url: string;\n children: ReactNode;\n // The browser cache; defaults to IndexedDB, null turns it off.\n store?: RuntimeCacheStore | null;\n}) {\n const { url } = props;\n const [queryClient] = useState(createRuntimeQueryClient);\n const [store] = useState(() =>\n props.store === undefined ? openIdbCacheStore() : props.store,\n );\n const client = useMemo(() => createRuntimeClient(url), [url]);\n\n useEffect(\n () => persistRuntimeQueries(queryClient, url, store).dispose,\n [queryClient, url, store],\n );\n\n const value = useMemo(() => ({ client, queryClient }), [client, queryClient]);\n const pieceSource = useMemo(\n () => runtimePieceSource(client, queryClient),\n [client, queryClient],\n );\n return (\n <RuntimeContext.Provider value={value}>\n <PieceSourceProvider value={pieceSource}>\n {props.children}\n </PieceSourceProvider>\n </RuntimeContext.Provider>\n );\n}\n\n// Resolves the selected drive's runtime and provides a client for it; says\n// why when no switchboard's runtime can be picked.\nexport function WorkflowRuntimeProvider(props: { children: ReactNode }) {\n const runtime = useWorkflowRuntime();\n if (runtime.status === \"resolving\") return null;\n if (runtime.status === \"unavailable\") {\n return (\n <p role=\"alert\" className=\"p-4 text-sm text-wf-fail\">\n The workflow runtime is unavailable: {runtime.error.message}\n </p>\n );\n }\n return <RuntimeProvider url={runtime.url}>{props.children}</RuntimeProvider>;\n}\n\nexport function useRuntime(): RuntimeContextValue {\n const context = useContext(RuntimeContext);\n if (!context) throw new Error(\"useRuntime needs a RuntimeProvider\");\n return context;\n}\n\nexport function usePieceCatalog() {\n const { client, queryClient } = useRuntime();\n return useQuery(catalogQuery(client), queryClient);\n}\n\n// Polled while `active`; inactive feeds hold no subscription.\nexport function useRunsQuery(\n scope: RunsScope,\n options: { active?: boolean; pollMs?: number } = {},\n) {\n const { client, queryClient } = useRuntime();\n return useQuery(\n {\n ...runsQuery(client, scope),\n enabled: options.active ?? true,\n refetchInterval: options.pollMs ?? false,\n },\n queryClient,\n );\n}\n\n// The paged listing; polling refetches every loaded page.\nexport function useRunPagesQuery(\n scope: RunsScope,\n options: { active?: boolean; pollMs?: number } = {},\n) {\n const { client, queryClient } = useRuntime();\n return useInfiniteQuery(\n {\n ...runPagesQuery(client, scope),\n enabled: options.active ?? true,\n refetchInterval: options.pollMs ?? false,\n },\n queryClient,\n );\n}\n\n// A suspended run changes when someone decides, so it is polled slowly.\nconst WAITING_RUN_POLL_MS = 30_000;\n\n// One run with its steps' input and output; polled until it finishes.\nexport function useRunQuery(runId: string, options: { pollMs?: number } = {}) {\n const { client, queryClient } = useRuntime();\n return useQuery(\n {\n ...runQuery(client, runId),\n refetchInterval: (query) => {\n const data = query.state.data;\n if (!options.pollMs || data?.endedAt != null) return false;\n return data?.status === \"WAITING\"\n ? Math.max(options.pollMs, WAITING_RUN_POLL_MS)\n : options.pollMs;\n },\n },\n queryClient,\n );\n}\n\n// Runs paused at a waitpoint, polled while `active`.\nexport function useWaitingRunsQuery(\n scope: WaitingRunsScope,\n options: { active?: boolean; pollMs?: number } = {},\n) {\n const { client, queryClient } = useRuntime();\n return useQuery(\n {\n ...waitingRunsQuery(client, scope),\n enabled: options.active ?? true,\n refetchInterval: options.pollMs ?? false,\n },\n queryClient,\n );\n}\n\n// Undefined while the stat loads; null when the ref doesn't resolve.\nexport function useSecretStat(\n ref: string,\n enabled: boolean,\n): SecretStat | null | undefined {\n const { client, queryClient } = useRuntime();\n const query = useQuery(\n { ...secretStatQuery(client, ref), enabled, gcTime: 0 },\n queryClient,\n );\n if (!enabled) return null;\n if (query.status === \"pending\") return undefined;\n return query.status === \"error\" ? null : query.data;\n}\n\n// Absolute; null when the host serves no OAuth2 callback.\nexport function useOAuthRedirectUri() {\n const { client, queryClient } = useRuntime();\n return useQuery(\n {\n queryKey: [client.url, \"oauthRedirectUri\"],\n queryFn: () => client.fetchOAuthRedirectUri(),\n staleTime: Infinity,\n },\n queryClient,\n );\n}\n\n// Polled until the sign-in finishes. Undefined while loading; null for no\n// state, or one the switchboard does not know (or could not be asked about).\nexport function useOAuthAttempt(\n state: string | null,\n): OAuthAttempt | null | undefined {\n const { client, queryClient } = useRuntime();\n const query = useQuery(\n {\n queryKey: [client.url, \"oauthAttempt\", state],\n queryFn: () => client.fetchOAuthAttempt(state!),\n enabled: state !== null,\n gcTime: 0,\n refetchInterval: (current) => {\n if (current.state.status === \"error\") return false;\n const data = current.state.data;\n if (data === null) return false;\n return data?.status === \"OK\" || data?.status === \"ERROR\" ? false : 1000;\n },\n },\n queryClient,\n );\n if (state === null || query.isError) return null;\n return query.data;\n}\n\n// Writes that change runtime state, each dropping the queries it affects.\nexport function useRuntimeActions() {\n const { client, queryClient } = useRuntime();\n return useMemo(() => {\n const invalidate = (queryKey: readonly unknown[]) =>\n void queryClient.invalidateQueries({ queryKey });\n const runsChanged = () => {\n invalidate(runtimeKeys.allRuns(client.url));\n invalidate([client.url, \"latestRun\"]);\n };\n const secretSaved = (stat: SecretStat) => {\n queryClient.setQueryData(runtimeKeys.secret(client.url, stat.ref), stat);\n return stat;\n };\n return {\n fireWorkflow: (workflowId: string, payload?: unknown) =>\n client.fireWorkflow(workflowId, payload).finally(runsChanged),\n rerunRun: (runId: string) => client.rerunRun(runId).finally(runsChanged),\n resolveWaitpoint: (\n waitpoint: { id: string; runId: string },\n approved: boolean,\n reason?: string,\n ) =>\n client.resolveWaitpoint(waitpoint.id, approved, reason).finally(() => {\n runsChanged();\n invalidate(runtimeKeys.run(client.url, waitpoint.runId));\n }),\n cancelRun: (runId: string) =>\n client.cancelRun(runId).finally(() => {\n runsChanged();\n invalidate(runtimeKeys.run(client.url, runId));\n }),\n createSecret: (documentId: string, value: string, label?: string) =>\n client.createSecret(documentId, value, label).then(secretSaved),\n rotateSecret: (ref: string, value: string) =>\n client.rotateSecret(ref, value).then(secretSaved),\n checkConnection: (connectionId: string) =>\n client\n .checkConnection(connectionId)\n .finally(() => invalidate(runtimeKeys.connections(client.url))),\n connectionsChanged: () => invalidate(runtimeKeys.connections(client.url)),\n startOAuth: (\n connectionId: string,\n options?: { redirectUri?: string; returnUrl?: string },\n ) => client.startOAuth(connectionId, options),\n };\n }, [client, queryClient]);\n}\n","// Lean required-field check shared by the property form, the side panel\n// header and the canvas badge. No schema validation: {{}} values defeat it.\nimport {\n scheduleConfigIssue,\n stepPorts,\n} from \"@powerhousedao/pieces-framework/workflow\";\nimport type { BlockRef } from \"./blocks.js\";\nimport type { BlockForm, BlockFormProp } from \"./forms.js\";\nimport type { PropertyModeValue, PropertySettingModel } from \"./model.js\";\nimport type { ResolverKeyInput } from \"./query-keys.js\";\n\nexport function isEmptyValue(value: unknown): boolean {\n if (value === undefined || value === null) return true;\n if (typeof value === \"string\") return value.trim() === \"\";\n if (Array.isArray(value)) return value.length === 0;\n return false;\n}\n\n// Whether a prop's `showWhen` is met; shared with the property form so one rule\n// decides render and required — else a hidden field warns with nothing to fix.\nexport function isPropVisible(\n prop: BlockFormProp,\n config: Record<string, unknown>,\n): boolean {\n const rule = prop.showWhen;\n if (!rule) return true;\n return rule.oneOf.includes(config[rule.prop] ?? undefined);\n}\n\nfunction asRecord(config: unknown): Record<string, unknown> {\n return config !== null && typeof config === \"object\" && !Array.isArray(config)\n ? (config as Record<string, unknown>)\n : {};\n}\n\n// Display names of required props with no value; MARKDOWN is informational.\nexport function missingRequired(\n props: BlockFormProp[],\n config: unknown,\n): string[] {\n const record = asRecord(config);\n return props\n .filter(\n (prop) =>\n prop.required &&\n prop.type !== \"MARKDOWN\" &&\n isPropVisible(prop, record) &&\n isEmptyValue(record[prop.name]),\n )\n .map((prop) => prop.displayName);\n}\n\n// What a prop's resolver answer depends on: its refreshers and the connection.\nexport function resolverInputFor(\n block: BlockRef,\n prop: BlockFormProp,\n config: Record<string, unknown>,\n connectionId: string | null | undefined,\n reactorConnectionId?: string | null,\n): ResolverKeyInput {\n const refreshers = (prop.refreshers ?? []).filter((name) => name !== \"auth\");\n return {\n block,\n propName: prop.name,\n refreshers: refreshers.map((name) => config[name] ?? null),\n connectionId: connectionId ?? null,\n ...(reactorConnectionId ? { reactorConnectionId } : {}),\n };\n}\n\nexport function settingFor(\n settings: readonly PropertySettingModel[] | null | undefined,\n prop: string,\n): PropertySettingModel | undefined {\n return settings?.find((setting) => setting.prop === prop);\n}\n\n// A DYNAMIC resolver's answer as a prop list.\nexport function parsePropList(result: unknown): BlockFormProp[] {\n if (!Array.isArray(result)) throw new Error(\"Unexpected properties result\");\n return result.filter(\n (entry): entry is BlockFormProp =>\n entry !== null &&\n typeof entry === \"object\" &&\n typeof (entry as BlockFormProp).name === \"string\",\n );\n}\n\n// A stored DYNAMIC schema, when it parses as a prop list.\nexport function storedSchema(\n settings: readonly PropertySettingModel[] | null | undefined,\n prop: string,\n): BlockFormProp[] | undefined {\n const schema = settingFor(settings, prop)?.schema;\n if (!Array.isArray(schema)) return undefined;\n return schema.filter(\n (entry): entry is BlockFormProp =>\n entry !== null &&\n typeof entry === \"object\" &&\n typeof (entry as BlockFormProp).name === \"string\",\n );\n}\n\n// Children as stored: dropdown options go, they are the resolver's to answer.\nexport function stripOptions(props: BlockFormProp[]): BlockFormProp[] {\n return props.map((prop) => {\n const { staticOptions: _options, properties, ...rest } = prop;\n return properties\n ? { ...rest, properties: stripOptions(properties) }\n : rest;\n });\n}\n\n// Settings with one prop's entry replaced; null drops the schema only.\nexport function withSetting(\n settings: readonly PropertySettingModel[] | null | undefined,\n prop: string,\n patch: { mode?: PropertyModeValue; schema?: unknown },\n): PropertySettingModel[] {\n const list = [...(settings ?? [])];\n const index = list.findIndex((setting) => setting.prop === prop);\n const current = index >= 0 ? list[index] : { prop, mode: \"MANUAL\" as const };\n const next: PropertySettingModel = {\n prop,\n mode: patch.mode ?? current.mode,\n schema:\n \"schema\" in patch ? (patch.schema ?? null) : (current.schema ?? null),\n };\n if (index >= 0) list[index] = next;\n else list.push(next);\n return list;\n}\n\nexport interface ValidityInput {\n form: BlockForm | null | \"loading\" | undefined;\n block: BlockRef;\n config: unknown;\n connectionId: string | null | undefined;\n reactorConnectionId?: string | null;\n propertySettings?: readonly PropertySettingModel[] | null;\n skip?: boolean | null;\n // DYNAMIC children already resolved for a key; undefined when not cached.\n resolveDynamic?: (input: ResolverKeyInput) => BlockFormProp[] | undefined;\n}\n\nexport const REACTOR_CONNECTION_LABEL = \"Reactor connection\";\n\n// What a block still needs before it can run. [] is complete; null is\n// unknown: the form isn't there, or a DYNAMIC prop is unresolved.\nexport function blockMissing(input: ValidityInput): string[] | null {\n if (input.skip) return [];\n const { form } = input;\n if (!form || form === \"loading\") return null;\n const record = asRecord(input.config);\n const missing: string[] = [];\n let unknown = false;\n if (form.auth === \"required\" && !input.connectionId) {\n missing.push(\"Connection\");\n }\n if (form.requireReactor && !input.reactorConnectionId) {\n missing.push(REACTOR_CONNECTION_LABEL);\n }\n for (const prop of form.props) {\n if (prop.type === \"MARKDOWN\" || !isPropVisible(prop, record)) continue;\n const value = record[prop.name];\n const bound =\n settingFor(input.propertySettings, prop.name)?.mode === \"EXPRESSION\";\n if (prop.type !== \"DYNAMIC\" || bound) {\n if (prop.required && isEmptyValue(value)) missing.push(prop.displayName);\n continue;\n }\n const children =\n input.resolveDynamic?.(\n resolverInputFor(\n input.block,\n prop,\n record,\n input.connectionId,\n input.reactorConnectionId,\n ),\n ) ?? storedSchema(input.propertySettings, prop.name);\n if (children === undefined) {\n unknown = true;\n continue;\n }\n missing.push(...missingRequired(children, value));\n }\n if (missing.length > 0) return missing;\n // The builder's config is checked by the parser the runtime arms with.\n if (form.display === \"schedule\") {\n const issue = scheduleConfigIssue(input.config);\n if (issue) return [issue.replace(/^Schedule: /, \"\")];\n }\n return unknown ? null : [];\n}\n\n// Edges leaving on a port the block does not declare: no run takes them.\n// With the step's config, a router's ports follow its branches.\nexport function undeclaredPortIssues(\n form: BlockForm | null | \"loading\" | undefined,\n outgoingPorts: readonly string[] | undefined,\n step?: { block: BlockRef; config: unknown },\n): string[] {\n const formPorts = form && form !== \"loading\" ? form.ports : undefined;\n const ports = step\n ? stepPorts(step.block, step.config, () => formPorts, outgoingPorts)\n : formPorts;\n if (!ports || !outgoingPorts) return [];\n return [...new Set(outgoingPorts)]\n .filter((port) => !ports.includes(port))\n .map((port) => `An edge leaves on \"${port}\", which this block never takes`);\n}\n\nexport interface WorkflowReadiness {\n // A trigger, and every non-skipped block checked and complete.\n ready: boolean;\n hasTrigger: boolean;\n // First block, in the order given, with a field left to fill.\n firstIncomplete: string | null;\n // Some block is not checked yet: its form or a DYNAMIC schema is unknown.\n checking: boolean;\n}\n\n// Folds per-block blockMissing results, trigger first then flow order.\nexport function workflowReadiness(\n blocks: readonly { id: string; missing: string[] | null }[],\n hasTrigger: boolean,\n): WorkflowReadiness {\n const firstIncomplete =\n blocks.find((block) => block.missing && block.missing.length > 0)?.id ??\n null;\n const checking = blocks.some((block) => block.missing === null);\n return {\n ready: hasTrigger && !checking && firstIncomplete === null,\n hasTrigger,\n firstIncomplete,\n checking,\n };\n}\n","// The step form's runtime seam: a DesignTimeService plus the query cache its\n// answers live in, provided by the editor shell (or a test harness).\nimport {\n keepPreviousData,\n QueryClient,\n useQueries,\n useQuery,\n type Query,\n type QueryKey,\n} from \"@tanstack/react-query\";\nimport {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport type {\n BlockForm,\n BlockFormProp,\n BlockResolutionView,\n ConnectionSummary,\n DesignTimeService,\n LatestRun,\n StepTestOutcome,\n WebhookEndpoint,\n} from \"./forms.js\";\nimport { parsePropList } from \"./validation.js\";\nimport { isSyncingError } from \"../runtime-client.js\";\nimport type { BlockRef } from \"./blocks.js\";\nimport {\n blockRefKey,\n RESOLVER_STALE_MS,\n runtimeKeys,\n SHARED_STALE_MS,\n type ResolverKeyInput,\n} from \"./query-keys.js\";\n\ninterface DesignTimeContextValue {\n service?: DesignTimeService;\n queryClient: QueryClient;\n // Leads every query key; the runtime URL in the editor.\n scope: string;\n}\n\nconst DesignTimeContext = createContext<DesignTimeContextValue | null>(null);\n\nexport function DesignTimeProvider(props: {\n service?: DesignTimeService;\n queryClient: QueryClient;\n scope: string;\n children: ReactNode;\n}) {\n const { service, queryClient, scope } = props;\n const value = useMemo(\n () => ({ service, queryClient, scope }),\n [service, queryClient, scope],\n );\n return (\n <DesignTimeContext.Provider value={value}>\n {props.children}\n </DesignTimeContext.Provider>\n );\n}\n\nexport function useDesignTime(): DesignTimeService | undefined {\n return useContext(DesignTimeContext)?.service;\n}\n\n// Outside a provider nothing loads; the private client only satisfies hooks.\nfunction useDesignTimeScope(): DesignTimeContextValue {\n const context = useContext(DesignTimeContext);\n const [detached] = useState(() =>\n context ? null : { queryClient: new QueryClient(), scope: \"\" },\n );\n return context ?? detached!;\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n// Null means \"no form, fall back to JSON\"; a refusal keeps its message.\nexport function useBlockForm(block: BlockRef): {\n form: BlockForm | null | \"loading\";\n error?: string;\n} {\n const { service, queryClient, scope } = useDesignTimeScope();\n const query = useQuery(\n {\n queryKey: runtimeKeys.form(scope, block),\n queryFn: () => service!.getBlockForm(block),\n enabled: Boolean(service),\n staleTime: SHARED_STALE_MS,\n },\n queryClient,\n );\n if (!service) return { form: null };\n if (query.data !== undefined) return { form: query.data };\n if (query.status === \"error\") {\n return { form: null, error: messageOf(query.error) };\n }\n return { form: \"loading\" };\n}\n\nfunction formQuery(service: DesignTimeService, scope: string, block: BlockRef) {\n return {\n queryKey: runtimeKeys.form(scope, block),\n queryFn: () => service.getBlockForm(block),\n staleTime: SHARED_STALE_MS,\n };\n}\n\n// Fetches a block's form through the shared cache; null when none loads.\nexport function useBlockFormLoader(): (\n block: BlockRef,\n) => Promise<BlockForm | null> {\n const { service, queryClient, scope } = useDesignTimeScope();\n return useMemo(\n () => async (block: BlockRef) => {\n if (!service) return null;\n try {\n return await queryClient.fetchQuery(formQuery(service, scope, block));\n } catch {\n return null;\n }\n },\n [service, queryClient, scope],\n );\n}\n\n// A block's form only if the cache already holds it; never fetches.\nexport function useCachedBlockForm(): (\n block: BlockRef,\n) => BlockForm | null | undefined {\n const { queryClient, scope } = useDesignTimeScope();\n return useMemo(\n () => (block: BlockRef) =>\n queryClient.getQueryData<BlockForm | null>(\n runtimeKeys.form(scope, block),\n ),\n [queryClient, scope],\n );\n}\n\n// Warms a block's form, e.g. while its picker row is hovered.\nexport function useBlockFormPrefetch(): (block: BlockRef) => void {\n const { service, queryClient, scope } = useDesignTimeScope();\n return useMemo(\n () => (block: BlockRef) => {\n if (!service) return;\n void queryClient.prefetchQuery(formQuery(service, scope, block));\n },\n [service, queryClient, scope],\n );\n}\n\n// useBlockForm for many blocks at once, keyed by blockRefKey.\nexport function useBlockForms(\n blocks: readonly BlockRef[],\n): ReadonlyMap<string, BlockForm | null | \"loading\"> {\n const { service, queryClient, scope } = useDesignTimeScope();\n const unique = [\n ...new Map(blocks.map((block) => [blockRefKey(block), block])).values(),\n ];\n const results = useQueries(\n {\n queries: unique.map((block) => ({\n queryKey: runtimeKeys.form(scope, block),\n queryFn: () => service!.getBlockForm(block),\n enabled: Boolean(service),\n staleTime: SHARED_STALE_MS,\n })),\n },\n queryClient,\n );\n const forms = new Map<string, BlockForm | null | \"loading\">();\n unique.forEach((block, index) => {\n const query = results[index];\n forms.set(\n blockRefKey(block),\n !service\n ? null\n : query.data !== undefined\n ? query.data\n : query.status === \"error\"\n ? null\n : \"loading\",\n );\n });\n return forms;\n}\n\n// Each block's declared ports, once its form has loaded.\nexport function useBlockPorts(\n blocks: readonly BlockRef[],\n): (block: BlockRef) => readonly string[] | undefined {\n const forms = useBlockForms(blocks);\n return (block) => {\n const form = forms.get(blockRefKey(block));\n return form && form !== \"loading\" ? form.ports : undefined;\n };\n}\n\nexport type LoadState<T> =\n | { kind: \"idle\" }\n | { kind: \"loading\" }\n | { kind: \"ready\"; result: T }\n | { kind: \"error\"; message: string };\n\nfunction keyHash(value: unknown): string {\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\n// A just-bound reactor connection the runtime doesn't hold yet reads as forbidden.\n// A just-made document the Switchboard doesn't hold yet; never a sign-in.\nconst SYNC_REFUSAL = /forbidden|document\\b.*not found|was not found/i;\nconst SYNC_RETRIES_MAX = 4;\n\nfunction retryWhileSyncing(input: ResolverKeyInput) {\n if (!input.reactorConnectionId) return {};\n return {\n retry: (failures: number, error: unknown) =>\n failures < SYNC_RETRIES_MAX && SYNC_REFUSAL.test(messageOf(error)),\n retryDelay: 1000,\n };\n}\n\n// The first value passes straight through; later changes settle after `ms`.\nfunction useSettled<T>(value: T, ms: number): T {\n const hash = keyHash(value);\n const latest = useRef(value);\n useEffect(() => {\n latest.current = value;\n });\n const [settled, setSettled] = useState({ hash, value });\n useEffect(() => {\n if (hash === settled.hash) return;\n const timer = setTimeout(\n () => setSettled({ hash, value: latest.current }),\n ms,\n );\n return () => clearTimeout(timer);\n }, [hash, settled.hash, ms]);\n return settled.value;\n}\n\n// A DROPDOWN's options or a DYNAMIC prop's fields, cached per resolver key;\n// a changed key re-resolves after `debounceMs`. `reload` is the manual retry.\nexport function useResolvedProp<T>(options: {\n kind: \"options\" | \"dynamic\";\n input: ResolverKeyInput;\n load: (() => Promise<unknown>) | undefined;\n parse: (raw: unknown) => T;\n debounceMs: number;\n}): { state: LoadState<T>; reload: () => void; syncing: boolean } {\n const { queryClient, scope } = useDesignTimeScope();\n const input = useSettled(options.input, options.debounceMs);\n const loadRef = useRef(options);\n useEffect(() => {\n loadRef.current = options;\n });\n const enabled = Boolean(options.load);\n const query = useQuery(\n {\n queryKey: runtimeKeys[options.kind](scope, input),\n queryFn: async () => {\n const current = loadRef.current;\n if (!current.load) throw new Error(\"No resolver\");\n return current.parse(await current.load());\n },\n enabled,\n staleTime: RESOLVER_STALE_MS,\n ...retryWhileSyncing(input),\n },\n queryClient,\n );\n const reload = () => void query.refetch();\n // Retrying a refusal that reads as a document still syncing.\n const syncing = query.isFetching && query.failureCount > 0;\n if (!enabled) return { state: { kind: \"idle\" }, reload, syncing: false };\n if (query.isFetching) return { state: { kind: \"loading\" }, reload, syncing };\n if (query.status === \"error\") {\n return {\n state: { kind: \"error\", message: messageOf(query.error) },\n reload,\n syncing,\n };\n }\n if (query.status === \"success\") {\n return { state: { kind: \"ready\", result: query.data }, reload, syncing };\n }\n return { state: { kind: \"loading\" }, reload, syncing };\n}\n\n// refreshOnSearch: the resolver re-runs with what the author types, debounced.\n// The previous answer stays up until the new one lands.\nexport function useOptionSearch<T>(options: {\n input: ResolverKeyInput;\n query: string;\n load: ((searchValue: string) => Promise<unknown>) | undefined;\n parse: (raw: unknown) => T;\n debounceMs: number;\n}): T | null {\n const { queryClient, scope } = useDesignTimeScope();\n const typed = options.query.trim() === \"\" ? \"\" : options.query;\n const settled = useSettled(typed, options.debounceMs);\n const loadRef = useRef(options);\n useEffect(() => {\n loadRef.current = options;\n });\n const query = useQuery(\n {\n queryKey: runtimeKeys.options(scope, {\n ...options.input,\n searchValue: settled,\n }),\n queryFn: async () => {\n const current = loadRef.current;\n if (!current.load) throw new Error(\"No resolver\");\n return current.parse(await current.load(settled));\n },\n enabled: Boolean(options.load) && settled !== \"\" && typed !== \"\",\n staleTime: RESOLVER_STALE_MS,\n ...retryWhileSyncing(options.input),\n placeholderData: keepPreviousData,\n },\n queryClient,\n );\n return typed === \"\" ? null : (query.data ?? null);\n}\n\n// DYNAMIC fields already resolved for `input`, straight from the cache.\nexport function getResolvedDynamicProps(\n queryClient: QueryClient,\n scope: string,\n input: ResolverKeyInput,\n): BlockFormProp[] | undefined {\n return queryClient.getQueryData<BlockFormProp[]>(\n runtimeKeys.dynamic(scope, input) as unknown as QueryKey,\n );\n}\n\n// Resolves a DYNAMIC prop into the cache the form reads, so the canvas can\n// check a step without its panel open.\nexport function useDynamicPrefetch(): (\n input: ResolverKeyInput,\n config: Record<string, unknown>,\n) => void {\n const { service, queryClient, scope } = useDesignTimeScope();\n return useMemo(\n () => (input: ResolverKeyInput, config: Record<string, unknown>) => {\n if (!service) return;\n void queryClient.prefetchQuery({\n queryKey: runtimeKeys.dynamic(scope, input),\n queryFn: () =>\n service\n .loadOptions(\n input.block,\n input.propName,\n config,\n input.connectionId ?? undefined,\n undefined,\n input.reactorConnectionId ?? undefined,\n )\n .then(parsePropList),\n staleTime: RESOLVER_STALE_MS,\n ...retryWhileSyncing(input),\n });\n },\n [service, queryClient, scope],\n );\n}\n\n// A cache lookup for DYNAMIC fields, read when the caller asks.\nexport function useDynamicCache(): (\n input: ResolverKeyInput,\n) => BlockFormProp[] | undefined {\n const { queryClient, scope } = useDesignTimeScope();\n return useMemo(\n () => (input: ResolverKeyInput) =>\n getResolvedDynamicProps(queryClient, scope, input),\n [queryClient, scope],\n );\n}\n\n// A cache lookup for DYNAMIC fields that re-renders as resolver answers land.\nexport function useDynamicLookup(): (\n input: ResolverKeyInput,\n) => BlockFormProp[] | undefined {\n const { queryClient, scope } = useDesignTimeScope();\n const [version, setVersion] = useState(0);\n useEffect(\n () =>\n queryClient.getQueryCache().subscribe((event) => {\n if (event.type !== \"updated\") return;\n const key = (event.query as Query).queryKey;\n if (key[0] === scope && key[1] === \"dynamic\") setVersion((v) => v + 1);\n }),\n [queryClient, scope],\n );\n // A fresh function per landed answer, so dependents recompute.\n return useMemo(\n () => (input: ResolverKeyInput) =>\n version >= 0\n ? getResolvedDynamicProps(queryClient, scope, input)\n : undefined,\n [queryClient, scope, version],\n );\n}\n\n// One journaled run, e.g. the trigger's last test; undefined while unknown.\nexport function useRunById(\n runId: string | null | undefined,\n): LatestRun | null | undefined {\n const { service, queryClient, scope } = useDesignTimeScope();\n const fetchRun = service?.fetchRun;\n const query = useQuery(\n {\n queryKey: runtimeKeys.run(scope, runId ?? \"\"),\n queryFn: () => fetchRun!(runId!),\n enabled: Boolean(fetchRun && runId),\n staleTime: Infinity,\n },\n queryClient,\n );\n if (!runId) return null;\n return query.data;\n}\n\nexport type LatestRunState =\n | { kind: \"loading\" }\n | { kind: \"ready\"; run: LatestRun | null };\n\n// The workflow's most recent run; null when the service can't say.\nexport function useLatestRun(enabled = true): LatestRunState | null {\n const { service, queryClient, scope } = useDesignTimeScope();\n const active = enabled && Boolean(service?.latestRun);\n const query = useQuery(\n {\n queryKey: runtimeKeys.latestRun(scope, service?.workflowId ?? \"\"),\n queryFn: () => service!.latestRun!(),\n enabled: active,\n staleTime: 0,\n },\n queryClient,\n );\n if (!active) return null;\n if (query.status === \"pending\") return { kind: \"loading\" };\n return { kind: \"ready\", run: query.data ?? null };\n}\n\n// The runtime already waits for the document; these cover a slower sync.\nconst SYNC_RETRIES = 5;\nconst SYNC_RETRY_MS = 2_000;\n\nexport type EndpointState =\n | { kind: \"loading\" }\n | { kind: \"syncing\" }\n | { kind: \"empty\" }\n | { kind: \"error\"; message: string }\n | { kind: \"ready\"; endpoint: WebhookEndpoint };\n\n// Never kept: the runtime mints the endpoint on first ask, and `armed`\n// follows the workflow's status.\nexport function useWebhookEndpoint(enabled: boolean): EndpointState {\n const { service, queryClient, scope } = useDesignTimeScope();\n const active = enabled && Boolean(service?.webhookEndpoint);\n const query = useQuery(\n {\n queryKey: runtimeKeys.webhook(scope, service?.workflowId ?? \"\"),\n queryFn: () => service!.webhookEndpoint!(),\n enabled: active,\n staleTime: 0,\n gcTime: 0,\n // A new workflow may not have reached the runtime yet.\n retry: (failures, error) =>\n isSyncingError(error) && failures < SYNC_RETRIES,\n retryDelay: SYNC_RETRY_MS,\n },\n queryClient,\n );\n if (query.status === \"pending\" && isSyncingError(query.failureReason)) {\n return { kind: \"syncing\" };\n }\n if (query.status === \"error\") {\n return { kind: \"error\", message: messageOf(query.error) };\n }\n if (query.status === \"pending\") return { kind: \"loading\" };\n return query.data\n ? { kind: \"ready\", endpoint: query.data }\n : { kind: \"empty\" };\n}\n\n// Connection documents for the picker. Never kept: the server scopes the\n// listing to the caller.\nexport function useConnectionList(): {\n connections: ConnectionSummary[];\n refetch: () => void;\n // Drops every connection listing for this runtime.\n invalidate: () => void;\n // Fetches afresh into the cache; creating a connection polls this.\n fetchNow: () => Promise<ConnectionSummary[]>;\n} {\n const { service, queryClient, scope } = useDesignTimeScope();\n const list = service?.listConnections;\n const options = {\n queryKey: runtimeKeys.connections(scope, service?.connectionScope ?? null),\n queryFn: () => list!(),\n staleTime: 0,\n gcTime: 0,\n };\n const query = useQuery({ ...options, enabled: Boolean(list) }, queryClient);\n return {\n connections: query.data ?? [],\n refetch: () => {\n if (list) void query.refetch();\n },\n invalidate: () =>\n void queryClient.invalidateQueries({\n queryKey: runtimeKeys.connections(scope),\n }),\n fetchNow: () =>\n list\n ? queryClient.fetchQuery({ ...options, staleTime: 0 })\n : Promise.resolve([]),\n };\n}\n\n// A step test is a new run and a new sample for the output trees.\nexport function useTestStepRunner():\n | ((stepId: string) => Promise<StepTestOutcome>)\n | undefined {\n const { service, queryClient, scope } = useDesignTimeScope();\n const test = service?.testStep;\n if (!test) return undefined;\n return (stepId) =>\n test(stepId).finally(() => {\n for (const queryKey of [\n runtimeKeys.allRuns(scope),\n [scope, \"latestRun\"],\n runtimeKeys.outputTrees(scope),\n ]) {\n void queryClient.invalidateQueries({ queryKey });\n }\n });\n}\n\n// Runs the trigger's test hook; its samples can change the output trees.\nexport function useTestTrigger(): (() => Promise<unknown>) | undefined {\n const { service, queryClient, scope } = useDesignTimeScope();\n const test = service?.testTrigger;\n if (!test) return undefined;\n return () =>\n test().finally(\n () =>\n void queryClient.invalidateQueries({\n queryKey: runtimeKeys.outputTrees(scope),\n }),\n );\n}\n\nclass DraftNotSynced extends Error {}\n\n// Retries while the runtime still reads an older draft than the editor holds.\nconst DRAFT_SYNC_RETRIES = 10;\n\n/**\n * The piece version each draft block runs, trigger first; `blocks` is the\n * draft in that order. Empty outside a runtime, or until the runtime answers.\n */\nexport function useBlockResolutions(\n workflowId: string,\n blocks: readonly { id: string; block: BlockRef }[],\n): BlockResolutionView[] {\n const { service, queryClient, scope } = useDesignTimeScope();\n const fetchResolutions = service?.blockResolutions;\n const expected = blocks.map(\n (entry) => `${entry.id}=${blockRefKey(entry.block)}`,\n );\n const query = useQuery(\n {\n queryKey: runtimeKeys.blockResolutions(\n scope,\n workflowId,\n blocks.map((entry) => entry.block),\n ),\n queryFn: async () => {\n const resolutions = await fetchResolutions!();\n const answered = resolutions.map(\n (resolution) => `${resolution.stepId}=${blockRefKey(resolution)}`,\n );\n if (keyHash(answered) !== keyHash(expected)) {\n throw new DraftNotSynced();\n }\n return resolutions;\n },\n enabled: Boolean(fetchResolutions && workflowId),\n retry: (count, error) =>\n error instanceof DraftNotSynced && count < DRAFT_SYNC_RETRIES,\n retryDelay: 300,\n placeholderData: keepPreviousData,\n staleTime: 0,\n },\n queryClient,\n );\n return query.data ?? EMPTY_RESOLUTIONS;\n}\n\nconst EMPTY_RESOLUTIONS: BlockResolutionView[] = [];\n","// Shared run vocabulary: one set of formatters and status colours so the\n// header, the table and the editor toolbar never disagree about a run.\nimport type { RunRecord } from \"../../workflow-editor/runtime-client.js\";\n\nexport const RUN_STATUSES = [\n \"RUNNING\",\n \"WAITING\",\n \"SUCCEEDED\",\n \"FAILED\",\n] as const;\n\n// Every status maps to one of five tones; colour carries meaning nowhere else.\nexport type Tone = \"ok\" | \"fail\" | \"warn\" | \"run\" | \"idle\";\n\nexport const TONE_TEXT: Record<Tone, string> = {\n ok: \"text-wf-ok\",\n fail: \"text-wf-fail\",\n warn: \"text-wf-warn\",\n run: \"text-wf-run\",\n idle: \"text-muted-foreground\",\n};\n\nexport const TONE_DOT: Record<Tone, string> = {\n ok: \"bg-wf-ok\",\n fail: \"bg-wf-fail\",\n warn: \"bg-wf-warn\",\n run: \"bg-wf-run\",\n idle: \"bg-muted-foreground/40\",\n};\n\nexport const TONE_BADGE: Record<Tone, string> = {\n ok: \"bg-wf-ok/12 text-wf-ok\",\n fail: \"bg-wf-fail/12 text-wf-fail\",\n warn: \"bg-wf-warn/12 text-wf-warn\",\n run: \"bg-wf-run/12 text-wf-run\",\n idle: \"bg-muted text-muted-foreground\",\n};\n\nexport const RUN_TONE: Record<string, Tone> = {\n SUCCEEDED: \"ok\",\n FAILED: \"fail\",\n RUNNING: \"run\",\n // Paused for an approval, a webhook or a delay: someone may need to act.\n WAITING: \"warn\",\n PENDING: \"idle\",\n PARKED: \"warn\",\n CANCELLED: \"idle\",\n};\n\nexport const STEP_TONE: Record<string, Tone> = {\n ...RUN_TONE,\n SKIPPED: \"idle\",\n REPLAYED: \"run\",\n // Neither a success nor a failure: a host call the step made timed out, so\n // a write it asked for may well have been committed. Its own tone, because\n // reading it as either of the other two is the mistake.\n INDETERMINATE: \"warn\",\n};\n\nexport const WORKFLOW_TONE: Record<string, Tone> = {\n ENABLED: \"ok\",\n DRAFT: \"idle\",\n DISABLED: \"warn\",\n ARCHIVED: \"idle\",\n};\n\n// A workflow's dot: hollow until it is first published, then coloured by its\n// last run, and a plain filled dot while it has none.\n// A succeeded run with warnings reads as a warning, never as a plain success.\nexport function runTone(run: {\n status: string;\n warningNotes?: readonly string[];\n}): Tone {\n if (run.status === \"SUCCEEDED\" && (run.warningNotes?.length ?? 0) > 0) {\n return \"warn\";\n }\n return toneOf(RUN_TONE, run.status);\n}\n\nexport function runStatusLabel(run: {\n status: string;\n warningNotes?: readonly string[];\n}): string {\n const count = run.warningNotes?.length ?? 0;\n const label = statusLabel(run.status);\n if (run.status !== \"SUCCEEDED\" || count === 0) return label;\n return `${label}, ${count} ${count === 1 ? \"warning\" : \"warnings\"}`;\n}\n\nexport function workflowHealth(\n status: string | undefined,\n lastRunStatus: string | undefined,\n published: boolean,\n): { tone: Tone; hollow: boolean; label: string } {\n if (!published) {\n return { tone: \"idle\", hollow: true, label: \"Not published yet\" };\n }\n const prefix =\n status === \"ENABLED\" ? \"\" : `${statusLabel(status ?? \"DISABLED\")}, `;\n const run = lastRunStatus\n ? `last run ${statusLabel(lastRunStatus).toLowerCase()}`\n : \"not run yet\";\n const label = prefix + run;\n return {\n tone: toneOf(RUN_TONE, lastRunStatus),\n hollow: false,\n label: label.charAt(0).toUpperCase() + label.slice(1),\n };\n}\n\nexport const CONNECTION_TONE: Record<string, Tone> = {\n OK: \"ok\",\n ERROR: \"fail\",\n REVOKED: \"fail\",\n UNCONFIGURED: \"warn\",\n};\n\nexport function toneOf(map: Record<string, Tone>, status?: string): Tone {\n const tone = status ? (map[status] as Tone | undefined) : undefined;\n return tone ?? \"idle\";\n}\n\n// FAILED → Failed; stored enums read as words, not tokens.\nexport function statusLabel(status: string): string {\n return status.charAt(0) + status.slice(1).toLowerCase();\n}\n\nexport function formatDuration(\n startedAt: string,\n endedAt: string | null,\n): string {\n if (!endedAt) return \"…\";\n return formatMs(new Date(endedAt).getTime() - new Date(startedAt).getTime());\n}\n\nexport interface TimelineSpan {\n // Fractions of the run's length, for positioning a bar.\n offset: number;\n width: number;\n ms: number;\n}\n\n// Where each timed step sat within its run; untimed steps (skipped, replayed,\n// journaled before timings) get no span.\nexport function runTimeline(run: {\n startedAt: string;\n endedAt: string | null;\n steps: { stepId: string; startedAt: string | null; endedAt: string | null }[];\n}): Map<string, TimelineSpan> {\n const start = new Date(run.startedAt).getTime();\n const ends = run.steps\n .map((step) => (step.endedAt ? new Date(step.endedAt).getTime() : 0))\n .concat(run.endedAt ? new Date(run.endedAt).getTime() : 0);\n const total = Math.max(...ends) - start;\n const spans = new Map<string, TimelineSpan>();\n if (total <= 0) return spans;\n for (const step of run.steps) {\n if (!step.startedAt || !step.endedAt) continue;\n const from = new Date(step.startedAt).getTime() - start;\n const ms =\n new Date(step.endedAt).getTime() - new Date(step.startedAt).getTime();\n spans.set(step.stepId, {\n offset: Math.min(Math.max(from / total, 0), 1),\n width: Math.min(Math.max(ms / total, 0), 1),\n ms,\n });\n }\n return spans;\n}\n\n// Rounds before splitting units, so 59.96s reads \"1m 0s\" rather than \"60.0s\".\nexport function formatMs(ms: number): string {\n if (ms < 1000) return `${ms}ms`;\n const tenths = Math.round(ms / 100);\n if (tenths < 600) return `${(tenths / 10).toFixed(1)}s`;\n const seconds = Math.round(ms / 1000);\n return `${Math.floor(seconds / 60)}m ${seconds % 60}s`;\n}\n\nexport function durationMs(\n startedAt: string,\n endedAt: string | null,\n): number | null {\n if (!endedAt) return null;\n return new Date(endedAt).getTime() - new Date(startedAt).getTime();\n}\n\nexport function formatWhen(startedAt: string): string {\n const diff = Date.now() - new Date(startedAt).getTime();\n if (diff < 60_000) return \"just now\";\n if (diff < 3_600_000) return `${Math.floor(diff / 60_000)}m ago`;\n if (diff < 86_400_000) return `${Math.floor(diff / 3_600_000)}h ago`;\n return new Date(startedAt).toLocaleDateString();\n}\n\n// A future instant, relative: \"in 5m\", \"in 3h\", \"in 2d\"; a past one is null.\nexport function formatUntil(iso: string): string | null {\n const diff = new Date(iso).getTime() - Date.now();\n if (diff <= 0) return null;\n if (diff < 60_000) return \"in under a minute\";\n if (diff < 3_600_000) return `in ${Math.floor(diff / 60_000)}m`;\n if (diff < 86_400_000) return `in ${Math.floor(diff / 3_600_000)}h`;\n if (diff < 7 * 86_400_000) return `in ${Math.floor(diff / 86_400_000)}d`;\n return `on ${new Date(iso).toLocaleDateString()}`;\n}\n\nexport function formatAbsolute(iso: string): string {\n return new Date(iso).toLocaleString();\n}\n\n// A trigger kind reads better as a verb phrase than as its stored token.\nexport function formatTrigger(kind: string): string {\n return kind.replace(/[-_]/g, \" \").toLowerCase();\n}\n\nexport interface RunStats {\n total: number;\n succeeded: number;\n failed: number;\n running: number;\n lastRun?: RunRecord;\n // Null until at least one run has finished.\n successRate: number | null;\n}\n\nexport function runStats(runs: RunRecord[]): RunStats {\n const succeeded = runs.filter((run) => run.status === \"SUCCEEDED\").length;\n const failed = runs.filter((run) => run.status === \"FAILED\").length;\n const finished = succeeded + failed;\n return {\n total: runs.length,\n succeeded,\n failed,\n running: runs.filter((run) => run.status === \"RUNNING\").length,\n // Runs arrive newest first.\n lastRun: runs[0],\n successRate:\n finished === 0 ? null : Math.round((succeeded / finished) * 100),\n };\n}\n\n// The error name of a run its deadline cancelled (the runtime's\n// RUN_DEADLINE_ERROR_NAME); a refused firing is CANCELLED without one.\nconst RUN_DEADLINE_ERROR_NAME = \"RunDeadlineExceeded\";\n\n// Whether the runtime will resume this run.\nexport function canRerun(run: { status: string; errorName?: string | null }) {\n return (\n run.status === \"FAILED\" ||\n (run.status === \"CANCELLED\" && run.errorName === RUN_DEADLINE_ERROR_NAME)\n );\n}\n","// Display metadata per block type: label + logo, Activepieces logos for\n// pieces, glyph badges for core blocks.\n//\n// Piece logo URLs are NOT derivable from the package name: Activepieces\n// serves ~10% of pieces from a different filename, folder or extension than\n// `<piece>.png` (e.g. @activepieces/piece-date-helper lives at\n// /pieces/new-core/date-helper.svg). So logos come from the piece catalog\n// metadata, registered here as it loads; unknown pieces render a glyph.\nimport {\n blockKey,\n type BlockIdentity,\n} from \"@powerhousedao/pieces-framework/block-type\";\nimport {\n APPROVAL_BLOCK,\n ASSERT_BLOCK,\n BRANCH_BLOCK,\n CALL_FLOW_BLOCK,\n CALLABLE_FLOW_TRIGGER,\n LOOP_BLOCK,\n ROUTER_BLOCK,\n DELAY_BLOCK,\n isCoreBlock,\n MANUAL_TRIGGER,\n RETURN_RESPONSE_BLOCK,\n SCHEDULE_TRIGGER,\n STOP_BLOCK,\n WAIT_FOR_WEBHOOK_BLOCK,\n WEBHOOK_TRIGGER,\n} from \"./blocks.js\";\nimport { useEffect, useSyncExternalStore } from \"react\";\nimport { usePieceSource, type PieceCatalogSource } from \"./piece-source.js\";\n\nexport interface BlockMeta {\n displayName: string;\n subtitle: string;\n logoUrl?: string;\n glyph?: string;\n}\n\n// Keyed by blockKey, so every version of a core block reads the same.\nconst CORE_META: Record<string, BlockMeta> = {\n [blockKey(MANUAL_TRIGGER)]: {\n displayName: \"Manual\",\n subtitle: \"Trigger\",\n glyph: \"▶\",\n },\n [blockKey(SCHEDULE_TRIGGER)]: {\n displayName: \"Schedule\",\n subtitle: \"Trigger\",\n glyph: \"◷\",\n },\n [blockKey(WEBHOOK_TRIGGER)]: {\n displayName: \"Webhook\",\n subtitle: \"Trigger\",\n glyph: \"⇲\",\n },\n [blockKey(BRANCH_BLOCK)]: {\n displayName: \"Branch\",\n subtitle: \"Core\",\n glyph: \"⑂\",\n },\n [blockKey(ROUTER_BLOCK)]: {\n displayName: \"Router\",\n subtitle: \"Core\",\n glyph: \"⑃\",\n },\n [blockKey(LOOP_BLOCK)]: {\n displayName: \"Loop on items\",\n subtitle: \"Core\",\n glyph: \"↻\",\n },\n [blockKey(ASSERT_BLOCK)]: {\n displayName: \"Assert\",\n subtitle: \"Core\",\n glyph: \"!\",\n },\n [blockKey(DELAY_BLOCK)]: {\n displayName: \"Delay\",\n subtitle: \"Core\",\n glyph: \"⧗\",\n },\n [blockKey(APPROVAL_BLOCK)]: {\n displayName: \"Request approval\",\n subtitle: \"Core\",\n glyph: \"✓\",\n },\n [blockKey(STOP_BLOCK)]: {\n displayName: \"Stop run\",\n subtitle: \"Core\",\n glyph: \"■\",\n },\n [blockKey(WAIT_FOR_WEBHOOK_BLOCK)]: {\n displayName: \"Respond and wait for webhook\",\n subtitle: \"Core\",\n glyph: \"⇄\",\n },\n [blockKey(CALLABLE_FLOW_TRIGGER)]: {\n displayName: \"Callable workflow\",\n subtitle: \"Trigger\",\n glyph: \"↳\",\n },\n [blockKey(CALL_FLOW_BLOCK)]: {\n displayName: \"Call workflow\",\n subtitle: \"Core\",\n glyph: \"↳\",\n },\n [blockKey(RETURN_RESPONSE_BLOCK)]: {\n displayName: \"Return response\",\n subtitle: \"Core\",\n glyph: \"↩\",\n },\n};\n\n// \"@activepieces/piece-http\" -> \"http\".\nfunction shortPieceName(packageName: string): string {\n return (\n packageName\n .split(\"/\")\n .pop()\n ?.replace(/^piece-/, \"\") ?? \"\"\n );\n}\n\n// Logos keyed by package name (\"@activepieces/piece-date-helper\"), as given\n// by the piece catalog. Module-level: display data, the same for any runtime.\nconst pieceLogos = new Map<string, string>();\n// Catalog display names (\"HTTP\", \"OpenAI\"), which the package name can't give.\nconst pieceNames = new Map<string, string>();\nconst listeners = new Set<() => void>();\n// Bumped on every registration so useSyncExternalStore re-reads.\nlet logoRevision = 0;\n\nexport function registerPieceLogos(\n entries: Iterable<{\n name: string;\n logoUrl?: string | null;\n displayName?: string | null;\n }>,\n): void {\n let changed = false;\n for (const entry of entries) {\n if (!entry.name) continue;\n if (entry.displayName && pieceNames.get(entry.name) !== entry.displayName) {\n pieceNames.set(entry.name, entry.displayName);\n changed = true;\n }\n if (!entry.logoUrl || pieceLogos.get(entry.name) === entry.logoUrl)\n continue;\n pieceLogos.set(entry.name, entry.logoUrl);\n changed = true;\n }\n if (!changed) return;\n logoRevision += 1;\n for (const listener of listeners) listener();\n}\n\nexport function pieceLogo(packageName: string): string | undefined {\n return pieceLogos.get(packageName);\n}\n\nexport function pieceDisplayName(packageName: string): string | undefined {\n return pieceNames.get(packageName);\n}\n\n// Action and trigger names (\"Ask ChatGPT\"), keyed by blockKey, loaded per\n// piece the first time one of its blocks is shown.\nconst blockNames = new Map<string, string>();\nconst namesRequested = new Set<string>();\n// Packages blockMeta() saw without names; drained by usePieceLogos.\nconst namesPending = new Set<string>();\n\nexport function registerBlockNames(\n entries: Iterable<BlockIdentity & { displayName: string }>,\n): void {\n let changed = false;\n for (const entry of entries) {\n const key = blockKey(entry);\n if (!entry.displayName || blockNames.get(key) === entry.displayName)\n continue;\n blockNames.set(key, entry.displayName);\n changed = true;\n }\n if (!changed) return;\n logoRevision += 1;\n for (const listener of listeners) listener();\n}\n\nfunction requestBlockNames(packageName: string): void {\n if (!namesRequested.has(packageName)) namesPending.add(packageName);\n}\n\n// Fire-and-forget, once per piece; a failure clears the mark so a later\n// render retries. The runtime layer caches the requests themselves.\nexport function loadPendingBlockNames(source: PieceCatalogSource): void {\n for (const packageName of namesPending) loadBlockNames(source, packageName);\n namesPending.clear();\n}\n\nfunction loadBlockNames(source: PieceCatalogSource, packageName: string) {\n if (namesRequested.has(packageName)) return;\n namesRequested.add(packageName);\n Promise.all([\n source.loadActions(packageName),\n source.loadTriggers(packageName),\n ])\n .then(([actions, triggers]) =>\n registerBlockNames([\n ...actions.map((entry) => ({ ...entry, kind: \"action\" as const })),\n ...triggers.map((entry) => ({ ...entry, kind: \"trigger\" as const })),\n ]),\n )\n .catch(() => namesRequested.delete(packageName));\n}\n\n// Test seam: drop the cache so a fresh catalog can be registered.\nexport function resetPieceLogos(): void {\n pieceLogos.clear();\n pieceNames.clear();\n blockNames.clear();\n namesRequested.clear();\n namesPending.clear();\n logoMisses.clear();\n for (const timer of retryTimers) clearTimeout(timer);\n retryTimers.clear();\n catalogLoads = new WeakMap();\n notify();\n}\n\nexport function subscribePieceLogos(listener: () => void): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n}\n\nfunction pieceLogoRevision(): number {\n return logoRevision;\n}\n\n// Pieces a block rendered for before their logo was known.\nconst logoMisses = new Set<string>();\n\ninterface CatalogLoad {\n // Absent while a retry waits.\n load?: Promise<void>;\n attempts: number;\n}\n\nlet catalogLoads = new WeakMap<PieceCatalogSource, CatalogLoad>();\nconst retryTimers = new Set<ReturnType<typeof setTimeout>>();\n\nexport const CATALOG_RETRY_MS = 2000;\nexport const CATALOG_MAX_ATTEMPTS = 5;\n\nfunction notify(): void {\n logoRevision += 1;\n for (const listener of listeners) listener();\n}\n\n// Backs off, then wakes subscribers so their next render's effect retries.\nfunction scheduleRetry(state: CatalogLoad): void {\n if (state.attempts >= CATALOG_MAX_ATTEMPTS) return;\n const timer = setTimeout(\n () => {\n retryTimers.delete(timer);\n state.load = undefined;\n notify();\n },\n CATALOG_RETRY_MS * 2 ** (state.attempts - 1),\n );\n retryTimers.add(timer);\n}\n\n// A failed load, or one missing a piece on screen (the runtime drops the\n// published catalog when it is down), is retried with a fresh fetch.\nexport function ensurePieceLogos(source?: PieceCatalogSource): Promise<void> {\n if (!source) return Promise.resolve();\n let state = catalogLoads.get(source);\n if (!state) {\n state = { attempts: 0 };\n catalogLoads.set(source, state);\n }\n if (state.load) return state.load;\n const current = state;\n const request =\n current.attempts > 0 && source.reloadCatalog\n ? source.reloadCatalog()\n : source.loadCatalog();\n current.attempts += 1;\n current.load = request.then(\n (pieces) => {\n registerPieceLogos(pieces);\n const listed = new Set(pieces.map((piece) => piece.name));\n const unlisted = [...logoMisses].some(\n (name) => !listed.has(name) && !pieceLogos.has(name),\n );\n if (unlisted) scheduleRetry(current);\n },\n () => scheduleRetry(current),\n );\n return current.load;\n}\n\n// Another piece's blocks the Core tab names itself, whatever the piece calls them.\nexport function namedByCoreTab(block: BlockIdentity): boolean {\n return !isCoreBlock(block) && blockKey(block) in CORE_META;\n}\n\nexport function blockMeta(block: BlockIdentity): BlockMeta {\n const key = blockKey(block);\n const core = CORE_META[key] as BlockMeta | undefined;\n if (core) return core;\n if (isCoreBlock(block)) {\n return { displayName: titleCase(block.name), subtitle: \"Core\", glyph: \"?\" };\n }\n const packageName = block.pieceName;\n const short = shortPieceName(packageName);\n const pieceLabel = pieceNames.get(packageName) ?? titleCase(short);\n const known = blockNames.get(key);\n if (!known) requestBlockNames(packageName);\n const logoUrl = pieceLogo(packageName);\n if (!logoUrl) logoMisses.add(packageName);\n return {\n // The name reads as a label until the piece's own list arrives.\n displayName: known ?? titleCase(block.name),\n subtitle: block.kind === \"trigger\" ? `${pieceLabel} · Trigger` : pieceLabel,\n logoUrl,\n // Shown until the catalog arrives, and whenever the logo fails to load.\n glyph: short.slice(0, 1).toUpperCase() || \"?\",\n };\n}\n\n// About what a step card's subtitle line holds at text-xs.\nexport const CARD_SUBTITLE_CHARS = 26;\n\n// A step card's subtitle: the action, led by its piece when that fits.\nexport function stepSubtitle(\n meta: BlockMeta,\n maxChars = CARD_SUBTITLE_CHARS,\n): string {\n if (meta.subtitle === \"Core\") return meta.displayName;\n const both = `${meta.subtitle} · ${meta.displayName}`;\n return both.length <= maxChars ? both : meta.displayName;\n}\n\nfunction titleCase(value: string): string {\n return value\n .replaceAll(/[-_]/g, \" \")\n .replace(/^\\w/, (char) => char.toUpperCase());\n}\n\n// Subscribes the caller to logo registrations and kicks off the catalog load.\n// Call once per component that renders many blocks, then use blockMeta().\nexport function usePieceLogos(): number {\n const source = usePieceSource();\n const revision = useSyncExternalStore(\n subscribePieceLogos,\n pieceLogoRevision,\n pieceLogoRevision,\n );\n // Every render: a retry due since the last one starts, and names this\n // render's blockMeta() calls asked for load. Both are no-ops otherwise.\n useEffect(() => {\n void ensurePieceLogos(source);\n if (source && namesPending.size > 0) loadPendingBlockNames(source);\n });\n return revision;\n}\n\nexport function useBlockMeta(block: BlockIdentity): BlockMeta {\n // Re-reads on every logo registration; blockMeta is a cheap lookup.\n usePieceLogos();\n return blockMeta(block);\n}\n","// Which piece version each block runs: the canvas badge, the header summary\n// and the step panel's update offer all read one resolution list.\nimport {\n compareVersions,\n type BlockRef,\n} from \"@powerhousedao/pieces-framework/block-type\";\nimport { createContext, useContext, type ReactNode } from \"react\";\nimport type { BlockResolutionView } from \"./forms.js\";\n\nexport type VersionTone = \"neutral\" | \"warn\" | \"fail\";\n\nexport interface VersionBadgeView {\n tone: VersionTone;\n label: string;\n title: string;\n}\n\n// The runtime's note, else what was configured against what runs.\nexport function resolutionText(resolution: BlockResolutionView): string {\n if (resolution.note) return resolution.note;\n if (!resolution.resolvedVersion)\n return `Nothing resolves ${resolution.pieceName} ${resolution.kind} \"${resolution.name}\"`;\n const from = resolution.source ? ` from ${resolution.source}` : \"\";\n return `Configured with v${resolution.pieceVersion}, runs v${resolution.resolvedVersion}${from}`;\n}\n\n// True when the block does not run the version it is configured with.\nexport function runsDifferentVersion(resolution: BlockResolutionView): boolean {\n switch (resolution.match) {\n case \"exact\":\n return false;\n case \"installed\":\n return resolution.resolvedVersion !== resolution.pieceVersion;\n default:\n return true;\n }\n}\n\nexport function versionBadge(\n resolution: BlockResolutionView | undefined,\n): VersionBadgeView | null {\n if (!resolution || !runsDifferentVersion(resolution)) return null;\n const title = resolutionText(resolution);\n if (resolution.match === \"missing\") {\n return { tone: \"fail\", label: \"Missing\", title };\n }\n return {\n tone: resolution.match === \"fallback\" ? \"warn\" : \"neutral\",\n label: `v${resolution.resolvedVersion}`,\n title,\n };\n}\n\n/** The newer version to offer, when a source has one above the pin. */\nexport function updateVersion(\n resolution: BlockResolutionView | undefined,\n): string | null {\n const { pieceVersion, latestVersion } = resolution ?? {};\n if (!pieceVersion || !latestVersion) return null;\n try {\n return compareVersions(latestVersion, pieceVersion) > 0\n ? latestVersion\n : null;\n } catch {\n return null;\n }\n}\n\nconst ResolutionsContext = createContext<readonly BlockResolutionView[]>([]);\nconst DraftBlocksContext = createContext<readonly BlockRef[]>([]);\n\nexport function BlockResolutionsProvider(props: {\n resolutions: readonly BlockResolutionView[];\n // Every block the draft holds, for the picker's version hints.\n blocks: readonly BlockRef[];\n children: ReactNode;\n}) {\n return (\n <DraftBlocksContext.Provider value={props.blocks}>\n <ResolutionsContext.Provider value={props.resolutions}>\n {props.children}\n </ResolutionsContext.Provider>\n </DraftBlocksContext.Provider>\n );\n}\n\nexport function useDraftBlocks(): readonly BlockRef[] {\n return useContext(DraftBlocksContext);\n}\n\n// Only an answer for the block, at the version, the draft holds now.\nexport function useResolution(\n id: string,\n block: BlockRef,\n): BlockResolutionView | undefined {\n const resolutions = useContext(ResolutionsContext);\n return resolutions.find(\n (entry) =>\n entry.stepId === id &&\n entry.pieceName === block.pieceName &&\n entry.pieceVersion === block.pieceVersion &&\n entry.kind === block.kind &&\n entry.name === block.name,\n );\n}\n\nconst SUMMARY_TONE: Record<\"neutral\" | \"warn\", string> = {\n neutral: \"text-muted-foreground hover:text-foreground\",\n warn: \"text-wf-warn\",\n};\n\nexport interface VersionSummaryView {\n text: string;\n // Amber only when a step runs another major or nothing at all.\n tone: \"neutral\" | \"warn\";\n title: string;\n firstStepId: string;\n}\n\nexport function versionSummary(\n resolutions: readonly BlockResolutionView[],\n): VersionSummaryView | null {\n const differing = resolutions.filter(runsDifferentVersion);\n if (differing.length === 0) return null;\n const missing = differing.filter((entry) => entry.match === \"missing\");\n const count = missing.length > 0 ? missing.length : differing.length;\n const noun = count === 1 ? \"step\" : \"steps\";\n const text =\n missing.length > 0\n ? `${count} ${noun} can't find ${count === 1 ? \"its\" : \"their\"} piece`\n : `${count} ${noun} ${count === 1 ? \"runs\" : \"run\"} a different piece version`;\n const warn = differing.some(\n (entry) => entry.match === \"fallback\" || entry.match === \"missing\",\n );\n return {\n text,\n tone: warn ? \"warn\" : \"neutral\",\n title: differing.map(resolutionText).join(\"\\n\"),\n firstStepId: (missing.length > 0 ? missing : differing)[0].stepId,\n };\n}\n\n// \"2 steps run a different piece version\"; selects the first on click.\nexport function VersionSummary(props: {\n resolutions: readonly BlockResolutionView[];\n onSelect: (id: string) => void;\n}) {\n const summary = versionSummary(props.resolutions);\n if (!summary) return null;\n return (\n <button\n type=\"button\"\n data-tone={summary.tone}\n className={`truncate text-xs underline-offset-2 hover:underline ${SUMMARY_TONE[summary.tone]}`}\n title={summary.title}\n onClick={() => props.onSelect(summary.firstStepId)}\n >\n {summary.text}\n </button>\n );\n}\n","// Where the block picker opens beside the button that opened it, kept on\n// screen: below when it fits, otherwise on the roomier side, shrunk to fit.\n\nexport interface PickerRect {\n left: number;\n right: number;\n top: number;\n bottom: number;\n}\n\nexport interface PickerSize {\n width: number;\n height: number;\n}\n\nexport interface PickerPlacement {\n left: number;\n top: number;\n width: number;\n height: number;\n // Opened above the button: a picker shorter than `height` keeps to it.\n above: boolean;\n}\n\nconst MARGIN = 8;\nconst GAP = 6;\n// Below this the list shows too little to be worth opening on that side.\nconst MIN_HEIGHT = 240;\n\nexport function pickerPlacement(\n anchor: PickerRect,\n size: PickerSize,\n viewport: PickerSize,\n): PickerPlacement {\n const width = Math.min(size.width, viewport.width - 2 * MARGIN);\n const below = viewport.height - anchor.bottom - GAP - MARGIN;\n const above = anchor.top - GAP - MARGIN;\n const downward = below >= Math.min(size.height, MIN_HEIGHT) || below >= above;\n const height = Math.max(\n Math.min(size.height, downward ? below : above),\n Math.min(size.height, MIN_HEIGHT),\n );\n const centre = (anchor.left + anchor.right) / 2;\n const left = Math.min(\n Math.max(centre - width / 2, MARGIN),\n viewport.width - width - MARGIN,\n );\n const top = downward\n ? Math.min(anchor.bottom + GAP, viewport.height - height - MARGIN)\n : Math.max(anchor.top - GAP - height, MARGIN);\n return { left, top: Math.max(top, MARGIN), width, height, above: !downward };\n}\n","// Hosts the block picker beside the button that opened it, outside the\n// canvas transform so zoom never scales it and placement sees the screen.\nimport { useLayoutEffect, useState, type RefObject } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { pickerPlacement, type PickerPlacement } from \"./picker-placement.js\";\n\nexport const PICKER_SIZE = { width: 640, height: 480 };\n\nexport function PickerPopover(props: {\n anchor: RefObject<HTMLElement | null>;\n onClose: () => void;\n children: (placement: PickerPlacement) => React.ReactNode;\n}) {\n const [placement, setPlacement] = useState<PickerPlacement | null>(null);\n const { anchor, onClose } = props;\n\n useLayoutEffect(() => {\n const place = () => {\n const rect = anchor.current?.getBoundingClientRect();\n if (!rect) return;\n setPlacement(\n pickerPlacement(rect, PICKER_SIZE, {\n width: window.innerWidth,\n height: window.innerHeight,\n }),\n );\n };\n place();\n // The canvas moving under it would leave it pointing at nothing.\n const onWheel = (event: WheelEvent) => {\n const target = event.target;\n const inside =\n target instanceof Element && target.closest(\"[data-selector-open]\");\n if (!inside) onClose();\n };\n window.addEventListener(\"resize\", onClose);\n window.addEventListener(\"wheel\", onWheel, { capture: true, passive: true });\n return () => {\n window.removeEventListener(\"resize\", onClose);\n window.removeEventListener(\"wheel\", onWheel, { capture: true });\n };\n }, [anchor, onClose]);\n\n const host =\n anchor.current?.closest(\".react-flow\")?.parentElement ?? document.body;\n if (!placement) return null;\n return createPortal(\n <div\n data-selector-open=\"true\"\n className=\"nodrag nopan nowheel fixed z-50 motion-safe:animate-[wf-picker-in_120ms_ease-out]\"\n style={\n placement.above\n ? {\n left: placement.left,\n bottom: window.innerHeight - placement.top - placement.height,\n transformOrigin: \"bottom center\",\n }\n : {\n left: placement.left,\n top: placement.top,\n transformOrigin: \"top center\",\n }\n }\n >\n {props.children(placement)}\n </div>,\n host,\n );\n}\n","// The blocks this browser picked last, per kind. Stored without a version,\n// so a pick from the list pins whatever the catalog offers now.\nimport type { BlockKind, BlockPick, BlockPreset } from \"./blocks.js\";\n\nconst STORAGE_KEY = \"ph-workflow-picker-recent:v1\";\nconst MAX_RECENT = 6;\n\ninterface StoredPick {\n label: string;\n description?: string;\n block: { pieceName: string; kind: BlockKind; name: string };\n}\n\n// Storage is another tab's or an older build's writing; every field is checked.\nfunction isStoredPick(value: unknown): value is StoredPick {\n const entry = value as Partial<StoredPick> | null;\n const block = entry?.block as Partial<StoredPick[\"block\"]> | undefined;\n return (\n typeof entry?.label === \"string\" &&\n typeof block?.pieceName === \"string\" &&\n typeof block.name === \"string\" &&\n (block.kind === \"action\" || block.kind === \"trigger\")\n );\n}\n\nfunction readAll(): StoredPick[] {\n try {\n const raw = window.localStorage.getItem(STORAGE_KEY);\n const parsed: unknown = raw ? JSON.parse(raw) : [];\n return Array.isArray(parsed) ? parsed.filter(isStoredPick) : [];\n } catch {\n return [];\n }\n}\n\nexport function recentPicks(kind: BlockKind): BlockPreset[] {\n return readAll()\n .filter((entry) => entry.block.kind === kind)\n .map((entry) => ({\n label: entry.label,\n description: entry.description ?? \"\",\n block: entry.block satisfies BlockPick,\n defaultConfig: {},\n }));\n}\n\nexport function rememberPick(preset: BlockPreset): void {\n const { pieceName, kind, name } = preset.block;\n const entry: StoredPick = {\n label: preset.label,\n description: preset.description,\n block: { pieceName, kind, name },\n };\n const same = (other: StoredPick) =>\n other.block.pieceName === pieceName &&\n other.block.kind === kind &&\n other.block.name === name;\n const all = readAll();\n const ofKind = all.filter((other) => other.block.kind === kind);\n const others = all.filter((other) => other.block.kind !== kind);\n const next = [entry, ...ofKind.filter((other) => !same(other))].slice(\n 0,\n MAX_RECENT,\n );\n try {\n window.localStorage.setItem(\n STORAGE_KEY,\n JSON.stringify([...next, ...others]),\n );\n } catch {\n // Storage off or full: the list is a convenience.\n }\n}\n","// A scrolling list that mounts only the rows in view. Rows have known heights,\n// so offsets are a running sum rather than a measurement.\nimport { useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\n\nconst OVERSCAN = 6;\n\nexport function rowOffsets(heights: readonly number[]): number[] {\n const offsets = [0];\n for (const height of heights) offsets.push(offsets.at(-1)! + height);\n return offsets;\n}\n\n// Rows [start, end) overlapping the window, plus the overscan either side.\nexport function visibleRange(\n offsets: readonly number[],\n scrollTop: number,\n height: number,\n overscan = OVERSCAN,\n): [number, number] {\n const count = offsets.length - 1;\n let start = 0;\n while (start < count && offsets[start + 1] <= scrollTop) start++;\n let end = start;\n while (end < count && offsets[end] < scrollTop + height) end++;\n return [Math.max(0, start - overscan), Math.min(count, end + overscan)];\n}\n\nexport function VirtualList<T>(props: {\n items: readonly T[];\n heightOf: (item: T) => number;\n keyOf: (item: T, index: number) => string;\n render: (item: T, index: number) => React.ReactNode;\n // Kept in view as it moves.\n activeIndex?: number;\n className?: string;\n label?: string;\n // The listbox the search box's aria-controls names.\n id?: string;\n // A new value is a new list, which starts from its top.\n resetKey?: string;\n}) {\n const ref = useRef<HTMLDivElement>(null);\n const [scrollTop, setScrollTop] = useState(0);\n const [height, setHeight] = useState(400);\n const offsets = useMemo(\n () => rowOffsets(props.items.map(props.heightOf)),\n [props.items, props.heightOf],\n );\n\n useLayoutEffect(() => {\n const element = ref.current;\n if (!element) return;\n const observer = new ResizeObserver(() => setHeight(element.clientHeight));\n observer.observe(element);\n setHeight(element.clientHeight);\n return () => observer.disconnect();\n }, []);\n\n // The scroll event syncs the state.\n useEffect(() => {\n if (ref.current) ref.current.scrollTop = 0;\n }, [props.resetKey]);\n\n useEffect(() => {\n const element = ref.current;\n const index = props.activeIndex;\n if (!element || index === undefined || index < 0) return;\n const top = offsets.at(index);\n const bottom = offsets.at(index + 1);\n if (top === undefined || bottom === undefined) return;\n if (top < element.scrollTop) element.scrollTop = top;\n else if (bottom > element.scrollTop + element.clientHeight) {\n element.scrollTop = bottom - element.clientHeight;\n }\n }, [props.activeIndex, offsets]);\n\n const [start, end] = visibleRange(offsets, scrollTop, height);\n return (\n <div\n ref={ref}\n id={props.id}\n role=\"listbox\"\n aria-label={props.label}\n className={`min-h-0 overflow-y-auto ${props.className ?? \"\"}`}\n onScroll={(event) => setScrollTop(event.currentTarget.scrollTop)}\n >\n <div\n role=\"presentation\"\n style={{ height: offsets.at(-1), position: \"relative\" }}\n >\n {props.items.slice(start, end).map((item, i) => {\n const index = start + i;\n return (\n <div\n key={props.keyOf(item, index)}\n role=\"presentation\"\n style={{\n position: \"absolute\",\n top: offsets[index],\n left: 0,\n right: 0,\n height: offsets[index + 1] - offsets[index],\n }}\n >\n {props.render(item, index)}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n","// Two-pane block picker: sources on the left, the selected one's blocks on the\n// right, and a grouped search list. Shaped after the Activepieces selector.\nimport {\n useEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type RefObject,\n useId,\n useLayoutEffect,\n} from \"react\";\nimport { Icon, type IconName } from \"../../shared/icons.js\";\nimport { blockKey } from \"@powerhousedao/pieces-framework/block-type\";\nimport {\n CATALOG_MAX_ATTEMPTS,\n CATALOG_RETRY_MS,\n registerPieceLogos,\n useBlockMeta,\n} from \"./block-meta.js\";\nimport {\n APPROVAL_BLOCK,\n ASSERT_BLOCK,\n BRANCH_BLOCK,\n CALL_FLOW_BLOCK,\n CALLABLE_FLOW_TRIGGER,\n LOOP_BLOCK,\n ROUTER_BLOCK,\n DELAY_BLOCK,\n isCoreBlock,\n MANUAL_TRIGGER,\n pinBlock,\n REACTOR_PIECE,\n RETURN_RESPONSE_BLOCK,\n SCHEDULE_TRIGGER,\n stepBlock,\n STOP_BLOCK,\n WAIT_FOR_WEBHOOK_BLOCK,\n WEBHOOK_TRIGGER,\n type BlockIdentity,\n type BlockPreset,\n type BlockRef,\n type PickedPreset,\n} from \"./blocks.js\";\nimport { useBlockFormPrefetch } from \"./design-time.js\";\nimport type { StepModel } from \"./model.js\";\nimport { useDraftBlocks } from \"./version-badge.js\";\nimport { PICKER_SIZE } from \"./PickerPopover.js\";\nimport { recentPicks, rememberPick } from \"./picker-recent.js\";\nimport { VirtualList } from \"./VirtualList.js\";\nimport {\n blockUnavailable,\n type PieceActionUi,\n type PieceSearchFilterUi,\n type PieceSearchMatchUi,\n type PieceSearchResultUi,\n type PieceSourceKind,\n type PieceSummaryUi,\n type PieceTriggerUi,\n usePieceSource,\n} from \"./piece-source.js\";\n\nexport type PieceMode = \"actions\" | \"triggers\";\n\n// Logo size for the picker's rows: presets, pieces, search hits and attach.\nconst ROW_LOGO = 24;\n\n// Built-in blocks have no artwork of their own; each gets a coloured tile.\nconst CORE_TILE: Record<string, { icon: IconName; color: string }> = {\n [blockKey(MANUAL_TRIGGER)]: { icon: \"play\", color: \"#2563eb\" },\n [blockKey(SCHEDULE_TRIGGER)]: { icon: \"clock\", color: \"#7c3aed\" },\n [blockKey(WEBHOOK_TRIGGER)]: { icon: \"bolt\", color: \"#0891b2\" },\n [blockKey(BRANCH_BLOCK)]: { icon: \"branch\", color: \"#d97706\" },\n [blockKey(ROUTER_BLOCK)]: { icon: \"route\", color: \"#ea580c\" },\n [blockKey(LOOP_BLOCK)]: { icon: \"loop\", color: \"#7c3aed\" },\n [blockKey(ASSERT_BLOCK)]: { icon: \"alert\", color: \"#dc2626\" },\n [blockKey(DELAY_BLOCK)]: { icon: \"clock\", color: \"#0d9488\" },\n [blockKey(APPROVAL_BLOCK)]: { icon: \"check\", color: \"#16a34a\" },\n [blockKey(STOP_BLOCK)]: { icon: \"stop\", color: \"#475569\" },\n [blockKey(WAIT_FOR_WEBHOOK_BLOCK)]: { icon: \"link\", color: \"#0891b2\" },\n [blockKey(CALLABLE_FLOW_TRIGGER)]: { icon: \"subflow\", color: \"#4f46e5\" },\n [blockKey(CALL_FLOW_BLOCK)]: { icon: \"subflow\", color: \"#4f46e5\" },\n [blockKey(RETURN_RESPONSE_BLOCK)]: { icon: \"reply\", color: \"#4f46e5\" },\n};\n\nfunction CoreTile(props: {\n tile: { icon: IconName; color: string };\n size: number;\n bare?: boolean;\n}) {\n const tile = props.tile;\n const glyph = Math.round(props.size * (props.bare ? 0.9 : 0.55));\n // Bare: the caller's badge is the tile, so only the icon is drawn.\n if (props.bare) {\n return (\n <span\n className=\"flex shrink-0 items-center justify-center\"\n style={{ width: props.size, height: props.size, color: tile.color }}\n >\n <Icon name={tile.icon} size={glyph} />\n </span>\n );\n }\n return (\n <span\n className=\"flex shrink-0 items-center justify-center rounded-[22%] text-white\"\n style={{\n width: props.size,\n height: props.size,\n backgroundColor: tile.color,\n }}\n >\n <Icon name={tile.icon} size={glyph} />\n </span>\n );\n}\n\nexport function BlockLogo(props: {\n block: BlockIdentity;\n size?: number;\n // Set where the caller already draws a light badge behind the logo.\n bare?: boolean;\n}) {\n const meta = useBlockMeta(props.block);\n const tile = CORE_TILE[blockKey(props.block)] as\n | { icon: IconName; color: string }\n | undefined;\n if (tile) {\n return <CoreTile tile={tile} size={props.size ?? 36} bare={props.bare} />;\n }\n return (\n <LogoFrame\n src={meta.logoUrl}\n alt={meta.displayName}\n size={props.size ?? 36}\n glyph={meta.glyph}\n bare={props.bare}\n />\n );\n}\n\nfunction GlyphBadge(props: { glyph?: string; size: number }) {\n return (\n <div\n className=\"flex shrink-0 items-center justify-center rounded-sm border border-solid border-foreground/10 bg-muted/50 text-muted-foreground\"\n style={{\n width: props.size,\n height: props.size,\n fontSize: props.size / 2,\n }}\n >\n {props.glyph ?? \"?\"}\n </div>\n );\n}\n\n// Falls back to the glyph badge when the piece metadata carries no logo, or\n// when the CDN image fails to load (Activepieces retires logo files).\nfunction LogoFrame(props: {\n src?: string;\n alt: string;\n size: number;\n glyph?: string;\n bare?: boolean;\n}) {\n const [broken, setBroken] = useState(false);\n useEffect(() => {\n // eslint-disable-next-line react-hooks-extra/set-state-in-effect -- a new src gets a fresh chance to load\n setBroken(false);\n }, [props.src]);\n if (!props.src || broken) {\n return <GlyphBadge glyph={props.glyph} size={props.size} />;\n }\n // No frame and no padding around a logo: a piece's artwork is its own tile,\n // with its own corner radius and its own margin.\n\n // Framing it drew our border through corners that were already rounded —\n // and no single radius matches every piece, so the frame is left to the\n // glyph badge, which is the only case where we draw the tile ourselves.\n return (\n // Piece logos are drawn for light backgrounds, so dark mode backs them\n // with a small white tile rather than losing black artwork to the page.\n <div\n className={`flex shrink-0 items-center justify-center ${\n props.bare\n ? \"\"\n : \"dark:rounded-[22%] dark:bg-white dark:p-[var(--logo-pad)]\"\n }`}\n // Pixels, not %: percentage padding follows the container's width.\n style={\n {\n width: props.size,\n height: props.size,\n \"--logo-pad\": `${Math.round(props.size * 0.12)}px`,\n } as CSSProperties\n }\n >\n <img\n src={props.src}\n alt={props.alt}\n // drop-shadow, not a border or a ring: it follows the image's alpha,\n // so it traces the artwork's own silhouette — rounded corners and all\n // — and gives a white-on-transparent logo an edge on a white row.\n className=\"h-full w-full object-contain drop-shadow-sm\"\n onError={() => setBroken(true)}\n />\n </div>\n );\n}\n\nfunction Row(props: {\n logo: React.ReactNode;\n label: React.ReactNode;\n description: React.ReactNode;\n // Full text for truncated labels.\n title?: string;\n onClick: () => void;\n // Warms what a pick will need, while the row is hovered or focused.\n onHover?: () => void;\n disabled?: boolean;\n // The keyboard's row: tinted and marked.\n active?: boolean;\n // The piece the other pane shows, while the keyboard is elsewhere.\n selected?: boolean;\n // Two lines of description, for blocks; the list sizes the row.\n tall?: boolean;\n // Where it sits in its listbox; only the rows in view are mounted.\n option?: OptionPlace;\n // The piece version a pick pins to; shown on hover unless `versionNote`\n // says why it matters here.\n version?: string;\n versionNote?: string;\n}) {\n // An option, not a button: focus stays in the search box, which drives the\n // keyboard and points assistive tech at this row.\n return (\n <div\n {...optionAttributes(props.option)}\n role=\"option\"\n aria-selected={(props.active ?? false) || (props.selected ?? false)}\n aria-disabled={props.disabled}\n className={`group mx-1.5 my-px flex h-[calc(100%-2px)] cursor-pointer items-center gap-2.5 rounded-md px-2 text-left ${rowTone(\n props.active,\n props.selected,\n )} ${props.disabled ? \"cursor-not-allowed opacity-50\" : \"\"}`}\n title={props.title}\n onClick={props.disabled ? undefined : props.onClick}\n onMouseDown={(event) => event.preventDefault()}\n onMouseEnter={props.onHover}\n >\n {/* Decorative: the label names the row. */}\n <span aria-hidden=\"true\" className=\"contents\">\n {props.logo}\n </span>\n <span className=\"min-w-0\">\n <span className=\"block truncate text-[13px] font-medium leading-[18px] text-foreground\">\n {props.label}\n </span>\n <span\n // line-clamp sets its own display; `block` would undo it.\n className={`text-xs leading-4 text-muted-foreground ${\n props.tall ? \"line-clamp-2\" : \"block truncate\"\n }`}\n >\n {props.description}\n </span>\n </span>\n {props.version ? (\n <span\n className={`ml-auto shrink-0 pl-2 text-[11px] tabular-nums text-muted-foreground ${\n props.versionNote\n ? \"\"\n : props.active\n ? \"\"\n : \"hidden group-hover:inline\"\n }`}\n title={props.versionNote ?? `Pinned to version ${props.version}`}\n >\n v{props.version}\n </span>\n ) : null}\n </div>\n );\n}\n\n// The keyboard's row is tinted with the accent; the piece open beside the\n// list sits raised on the rail, joined to the pane that shows it.\nfunction rowTone(active?: boolean, selected?: boolean): string {\n if (active) return \"bg-wf-run/10 ring-1 ring-inset ring-wf-run/25\";\n if (selected) return \"bg-card shadow-sm ring-1 ring-foreground/10\";\n return \"hover:bg-foreground/[0.05]\";\n}\n\n// A row's id and position, named by the search box's aria-activedescendant.\ninterface OptionPlace {\n list: string;\n index: number;\n size: number;\n}\n\nexport function optionId(list: string, index: number): string {\n return `${list}-${index}`;\n}\n\nfunction optionAttributes(place: OptionPlace | undefined) {\n return place\n ? {\n id: optionId(place.list, place.index),\n \"aria-posinset\": place.index + 1,\n \"aria-setsize\": place.size,\n }\n : {};\n}\n\n// The core piece is the runtime's own, so its rows carry no version.\nfunction shownVersion(\n pieceName: string,\n version: string | undefined,\n): string | undefined {\n return isCoreBlock({ pieceName }) ? undefined : version;\n}\n\ntype VersionNote = (\n piece: string | undefined,\n version: string | undefined,\n) => string | undefined;\n\n// Why a row's version is worth showing: a local build shadowing the published\n// piece, or other steps of the workflow on another version of it.\nfunction useVersionNote(\n catalog: readonly PieceSummaryUi[] | undefined,\n): VersionNote {\n const draft = useDraftBlocks();\n return (piece, version) => {\n if (!piece || !version) return undefined;\n const others = [\n ...new Set(\n draft\n .filter(\n (block) =>\n block.pieceName === piece && block.pieceVersion !== version,\n )\n .map((block) => `v${block.pieceVersion}`),\n ),\n ];\n if (others.length > 0) {\n return `Other steps of this workflow use ${others.join(\", \")}`;\n }\n // The reactor piece ships with the runtime, so its copy is the one meant.\n if (piece === REACTOR_PIECE) return undefined;\n const published = catalog?.find(\n (entry) => entry.name === piece,\n )?.publishedVersion;\n return published && published !== version\n ? `A local build; v${published} is published`\n : undefined;\n };\n}\n\n// null while loading.\ninterface CatalogState {\n pieces: PieceSummaryUi[];\n error?: string;\n}\n\n// Activepieces category ids → chip labels; AI variants share one chip.\nconst CATEGORY_LABELS: Record<string, string> = {\n ARTIFICIAL_INTELLIGENCE: \"AI\",\n UNIVERSAL_AI: \"AI\",\n PRODUCTIVITY: \"Productivity\",\n MARKETING: \"Marketing\",\n COMMUNICATION: \"Communication\",\n SALES_AND_CRM: \"Sales & CRM\",\n DEVELOPER_TOOLS: \"Developer tools\",\n CONTENT_AND_FILES: \"Content & files\",\n BUSINESS_INTELLIGENCE: \"Business intelligence\",\n CORE: \"Utilities\",\n FLOW_CONTROL: \"Utilities\",\n COMMERCE: \"Commerce\",\n FORMS_AND_SURVEYS: \"Forms & surveys\",\n ACCOUNTING: \"Accounting\",\n CUSTOMER_SUPPORT: \"Customer support\",\n PAYMENT_PROCESSING: \"Payments\",\n HUMAN_RESOURCES: \"HR\",\n};\n\nconst AI_CHIP = \"AI\";\n\nfunction categoryLabel(id: string): string {\n return (\n CATEGORY_LABELS[id] ??\n id\n .toLowerCase()\n .replaceAll(\"_\", \" \")\n .replace(/^\\w/, (char) => char.toUpperCase())\n );\n}\n\nexport function chipsOf(piece: { categories: string[] }): Set<string> {\n return new Set(piece.categories.map(categoryLabel));\n}\n\n// The category ids a chip stands for, among those the pieces carry.\nexport function categoriesOfChip(\n chip: string,\n pieces: { categories: string[] }[],\n): string[] {\n const ids = new Set(pieces.flatMap((piece) => piece.categories));\n return [...ids].filter((id) => categoryLabel(id) === chip);\n}\n\n// Chip order: AI first, then by piece count.\nexport function orderChips(pieces: { categories: string[] }[]): string[] {\n const counts = new Map<string, number>();\n for (const piece of pieces) {\n for (const chip of chipsOf(piece)) {\n counts.set(chip, (counts.get(chip) ?? 0) + 1);\n }\n }\n const rest = [...counts.entries()]\n .filter(([chip]) => chip !== AI_CHIP)\n .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))\n .map(([chip]) => chip);\n return [...(counts.has(AI_CHIP) ? [AI_CHIP] : []), ...rest];\n}\n\nexport type SourceTab = \"all\" | \"core\" | \"powerhouse\" | \"activepieces\";\n\nconst TAB_LABELS: Record<SourceTab, string> = {\n all: \"All\",\n core: \"Core\",\n powerhouse: \"Powerhouse\",\n activepieces: \"Integrations\",\n};\n\n// Pieces each tab lists; Core lists the engine's presets only.\nconst TAB_SOURCES: Record<SourceTab, readonly PieceSourceKind[] | undefined> = {\n all: undefined,\n core: [],\n powerhouse: [\"local\", \"registry\"],\n activepieces: [\"activepieces\"],\n};\n\nexport function inTab(tab: SourceTab, piece: { source?: PieceSourceKind }) {\n const sources = TAB_SOURCES[tab];\n return (\n sources === undefined || sources.includes(piece.source ?? \"activepieces\")\n );\n}\n\n// Accents dropped, as the runtime's search drops them.\nfunction folded(text: string): string {\n return text.normalize(\"NFKD\").replace(/\\p{M}/gu, \"\").toLowerCase();\n}\n\nexport function queryTokens(query: string): string[] {\n return folded(query)\n .split(/[^\\p{L}\\p{N}]+/u)\n .filter(Boolean);\n}\n\n// Every token somewhere in the text, in any order.\nexport function matchesQuery(text: string, tokens: string[]): boolean {\n const lowered = folded(text);\n return tokens.every((token) => lowered.includes(token));\n}\n\nfunction escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n// Bolds the words the query's tokens start.\nfunction Highlight(props: { text: string; tokens: string[] }) {\n if (props.tokens.length === 0) return <>{props.text}</>;\n const pattern = new RegExp(\n `(?<![\\\\p{L}\\\\p{N}])(${props.tokens.map(escapeRegExp).join(\"|\")})`,\n \"giu\",\n );\n const parts = props.text.split(pattern);\n return (\n <>\n {parts.map((part, i) =>\n i % 2 === 1 ? (\n <mark key={i} className=\"bg-transparent font-semibold text-inherit\">\n {part}\n </mark>\n ) : (\n part\n ),\n )}\n </>\n );\n}\n\nconst SEARCH_MIN_CHARS = 2;\nconst SEARCH_DEBOUNCE_MS = 250;\nconst INDEXING_RETRY_MS = 2000;\n\ntype SearchState =\n | { kind: \"idle\" }\n | { kind: \"loading\" }\n // Stale: answered for an earlier query or filter, while the current one runs.\n | { kind: \"done\"; result: PieceSearchResultUi; stale: boolean }\n | { kind: \"error\"; message: string };\n\ntype SearchAnswer =\n | { kind: \"idle\" }\n | { kind: \"done\"; key: string; result: PieceSearchResultUi }\n | { kind: \"error\"; key: string; message: string };\n\n// Debounced catalog-wide search; keeps polling while the runtime indexes.\nfunction usePieceSearch(\n query: string,\n filter: PieceSearchFilterUi | null,\n): SearchState {\n const [state, setState] = useState<SearchAnswer>({ kind: \"idle\" });\n const [attempt, setAttempt] = useState(0);\n const trimmed = query.trim();\n const search = usePieceSource()?.searchPieces;\n const active =\n filter !== null &&\n search !== undefined &&\n trimmed.length >= SEARCH_MIN_CHARS;\n // A key, so a filter rebuilt with the same fields does not search again.\n const filterKey = JSON.stringify(filter);\n const key = `${trimmed}\\n${filterKey}`;\n\n useEffect(() => {\n if (!active) {\n // eslint-disable-next-line react-hooks-extra/set-state-in-effect -- drops a finished search when the query goes inactive\n setState({ kind: \"idle\" });\n return;\n }\n let alive = true;\n let retry: ReturnType<typeof setTimeout> | undefined;\n const timer = setTimeout(() => {\n search(trimmed, JSON.parse(filterKey) as PieceSearchFilterUi).then(\n (result) => {\n if (!alive) return;\n setState({ kind: \"done\", key, result });\n if (result.status === \"indexing\") {\n retry = setTimeout(\n () => setAttempt((value) => value + 1),\n INDEXING_RETRY_MS,\n );\n }\n },\n (error: unknown) => {\n if (alive) {\n setState({\n kind: \"error\",\n key,\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n );\n }, SEARCH_DEBOUNCE_MS);\n return () => {\n alive = false;\n clearTimeout(timer);\n if (retry) clearTimeout(retry);\n };\n }, [active, trimmed, filterKey, key, attempt, search]);\n\n if (!active) return { kind: \"idle\" };\n // Loading through the debounce, so the browse list does not flash first.\n if (state.kind === \"idle\") return { kind: \"loading\" };\n if (state.kind === \"error\") {\n return state.key === key\n ? { kind: \"error\", message: state.message }\n : { kind: \"loading\" };\n }\n // The last answer stays on screen while the next one runs, marked stale.\n return { kind: \"done\", result: state.result, stale: state.key !== key };\n}\n\n// Arrow keys move focus along a row of buttons, wrapping at the ends.\nfunction rovingFocus(event: React.KeyboardEvent<HTMLElement>): void {\n const delta =\n event.key === \"ArrowRight\" ? 1 : event.key === \"ArrowLeft\" ? -1 : 0;\n if (delta === 0) return;\n event.preventDefault();\n const buttons = [\n ...event.currentTarget.querySelectorAll<HTMLButtonElement>(\"button\"),\n ];\n const at = buttons.indexOf(document.activeElement as HTMLButtonElement);\n buttons.at((at + delta) % buttons.length)?.focus();\n}\n\nfunction Chip(props: {\n label: string;\n active: boolean;\n // The one chip Tab lands on.\n tabStop: boolean;\n onClick: (fromKeyboard: boolean) => void;\n}) {\n return (\n <button\n type=\"button\"\n aria-pressed={props.active}\n tabIndex={props.tabStop ? 0 : -1}\n className={`shrink-0 rounded-full border px-2.5 py-0.5 text-[11px] font-medium focus-visible:outline-2 focus-visible:outline-wf-run ${\n props.active\n ? \"border-wf-run/40 bg-wf-run/10 text-wf-run\"\n : \"border-foreground/10 text-muted-foreground hover:border-foreground/25 hover:text-foreground\"\n }`}\n // A keyboard click reports no pointer clicks.\n onClick={(event) => props.onClick(event.detail === 0)}\n >\n {props.label}\n </button>\n );\n}\n\n// A scrolling row of chips that fades at an edge with more beyond it.\nfunction ChipBar(props: { children: React.ReactNode }) {\n const ref = useRef<HTMLDivElement>(null);\n const [more, setMore] = useState({ left: false, right: false });\n const measure = () => {\n const element = ref.current;\n if (!element) return;\n const left = element.scrollLeft > 1;\n const right =\n element.scrollLeft + element.clientWidth < element.scrollWidth - 1;\n setMore((previous) =>\n previous.left === left && previous.right === right\n ? previous\n : { left, right },\n );\n };\n useLayoutEffect(() => {\n const element = ref.current;\n if (!element) return;\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, []);\n const fade = (side: \"left\" | \"right\") => (\n <span\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-y-0 w-14\"\n style={{\n [side]: 0,\n background: `linear-gradient(to ${side === \"left\" ? \"right\" : \"left\"}, var(--card), transparent)`,\n }}\n />\n );\n return (\n <div className=\"relative shrink-0 border-b border-foreground/10\">\n <div\n ref={ref}\n role=\"toolbar\"\n aria-label=\"Categories\"\n className=\"flex gap-1.5 overflow-x-auto whitespace-nowrap px-3 py-2 [scrollbar-width:none]\"\n onKeyDown={rovingFocus}\n onScroll={measure}\n >\n {props.children}\n </div>\n {more.left ? fade(\"left\") : null}\n {more.right ? fade(\"right\") : null}\n </div>\n );\n}\n\nfunction Tabs(props: {\n tabs: SourceTab[];\n active: SourceTab;\n onSelect: (tab: SourceTab, fromKeyboard: boolean) => void;\n}) {\n return (\n <div\n role=\"tablist\"\n aria-label=\"Piece sources\"\n className=\"inline-flex gap-0.5 rounded-md bg-foreground/[0.05] p-0.5\"\n onKeyDown={(event) => {\n rovingFocus(event);\n // Following focus, as a tab list does.\n const focused = document.activeElement as HTMLElement | null;\n const tab = focused?.dataset.tab as SourceTab | undefined;\n if (tab && tab !== props.active) props.onSelect(tab, true);\n }}\n >\n {props.tabs.map((tab) => (\n <button\n key={tab}\n type=\"button\"\n role=\"tab\"\n data-tab={tab}\n aria-selected={props.active === tab}\n tabIndex={props.active === tab ? 0 : -1}\n className={`rounded px-2.5 py-1 text-xs font-medium focus-visible:outline-2 focus-visible:outline-wf-run ${\n props.active === tab\n ? \"bg-card text-foreground shadow-sm\"\n : \"text-muted-foreground hover:text-foreground\"\n }`}\n onClick={(event) => props.onSelect(tab, event.detail === 0)}\n >\n {TAB_LABELS[tab]}\n </button>\n ))}\n </div>\n );\n}\n\nfunction Status(props: { children: React.ReactNode; error?: boolean }) {\n return (\n <div\n role=\"status\"\n className={`px-4 py-2.5 text-xs ${props.error ? \"text-wf-fail\" : \"text-muted-foreground\"}`}\n >\n {props.children}\n </div>\n );\n}\n\n// One pickable row, in either pane or the search list.\ninterface Entry {\n key: string;\n logo: React.ReactNode;\n label: string;\n description: string;\n // Why it cannot be picked; listed anyway, so the reason shows.\n unavailable?: string;\n version?: string;\n versionNote?: string;\n pick: () => void;\n // Warms what a pick needs.\n warm?: () => void;\n}\n\ntype ListId = \"recent\" | \"attach\" | \"core\" | \"powerhouse\";\n\n// A left-pane item: one of our own lists, or a catalog piece.\ntype Source =\n | {\n kind: \"list\";\n id: ListId;\n title: string;\n subtitle: string;\n // Drawn small in the list and large over its blocks.\n logo: (size: number) => React.ReactNode;\n entries: Entry[];\n }\n | { kind: \"piece\"; id: string; piece: PieceSummaryUi };\n\ntype SearchRow =\n | { type: \"list\"; source: Extract<Source, { kind: \"list\" }> }\n | { type: \"piece\"; match: PieceSearchMatchUi }\n | { type: \"entry\"; entry: Entry }\n | { type: \"more\"; pieceName: string; hidden: number };\n\nconst ROW_HEIGHT = 46;\nconst BLOCK_HEIGHT = 60;\n// The open piece's logo, over its blocks.\nconst HEADER_LOGO = 36;\nconst HEADER_HEIGHT = 38;\nconst MORE_HEIGHT = 28;\n// Blocks a search group shows before \"more\"; all of them for one or two groups.\nconst GROUP_BLOCKS = 4;\n// Hovering a piece previews it once the pointer settles.\nconst HOVER_PREVIEW_MS = 120;\n\nconst searchRowHeight = (row: SearchRow) =>\n row.type === \"entry\"\n ? BLOCK_HEIGHT\n : row.type === \"more\"\n ? MORE_HEIGHT\n : HEADER_HEIGHT;\nconst sourceHeight = () => ROW_HEIGHT;\nconst entryHeight = () => BLOCK_HEIGHT;\n\nfunction listTile(icon: IconName, color: string) {\n return (size: number) => <CoreTile tile={{ icon, color }} size={size} />;\n}\n\nfunction EntryRow(props: {\n entry: Entry;\n tokens: string[];\n active: boolean;\n option: OptionPlace;\n indent?: boolean;\n onActivate: () => void;\n}) {\n const { entry } = props;\n return (\n <Row\n logo={\n props.indent ? (\n // An empty slot keeps the block indented under its piece.\n <span className=\"shrink-0\" style={{ width: ROW_LOGO }} />\n ) : (\n entry.logo\n )\n }\n label={<Highlight text={entry.label} tokens={props.tokens} />}\n title={entry.description || entry.label}\n description={\n entry.unavailable ?? (\n <Highlight text={entry.description} tokens={props.tokens} />\n )\n }\n disabled={entry.unavailable !== undefined}\n active={props.active}\n tall\n option={props.option}\n version={entry.version}\n versionNote={entry.versionNote}\n onHover={() => {\n props.onActivate();\n if (entry.unavailable === undefined) entry.warm?.();\n }}\n onClick={entry.pick}\n />\n );\n}\n\nfunction SourceRow(props: {\n source: Source;\n tokens: string[];\n mode: PieceMode;\n active: boolean;\n selected: boolean;\n option: OptionPlace;\n onActivate: () => void;\n onOpen: () => void;\n}) {\n const { source } = props;\n if (source.kind === \"list\") {\n return (\n <Row\n logo={source.logo(ROW_LOGO)}\n label={source.title}\n description={source.subtitle}\n active={props.active}\n selected={props.selected}\n option={props.option}\n onHover={props.onActivate}\n onClick={props.onOpen}\n />\n );\n }\n const { piece } = source;\n const count =\n props.mode === \"triggers\" ? piece.triggerCount : piece.actionCount;\n const noun = props.mode === \"triggers\" ? \"trigger\" : \"action\";\n return (\n <Row\n logo={\n <LogoFrame\n src={piece.logoUrl}\n alt={piece.displayName}\n size={ROW_LOGO}\n />\n }\n label={\n <>\n <Highlight text={piece.displayName} tokens={props.tokens} />\n {piece.deprecated ? \" (deprecated)\" : \"\"}\n </>\n }\n title={piece.description || piece.displayName}\n description={\n piece.unsupported ?? `${count} ${noun}${count === 1 ? \"\" : \"s\"}`\n }\n active={props.active}\n selected={props.selected}\n option={props.option}\n onHover={props.onActivate}\n onClick={props.onOpen}\n />\n );\n}\n\n// The actions or triggers of one piece, once loaded.\nfunction usePieceEntries(\n piece: PieceSummaryUi | undefined,\n mode: PieceMode,\n): {\n entries: (PieceActionUi & Partial<PieceTriggerUi>)[] | null;\n error: string | null;\n} {\n const pieceSource = usePieceSource();\n const [state, setState] = useState<{\n name: string;\n entries: (PieceActionUi & Partial<PieceTriggerUi>)[] | null;\n error: string | null;\n } | null>(null);\n const name = piece?.name;\n\n useEffect(() => {\n if (!name || !pieceSource) return;\n let cancelled = false;\n const load =\n mode === \"triggers\"\n ? pieceSource.loadTriggers(name)\n : pieceSource.loadActions(name);\n load.then(\n (entries) => {\n if (!cancelled) setState({ name, entries, error: null });\n },\n (error: unknown) => {\n if (!cancelled) {\n setState({\n name,\n entries: null,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n },\n );\n return () => {\n cancelled = true;\n };\n }, [name, mode, pieceSource]);\n\n return state && state.name === name\n ? { entries: state.entries, error: state.error }\n : { entries: null, error: null };\n}\n\nfunction EntriesPane(props: {\n source: Source | undefined;\n mode: PieceMode;\n pieceEntries: Entry[] | null;\n pieceError: string | null;\n tokens: string[];\n activeIndex: number;\n listId: string;\n // Off where the source is the whole picker, as a tab already names it.\n showHeader: boolean;\n onActivate: (index: number) => void;\n}) {\n const { source } = props;\n const entries = source?.kind === \"list\" ? source.entries : props.pieceEntries;\n const kind = props.mode === \"triggers\" ? \"trigger\" : \"action\";\n const title =\n source?.kind === \"list\" ? source.title : source?.piece.displayName;\n const about =\n source?.kind === \"list\" ? source.subtitle : source?.piece.description;\n return (\n <div className=\"flex min-h-0 min-w-0 flex-1 flex-col\">\n {source && props.showHeader ? (\n <div className=\"flex shrink-0 items-start gap-3 border-b border-foreground/10 px-4 py-3\">\n <span aria-hidden=\"true\" className=\"contents\">\n {source.kind === \"list\" ? (\n source.logo(HEADER_LOGO)\n ) : (\n <LogoFrame src={source.piece.logoUrl} alt=\"\" size={HEADER_LOGO} />\n )}\n </span>\n <div className=\"min-w-0\">\n <div className=\"truncate text-sm font-semibold leading-5 text-foreground\">\n {title}\n </div>\n {about ? (\n <div\n className=\"line-clamp-2 text-xs leading-4 text-muted-foreground\"\n title={about}\n >\n {about}\n </div>\n ) : null}\n </div>\n </div>\n ) : null}\n {!source ? (\n <Status>Pick a piece to see its {kind}s</Status>\n ) : props.pieceError ? (\n <Status error>{props.pieceError}</Status>\n ) : entries === null ? (\n <Status>Loading…</Status>\n ) : entries.length === 0 ? (\n <Status>No {kind}s</Status>\n ) : (\n <VirtualList\n id={props.listId}\n resetKey={source.id}\n label={`${title ?? \"\"} ${kind}s`}\n className=\"flex-1 py-1\"\n items={entries}\n heightOf={entryHeight}\n keyOf={(entry) => entry.key}\n activeIndex={props.activeIndex}\n render={(entry, index) => (\n <EntryRow\n entry={entry}\n tokens={props.tokens}\n active={index === props.activeIndex}\n option={{ list: props.listId, index, size: entries.length }}\n onActivate={() => props.onActivate(index)}\n />\n )}\n />\n )}\n </div>\n );\n}\n\nfunction SearchList(props: {\n rows: SearchRow[];\n tokens: string[];\n activeIndex: number;\n onActivate: (index: number) => void;\n onOpenPiece: (pieceName: string) => void;\n onOpenList: (id: ListId) => void;\n onExpand: (pieceName: string) => void;\n status: React.ReactNode;\n // \"action\" or \"trigger\", for the heading's link.\n kind: string;\n listId: string;\n resetKey: string;\n stale: boolean;\n}) {\n const size = props.rows.length;\n return (\n <div className=\"flex min-h-0 flex-1 flex-col\">\n {props.status}\n <VirtualList\n id={props.listId}\n label=\"Search results\"\n resetKey={props.resetKey}\n className={`flex-1 py-1 ${props.stale ? \"opacity-60\" : \"\"}`}\n items={props.rows}\n heightOf={searchRowHeight}\n keyOf={(row, index) =>\n row.type === \"entry\"\n ? `e:${row.entry.key}`\n : row.type === \"piece\"\n ? `p:${row.match.pieceName}`\n : row.type === \"list\"\n ? `l:${row.source.id}`\n : `m:${row.pieceName}:${index}`\n }\n activeIndex={props.activeIndex}\n render={(row, index) => {\n const active = index === props.activeIndex;\n const activate = () => props.onActivate(index);\n const option = { list: props.listId, index, size };\n if (row.type === \"entry\") {\n return (\n <EntryRow\n entry={row.entry}\n tokens={props.tokens}\n active={active}\n option={option}\n indent\n onActivate={activate}\n />\n );\n }\n if (row.type === \"more\") {\n return (\n <div\n {...optionAttributes(option)}\n role=\"option\"\n aria-selected={active}\n className={`mx-1.5 my-px flex h-[calc(100%-2px)] cursor-pointer items-center rounded-md pl-[42px] text-xs text-muted-foreground hover:text-foreground ${rowTone(active)}`}\n onMouseDown={(event) => event.preventDefault()}\n onMouseEnter={activate}\n onClick={() => props.onExpand(row.pieceName)}\n >\n {row.hidden} more…\n </div>\n );\n }\n const header =\n row.type === \"piece\"\n ? {\n logo: (\n <LogoFrame\n src={row.match.logoUrl}\n alt={row.match.displayName}\n size={20}\n />\n ),\n label: row.match.displayName,\n note: row.match.deprecated\n ? \"Deprecated\"\n : (row.match.unsupported ?? undefined),\n kind: props.kind,\n open: () => props.onOpenPiece(row.match.pieceName),\n }\n : {\n logo: row.source.logo(20),\n label: row.source.title,\n note: undefined,\n kind: props.kind,\n open: () => props.onOpenList(row.source.id),\n };\n return (\n <div\n {...optionAttributes(option)}\n role=\"option\"\n aria-selected={active}\n title={`Open ${header.label}`}\n className={`group mx-1.5 mt-1 flex h-[calc(100%-4px)] cursor-pointer items-center gap-2.5 rounded-md px-2 text-left ${rowTone(active)}`}\n onMouseDown={(event) => event.preventDefault()}\n onMouseEnter={activate}\n onClick={header.open}\n >\n <span aria-hidden=\"true\" className=\"contents\">\n {header.logo}\n </span>\n <span className=\"truncate text-[13px] font-semibold text-foreground\">\n <Highlight text={header.label} tokens={props.tokens} />\n </span>\n {header.note ? (\n <span className=\"truncate text-[11px] text-muted-foreground\">\n {header.note}\n </span>\n ) : null}\n <span\n className={`ml-auto flex shrink-0 items-center gap-0.5 text-[11px] text-muted-foreground ${\n active ? \"\" : \"opacity-0 group-hover:opacity-100\"\n }`}\n >\n All {header.kind}s\n <Icon name=\"chevron\" size={12} />\n </span>\n </div>\n );\n }}\n />\n </div>\n );\n}\n\nexport function BlockSelector(props: {\n title: string;\n presets: BlockPreset[];\n onPick: (preset: PickedPreset) => void;\n onClose: () => void;\n // Show the piece catalog beside the presets.\n showPieces?: boolean;\n // Which piece entries the picker offers; defaults to actions.\n pieceMode?: PieceMode;\n // Detached steps offered for re-attachment at this insertion point.\n attachSteps?: StepModel[];\n onAttach?: (stepId: string) => void;\n // The button that opened it: clicks there are its own to handle.\n anchor?: RefObject<HTMLElement | null>;\n width?: number;\n height?: number;\n}) {\n const [query, setQuery] = useState(\"\");\n const [tab, setTab] = useState<SourceTab>(\"all\");\n const [chip, setChip] = useState<string | null>(null);\n const [catalog, setCatalog] = useState<CatalogState | null>(null);\n const [selectedId, setSelectedId] = useState<string | null>(null);\n const [paneState, setPane] = useState<\"sources\" | \"entries\">(\"sources\");\n const [entryIndex, setEntryIndex] = useState(-1);\n const [rowIndex, setRowIndex] = useState(-1);\n const [expanded, setExpanded] = useState<ReadonlySet<string>>(new Set());\n const containerRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const baseId = useId();\n const listIds = {\n sources: `${baseId}-sources`,\n entries: `${baseId}-entries`,\n results: `${baseId}-results`,\n };\n // Hover only counts once the pointer has moved, so a list scrolling under\n // a still pointer does not steal the selection.\n const pointerMoved = useRef(false);\n const hoverTimer = useRef<ReturnType<typeof setTimeout> | undefined>(\n undefined,\n );\n const { anchor, onClose } = props;\n\n useEffect(() => {\n const handler = (event: PointerEvent) => {\n const target = event.target as globalThis.Node;\n if (containerRef.current?.contains(target)) return;\n // The opener toggles the picker itself.\n if (anchor?.current?.contains(target)) return;\n onClose();\n };\n // Capture: the canvas pan handler stops the event before it bubbles.\n window.addEventListener(\"pointerdown\", handler, true);\n return () => window.removeEventListener(\"pointerdown\", handler, true);\n }, [anchor, onClose]);\n\n useEffect(() => () => clearTimeout(hoverTimer.current), []);\n\n const anySource = usePieceSource();\n const pieceSource = props.showPieces ? anySource : undefined;\n const [catalogRound, setCatalogRound] = useState(0);\n // Loaded even without the piece list: presets are pinned to its versions.\n // A failed load retries with a fresh fetch, backing off, before it shows.\n useEffect(() => {\n if (!anySource) return;\n let cancelled = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const load = (attempt: number) => {\n const request =\n attempt > 0 && anySource.reloadCatalog\n ? anySource.reloadCatalog()\n : anySource.loadCatalog();\n request\n .then((pieces) => {\n // Canvas nodes read logos from the registry, not from this list.\n registerPieceLogos(pieces);\n if (!cancelled) setCatalog({ pieces });\n })\n .catch((error: unknown) => {\n if (cancelled) return;\n if (attempt + 1 < CATALOG_MAX_ATTEMPTS) {\n timer = setTimeout(\n () => load(attempt + 1),\n CATALOG_RETRY_MS * 2 ** attempt,\n );\n return;\n }\n setCatalog({\n pieces: [],\n error: error instanceof Error ? error.message : String(error),\n });\n });\n };\n load(catalogRound > 0 ? 1 : 0);\n return () => {\n cancelled = true;\n clearTimeout(timer);\n };\n }, [anySource, catalogRound]);\n\n const installed = (name: string) =>\n catalog?.pieces.find((entry) => entry.name === name)?.version;\n const versionNote = useVersionNote(catalog?.pieces);\n const pinned = (preset: BlockPreset) => pinBlock(preset.block, installed);\n const pick = (preset: BlockPreset) => {\n const block = pinned(preset);\n if (!block) return;\n rememberPick(preset);\n props.onPick({ ...preset, block });\n };\n const prefetch = useBlockFormPrefetch();\n\n const mode: PieceMode = props.pieceMode ?? \"actions\";\n const kind = mode === \"triggers\" ? \"trigger\" : \"action\";\n const tokens = queryTokens(query);\n const searching = query.trim().length >= SEARCH_MIN_CHARS;\n const showCatalog = pieceSource !== undefined && tab !== \"core\";\n const tabs: SourceTab[] = pieceSource\n ? [\"all\", \"core\", \"powerhouse\", \"activepieces\"]\n : [\"all\", \"core\", \"powerhouse\"];\n\n // A piece whose every block is a preset is listed as those presets.\n const modePieces = useMemo(() => {\n const presetCounts = new Map<string, number>();\n for (const preset of props.presets) {\n const name = preset.block.pieceName;\n presetCounts.set(name, (presetCounts.get(name) ?? 0) + 1);\n }\n return (catalog?.pieces ?? []).filter((entry) => {\n const count =\n mode === \"triggers\" ? entry.triggerCount : entry.actionCount;\n return count > (presetCounts.get(entry.name) ?? 0);\n });\n }, [catalog, mode, props.presets]);\n const tabPieces = useMemo(\n () => modePieces.filter((entry) => inTab(tab, entry)),\n [modePieces, tab],\n );\n const chips = useMemo(() => orderChips(tabPieces), [tabPieces]);\n // Categories narrow catalogs; All and Core lead with our own lists. One\n // chip has nothing to narrow.\n const showChips =\n showCatalog &&\n (tab === \"activepieces\" || tab === \"powerhouse\") &&\n chips.length > 1;\n const activeChip =\n showChips && chip !== null && chips.includes(chip) ? chip : null;\n\n const searchFilter = useMemo<PieceSearchFilterUi | null>(\n () =>\n showCatalog\n ? {\n kind,\n ...(TAB_SOURCES[tab] ? { sources: TAB_SOURCES[tab] } : {}),\n ...(activeChip\n ? { categories: categoriesOfChip(activeChip, tabPieces) }\n : {}),\n }\n : null,\n [showCatalog, kind, tab, activeChip, tabPieces],\n );\n const search = usePieceSearch(query, searchFilter);\n\n const presetEntry = (preset: BlockPreset): Entry => {\n const block = pinned(preset);\n return {\n key: `${blockKey(preset.block)} ${preset.label}`,\n logo: <BlockLogo block={preset.block} size={ROW_LOGO} />,\n label: preset.label,\n description: preset.description,\n unavailable: block\n ? undefined\n : catalog === null\n ? \"Loading…\"\n : \"Not installed on this runtime\",\n version: shownVersion(preset.block.pieceName, block?.pieceVersion),\n versionNote: versionNote(preset.block.pieceName, block?.pieceVersion),\n pick: () => pick(preset),\n warm: block ? () => prefetch(block) : undefined,\n };\n };\n\n const blockEntry = (\n entry: {\n pieceName: string;\n pieceVersion: string;\n name: string;\n displayName: string;\n description: string;\n unsupported?: string | null;\n strategy?: string | null;\n },\n logo: React.ReactNode,\n ): Entry => {\n const block: BlockRef = {\n pieceName: entry.pieceName,\n pieceVersion: entry.pieceVersion,\n kind,\n name: entry.name,\n };\n return {\n key: blockKey(block),\n logo,\n label: entry.displayName,\n description: entry.description,\n // Visible but inert: picking one would build a step that never runs.\n unavailable: blockUnavailable({ ...entry, kind }),\n version: shownVersion(entry.pieceName, entry.pieceVersion),\n versionNote: versionNote(entry.pieceName, entry.pieceVersion),\n pick: () =>\n pick({\n label: entry.displayName,\n block,\n description: entry.description,\n defaultConfig: {},\n }),\n warm: () => prefetch(block),\n };\n };\n\n // Our own lists, each a source in the left pane. A chip narrows to pieces.\n const lists = (() => {\n if (activeChip !== null) return [];\n const result: Extract<Source, { kind: \"list\" }>[] = [];\n const add = (\n id: ListId,\n title: string,\n subtitle: string,\n logo: (size: number) => React.ReactNode,\n entries: Entry[],\n ) => {\n if (entries.length > 0) {\n result.push({ kind: \"list\", id, title, subtitle, logo, entries });\n }\n };\n // Detached steps first: re-attaching is why the picker opened there.\n if (tab === \"all\") {\n if (props.onAttach) {\n add(\n \"attach\",\n \"Detached steps\",\n \"Re-attach a step at this point\",\n listTile(\"branch\", \"#64748b\"),\n (props.attachSteps ?? []).map((step) => ({\n key: `attach ${step.id}`,\n logo: <BlockLogo block={stepBlock(step)} size={ROW_LOGO} />,\n label: step.name,\n description: `{{steps.${step.key}}} · detached`,\n pick: () => props.onAttach?.(step.id),\n })),\n );\n }\n }\n if (tab === \"all\" || tab === \"core\") {\n add(\n \"core\",\n \"Core\",\n \"Built into the workflow engine\",\n listTile(\"bolt\", \"#2563eb\"),\n props.presets\n .filter((preset) => preset.group !== \"powerhouse\")\n .map(presetEntry),\n );\n }\n if (tab === \"all\" || tab === \"powerhouse\") {\n const reactorPreset = props.presets.find(\n (preset) => preset.group === \"powerhouse\",\n );\n add(\n \"powerhouse\",\n \"Documents\",\n \"Read and change documents on this reactor\",\n (size) =>\n reactorPreset ? (\n <BlockLogo block={reactorPreset.block} size={size} />\n ) : null,\n props.presets\n .filter((preset) => preset.group === \"powerhouse\")\n .map(presetEntry),\n );\n }\n if (tab === \"all\") {\n const recent = recentPicks(kind).filter(\n (preset) =>\n isCoreBlock(preset.block) || installed(preset.block.pieceName),\n );\n add(\n \"recent\",\n \"Recently used\",\n `Your last ${kind}s`,\n listTile(\"clock\", \"#64748b\"),\n recent.map((preset) => {\n const entry = presetEntry(preset);\n // A piece this runtime has since stopped running stays inert.\n const reason = catalog?.pieces.find(\n (piece) => piece.name === preset.block.pieceName,\n )?.unsupported;\n return reason ? { ...entry, unavailable: reason } : entry;\n }),\n );\n }\n return result;\n })();\n\n // Browse: lists then pieces, narrowed by a short query on the client.\n const sources = ((): Source[] => {\n const listSources = lists\n .map((list) => ({\n ...list,\n entries: list.entries.filter((entry) =>\n matchesQuery(`${entry.label} ${entry.description}`, tokens),\n ),\n }))\n .filter((list) => list.entries.length > 0);\n const pieceSources: Source[] = showCatalog\n ? tabPieces\n .filter(\n (entry) =>\n (activeChip === null || chipsOf(entry).has(activeChip)) &&\n matchesQuery(\n `${entry.displayName} ${entry.name} ${entry.description}`,\n tokens,\n ),\n )\n .map((piece) => ({ kind: \"piece\", id: piece.name, piece }))\n : [];\n return [...listSources, ...pieceSources];\n })();\n\n const selected: Source | undefined =\n sources.find((source) => source.id === selectedId) ?? sources.at(0);\n const sourceIndex = selected ? sources.indexOf(selected) : -1;\n const selectedPiece = selected?.kind === \"piece\" ? selected.piece : undefined;\n const loaded = usePieceEntries(selectedPiece, mode);\n const pieceEntries =\n selectedPiece && loaded.entries\n ? loaded.entries.map((entry) =>\n blockEntry(\n entry,\n <LogoFrame\n src={selectedPiece.logoUrl}\n alt={selectedPiece.displayName}\n size={ROW_LOGO}\n />,\n ),\n )\n : null;\n const entries =\n selected?.kind === \"list\" ? selected.entries : (pieceEntries ?? []);\n // The keyboard's block, once the list it points into has loaded.\n const entryAt =\n entries.length === 0 ? -1 : Math.min(entryIndex, entries.length - 1);\n\n // Search: our lists that match, then the server's groups.\n const presetKeys = new Set(\n props.presets.map(\n (preset) => `${preset.block.pieceName} ${preset.block.name}`,\n ),\n );\n const rows: SearchRow[] = [];\n if (searching) {\n for (const source of sources) {\n if (source.kind !== \"list\" || source.id === \"recent\") continue;\n rows.push({ type: \"list\", source });\n for (const entry of source.entries) rows.push({ type: \"entry\", entry });\n }\n const groups =\n search.kind === \"done\"\n ? search.result.pieces\n .map((match) => ({\n ...match,\n // A block a preset offers is listed once, as the preset.\n blocks: match.blocks.filter(\n (hit) => !presetKeys.has(`${hit.pieceName} ${hit.name}`),\n ),\n }))\n .filter((match) => match.blocks.length > 0)\n : [];\n for (const match of groups) {\n rows.push({ type: \"piece\", match });\n const all = groups.length <= 2 || expanded.has(match.pieceName);\n const shown = all ? match.blocks : match.blocks.slice(0, GROUP_BLOCKS);\n const logo = (\n <LogoFrame\n src={match.logoUrl}\n alt={match.displayName}\n size={ROW_LOGO}\n />\n );\n for (const hit of shown) {\n rows.push({ type: \"entry\", entry: blockEntry(hit, logo) });\n }\n if (shown.length < match.blocks.length) {\n rows.push({\n type: \"more\",\n pieceName: match.pieceName,\n hidden: match.blocks.length - shown.length,\n });\n }\n }\n // A source that cannot search, or an index still building, falls back to\n // matching the catalog's piece names.\n const partial =\n !pieceSource?.searchPieces ||\n (search.kind === \"done\" && search.result.status !== \"ready\");\n if (showCatalog && partial) {\n const grouped = new Set(groups.map((match) => match.pieceName));\n // Names that match ahead of descriptions that mention them.\n const named = (source: Source) =>\n source.kind === \"piece\" &&\n matchesQuery(source.piece.displayName, tokens)\n ? 0\n : 1;\n for (const source of [...sources].sort((a, b) => named(a) - named(b))) {\n if (source.kind !== \"piece\" || grouped.has(source.id)) continue;\n rows.push({\n type: \"piece\",\n match: {\n pieceName: source.piece.name,\n pieceVersion: source.piece.version ?? \"\",\n displayName: source.piece.displayName,\n description: source.piece.description,\n logoUrl: source.piece.logoUrl,\n categories: source.piece.categories,\n source: source.piece.source ?? \"activepieces\",\n namedPiece: true,\n blocks: [],\n },\n });\n }\n }\n }\n\n // Until the keyboard moves, the best block: Enter picks it.\n const activeRow =\n rowIndex < 0\n ? rows.findIndex((row) => row.type === \"entry\")\n : Math.min(rowIndex, rows.length - 1);\n\n // One source needs no list to choose from; its blocks fill the picker.\n const twoPane = showCatalog || sources.length > 1;\n const pane = twoPane ? paneState : \"entries\";\n\n const selectSource = (id: string) => {\n setSelectedId(id);\n setPane(\"sources\");\n setEntryIndex(-1);\n };\n const openSource = (id: string) => {\n setSelectedId(id);\n setPane(\"entries\");\n setEntryIndex(0);\n };\n // From a search group to the piece itself, in the browse panes.\n const openPiece = (pieceName: string) => {\n // Not in the browse list (the catalog lacks it): show its blocks here.\n if (!modePieces.some((piece) => piece.name === pieceName)) {\n setExpanded(new Set([...expanded, pieceName]));\n return;\n }\n setQuery(\"\");\n setChip(null);\n if (tab !== \"all\") setTab(\"all\");\n openSource(pieceName);\n inputRef.current?.focus();\n };\n const hoverSource = (id: string) => {\n if (!pointerMoved.current) return;\n clearTimeout(hoverTimer.current);\n hoverTimer.current = setTimeout(() => selectSource(id), HOVER_PREVIEW_MS);\n };\n\n // An empty list (a piece's blocks still loading) keeps the position.\n const step = (index: number, delta: number, count: number) =>\n count === 0 ? index : Math.min(Math.max(index + delta, 0), count - 1);\n\n const onKeyDown = (event: React.KeyboardEvent) => {\n const key = event.key;\n // Tabs and chips handle their own keys; the lists answer the search box.\n if (key !== \"Escape\" && event.target !== inputRef.current) return;\n if (key === \"Escape\") {\n event.stopPropagation();\n if (query !== \"\") setQuery(\"\");\n else if (twoPane && pane === \"entries\" && !searching) setPane(\"sources\");\n else onClose();\n return;\n }\n const delta = key === \"ArrowDown\" ? 1 : key === \"ArrowUp\" ? -1 : 0;\n if (searching) {\n if (delta !== 0) {\n event.preventDefault();\n setRowIndex(Math.max(step(activeRow, delta, rows.length), 0));\n return;\n }\n if (key === \"Enter\") {\n event.preventDefault();\n // Rows answered for an earlier query are not what Enter means.\n if (search.kind === \"done\" && search.stale) return;\n const row = rows.at(activeRow);\n if (!row) return;\n if (row.type === \"entry\") {\n if (row.entry.unavailable === undefined) row.entry.pick();\n } else if (row.type === \"piece\") openPiece(row.match.pieceName);\n else if (row.type === \"list\") openSource(row.source.id);\n else setExpanded(new Set([...expanded, row.pieceName]));\n }\n return;\n }\n // Left and right move the caret while there is text to move it in.\n const sideways = query === \"\";\n if (pane === \"sources\") {\n if (delta !== 0) {\n event.preventDefault();\n const next = sources.at(step(sourceIndex, delta, sources.length));\n if (next) selectSource(next.id);\n } else if (key === \"Enter\" || (sideways && key === \"ArrowRight\")) {\n event.preventDefault();\n if (selected) openSource(selected.id);\n }\n return;\n }\n if (delta !== 0) {\n event.preventDefault();\n setEntryIndex(step(entryIndex, delta, entries.length));\n } else if (sideways && key === \"ArrowLeft\") {\n event.preventDefault();\n setPane(\"sources\");\n } else if (key === \"Enter\") {\n event.preventDefault();\n const entry = entryAt < 0 ? undefined : entries.at(entryAt);\n if (entry && entry.unavailable === undefined) entry.pick();\n }\n };\n\n const width = props.width ?? (pieceSource ? PICKER_SIZE.width : 360);\n const activeList = searching\n ? listIds.results\n : pane === \"entries\"\n ? listIds.entries\n : listIds.sources;\n const activeIndex = searching\n ? activeRow\n : pane === \"entries\"\n ? entryAt\n : sourceIndex;\n const activeOption =\n activeIndex >= 0 ? optionId(activeList, activeIndex) : undefined;\n const searchStatus =\n search.kind === \"loading\" || (search.kind === \"done\" && search.stale) ? (\n <Status>Searching…</Status>\n ) : search.kind === \"error\" ? (\n <Status error>{search.message}</Status>\n ) : search.kind === \"done\" && search.result.status === \"indexing\" ? (\n // Status covers the published catalog only; local pieces are listed.\n <Status>\n Still indexing the catalog: pieces are matched by name until it is\n ready.\n </Status>\n ) : search.kind === \"done\" && search.result.status === \"error\" ? (\n <Status error>\n {search.result.error ?? \"Search failed\"}; pieces are matched by name.\n </Status>\n ) : rows.length === 0 ? (\n <Status>No matching {kind}s</Status>\n ) : null;\n // Fitted to its content where one short list is all there is to show.\n const compact = !twoPane && !searching;\n const height = props.height ?? PICKER_SIZE.height;\n\n return (\n <div\n ref={containerRef}\n className=\"nodrag nopan nowheel flex flex-col overflow-hidden rounded-lg border border-solid border-foreground/10 bg-card shadow-xl\"\n style={compact ? { width, maxHeight: height } : { width, height }}\n onClick={(event) => event.stopPropagation()}\n onKeyDown={onKeyDown}\n onMouseMove={() => {\n pointerMoved.current = true;\n }}\n >\n <div className=\"shrink-0 border-b border-foreground/10\">\n <div className=\"flex items-center gap-2 px-3.5 pt-3 text-muted-foreground\">\n <Icon name=\"search\" size={15} />\n <input\n ref={inputRef}\n autoFocus\n role=\"combobox\"\n aria-expanded\n aria-autocomplete=\"list\"\n aria-label={`Search ${props.title.toLowerCase()}`}\n aria-controls={activeList}\n aria-activedescendant={activeOption}\n // Always focused while open; the caret is its focus indicator.\n className=\"min-w-0 flex-1 bg-transparent py-1 text-sm text-foreground outline-none placeholder:text-muted-foreground\"\n placeholder={\n pieceSource ? `Search pieces and ${kind}s…` : \"Search…\"\n }\n value={query}\n onChange={(event) => {\n setQuery(event.target.value);\n setRowIndex(-1);\n setExpanded(new Set());\n }}\n />\n <span className=\"shrink-0 truncate text-xs\">{props.title}</span>\n </div>\n <div className=\"px-3 pb-2.5 pt-2\">\n <Tabs\n tabs={tabs}\n active={tab}\n onSelect={(next, fromKeyboard) => {\n setTab(next);\n setChip(null);\n setSelectedId(null);\n setPane(\"sources\");\n if (!fromKeyboard) inputRef.current?.focus();\n }}\n />\n </div>\n </div>\n {showChips && catalog && !catalog.error ? (\n <ChipBar>\n {chips.map((label, index) => (\n <Chip\n key={label}\n label={label}\n active={activeChip === label}\n tabStop={activeChip === null ? index === 0 : activeChip === label}\n onClick={(fromKeyboard) => {\n setChip(activeChip === label ? null : label);\n setSelectedId(null);\n if (!fromKeyboard) inputRef.current?.focus();\n }}\n />\n ))}\n </ChipBar>\n ) : null}\n {searching ? (\n <SearchList\n rows={rows}\n tokens={tokens}\n activeIndex={activeRow}\n onActivate={(index) => {\n if (pointerMoved.current) setRowIndex(index);\n }}\n onOpenPiece={openPiece}\n onOpenList={(id) => {\n setQuery(\"\");\n openSource(id);\n }}\n onExpand={(name) => setExpanded(new Set([...expanded, name]))}\n status={searchStatus}\n kind={kind}\n listId={listIds.results}\n resetKey={`${query} ${JSON.stringify(searchFilter)}`}\n stale={search.kind === \"done\" && search.stale}\n />\n ) : (\n <div className=\"flex min-h-0 flex-1\">\n {twoPane ? (\n // A tinted rail, so the open piece can sit raised on it.\n <div className=\"flex w-56 shrink-0 flex-col border-r border-foreground/10 bg-foreground/[0.025]\">\n {catalog?.error ? (\n <div className=\"flex items-center gap-2 px-3 py-2 text-xs text-wf-fail\">\n <span className=\"min-w-0 flex-1\">{catalog.error}</span>\n <button\n type=\"button\"\n className=\"shrink-0 cursor-pointer rounded border border-solid border-foreground/15 bg-card px-1.5 py-0.5 text-foreground hover:border-foreground/25\"\n onClick={() => {\n setCatalog(null);\n setCatalogRound((round) => round + 1);\n }}\n >\n Retry\n </button>\n </div>\n ) : null}\n <VirtualList\n id={listIds.sources}\n label=\"Pieces\"\n resetKey={`${tab} ${activeChip ?? \"\"} ${query}`}\n className=\"flex-1 py-1\"\n items={sources}\n heightOf={sourceHeight}\n keyOf={(source) => `${source.kind}:${source.id}`}\n activeIndex={sourceIndex}\n render={(source, index) => (\n <SourceRow\n source={source}\n tokens={tokens}\n mode={mode}\n active={pane === \"sources\" && index === sourceIndex}\n selected={index === sourceIndex}\n option={{\n list: listIds.sources,\n index,\n size: sources.length,\n }}\n onActivate={() => hoverSource(source.id)}\n onOpen={() => {\n clearTimeout(hoverTimer.current);\n openSource(source.id);\n inputRef.current?.focus();\n }}\n />\n )}\n />\n {showCatalog && catalog === null ? (\n <Status>Loading catalog…</Status>\n ) : sources.length === 0 ? (\n <Status>\n {tab === \"powerhouse\" && tokens.length === 0\n ? \"No registry pieces on this runtime\"\n : \"No matching pieces\"}\n </Status>\n ) : null}\n </div>\n ) : null}\n <EntriesPane\n source={selected}\n mode={mode}\n pieceEntries={pieceEntries}\n pieceError={selected?.kind === \"piece\" ? loaded.error : null}\n tokens={tokens}\n activeIndex={pane === \"entries\" ? entryAt : -1}\n listId={listIds.entries}\n showHeader={twoPane}\n onActivate={(index) => {\n if (!pointerMoved.current) return;\n setPane(\"entries\");\n setEntryIndex(index);\n }}\n />\n </div>\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