@lace-cloud/canvas 0.21.1 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -33,7 +33,7 @@ import {
33
33
  rowActions,
34
34
  toArgv,
35
35
  uniqueDiagnostics
36
- } from "./chunk-TPJXMHYN.mjs";
36
+ } from "./chunk-GV2FO3E2.mjs";
37
37
 
38
38
  // src/index.ts
39
39
  import { projectCanvasView as projectCanvasView2 } from "@lace-cloud/proto";
@@ -42,12 +42,12 @@ import { Toast } from "@lace-cloud/ui/feedback";
42
42
  // src/App.tsx
43
43
  import { ReactFlowProvider } from "@xyflow/react";
44
44
  import {
45
- Fragment as Fragment10,
46
- useCallback as useCallback13,
45
+ Fragment as Fragment14,
46
+ useCallback as useCallback14,
47
47
  useEffect as useEffect11,
48
- useMemo as useMemo10,
48
+ useMemo as useMemo9,
49
49
  useRef as useRef11,
50
- useState as useState20,
50
+ useState as useState23,
51
51
  useSyncExternalStore
52
52
  } from "react";
53
53
  import "./App-IFIOMNV7.css";
@@ -953,18 +953,18 @@ async function groupRun(env) {
953
953
  const declared = new Map(
954
954
  (frame.bundle.modules[created.scope]?.modules ?? []).map((use, i) => [use.id, i])
955
955
  );
956
- const keyOf = (id, at) => ({ ...at, declared: declared.get(id) ?? 0 });
956
+ const keyOf2 = (id, at) => ({ ...at, declared: declared.get(id) ?? 0 });
957
957
  const selected = new Set(ids);
958
958
  const others = [...view.nodes, ...view.groups].flatMap(({ id }) => {
959
959
  const { parentPath: scopePath, localId } = splitPath2(id);
960
960
  const rect = selected.has(id) || scopePath !== parentPath ? void 0 : drawnRect(view, id);
961
- return rect ? [{ rect, key: keyOf(localId, rect) }] : [];
961
+ return rect ? [{ rect, key: keyOf2(localId, rect) }] : [];
962
962
  });
963
963
  const enclosing = view.groups.find((g) => g.id === parentPath);
964
964
  const wanted = boxAt(origin);
965
965
  let anchor = enclosing ? { x: wanted.x, y: Math.max(wanted.y, originAt(enclosing.position).y) } : wanted;
966
966
  for (let moved = true; moved; ) {
967
- const groupKey = keyOf(created.id, anchor);
967
+ const groupKey = keyOf2(created.id, anchor);
968
968
  const keptFirst = others.filter((o) => keepOrder(o.key, groupKey) < 0).map((o) => o.rect);
969
969
  const stepped = stepDown(anchor, reach, keptFirst);
970
970
  moved = stepped.y !== anchor.y;
@@ -1545,6 +1545,11 @@ function sourceHandleId(output) {
1545
1545
  return `out:${output}`;
1546
1546
  }
1547
1547
 
1548
+ // src/utils/typed-name.ts
1549
+ function typedName(name, type) {
1550
+ return type ? `${name}: ${type}` : name;
1551
+ }
1552
+
1548
1553
  // src/components/nodes/ModuleNode.tsx
1549
1554
  import "./ModuleNode-RRZ37SFM.css";
1550
1555
 
@@ -1647,7 +1652,7 @@ var PinRow = ({ pin, side, top, shared, problem, isConnectable }) => {
1647
1652
  [isInput ? "left" : "right"]: -5,
1648
1653
  top: NODE_ROW_HEIGHT2 / 2
1649
1654
  };
1650
- const about = `${pin.name}: ${pin.type}${pin.description ? ` \u2014 ${pin.description}` : ""}`;
1655
+ const about = `${typedName(pin.name, pin.type)}${pin.description ? ` \u2014 ${pin.description}` : ""}`;
1651
1656
  return /* @__PURE__ */ jsxs4(
1652
1657
  "div",
1653
1658
  {
@@ -3421,8 +3426,8 @@ import { createElement as createElement2 } from "react";
3421
3426
 
3422
3427
  // src/components/panels/ModuleConfigPanel.tsx
3423
3428
  import { deriveNodeConfig, instanceAddress as instanceAddress6 } from "@lace-cloud/proto";
3424
- import { Button as Button6, IconButton as IconButton3, Input, ModeToggle, Panel as Panel2, Textarea } from "@lace-cloud/ui";
3425
- import { useCallback as useCallback8, useEffect as useEffect10, useMemo as useMemo7, useState as useState15 } from "react";
3429
+ import { Button as Button12, IconButton as IconButton9, Input as Input8, ModeToggle, Panel as Panel6, Textarea as Textarea3 } from "@lace-cloud/ui";
3430
+ import { useCallback as useCallback13, useEffect as useEffect10, useMemo as useMemo8, useState as useState22 } from "react";
3426
3431
 
3427
3432
  // src/exhaustive.ts
3428
3433
  function assertNever(value) {
@@ -3497,7 +3502,7 @@ function AccordionSection({ title, defaultOpen = false, badge, children }) {
3497
3502
  }
3498
3503
 
3499
3504
  // src/components/panels/ModuleConfigPanel.tsx
3500
- import "./ModuleConfigPanel-LTPLEG2L.css";
3505
+ import "./ModuleConfigPanel-ZMWRMN5N.css";
3501
3506
  import "./panels-shared-5JFNYXQ7.css";
3502
3507
 
3503
3508
  // src/components/UpdateButton.tsx
@@ -3531,521 +3536,188 @@ function UpdateButton({ status, label, onClick, disabled, disabledTitle }) {
3531
3536
  ) });
3532
3537
  }
3533
3538
 
3534
- // src/components/panels/ModuleConfigPanel.tsx
3535
- import { jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
3536
- var MODE_ITEMS = [
3537
- { value: "literal", label: "Lit" },
3538
- { value: "variable", label: "Var" },
3539
- { value: "expression", label: "Expr" },
3540
- { value: "wired", label: "Wired" }
3541
- ];
3542
- function toInputMode(mode) {
3543
- switch (mode) {
3544
- case "empty":
3545
- return 1 /* INPUT_MODE_EMPTY */;
3546
- case "literal":
3547
- return 2 /* INPUT_MODE_LITERAL */;
3548
- case "variable":
3549
- return 3 /* INPUT_MODE_VARIABLE */;
3550
- case "expression":
3551
- return 4 /* INPUT_MODE_EXPRESSION */;
3552
- case "wired":
3553
- return 5 /* INPUT_MODE_WIRED */;
3554
- default:
3555
- return assertNever(mode);
3556
- }
3539
+ // src/components/panels/ModuleDetails.tsx
3540
+ import { deriveSettingsConfig } from "@lace-cloud/proto";
3541
+ import { Input as Input7 } from "@lace-cloud/ui";
3542
+ import { useMemo as useMemo7, useState as useState21 } from "react";
3543
+
3544
+ // src/components/panels/BlockEditor.tsx
3545
+ import { Button as Button6, IconButton as IconButton3, Input } from "@lace-cloud/ui";
3546
+ import { useState as useState15 } from "react";
3547
+ import "./panels-shared-5JFNYXQ7.css";
3548
+ import { Fragment as Fragment6, jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
3549
+ function replaceAt(list, index, item) {
3550
+ return list.map((x, i) => i === index ? item : x);
3557
3551
  }
3558
- function ModuleConfigPanel({ instance_id, onClose, onModified }) {
3559
- const { editable, bundle, runner } = useCanvas();
3560
- const config = useMemo7(
3561
- () => deriveNodeConfig(bundle, instance_id),
3562
- [bundle, instance_id]
3563
- );
3564
- const [inputState, setInputState] = useState15({
3565
- modes: {},
3566
- values: {},
3567
- variables: {},
3568
- expressions: {}
3569
- });
3570
- const {
3571
- modes: localModes,
3572
- values: localValues,
3573
- variables: localVariables,
3574
- expressions: localExpressions
3575
- } = inputState;
3576
- const setLocalModes = useCallback8(
3577
- (fn) => setInputState((s) => ({ ...s, modes: fn(s.modes) })),
3578
- []
3579
- );
3580
- const setLocalValues = useCallback8(
3581
- (fn) => setInputState((s) => ({ ...s, values: fn(s.values) })),
3582
- []
3583
- );
3584
- const setLocalVariables = useCallback8(
3585
- (fn) => setInputState((s) => ({ ...s, variables: fn(s.variables) })),
3586
- []
3587
- );
3588
- const setLocalExpressions = useCallback8(
3589
- (fn) => setInputState((s) => ({ ...s, expressions: fn(s.expressions) })),
3590
- []
3591
- );
3592
- const [localDependsOn, setLocalDependsOn] = useState15(/* @__PURE__ */ new Set());
3593
- const [localProviders, setLocalProviders] = useState15([]);
3594
- useEffect10(() => {
3595
- if (!config) return;
3596
- const modes = {};
3597
- const values = {};
3598
- const variables = {};
3599
- const expressions = {};
3600
- for (const input of config.inputs) {
3601
- modes[input.name] = input.mode;
3602
- if (input.value !== void 0) values[input.name] = input.value;
3603
- if (input.variable) variables[input.name] = input.variable;
3604
- if (input.expression) expressions[input.name] = input.expression;
3605
- }
3606
- setInputState({ modes, values, variables, expressions });
3607
- setLocalDependsOn(new Set(config.depends_on));
3608
- setLocalProviders(
3609
- Object.entries(config.providers ?? {}).map(([key, value]) => ({ key, value }))
3610
- );
3611
- }, [config]);
3612
- const switchMode = useCallback8(
3613
- (name, mode, input) => {
3614
- setLocalModes((prev) => ({ ...prev, [name]: mode }));
3615
- switch (mode) {
3616
- case "literal":
3617
- setLocalValues((prev) => ({ ...prev, [name]: input.default_value ?? null }));
3618
- break;
3619
- case "variable":
3620
- setLocalVariables((prev) => ({ ...prev, [name]: "" }));
3621
- break;
3622
- case "expression":
3623
- setLocalExpressions((prev) => ({ ...prev, [name]: "" }));
3624
- break;
3625
- case "empty":
3626
- setLocalValues((prev) => {
3627
- const next = { ...prev };
3628
- delete next[name];
3629
- return next;
3630
- });
3631
- break;
3632
- case "wired":
3633
- break;
3634
- default:
3635
- assertNever(mode);
3636
- }
3637
- },
3638
- [setLocalModes, setLocalValues, setLocalVariables, setLocalExpressions]
3639
- );
3640
- const { requiredInputs, optionalInputs } = useMemo7(
3641
- () => ({
3642
- requiredInputs: (config?.inputs ?? []).filter((i) => i.required),
3643
- optionalInputs: (config?.inputs ?? []).filter((i) => !i.required)
3644
- }),
3645
- [config?.inputs]
3646
- );
3647
- const address = useMemo7(() => instanceAddress6(bundle, instance_id), [bundle, instance_id]);
3648
- const { status: updateStatus, handleUpdate } = useUpdateState(async () => {
3649
- if (!config || !editable) return;
3650
- const actions = [];
3651
- for (const input of config.inputs) {
3652
- const mode = localModes[input.name] ?? input.mode;
3653
- if (mode === "wired") continue;
3654
- actions.push({
3655
- update_input: {
3656
- scope: address.scope,
3657
- instance_id: address.id,
3658
- input_name: input.name,
3659
- mode: toInputMode(mode),
3660
- value: mode === "literal" ? localValues[input.name] : void 0,
3661
- variable: mode === "variable" ? localVariables[input.name] ?? "" : "",
3662
- expression: mode === "expression" ? localExpressions[input.name] ?? "" : ""
3663
- }
3664
- });
3665
- }
3666
- actions.push({
3667
- set_depends_on: {
3668
- scope: address.scope,
3669
- instance_id: address.id,
3670
- depends_on: [...localDependsOn]
3671
- }
3672
- });
3673
- const providersRecord = {};
3674
- for (const { key, value } of localProviders) {
3675
- const name = key.trim();
3676
- if (name) providersRecord[name] = value.trim();
3677
- }
3678
- actions.push({
3679
- set_use_providers: {
3680
- scope: address.scope,
3681
- instance_id: address.id,
3682
- providers: providersRecord
3683
- }
3684
- });
3685
- const result = await runner.apply(actions);
3686
- if (!result?.success) throw new Error("apply failed");
3687
- const requiredToCheck = config.inputs.filter((i) => i.required);
3688
- const hasFilledRequired = requiredToCheck.length === 0 || requiredToCheck.some((input) => {
3689
- const mode = localModes[input.name] ?? input.mode;
3690
- if (mode === "wired") return true;
3691
- if (mode === "literal") {
3692
- const v = localValues[input.name];
3693
- return v !== void 0 && v !== null && v !== "";
3552
+ function blockTitle(block) {
3553
+ return [block.type, ...block.labels.map((l) => `"${l}"`)].join(" ");
3554
+ }
3555
+ function BlockEditor({ blocks, onChange, editable, templates }) {
3556
+ return /* @__PURE__ */ jsxs15(Fragment6, { children: [
3557
+ blocks.map((block, i) => /* @__PURE__ */ jsx24(
3558
+ BlockCard,
3559
+ {
3560
+ block,
3561
+ editable,
3562
+ onChange: (next) => onChange(replaceAt(blocks, i, next)),
3563
+ onRemove: () => onChange(blocks.filter((_, j) => j !== i))
3564
+ },
3565
+ i
3566
+ )),
3567
+ editable && (templates ? /* @__PURE__ */ jsx24("div", { className: "lace-panel-row-actions", children: templates.map((t) => /* @__PURE__ */ jsxs15(
3568
+ Button6,
3569
+ {
3570
+ variant: "secondary",
3571
+ size: "sm",
3572
+ onClick: () => onChange([
3573
+ ...blocks,
3574
+ {
3575
+ type: t.type,
3576
+ labels: [],
3577
+ attributes: t.attributes.map((name) => ({ name, value: "" })),
3578
+ blocks: []
3579
+ }
3580
+ ]),
3581
+ children: [
3582
+ "+ Add ",
3583
+ t.type,
3584
+ " block"
3585
+ ]
3586
+ },
3587
+ t.type
3588
+ )) }) : /* @__PURE__ */ jsx24(
3589
+ NewBlockRow,
3590
+ {
3591
+ onAdd: (type, label) => onChange([
3592
+ ...blocks,
3593
+ { type, labels: label ? [label] : [], attributes: [], blocks: [] }
3594
+ ])
3694
3595
  }
3695
- if (mode === "variable") {
3696
- return (localVariables[input.name] ?? "").trim().length > 0;
3596
+ ))
3597
+ ] });
3598
+ }
3599
+ function NewBlockRow({ onAdd }) {
3600
+ const [type, setType] = useState15("");
3601
+ const [label, setLabel] = useState15("");
3602
+ return /* @__PURE__ */ jsxs15("div", { className: "lace-panel-row-actions", children: [
3603
+ /* @__PURE__ */ jsx24(
3604
+ Input,
3605
+ {
3606
+ value: type,
3607
+ onChange: (e) => setType(e.target.value),
3608
+ placeholder: "Block type (e.g. lifecycle)",
3609
+ "aria-label": "New block type",
3610
+ mono: true
3697
3611
  }
3698
- if (mode === "expression") {
3699
- return (localExpressions[input.name] ?? "").trim().length > 0;
3612
+ ),
3613
+ /* @__PURE__ */ jsx24(
3614
+ Input,
3615
+ {
3616
+ value: label,
3617
+ onChange: (e) => setLabel(e.target.value),
3618
+ placeholder: "Label (optional)",
3619
+ "aria-label": "New block label",
3620
+ mono: true
3700
3621
  }
3701
- return false;
3702
- });
3703
- if (hasFilledRequired) {
3704
- onModified?.(instance_id);
3705
- }
3706
- onClose();
3707
- });
3708
- const handleDisconnect = async (inputName) => {
3709
- if (!editable) return;
3710
- const result = await runner.apply([
3711
- { disconnect: { scope: address.scope, target: address.id, input_name: inputName } }
3712
- ]);
3713
- if (!result?.success) return;
3714
- setLocalModes((prev) => ({ ...prev, [inputName]: "empty" }));
3715
- };
3716
- function renderModeSelector(input) {
3717
- const currentMode = localModes[input.name] ?? input.mode;
3718
- const isWired = currentMode === "wired";
3719
- const items = MODE_ITEMS.map((m) => ({
3720
- ...m,
3721
- disabled: !editable || m.value === "wired" || isWired
3722
- }));
3723
- return /* @__PURE__ */ jsx24(
3724
- ModeToggle,
3622
+ ),
3623
+ /* @__PURE__ */ jsx24(
3624
+ Button6,
3725
3625
  {
3726
- value: currentMode,
3727
- onChange: (next) => switchMode(input.name, next, input),
3728
- items,
3729
- "aria-label": `${input.name} binding mode`
3626
+ variant: "secondary",
3627
+ size: "sm",
3628
+ disabled: !type.trim(),
3629
+ onClick: () => {
3630
+ onAdd(type.trim(), label.trim());
3631
+ setType("");
3632
+ setLabel("");
3633
+ },
3634
+ children: "+ Add block"
3730
3635
  }
3731
- );
3732
- }
3733
- function renderInputField(input) {
3734
- const currentMode = localModes[input.name] ?? input.mode;
3735
- return /* @__PURE__ */ jsxs15("div", { className: "lace-panel-field", children: [
3736
- /* @__PURE__ */ jsxs15("label", { className: "lace-panel-row-label", children: [
3737
- /* @__PURE__ */ jsx24(Identifier, { text: input.name }),
3738
- input.required && /* @__PURE__ */ jsx24("span", { className: "lace-mcp__required-star", children: "*" })
3739
- ] }),
3740
- renderModeSelector(input),
3741
- /* @__PURE__ */ jsxs15("div", { className: "lace-panel-row-content", children: [
3742
- currentMode === "wired" && renderWiredEditor(input),
3743
- currentMode === "variable" && renderVariableEditor(input),
3744
- currentMode === "expression" && renderExpressionEditor(input),
3745
- currentMode === "literal" && renderLiteralEditor(input)
3746
- ] }),
3747
- input.description && /* @__PURE__ */ jsx24("div", { className: "lace-panel-field__description", children: input.description })
3748
- ] }, input.name);
3749
- }
3750
- function renderWiredEditor(input) {
3751
- const label = input.wired_source ?? "Not wired";
3752
- return /* @__PURE__ */ jsxs15("div", { className: "lace-mcp__wired-row", children: [
3753
- /* @__PURE__ */ jsx24("div", { className: "lace-mcp__wired-input", children: /* @__PURE__ */ jsx24(Input, { value: label, readOnly: true, fullWidth: true, mono: true }) }),
3636
+ )
3637
+ ] });
3638
+ }
3639
+ function BlockCard({ block, editable, onChange, onRemove }) {
3640
+ const setAttribute = (index, field, value) => onChange({
3641
+ ...block,
3642
+ attributes: replaceAt(block.attributes, index, {
3643
+ ...block.attributes[index],
3644
+ [field]: value
3645
+ })
3646
+ });
3647
+ return /* @__PURE__ */ jsxs15("div", { className: "lace-panel-validation-block", children: [
3648
+ /* @__PURE__ */ jsxs15("div", { className: "lace-panel-row-actions", children: [
3649
+ /* @__PURE__ */ jsx24(Identifier, { className: "lace-panel-row-card__name", text: blockTitle(block) }),
3754
3650
  editable && /* @__PURE__ */ jsx24(
3755
3651
  IconButton3,
3756
3652
  {
3757
3653
  icon: /* @__PURE__ */ jsx24(CanvasIcon, { name: "close" }),
3758
- "aria-label": "Disconnect this input",
3654
+ "aria-label": `Remove the ${block.type} block`,
3759
3655
  size: "md",
3760
3656
  tooltipPlacement: "bottom-end",
3761
- onClick: () => handleDisconnect(input.name)
3657
+ onClick: onRemove
3762
3658
  }
3763
3659
  )
3764
- ] });
3765
- }
3766
- function renderVariableEditor(input) {
3767
- const currentVar = localVariables[input.name] ?? input.variable ?? "";
3768
- return /* @__PURE__ */ jsx24(
3769
- Input,
3660
+ ] }),
3661
+ block.attributes.map((attribute, i) => (
3662
+ // biome-ignore lint/suspicious/noArrayIndexKey: attributes are positional; the render keeps their order
3663
+ /* @__PURE__ */ jsxs15("div", { className: "lace-panel-row-actions", children: [
3664
+ /* @__PURE__ */ jsx24(
3665
+ Input,
3666
+ {
3667
+ value: attribute.name,
3668
+ onChange: (e) => setAttribute(i, "name", e.target.value),
3669
+ placeholder: "Argument",
3670
+ "aria-label": `${block.type} argument name`,
3671
+ mono: true,
3672
+ readOnly: !editable
3673
+ }
3674
+ ),
3675
+ /* @__PURE__ */ jsx24(
3676
+ Input,
3677
+ {
3678
+ value: attribute.value,
3679
+ onChange: (e) => setAttribute(i, "value", e.target.value),
3680
+ placeholder: "Value",
3681
+ "aria-label": `${attribute.name || block.type} value`,
3682
+ mono: true,
3683
+ readOnly: !editable
3684
+ }
3685
+ ),
3686
+ editable && /* @__PURE__ */ jsx24(
3687
+ IconButton3,
3688
+ {
3689
+ icon: /* @__PURE__ */ jsx24(CanvasIcon, { name: "close" }),
3690
+ "aria-label": `Remove ${attribute.name || "the argument"}`,
3691
+ size: "md",
3692
+ tooltipPlacement: "bottom-end",
3693
+ onClick: () => onChange({ ...block, attributes: block.attributes.filter((_, j) => j !== i) })
3694
+ }
3695
+ )
3696
+ ] }, i)
3697
+ )),
3698
+ editable && /* @__PURE__ */ jsx24(
3699
+ Button6,
3770
3700
  {
3771
- value: currentVar,
3772
- onChange: (e) => {
3773
- const raw = e.target.value;
3774
- const name = raw.startsWith("var.") ? raw.slice(4) : raw;
3775
- setLocalVariables((prev) => ({ ...prev, [input.name]: name }));
3776
- },
3777
- placeholder: "e.g. region",
3778
- fullWidth: true,
3779
- mono: true,
3780
- readOnly: !editable
3781
- }
3782
- );
3783
- }
3784
- function renderExpressionEditor(input) {
3785
- const currentExpr = localExpressions[input.name] ?? input.expression ?? "";
3786
- return /* @__PURE__ */ jsx24(
3787
- Textarea,
3788
- {
3789
- value: currentExpr,
3790
- onChange: (e) => setLocalExpressions((prev) => ({ ...prev, [input.name]: e.target.value })),
3791
- rows: 3,
3792
- placeholder: 'e.g. join("-", [var.prefix, var.name])',
3793
- fullWidth: true,
3794
- mono: true,
3795
- readOnly: !editable
3796
- }
3797
- );
3798
- }
3799
- function renderLiteralEditor(input) {
3800
- const value = localValues[input.name] ?? input.value ?? input.default_value ?? null;
3801
- const type = input.type || "string";
3802
- const updateValue = (val) => {
3803
- setLocalValues((prev) => ({ ...prev, [input.name]: val }));
3804
- };
3805
- if (type === "bool") {
3806
- return /* @__PURE__ */ jsxs15(
3807
- "select",
3808
- {
3809
- className: "lace-mcp__select",
3810
- value: String(value ?? false),
3811
- onChange: (e) => updateValue(e.target.value === "true"),
3812
- disabled: !editable,
3813
- children: [
3814
- /* @__PURE__ */ jsx24("option", { value: "true", children: "True" }),
3815
- /* @__PURE__ */ jsx24("option", { value: "false", children: "False" })
3816
- ]
3817
- }
3818
- );
3819
- }
3820
- if (type === "number") {
3821
- return /* @__PURE__ */ jsx24(
3822
- Input,
3823
- {
3824
- type: "number",
3825
- value: String(value ?? ""),
3826
- onChange: (e) => updateValue(e.target.value === "" ? "" : Number(e.target.value)),
3827
- fullWidth: true,
3828
- readOnly: !editable
3829
- }
3830
- );
3831
- }
3832
- if (type.startsWith("list(") || type.startsWith("map(") || type.startsWith("set(") || type === "object" || type.startsWith("object(")) {
3833
- const jsonStr = typeof value === "string" ? value : JSON.stringify(value ?? null, null, 2);
3834
- return /* @__PURE__ */ jsx24(
3835
- Textarea,
3836
- {
3837
- value: jsonStr,
3838
- onChange: (e) => {
3839
- try {
3840
- updateValue(JSON.parse(e.target.value));
3841
- } catch {
3842
- updateValue(e.target.value);
3843
- }
3844
- },
3845
- rows: 4,
3846
- fullWidth: true,
3847
- mono: true,
3848
- readOnly: !editable
3849
- }
3850
- );
3851
- }
3852
- return /* @__PURE__ */ jsx24(
3853
- Input,
3854
- {
3855
- value: String(value ?? ""),
3856
- onChange: (e) => {
3857
- let v = e.target.value;
3858
- if (v.length >= 2 && (v[0] === '"' && v[v.length - 1] === '"' || v[0] === "'" && v[v.length - 1] === "'")) {
3859
- v = v.slice(1, -1);
3860
- }
3861
- updateValue(v);
3862
- },
3863
- fullWidth: true,
3864
- readOnly: !editable
3865
- }
3866
- );
3867
- }
3868
- if (!config) {
3869
- return /* @__PURE__ */ jsxs15(Panel2, { title: "Error", onClose, children: [
3870
- /* @__PURE__ */ jsxs15("div", { className: "lace-mcp__error-title", children: [
3871
- 'Failed to load configuration for "',
3872
- instance_id,
3873
- '":'
3874
- ] }),
3875
- /* @__PURE__ */ jsx24("div", { className: "lace-mcp__error-detail", children: "Instance not found in the current Bundle." })
3876
- ] });
3877
- }
3878
- const dependsOnCount = localDependsOn.size;
3879
- const title = /* @__PURE__ */ jsxs15("div", { className: "lace-mcp__title", children: [
3880
- /* @__PURE__ */ jsx24("div", { className: "lace-mcp__title-eyebrow", children: "Module" }),
3881
- /* @__PURE__ */ jsx24("h3", { className: "lace-mcp__title-id", children: /* @__PURE__ */ jsx24(Identifier, { text: instance_id }) })
3882
- ] });
3883
- const footer = editable ? /* @__PURE__ */ jsx24(UpdateButton, { status: updateStatus, label: "Update configuration", onClick: handleUpdate }) : void 0;
3884
- return /* @__PURE__ */ jsxs15(Panel2, { title, footer, flush: true, onClose, children: [
3885
- requiredInputs.length > 0 && /* @__PURE__ */ jsx24(AccordionSection, { title: "Required Inputs", defaultOpen: true, badge: `(${requiredInputs.length})`, children: requiredInputs.map(renderInputField) }),
3886
- optionalInputs.length > 0 && /* @__PURE__ */ jsx24(AccordionSection, { title: "Optional Inputs", defaultOpen: true, badge: `(${optionalInputs.length})`, children: optionalInputs.map(renderInputField) }),
3887
- config.sibling_ids.length > 0 && /* @__PURE__ */ jsxs15(
3888
- AccordionSection,
3889
- {
3890
- title: "Depends On",
3891
- badge: dependsOnCount > 0 ? `(${dependsOnCount})` : void 0,
3892
- children: [
3893
- /* @__PURE__ */ jsx24("div", { className: "lace-mcp__depends-hint", children: "Select sibling instances this module depends on." }),
3894
- config.sibling_ids.map((sibId) => {
3895
- const depKey = `module.${sibId}`;
3896
- return /* @__PURE__ */ jsxs15("label", { className: "lace-mcp__depends-item", children: [
3897
- /* @__PURE__ */ jsx24(
3898
- "input",
3899
- {
3900
- type: "checkbox",
3901
- className: "lace-mcp__depends-checkbox",
3902
- checked: localDependsOn.has(depKey),
3903
- disabled: !editable,
3904
- onChange: (e) => {
3905
- setLocalDependsOn((prev) => {
3906
- const next = new Set(prev);
3907
- if (e.target.checked) next.add(depKey);
3908
- else next.delete(depKey);
3909
- return next;
3910
- });
3911
- }
3912
- }
3913
- ),
3914
- /* @__PURE__ */ jsx24(Identifier, { className: "lace-mcp__depends-label", text: depKey })
3915
- ] }, sibId);
3916
- })
3917
- ]
3701
+ variant: "secondary",
3702
+ size: "sm",
3703
+ onClick: () => onChange({ ...block, attributes: [...block.attributes, { name: "", value: "" }] }),
3704
+ children: "+ Add argument"
3918
3705
  }
3919
3706
  ),
3920
- (localProviders.length > 0 || editable) && /* @__PURE__ */ jsxs15(
3921
- AccordionSection,
3707
+ (block.blocks.length > 0 || editable) && /* @__PURE__ */ jsx24(
3708
+ BlockEditor,
3922
3709
  {
3923
- title: "Providers",
3924
- badge: localProviders.length > 0 ? `(${localProviders.length})` : void 0,
3925
- children: [
3926
- /* @__PURE__ */ jsxs15("div", { className: "lace-mcp__depends-hint", children: [
3927
- "Map each child-local provider name to the root provider reference passed down (e.g.",
3928
- " ",
3929
- /* @__PURE__ */ jsx24("code", { children: "aws" }),
3930
- " \u2192 ",
3931
- /* @__PURE__ */ jsx24("code", { children: "aws.west" }),
3932
- ")."
3933
- ] }),
3934
- localProviders.map((row, i) => (
3935
- // biome-ignore lint/suspicious/noArrayIndexKey: rows are positional and freely editable
3936
- /* @__PURE__ */ jsxs15("div", { className: "lace-mcp__provider-row", children: [
3937
- /* @__PURE__ */ jsx24(
3938
- Input,
3939
- {
3940
- value: row.key,
3941
- onChange: (e) => setLocalProviders(
3942
- (prev) => prev.map((r, j) => j === i ? { ...r, key: e.target.value } : r)
3943
- ),
3944
- placeholder: "child local (e.g. aws)",
3945
- mono: true,
3946
- readOnly: !editable
3947
- }
3948
- ),
3949
- /* @__PURE__ */ jsx24("span", { className: "lace-mcp__provider-arrow", children: "=" }),
3950
- /* @__PURE__ */ jsx24(
3951
- Input,
3952
- {
3953
- value: row.value,
3954
- onChange: (e) => setLocalProviders(
3955
- (prev) => prev.map((r, j) => j === i ? { ...r, value: e.target.value } : r)
3956
- ),
3957
- placeholder: "root ref (e.g. aws.west)",
3958
- mono: true,
3959
- readOnly: !editable
3960
- }
3961
- ),
3962
- editable && /* @__PURE__ */ jsx24(
3963
- IconButton3,
3964
- {
3965
- icon: /* @__PURE__ */ jsx24(CanvasIcon, { name: "close" }),
3966
- "aria-label": "Remove this provider mapping",
3967
- size: "md",
3968
- tooltipPlacement: "bottom-end",
3969
- onClick: () => setLocalProviders((prev) => prev.filter((_, j) => j !== i))
3970
- }
3971
- )
3972
- ] }, i)
3973
- )),
3974
- editable && /* @__PURE__ */ jsx24(
3975
- Button6,
3976
- {
3977
- variant: "secondary",
3978
- size: "sm",
3979
- onClick: () => setLocalProviders((prev) => [...prev, { key: "", value: "" }]),
3980
- children: "Add provider mapping"
3981
- }
3982
- )
3983
- ]
3710
+ blocks: block.blocks,
3711
+ editable,
3712
+ onChange: (blocks) => onChange({ ...block, blocks })
3984
3713
  }
3985
- ),
3986
- config.outputs.length > 0 && /* @__PURE__ */ jsx24(AccordionSection, { title: "Outputs", badge: `(${config.outputs.length})`, children: config.outputs.map((o) => /* @__PURE__ */ jsxs15("div", { className: "lace-mcp__output-card", children: [
3987
- /* @__PURE__ */ jsxs15("div", { className: "lace-mcp__output-header", children: [
3988
- /* @__PURE__ */ jsx24(Identifier, { className: "lace-mcp__output-name", text: o.name }),
3989
- /* @__PURE__ */ jsx24(Identifier, { className: "lace-mcp__output-type", text: o.type ?? "" })
3990
- ] }),
3991
- o.description && /* @__PURE__ */ jsx24("div", { className: "lace-mcp__output-description", children: o.description }),
3992
- o.sensitive && /* @__PURE__ */ jsx24("div", { className: "lace-mcp__output-sensitive", children: "sensitive" })
3993
- ] }, o.name)) })
3714
+ )
3994
3715
  ] });
3995
3716
  }
3996
3717
 
3997
- // src/core/panels/module-config.ts
3998
- function ModuleConfigPanel2({ ctx }) {
3999
- const { setSelection } = useCanvas();
4000
- const instanceId = ctx.selection.nodes[0];
4001
- if (!instanceId) return null;
4002
- return createElement2(ModuleConfigPanel, {
4003
- instance_id: instanceId,
4004
- onClose: () => setSelection({ nodes: [], edge: null })
4005
- });
4006
- }
4007
- var moduleConfigPanel = {
4008
- id: "module-config",
4009
- title: "Module",
4010
- slot: "drawer",
4011
- requiredPorts: [],
4012
- requiredContext: ["selection.node"],
4013
- Component: ModuleConfigPanel2
4014
- };
4015
-
4016
- // src/core/panels/SourceRefusedBanner.tsx
4017
- import { jsx as jsx25 } from "react/jsx-runtime";
4018
- function SourceRefusedBanner() {
4019
- return /* @__PURE__ */ jsx25(
4020
- Banner,
4021
- {
4022
- severity: "error",
4023
- className: "lace-source-refused-banner",
4024
- message: "The canvas can't take this module's .tf, so editing, saving and generating are locked until it can; the Diagnostics tab says why."
4025
- }
4026
- );
4027
- }
4028
- var sourceRefusedPanel = {
4029
- id: "source-refused",
4030
- title: "Source refused",
4031
- slot: "banner",
4032
- requiredPorts: [],
4033
- requiredContext: ["sourceRefused"],
4034
- Component: SourceRefusedBanner
4035
- };
4036
-
4037
- // src/core/panels/settings.ts
4038
- import { IconButton as IconButton8 } from "@lace-cloud/ui";
4039
- import { createElement as createElement3 } from "react";
4040
-
4041
- // src/components/panels/UnifiedSettingsPanel.tsx
4042
- import { deriveSettingsConfig } from "@lace-cloud/proto";
4043
- import { Panel as Panel7 } from "@lace-cloud/ui";
4044
- import { useMemo as useMemo9 } from "react";
4045
-
4046
3718
  // src/components/panels/LocalsPanel.tsx
4047
- import { Button as Button7, IconButton as IconButton4, Input as Input2, ModeToggle as ModeToggle2, Panel as Panel3, Textarea as Textarea2 } from "@lace-cloud/ui";
4048
- import { useCallback as useCallback9, useState as useState16 } from "react";
3719
+ import { Button as Button7, IconButton as IconButton4, Input as Input2, Panel as Panel2, Textarea } from "@lace-cloud/ui";
3720
+ import { useCallback as useCallback8, useState as useState16 } from "react";
4049
3721
 
4050
3722
  // src/utils/duplicates.ts
4051
3723
  function findDuplicateIndices(items, keyFn) {
@@ -4065,79 +3737,53 @@ function findDuplicateIndices(items, keyFn) {
4065
3737
 
4066
3738
  // src/components/panels/LocalsPanel.tsx
4067
3739
  import "./panels-shared-5JFNYXQ7.css";
4068
- import { Fragment as Fragment6, jsx as jsx26, jsxs as jsxs16 } from "react/jsx-runtime";
3740
+ import { Fragment as Fragment7, jsx as jsx25, jsxs as jsxs16 } from "react/jsx-runtime";
4069
3741
  function toRows(locals) {
4070
- if (!locals) return [];
4071
- return locals.map((l) => ({
4072
- id: crypto.randomUUID(),
4073
- name: l.name,
4074
- mode: l.mode === "expression" ? "expression" : "literal",
4075
- litValue: l.mode !== "expression" ? l.value_display : "",
4076
- exprValue: l.mode === "expression" ? l.value_display : ""
4077
- }));
3742
+ return (locals ?? []).map((l) => ({ id: crypto.randomUUID(), ...l }));
4078
3743
  }
4079
3744
  function fromRows(rows) {
4080
- return rows.filter((r) => r.name.trim()).map((r) => ({
4081
- name: r.name.trim(),
4082
- mode: r.mode,
4083
- value_display: r.mode === "expression" ? r.exprValue : r.litValue
4084
- }));
3745
+ return rows.filter((r) => r.name.trim()).map((r) => ({ name: r.name.trim(), value: r.value }));
4085
3746
  }
4086
- var BINDING_MODE_ITEMS = [
4087
- { value: "literal", label: "Literal" },
4088
- { value: "expression", label: "Expression" }
4089
- ];
4090
3747
  function LocalsContent({ locals, onSave }) {
4091
3748
  const { editable } = useCanvas();
4092
3749
  const [rows, setRows] = useState16(() => toRows(locals));
4093
- const addLocal = useCallback9(() => {
4094
- setRows((prev) => [
4095
- ...prev,
4096
- { id: crypto.randomUUID(), name: "", mode: "literal", litValue: "", exprValue: "" }
4097
- ]);
3750
+ const addLocal = useCallback8(() => {
3751
+ setRows((prev) => [...prev, { id: crypto.randomUUID(), name: "", value: "" }]);
4098
3752
  }, []);
4099
- const removeLocal = useCallback9((index) => {
3753
+ const removeLocal = useCallback8((index) => {
4100
3754
  setRows((prev) => prev.filter((_, i) => i !== index));
4101
3755
  }, []);
4102
- const updateName = useCallback9((index, name) => {
4103
- setRows((prev) => prev.map((r, i) => i === index ? { ...r, name } : r));
4104
- }, []);
4105
- const switchMode = useCallback9((index, mode) => {
4106
- setRows((prev) => prev.map((r, i) => i === index ? { ...r, mode } : r));
4107
- }, []);
4108
- const updateLitValue = useCallback9((index, litValue) => {
4109
- setRows((prev) => prev.map((r, i) => i === index ? { ...r, litValue } : r));
4110
- }, []);
4111
- const updateExprValue = useCallback9((index, exprValue) => {
4112
- setRows((prev) => prev.map((r, i) => i === index ? { ...r, exprValue } : r));
3756
+ const updateRow = useCallback8((index, field, value) => {
3757
+ setRows((prev) => prev.map((r, i) => i === index ? { ...r, [field]: value } : r));
4113
3758
  }, []);
4114
3759
  const nameDupes = findDuplicateIndices(rows, (r) => r.name);
4115
3760
  const hasErrors = nameDupes.size > 0;
4116
3761
  const { status: updateStatus, handleUpdate } = useUpdateState(
4117
- useCallback9(async () => {
3762
+ useCallback8(async () => {
4118
3763
  if (hasErrors) return;
4119
3764
  await onSave(fromRows(rows));
4120
3765
  }, [onSave, rows, hasErrors])
4121
3766
  );
4122
- return /* @__PURE__ */ jsxs16(Fragment6, { children: [
3767
+ return /* @__PURE__ */ jsxs16(Fragment7, { children: [
4123
3768
  rows.map((row, i) => /* @__PURE__ */ jsxs16("div", { className: "lace-panel-row-card lace-panel-row-card--with-footer", children: [
4124
3769
  /* @__PURE__ */ jsxs16("div", { className: "lace-panel-row-actions", children: [
4125
- /* @__PURE__ */ jsx26(
3770
+ /* @__PURE__ */ jsx25(
4126
3771
  Input2,
4127
3772
  {
4128
3773
  value: row.name,
4129
- onChange: (e) => updateName(i, e.target.value),
3774
+ onChange: (e) => updateRow(i, "name", e.target.value),
4130
3775
  placeholder: "Local name",
3776
+ "aria-label": "Local name",
4131
3777
  fullWidth: true,
4132
3778
  mono: true,
4133
3779
  error: nameDupes.has(i),
4134
3780
  readOnly: !editable
4135
3781
  }
4136
3782
  ),
4137
- editable && /* @__PURE__ */ jsx26(
3783
+ editable && /* @__PURE__ */ jsx25(
4138
3784
  IconButton4,
4139
3785
  {
4140
- icon: /* @__PURE__ */ jsx26(CanvasIcon, { name: "close" }),
3786
+ icon: /* @__PURE__ */ jsx25(CanvasIcon, { name: "close" }),
4141
3787
  "aria-label": "Remove local",
4142
3788
  size: "md",
4143
3789
  tooltipPlacement: "bottom-end",
@@ -4145,33 +3791,14 @@ function LocalsContent({ locals, onSave }) {
4145
3791
  }
4146
3792
  )
4147
3793
  ] }),
4148
- nameDupes.has(i) && /* @__PURE__ */ jsx26("div", { className: "lace-panel-row-error", children: "Duplicate local name" }),
4149
- /* @__PURE__ */ jsx26("div", { className: "lace-panel-row-actions", children: /* @__PURE__ */ jsx26(
4150
- ModeToggle2,
4151
- {
4152
- value: row.mode,
4153
- onChange: (next) => switchMode(i, next),
4154
- items: BINDING_MODE_ITEMS.map((it) => ({ ...it, disabled: !editable })),
4155
- "aria-label": "Local binding mode"
4156
- }
4157
- ) }),
4158
- /* @__PURE__ */ jsx26("div", { className: "lace-panel-row-content", children: row.mode === "literal" ? /* @__PURE__ */ jsx26(
4159
- Textarea2,
4160
- {
4161
- value: row.litValue,
4162
- onChange: (e) => updateLitValue(i, e.target.value),
4163
- placeholder: 'e.g. "my-bucket" or {"key": "value"}',
4164
- rows: 3,
4165
- fullWidth: true,
4166
- mono: true,
4167
- readOnly: !editable
4168
- }
4169
- ) : /* @__PURE__ */ jsx26(
4170
- Textarea2,
3794
+ nameDupes.has(i) && /* @__PURE__ */ jsx25("div", { className: "lace-panel-row-error", children: "Duplicate local name" }),
3795
+ /* @__PURE__ */ jsx25("div", { className: "lace-panel-row-content", children: /* @__PURE__ */ jsx25(
3796
+ Textarea,
4171
3797
  {
4172
- value: row.exprValue,
4173
- onChange: (e) => updateExprValue(i, e.target.value),
4174
- placeholder: 'e.g. "${var.environment}-${var.role_name}"',
3798
+ value: row.value,
3799
+ onChange: (e) => updateRow(i, "value", e.target.value),
3800
+ placeholder: 'e.g. "my-bucket" or "${var.environment}-logs"',
3801
+ "aria-label": `${row.name || "Local"} value`,
4175
3802
  rows: 3,
4176
3803
  fullWidth: true,
4177
3804
  mono: true,
@@ -4179,9 +3806,9 @@ function LocalsContent({ locals, onSave }) {
4179
3806
  }
4180
3807
  ) })
4181
3808
  ] }, row.id)),
4182
- editable && /* @__PURE__ */ jsxs16(Fragment6, { children: [
4183
- /* @__PURE__ */ jsx26(Button7, { variant: "secondary", size: "sm", onClick: addLocal, children: "+ Add local" }),
4184
- /* @__PURE__ */ jsx26(
3809
+ editable && /* @__PURE__ */ jsxs16(Fragment7, { children: [
3810
+ /* @__PURE__ */ jsx25(Button7, { variant: "secondary", size: "sm", onClick: addLocal, children: "+ Add local" }),
3811
+ /* @__PURE__ */ jsx25(
4185
3812
  UpdateButton,
4186
3813
  {
4187
3814
  status: updateStatus,
@@ -4195,22 +3822,24 @@ function LocalsContent({ locals, onSave }) {
4195
3822
  ] });
4196
3823
  }
4197
3824
  function LocalsPanel({ locals, onSave, onClose }) {
4198
- return /* @__PURE__ */ jsx26(Panel3, { title: "Locals", onClose, children: /* @__PURE__ */ jsx26(LocalsContent, { locals, onSave }) });
3825
+ return /* @__PURE__ */ jsx25(Panel2, { title: "Locals", onClose, children: /* @__PURE__ */ jsx25(LocalsContent, { locals, onSave }) });
4199
3826
  }
4200
3827
 
4201
3828
  // src/components/panels/ModuleInterfacePanel.tsx
4202
- import { Button as Button8, IconButton as IconButton5, Input as Input3, Panel as Panel4, Textarea as Textarea3 } from "@lace-cloud/ui";
4203
- import { useCallback as useCallback10, useMemo as useMemo8, useState as useState17 } from "react";
3829
+ import { Button as Button8, IconButton as IconButton5, Input as Input3, Panel as Panel3, Select, Textarea as Textarea2 } from "@lace-cloud/ui";
3830
+ import { useCallback as useCallback9, useState as useState17 } from "react";
4204
3831
  import "./panels-shared-5JFNYXQ7.css";
4205
- import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs17 } from "react/jsx-runtime";
3832
+ import { Fragment as Fragment8, jsx as jsx26, jsxs as jsxs17 } from "react/jsx-runtime";
4206
3833
  function variablesToRows(variables) {
4207
3834
  return variables.map((v) => ({
4208
3835
  id: crypto.randomUUID(),
4209
3836
  name: v.name,
3837
+ added: false,
4210
3838
  type: v.type,
4211
3839
  required: v.required,
4212
3840
  description: v.description ?? "",
4213
3841
  default_value: v.default_value,
3842
+ defaultText: v.default,
4214
3843
  validation: (v.validation ?? []).map((b) => ({
4215
3844
  id: crypto.randomUUID(),
4216
3845
  condition: b.condition,
@@ -4223,70 +3852,53 @@ function variablesToRows(variables) {
4223
3852
  nullable: v.nullable ?? true
4224
3853
  }));
4225
3854
  }
4226
- function buildOutputRows(view, exports, outputDefs) {
4227
- if (!view) return [];
4228
- const exposedByKey = /* @__PURE__ */ new Map();
4229
- for (const e of exports) {
4230
- exposedByKey.set(`${e.source_instance}|${e.source_output}`, { name: e.name });
4231
- }
4232
- const dependsOnByName = /* @__PURE__ */ new Map();
4233
- for (const d of outputDefs) {
4234
- if (d.depends_on && d.depends_on.length > 0) dependsOnByName.set(d.name, d.depends_on);
4235
- }
4236
- const sources = [];
4237
- for (const node of view.nodes) {
4238
- if (node.outputs.length > 0) sources.push({ id: node.id, outputs: node.outputs });
4239
- }
4240
- for (const group2 of view.groups) {
4241
- if (group2.outputs && group2.outputs.length > 0) {
4242
- sources.push({ id: group2.id, outputs: group2.outputs });
4243
- }
4244
- }
4245
- const rows = [];
4246
- for (const src of sources) {
4247
- for (const out of src.outputs) {
4248
- const key = `${src.id}|${out.name}`;
4249
- const exposed = exposedByKey.get(key);
4250
- const exposedName = exposed?.name ?? out.name;
4251
- rows.push({
4252
- id: crypto.randomUUID(),
4253
- source_instance: src.id,
4254
- source_output: out.name,
4255
- type: out.type,
4256
- description: out.description ?? "",
4257
- sensitive: out.sensitive ?? false,
4258
- exposed: Boolean(exposed),
4259
- exposed_name: exposedName,
4260
- depends_on: exposed ? dependsOnByName.get(exposedName) ?? [] : []
4261
- });
4262
- }
4263
- }
4264
- return rows;
3855
+ function outputsToRows(outputs) {
3856
+ return outputs.map((o) => ({
3857
+ id: crypto.randomUUID(),
3858
+ name: o.name,
3859
+ value: o.value,
3860
+ description: o.description ?? "",
3861
+ sensitive: o.sensitive ?? false,
3862
+ depends_on: o.depends_on ?? []
3863
+ }));
4265
3864
  }
4266
- function ModuleInterfaceContent({
4267
- settings,
4268
- view,
4269
- onSaveVariables,
4270
- onSaveExports
4271
- }) {
3865
+ function outputName(text) {
3866
+ return text.slice(text.lastIndexOf(".") + 1);
3867
+ }
3868
+ function ModuleInterfaceContent({ settings, onSave }) {
4272
3869
  const { editable } = useCanvas();
4273
- const [variables, setVariables] = useState17(
3870
+ const [variables, setVariables2] = useState17(
4274
3871
  () => variablesToRows(settings.variables)
4275
3872
  );
4276
- const [outputs, setOutputs] = useState17(
4277
- () => buildOutputRows(view, settings.exports, settings.output_defs)
4278
- );
4279
- const siblingModuleKeys = useMemo8(() => (view?.nodes ?? []).map((n) => `module.${n.id}`), [view]);
4280
- const updateVariable = useCallback10(
3873
+ const [outputs, setOutputs2] = useState17(() => outputsToRows(settings.outputs));
3874
+ const updateVariable = useCallback9(
4281
3875
  (index, field, value) => {
4282
- setVariables((prev) => prev.map((v, i) => i === index ? { ...v, [field]: value } : v));
3876
+ setVariables2((prev) => prev.map((v, i) => i === index ? { ...v, [field]: value } : v));
4283
3877
  },
4284
3878
  []
4285
3879
  );
4286
- const addValidation = useCallback10((index) => {
4287
- setVariables(
4288
- (prev) => prev.map(
4289
- (v, i) => i === index ? {
3880
+ const addVariable = useCallback9(() => {
3881
+ setVariables2((prev) => [
3882
+ ...prev,
3883
+ {
3884
+ id: crypto.randomUUID(),
3885
+ name: "",
3886
+ added: true,
3887
+ type: "",
3888
+ required: true,
3889
+ description: "",
3890
+ defaultText: "",
3891
+ validation: [],
3892
+ ephemeral: false,
3893
+ sensitive: false,
3894
+ nullable: true
3895
+ }
3896
+ ]);
3897
+ }, []);
3898
+ const addValidation = useCallback9((index) => {
3899
+ setVariables2(
3900
+ (prev) => prev.map(
3901
+ (v, i) => i === index ? {
4290
3902
  ...v,
4291
3903
  validation: [
4292
3904
  ...v.validation,
@@ -4296,16 +3908,16 @@ function ModuleInterfaceContent({
4296
3908
  )
4297
3909
  );
4298
3910
  }, []);
4299
- const removeValidation = useCallback10((index, vIndex) => {
4300
- setVariables(
3911
+ const removeValidation = useCallback9((index, vIndex) => {
3912
+ setVariables2(
4301
3913
  (prev) => prev.map(
4302
3914
  (v, i) => i === index ? { ...v, validation: v.validation.filter((_, j) => j !== vIndex) } : v
4303
3915
  )
4304
3916
  );
4305
3917
  }, []);
4306
- const updateValidation = useCallback10(
3918
+ const updateValidation = useCallback9(
4307
3919
  (index, vIndex, field, value) => {
4308
- setVariables(
3920
+ setVariables2(
4309
3921
  (prev) => prev.map(
4310
3922
  (v, i) => i === index ? {
4311
3923
  ...v,
@@ -4318,117 +3930,111 @@ function ModuleInterfaceContent({
4318
3930
  },
4319
3931
  []
4320
3932
  );
4321
- const toggleExposed = useCallback10((index) => {
4322
- setOutputs((prev) => prev.map((o, i) => i === index ? { ...o, exposed: !o.exposed } : o));
4323
- }, []);
4324
- const updateExposedName = useCallback10((index, value) => {
4325
- setOutputs((prev) => prev.map((o, i) => i === index ? { ...o, exposed_name: value } : o));
3933
+ const updateOutput = useCallback9(
3934
+ (index, field, value) => {
3935
+ setOutputs2((prev) => prev.map((o, i) => i === index ? { ...o, [field]: value } : o));
3936
+ },
3937
+ []
3938
+ );
3939
+ const addOutput = useCallback9((name, value) => {
3940
+ setOutputs2((prev) => [
3941
+ ...prev,
3942
+ { id: crypto.randomUUID(), name, value, description: "", sensitive: false, depends_on: [] }
3943
+ ]);
4326
3944
  }, []);
4327
- const toggleDependsOn = useCallback10((index, depKey) => {
4328
- setOutputs(
3945
+ const toggleDependsOn = useCallback9((index, dep) => {
3946
+ setOutputs2(
4329
3947
  (prev) => prev.map((o, i) => {
4330
3948
  if (i !== index) return o;
4331
- const has = o.depends_on.includes(depKey);
3949
+ const has = o.depends_on.includes(dep);
4332
3950
  return {
4333
3951
  ...o,
4334
- depends_on: has ? o.depends_on.filter((k) => k !== depKey) : [...o.depends_on, depKey]
3952
+ depends_on: has ? o.depends_on.filter((k) => k !== dep) : [...o.depends_on, dep]
4335
3953
  };
4336
3954
  })
4337
3955
  );
4338
3956
  }, []);
4339
- const exposedNameCollisions = useMemo8(() => {
4340
- const counts = /* @__PURE__ */ new Map();
4341
- for (const o of outputs) {
4342
- if (!o.exposed) continue;
4343
- const name = o.exposed_name.trim();
4344
- if (!name) continue;
4345
- counts.set(name, (counts.get(name) ?? 0) + 1);
4346
- }
4347
- const dupes = /* @__PURE__ */ new Set();
4348
- outputs.forEach((o, i) => {
4349
- if (!o.exposed) return;
4350
- const name = o.exposed_name.trim();
4351
- if (!name) {
4352
- dupes.add(i);
4353
- return;
4354
- }
4355
- if ((counts.get(name) ?? 0) > 1) dupes.add(i);
4356
- });
4357
- return dupes;
4358
- }, [outputs]);
4359
- const hasErrors = exposedNameCollisions.size > 0;
3957
+ const variableDupes = findDuplicateIndices(variables, (v) => v.name);
3958
+ const outputDupes = findDuplicateIndices(outputs, (o) => o.name);
3959
+ const unnamedOutput = outputs.some((o) => !o.name.trim() || !o.value.trim());
3960
+ const hasErrors = variableDupes.size > 0 || outputDupes.size > 0 || unnamedOutput;
4360
3961
  const { status: updateStatus, handleUpdate } = useUpdateState(
4361
- useCallback10(async () => {
3962
+ useCallback9(async () => {
4362
3963
  if (hasErrors) return;
4363
3964
  const variableDefs = variables.filter((v) => v.name.trim()).map((v) => {
4364
3965
  const validation = v.validation.map((b) => ({ condition: b.condition.trim(), error_message: b.error_message.trim() })).filter((b) => b.condition || b.error_message);
4365
3966
  return {
4366
3967
  name: v.name.trim(),
4367
- type: v.type.trim() || "string",
3968
+ type: v.type.trim(),
4368
3969
  required: v.required,
4369
3970
  description: v.description.trim() || void 0,
4370
3971
  default: v.default_value,
4371
3972
  validation: validation.length > 0 ? validation : void 0,
4372
3973
  ephemeral: v.ephemeral || void 0,
4373
- // Send `false` (not undefined) so turning sensitive OFF actually
4374
- // clears the stored flag — the settings tier assigns wholesale
4375
- // (#849). An omitted value would default back to false at the
4376
- // mapper, which is the same effect, but being explicit documents
4377
- // that OFF is authorable.
3974
+ // `false` turns sensitive off: the variables are set whole.
4378
3975
  sensitive: v.sensitive,
4379
3976
  // `nullable` is tri-state on the wire (unset = default true). The
4380
- // toggle ON preserves the default by omitting the field; OFF
4381
- // authors an explicit `false`.
3977
+ // toggle ON keeps the default by omitting the field; OFF authors
3978
+ // an explicit `false`.
4382
3979
  nullable: v.nullable ? void 0 : false
4383
3980
  };
4384
3981
  });
4385
- const exportDefs = [];
4386
- const outputDefs = [];
4387
- for (const o of outputs) {
4388
- if (!o.exposed) continue;
4389
- const name = o.exposed_name.trim();
4390
- if (!name) continue;
4391
- exportDefs.push({
4392
- name,
4393
- source_instance: o.source_instance,
4394
- source_output: o.source_output
4395
- });
4396
- outputDefs.push({
4397
- name,
4398
- type: o.type,
4399
- description: o.description || void 0,
4400
- sensitive: o.sensitive || void 0,
4401
- depends_on: o.depends_on.length > 0 ? o.depends_on : void 0
4402
- });
4403
- }
4404
- await onSaveVariables(variableDefs);
4405
- await onSaveExports(exportDefs, outputDefs);
4406
- }, [variables, outputs, hasErrors, onSaveVariables, onSaveExports])
3982
+ const outputDefs = outputs.map((o) => ({
3983
+ name: o.name.trim(),
3984
+ value: o.value,
3985
+ description: o.description || void 0,
3986
+ sensitive: o.sensitive || void 0,
3987
+ depends_on: o.depends_on.length > 0 ? o.depends_on : void 0
3988
+ }));
3989
+ await onSave(variableDefs, outputDefs);
3990
+ }, [variables, outputs, hasErrors, onSave])
4407
3991
  );
4408
- return /* @__PURE__ */ jsxs17(Fragment7, { children: [
4409
- /* @__PURE__ */ jsx27("div", { className: "lace-panel-hint", children: "The composition's public surface \u2014 what the registry sees when this module is published." }),
4410
- /* @__PURE__ */ jsx27("h4", { className: "lace-panel-section-title", children: "Inputs" }),
4411
- variables.length === 0 ? /* @__PURE__ */ jsxs17("div", { className: "lace-panel-hint", children: [
4412
- "No variables yet. They'll auto-derive on the next Generate from any ",
4413
- /* @__PURE__ */ jsx27("code", { children: "var.xxx" }),
4414
- " ",
4415
- "references in child input bindings."
4416
- ] }) : variables.map((v, i) => /* @__PURE__ */ jsxs17("div", { className: "lace-panel-row-card lace-panel-row-card--with-footer", children: [
4417
- /* @__PURE__ */ jsx27(Identifier, { className: "lace-panel-row-card__name", text: v.name }),
4418
- /* @__PURE__ */ jsx27("div", { className: "lace-panel-row-actions", children: /* @__PURE__ */ jsx27(
3992
+ const exposable = settings.call_outputs.filter((text) => !outputs.some((o) => o.value === text));
3993
+ return /* @__PURE__ */ jsxs17(Fragment8, { children: [
3994
+ /* @__PURE__ */ jsx26("div", { className: "lace-panel-hint", children: "The module's public surface: the variables its callers set and the outputs they read." }),
3995
+ /* @__PURE__ */ jsx26("h4", { className: "lace-panel-section-title", children: "Inputs" }),
3996
+ variables.length === 0 && /* @__PURE__ */ jsx26("div", { className: "lace-panel-hint", children: "No variables." }),
3997
+ variables.map((v, i) => /* @__PURE__ */ jsxs17("div", { className: "lace-panel-row-card lace-panel-row-card--with-footer", children: [
3998
+ /* @__PURE__ */ jsxs17("div", { className: "lace-panel-row-actions", children: [
3999
+ v.added ? /* @__PURE__ */ jsx26(
4000
+ Input3,
4001
+ {
4002
+ label: "Name",
4003
+ value: v.name,
4004
+ onChange: (e) => updateVariable(i, "name", e.target.value),
4005
+ placeholder: "Variable name",
4006
+ fullWidth: true,
4007
+ mono: true,
4008
+ error: variableDupes.has(i)
4009
+ }
4010
+ ) : /* @__PURE__ */ jsx26(Identifier, { className: "lace-panel-row-card__name", text: v.name }),
4011
+ editable && /* @__PURE__ */ jsx26(
4012
+ IconButton5,
4013
+ {
4014
+ icon: /* @__PURE__ */ jsx26(CanvasIcon, { name: "close" }),
4015
+ "aria-label": `Remove variable ${v.name}`,
4016
+ size: "md",
4017
+ tooltipPlacement: "bottom-end",
4018
+ onClick: () => setVariables2((prev) => prev.filter((_, j) => j !== i))
4019
+ }
4020
+ )
4021
+ ] }),
4022
+ variableDupes.has(i) && /* @__PURE__ */ jsx26("div", { className: "lace-panel-row-error", children: "Duplicate variable name" }),
4023
+ /* @__PURE__ */ jsx26("div", { className: "lace-panel-row-actions", children: /* @__PURE__ */ jsx26(
4419
4024
  Input3,
4420
4025
  {
4421
4026
  label: "Type",
4422
4027
  value: v.type,
4423
4028
  onChange: (e) => updateVariable(i, "type", e.target.value),
4424
- placeholder: "string, number, list(string)\u2026",
4029
+ placeholder: "No declared type",
4425
4030
  fullWidth: true,
4426
4031
  mono: true,
4427
4032
  readOnly: !editable
4428
4033
  }
4429
4034
  ) }),
4430
- /* @__PURE__ */ jsx27("div", { className: "lace-panel-row-content", children: /* @__PURE__ */ jsx27(
4431
- Textarea3,
4035
+ v.defaultText && /* @__PURE__ */ jsx26("div", { className: "lace-panel-row-actions", children: /* @__PURE__ */ jsx26(Input3, { label: "Default", value: v.defaultText, fullWidth: true, mono: true, readOnly: true }) }),
4036
+ /* @__PURE__ */ jsx26("div", { className: "lace-panel-row-content", children: /* @__PURE__ */ jsx26(
4037
+ Textarea2,
4432
4038
  {
4433
4039
  label: "Description",
4434
4040
  value: v.description,
@@ -4441,7 +4047,7 @@ function ModuleInterfaceContent({
4441
4047
  ) }),
4442
4048
  /* @__PURE__ */ jsxs17("div", { className: "lace-panel-row-actions", children: [
4443
4049
  /* @__PURE__ */ jsxs17("label", { className: "lace-panel-checkbox-row", children: [
4444
- /* @__PURE__ */ jsx27(
4050
+ /* @__PURE__ */ jsx26(
4445
4051
  "input",
4446
4052
  {
4447
4053
  type: "checkbox",
@@ -4450,10 +4056,10 @@ function ModuleInterfaceContent({
4450
4056
  disabled: !editable
4451
4057
  }
4452
4058
  ),
4453
- /* @__PURE__ */ jsx27("span", { children: "Required" })
4059
+ /* @__PURE__ */ jsx26("span", { children: "Required" })
4454
4060
  ] }),
4455
4061
  /* @__PURE__ */ jsxs17("label", { className: "lace-panel-checkbox-row", children: [
4456
- /* @__PURE__ */ jsx27(
4062
+ /* @__PURE__ */ jsx26(
4457
4063
  "input",
4458
4064
  {
4459
4065
  type: "checkbox",
@@ -4462,10 +4068,10 @@ function ModuleInterfaceContent({
4462
4068
  disabled: !editable
4463
4069
  }
4464
4070
  ),
4465
- /* @__PURE__ */ jsx27("span", { children: "Ephemeral" })
4071
+ /* @__PURE__ */ jsx26("span", { children: "Ephemeral" })
4466
4072
  ] }),
4467
4073
  /* @__PURE__ */ jsxs17("label", { className: "lace-panel-checkbox-row", children: [
4468
- /* @__PURE__ */ jsx27(
4074
+ /* @__PURE__ */ jsx26(
4469
4075
  "input",
4470
4076
  {
4471
4077
  type: "checkbox",
@@ -4474,10 +4080,10 @@ function ModuleInterfaceContent({
4474
4080
  disabled: !editable
4475
4081
  }
4476
4082
  ),
4477
- /* @__PURE__ */ jsx27("span", { children: "Sensitive" })
4083
+ /* @__PURE__ */ jsx26("span", { children: "Sensitive" })
4478
4084
  ] }),
4479
4085
  /* @__PURE__ */ jsxs17("label", { className: "lace-panel-checkbox-row", children: [
4480
- /* @__PURE__ */ jsx27(
4086
+ /* @__PURE__ */ jsx26(
4481
4087
  "input",
4482
4088
  {
4483
4089
  type: "checkbox",
@@ -4486,13 +4092,13 @@ function ModuleInterfaceContent({
4486
4092
  disabled: !editable
4487
4093
  }
4488
4094
  ),
4489
- /* @__PURE__ */ jsx27("span", { children: "Nullable" })
4095
+ /* @__PURE__ */ jsx26("span", { children: "Nullable" })
4490
4096
  ] })
4491
4097
  ] }),
4492
4098
  (v.validation.length > 0 || editable) && /* @__PURE__ */ jsxs17("div", { className: "lace-panel-row-content", children: [
4493
- /* @__PURE__ */ jsx27("div", { className: "lace-panel-subsection-label", children: "Validation" }),
4099
+ /* @__PURE__ */ jsx26("div", { className: "lace-panel-subsection-label", children: "Validation" }),
4494
4100
  v.validation.map((block, j) => /* @__PURE__ */ jsxs17("div", { className: "lace-panel-validation-block", children: [
4495
- /* @__PURE__ */ jsx27(
4101
+ /* @__PURE__ */ jsx26(
4496
4102
  Input3,
4497
4103
  {
4498
4104
  value: block.condition,
@@ -4504,7 +4110,7 @@ function ModuleInterfaceContent({
4504
4110
  readOnly: !editable
4505
4111
  }
4506
4112
  ),
4507
- /* @__PURE__ */ jsx27(
4113
+ /* @__PURE__ */ jsx26(
4508
4114
  Input3,
4509
4115
  {
4510
4116
  value: block.error_message,
@@ -4515,10 +4121,10 @@ function ModuleInterfaceContent({
4515
4121
  readOnly: !editable
4516
4122
  }
4517
4123
  ),
4518
- editable && /* @__PURE__ */ jsx27(
4124
+ editable && /* @__PURE__ */ jsx26(
4519
4125
  IconButton5,
4520
4126
  {
4521
- icon: /* @__PURE__ */ jsx27(CanvasIcon, { name: "close" }),
4127
+ icon: /* @__PURE__ */ jsx26(CanvasIcon, { name: "close" }),
4522
4128
  "aria-label": "Remove validation rule",
4523
4129
  size: "md",
4524
4130
  tooltipPlacement: "bottom-end",
@@ -4526,90 +4132,243 @@ function ModuleInterfaceContent({
4526
4132
  }
4527
4133
  )
4528
4134
  ] }, block.id)),
4529
- editable && /* @__PURE__ */ jsx27(Button8, { variant: "secondary", size: "sm", onClick: () => addValidation(i), children: "+ Add validation rule" })
4135
+ editable && /* @__PURE__ */ jsx26(Button8, { variant: "secondary", size: "sm", onClick: () => addValidation(i), children: "+ Add validation rule" })
4530
4136
  ] })
4531
4137
  ] }, v.id)),
4532
- /* @__PURE__ */ jsx27("h4", { className: "lace-panel-section-title", children: "Outputs" }),
4533
- outputs.length === 0 ? /* @__PURE__ */ jsx27("div", { className: "lace-panel-hint", children: "No child outputs available yet. Drop a module onto the canvas to see its outputs here." }) : outputs.map((o, i) => /* @__PURE__ */ jsxs17("div", { className: "lace-panel-row-card lace-panel-row-card--with-footer", children: [
4534
- /* @__PURE__ */ jsx27("div", { className: "lace-panel-row-actions", children: /* @__PURE__ */ jsxs17("label", { className: "lace-panel-checkbox-row", children: [
4535
- /* @__PURE__ */ jsx27(
4536
- "input",
4138
+ editable && /* @__PURE__ */ jsx26(Button8, { variant: "secondary", size: "sm", onClick: addVariable, children: "+ Add variable" }),
4139
+ /* @__PURE__ */ jsx26("h4", { className: "lace-panel-section-title", children: "Outputs" }),
4140
+ outputs.length === 0 && /* @__PURE__ */ jsx26("div", { className: "lace-panel-hint", children: "No outputs." }),
4141
+ outputs.map((o, i) => /* @__PURE__ */ jsxs17("div", { className: "lace-panel-row-card lace-panel-row-card--with-footer", children: [
4142
+ /* @__PURE__ */ jsxs17("div", { className: "lace-panel-row-actions", children: [
4143
+ /* @__PURE__ */ jsx26(
4144
+ Input3,
4537
4145
  {
4538
- type: "checkbox",
4539
- checked: o.exposed,
4540
- onChange: () => toggleExposed(i),
4541
- disabled: !editable
4146
+ label: "Name",
4147
+ value: o.name,
4148
+ onChange: (e) => updateOutput(i, "name", e.target.value),
4149
+ placeholder: "Output name",
4150
+ fullWidth: true,
4151
+ mono: true,
4152
+ readOnly: !editable,
4153
+ error: outputDupes.has(i) || editable && !o.name.trim()
4542
4154
  }
4543
4155
  ),
4544
- /* @__PURE__ */ jsx27(Identifier, { text: `${o.source_instance}.${o.source_output}` })
4545
- ] }) }),
4546
- o.exposed ? /* @__PURE__ */ jsx27("div", { className: "lace-panel-row-actions", children: /* @__PURE__ */ jsx27(
4156
+ editable && /* @__PURE__ */ jsx26(
4157
+ IconButton5,
4158
+ {
4159
+ icon: /* @__PURE__ */ jsx26(CanvasIcon, { name: "close" }),
4160
+ "aria-label": `Remove output ${o.name}`,
4161
+ size: "md",
4162
+ tooltipPlacement: "bottom-end",
4163
+ onClick: () => setOutputs2((prev) => prev.filter((_, j) => j !== i))
4164
+ }
4165
+ )
4166
+ ] }),
4167
+ /* @__PURE__ */ jsx26("div", { className: "lace-panel-row-actions", children: /* @__PURE__ */ jsx26(
4547
4168
  Input3,
4548
4169
  {
4549
- label: "Exposed as",
4550
- value: o.exposed_name,
4551
- onChange: (e) => updateExposedName(i, e.target.value),
4552
- placeholder: "Exposed name",
4170
+ label: "Value",
4171
+ value: o.value,
4172
+ onChange: (e) => updateOutput(i, "value", e.target.value),
4173
+ placeholder: "e.g. aws_s3_bucket.this.arn",
4553
4174
  fullWidth: true,
4554
4175
  mono: true,
4555
4176
  readOnly: !editable,
4556
- error: exposedNameCollisions.has(i)
4177
+ error: editable && !o.value.trim()
4178
+ }
4179
+ ) }),
4180
+ /* @__PURE__ */ jsx26("div", { className: "lace-panel-row-content", children: /* @__PURE__ */ jsx26(
4181
+ Textarea2,
4182
+ {
4183
+ label: "Description",
4184
+ value: o.description,
4185
+ onChange: (e) => updateOutput(i, "description", e.target.value),
4186
+ placeholder: "Optional",
4187
+ rows: 2,
4188
+ fullWidth: true,
4189
+ readOnly: !editable
4557
4190
  }
4558
- ) }) : null,
4559
- o.exposed && (o.depends_on.length > 0 || editable && siblingModuleKeys.length > 0) ? /* @__PURE__ */ jsxs17("div", { className: "lace-panel-row-content", children: [
4560
- /* @__PURE__ */ jsx27("div", { className: "lace-panel-subsection-label", children: "Depends on" }),
4561
- !editable ? o.depends_on.map((depKey) => /* @__PURE__ */ jsx27("div", { className: "lace-panel-depends-item", children: /* @__PURE__ */ jsx27(Identifier, { text: depKey }) }, depKey)) : siblingModuleKeys.map((depKey) => /* @__PURE__ */ jsxs17("label", { className: "lace-panel-checkbox-row", children: [
4562
- /* @__PURE__ */ jsx27(
4191
+ ) }),
4192
+ /* @__PURE__ */ jsxs17("label", { className: "lace-panel-checkbox-row", children: [
4193
+ /* @__PURE__ */ jsx26(
4194
+ "input",
4195
+ {
4196
+ type: "checkbox",
4197
+ checked: o.sensitive,
4198
+ onChange: (e) => updateOutput(i, "sensitive", e.target.checked),
4199
+ disabled: !editable
4200
+ }
4201
+ ),
4202
+ /* @__PURE__ */ jsx26("span", { children: "Sensitive" })
4203
+ ] }),
4204
+ (o.depends_on.length > 0 || editable && settings.dependency_options.length > 0) && /* @__PURE__ */ jsxs17("div", { className: "lace-panel-row-content", children: [
4205
+ /* @__PURE__ */ jsx26("div", { className: "lace-panel-subsection-label", children: "Depends on" }),
4206
+ !editable ? o.depends_on.map((dep) => /* @__PURE__ */ jsx26("div", { className: "lace-panel-depends-item", children: /* @__PURE__ */ jsx26(Identifier, { text: dep }) }, dep)) : settings.dependency_options.map((dep) => /* @__PURE__ */ jsxs17("label", { className: "lace-panel-checkbox-row", children: [
4207
+ /* @__PURE__ */ jsx26(
4563
4208
  "input",
4564
4209
  {
4565
4210
  type: "checkbox",
4566
- checked: o.depends_on.includes(depKey),
4567
- onChange: () => toggleDependsOn(i, depKey)
4211
+ checked: o.depends_on.includes(dep),
4212
+ onChange: () => toggleDependsOn(i, dep)
4568
4213
  }
4569
4214
  ),
4570
- /* @__PURE__ */ jsx27(Identifier, { text: depKey })
4571
- ] }, depKey))
4572
- ] }) : null,
4573
- exposedNameCollisions.has(i) ? /* @__PURE__ */ jsx27("div", { className: "lace-panel-row-error", children: "Exposed name must be unique and non-empty." }) : null
4215
+ /* @__PURE__ */ jsx26(Identifier, { text: dep })
4216
+ ] }, dep))
4217
+ ] }),
4218
+ outputDupes.has(i) && /* @__PURE__ */ jsx26("div", { className: "lace-panel-row-error", children: "Output names must be unique." })
4574
4219
  ] }, o.id)),
4575
- editable && /* @__PURE__ */ jsx27(
4220
+ editable && /* @__PURE__ */ jsxs17("div", { className: "lace-panel-row-actions", children: [
4221
+ /* @__PURE__ */ jsx26(Button8, { variant: "secondary", size: "sm", onClick: () => addOutput("", ""), children: "+ Add output" }),
4222
+ exposable.length > 0 && /* @__PURE__ */ jsx26(
4223
+ Select,
4224
+ {
4225
+ "aria-label": "Expose a call's output",
4226
+ options: [
4227
+ { value: "", label: "Expose a call's output\u2026" },
4228
+ ...exposable.map((text) => ({ value: text, label: text }))
4229
+ ],
4230
+ value: "",
4231
+ onChange: (e) => {
4232
+ const text = e.target.value;
4233
+ if (text) addOutput(outputName(text), text);
4234
+ }
4235
+ }
4236
+ )
4237
+ ] }),
4238
+ editable && /* @__PURE__ */ jsx26(
4576
4239
  UpdateButton,
4577
4240
  {
4578
4241
  status: updateStatus,
4579
4242
  label: "Update interface",
4580
4243
  onClick: handleUpdate,
4581
4244
  disabled: hasErrors,
4582
- disabledTitle: "Resolve exposed-name collisions before saving"
4245
+ disabledTitle: "Give every output a unique name and a value, and every variable a unique name"
4583
4246
  }
4584
4247
  )
4585
4248
  ] });
4586
4249
  }
4587
- function ModuleInterfacePanel({
4588
- settings,
4589
- view,
4590
- onSaveVariables,
4591
- onSaveExports,
4592
- onClose
4593
- }) {
4594
- return /* @__PURE__ */ jsx27(Panel4, { title: "Module Interface", onClose, children: /* @__PURE__ */ jsx27(
4595
- ModuleInterfaceContent,
4596
- {
4597
- settings,
4598
- view,
4599
- onSaveVariables,
4600
- onSaveExports
4250
+ function ModuleInterfacePanel({ onClose, ...content }) {
4251
+ return /* @__PURE__ */ jsx26(Panel3, { title: "Module Interface", onClose, children: /* @__PURE__ */ jsx26(ModuleInterfaceContent, { ...content }) });
4252
+ }
4253
+
4254
+ // src/components/panels/module-actions.ts
4255
+ function setVariables(scope, variables) {
4256
+ return {
4257
+ set_variables: {
4258
+ scope,
4259
+ variables: variables.map(
4260
+ (v) => ({
4261
+ name: v.name,
4262
+ type: v.type,
4263
+ required: v.required,
4264
+ description: v.description ?? "",
4265
+ default_value: v.default,
4266
+ validation: v.validation ?? [],
4267
+ ephemeral: v.ephemeral,
4268
+ nullable: v.nullable,
4269
+ sensitive: v.sensitive ?? false
4270
+ })
4271
+ )
4601
4272
  }
4602
- ) });
4273
+ };
4274
+ }
4275
+ function setOutputs(scope, outputs) {
4276
+ return {
4277
+ set_exports: {
4278
+ scope,
4279
+ outputs: outputs.map((o) => ({ name: o.name, value: o.value })),
4280
+ output_defs: outputs.map((o) => ({
4281
+ name: o.name,
4282
+ type: "",
4283
+ description: o.description ?? "",
4284
+ sensitive: o.sensitive ?? false,
4285
+ depends_on: o.depends_on ?? []
4286
+ }))
4287
+ }
4288
+ };
4289
+ }
4290
+ function setTerraform(scope, terraform) {
4291
+ return {
4292
+ set_terraform: {
4293
+ scope,
4294
+ required_version: terraform.required_version,
4295
+ required_providers: terraform.required_providers.map((p) => ({
4296
+ name: p.name,
4297
+ source: p.source,
4298
+ version: p.version,
4299
+ configuration_aliases: p.configuration_aliases ?? []
4300
+ }))
4301
+ }
4302
+ };
4303
+ }
4304
+ function setProviders(scope, providers) {
4305
+ return { set_providers: { scope, providers: providers.map((p) => ({ ...p })) } };
4306
+ }
4307
+ function setLocals(scope, locals) {
4308
+ return { set_locals: { scope, locals: locals.map((l) => ({ ...l })) } };
4309
+ }
4310
+ function setDirectives(scope, blocks) {
4311
+ return { set_directives: { scope, blocks: [...blocks] } };
4312
+ }
4313
+ function addResource(scope, kind, type, name) {
4314
+ return { add_resource: { scope, kind, type, name } };
4315
+ }
4316
+ function removeResource(scope, id) {
4317
+ return { delete_instance: { scope, instance_id: id } };
4318
+ }
4319
+ function resourceActions(scope, before, after) {
4320
+ const actions = [];
4321
+ const was = new Map(before.arguments.map((a) => [a.name, a.value]));
4322
+ const now = new Map(after.arguments.map((a) => [a.name, a.value]));
4323
+ for (const [name, value] of now) {
4324
+ if (was.get(name) === value) continue;
4325
+ actions.push({
4326
+ update_input: {
4327
+ scope,
4328
+ instance_id: before.id,
4329
+ input_name: name,
4330
+ mode: 4 /* INPUT_MODE_EXPRESSION */,
4331
+ value: void 0,
4332
+ variable: "",
4333
+ expression: value
4334
+ }
4335
+ });
4336
+ }
4337
+ for (const name of was.keys()) {
4338
+ if (!now.has(name)) {
4339
+ actions.push({ disconnect: { scope, target: before.id, input_name: name } });
4340
+ }
4341
+ }
4342
+ if (before.count !== after.count || before.for_each !== after.for_each || before.provider !== after.provider) {
4343
+ actions.push({
4344
+ set_meta_arguments: {
4345
+ scope,
4346
+ instance_id: before.id,
4347
+ count: after.count,
4348
+ for_each: after.for_each,
4349
+ provider: after.provider
4350
+ }
4351
+ });
4352
+ }
4353
+ if (JSON.stringify(before.blocks) !== JSON.stringify(after.blocks)) {
4354
+ actions.push({ set_blocks: { scope, instance_id: before.id, blocks: after.blocks } });
4355
+ }
4356
+ if (JSON.stringify(before.depends_on) !== JSON.stringify(after.depends_on)) {
4357
+ actions.push({
4358
+ set_depends_on: { scope, instance_id: before.id, depends_on: after.depends_on }
4359
+ });
4360
+ }
4361
+ return actions;
4603
4362
  }
4604
4363
 
4605
- // src/components/panels/UnifiedSettingsPanel.tsx
4364
+ // src/components/panels/ModuleDetails.tsx
4606
4365
  import "./panels-shared-5JFNYXQ7.css";
4607
4366
 
4608
4367
  // src/components/panels/ProvidersPanel.tsx
4609
- import { Button as Button9, IconButton as IconButton6, Input as Input4, Panel as Panel5 } from "@lace-cloud/ui";
4610
- import { useCallback as useCallback11, useState as useState18 } from "react";
4368
+ import { Button as Button9, IconButton as IconButton6, Input as Input4, Panel as Panel4 } from "@lace-cloud/ui";
4369
+ import { useCallback as useCallback10, useState as useState18 } from "react";
4611
4370
  import "./panels-shared-5JFNYXQ7.css";
4612
- import { Fragment as Fragment8, jsx as jsx28, jsxs as jsxs18 } from "react/jsx-runtime";
4371
+ import { Fragment as Fragment9, jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
4613
4372
  function toRows2(providers) {
4614
4373
  if (!providers || providers.length === 0) return [];
4615
4374
  return providers.map((p) => ({
@@ -4621,7 +4380,7 @@ function toRows2(providers) {
4621
4380
  key,
4622
4381
  value: String(value)
4623
4382
  })),
4624
- blocks: p.blocks ?? []
4383
+ blocks: p.blocks
4625
4384
  }));
4626
4385
  }
4627
4386
  function fromRows2(rows) {
@@ -4632,23 +4391,13 @@ function fromRows2(rows) {
4632
4391
  config[c.key.trim()] = c.value;
4633
4392
  }
4634
4393
  }
4635
- return {
4636
- name: r.name.trim(),
4637
- alias: r.alias.trim() || "",
4638
- config,
4639
- // Echo the nested blocks verbatim so a config edit never wipes them.
4640
- blocks: r.blocks.length > 0 ? r.blocks : void 0
4641
- };
4394
+ return { name: r.name.trim(), alias: r.alias.trim() || "", config, blocks: r.blocks };
4642
4395
  });
4643
4396
  }
4644
- function blockLabel(block) {
4645
- const labels = block.labels.length > 0 ? ` ${block.labels.map((l) => `"${l}"`).join(" ")}` : "";
4646
- return `${block.type}${labels}`;
4647
- }
4648
4397
  function ProvidersContent({ providers, onSave }) {
4649
4398
  const { editable } = useCanvas();
4650
4399
  const [rows, setRows] = useState18(() => toRows2(providers));
4651
- const addProvider = useCallback11(() => {
4400
+ const addProvider = useCallback10(() => {
4652
4401
  setRows((prev) => [
4653
4402
  ...prev,
4654
4403
  {
@@ -4660,13 +4409,16 @@ function ProvidersContent({ providers, onSave }) {
4660
4409
  }
4661
4410
  ]);
4662
4411
  }, []);
4663
- const removeProvider = useCallback11((index) => {
4412
+ const removeProvider = useCallback10((index) => {
4664
4413
  setRows((prev) => prev.filter((_, i) => i !== index));
4665
4414
  }, []);
4666
- const updateField = useCallback11((index, field, value) => {
4415
+ const updateField = useCallback10((index, field, value) => {
4667
4416
  setRows((prev) => prev.map((r, i) => i === index ? { ...r, [field]: value } : r));
4668
4417
  }, []);
4669
- const addConfigEntry = useCallback11((providerIndex) => {
4418
+ const updateBlocks = useCallback10((index, blocks) => {
4419
+ setRows((prev) => prev.map((r, i) => i === index ? { ...r, blocks } : r));
4420
+ }, []);
4421
+ const addConfigEntry = useCallback10((providerIndex) => {
4670
4422
  setRows(
4671
4423
  (prev) => prev.map(
4672
4424
  (r, i) => i === providerIndex ? {
@@ -4676,14 +4428,14 @@ function ProvidersContent({ providers, onSave }) {
4676
4428
  )
4677
4429
  );
4678
4430
  }, []);
4679
- const removeConfigEntry = useCallback11((providerIndex, entryIndex) => {
4431
+ const removeConfigEntry = useCallback10((providerIndex, entryIndex) => {
4680
4432
  setRows(
4681
4433
  (prev) => prev.map(
4682
4434
  (r, i) => i === providerIndex ? { ...r, configEntries: r.configEntries.filter((_, ei) => ei !== entryIndex) } : r
4683
4435
  )
4684
4436
  );
4685
4437
  }, []);
4686
- const updateConfigEntry = useCallback11(
4438
+ const updateConfigEntry = useCallback10(
4687
4439
  (providerIndex, entryIndex, field, value) => {
4688
4440
  setRows(
4689
4441
  (prev) => prev.map(
@@ -4699,14 +4451,14 @@ function ProvidersContent({ providers, onSave }) {
4699
4451
  []
4700
4452
  );
4701
4453
  const { status: updateStatus, handleUpdate } = useUpdateState(
4702
- useCallback11(async () => {
4454
+ useCallback10(async () => {
4703
4455
  await onSave(fromRows2(rows));
4704
4456
  }, [onSave, rows])
4705
4457
  );
4706
- return /* @__PURE__ */ jsxs18(Fragment8, { children: [
4458
+ return /* @__PURE__ */ jsxs18(Fragment9, { children: [
4707
4459
  rows.map((row, pi) => /* @__PURE__ */ jsxs18("div", { className: "lace-panel-row-card lace-panel-row-card--with-footer", children: [
4708
4460
  /* @__PURE__ */ jsxs18("div", { className: "lace-panel-row-actions", children: [
4709
- /* @__PURE__ */ jsx28(
4461
+ /* @__PURE__ */ jsx27(
4710
4462
  Input4,
4711
4463
  {
4712
4464
  value: row.name,
@@ -4716,7 +4468,7 @@ function ProvidersContent({ providers, onSave }) {
4716
4468
  readOnly: !editable
4717
4469
  }
4718
4470
  ),
4719
- /* @__PURE__ */ jsx28(
4471
+ /* @__PURE__ */ jsx27(
4720
4472
  Input4,
4721
4473
  {
4722
4474
  value: row.alias,
@@ -4726,10 +4478,10 @@ function ProvidersContent({ providers, onSave }) {
4726
4478
  readOnly: !editable
4727
4479
  }
4728
4480
  ),
4729
- editable && /* @__PURE__ */ jsx28(
4481
+ editable && /* @__PURE__ */ jsx27(
4730
4482
  IconButton6,
4731
4483
  {
4732
- icon: /* @__PURE__ */ jsx28(CanvasIcon, { name: "close" }),
4484
+ icon: /* @__PURE__ */ jsx27(CanvasIcon, { name: "close" }),
4733
4485
  "aria-label": "Remove provider",
4734
4486
  size: "md",
4735
4487
  tooltipPlacement: "bottom-end",
@@ -4737,9 +4489,9 @@ function ProvidersContent({ providers, onSave }) {
4737
4489
  }
4738
4490
  )
4739
4491
  ] }),
4740
- /* @__PURE__ */ jsx28("div", { className: "lace-panel-row-sublabel", children: "Config" }),
4492
+ /* @__PURE__ */ jsx27("div", { className: "lace-panel-row-sublabel", children: "Config" }),
4741
4493
  row.configEntries.map((entry, ei) => /* @__PURE__ */ jsxs18("div", { className: "lace-panel-row-actions", children: [
4742
- /* @__PURE__ */ jsx28(
4494
+ /* @__PURE__ */ jsx27(
4743
4495
  Input4,
4744
4496
  {
4745
4497
  value: entry.key,
@@ -4749,7 +4501,7 @@ function ProvidersContent({ providers, onSave }) {
4749
4501
  readOnly: !editable
4750
4502
  }
4751
4503
  ),
4752
- /* @__PURE__ */ jsx28(
4504
+ /* @__PURE__ */ jsx27(
4753
4505
  Input4,
4754
4506
  {
4755
4507
  value: entry.value,
@@ -4759,10 +4511,10 @@ function ProvidersContent({ providers, onSave }) {
4759
4511
  readOnly: !editable
4760
4512
  }
4761
4513
  ),
4762
- editable && /* @__PURE__ */ jsx28(
4514
+ editable && /* @__PURE__ */ jsx27(
4763
4515
  IconButton6,
4764
4516
  {
4765
- icon: /* @__PURE__ */ jsx28(CanvasIcon, { name: "close" }),
4517
+ icon: /* @__PURE__ */ jsx27(CanvasIcon, { name: "close" }),
4766
4518
  "aria-label": "Remove config key",
4767
4519
  size: "md",
4768
4520
  tooltipPlacement: "bottom-end",
@@ -4770,59 +4522,301 @@ function ProvidersContent({ providers, onSave }) {
4770
4522
  }
4771
4523
  )
4772
4524
  ] }, entry.id)),
4773
- editable && /* @__PURE__ */ jsx28(Button9, { variant: "secondary", size: "sm", onClick: () => addConfigEntry(pi), children: "+ Add config key" }),
4774
- row.blocks.length > 0 ? /* @__PURE__ */ jsxs18(Fragment8, { children: [
4775
- /* @__PURE__ */ jsx28("div", { className: "lace-panel-row-sublabel", children: "Nested blocks (read-only)" }),
4776
- row.blocks.map((block, bi) => /* @__PURE__ */ jsx28(
4777
- "div",
4525
+ editable && /* @__PURE__ */ jsx27(Button9, { variant: "secondary", size: "sm", onClick: () => addConfigEntry(pi), children: "+ Add config key" }),
4526
+ (row.blocks.length > 0 || editable) && /* @__PURE__ */ jsxs18(Fragment9, { children: [
4527
+ /* @__PURE__ */ jsx27("div", { className: "lace-panel-row-sublabel", children: "Nested blocks" }),
4528
+ /* @__PURE__ */ jsx27(
4529
+ BlockEditor,
4778
4530
  {
4779
- className: "lace-panel-depends-item",
4780
- children: blockLabel(block)
4781
- },
4782
- `${row.id}-block-${bi}`
4783
- ))
4784
- ] }) : null
4531
+ blocks: row.blocks,
4532
+ editable,
4533
+ onChange: (blocks) => updateBlocks(pi, blocks)
4534
+ }
4535
+ )
4536
+ ] })
4785
4537
  ] }, row.id)),
4786
- editable && /* @__PURE__ */ jsxs18(Fragment8, { children: [
4787
- /* @__PURE__ */ jsx28(Button9, { variant: "secondary", size: "sm", onClick: addProvider, children: "+ Add provider" }),
4788
- /* @__PURE__ */ jsx28(UpdateButton, { status: updateStatus, label: "Update providers", onClick: handleUpdate })
4538
+ editable && /* @__PURE__ */ jsxs18(Fragment9, { children: [
4539
+ /* @__PURE__ */ jsx27(Button9, { variant: "secondary", size: "sm", onClick: addProvider, children: "+ Add provider" }),
4540
+ /* @__PURE__ */ jsx27(UpdateButton, { status: updateStatus, label: "Update providers", onClick: handleUpdate })
4789
4541
  ] })
4790
4542
  ] });
4791
4543
  }
4792
4544
  function ProvidersPanel({ providers, onSave, onClose }) {
4793
- return /* @__PURE__ */ jsx28(Panel5, { title: "Providers", onClose, children: /* @__PURE__ */ jsx28(ProvidersContent, { providers, onSave }) });
4545
+ return /* @__PURE__ */ jsx27(Panel4, { title: "Providers", onClose, children: /* @__PURE__ */ jsx27(ProvidersContent, { providers, onSave }) });
4546
+ }
4547
+
4548
+ // src/components/panels/ResourcesPanel.tsx
4549
+ import { Badge as Badge2, Button as Button10, IconButton as IconButton7, Input as Input5, Select as Select2 } from "@lace-cloud/ui";
4550
+ import { useCallback as useCallback11, useState as useState19 } from "react";
4551
+ import "./panels-shared-5JFNYXQ7.css";
4552
+ import { Fragment as Fragment10, jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
4553
+ function ResourcesContent({
4554
+ resources,
4555
+ dependencyOptions,
4556
+ managed,
4557
+ onUpdate,
4558
+ onRemove,
4559
+ onAdd
4560
+ }) {
4561
+ const { editable } = useCanvas();
4562
+ return /* @__PURE__ */ jsxs19(Fragment10, { children: [
4563
+ resources.length === 0 && /* @__PURE__ */ jsx28("div", { className: "lace-panel-hint", children: "No resources or data sources." }),
4564
+ resources.map((resource) => /* @__PURE__ */ jsx28(
4565
+ ResourceCard,
4566
+ {
4567
+ resource,
4568
+ dependencyOptions: dependencyOptions.filter(
4569
+ (dep) => dep !== resource.id.replace(/^resource\./, "")
4570
+ ),
4571
+ editable,
4572
+ onUpdate,
4573
+ onRemove
4574
+ },
4575
+ JSON.stringify(resource)
4576
+ )),
4577
+ editable && /* @__PURE__ */ jsx28(NewResourceRow, { managed, onAdd })
4578
+ ] });
4579
+ }
4580
+ var MANAGED_OPTION = { value: "resource", label: "Resource" };
4581
+ var DATA_OPTION = { value: "data", label: "Data source" };
4582
+ function NewResourceRow({
4583
+ managed,
4584
+ onAdd
4585
+ }) {
4586
+ const options = managed ? [MANAGED_OPTION, DATA_OPTION] : [DATA_OPTION];
4587
+ const [chosen, setChosen] = useState19("resource");
4588
+ const kind = managed ? chosen : "data";
4589
+ const [type, setType] = useState19("");
4590
+ const [name, setName] = useState19("");
4591
+ return /* @__PURE__ */ jsxs19("div", { className: "lace-panel-row-card", children: [
4592
+ /* @__PURE__ */ jsx28("div", { className: "lace-panel-subsection-label", children: "Add a resource" }),
4593
+ /* @__PURE__ */ jsxs19("div", { className: "lace-panel-row-actions", children: [
4594
+ /* @__PURE__ */ jsx28(
4595
+ Select2,
4596
+ {
4597
+ "aria-label": "New resource kind",
4598
+ options,
4599
+ value: kind,
4600
+ onChange: (e) => setChosen(e.target.value === "data" ? "data" : "resource")
4601
+ }
4602
+ ),
4603
+ /* @__PURE__ */ jsx28(
4604
+ Input5,
4605
+ {
4606
+ value: type,
4607
+ onChange: (e) => setType(e.target.value),
4608
+ placeholder: "Type (e.g. aws_s3_bucket)",
4609
+ "aria-label": "New resource type",
4610
+ mono: true
4611
+ }
4612
+ ),
4613
+ /* @__PURE__ */ jsx28(
4614
+ Input5,
4615
+ {
4616
+ value: name,
4617
+ onChange: (e) => setName(e.target.value),
4618
+ placeholder: "Name",
4619
+ "aria-label": "New resource name",
4620
+ mono: true
4621
+ }
4622
+ ),
4623
+ /* @__PURE__ */ jsx28(
4624
+ Button10,
4625
+ {
4626
+ variant: "secondary",
4627
+ size: "sm",
4628
+ disabled: !type.trim() || !name.trim(),
4629
+ onClick: async () => {
4630
+ await onAdd(kind, type.trim(), name.trim());
4631
+ setType("");
4632
+ setName("");
4633
+ },
4634
+ children: "+ Add"
4635
+ }
4636
+ )
4637
+ ] })
4638
+ ] });
4639
+ }
4640
+ function ResourceCard({ resource, dependencyOptions, editable, onUpdate, onRemove }) {
4641
+ const [draft, setDraft] = useState19(resource);
4642
+ const set = useCallback11(
4643
+ (field, value) => setDraft((prev) => ({ ...prev, [field]: value })),
4644
+ []
4645
+ );
4646
+ const setArgument = (index, field, value) => set(
4647
+ "arguments",
4648
+ draft.arguments.map((a, i) => i === index ? { ...a, [field]: value } : a)
4649
+ );
4650
+ const argumentDupes = findDuplicateIndices(draft.arguments, (a) => a.name);
4651
+ const hasErrors = argumentDupes.size > 0 || draft.arguments.some((a) => !a.name.trim());
4652
+ const { status, handleUpdate } = useUpdateState(
4653
+ useCallback11(async () => {
4654
+ if (hasErrors) return;
4655
+ await onUpdate(resource, draft);
4656
+ }, [onUpdate, resource, draft, hasErrors])
4657
+ );
4658
+ const metaArguments = [
4659
+ { field: "count", placeholder: "e.g. 2 or var.instances" },
4660
+ { field: "for_each", placeholder: "e.g. var.names" },
4661
+ { field: "provider", placeholder: "e.g. aws.west" }
4662
+ ];
4663
+ return /* @__PURE__ */ jsxs19("div", { className: "lace-panel-row-card lace-panel-row-card--with-footer", children: [
4664
+ /* @__PURE__ */ jsxs19("div", { className: "lace-panel-row-actions", children: [
4665
+ /* @__PURE__ */ jsx28(Badge2, { variant: resource.kind === "data" ? "info" : "neutral", children: resource.kind === "data" ? "data" : "resource" }),
4666
+ /* @__PURE__ */ jsx28(
4667
+ Identifier,
4668
+ {
4669
+ className: "lace-panel-row-card__name",
4670
+ text: `${resource.type}.${resource.name}`
4671
+ }
4672
+ ),
4673
+ editable && /* @__PURE__ */ jsx28(
4674
+ IconButton7,
4675
+ {
4676
+ icon: /* @__PURE__ */ jsx28(CanvasIcon, { name: "close" }),
4677
+ "aria-label": `Remove ${resource.type}.${resource.name}`,
4678
+ size: "md",
4679
+ tooltipPlacement: "bottom-end",
4680
+ onClick: () => onRemove(resource.id)
4681
+ }
4682
+ )
4683
+ ] }),
4684
+ metaArguments.map(
4685
+ ({ field, placeholder }) => draft[field] || editable ? /* @__PURE__ */ jsx28("div", { className: "lace-panel-row-actions", children: /* @__PURE__ */ jsx28(
4686
+ Input5,
4687
+ {
4688
+ label: field,
4689
+ value: draft[field],
4690
+ onChange: (e) => set(field, e.target.value),
4691
+ placeholder,
4692
+ fullWidth: true,
4693
+ mono: true,
4694
+ readOnly: !editable
4695
+ }
4696
+ ) }, field) : null
4697
+ ),
4698
+ /* @__PURE__ */ jsx28("div", { className: "lace-panel-row-sublabel", children: "Arguments" }),
4699
+ draft.arguments.map((argument, i) => (
4700
+ // biome-ignore lint/suspicious/noArrayIndexKey: argument rows are positional while edited
4701
+ /* @__PURE__ */ jsxs19("div", { className: "lace-panel-row-actions", children: [
4702
+ /* @__PURE__ */ jsx28(
4703
+ Input5,
4704
+ {
4705
+ value: argument.name,
4706
+ onChange: (e) => setArgument(i, "name", e.target.value),
4707
+ placeholder: "Argument",
4708
+ "aria-label": "Argument name",
4709
+ mono: true,
4710
+ readOnly: !editable,
4711
+ error: argumentDupes.has(i)
4712
+ }
4713
+ ),
4714
+ /* @__PURE__ */ jsx28(
4715
+ Input5,
4716
+ {
4717
+ value: argument.value,
4718
+ onChange: (e) => setArgument(i, "value", e.target.value),
4719
+ placeholder: "Value",
4720
+ "aria-label": `${argument.name || "Argument"} value`,
4721
+ mono: true,
4722
+ readOnly: !editable
4723
+ }
4724
+ ),
4725
+ editable && /* @__PURE__ */ jsx28(
4726
+ IconButton7,
4727
+ {
4728
+ icon: /* @__PURE__ */ jsx28(CanvasIcon, { name: "close" }),
4729
+ "aria-label": `Remove ${argument.name || "the argument"}`,
4730
+ size: "md",
4731
+ tooltipPlacement: "bottom-end",
4732
+ onClick: () => set(
4733
+ "arguments",
4734
+ draft.arguments.filter((_, j) => j !== i)
4735
+ )
4736
+ }
4737
+ )
4738
+ ] }, i)
4739
+ )),
4740
+ editable && /* @__PURE__ */ jsx28(
4741
+ Button10,
4742
+ {
4743
+ variant: "secondary",
4744
+ size: "sm",
4745
+ onClick: () => set("arguments", [...draft.arguments, { name: "", value: "" }]),
4746
+ children: "+ Add argument"
4747
+ }
4748
+ ),
4749
+ (draft.blocks.length > 0 || editable) && /* @__PURE__ */ jsxs19(Fragment10, { children: [
4750
+ /* @__PURE__ */ jsx28("div", { className: "lace-panel-row-sublabel", children: "Nested blocks" }),
4751
+ /* @__PURE__ */ jsx28(
4752
+ BlockEditor,
4753
+ {
4754
+ blocks: draft.blocks,
4755
+ editable,
4756
+ onChange: (blocks) => set("blocks", blocks)
4757
+ }
4758
+ )
4759
+ ] }),
4760
+ (draft.depends_on.length > 0 || editable && dependencyOptions.length > 0) && /* @__PURE__ */ jsxs19(Fragment10, { children: [
4761
+ /* @__PURE__ */ jsx28("div", { className: "lace-panel-row-sublabel", children: "Depends on" }),
4762
+ !editable ? draft.depends_on.map((dep) => /* @__PURE__ */ jsx28("div", { className: "lace-panel-depends-item", children: /* @__PURE__ */ jsx28(Identifier, { text: dep }) }, dep)) : dependencyOptions.map((dep) => /* @__PURE__ */ jsxs19("label", { className: "lace-panel-checkbox-row", children: [
4763
+ /* @__PURE__ */ jsx28(
4764
+ "input",
4765
+ {
4766
+ type: "checkbox",
4767
+ checked: draft.depends_on.includes(dep),
4768
+ onChange: (e) => set(
4769
+ "depends_on",
4770
+ e.target.checked ? [...draft.depends_on, dep] : draft.depends_on.filter((d) => d !== dep)
4771
+ )
4772
+ }
4773
+ ),
4774
+ /* @__PURE__ */ jsx28(Identifier, { text: dep })
4775
+ ] }, dep))
4776
+ ] }),
4777
+ editable && /* @__PURE__ */ jsx28(
4778
+ UpdateButton,
4779
+ {
4780
+ status,
4781
+ label: "Update resource",
4782
+ onClick: handleUpdate,
4783
+ disabled: hasErrors,
4784
+ disabledTitle: "Give every argument a unique name"
4785
+ }
4786
+ )
4787
+ ] });
4794
4788
  }
4795
4789
 
4796
4790
  // src/components/panels/TerraformConfigPanel.tsx
4797
- import { Button as Button10, IconButton as IconButton7, Input as Input5, Panel as Panel6 } from "@lace-cloud/ui";
4798
- import { useCallback as useCallback12, useState as useState19 } from "react";
4791
+ import { Button as Button11, IconButton as IconButton8, Input as Input6, Panel as Panel5 } from "@lace-cloud/ui";
4792
+ import { useCallback as useCallback12, useState as useState20 } from "react";
4799
4793
  import "./panels-shared-5JFNYXQ7.css";
4800
- import { Fragment as Fragment9, jsx as jsx29, jsxs as jsxs19 } from "react/jsx-runtime";
4794
+ import { Fragment as Fragment11, jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
4801
4795
  function TerraformConfigContent({ terraform, onSave }) {
4802
4796
  const { editable } = useCanvas();
4803
- const [requiredVersion, setRequiredVersion] = useState19(terraform?.required_version ?? "");
4804
- const [providers, setProviders] = useState19(() => {
4797
+ const [requiredVersion, setRequiredVersion] = useState20(terraform?.required_version ?? "");
4798
+ const [providers, setProviders2] = useState20(() => {
4805
4799
  if (!terraform?.required_providers) return [];
4806
4800
  return terraform.required_providers.map((req) => ({
4807
4801
  id: crypto.randomUUID(),
4808
4802
  name: req.name,
4809
4803
  source: req.source ?? "",
4810
4804
  version: req.version ?? "",
4811
- configuration_aliases: req.configuration_aliases ?? []
4805
+ aliases: (req.configuration_aliases ?? []).join(", ")
4812
4806
  }));
4813
4807
  });
4814
4808
  const addProvider = useCallback12(() => {
4815
- setProviders((prev) => [
4809
+ setProviders2((prev) => [
4816
4810
  ...prev,
4817
- { id: crypto.randomUUID(), name: "", source: "", version: "", configuration_aliases: [] }
4811
+ { id: crypto.randomUUID(), name: "", source: "", version: "", aliases: "" }
4818
4812
  ]);
4819
4813
  }, []);
4820
4814
  const removeProvider = useCallback12((index) => {
4821
- setProviders((prev) => prev.filter((_, i) => i !== index));
4815
+ setProviders2((prev) => prev.filter((_, i) => i !== index));
4822
4816
  }, []);
4823
4817
  const updateProvider = useCallback12(
4824
4818
  (index, field, value) => {
4825
- setProviders((prev) => prev.map((p, i) => i === index ? { ...p, [field]: value } : p));
4819
+ setProviders2((prev) => prev.map((p, i) => i === index ? { ...p, [field]: value } : p));
4826
4820
  },
4827
4821
  []
4828
4822
  );
@@ -4834,16 +4828,16 @@ function TerraformConfigContent({ terraform, onSave }) {
4834
4828
  name: p.name.trim(),
4835
4829
  source: p.source.trim(),
4836
4830
  version: p.version.trim(),
4837
- configuration_aliases: p.configuration_aliases.length > 0 ? p.configuration_aliases : void 0
4831
+ configuration_aliases: p.aliases.split(",").map((alias) => alias.trim()).filter((alias) => alias !== "")
4838
4832
  }))
4839
4833
  };
4840
4834
  await onSave(block);
4841
4835
  }, [onSave, requiredVersion, providers])
4842
4836
  );
4843
- return /* @__PURE__ */ jsxs19(Fragment9, { children: [
4837
+ return /* @__PURE__ */ jsxs20(Fragment11, { children: [
4844
4838
  /* @__PURE__ */ jsx29("h4", { className: "lace-panel-section-title", children: "Required Version" }),
4845
4839
  /* @__PURE__ */ jsx29("div", { className: "lace-panel-field", children: /* @__PURE__ */ jsx29(
4846
- Input5,
4840
+ Input6,
4847
4841
  {
4848
4842
  value: requiredVersion,
4849
4843
  onChange: (e) => setRequiredVersion(e.target.value),
@@ -4853,10 +4847,10 @@ function TerraformConfigContent({ terraform, onSave }) {
4853
4847
  }
4854
4848
  ) }),
4855
4849
  /* @__PURE__ */ jsx29("h4", { className: "lace-panel-section-title", children: "Required Providers" }),
4856
- providers.map((p, i) => /* @__PURE__ */ jsxs19("div", { className: "lace-panel-row-card lace-panel-row-card--with-footer", children: [
4857
- /* @__PURE__ */ jsxs19("div", { className: "lace-panel-row-actions", children: [
4850
+ providers.map((p, i) => /* @__PURE__ */ jsxs20("div", { className: "lace-panel-row-card lace-panel-row-card--with-footer", children: [
4851
+ /* @__PURE__ */ jsxs20("div", { className: "lace-panel-row-actions", children: [
4858
4852
  /* @__PURE__ */ jsx29(
4859
- Input5,
4853
+ Input6,
4860
4854
  {
4861
4855
  value: p.name,
4862
4856
  onChange: (e) => updateProvider(i, "name", e.target.value),
@@ -4866,7 +4860,7 @@ function TerraformConfigContent({ terraform, onSave }) {
4866
4860
  }
4867
4861
  ),
4868
4862
  editable && /* @__PURE__ */ jsx29(
4869
- IconButton7,
4863
+ IconButton8,
4870
4864
  {
4871
4865
  icon: /* @__PURE__ */ jsx29(CanvasIcon, { name: "close" }),
4872
4866
  "aria-label": "Remove provider",
@@ -4877,7 +4871,7 @@ function TerraformConfigContent({ terraform, onSave }) {
4877
4871
  )
4878
4872
  ] }),
4879
4873
  /* @__PURE__ */ jsx29("div", { className: "lace-panel-row-actions", children: /* @__PURE__ */ jsx29(
4880
- Input5,
4874
+ Input6,
4881
4875
  {
4882
4876
  value: p.source,
4883
4877
  onChange: (e) => updateProvider(i, "source", e.target.value),
@@ -4887,7 +4881,7 @@ function TerraformConfigContent({ terraform, onSave }) {
4887
4881
  }
4888
4882
  ) }),
4889
4883
  /* @__PURE__ */ jsx29("div", { className: "lace-panel-row-actions", children: /* @__PURE__ */ jsx29(
4890
- Input5,
4884
+ Input6,
4891
4885
  {
4892
4886
  value: p.version,
4893
4887
  onChange: (e) => updateProvider(i, "version", e.target.value),
@@ -4896,169 +4890,761 @@ function TerraformConfigContent({ terraform, onSave }) {
4896
4890
  readOnly: !editable
4897
4891
  }
4898
4892
  ) }),
4899
- p.configuration_aliases.length > 0 && /* @__PURE__ */ jsx29("div", { className: "lace-panel-row-actions", children: /* @__PURE__ */ jsx29(
4900
- Input5,
4893
+ (p.aliases || editable) && /* @__PURE__ */ jsx29("div", { className: "lace-panel-row-actions", children: /* @__PURE__ */ jsx29(
4894
+ Input6,
4895
+ {
4896
+ value: p.aliases,
4897
+ onChange: (e) => updateProvider(i, "aliases", e.target.value),
4898
+ "aria-label": `${p.name || "provider"} configuration_aliases`,
4899
+ placeholder: "configuration_aliases (e.g. aws.src, aws.dst)",
4900
+ fullWidth: true,
4901
+ mono: true,
4902
+ readOnly: !editable
4903
+ }
4904
+ ) })
4905
+ ] }, p.id)),
4906
+ editable && /* @__PURE__ */ jsx29(Button11, { variant: "secondary", size: "sm", onClick: addProvider, children: "+ Add provider" }),
4907
+ /* @__PURE__ */ jsx29("h4", { className: "lace-panel-section-title", children: "Backend" }),
4908
+ /* @__PURE__ */ jsx29("div", { className: "lace-panel-hint", children: "Terraform state is managed by Lace Cloud. The HTTP backend is configured automatically during generation." }),
4909
+ editable && /* @__PURE__ */ jsx29(UpdateButton, { status: updateStatus, label: "Update terraform block", onClick: handleUpdate })
4910
+ ] });
4911
+ }
4912
+ function TerraformConfigPanel({ terraform, onSave, onClose }) {
4913
+ return /* @__PURE__ */ jsx29(Panel5, { title: "Terraform Configuration", onClose, children: /* @__PURE__ */ jsx29(TerraformConfigContent, { terraform, onSave }) });
4914
+ }
4915
+
4916
+ // src/components/panels/ModuleDetails.tsx
4917
+ import { Fragment as Fragment12, jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
4918
+ function assertApplied(result) {
4919
+ if (!result?.success) throw new Error("apply failed");
4920
+ }
4921
+ var keyOf = (value) => JSON.stringify(value);
4922
+ function ModuleDetails({ moduleKey, open = [] }) {
4923
+ const { bundle, runner, editable } = useCanvas();
4924
+ const settings = useMemo7(() => deriveSettingsConfig(bundle, moduleKey), [bundle, moduleKey]);
4925
+ if (!settings) return null;
4926
+ if (settings.reference) return /* @__PURE__ */ jsx30(ReferenceDetails, { settings });
4927
+ const apply = async (actions) => {
4928
+ if (!editable) return;
4929
+ assertApplied(await runner.apply(actions));
4930
+ };
4931
+ return /* @__PURE__ */ jsxs21(Fragment12, { children: [
4932
+ /* @__PURE__ */ jsx30(
4933
+ AccordionSection,
4934
+ {
4935
+ title: "Resources",
4936
+ defaultOpen: open.includes("Resources"),
4937
+ badge: `(${settings.resources.length})`,
4938
+ children: /* @__PURE__ */ jsx30(
4939
+ ResourcesContent,
4940
+ {
4941
+ resources: settings.resources,
4942
+ dependencyOptions: settings.dependency_options,
4943
+ managed: settings.holds_managed_resources,
4944
+ onUpdate: (before, after) => apply(resourceActions(moduleKey, before, after)),
4945
+ onRemove: (id) => apply([removeResource(moduleKey, id)]),
4946
+ onAdd: (kind, type, name) => apply([addResource(moduleKey, kind, type, name)])
4947
+ }
4948
+ )
4949
+ }
4950
+ ),
4951
+ /* @__PURE__ */ jsx30(AccordionSection, { title: "Interface", defaultOpen: open.includes("Interface"), children: /* @__PURE__ */ jsx30(
4952
+ ModuleInterfaceContent,
4953
+ {
4954
+ settings,
4955
+ onSave: (variables, outputs) => apply([setVariables(moduleKey, variables), setOutputs(moduleKey, outputs)])
4956
+ },
4957
+ keyOf([settings.variables, settings.outputs, settings.call_outputs])
4958
+ ) }),
4959
+ /* @__PURE__ */ jsx30(
4960
+ AccordionSection,
4961
+ {
4962
+ title: "Moved and import blocks",
4963
+ defaultOpen: open.includes("Moved and import blocks"),
4964
+ badge: settings.directives.length > 0 ? `(${settings.directives.length})` : void 0,
4965
+ children: /* @__PURE__ */ jsx30(
4966
+ DirectivesContent,
4967
+ {
4968
+ directives: settings.directives,
4969
+ onSave: (blocks) => apply([setDirectives(moduleKey, blocks)])
4970
+ },
4971
+ keyOf(settings.directives)
4972
+ )
4973
+ }
4974
+ ),
4975
+ /* @__PURE__ */ jsx30(AccordionSection, { title: "Locals", defaultOpen: open.includes("Locals"), children: /* @__PURE__ */ jsx30(
4976
+ LocalsContent,
4977
+ {
4978
+ locals: settings.locals,
4979
+ onSave: (locals) => apply([setLocals(moduleKey, locals)])
4980
+ },
4981
+ keyOf(settings.locals)
4982
+ ) }),
4983
+ /* @__PURE__ */ jsx30(AccordionSection, { title: "Providers", defaultOpen: open.includes("Providers"), children: /* @__PURE__ */ jsx30(
4984
+ ProvidersContent,
4985
+ {
4986
+ providers: settings.providers,
4987
+ onSave: (providers) => apply([setProviders(moduleKey, providers)])
4988
+ },
4989
+ keyOf(settings.providers)
4990
+ ) }),
4991
+ /* @__PURE__ */ jsx30(AccordionSection, { title: "Terraform Config", defaultOpen: open.includes("Terraform Config"), children: /* @__PURE__ */ jsx30(
4992
+ TerraformConfigContent,
4993
+ {
4994
+ terraform: settings.terraform,
4995
+ onSave: (terraform) => apply([setTerraform(moduleKey, terraform)])
4996
+ },
4997
+ keyOf(settings.terraform)
4998
+ ) })
4999
+ ] });
5000
+ }
5001
+ function DirectivesContent({
5002
+ directives,
5003
+ onSave
5004
+ }) {
5005
+ const { editable } = useCanvas();
5006
+ const [blocks, setBlocks] = useState21(directives);
5007
+ const { status, handleUpdate } = useUpdateState(() => onSave(blocks));
5008
+ return /* @__PURE__ */ jsxs21(Fragment12, { children: [
5009
+ blocks.length === 0 && /* @__PURE__ */ jsx30("div", { className: "lace-panel-hint", children: "No moved or import blocks." }),
5010
+ /* @__PURE__ */ jsx30(
5011
+ BlockEditor,
5012
+ {
5013
+ blocks,
5014
+ editable,
5015
+ onChange: setBlocks,
5016
+ templates: [
5017
+ { type: "moved", attributes: ["from", "to"] },
5018
+ { type: "import", attributes: ["to", "id"] }
5019
+ ]
5020
+ }
5021
+ ),
5022
+ editable && /* @__PURE__ */ jsx30(
5023
+ UpdateButton,
5024
+ {
5025
+ status,
5026
+ label: "Update moved and import blocks",
5027
+ onClick: handleUpdate
5028
+ }
5029
+ )
5030
+ ] });
5031
+ }
5032
+ function ReferenceDetails({ settings }) {
5033
+ const reference = settings.reference;
5034
+ if (!reference) return null;
5035
+ return /* @__PURE__ */ jsxs21(Fragment12, { children: [
5036
+ /* @__PURE__ */ jsxs21(AccordionSection, { title: "Source", defaultOpen: true, children: [
5037
+ /* @__PURE__ */ jsx30("div", { className: "lace-panel-hint", children: "A reference: Lace reads it where its source points and never edits it." }),
5038
+ /* @__PURE__ */ jsxs21("div", { className: "lace-panel-row-actions lace-panel-row-actions--stacked", children: [
5039
+ /* @__PURE__ */ jsx30(Input7, { label: "Source", value: reference.source, fullWidth: true, mono: true, readOnly: true }),
5040
+ /* @__PURE__ */ jsx30(Input7, { label: "Version", value: reference.version, fullWidth: true, mono: true, readOnly: true })
5041
+ ] })
5042
+ ] }),
5043
+ /* @__PURE__ */ jsxs21(AccordionSection, { title: "Interface", defaultOpen: true, children: [
5044
+ /* @__PURE__ */ jsx30("h4", { className: "lace-panel-section-title", children: "Inputs" }),
5045
+ settings.variables.length === 0 && /* @__PURE__ */ jsx30("div", { className: "lace-panel-hint", children: "The IR holds no interface for this reference." }),
5046
+ settings.variables.map((v) => /* @__PURE__ */ jsx30("div", { className: "lace-panel-depends-item", children: /* @__PURE__ */ jsx30(Identifier, { text: `${typedName(v.name, v.type)}${v.required ? " (required)" : ""}` }) }, v.name)),
5047
+ /* @__PURE__ */ jsx30("h4", { className: "lace-panel-section-title", children: "Outputs" }),
5048
+ settings.outputs.map((o) => /* @__PURE__ */ jsx30("div", { className: "lace-panel-depends-item", children: /* @__PURE__ */ jsx30(Identifier, { text: typedName(o.name, o.type) }) }, o.name))
5049
+ ] })
5050
+ ] });
5051
+ }
5052
+
5053
+ // src/components/panels/ModuleConfigPanel.tsx
5054
+ import { Fragment as Fragment13, jsx as jsx31, jsxs as jsxs22 } from "react/jsx-runtime";
5055
+ var MODE_ITEMS = [
5056
+ { value: "literal", label: "Lit" },
5057
+ { value: "variable", label: "Var" },
5058
+ { value: "expression", label: "Expr" },
5059
+ { value: "wired", label: "Wired" }
5060
+ ];
5061
+ function toInputMode(mode) {
5062
+ switch (mode) {
5063
+ case "empty":
5064
+ return 1 /* INPUT_MODE_EMPTY */;
5065
+ case "literal":
5066
+ return 2 /* INPUT_MODE_LITERAL */;
5067
+ case "variable":
5068
+ return 3 /* INPUT_MODE_VARIABLE */;
5069
+ case "expression":
5070
+ return 4 /* INPUT_MODE_EXPRESSION */;
5071
+ case "wired":
5072
+ return 5 /* INPUT_MODE_WIRED */;
5073
+ default:
5074
+ return assertNever(mode);
5075
+ }
5076
+ }
5077
+ function ModuleConfigPanel({ instance_id, onClose, onModified }) {
5078
+ const { editable, bundle, runner } = useCanvas();
5079
+ const config = useMemo8(
5080
+ () => deriveNodeConfig(bundle, instance_id),
5081
+ [bundle, instance_id]
5082
+ );
5083
+ const [inputState, setInputState] = useState22({
5084
+ modes: {},
5085
+ values: {},
5086
+ variables: {},
5087
+ expressions: {}
5088
+ });
5089
+ const {
5090
+ modes: localModes,
5091
+ values: localValues,
5092
+ variables: localVariables,
5093
+ expressions: localExpressions
5094
+ } = inputState;
5095
+ const setLocalModes = useCallback13(
5096
+ (fn) => setInputState((s) => ({ ...s, modes: fn(s.modes) })),
5097
+ []
5098
+ );
5099
+ const setLocalValues = useCallback13(
5100
+ (fn) => setInputState((s) => ({ ...s, values: fn(s.values) })),
5101
+ []
5102
+ );
5103
+ const setLocalVariables = useCallback13(
5104
+ (fn) => setInputState((s) => ({ ...s, variables: fn(s.variables) })),
5105
+ []
5106
+ );
5107
+ const setLocalExpressions = useCallback13(
5108
+ (fn) => setInputState((s) => ({ ...s, expressions: fn(s.expressions) })),
5109
+ []
5110
+ );
5111
+ const [localDependsOn, setLocalDependsOn] = useState22(/* @__PURE__ */ new Set());
5112
+ const [localProviders, setLocalProviders] = useState22([]);
5113
+ const [localRepetition, setLocalRepetition] = useState22({ count: "", for_each: "" });
5114
+ useEffect10(() => {
5115
+ if (!config) return;
5116
+ const modes = {};
5117
+ const values = {};
5118
+ const variables = {};
5119
+ const expressions = {};
5120
+ for (const input of config.inputs) {
5121
+ modes[input.name] = input.mode;
5122
+ if (input.value !== void 0) values[input.name] = input.value;
5123
+ if (input.variable) variables[input.name] = input.variable;
5124
+ if (input.expression) expressions[input.name] = input.expression;
5125
+ }
5126
+ setInputState({ modes, values, variables, expressions });
5127
+ setLocalDependsOn(new Set(config.depends_on));
5128
+ setLocalProviders(
5129
+ Object.entries(config.providers ?? {}).map(([key, value]) => ({ key, value }))
5130
+ );
5131
+ setLocalRepetition({ count: config.count, for_each: config.for_each });
5132
+ }, [config]);
5133
+ const switchMode = useCallback13(
5134
+ (name, mode, input) => {
5135
+ setLocalModes((prev) => ({ ...prev, [name]: mode }));
5136
+ switch (mode) {
5137
+ case "literal":
5138
+ setLocalValues((prev) => ({ ...prev, [name]: input.default_value ?? null }));
5139
+ break;
5140
+ case "variable":
5141
+ setLocalVariables((prev) => ({ ...prev, [name]: "" }));
5142
+ break;
5143
+ case "expression":
5144
+ setLocalExpressions((prev) => ({ ...prev, [name]: "" }));
5145
+ break;
5146
+ case "empty":
5147
+ setLocalValues((prev) => {
5148
+ const next = { ...prev };
5149
+ delete next[name];
5150
+ return next;
5151
+ });
5152
+ break;
5153
+ case "wired":
5154
+ break;
5155
+ default:
5156
+ assertNever(mode);
5157
+ }
5158
+ },
5159
+ [setLocalModes, setLocalValues, setLocalVariables, setLocalExpressions]
5160
+ );
5161
+ const { requiredInputs, optionalInputs } = useMemo8(
5162
+ () => ({
5163
+ requiredInputs: (config?.inputs ?? []).filter((i) => i.required),
5164
+ optionalInputs: (config?.inputs ?? []).filter((i) => !i.required)
5165
+ }),
5166
+ [config?.inputs]
5167
+ );
5168
+ const address = useMemo8(() => instanceAddress6(bundle, instance_id), [bundle, instance_id]);
5169
+ const { status: updateStatus, handleUpdate } = useUpdateState(async () => {
5170
+ if (!config || !editable) return;
5171
+ const actions = [];
5172
+ for (const input of config.inputs) {
5173
+ const mode = localModes[input.name] ?? input.mode;
5174
+ if (mode === "wired") continue;
5175
+ actions.push({
5176
+ update_input: {
5177
+ scope: address.scope,
5178
+ instance_id: address.id,
5179
+ input_name: input.name,
5180
+ mode: toInputMode(mode),
5181
+ value: mode === "literal" ? localValues[input.name] : void 0,
5182
+ variable: mode === "variable" ? localVariables[input.name] ?? "" : "",
5183
+ expression: mode === "expression" ? localExpressions[input.name] ?? "" : ""
5184
+ }
5185
+ });
5186
+ }
5187
+ actions.push({
5188
+ set_depends_on: {
5189
+ scope: address.scope,
5190
+ instance_id: address.id,
5191
+ depends_on: [...localDependsOn]
5192
+ }
5193
+ });
5194
+ const providersRecord = {};
5195
+ for (const { key, value } of localProviders) {
5196
+ const name = key.trim();
5197
+ if (name) providersRecord[name] = value.trim();
5198
+ }
5199
+ actions.push({
5200
+ set_use_providers: {
5201
+ scope: address.scope,
5202
+ instance_id: address.id,
5203
+ providers: providersRecord
5204
+ }
5205
+ });
5206
+ if (localRepetition.count !== config.count || localRepetition.for_each !== config.for_each) {
5207
+ actions.push({
5208
+ set_meta_arguments: {
5209
+ scope: address.scope,
5210
+ instance_id: address.id,
5211
+ count: localRepetition.count,
5212
+ for_each: localRepetition.for_each,
5213
+ provider: ""
5214
+ }
5215
+ });
5216
+ }
5217
+ const result = await runner.apply(actions);
5218
+ if (!result?.success) throw new Error("apply failed");
5219
+ const requiredToCheck = config.inputs.filter((i) => i.required);
5220
+ const hasFilledRequired = requiredToCheck.length === 0 || requiredToCheck.some((input) => {
5221
+ const mode = localModes[input.name] ?? input.mode;
5222
+ if (mode === "wired") return true;
5223
+ if (mode === "literal") {
5224
+ const v = localValues[input.name];
5225
+ return v !== void 0 && v !== null && v !== "";
5226
+ }
5227
+ if (mode === "variable") {
5228
+ return (localVariables[input.name] ?? "").trim().length > 0;
5229
+ }
5230
+ if (mode === "expression") {
5231
+ return (localExpressions[input.name] ?? "").trim().length > 0;
5232
+ }
5233
+ return false;
5234
+ });
5235
+ if (hasFilledRequired) {
5236
+ onModified?.(instance_id);
5237
+ }
5238
+ onClose();
5239
+ });
5240
+ const handleDisconnect = async (inputName) => {
5241
+ if (!editable) return;
5242
+ const result = await runner.apply([
5243
+ { disconnect: { scope: address.scope, target: address.id, input_name: inputName } }
5244
+ ]);
5245
+ if (!result?.success) return;
5246
+ setLocalModes((prev) => ({ ...prev, [inputName]: "empty" }));
5247
+ };
5248
+ function renderModeSelector(input) {
5249
+ const currentMode = localModes[input.name] ?? input.mode;
5250
+ const isWired = currentMode === "wired";
5251
+ const items = MODE_ITEMS.map((m) => ({
5252
+ ...m,
5253
+ disabled: !editable || m.value === "wired" || isWired
5254
+ }));
5255
+ return /* @__PURE__ */ jsx31(
5256
+ ModeToggle,
5257
+ {
5258
+ value: currentMode,
5259
+ onChange: (next) => switchMode(input.name, next, input),
5260
+ items,
5261
+ "aria-label": `${input.name} binding mode`
5262
+ }
5263
+ );
5264
+ }
5265
+ function renderInputField(input) {
5266
+ const currentMode = localModes[input.name] ?? input.mode;
5267
+ return /* @__PURE__ */ jsxs22("div", { className: "lace-panel-field", children: [
5268
+ /* @__PURE__ */ jsxs22("label", { className: "lace-panel-row-label", children: [
5269
+ /* @__PURE__ */ jsx31(Identifier, { text: input.name }),
5270
+ input.required && /* @__PURE__ */ jsx31("span", { className: "lace-mcp__required-star", children: "*" })
5271
+ ] }),
5272
+ renderModeSelector(input),
5273
+ /* @__PURE__ */ jsxs22("div", { className: "lace-panel-row-content", children: [
5274
+ currentMode === "wired" && renderWiredEditor(input),
5275
+ currentMode === "variable" && renderVariableEditor(input),
5276
+ currentMode === "expression" && renderExpressionEditor(input),
5277
+ currentMode === "literal" && renderLiteralEditor(input)
5278
+ ] }),
5279
+ input.description && /* @__PURE__ */ jsx31("div", { className: "lace-panel-field__description", children: input.description })
5280
+ ] }, input.name);
5281
+ }
5282
+ function renderWiredEditor(input) {
5283
+ const label = input.wired_source ?? "Not wired";
5284
+ return /* @__PURE__ */ jsxs22("div", { className: "lace-mcp__wired-row", children: [
5285
+ /* @__PURE__ */ jsx31("div", { className: "lace-mcp__wired-input", children: /* @__PURE__ */ jsx31(Input8, { value: label, readOnly: true, fullWidth: true, mono: true }) }),
5286
+ editable && /* @__PURE__ */ jsx31(
5287
+ IconButton9,
5288
+ {
5289
+ icon: /* @__PURE__ */ jsx31(CanvasIcon, { name: "close" }),
5290
+ "aria-label": "Disconnect this input",
5291
+ size: "md",
5292
+ tooltipPlacement: "bottom-end",
5293
+ onClick: () => handleDisconnect(input.name)
5294
+ }
5295
+ )
5296
+ ] });
5297
+ }
5298
+ function renderVariableEditor(input) {
5299
+ const currentVar = localVariables[input.name] ?? input.variable ?? "";
5300
+ return /* @__PURE__ */ jsx31(
5301
+ Input8,
5302
+ {
5303
+ value: currentVar,
5304
+ onChange: (e) => {
5305
+ const raw = e.target.value;
5306
+ const name = raw.startsWith("var.") ? raw.slice(4) : raw;
5307
+ setLocalVariables((prev) => ({ ...prev, [input.name]: name }));
5308
+ },
5309
+ placeholder: "e.g. region",
5310
+ fullWidth: true,
5311
+ mono: true,
5312
+ readOnly: !editable
5313
+ }
5314
+ );
5315
+ }
5316
+ function renderExpressionEditor(input) {
5317
+ const currentExpr = localExpressions[input.name] ?? input.expression ?? "";
5318
+ return /* @__PURE__ */ jsx31(
5319
+ Textarea3,
5320
+ {
5321
+ value: currentExpr,
5322
+ onChange: (e) => setLocalExpressions((prev) => ({ ...prev, [input.name]: e.target.value })),
5323
+ rows: 3,
5324
+ placeholder: 'e.g. join("-", [var.prefix, var.name])',
5325
+ fullWidth: true,
5326
+ mono: true,
5327
+ readOnly: !editable
5328
+ }
5329
+ );
5330
+ }
5331
+ function renderLiteralEditor(input) {
5332
+ const value = localValues[input.name] ?? input.value ?? input.default_value ?? null;
5333
+ const type = input.type || "string";
5334
+ const updateValue = (val) => {
5335
+ setLocalValues((prev) => ({ ...prev, [input.name]: val }));
5336
+ };
5337
+ if (type === "bool") {
5338
+ return /* @__PURE__ */ jsxs22(
5339
+ "select",
4901
5340
  {
4902
- value: p.configuration_aliases.join(", "),
4903
- "aria-label": `${p.name || "provider"} configuration_aliases`,
4904
- placeholder: "configuration_aliases",
5341
+ className: "lace-mcp__select",
5342
+ value: String(value ?? false),
5343
+ onChange: (e) => updateValue(e.target.value === "true"),
5344
+ disabled: !editable,
5345
+ children: [
5346
+ /* @__PURE__ */ jsx31("option", { value: "true", children: "True" }),
5347
+ /* @__PURE__ */ jsx31("option", { value: "false", children: "False" })
5348
+ ]
5349
+ }
5350
+ );
5351
+ }
5352
+ if (type === "number") {
5353
+ return /* @__PURE__ */ jsx31(
5354
+ Input8,
5355
+ {
5356
+ type: "number",
5357
+ value: String(value ?? ""),
5358
+ onChange: (e) => updateValue(e.target.value === "" ? "" : Number(e.target.value)),
4905
5359
  fullWidth: true,
4906
- readOnly: true
5360
+ readOnly: !editable
4907
5361
  }
4908
- ) })
4909
- ] }, p.id)),
4910
- editable && /* @__PURE__ */ jsx29(Button10, { variant: "secondary", size: "sm", onClick: addProvider, children: "+ Add provider" }),
4911
- /* @__PURE__ */ jsx29("h4", { className: "lace-panel-section-title", children: "Backend" }),
4912
- /* @__PURE__ */ jsx29("div", { className: "lace-panel-hint", children: "Terraform state is managed by Lace Cloud. The HTTP backend is configured automatically during generation." }),
4913
- editable && /* @__PURE__ */ jsx29(UpdateButton, { status: updateStatus, label: "Update configuration", onClick: handleUpdate })
4914
- ] });
4915
- }
4916
- function TerraformConfigPanel({ terraform, onSave, onClose }) {
4917
- return /* @__PURE__ */ jsx29(Panel6, { title: "Terraform Configuration", onClose, children: /* @__PURE__ */ jsx29(TerraformConfigContent, { terraform, onSave }) });
4918
- }
4919
-
4920
- // src/components/panels/UnifiedSettingsPanel.tsx
4921
- import { jsx as jsx30, jsxs as jsxs20 } from "react/jsx-runtime";
4922
- function assertApplied(result) {
4923
- if (!result?.success) throw new Error("apply failed");
4924
- }
4925
- function UnifiedSettingsPanel({ onClose, onSaved }) {
4926
- const { ctx, bundle, runner, editable } = useCanvas();
4927
- const settings = useMemo9(() => deriveSettingsConfig(bundle), [bundle]);
4928
- return /* @__PURE__ */ jsxs20(Panel7, { title: "Settings", flush: true, onClose, children: [
4929
- /* @__PURE__ */ jsx30(AccordionSection, { title: "Interface", defaultOpen: true, children: /* @__PURE__ */ jsx30(
4930
- ModuleInterfaceContent,
4931
- {
4932
- settings,
4933
- view: ctx.view,
4934
- onSaveVariables: async (variables) => {
4935
- if (!editable) return;
4936
- const result = await runner.apply([
4937
- {
4938
- set_variables: {
4939
- variables: variables.map((v) => ({
4940
- name: v.name,
4941
- type: v.type,
4942
- required: v.required,
4943
- description: v.description ?? "",
4944
- default_value: v.default,
4945
- validation: v.validation ?? [],
4946
- ephemeral: v.ephemeral,
4947
- nullable: v.nullable,
4948
- sensitive: v.sensitive ?? false
4949
- }))
4950
- }
4951
- }
4952
- ]);
4953
- assertApplied(result);
4954
- onSaved?.();
4955
- },
4956
- onSaveExports: async (exports, outputDefs) => {
4957
- if (!editable) return;
4958
- const result = await runner.apply([
4959
- {
4960
- set_exports: {
4961
- outputs: exports,
4962
- output_defs: outputDefs.map((d) => ({
4963
- name: d.name,
4964
- type: d.type,
4965
- description: d.description ?? "",
4966
- sensitive: d.sensitive ?? false,
4967
- depends_on: d.depends_on ?? []
4968
- }))
4969
- }
5362
+ );
5363
+ }
5364
+ if (type.startsWith("list(") || type.startsWith("map(") || type.startsWith("set(") || type === "object" || type.startsWith("object(")) {
5365
+ const jsonStr = typeof value === "string" ? value : JSON.stringify(value ?? null, null, 2);
5366
+ return /* @__PURE__ */ jsx31(
5367
+ Textarea3,
5368
+ {
5369
+ value: jsonStr,
5370
+ onChange: (e) => {
5371
+ try {
5372
+ updateValue(JSON.parse(e.target.value));
5373
+ } catch {
5374
+ updateValue(e.target.value);
4970
5375
  }
4971
- ]);
4972
- assertApplied(result);
4973
- onSaved?.();
5376
+ },
5377
+ rows: 4,
5378
+ fullWidth: true,
5379
+ mono: true,
5380
+ readOnly: !editable
4974
5381
  }
4975
- }
4976
- ) }),
4977
- /* @__PURE__ */ jsx30(AccordionSection, { title: "Terraform Config", children: /* @__PURE__ */ jsx30(
4978
- TerraformConfigContent,
5382
+ );
5383
+ }
5384
+ return /* @__PURE__ */ jsx31(
5385
+ Input8,
4979
5386
  {
4980
- terraform: settings.terraform,
4981
- onSave: async (terraform) => {
4982
- if (!editable) return;
4983
- const result = await runner.apply([
4984
- {
4985
- set_terraform: {
4986
- required_version: terraform.required_version,
4987
- required_providers: terraform.required_providers.map((p) => ({
4988
- name: p.name,
4989
- source: p.source,
4990
- version: p.version,
4991
- configuration_aliases: p.configuration_aliases ?? []
4992
- })),
4993
- backend: void 0
4994
- }
4995
- }
4996
- ]);
4997
- assertApplied(result);
4998
- onSaved?.();
4999
- }
5387
+ value: String(value ?? ""),
5388
+ onChange: (e) => {
5389
+ let v = e.target.value;
5390
+ if (v.length >= 2 && (v[0] === '"' && v[v.length - 1] === '"' || v[0] === "'" && v[v.length - 1] === "'")) {
5391
+ v = v.slice(1, -1);
5392
+ }
5393
+ updateValue(v);
5394
+ },
5395
+ fullWidth: true,
5396
+ readOnly: !editable
5000
5397
  }
5001
- ) }),
5002
- /* @__PURE__ */ jsx30(AccordionSection, { title: "Providers", children: /* @__PURE__ */ jsx30(
5003
- ProvidersContent,
5398
+ );
5399
+ }
5400
+ if (!config) {
5401
+ return /* @__PURE__ */ jsxs22(Panel6, { title: "Error", onClose, children: [
5402
+ /* @__PURE__ */ jsxs22("div", { className: "lace-mcp__error-title", children: [
5403
+ 'Failed to load configuration for "',
5404
+ instance_id,
5405
+ '":'
5406
+ ] }),
5407
+ /* @__PURE__ */ jsx31("div", { className: "lace-mcp__error-detail", children: "Instance not found in the current Bundle." })
5408
+ ] });
5409
+ }
5410
+ const dependsOnCount = localDependsOn.size;
5411
+ const title = /* @__PURE__ */ jsxs22("div", { className: "lace-mcp__title", children: [
5412
+ /* @__PURE__ */ jsx31("div", { className: "lace-mcp__title-eyebrow", children: "Module" }),
5413
+ /* @__PURE__ */ jsx31("h3", { className: "lace-mcp__title-id", children: /* @__PURE__ */ jsx31(Identifier, { text: instance_id }) })
5414
+ ] });
5415
+ const footer = editable ? /* @__PURE__ */ jsx31(UpdateButton, { status: updateStatus, label: "Update configuration", onClick: handleUpdate }) : void 0;
5416
+ return /* @__PURE__ */ jsxs22(Panel6, { title, footer, flush: true, onClose, children: [
5417
+ requiredInputs.length > 0 && /* @__PURE__ */ jsx31(AccordionSection, { title: "Required Inputs", defaultOpen: true, badge: `(${requiredInputs.length})`, children: requiredInputs.map(renderInputField) }),
5418
+ optionalInputs.length > 0 && /* @__PURE__ */ jsx31(AccordionSection, { title: "Optional Inputs", defaultOpen: true, badge: `(${optionalInputs.length})`, children: optionalInputs.map(renderInputField) }),
5419
+ config.sibling_ids.length > 0 && /* @__PURE__ */ jsxs22(
5420
+ AccordionSection,
5004
5421
  {
5005
- providers: settings.providers,
5006
- onSave: async (providers) => {
5007
- if (!editable) return;
5008
- const result = await runner.apply([
5009
- {
5010
- set_providers: {
5011
- providers: providers.map((p) => ({
5012
- name: p.name,
5013
- alias: p.alias ?? "",
5014
- config: p.config,
5015
- blocks: p.blocks ?? []
5016
- }))
5017
- }
5018
- }
5019
- ]);
5020
- assertApplied(result);
5021
- onSaved?.();
5022
- }
5422
+ title: "Depends On",
5423
+ badge: dependsOnCount > 0 ? `(${dependsOnCount})` : void 0,
5424
+ children: [
5425
+ /* @__PURE__ */ jsx31("div", { className: "lace-mcp__depends-hint", children: "Select sibling instances this module depends on." }),
5426
+ config.sibling_ids.map((sibId) => {
5427
+ const depKey = `module.${sibId}`;
5428
+ return /* @__PURE__ */ jsxs22("label", { className: "lace-mcp__depends-item", children: [
5429
+ /* @__PURE__ */ jsx31(
5430
+ "input",
5431
+ {
5432
+ type: "checkbox",
5433
+ className: "lace-mcp__depends-checkbox",
5434
+ checked: localDependsOn.has(depKey),
5435
+ disabled: !editable,
5436
+ onChange: (e) => {
5437
+ setLocalDependsOn((prev) => {
5438
+ const next = new Set(prev);
5439
+ if (e.target.checked) next.add(depKey);
5440
+ else next.delete(depKey);
5441
+ return next;
5442
+ });
5443
+ }
5444
+ }
5445
+ ),
5446
+ /* @__PURE__ */ jsx31(Identifier, { className: "lace-mcp__depends-label", text: depKey })
5447
+ ] }, sibId);
5448
+ })
5449
+ ]
5023
5450
  }
5024
- ) }),
5025
- /* @__PURE__ */ jsx30(AccordionSection, { title: "Locals", children: /* @__PURE__ */ jsx30(
5026
- LocalsContent,
5451
+ ),
5452
+ (localProviders.length > 0 || editable) && /* @__PURE__ */ jsxs22(
5453
+ AccordionSection,
5027
5454
  {
5028
- locals: settings.locals,
5029
- onSave: async (locals) => {
5030
- if (!editable) return;
5031
- const result = await runner.apply([
5455
+ title: "Providers",
5456
+ badge: localProviders.length > 0 ? `(${localProviders.length})` : void 0,
5457
+ children: [
5458
+ /* @__PURE__ */ jsxs22("div", { className: "lace-mcp__depends-hint", children: [
5459
+ "Map each child-local provider name to the root provider reference passed down (e.g.",
5460
+ " ",
5461
+ /* @__PURE__ */ jsx31("code", { children: "aws" }),
5462
+ " \u2192 ",
5463
+ /* @__PURE__ */ jsx31("code", { children: "aws.west" }),
5464
+ ")."
5465
+ ] }),
5466
+ localProviders.map((row, i) => (
5467
+ // biome-ignore lint/suspicious/noArrayIndexKey: rows are positional and freely editable
5468
+ /* @__PURE__ */ jsxs22("div", { className: "lace-mcp__provider-row", children: [
5469
+ /* @__PURE__ */ jsx31(
5470
+ Input8,
5471
+ {
5472
+ value: row.key,
5473
+ onChange: (e) => setLocalProviders(
5474
+ (prev) => prev.map((r, j) => j === i ? { ...r, key: e.target.value } : r)
5475
+ ),
5476
+ placeholder: "child local (e.g. aws)",
5477
+ mono: true,
5478
+ readOnly: !editable
5479
+ }
5480
+ ),
5481
+ /* @__PURE__ */ jsx31("span", { className: "lace-mcp__provider-arrow", children: "=" }),
5482
+ /* @__PURE__ */ jsx31(
5483
+ Input8,
5484
+ {
5485
+ value: row.value,
5486
+ onChange: (e) => setLocalProviders(
5487
+ (prev) => prev.map((r, j) => j === i ? { ...r, value: e.target.value } : r)
5488
+ ),
5489
+ placeholder: "root ref (e.g. aws.west)",
5490
+ mono: true,
5491
+ readOnly: !editable
5492
+ }
5493
+ ),
5494
+ editable && /* @__PURE__ */ jsx31(
5495
+ IconButton9,
5496
+ {
5497
+ icon: /* @__PURE__ */ jsx31(CanvasIcon, { name: "close" }),
5498
+ "aria-label": "Remove this provider mapping",
5499
+ size: "md",
5500
+ tooltipPlacement: "bottom-end",
5501
+ onClick: () => setLocalProviders((prev) => prev.filter((_, j) => j !== i))
5502
+ }
5503
+ )
5504
+ ] }, i)
5505
+ )),
5506
+ editable && /* @__PURE__ */ jsx31(
5507
+ Button12,
5032
5508
  {
5033
- set_locals: {
5034
- locals: locals.map((l) => {
5035
- if (l.mode === "expression") {
5036
- return {
5037
- name: l.name,
5038
- mode: l.mode,
5039
- expression: l.value_display,
5040
- value: void 0,
5041
- variable: ""
5042
- };
5043
- }
5044
- let value = l.value_display;
5045
- try {
5046
- value = JSON.parse(l.value_display);
5047
- } catch {
5048
- }
5049
- return { name: l.name, mode: l.mode, value, expression: "", variable: "" };
5050
- })
5051
- }
5509
+ variant: "secondary",
5510
+ size: "sm",
5511
+ onClick: () => setLocalProviders((prev) => [...prev, { key: "", value: "" }]),
5512
+ children: "Add provider mapping"
5052
5513
  }
5053
- ]);
5054
- assertApplied(result);
5055
- onSaved?.();
5056
- }
5514
+ )
5515
+ ]
5057
5516
  }
5058
- ) })
5517
+ ),
5518
+ (localRepetition.count || localRepetition.for_each || editable) && /* @__PURE__ */ jsxs22(AccordionSection, { title: "Repetition", children: [
5519
+ /* @__PURE__ */ jsxs22("div", { className: "lace-mcp__depends-hint", children: [
5520
+ "The call's ",
5521
+ /* @__PURE__ */ jsx31("code", { children: "count" }),
5522
+ " or ",
5523
+ /* @__PURE__ */ jsx31("code", { children: "for_each" }),
5524
+ ": one module, called once per instance."
5525
+ ] }),
5526
+ /* @__PURE__ */ jsx31(
5527
+ Input8,
5528
+ {
5529
+ label: "count",
5530
+ value: localRepetition.count,
5531
+ onChange: (e) => setLocalRepetition((prev) => ({ ...prev, count: e.target.value })),
5532
+ placeholder: "e.g. 2 or var.instances",
5533
+ fullWidth: true,
5534
+ mono: true,
5535
+ readOnly: !editable
5536
+ }
5537
+ ),
5538
+ /* @__PURE__ */ jsx31(
5539
+ Input8,
5540
+ {
5541
+ label: "for_each",
5542
+ value: localRepetition.for_each,
5543
+ onChange: (e) => setLocalRepetition((prev) => ({ ...prev, for_each: e.target.value })),
5544
+ placeholder: "e.g. var.regions",
5545
+ fullWidth: true,
5546
+ mono: true,
5547
+ readOnly: !editable
5548
+ }
5549
+ )
5550
+ ] }),
5551
+ config.outputs.length > 0 && /* @__PURE__ */ jsx31(AccordionSection, { title: "Outputs", badge: `(${config.outputs.length})`, children: config.outputs.map((o) => /* @__PURE__ */ jsxs22("div", { className: "lace-mcp__output-card", children: [
5552
+ /* @__PURE__ */ jsxs22("div", { className: "lace-mcp__output-header", children: [
5553
+ /* @__PURE__ */ jsx31(Identifier, { className: "lace-mcp__output-name", text: o.name }),
5554
+ /* @__PURE__ */ jsx31(Identifier, { className: "lace-mcp__output-type", text: o.type ?? "" })
5555
+ ] }),
5556
+ o.description && /* @__PURE__ */ jsx31("div", { className: "lace-mcp__output-description", children: o.description }),
5557
+ o.sensitive && /* @__PURE__ */ jsx31("div", { className: "lace-mcp__output-sensitive", children: "sensitive" })
5558
+ ] }, o.name)) }),
5559
+ config.module_key && /* @__PURE__ */ jsxs22(Fragment13, { children: [
5560
+ /* @__PURE__ */ jsxs22("div", { className: "lace-mcp__module-heading", children: [
5561
+ /* @__PURE__ */ jsx31("div", { className: "lace-mcp__title-eyebrow", children: "Called module" }),
5562
+ /* @__PURE__ */ jsx31(Identifier, { text: config.module_key })
5563
+ ] }),
5564
+ /* @__PURE__ */ jsx31(ModuleDetails, { moduleKey: config.module_key }, config.module_key)
5565
+ ] })
5059
5566
  ] });
5060
5567
  }
5061
5568
 
5569
+ // src/core/panels/module-config.ts
5570
+ function ModuleConfigPanel2({ ctx }) {
5571
+ const { setSelection } = useCanvas();
5572
+ const instanceId = ctx.selection.nodes[0];
5573
+ if (!instanceId) return null;
5574
+ return createElement2(ModuleConfigPanel, {
5575
+ instance_id: instanceId,
5576
+ onClose: () => setSelection({ nodes: [], edge: null })
5577
+ });
5578
+ }
5579
+ var moduleConfigPanel = {
5580
+ id: "module-config",
5581
+ title: "Module",
5582
+ slot: "drawer",
5583
+ requiredPorts: [],
5584
+ requiredContext: ["selection.node"],
5585
+ Component: ModuleConfigPanel2
5586
+ };
5587
+
5588
+ // src/core/panels/SourceRefusedBanner.tsx
5589
+ import { Button as Button13 } from "@lace-cloud/ui";
5590
+ import { jsx as jsx32 } from "react/jsx-runtime";
5591
+ function SourceRefusedBanner({ ctx }) {
5592
+ const { runner } = useCanvas();
5593
+ const envExtras = useEditorEnvExtras();
5594
+ if (!keySatisfied(ctx, "needsConversion")) {
5595
+ return /* @__PURE__ */ jsx32(
5596
+ Banner,
5597
+ {
5598
+ severity: "error",
5599
+ className: "lace-source-refused-banner",
5600
+ message: "The canvas can't take this module's .tf, so editing, saving and generating are locked until it can; the Diagnostics tab says why."
5601
+ }
5602
+ );
5603
+ }
5604
+ const actions = rowActionsFor(ctx, "source-refused");
5605
+ return /* @__PURE__ */ jsx32(
5606
+ Banner,
5607
+ {
5608
+ severity: "error",
5609
+ className: "lace-source-refused-banner lace-source-refused-banner--needs-conversion",
5610
+ message: "Needs conversion: this module's .tf is not in lace shape, so the canvas shows it read-only. Convert composes each managed resource the Diagnostics tab names into a module of its own.",
5611
+ actions: actions.map((action) => /* @__PURE__ */ jsx32(
5612
+ Button13,
5613
+ {
5614
+ rung: true,
5615
+ size: "sm",
5616
+ variant: "primary",
5617
+ className: `lace-source-refused-banner__${action.id}`,
5618
+ onClick: () => void runner.run(action, ctx, {}, envExtras),
5619
+ children: action.label
5620
+ },
5621
+ action.id
5622
+ ))
5623
+ }
5624
+ );
5625
+ }
5626
+ var sourceRefusedPanel = {
5627
+ id: "source-refused",
5628
+ title: "Source refused",
5629
+ slot: "banner",
5630
+ requiredPorts: [],
5631
+ requiredContext: ["sourceRefused"],
5632
+ Component: SourceRefusedBanner
5633
+ };
5634
+
5635
+ // src/core/panels/settings.ts
5636
+ import { IconButton as IconButton10 } from "@lace-cloud/ui";
5637
+ import { createElement as createElement3 } from "react";
5638
+
5639
+ // src/components/panels/UnifiedSettingsPanel.tsx
5640
+ import { Panel as Panel7 } from "@lace-cloud/ui";
5641
+ import "./panels-shared-5JFNYXQ7.css";
5642
+ import { jsx as jsx33 } from "react/jsx-runtime";
5643
+ function UnifiedSettingsPanel({ onClose }) {
5644
+ const { bundle } = useCanvas();
5645
+ return /* @__PURE__ */ jsx33(Panel7, { title: "Settings", flush: true, onClose, children: /* @__PURE__ */ jsx33(ModuleDetails, { moduleKey: bundle.entry, open: ["Interface"] }, bundle.entry) });
5646
+ }
5647
+
5062
5648
  // src/core/panels/settings.ts
5063
5649
  function SettingsPanel(_props) {
5064
5650
  const { setSettingsOpen } = useCanvas();
@@ -5070,17 +5656,13 @@ var settingsPanel = {
5070
5656
  id: "settings",
5071
5657
  title: "Settings",
5072
5658
  slot: "drawer",
5073
- // The settings panel edits IR-backed config — the same `editor` gate
5074
- // Save/Generate carry — so a portal-shaped host (no editor) never draws
5075
- // it at all; and it draws only while open, so no drawer stands empty
5076
- // beside the canvas.
5077
- requiredPorts: ["editor"],
5659
+ requiredPorts: [],
5078
5660
  requiredContext: ["settingsOpen"],
5079
5661
  Component: SettingsPanel
5080
5662
  };
5081
5663
  function SettingsToggle({ ctx }) {
5082
5664
  const { setSettingsOpen } = useCanvas();
5083
- return createElement3(IconButton8, {
5665
+ return createElement3(IconButton10, {
5084
5666
  icon: createElement3(CanvasIcon, { name: "settings" }),
5085
5667
  "aria-label": "Settings",
5086
5668
  size: "md",
@@ -5093,7 +5675,7 @@ var settingsToggle = {
5093
5675
  id: "settings-toggle",
5094
5676
  title: "Settings",
5095
5677
  slot: "toolbar",
5096
- requiredPorts: ["editor"],
5678
+ requiredPorts: [],
5097
5679
  Component: SettingsToggle
5098
5680
  };
5099
5681
 
@@ -5117,7 +5699,7 @@ var CORE_CONTRIBUTIONS = {
5117
5699
  };
5118
5700
 
5119
5701
  // src/App.tsx
5120
- import { jsx as jsx31, jsxs as jsxs21 } from "react/jsx-runtime";
5702
+ import { jsx as jsx34, jsxs as jsxs23 } from "react/jsx-runtime";
5121
5703
  var EMPTY_CONTRIBUTIONS = { overlays: [], panels: [], actions: [] };
5122
5704
  var NO_SELECTION = { nodes: [], edge: null };
5123
5705
  var NO_TARGET = {};
@@ -5128,7 +5710,7 @@ function OverlayRunner({
5128
5710
  onDecorations
5129
5711
  }) {
5130
5712
  const lastErrorRef = useRef11(/* @__PURE__ */ new Map());
5131
- const onReadError = useCallback13(
5713
+ const onReadError = useCallback14(
5132
5714
  (path, error) => {
5133
5715
  const next = error?.message ?? null;
5134
5716
  if (lastErrorRef.current.get(path) === next) return;
@@ -5137,7 +5719,7 @@ function OverlayRunner({
5137
5719
  },
5138
5720
  [ctx.ports.presenter]
5139
5721
  );
5140
- return /* @__PURE__ */ jsx31(PanelScope, { ctx, paths: overlay.paths, tick, onReadError, children: /* @__PURE__ */ jsx31(OverlayDecorations, { overlay, ctx, onDecorations }) });
5722
+ return /* @__PURE__ */ jsx34(PanelScope, { ctx, paths: overlay.paths, tick, onReadError, children: /* @__PURE__ */ jsx34(OverlayDecorations, { overlay, ctx, onDecorations }) });
5141
5723
  }
5142
5724
  function OverlayDecorations({
5143
5725
  overlay,
@@ -5151,8 +5733,8 @@ function OverlayDecorations({
5151
5733
  return null;
5152
5734
  }
5153
5735
  function PanelSlot({ panel, ctx, tick }) {
5154
- const [readErrors, setReadErrors] = useState20(/* @__PURE__ */ new Map());
5155
- const onReadError = useCallback13((path, error) => {
5736
+ const [readErrors, setReadErrors] = useState23(/* @__PURE__ */ new Map());
5737
+ const onReadError = useCallback14((path, error) => {
5156
5738
  setReadErrors((prev) => {
5157
5739
  if (error === null) {
5158
5740
  if (!prev.has(path)) return prev;
@@ -5165,7 +5747,7 @@ function PanelSlot({ panel, ctx, tick }) {
5165
5747
  return next;
5166
5748
  });
5167
5749
  }, []);
5168
- return /* @__PURE__ */ jsxs21(
5750
+ return /* @__PURE__ */ jsxs23(
5169
5751
  PanelScope,
5170
5752
  {
5171
5753
  ctx,
@@ -5173,13 +5755,13 @@ function PanelSlot({ panel, ctx, tick }) {
5173
5755
  tick,
5174
5756
  onReadError,
5175
5757
  children: [
5176
- [...readErrors].map(([path, error]) => /* @__PURE__ */ jsxs21("p", { className: "lace-app__panel-error", children: [
5758
+ [...readErrors].map(([path, error]) => /* @__PURE__ */ jsxs23("p", { className: "lace-app__panel-error", children: [
5177
5759
  "Couldn't load ",
5178
5760
  path,
5179
5761
  ": ",
5180
5762
  error.message
5181
5763
  ] }, path)),
5182
- /* @__PURE__ */ jsx31(panel.Component, { ctx })
5764
+ /* @__PURE__ */ jsx34(panel.Component, { ctx })
5183
5765
  ]
5184
5766
  }
5185
5767
  );
@@ -5189,12 +5771,12 @@ function BottomTabs({
5189
5771
  ctx,
5190
5772
  tick
5191
5773
  }) {
5192
- const [manualId, setManualId] = useState20(null);
5774
+ const [manualId, setManualId] = useState23(null);
5193
5775
  const manual = manualId !== null ? panels.find((p) => p.id === manualId) : void 0;
5194
5776
  const active = manual ?? panels[0] ?? null;
5195
5777
  if (panels.length === 0) return null;
5196
- return /* @__PURE__ */ jsxs21("div", { className: "lace-app__bottom", children: [
5197
- /* @__PURE__ */ jsx31("div", { className: "lace-app__bottom-tabs", role: "tablist", children: panels.map((panel) => /* @__PURE__ */ jsx31(
5778
+ return /* @__PURE__ */ jsxs23("div", { className: "lace-app__bottom", children: [
5779
+ /* @__PURE__ */ jsx34("div", { className: "lace-app__bottom-tabs", role: "tablist", children: panels.map((panel) => /* @__PURE__ */ jsx34(
5198
5780
  "button",
5199
5781
  {
5200
5782
  type: "button",
@@ -5206,7 +5788,7 @@ function BottomTabs({
5206
5788
  },
5207
5789
  panel.id
5208
5790
  )) }),
5209
- /* @__PURE__ */ jsx31("div", { className: "lace-app__bottom-content", children: active && /* @__PURE__ */ jsx31(PanelSlot, { panel: active, ctx, tick }) })
5791
+ /* @__PURE__ */ jsx34("div", { className: "lace-app__bottom-content", children: active && /* @__PURE__ */ jsx34(PanelSlot, { panel: active, ctx, tick }) })
5210
5792
  ] });
5211
5793
  }
5212
5794
  function endMessage(end) {
@@ -5218,8 +5800,8 @@ function App({
5218
5800
  height = "100vh",
5219
5801
  results: hostResults
5220
5802
  }) {
5221
- const results = useMemo10(() => hostResults ?? createResultStore(), [hostResults]);
5222
- const writeReport = useCallback13(
5803
+ const results = useMemo9(() => hostResults ?? createResultStore(), [hostResults]);
5804
+ const writeReport = useCallback14(
5223
5805
  (result, session2) => {
5224
5806
  try {
5225
5807
  results.write("report", session2, result, { stack: void 0 });
@@ -5230,24 +5812,24 @@ function App({
5230
5812
  },
5231
5813
  [results, ports.presenter]
5232
5814
  );
5233
- const dropReport = useCallback13((session2) => results.detach("report", session2), [results]);
5815
+ const dropReport = useCallback14((session2) => results.detach("report", session2), [results]);
5234
5816
  const { source, end, session } = useCanvasSource(ports.source, writeReport, dropReport);
5235
- const [arrangement, setArrangement] = useState20(() => ports.viewState.load());
5817
+ const [arrangement, setArrangement] = useState23(() => ports.viewState.load());
5236
5818
  const stack = ports.context.stack;
5237
- const [selection, setSelection] = useState20(
5819
+ const [selection, setSelection] = useState23(
5238
5820
  NO_SELECTION
5239
5821
  );
5240
- const [settingsOpen, setSettingsOpen] = useState20(false);
5241
- const select = useCallback13((next) => {
5822
+ const [settingsOpen, setSettingsOpen] = useState23(false);
5823
+ const select = useCallback14((next) => {
5242
5824
  setSelection(next);
5243
5825
  if (next.nodes.length > 0 || next.edge !== null) setSettingsOpen(false);
5244
5826
  }, []);
5245
- const [pendingForm, setPendingForm] = useState20(null);
5246
- const [overlayDecorations, setOverlayDecorations] = useState20({});
5827
+ const [pendingForm, setPendingForm] = useState23(null);
5828
+ const [overlayDecorations, setOverlayDecorations] = useState23({});
5247
5829
  const layoutRef = useRef11({ panIntoView: () => {
5248
5830
  } });
5249
5831
  const { commands, presenter, editor } = ports;
5250
- const runner = useMemo10(
5832
+ const runner = useMemo9(
5251
5833
  () => createActionRunner({ commands, presenter, editor }, results, {
5252
5834
  onPendingFormChange: setPendingForm
5253
5835
  }),
@@ -5259,7 +5841,7 @@ function App({
5259
5841
  };
5260
5842
  }, [runner]);
5261
5843
  const tick = useSyncExternalStore(results.subscribe, results.getTick);
5262
- const updateArrangement = useCallback13(
5844
+ const updateArrangement = useCallback14(
5263
5845
  (next) => {
5264
5846
  setArrangement(next);
5265
5847
  ports.viewState.save(next);
@@ -5277,12 +5859,12 @@ function App({
5277
5859
  });
5278
5860
  }
5279
5861
  }
5280
- const view = useMemo10(
5862
+ const view = useMemo9(
5281
5863
  () => source ? projectFrame(source, arrangement) : null,
5282
5864
  [source, arrangement]
5283
5865
  );
5284
5866
  const editable = ports.editor !== void 0 && !source?.sourceRefused;
5285
- const merged = useMemo10(
5867
+ const merged = useMemo9(
5286
5868
  () => ({
5287
5869
  overlays: [...CORE_CONTRIBUTIONS.overlays, ...contributions.overlays],
5288
5870
  panels: [...CORE_CONTRIBUTIONS.panels, ...contributions.panels],
@@ -5292,15 +5874,15 @@ function App({
5292
5874
  );
5293
5875
  const resultSlots = useSyncExternalStore(results.subscribe, results.getSnapshot);
5294
5876
  const stackId = stack?.id;
5295
- const live = useMemo10(
5877
+ const live = useMemo9(
5296
5878
  () => source && session ? liveSlots(resultSlots, { session, treeHash: source.treeHash, stack: stackId }) : null,
5297
5879
  [resultSlots, source, session, stackId]
5298
5880
  );
5299
- const diagnostics = useMemo10(
5881
+ const diagnostics = useMemo9(
5300
5882
  () => source && live ? diagnosticsOf(source.diagnostics, live.report ? reportDiagnostics(live.report) : []) : [],
5301
5883
  [source, live]
5302
5884
  );
5303
- const ctx = useMemo10(() => {
5885
+ const ctx = useMemo9(() => {
5304
5886
  if (!source || !view) return null;
5305
5887
  return {
5306
5888
  ports,
@@ -5317,18 +5899,18 @@ function App({
5317
5899
  contributions: merged
5318
5900
  };
5319
5901
  }, [ports, source, view, stack, selection, settingsOpen, merged, diagnostics, editable]);
5320
- const resolved = useMemo10(() => {
5902
+ const resolved = useMemo9(() => {
5321
5903
  if (!ctx) return EMPTY_CONTRIBUTIONS;
5322
5904
  return resolveContributions(merged, ports, ctx, NO_TARGET);
5323
5905
  }, [merged, ports, ctx]);
5324
- const setOverlayDecoration = useCallback13((id, next) => {
5906
+ const setOverlayDecoration = useCallback14((id, next) => {
5325
5907
  setOverlayDecorations((prev) => prev[id] === next ? prev : { ...prev, [id]: next });
5326
5908
  }, []);
5327
- const decorations = useMemo10(() => {
5909
+ const decorations = useMemo9(() => {
5328
5910
  if (!view || !source) return { nodes: {} };
5329
5911
  return decorate(view, Object.values(overlayDecorations), diagnostics);
5330
5912
  }, [view, source, overlayDecorations, diagnostics]);
5331
- const envExtras = useMemo10(() => {
5913
+ const envExtras = useMemo9(() => {
5332
5914
  if (!source) return null;
5333
5915
  return {
5334
5916
  bundle: source.bundle,
@@ -5349,7 +5931,7 @@ function App({
5349
5931
  useFocusWhenNoneHeld(rootRef, Boolean(ctx && view && source && envExtras));
5350
5932
  useActionKeys(ctx && envExtras ? resolved.actions : [], ctx, runner, envExtras);
5351
5933
  if (!ctx || !view || !source || !envExtras) {
5352
- return end ? /* @__PURE__ */ jsx31(ErrorState, { message: endMessage(end) }) : null;
5934
+ return end ? /* @__PURE__ */ jsx34(ErrorState, { message: endMessage(end) }) : null;
5353
5935
  }
5354
5936
  const contextValue = {
5355
5937
  ports,
@@ -5369,8 +5951,8 @@ function App({
5369
5951
  const bannerPanels = resolved.panels.filter((panel) => panel.slot === "banner");
5370
5952
  const bottomPanels = resolved.panels.filter((panel) => panel.slot === "bottom");
5371
5953
  const drawerPanel = resolved.panels.find((panel) => panel.slot === "drawer");
5372
- return /* @__PURE__ */ jsxs21(ErrorBoundary, { children: [
5373
- resolved.overlays.map((overlay) => /* @__PURE__ */ jsx31(
5954
+ return /* @__PURE__ */ jsxs23(ErrorBoundary, { children: [
5955
+ resolved.overlays.map((overlay) => /* @__PURE__ */ jsx34(
5374
5956
  OverlayRunner,
5375
5957
  {
5376
5958
  overlay,
@@ -5380,14 +5962,14 @@ function App({
5380
5962
  },
5381
5963
  overlay.id
5382
5964
  )),
5383
- /* @__PURE__ */ jsx31(CanvasContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs21("div", { ref: rootRef, className: "lace-app", style: { height }, tabIndex: -1, children: [
5384
- (toolbar.sections.length > 0 || toolbar.trailing.length > 0) && /* @__PURE__ */ jsxs21("div", { className: "lace-app__toolbar", children: [
5385
- toolbar.sections.map((section, index) => /* @__PURE__ */ jsxs21(Fragment10, { children: [
5386
- index > 0 ? /* @__PURE__ */ jsx31("span", { className: "lace-app__toolbar-separator", "aria-hidden": "true" }) : null,
5387
- /* @__PURE__ */ jsxs21("div", { className: "lace-app__toolbar-section", children: [
5965
+ /* @__PURE__ */ jsx34(CanvasContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs23("div", { ref: rootRef, className: "lace-app", style: { height }, tabIndex: -1, children: [
5966
+ (toolbar.sections.length > 0 || toolbar.trailing.length > 0) && /* @__PURE__ */ jsxs23("div", { className: "lace-app__toolbar", children: [
5967
+ toolbar.sections.map((section, index) => /* @__PURE__ */ jsxs23(Fragment14, { children: [
5968
+ index > 0 ? /* @__PURE__ */ jsx34("span", { className: "lace-app__toolbar-separator", "aria-hidden": "true" }) : null,
5969
+ /* @__PURE__ */ jsxs23("div", { className: "lace-app__toolbar-section", children: [
5388
5970
  section.actions.map((action) => {
5389
5971
  const commandBusy = action.binding.kind === "command" && results.isBusy(action.binding.resultKind);
5390
- return /* @__PURE__ */ jsx31(
5972
+ return /* @__PURE__ */ jsx34(
5391
5973
  ToolbarAction,
5392
5974
  {
5393
5975
  action,
@@ -5399,20 +5981,20 @@ function App({
5399
5981
  action.id
5400
5982
  );
5401
5983
  }),
5402
- section.panels.map((panel) => /* @__PURE__ */ jsx31(PanelSlot, { panel, ctx, tick }, panel.id))
5984
+ section.panels.map((panel) => /* @__PURE__ */ jsx34(PanelSlot, { panel, ctx, tick }, panel.id))
5403
5985
  ] })
5404
5986
  ] }, section.key ?? "")),
5405
- toolbar.trailing.length > 0 && /* @__PURE__ */ jsx31("div", { className: "lace-app__toolbar-end", children: toolbar.trailing.map((panel) => /* @__PURE__ */ jsx31(PanelSlot, { panel, ctx, tick }, panel.id)) })
5987
+ toolbar.trailing.length > 0 && /* @__PURE__ */ jsx34("div", { className: "lace-app__toolbar-end", children: toolbar.trailing.map((panel) => /* @__PURE__ */ jsx34(PanelSlot, { panel, ctx, tick }, panel.id)) })
5406
5988
  ] }),
5407
- /* @__PURE__ */ jsx31("div", { className: "lace-app__banners", children: bannerPanels.map((panel) => /* @__PURE__ */ jsx31(PanelSlot, { panel, ctx, tick }, panel.id)) }),
5408
- /* @__PURE__ */ jsxs21("div", { className: "lace-app__body", children: [
5409
- /* @__PURE__ */ jsxs21("div", { className: "lace-app__main", children: [
5410
- /* @__PURE__ */ jsx31("div", { className: "lace-app__canvas", children: /* @__PURE__ */ jsx31(ReactFlowProvider, { children: /* @__PURE__ */ jsx31(Canvas, { height: "100%" }) }) }),
5411
- /* @__PURE__ */ jsx31(BottomTabs, { panels: bottomPanels, ctx, tick })
5989
+ /* @__PURE__ */ jsx34("div", { className: "lace-app__banners", children: bannerPanels.map((panel) => /* @__PURE__ */ jsx34(PanelSlot, { panel, ctx, tick }, panel.id)) }),
5990
+ /* @__PURE__ */ jsxs23("div", { className: "lace-app__body", children: [
5991
+ /* @__PURE__ */ jsxs23("div", { className: "lace-app__main", children: [
5992
+ /* @__PURE__ */ jsx34("div", { className: "lace-app__canvas", children: /* @__PURE__ */ jsx34(ReactFlowProvider, { children: /* @__PURE__ */ jsx34(Canvas, { height: "100%" }) }) }),
5993
+ /* @__PURE__ */ jsx34(BottomTabs, { panels: bottomPanels, ctx, tick })
5412
5994
  ] }),
5413
- drawerPanel && /* @__PURE__ */ jsx31(Drawer, { label: drawerPanel.title, children: /* @__PURE__ */ jsx31(PanelSlot, { panel: drawerPanel, ctx, tick }, drawerPanel.id) })
5995
+ drawerPanel && /* @__PURE__ */ jsx34(Drawer, { label: drawerPanel.title, children: /* @__PURE__ */ jsx34(PanelSlot, { panel: drawerPanel, ctx, tick }, drawerPanel.id) })
5414
5996
  ] }),
5415
- /* @__PURE__ */ jsx31(CommandArgsForm, { form: pendingForm })
5997
+ /* @__PURE__ */ jsx34(CommandArgsForm, { form: pendingForm })
5416
5998
  ] }) })
5417
5999
  ] });
5418
6000
  }