{{-- Recursive tree-node partial. ─────────────────────────── Renders one node + its connector lines to children. Children are rendered by re-including this partial — the call chain builds the whole tree without ever leaving Blade. Expected `$node` shape (from `Edit::buildFlowTree`): ['kind' => 'node', 'step' => [...], 'index' => int, 'children' => [{label, node}, ...]] ['kind' => 'missing', 'step_key' => string] ['kind' => 'unset', 'option_label' => string] ['kind' => 'jump', 'step_key' => string] Optional `$selectedStepIndex` (passed through) is used to ring the currently-edited node. Layout strategy: pure CSS family-tree pattern. • Parent node is centered. • Below it, a vertical drop line (4 units tall). • Below that, a `.children-row` flex of equal-width columns. • Each column has its own vertical drop line on top + a horizontal "spanner" line connecting siblings (drawn via `border-t` on each column, then clipped on first / last to produce the inverted-U shape). • Recursion continues inside each column. --}} @php /** @var array{kind:string, ...} $node */ $kind = $node['kind'] ?? 'node'; // Stable identity for Livewire morphdom — every branch below // owns a wire:key derived from the canonical step_key (or // option label for the "unset target" pseudo-node). Without // stable keys, Livewire's diff can reuse a sibling's DOM into // a different array index, which manifests as "I edited step // N but step N-1 also picked up the change" on save. The keys // here MUST line up with the parent's loop so each child // column is uniquely identifiable across renders. $nodeWireKey = match ($kind) { 'missing' => 'flow-tree-missing-'.($node['step_key'] ?? 'unknown'), 'unset' => 'flow-tree-unset-'.($node['option_label'] ?? 'option'), 'jump' => 'flow-tree-jump-'.($node['step_key'] ?? 'unknown'), default => 'flow-tree-node-'.($node['step']['step_key'] ?? ($node['index'] ?? 'unknown')), }; @endphp @if ($kind === 'missing') {{-- Red placeholder node — the parent's `next` references a step_key that doesn't exist in $steps. Operator action: either create the step or rewire the pointer. --}}